Marlin  1.10.0
 All Classes Namespaces Functions Variables Enumerations Friends Pages
MarlinSteerCheck.h
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 
50  typedef std::vector< CCProcessor* > ProcVec;
51 
73 
74  public:
75 
76  // Constructor
77  MarlinSteerCheck( const char* steerFileName=NULL, const CommandLineParametersMap * cmdlineparams=NULL );
78 
79  // Destructor
81 
83  CMProcessor* getMProcs() { return _marlinProcs; };
84 
86  ProcVec& getAProcs() { return _aProc; };
87 
89  ProcVec& getIProcs() { return _iProc; };
90 
95  int existsProcessor( const std::string& type, const std::string& name="" );
96 
98  ColVec& getLCIOCols() const;
99 
101  StringVec& getLCIOFiles(){ return _lcioFiles; }
102 
104  sSet& getColsSet( const std::string& type, const std::string& name, CCProcessor* proc );
105 
107  StringParameters* getGlobalParameters(){ return _gparam; }
108 
110  void dumpColErrors( unsigned int i, std::ostream& stream, bool separators=false );
111 
113  int addLCIOFile( const std::string& file );
114 
116  void remLCIOFile( const std::string& file );
117 
119  void changeLCIOFilePos( unsigned int pos, unsigned int newPos );
120 
122  void addProcessor( bool status, const std::string& name, const std::string& type, StringParameters* p=NULL );
123 
125  void remProcessor( unsigned int index, bool status );
126 
128  void activateProcessor( unsigned int index );
129 
131  void deactivateProcessor( unsigned int index );
132 
134  void changeProcessorPos( unsigned int pos, unsigned int newPos );
135 
137  void consistencyCheck();
138 
141  bool saveAsXMLFile( const std::string& file );
142 
143  /* Returns the relative path of the XML file */
144  const std::string getXMLFileRelPath(){ return _XMLFileRelPath; }
145 
146  /* Returns the absolute path of the XML file */
147  const std::string getXMLFileAbsPath(){ return _XMLFileAbsPath; }
148 
149  /* Returns the XML fileName */
150  const std::string getXMLFileName(){ return _XMLFileName; }
151 
152  /* Returns the XML file as given by the user in the command prompt */
153  const std::string getXMLFile(){ return _steeringFile; }
154 
156  void dump_information();
157 
159  sSet& getErrors(){ return _errors; };
160 
162  sSet& getPConditions(){ return _pConditions; };
163 
165  const std::string getCondition( unsigned int index );
166 
168  void addCondition( const std::string& condition );
169 
171  void repCondition( const std::string& oldCond, const std::string& newCond );
172 
174  void remCondition( const std::string& condition );
175 
177  bool saveAsDOTFile(const std::string& file);
178 
179  private:
180 
182  //METHODS
184 
185  // Return all available collections from the active or inactive processors
186  ColVec& getProcCols( const ProcVec& v, const std::string& iotype ) const;
187 
188  // Return all available collections found in LCIO files and active/inactive processors
189  ColVec& getAllCols() const;
190 
191  // Return all available collections found in LCIO files and active/inactive processors
192  ProcVec& getAllProcs() const;
193 
194  // Parse the given steering file
195  bool parseXMLFile( const std::string& file, const CommandLineParametersMap * cmdlineparams=NULL );
196 
197  // Pop a processor out of a vector from processors
198  CCProcessor* popProc(ProcVec& v, CCProcessor* p);
199 
200  // Find matching collections of a given type and value in a vector of collections for a given processor
201  ColVec& findMatchingCols( ColVec& v, CCProcessor* srcProc,
202  const std::string& type, const std::string& value="UNDEFINED", const std::string& name="UNDEFINED" );
203 
205  //VARIABLES
207 
208  sSet _errors; //XML File parsing error
209  //LCIO Files loading error
210  //GEAR File loading error
211  //Some Processors have no parameters
212  //Some Active Processors are not installed
213  //Some Active Processors have collection errors
214  //Warning: Some Inactive Processors are not installed
215 
216  IParser* _parser; //parser
217  StringParameters* _gparam; //global parameters (without LCIO Files)
218 
219  std::string _steeringFile; //steering file name + path as passed by the user in the command line
220  std::string _XMLFileName; //steering file name
221  std::string _XMLFileAbsPath; //steering file (absolute path without filename)
222  std::string _XMLFileRelPath; //steering file (relative path without filename)
223 
224  ProcVec _aProc; //active processors
225  ProcVec _iProc; //inactive processors
226  sColVecMap _lcioCols; //LCIO collections
227  StringVec _lcioFiles; //LCIO filenames
228 
229  sSet _colValues; //all available collection values for a given type (use in ComboBox)
230 
231  sSet _pConditions; //all processor's conditions
232 
233  CMProcessor* _marlinProcs; //Sigleton class containing all marlin processors
234  };
235 
236 } // namespace
237 #endif
void remProcessor(unsigned int index, bool status)
Remove processor with the given status at the given index.
Definition: MarlinSteerCheck.cc:342
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.
Definition: MarlinSteerCheck.cc:759
sSet & getPConditions()
Returns a set with all the processor's conditions.
Definition: MarlinSteerCheck.h:162
this class is a Marlin Steering File consistency check Tool.
Definition: MarlinSteerCheck.h:72
ColVec & getLCIOCols() const
Returns the collections read from LCIO files.
Definition: MarlinSteerCheck.cc:786
void remCondition(const std::string &condition)
Removes the given condition.
Definition: MarlinSteerCheck.cc:771
StringParameters * getGlobalParameters()
Returns the Global Parameters.
Definition: MarlinSteerCheck.h:107
Interface for a parser of a steering file to be used with marlin.
Definition: IParser.h:18
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.
Definition: MarlinSteerCheck.cc:1100
const std::string getCondition(unsigned int index)
Returns the condition for a given index.
Definition: MarlinSteerCheck.cc:746
void activateProcessor(unsigned int index)
Activate processor at the given index.
Definition: MarlinSteerCheck.cc:375
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...
Definition: MarlinSteerCheck.cc:126
bool saveAsDOTFile(const std::string &file)
Saves steering file in dot format.
Definition: MarlinSteerCheck.cc:1003
sSet & getErrors()
Returns a set with all the errors found after performing a consistency check.
Definition: MarlinSteerCheck.h:159
ProcVec & getIProcs()
Returns the Inactive Processors.
Definition: MarlinSteerCheck.h:89
bool saveAsXMLFile(const std::string &file)
Saves the data to an XML file with the given name Returns false if error occured. ...
Definition: MarlinSteerCheck.cc:824
void consistencyCheck()
Performs a check at all active processors to search for unavailable collections.
Definition: MarlinSteerCheck.cc:444
CMProcessor * getMProcs()
Returns the Marlin Processors.
Definition: MarlinSteerCheck.h:83
void changeProcessorPos(unsigned int pos, unsigned int newPos)
Change the active processor at the given index to the new given position.
Definition: MarlinSteerCheck.cc:416
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...
Definition: MarlinSteerCheck.cc:1207
void deactivateProcessor(unsigned int index)
Deactivate processor at the given index.
Definition: MarlinSteerCheck.cc:393
void addProcessor(bool status, const std::string &name, const std::string &type, StringParameters *p=NULL)
Add a new processor.
Definition: MarlinSteerCheck.cc:328
ProcVec & getAProcs()
Returns the Active Processors.
Definition: MarlinSteerCheck.h:86
StringVec & getLCIOFiles()
Returns the names of the LCIO files found in the global section.
Definition: MarlinSteerCheck.h:101
void changeLCIOFilePos(unsigned int pos, unsigned int newPos)
Change the LCIO File at the given index to the new given position.
Definition: MarlinSteerCheck.cc:293
void addCondition(const std::string &condition)
Add a new Condition.
Definition: MarlinSteerCheck.cc:755
int addLCIOFile(const std::string &file)
Add LCIO file and read all collections inside it.
Definition: MarlinSteerCheck.cc:173
void remLCIOFile(const std::string &file)
Remove LCIO file and all collections associated to it.
Definition: MarlinSteerCheck.cc:270
Simple parameters class for Marlin.
Definition: StringParameters.h:34
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 ...
Definition: MarlinSteerCheck.cc:360