Marlin  01.17.01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MarlinSteerCheck.h
Go to the documentation of this file.
1 #ifndef MARLINSTEERCHECK_H
2 #define MARLINSTEERCHECK_H
3 
4 #include "marlin/CCProcessor.h"
5 #include "marlin/CCCollection.h"
6 #include "marlin/CMProcessor.h"
7 #include "marlin/XMLParser.h"
8 
9 //comment out the line below if your terminal
10 //doesn't support colored output
11 #define TERM_COLOR
12 
13 #ifdef TERM_COLOR
14 
15 #define clrscr() printf("\033[2J")
16 #define dblue() printf("\x1b[34m")
17 #define dred() printf("\x1b[31m")
18 #define dyellow() printf("\x1b[33m")
19 #define dgreen() printf("\x1b[32m")
20 #define dunderline() printf("\x1b[4m")
21 #define ditalic() printf("\x1b[3m")
22 #define ddunkel() printf("\x1b[2m")
23 #define dhell() printf("\x1b[1m")
24 #define dblink() printf("\x1b[5m")
25 #define endcolor() printf("\x1b[m")
26 
27 #else
28 
29 #define clrscr()
30 #define dblue()
31 #define dred()
32 #define dyellow()
33 #define dgreen()
34 #define dunderline()
35 #define ditalic()
36 #define ddunkel()
37 #define dhell()
38 #define dblink()
39 #define endcolor()
40 
41 #endif
42 
43 #define MAXEVENTS 30
44 
45 namespace marlin {
46 
47  class CCCollection;
48  class CCProcessor;
49 
51 
73 
74  public:
75 
76  // Constructor
77  MarlinSteerCheck( const char* steerFileName=NULL, const CommandLineParametersMap * cmdlineparams=NULL );
78 
81 
82  // Destructor
84 
87 
89  ProcVec& getAProcs() { return _aProc; };
90 
92  ProcVec& getIProcs() { return _iProc; };
93 
98  int existsProcessor( const std::string& type, const std::string& name="" );
99 
101  ColVec& getLCIOCols() const;
102 
105 
107  sSet& getColsSet( const std::string& type, const std::string& name, CCProcessor* proc );
108 
111 
113  void dumpColErrors( unsigned int i, std::ostream& stream, bool separators=false );
114 
116  int addLCIOFile( const std::string& file );
117 
119  void remLCIOFile( const std::string& file );
120 
122  void changeLCIOFilePos( unsigned int pos, unsigned int newPos );
123 
125  void addProcessor( bool status, const std::string& name, const std::string& type, std::shared_ptr<StringParameters> p );
126 
128  void remProcessor( unsigned int index, bool status );
129 
131  void activateProcessor( unsigned int index );
132 
134  void deactivateProcessor( unsigned int index );
135 
137  void changeProcessorPos( unsigned int pos, unsigned int newPos );
138 
140  void consistencyCheck();
141 
144  bool saveAsXMLFile( const std::string& file );
145 
146  /* Returns the relative path of the XML file */
148 
149  /* Returns the absolute path of the XML file */
151 
152  /* Returns the XML fileName */
154 
155  /* Returns the XML file as given by the user in the command prompt */
157 
159  void dump_information();
160 
162  sSet& getErrors(){ return _errors; };
163 
166 
168  const std::string getCondition( unsigned int index );
169 
171  void addCondition( const std::string& condition );
172 
174  void repCondition( const std::string& oldCond, const std::string& newCond );
175 
177  void remCondition( const std::string& condition );
178 
180  bool saveAsDOTFile(const std::string& file);
181 
182  private:
183 
185  //METHODS
187 
188  // Return all available collections from the active or inactive processors
189  ColVec& getProcCols( const ProcVec& v, const std::string& iotype ) const;
190 
191  // Return all available collections found in LCIO files and active/inactive processors
192  ColVec& getAllCols() const;
193 
194  // Return all available collections found in LCIO files and active/inactive processors
195  ProcVec& getAllProcs() const;
196 
197  // Parse the given steering file
198  bool parseXMLFile( const std::string& file, const CommandLineParametersMap * cmdlineparams=NULL );
199 
200  // Pop a processor out of a vector from processors
202 
203  // Find matching collections of a given type and value in a vector of collections for a given processor
204  ColVec& findMatchingCols( ColVec& v, CCProcessor* srcProc,
205  const std::string& type, const std::string& value="UNDEFINED", const std::string& name="UNDEFINED" );
206 
208  //VARIABLES
210 
211  sSet _errors{}; //XML File parsing error
212  //LCIO Files loading error
213  //GEAR File loading error
214  //Some Processors have no parameters
215  //Some Active Processors are not installed
216  //Some Active Processors have collection errors
217  //Warning: Some Inactive Processors are not installed
218 
219  IParser* _parser; //parser
220  std::shared_ptr<StringParameters> _gparam; //global parameters (without LCIO Files)
221 
222  std::string _steeringFile; //steering file name + path as passed by the user in the command line
223  std::string _XMLFileName=""; //steering file name
224  std::string _XMLFileAbsPath=""; //steering file (absolute path without filename)
225  std::string _XMLFileRelPath=""; //steering file (relative path without filename)
226 
227  ProcVec _aProc{}; //active processors
228  ProcVec _iProc{}; //inactive processors
229  sColVecMap _lcioCols{}; //LCIO collections
230  StringVec _lcioFiles{}; //LCIO filenames
231 
232  sSet _colValues{}; //all available collection values for a given type (use in ComboBox)
233 
234  sSet _pConditions{}; //all processor's conditions
235 
236  CMProcessor* _marlinProcs =NULL; //Sigleton class containing all marlin processors
237  };
238 
239 } // namespace
240 #endif
MarlinSteerCheck(const char *steerFileName=NULL, const CommandLineParametersMap *cmdlineparams=NULL)
void remProcessor(unsigned int index, bool status)
Remove processor with the given status at the given index.
This singleton class contains an instance of every available marlin processor type.
Definition: CMProcessor.h:21
void repCondition(const std::string &oldCond, const std::string &newCond)
Replace a Condition.
sSet & getPConditions()
Returns a set with all the processor&#39;s conditions.
ColVec & getProcCols(const ProcVec &v, const std::string &iotype) const
this class is a Marlin Steering File consistency check Tool.
const std::string getXMLFileRelPath()
ColVec & getLCIOCols() const
Returns the collections read from LCIO files.
ColVec & findMatchingCols(ColVec &v, CCProcessor *srcProc, const std::string &type, const std::string &value="UNDEFINED", const std::string &name="UNDEFINED")
void remCondition(const std::string &condition)
Removes the given condition.
std::shared_ptr< StringParameters > getGlobalParameters()
Returns the Global Parameters.
std::shared_ptr< StringParameters > _gparam
Interface for a parser of a steering file to be used with marlin.
Definition: IParser.h:19
CCProcessor * popProc(ProcVec &v, CCProcessor *p)
handles information about marlin processors and their collections needed by MarlinSteerCheck ...
Definition: CCProcessor.h:39
void dump_information()
Dumps all information read from the steering file to stdout.
const std::string getCondition(unsigned int index)
Returns the condition for a given index.
void activateProcessor(unsigned int index)
Activate processor at the given index.
bool parseXMLFile(const std::string &file, const CommandLineParametersMap *cmdlineparams=NULL)
STL class.
sSet & getColsSet(const std::string &type, const std::string &name, CCProcessor *proc)
Returns a list of all available Collections for a given type, name and processor (to use in a ComboBo...
ColVec & getAllCols() const
const std::string getXMLFileAbsPath()
bool saveAsDOTFile(const std::string &file)
Saves steering file in dot format.
void addProcessor(bool status, const std::string &name, const std::string &type, std::shared_ptr< StringParameters > p)
Add a new processor.
sSet & getErrors()
Returns a set with all the errors found after performing a consistency check.
ProcVec & getIProcs()
Returns the Inactive Processors.
bool saveAsXMLFile(const std::string &file)
Saves the data to an XML file with the given name Returns false if error occured. ...
const std::string getXMLFile()
void consistencyCheck()
Performs a check at all active processors to search for unavailable collections.
CMProcessor * getMProcs()
Returns the Marlin Processors.
ProcVec & getAllProcs() const
MarlinSteerCheck operator=(const marlin::MarlinSteerCheck &)=delete
void changeProcessorPos(unsigned int pos, unsigned int newPos)
Change the active processor at the given index to the new given position.
void dumpColErrors(unsigned int i, std::ostream &stream, bool separators=false)
Writes the collection errors for the active processor with given index to the given stream...
void deactivateProcessor(unsigned int index)
Deactivate processor at the given index.
const std::string getXMLFileName()
ProcVec & getAProcs()
Returns the Active Processors.
StringVec & getLCIOFiles()
Returns the names of the LCIO files found in the global section.
void changeLCIOFilePos(unsigned int pos, unsigned int newPos)
Change the LCIO File at the given index to the new given position.
void addCondition(const std::string &condition)
Add a new Condition.
STL class.
int addLCIOFile(const std::string &file)
Add LCIO file and read all collections inside it.
void remLCIOFile(const std::string &file)
Remove LCIO file and all collections associated to it.
int existsProcessor(const std::string &type, const std::string &name="")
Check if a processor of the given type with the given name already exists Returns 0 if the processor ...
std::vector< CCProcessor * > ProcVec