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