Go to the documentation of this file.00001 #ifndef EVENTFILTER_PROCESSOR_FWEPWRAPPER_H
00002 #define EVENTFILTER_PROCESSOR_FWEPWRAPPER_H
00003
00004 #include "FWCore/Framework/interface/EventProcessor.h"
00005
00006 #include "FWCore/PrescaleService/interface/PrescaleService.h"
00007
00008 #include "EventFilter/Utilities/interface/Exception.h"
00009 #include "TriggerReportHelpers.h"
00010
00011 #include "toolbox/lang/Class.h"
00012 #include "toolbox/task/WorkLoop.h"
00013 #include "toolbox/net/URL.h"
00014
00015
00016 #include "xgi/Input.h"
00017 #include "xgi/Output.h"
00018 #include "xgi/exception/Exception.h"
00019
00020 #include "xoap/MessageReference.h"
00021
00022 #include "xdata/InfoSpace.h"
00023 #include "xdata/Integer.h"
00024 #include "xdata/UnsignedInteger32.h"
00025 #include "xdata/Boolean.h"
00026 #include "log4cplus/logger.h"
00027
00028 #include <string>
00029 #include "EventFilter/Utilities/interface/MsgBuf.h"
00030 #include "EventFilter/Utilities/interface/ModuleWeb.h"
00031 #include "EventFilter/Utilities/interface/ModuleWebRegistry.h"
00032
00033 namespace xdaq{
00034 class ApplicationDescriptor;
00035 class ApplicationContext;
00036 }
00037
00038 namespace evf{
00039
00040 struct lsTriplet{
00041 lsTriplet(): ls(0), proc(0), acc(0){}
00042 unsigned int ls;
00043 unsigned int proc;
00044 unsigned int acc;
00045 };
00046 class FWEPWrapper : public toolbox::lang::Class{
00047
00048 public:
00049
00050 FWEPWrapper(log4cplus::Logger &, unsigned int instance);
00051 virtual ~FWEPWrapper();
00052
00053
00054
00055 void taskWebPage(xgi::Input *,xgi::Output *,const std::string &);
00056 void summaryWebPage(xgi::Input *,xgi::Output *,const std::string &);
00057 void moduleWeb(xgi::Input *in,xgi::Output *out);
00058 void serviceWeb(xgi::Input *in,xgi::Output *out);
00059 void microState(xgi::Input *in,xgi::Output *out);
00060
00061 edm::EventProcessor *operator->(){return evtProcessor_;}
00062 operator bool(){return epInitialized_;}
00063
00064
00065 void init(unsigned short, std::string &);
00066 void makeServicesOnly();
00067 void forceInitEventProcessorMaybe(){epInitialized_ = false;}
00068
00069
00070 edm::EventProcessor::StatusCode stop();
00071
00072
00073 void stopAndHalt();
00074
00075
00076 void setScalersInfoSpace(xdata::InfoSpace *sis, xdata::InfoSpace *slis)
00077 {
00078 scalersInfoSpace_ = sis;
00079 scalersLegendaInfoSpace_ = slis;
00080 }
00081 void setApplicationInfoSpace(xdata::InfoSpace *is){applicationInfoSpace_ = is;}
00082 void setMonitorInfoSpace(xdata::InfoSpace *mis, xdata::InfoSpace *mlis)
00083 {
00084 monitorInfoSpace_ = mis;
00085 monitorLegendaInfoSpace_ = mlis;
00086 }
00087 void setMonitorInfoSpaceLegend(xdata::InfoSpace *is){monitorInfoSpaceLegend_ = is;}
00088 void setRcms(xdaq::ApplicationDescriptor* rcms){rcms_ = rcms;}
00089 void setAppDesc(xdaq::ApplicationDescriptor *ad){xappDesc_ = ad;}
00090 void setAppCtxt(xdaq::ApplicationContext *ctx){xappCtxt_ = ctx;}
00091
00092
00093 void publishConfigAndMonitorItems(bool);
00094 void publishConfigAndMonitorItemsSP();
00095
00096 std::string wlMonitoring(){
00097 if(wlMonitoring_!=0 && wlMonitoring_->isActive()) return (wlMonitoringActive_ ? "active" : "inactive");
00098 else return "not initialized";
00099 }
00100 std::string const &configuration() const {return configuration_;}
00101
00102 void startMonitoringWorkLoop() throw (evf::Exception);
00103 bool monitoring(toolbox::task::WorkLoop* wl);
00104
00105 bool getTriggerReport(bool useLock);
00106 void updateRollingReport();
00107
00108 void sumAndPackTriggerReport(MsgBuf &buf);
00109 void resetPackedTriggerReport(){trh_.resetPackedTriggerReport();}
00110 void adjustLsIndexForRestart(){trh_.adjustLsIndexForRestart();}
00111 void resetTriggerReport(){trh_.resetTriggerReport();}
00112 MsgBuf &getPackedTriggerReport(){return trh_.getPackedTriggerReport();}
00113 TriggerReportStatic *getPackedTriggerReportAsStruct(){return trh_.getPackedTriggerReportAsStruct();}
00114 bool fireScalersUpdate();
00115 void createAndSendScalersMessage();
00116
00117 void lumiSumTable(xgi::Output *out);
00118
00119
00120 std::string const &moduleNameFromIndex(unsigned int i) const
00121 {
00122 if(i<mapmod_.size()) return mapmod_[i];
00123 else return unknown;
00124 }
00125 std::string const &stateNameFromIndex(unsigned int i) const
00126 {
00127 if(i<statmod_.size()) return statmod_[i];
00128 else return unknown;
00129 }
00130 int notstarted_state_code() const { return notstarted_state_code_;}
00131 lsTriplet &lastLumi(){return lumiSectionsCtr_[rollingLsIndex_];}
00132 void resetWaiting(){waitingForLs_ = false;}
00133 bool isWaitingForLs(){return waitingForLs_;}
00134 unsigned int getScalersUpdates(){return scalersUpdateCounter_;}
00135 void resetLumiSectionReferenceIndex(){trh_.resetLumiSectionReferenceIndex();}
00136 void withdrawLumiSectionIncrement(){trh_.withdrawLumiSectionIncrement();}
00137 unsigned int getLumiSectionReferenceIndex(){return trh_.getLumiSectionReferenceIndex();}
00138 unsigned int getNumberOfMicrostates(){return mapmod_.size();}
00139 std::vector<std::string> const &getmicromap() const { return mapmod_;}
00140
00141 ModuleWebRegistry * getModuleWebRegistry();
00142 ShmOutputModuleRegistry * getShmOutputModuleRegistry();
00143 private:
00144 static const std::string unknown;
00145 edm::EventProcessor *evtProcessor_;
00146
00147 edm::ServiceToken serviceToken_;
00148 bool servicesDone_;
00149 bool epInitialized_;
00150 std::string configString_;
00151
00152
00153 edm::service::PrescaleService* prescaleSvc_;
00154
00155
00156 fuep::TriggerReportHelpers trh_;
00157 log4cplus::Logger log_;
00158 bool isPython_;
00159 bool hasPrescaleService_;
00160 bool hasModuleWebRegistry_;
00161 bool hasServiceWebRegistry_;
00162
00163
00164 xdata::InfoSpace *applicationInfoSpace_;
00165
00166
00167 xdata::InfoSpace *monitorInfoSpace_;
00168 xdata::InfoSpace *monitorLegendaInfoSpace_;
00169 xdata::InfoSpace *monitorInfoSpaceLegend_;
00170
00171 xdata::UnsignedInteger32 timeoutOnStop_;
00172
00173 std::vector<edm::ModuleDescription const*> descs_;
00174 std::map<std::string,int> modmap_;
00175 std::vector<std::string> mapmod_;
00176 std::vector<std::string> statmod_;
00177
00178
00179 xdata::UnsignedInteger32 monSleepSec_;
00180 struct timeval monStartTime_;
00181
00182
00183 xdata::String epMState_;
00184 xdata::String epmState_;
00185 xdata::UnsignedInteger32 nbProcessed_;
00186 xdata::UnsignedInteger32 nbAccepted_;
00187
00188
00189 toolbox::task::WorkLoop *wlMonitoring_;
00190 toolbox::task::ActionSignature *asMonitoring_;
00191 bool wlMonitoringActive_;
00192 bool watching_;
00193
00194
00195 xdata::Integer epMAltState_;
00196 xdata::Integer epmAltState_;
00197
00198
00199
00200 xdata::String macro_state_legend_;
00201 xdata::String micro_state_legend_;
00202
00203
00204 unsigned int allPastLumiProcessed_;
00205 std::list<std::string> names_;
00206 std::list<std::string> namesStatusLegenda_;
00207 std::list<std::string> namesScalersLegenda_;
00208 std::string lsidTimedOutAsString_;
00209 unsigned int lsid_;
00210 unsigned int psid_;
00211
00212 xdata::InfoSpace *scalersInfoSpace_;
00213 xdata::InfoSpace *scalersLegendaInfoSpace_;
00214 xdata::UnsignedInteger32 localLsIncludingTimeOuts_;
00215 xdata::UnsignedInteger32 lsTimeOut_;
00216 xdata::Table scalersComplete_;
00217
00218 xdata::UnsignedInteger32 lumiSectionIndex_;
00219 xdata::UnsignedInteger32 prescaleSetIndex_;
00220 xdata::UnsignedInteger32 lastLumiPrescaleIndex_;
00221 xdata::UnsignedInteger32 lastLumiUsingEol_;
00222 xdata::Boolean lsTimedOut_;
00223 xdata::Boolean lsToBeRecovered_;
00224
00225 unsigned int scalersUpdateAttempted_;
00226 unsigned int scalersUpdateCounter_;
00227 std::vector<lsTriplet> lumiSectionsCtr_;
00228 std::vector<bool> lumiSectionsTo_;
00229 unsigned int rollingLsIndex_;
00230 bool rollingLsWrap_;
00231 static const unsigned int lsRollSize_ = 20;
00232 xdaq::ApplicationDescriptor* rcms_;
00233 xdaq::ApplicationDescriptor* xappDesc_;
00234 xdaq::ApplicationContext* xappCtxt_;
00235 std::string configuration_;
00236 std::string pathTable_;
00237 xdata::UnsignedInteger32 instance_;
00238 bool hasSubProcesses;
00239 bool waitingForLs_;
00240 pthread_mutex_t ep_guard_lock_;
00241 int notstarted_state_code_;
00242 ModuleWebRegistry *mwrRef_;
00243 ShmOutputModuleRegistry *sorRef_;
00244 friend class FUEventProcessor;
00245
00246 };
00247 }
00248 #endif