Marlin  1.17.1
 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 
80  MarlinSteerCheck operator=(const marlin::MarlinSteerCheck&) = delete;
81 
82  // Destructor
84 
86  CMProcessor* getMProcs() { return _marlinProcs; };
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 
104  StringVec& getLCIOFiles(){ return _lcioFiles; }
105 
107  sSet& getColsSet( const std::string& type, const std::string& name, CCProcessor* proc );
108 
110  std::shared_ptr<StringParameters> getGlobalParameters(){ return _gparam; }
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 */
147  const std::string getXMLFileRelPath(){ return _XMLFileRelPath; }
148 
149  /* Returns the absolute path of the XML file */
150  const std::string getXMLFileAbsPath(){ return _XMLFileAbsPath; }
151 
152  /* Returns the XML fileName */
153  const std::string getXMLFileName(){ return _XMLFileName; }
154 
155  /* Returns the XML file as given by the user in the command prompt */
156  const std::string getXMLFile(){ return _steeringFile; }
157 
159  void dump_information();
160 
162  sSet& getErrors(){ return _errors; };
163 
165  sSet& getPConditions(){ return _pConditions; };
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
201  CCProcessor* popProc(ProcVec& v, CCProcessor* p);
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
void remProcessor(unsigned int index, bool status)
Remove processor with the given status at the given index.
Definition: MarlinSteerCheck.cc:338
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:755
sSet & getPConditions()
Returns a set with all the processor&#39;s conditions.
Definition: MarlinSteerCheck.h:165
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:782
void remCondition(const std::string &condition)
Removes the given condition.
Definition: MarlinSteerCheck.cc:767
std::shared_ptr< StringParameters > getGlobalParameters()
Returns the Global Parameters.
Definition: MarlinSteerCheck.h:110
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:1096
const std::string getCondition(unsigned int index)
Returns the condition for a given index.
Definition: MarlinSteerCheck.cc:742
void activateProcessor(unsigned int index)
Activate processor at the given index.
Definition: MarlinSteerCheck.cc:371
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:122
bool saveAsDOTFile(const std::string &file)
Saves steering file in dot format.
Definition: MarlinSteerCheck.cc:999
void addProcessor(bool status, const std::string &name, const std::string &type, std::shared_ptr< StringParameters > p)
Add a new processor.
Definition: MarlinSteerCheck.cc:324
sSet & getErrors()
Returns a set with all the errors found after performing a consistency check.
Definition: MarlinSteerCheck.h:162
ProcVec & getIProcs()
Returns the Inactive Processors.
Definition: MarlinSteerCheck.h:92
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:820
void consistencyCheck()
Performs a check at all active processors to search for unavailable collections.
Definition: MarlinSteerCheck.cc:440
CMProcessor * getMProcs()
Returns the Marlin Processors.
Definition: MarlinSteerCheck.h:86
void changeProcessorPos(unsigned int pos, unsigned int newPos)
Change the active processor at the given index to the new given position.
Definition: MarlinSteerCheck.cc:412
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:1203
void deactivateProcessor(unsigned int index)
Deactivate processor at the given index.
Definition: MarlinSteerCheck.cc:389
ProcVec & getAProcs()
Returns the Active Processors.
Definition: MarlinSteerCheck.h:89
StringVec & getLCIOFiles()
Returns the names of the LCIO files found in the global section.
Definition: MarlinSteerCheck.h:104
void changeLCIOFilePos(unsigned int pos, unsigned int newPos)
Change the LCIO File at the given index to the new given position.
Definition: MarlinSteerCheck.cc:289
void addCondition(const std::string &condition)
Add a new Condition.
Definition: MarlinSteerCheck.cc:751
int addLCIOFile(const std::string &file)
Add LCIO file and read all collections inside it.
Definition: MarlinSteerCheck.cc:169
void remLCIOFile(const std::string &file)
Remove LCIO file and all collections associated to it.
Definition: MarlinSteerCheck.cc:266
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:356