CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWEPWrapper.h
Go to the documentation of this file.
1 #ifndef EVENTFILTER_PROCESSOR_FWEPWRAPPER_H
2 #define EVENTFILTER_PROCESSOR_FWEPWRAPPER_H
3 
5 
8 
10 #include "TriggerReportHelpers.h"
11 
12 #include "toolbox/lang/Class.h"
13 #include "toolbox/task/WorkLoop.h"
14 #include "toolbox/net/URL.h"
15 
16 
17 #include "xgi/Input.h"
18 #include "xgi/Output.h"
19 #include "xgi/exception/Exception.h"
20 
21 #include "xoap/MessageReference.h"
22 
23 #include "xdata/InfoSpace.h"
24 #include "xdata/Integer.h"
25 #include "xdata/UnsignedInteger32.h"
26 #include "xdata/Boolean.h"
27 #include "log4cplus/logger.h"
28 
29 #include <string>
33 
34 namespace xdaq{
35  class ApplicationDescriptor;
36  class ApplicationContext;
37 }
38 
39 namespace evf{
40 
41  struct lsTriplet{
42  lsTriplet(): ls(0), proc(0), acc(0){}
43  unsigned int ls;
44  unsigned int proc;
45  unsigned int acc;
46  };
47  class FWEPWrapper : public toolbox::lang::Class{
48 
49  public:
50 
51  FWEPWrapper(log4cplus::Logger &, unsigned int instance);
52  virtual ~FWEPWrapper();
53 
54 
55 
56  void taskWebPage(xgi::Input *,xgi::Output *,const std::string &);
57  void summaryWebPage(xgi::Input *,xgi::Output *,const std::string &);
59  void serviceWeb(xgi::Input *in,xgi::Output *out);
60  void microState(xgi::Input *in,xgi::Output *out);
61 
63  operator bool(){return epInitialized_;}
64 
65  // initialize the cmssw event processor
66  void init(unsigned short, std::string &);
67  void makeServicesOnly();
69 
70  // stop the cmssw event processor
72 
73  // stop and halt (check if stop done)
74  void stopAndHalt();
75 
76  // infospace pointers transfer
77  void setScalersInfoSpace(xdata::InfoSpace *sis, xdata::InfoSpace *slis)
78  {
79  scalersInfoSpace_ = sis;
81  }
82  void setApplicationInfoSpace(xdata::InfoSpace *is){applicationInfoSpace_ = is;}
83  void setMonitorInfoSpace(xdata::InfoSpace *mis, xdata::InfoSpace *mlis)
84  {
85  monitorInfoSpace_ = mis;
87  }
88  void setMonitorInfoSpaceLegend(xdata::InfoSpace *is){monitorInfoSpaceLegend_ = is;}
89  void setRcms(xdaq::ApplicationDescriptor* rcms){rcms_ = rcms;}
90  void setAppDesc(xdaq::ApplicationDescriptor *ad){xappDesc_ = ad;}
91  void setAppCtxt(xdaq::ApplicationContext *ctx){xappCtxt_ = ctx;}
92 
93 
96  void setupFastTimerService(unsigned int nProcesses);
97 
98  std::string wlMonitoring(){
99  if(wlMonitoring_!=0 && wlMonitoring_->isActive()) return (wlMonitoringActive_ ? "active" : "inactive");
100  else return "not initialized";
101  }
102  std::string const &configuration() const {return configuration_;}
103  // calculate monitoring information in separate thread
105  bool monitoring(toolbox::task::WorkLoop* wl);
106  // trigger report callback
107  bool getTriggerReport(bool useLock);
108  void updateRollingReport();
109 
110  void sumAndPackTriggerReport(MsgBuf &buf);
116  bool fireScalersUpdate();
118 
119  void lumiSumTable(xgi::Output *out);
120 
121  // some accessors for FUEventProcessor
122  std::string const &moduleNameFromIndex(unsigned int i) const
123  {
124  if(i<mapmod_.size()) return mapmod_[i];
125  else return unknown;
126  }
127  std::string const &stateNameFromIndex(unsigned int i) const
128  {
129  if(i<statmod_.size()) return statmod_[i];
130  else return unknown;
131  }
134  void resetWaiting(){waitingForLs_ = false;}
136  unsigned int getScalersUpdates(){return scalersUpdateCounter_;}
140  unsigned int getNumberOfMicrostates(){return mapmod_.size();}
141  std::vector<std::string> const &getmicromap() const { return mapmod_;}
142 
145  private:
146  static const std::string unknown;
148 
152  std::string configString_;
153 
154  // prescale (cmssw framework-) service
156 
158  log4cplus::Logger log_;
159  bool isPython_;
163 
164  // infospace variables, general
165  xdata::InfoSpace *applicationInfoSpace_;
166 
167  // infospace variables, monitor
168  xdata::InfoSpace *monitorInfoSpace_;
169  xdata::InfoSpace *monitorLegendaInfoSpace_;
170  xdata::InfoSpace *monitorInfoSpaceLegend_;
171 
172  xdata::UnsignedInteger32 timeoutOnStop_; // in seconds
173 
174  std::vector<edm::ModuleDescription const*> descs_; //module description array
175  std::map<std::string,int> modmap_;
176  std::vector<std::string> mapmod_;
177  std::vector<std::string> statmod_;
178 
179  // monitoring workloop params
180  xdata::UnsignedInteger32 monSleepSec_;
181  struct timeval monStartTime_;
182 
183  // flahslist variables
184  xdata::String epMState_;
185  xdata::String epmState_;
186  xdata::UnsignedInteger32 nbProcessed_;
187  xdata::UnsignedInteger32 nbAccepted_;
188 
189  // workloop / action signature for monitoring
190  toolbox::task::WorkLoop *wlMonitoring_;
191  toolbox::task::ActionSignature *asMonitoring_;
193  bool watching_;
194 
195  // flahslist variables, alt
196  xdata::Integer epMAltState_;
197  xdata::Integer epmAltState_;
198 
199 
200  // flahslist variables, legend
201  xdata::String macro_state_legend_;
202  xdata::String micro_state_legend_;
203 
204  // LS stuff
205  unsigned int allPastLumiProcessed_;
206  std::list<std::string> names_;
207  std::list<std::string> namesStatusLegenda_;
208  std::list<std::string> namesScalersLegenda_;
210  unsigned int lsid_;
211  unsigned int psid_;
212 
213  xdata::InfoSpace *scalersInfoSpace_;
214  xdata::InfoSpace *scalersLegendaInfoSpace_;
215  xdata::UnsignedInteger32 localLsIncludingTimeOuts_;
216  xdata::UnsignedInteger32 lsTimeOut_;
217  xdata::Table scalersComplete_;
218 
219  xdata::UnsignedInteger32 lumiSectionIndex_;
220  xdata::UnsignedInteger32 prescaleSetIndex_;
221  xdata::UnsignedInteger32 lastLumiPrescaleIndex_;
222  xdata::UnsignedInteger32 lastLumiUsingEol_;
223  xdata::Boolean lsTimedOut_;
224  xdata::Boolean lsToBeRecovered_;
225 
226  unsigned int scalersUpdateAttempted_;
227  unsigned int scalersUpdateCounter_;
228  std::vector<lsTriplet> lumiSectionsCtr_;
229  std::vector<bool> lumiSectionsTo_;
230  unsigned int rollingLsIndex_;
232  static const unsigned int lsRollSize_ = 20;
233  xdaq::ApplicationDescriptor* rcms_;
234  xdaq::ApplicationDescriptor* xappDesc_;
235  xdaq::ApplicationContext* xappCtxt_;
236  std::string configuration_;
237  std::string pathTable_;
238  xdata::UnsignedInteger32 instance_;
241  pthread_mutex_t ep_guard_lock_;
247  friend class FUEventProcessor;
248 
249  };
250 }
251 #endif
xdata::InfoSpace * monitorLegendaInfoSpace_
Definition: FWEPWrapper.h:169
xdata::String macro_state_legend_
Definition: FWEPWrapper.h:201
void summaryWebPage(xgi::Input *, xgi::Output *, const std::string &)
Definition: FWEPWrapper.cc:815
ShmOutputModuleRegistry * sorRef_
Definition: FWEPWrapper.h:244
int i
Definition: DBlmapReader.cc:9
FWEPWrapper(log4cplus::Logger &, unsigned int instance)
Definition: FWEPWrapper.cc:52
std::vector< bool > lumiSectionsTo_
Definition: FWEPWrapper.h:229
#define Input(cl)
Definition: vmac.h:189
xdata::String epMState_
Definition: FWEPWrapper.h:184
void updateRollingReport()
TriggerReportStatic * getPackedTriggerReportAsStruct()
void serviceWeb(xgi::Input *in, xgi::Output *out)
xdata::Integer epmAltState_
Definition: FWEPWrapper.h:197
static PFTauRenderPlugin instance
void moduleWeb(xgi::Input *in, xgi::Output *out)
void startMonitoringWorkLoop()
Definition: FWEPWrapper.cc:614
void taskWebPage(xgi::Input *, xgi::Output *, const std::string &)
Definition: FWEPWrapper.cc:881
struct timeval monStartTime_
Definition: FWEPWrapper.h:181
void setAppCtxt(xdaq::ApplicationContext *ctx)
Definition: FWEPWrapper.h:91
ShmOutputModuleRegistry * getShmOutputModuleRegistry()
Definition: FWEPWrapper.cc:491
unsigned int acc
Definition: FWEPWrapper.h:45
void createAndSendScalersMessage()
std::string configString_
Definition: FWEPWrapper.h:152
edm::EventProcessor * operator->()
Definition: FWEPWrapper.h:62
void init(unsigned short, std::string &)
Definition: FWEPWrapper.cc:193
xdata::InfoSpace * scalersInfoSpace_
Definition: FWEPWrapper.h:213
MsgBuf & getPackedTriggerReport()
Definition: FWEPWrapper.h:114
xdata::UnsignedInteger32 localLsIncludingTimeOuts_
Definition: FWEPWrapper.h:215
xdaq::ApplicationContext * xappCtxt_
Definition: FWEPWrapper.h:235
xdata::UnsignedInteger32 lastLumiPrescaleIndex_
Definition: FWEPWrapper.h:221
void setupFastTimerService(unsigned int nProcesses)
Definition: FWEPWrapper.cc:497
std::string const & moduleNameFromIndex(unsigned int i) const
Definition: FWEPWrapper.h:122
xdata::Boolean lsToBeRecovered_
Definition: FWEPWrapper.h:224
void forceInitEventProcessorMaybe()
Definition: FWEPWrapper.h:68
lsTriplet & lastLumi()
Definition: FWEPWrapper.h:133
xdata::InfoSpace * scalersLegendaInfoSpace_
Definition: FWEPWrapper.h:214
std::vector< std::string > mapmod_
Definition: FWEPWrapper.h:176
ModuleWebRegistry * mwrRef_
Definition: FWEPWrapper.h:243
void makeServicesOnly()
Definition: FWEPWrapper.cc:479
toolbox::task::WorkLoop * wlMonitoring_
Definition: FWEPWrapper.h:190
std::string wlMonitoring()
Definition: FWEPWrapper.h:98
static const std::string unknown
Definition: FWEPWrapper.h:146
int notstarted_state_code_
Definition: FWEPWrapper.h:242
void adjustLsIndexForRestart()
Definition: FWEPWrapper.h:112
std::list< std::string > namesScalersLegenda_
Definition: FWEPWrapper.h:208
bool fireScalersUpdate()
Definition: FWEPWrapper.cc:777
xdata::Boolean lsTimedOut_
Definition: FWEPWrapper.h:223
static const unsigned int lsRollSize_
Definition: FWEPWrapper.h:232
ModuleWebRegistry * getModuleWebRegistry()
Definition: FWEPWrapper.cc:485
unsigned int lsid_
Definition: FWEPWrapper.h:210
void lumiSumTable(xgi::Output *out)
std::vector< std::string > statmod_
Definition: FWEPWrapper.h:177
edm::ServiceToken serviceToken_
Definition: FWEPWrapper.h:149
void resetLumiSectionReferenceIndex()
Definition: FWEPWrapper.h:137
xdata::String epmState_
Definition: FWEPWrapper.h:185
unsigned int proc
Definition: FWEPWrapper.h:44
bool monitoring(toolbox::task::WorkLoop *wl)
Definition: FWEPWrapper.cc:647
unsigned int psid_
Definition: FWEPWrapper.h:211
bool hasPrescaleService_
Definition: FWEPWrapper.h:160
std::list< std::string > namesStatusLegenda_
Definition: FWEPWrapper.h:207
void setAppDesc(xdaq::ApplicationDescriptor *ad)
Definition: FWEPWrapper.h:90
xdata::Table scalersComplete_
Definition: FWEPWrapper.h:217
xdata::String micro_state_legend_
Definition: FWEPWrapper.h:202
void resetPackedTriggerReport()
Definition: FWEPWrapper.h:111
std::list< std::string > names_
Definition: FWEPWrapper.h:206
void setScalersInfoSpace(xdata::InfoSpace *sis, xdata::InfoSpace *slis)
Definition: FWEPWrapper.h:77
xdata::InfoSpace * monitorInfoSpaceLegend_
Definition: FWEPWrapper.h:170
xdata::InfoSpace * monitorInfoSpace_
Definition: FWEPWrapper.h:168
unsigned int getNumberOfMicrostates()
Definition: FWEPWrapper.h:140
std::map< std::string, int > modmap_
Definition: FWEPWrapper.h:175
tuple out
Definition: dbtoconf.py:99
unsigned int allPastLumiProcessed_
Definition: FWEPWrapper.h:205
std::vector< edm::ModuleDescription const * > descs_
Definition: FWEPWrapper.h:174
void setMonitorInfoSpace(xdata::InfoSpace *mis, xdata::InfoSpace *mlis)
Definition: FWEPWrapper.h:83
xdata::UnsignedInteger32 lumiSectionIndex_
Definition: FWEPWrapper.h:219
int notstarted_state_code() const
Definition: FWEPWrapper.h:132
edm::EventProcessor::StatusCode stop()
Definition: FWEPWrapper.cc:503
xdata::UnsignedInteger32 nbProcessed_
Definition: FWEPWrapper.h:186
void setApplicationInfoSpace(xdata::InfoSpace *is)
Definition: FWEPWrapper.h:82
unsigned int getLumiSectionReferenceIndex()
Definition: FWEPWrapper.h:139
bool getTriggerReport(bool useLock)
Definition: FWEPWrapper.cc:694
void resetTriggerReport()
Definition: FWEPWrapper.h:113
std::vector< std::string > const & getmicromap() const
Definition: FWEPWrapper.h:141
log4cplus::Logger log_
Definition: FWEPWrapper.h:158
xdata::UnsignedInteger32 lastLumiUsingEol_
Definition: FWEPWrapper.h:222
std::string const & stateNameFromIndex(unsigned int i) const
Definition: FWEPWrapper.h:127
bool isWaitingForLs()
Definition: FWEPWrapper.h:135
std::string const & configuration() const
Definition: FWEPWrapper.h:102
void setMonitorInfoSpaceLegend(xdata::InfoSpace *is)
Definition: FWEPWrapper.h:88
pthread_mutex_t ep_guard_lock_
Definition: FWEPWrapper.h:241
edm::service::PrescaleService * prescaleSvc_
Definition: FWEPWrapper.h:155
xdata::UnsignedInteger32 instance_
Definition: FWEPWrapper.h:238
xdata::UnsignedInteger32 monSleepSec_
Definition: FWEPWrapper.h:180
void publishConfigAndMonitorItemsSP()
Definition: FWEPWrapper.cc:183
unsigned int scalersUpdateCounter_
Definition: FWEPWrapper.h:227
#define Output(cl)
Definition: vmac.h:193
toolbox::task::ActionSignature * asMonitoring_
Definition: FWEPWrapper.h:191
unsigned int ls
Definition: FWEPWrapper.h:43
xdata::UnsignedInteger32 prescaleSetIndex_
Definition: FWEPWrapper.h:220
unsigned int rollingLsIndex_
Definition: FWEPWrapper.h:230
std::vector< lsTriplet > lumiSectionsCtr_
Definition: FWEPWrapper.h:228
fuep::TriggerReportHelpers trh_
Definition: FWEPWrapper.h:157
edm::EventProcessor * evtProcessor_
Definition: FWEPWrapper.h:147
xdata::Integer epMAltState_
Definition: FWEPWrapper.h:196
std::string lsidTimedOutAsString_
Definition: FWEPWrapper.h:209
void withdrawLumiSectionIncrement()
Definition: FWEPWrapper.h:138
bool hasServiceWebRegistry_
Definition: FWEPWrapper.h:162
FastTimerService * ftsRef_
Definition: FWEPWrapper.h:245
void microState(xgi::Input *in, xgi::Output *out)
void sumAndPackTriggerReport(MsgBuf &buf)
std::string pathTable_
Definition: FWEPWrapper.h:237
TriggerReportStatic * getPackedTriggerReportAsStruct()
Definition: FWEPWrapper.h:115
xdaq::ApplicationDescriptor * rcms_
Definition: FWEPWrapper.h:233
bool hasModuleWebRegistry_
Definition: FWEPWrapper.h:161
unsigned int scalersUpdateAttempted_
Definition: FWEPWrapper.h:226
xdata::InfoSpace * applicationInfoSpace_
Definition: FWEPWrapper.h:165
unsigned int getScalersUpdates()
Definition: FWEPWrapper.h:136
xdata::UnsignedInteger32 lsTimeOut_
Definition: FWEPWrapper.h:216
virtual ~FWEPWrapper()
Definition: FWEPWrapper.cc:110
void publishConfigAndMonitorItems(bool)
Definition: FWEPWrapper.cc:112
std::string configuration_
Definition: FWEPWrapper.h:236
bool wlMonitoringActive_
Definition: FWEPWrapper.h:192
xdaq::ApplicationDescriptor * xappDesc_
Definition: FWEPWrapper.h:234
xdata::UnsignedInteger32 timeoutOnStop_
Definition: FWEPWrapper.h:172
void setRcms(xdaq::ApplicationDescriptor *rcms)
Definition: FWEPWrapper.h:89
xdata::UnsignedInteger32 nbAccepted_
Definition: FWEPWrapper.h:187