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