00001 #include "FWEPWrapper.h"
00002
00003 #include "EventFilter/Utilities/interface/ParameterSetRetriever.h"
00004 #include "EventFilter/Utilities/interface/ModuleWebRegistry.h"
00005 #include "EventFilter/Utilities/interface/ServiceWebRegistry.h"
00006 #include "EventFilter/Utilities/interface/ServiceWeb.h"
00007 #include "EventFilter/Utilities/interface/MicroStateService.h"
00008 #include "EventFilter/Utilities/interface/TimeProfilerService.h"
00009 #include "EventFilter/Modules/interface/ShmOutputModuleRegistry.h"
00010
00011 #include "EventFilter/Modules/src/FUShmOutputModule.h"
00012
00013 #include "toolbox/task/WorkLoopFactory.h"
00014 #include "xdaq/ApplicationDescriptorImpl.h"
00015 #include "xdaq/ContextDescriptor.h"
00016 #include "xdaq/ApplicationContext.h"
00017 #include "xdata/Boolean.h"
00018 #include "xdata/TableIterator.h"
00019 #include "xdata/exdr/Serializer.h"
00020 #include "xdata/exdr/AutoSizeOutputStreamBuffer.h"
00021
00022 #include "FWCore/PythonParameterSet/interface/MakeParameterSets.h"
00023 #undef HAVE_STAT
00024 #include "FWCore/PythonParameterSet/interface/PythonProcessDesc.h"
00025 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00026 #include "FWCore/ParameterSet/interface/ProcessDesc.h"
00027 #include "FWCore/ServiceRegistry/interface/Service.h"
00028 #include "FWCore/PrescaleService/interface/PrescaleService.h"
00029 #include "FWCore/Framework/interface/TriggerReport.h"
00030
00031 #include "DQMServices/Core/interface/DQMStore.h"
00032
00033 #include "xoap/MessageFactory.h"
00034 #include "xoap/SOAPEnvelope.h"
00035 #include "xoap/SOAPBody.h"
00036 #include "xoap/domutils.h"
00037 #include "xoap/Method.h"
00038 #include "xmas/xmas.h"
00039
00040 #include "cgicc/CgiDefs.h"
00041 #include "cgicc/Cgicc.h"
00042 #include "cgicc/FormEntry.h"
00043
00044 #include "utils.icc"
00045
00046 #include <vector>
00047
00048 namespace evf{
00049
00050 const std::string FWEPWrapper::unknown = "unknown";
00051 FWEPWrapper::FWEPWrapper(log4cplus::Logger &log, unsigned int instance)
00052 : evtProcessor_(0)
00053 , serviceToken_()
00054 , servicesDone_(false)
00055 , epInitialized_(false)
00056 , prescaleSvc_(0)
00057 , log_(log)
00058 , isPython_(true)
00059 , hasPrescaleService_(false)
00060 , hasModuleWebRegistry_(false)
00061 , hasServiceWebRegistry_(false)
00062 , monitorInfoSpace_(0)
00063 , monitorInfoSpaceLegend_(0)
00064 , timeoutOnStop_(3)
00065 , monSleepSec_(1)
00066 , nbProcessed_(0)
00067 , nbAccepted_(0)
00068 , wlMonitoring_(0)
00069 , asMonitoring_(0)
00070 , wlMonitoringActive_(false)
00071 , watching_(false)
00072 , allPastLumiProcessed_(0)
00073 , lsid_(0)
00074 , psid_(0)
00075 , lsTimeOut_(100000000)
00076 , lumiSectionIndex_(1)
00077 , prescaleSetIndex_(0)
00078 , lastLumiPrescaleIndex_(0)
00079 , lastLumiUsingEol_(0)
00080 , lsTimedOut_(false)
00081 , lsToBeRecovered_(true)
00082 , scalersUpdateAttempted_(0)
00083 , scalersUpdateCounter_(0)
00084 , lumiSectionsCtr_(lsRollSize_+1)
00085 , lumiSectionsTo_(lsRollSize_)
00086 , rollingLsIndex_(lsRollSize_-1)
00087 , rollingLsWrap_(false)
00088 , rcms_(0)
00089 , instance_(instance)
00090 , waitingForLs_(false)
00091 , mwrRef_(nullptr)
00092 , sorRef_(nullptr)
00093 {
00094
00095 names_.push_back("lumiSectionIndex");
00096 names_.push_back("prescaleSetIndex");
00097 names_.push_back("scalersTable");
00098 namesStatusLegenda_.push_back("macroStateLegenda");
00099 namesStatusLegenda_.push_back("microStateLegenda");
00100 namesScalersLegenda_.push_back("scalersLegenda");
00101
00102 epMAltState_ = -1;
00103 epmAltState_ = -1;
00104 pthread_mutex_init(&ep_guard_lock_,0);
00105 }
00106
00107 FWEPWrapper::~FWEPWrapper() {delete evtProcessor_; evtProcessor_=0;}
00108
00109 void FWEPWrapper::publishConfigAndMonitorItems(bool multi)
00110 {
00111
00112 applicationInfoSpace_->fireItemAvailable("monSleepSec", &monSleepSec_);
00113 applicationInfoSpace_->fireItemAvailable("timeoutOnStop", &timeoutOnStop_);
00114 applicationInfoSpace_->fireItemAvailable("lsTimeOut", &lsTimeOut_);
00115
00116 applicationInfoSpace_->fireItemAvailable("lumiSectionIndex", &lumiSectionIndex_);
00117 applicationInfoSpace_->fireItemAvailable("prescaleSetIndex", &prescaleSetIndex_);
00118 applicationInfoSpace_->fireItemAvailable("lastLumiPrescaleIndex", &lastLumiPrescaleIndex_);
00119 applicationInfoSpace_->fireItemAvailable("lastLumiUsingEol", &lastLumiUsingEol_);
00120 applicationInfoSpace_->fireItemAvailable("lsTimedOut", &lsTimedOut_);
00121 applicationInfoSpace_->fireItemAvailable("lsToBeRecovered", &lsToBeRecovered_);
00122
00123 monitorLegendaInfoSpace_->fireItemAvailable("macroStateLegenda", ¯o_state_legend_);
00124 monitorLegendaInfoSpace_->fireItemAvailable("microStateLegenda", µ_state_legend_);
00125
00126 monitorInfoSpace_->fireItemAvailable("epMacroState", &epMState_);
00127 monitorInfoSpace_->fireItemAvailable("epMicroState", &epmState_);
00128
00129 xdata::Table &stbl = trh_.getTable();
00130 scalersInfoSpace_->fireItemAvailable("scalersTable", &stbl);
00131 scalersInfoSpace_->fireItemAvailable("lumiSectionIndex", &lumiSectionIndex_);
00132 scalersInfoSpace_->fireItemAvailable("prescaleSetIndex", &prescaleSetIndex_);
00133 scalersInfoSpace_->fireItemAvailable("lastLumiPrescaleIndex", &lastLumiPrescaleIndex_);
00134 scalersInfoSpace_->fireItemAvailable("lastLumiUsingEol", &lastLumiUsingEol_);
00135 scalersLegendaInfoSpace_->fireItemAvailable("scalersLegenda", trh_.getPathLegenda());
00136
00137 scalersComplete_.addColumn("instance", "unsigned int 32");
00138 scalersComplete_.addColumn("lsid", "unsigned int 32");
00139 scalersComplete_.addColumn("psid", "unsigned int 32");
00140 scalersComplete_.addColumn("proc", "unsigned int 32");
00141 scalersComplete_.addColumn("acc", "unsigned int 32");
00142 scalersComplete_.addColumn("exprep", "unsigned int 32");
00143 scalersComplete_.addColumn("effrep", "unsigned int 32");
00144 scalersComplete_.addColumn("triggerReport", "table");
00145
00146 xdata::Table::iterator it = scalersComplete_.begin();
00147 if( it == scalersComplete_.end())
00148 {
00149 it = scalersComplete_.append();
00150 it->setField("instance",instance_);
00151 }
00152
00153
00154
00155 unsigned int i = 0;
00156 std::stringstream oss;
00157 for(i = (unsigned int)edm::event_processor::sInit; i < (unsigned int)edm::event_processor::sInvalid; i++)
00158 {
00159 oss << i << "=" << evtProcessor_->stateName((edm::event_processor::State) i) << " ";
00160 statmod_.push_back(evtProcessor_->stateName((edm::event_processor::State) i));
00161 }
00162 oss << i << "=" << "NotStarted ";
00163 statmod_.push_back("NotStarted");
00164 notstarted_state_code_ = i;
00165 std::stringstream oss2;
00166 oss2 << 0 << "=Invalid ";
00167 modmap_["Invalid"]=0;
00168 mapmod_.resize(1);
00169 mapmod_[0]="Invalid";
00170
00171 monitorInfoSpace_->lock();
00172 macro_state_legend_ = oss.str();
00173 micro_state_legend_ = oss2.str();
00174 monitorInfoSpace_->unlock();
00175
00176 if(!multi) publishConfigAndMonitorItemsSP();
00177
00178 }
00179
00180 void FWEPWrapper::publishConfigAndMonitorItemsSP()
00181 {
00182 monitorInfoSpace_->fireItemAvailable("epSPMacroStateInt", &epMAltState_);
00183 monitorInfoSpace_->fireItemAvailable("epSPMicroStateInt", &epmAltState_);
00184
00185 monitorInfoSpace_->fireItemAvailable("nbProcessed", &nbProcessed_);
00186 monitorInfoSpace_->fireItemAvailable("nbAccepted", &nbAccepted_);
00187 }
00188
00189
00190 void FWEPWrapper::init(unsigned short serviceMap, std::string &configString)
00191 {
00192 hasPrescaleService_ = serviceMap & 0x1;
00193 hasModuleWebRegistry_ = serviceMap & 0x2;
00194 hasServiceWebRegistry_ = serviceMap & 0x4;
00195 bool instanceZero = serviceMap & 0x8;
00196 hasSubProcesses = serviceMap & 0x10;
00197 configString_ = configString;
00198 trh_.resetFormat();
00199 scalersUpdateCounter_ = 0;
00200 if (epInitialized_) {
00201 LOG4CPLUS_INFO(log_,"CMSSW EventProcessor already initialized: skip!");
00202 return;
00203 }
00204
00205 LOG4CPLUS_INFO(log_,"Initialize CMSSW EventProcessor.");
00206 LOG4CPLUS_INFO(log_,"CMSSW_BASE:"<<getenv("CMSSW_BASE"));
00207
00208
00209
00210 ParameterSetRetriever pr(configString_);
00211 configuration_ = pr.getAsString();
00212 pathTable_ = pr.getPathTableAsString();
00213
00214 if (configString_.size() > 3 && configString_.substr(configString_.size()-3) == ".py") isPython_ = true;
00215 boost::shared_ptr<edm::ParameterSet> params;
00216 boost::shared_ptr<std::vector<edm::ParameterSet> > pServiceSets;
00217 boost::shared_ptr<edm::ProcessDesc> pdesc;
00218 if(isPython_)
00219 {
00220 PythonProcessDesc ppdesc = PythonProcessDesc(configuration_);
00221 pdesc = ppdesc.processDesc();
00222 }
00223 else
00224 pdesc = boost::shared_ptr<edm::ProcessDesc>(new edm::ProcessDesc(configuration_));
00225 pServiceSets = pdesc->getServicesPSets();
00226
00227 if(!servicesDone_) {
00228
00229 if(!hasSubProcesses){
00230 internal::addServiceMaybe(*pServiceSets,"DQMStore");
00231 internal::addServiceMaybe(*pServiceSets,"DQM");
00232 }
00233 else{
00234 internal::removeServiceMaybe(*pServiceSets,"DQMStore");
00235 internal::removeServiceMaybe(*pServiceSets,"DQM");
00236 }
00237 internal::addServiceMaybe(*pServiceSets,"MLlog4cplus");
00238 internal::addServiceMaybe(*pServiceSets,"MicroStateService");
00239 internal::addServiceMaybe(*pServiceSets,"ShmOutputModuleRegistry");
00240 if(hasPrescaleService_) internal::addServiceMaybe(*pServiceSets,"PrescaleService");
00241 if(hasModuleWebRegistry_) internal::addServiceMaybe(*pServiceSets,"ModuleWebRegistry");
00242 if(hasServiceWebRegistry_) internal::addServiceMaybe(*pServiceSets,"ServiceWebRegistry");
00243
00244 try{
00245 serviceToken_ = edm::ServiceRegistry::createSet(*pServiceSets);
00246 internal::addServiceMaybe(*pServiceSets,"DQMStore");
00247 internal::addServiceMaybe(*pServiceSets,"DQM");
00248
00249 }
00250 catch(cms::Exception &e) {
00251 LOG4CPLUS_ERROR(log_,e.explainSelf());
00252 }
00253 catch(std::exception &e) {
00254 LOG4CPLUS_ERROR(log_,e.what());
00255 }
00256 catch(...) {
00257 LOG4CPLUS_ERROR(log_,"Unknown Exception");
00258 }
00259 servicesDone_ = true;
00260 }
00261
00262 edm::ServiceRegistry::Operate operate(serviceToken_);
00263
00264
00265
00266 edm::LogInfo("FWEPWrapper")<<"started MessageLogger Service.";
00267 edm::LogInfo("FWEPWrapper")<<"Using config \n"<<configuration_;
00268
00269 DQMStore *dqm = 0;
00270 try{
00271 if(edm::Service<DQMStore>().isAvailable())
00272 dqm = edm::Service<DQMStore>().operator->();
00273 }
00274 catch(...) {
00275 LOG4CPLUS_INFO(log_,
00276 "exception when trying to get service DQMStore");
00277 }
00278 if(dqm!=0) dqm->rmdir("");
00279
00280
00281 ModuleWebRegistry *mwr = 0;
00282 try{
00283 if(edm::Service<ModuleWebRegistry>().isAvailable())
00284 mwr = edm::Service<ModuleWebRegistry>().operator->();
00285 }
00286 catch(...) {
00287 LOG4CPLUS_INFO(log_,
00288 "exception when trying to get service ModuleWebRegistry");
00289 }
00290 mwrRef_=mwr;
00291
00292 if(mwr) mwr->clear();
00293
00294 ServiceWebRegistry *swr = 0;
00295 try{
00296 if(edm::Service<ServiceWebRegistry>().isAvailable())
00297 swr = edm::Service<ServiceWebRegistry>().operator->();
00298 }
00299 catch(...) {
00300 LOG4CPLUS_INFO(log_,
00301 "exception when trying to get service ModuleWebRegistry");
00302 }
00303 ShmOutputModuleRegistry *sor = 0;
00304 try{
00305 if(edm::Service<ShmOutputModuleRegistry>().isAvailable())
00306 sor = edm::Service<ShmOutputModuleRegistry>().operator->();
00307 }
00308 catch(...) {
00309 LOG4CPLUS_INFO(log_,
00310 "exception when trying to get service ShmOutputModuleRegistry");
00311 }
00312 sorRef_=sor;
00313
00314 if(sor) sor->clear();
00315
00316
00317
00318
00319
00320 std::vector<std::string> defaultServices;
00321 std::vector<std::string> forcedServices;
00322 defaultServices.push_back("MessageLogger");
00323 defaultServices.push_back("InitRootHandlers");
00324 defaultServices.push_back("JobReportService");
00325 pdesc->addServices(defaultServices, forcedServices);
00326 pthread_mutex_lock(&ep_guard_lock_);
00327 if (0!=evtProcessor_) delete evtProcessor_;
00328
00329 evtProcessor_ = new edm::EventProcessor(pdesc,
00330 serviceToken_,
00331 edm::serviceregistry::kTokenOverrides);
00332 pthread_mutex_unlock(&ep_guard_lock_);
00333
00334
00335
00336
00337
00338
00339
00340
00341 if(mwr)
00342 {
00343 mwr->publish(applicationInfoSpace_);
00344 mwr->publishToXmas(scalersInfoSpace_);
00345 }
00346 if(swr)
00347 {
00348 swr->publish(applicationInfoSpace_);
00349 }
00350
00351 LOG4CPLUS_INFO(log_,
00352 "Checking for edm::service::PrescaleService!");
00353 try {
00354 if(edm::Service<edm::service::PrescaleService>().isAvailable())
00355 {
00356 LOG4CPLUS_INFO(log_,
00357 "edm::service::PrescaleService is available!");
00358 prescaleSvc_ = edm::Service<edm::service::PrescaleService>().operator->();
00359 LOG4CPLUS_INFO(log_,
00360 "Obtained pointer to PrescaleService");
00361 }
00362 }
00363 catch(...) {
00364 LOG4CPLUS_INFO(log_,
00365 "exception when trying to get service "
00366 <<"edm::service::PrescaleService");
00367 }
00368 const edm::ParameterSet *prescaleSvcConfig = internal::findService(*pServiceSets,"PrescaleService");
00369 if(prescaleSvc_ != 0 && prescaleSvcConfig !=0) prescaleSvc_->reconfigure(*prescaleSvcConfig);
00370
00371 monitorLegendaInfoSpace_->lock();
00372
00373 descs_ = evtProcessor_->getAllModuleDescriptions();
00374
00375 std::stringstream oss2;
00376 unsigned int outcount = 0;
00377 oss2 << 0 << "=Invalid ";
00378 oss2 << 1 << "=FwkOvh ";
00379 oss2 << 2 << "=Input ";
00380 modmap_["Invalid"]=0;
00381 modmap_["FWKOVH"]=1;
00382 modmap_["INPUT"]=2;
00383 mapmod_.resize(descs_.size()+4);
00384 mapmod_[0]="Invalid";
00385 mapmod_[1]="FWKOVH";
00386 mapmod_[2]="INPUT";
00387 outcount+=2;
00388 for(unsigned int j = 0; j < descs_.size(); j++)
00389 {
00390 if(descs_[j]->moduleName() == "ShmStreamConsumer")
00391 {
00392 outcount++;
00393 oss2 << outcount << "=" << descs_[j]->moduleLabel() << " ";
00394 modmap_[descs_[j]->moduleLabel()]=outcount;
00395 mapmod_[outcount] = descs_[j]->moduleLabel();
00396 }
00397 }
00398 modmap_["DQM"]=outcount+1;
00399 mapmod_[outcount+1]="DQM";
00400 oss2 << outcount+1 << "=DQMHistograms ";
00401 unsigned int modcount = 1;
00402 for(unsigned int i = 0; i < descs_.size(); i++)
00403 {
00404 if(descs_[i]->moduleName() != "ShmStreamConsumer")
00405 {
00406 modcount++;
00407 oss2 << outcount+modcount << "=" << descs_[i]->moduleLabel() << " ";
00408 modmap_[descs_[i]->moduleLabel()]=outcount+modcount;
00409 mapmod_[outcount+modcount] = descs_[i]->moduleLabel();
00410 }
00411 }
00412
00413
00414
00415
00416 if(instanceZero){
00417 micro_state_legend_ = oss2.str().c_str();
00418 }
00419 monitorLegendaInfoSpace_->unlock();
00420 try{
00421 monitorLegendaInfoSpace_->fireItemGroupChanged(namesStatusLegenda_,0);
00422 scalersLegendaInfoSpace_->fireItemGroupChanged(namesScalersLegenda_,0);
00423 ::usleep(10);
00424 }
00425 catch(xdata::exception::Exception &e)
00426 {
00427 LOG4CPLUS_ERROR(log_, "Exception from fireItemGroupChanged: " << e.what());
00428 }
00429 LOG4CPLUS_INFO(log_," edm::EventProcessor configuration finished.");
00430 edm::TriggerReport tr;
00431 evtProcessor_->getTriggerReport(tr);
00432 trh_.formatReportTable(tr,descs_,pathTable_,instanceZero);
00433 epInitialized_ = true;
00434 return;
00435 }
00436
00437 void FWEPWrapper::makeServicesOnly()
00438 {
00439 edm::ServiceRegistry::Operate operate(serviceToken_);
00440 }
00441
00442 ModuleWebRegistry * FWEPWrapper::getModuleWebRegistry() {
00443 return mwrRef_;
00444 }
00445
00446 ShmOutputModuleRegistry * FWEPWrapper::getShmOutputModuleRegistry() {
00447 return sorRef_;
00448 }
00449
00450
00451 edm::EventProcessor::StatusCode FWEPWrapper::stop()
00452 {
00453 edm::event_processor::State st = evtProcessor_->getState();
00454
00455 LOG4CPLUS_WARN(log_,"FUEventProcessor::stopEventProcessor.1 state "
00456 << evtProcessor_->stateName(st));
00457 edm::EventProcessor::StatusCode rc = edm::EventProcessor::epSuccess;
00458 if(!(st==edm::event_processor::sStopping || st==edm::event_processor::sJobReady
00459 || st==edm::event_processor::sDone)){
00460 ::sleep(1);
00461 st = evtProcessor_->getState();
00462 if(st!=edm::event_processor::sStopping) {
00463 LOG4CPLUS_WARN(log_,
00464 "FUEventProcessor::stopEventProcessor.2 After 1s - state: "
00465 << evtProcessor_->stateName(st));
00466 return edm::EventProcessor::epOther;
00467 }
00468 }
00469 LOG4CPLUS_WARN(log_,"FUEventProcessor::stopEventProcessor.3 state "
00470 << evtProcessor_->stateName(st));
00471
00472 try {
00473 rc = evtProcessor_->waitTillDoneAsync(timeoutOnStop_.value_);
00474 watching_ = false;
00475 }
00476 catch(cms::Exception &e) {
00477 XCEPT_RAISE(evf::Exception,e.explainSelf());
00478 }
00479 catch(std::exception &e) {
00480 XCEPT_RAISE(evf::Exception,e.what());
00481 }
00482 catch(...) {
00483 XCEPT_RAISE(evf::Exception,"Unknown Exception");
00484 }
00485 allPastLumiProcessed_ = 0;
00486 return rc;
00487
00488 }
00489
00490 void FWEPWrapper::stopAndHalt()
00491 {
00492 edm::ServiceRegistry::Operate operate(serviceToken_);
00493 ModuleWebRegistry *mwr = 0;
00494 try{
00495 if(edm::Service<ModuleWebRegistry>().isAvailable())
00496 mwr = edm::Service<ModuleWebRegistry>().operator->();
00497 }
00498 catch(...) {
00499 LOG4CPLUS_INFO(log_,
00500 "exception when trying to get service ModuleWebRegistry");
00501 }
00502
00503 if(mwr)
00504 {
00505 mwr->clear();
00506 }
00507
00508 ServiceWebRegistry *swr = 0;
00509 try{
00510 if(edm::Service<ServiceWebRegistry>().isAvailable())
00511 swr = edm::Service<ServiceWebRegistry>().operator->();
00512 }
00513 catch(...) {
00514 LOG4CPLUS_INFO(log_,
00515 "exception when trying to get service ModuleWebRegistry");
00516 }
00517
00518 if(swr)
00519 {
00520 swr->clear();
00521 }
00522
00523 edm::event_processor::State st = evtProcessor_->getState();
00524 edm::EventProcessor::StatusCode rc = stop();
00525 watching_ = false;
00526 if(rc != edm::EventProcessor::epTimedOut)
00527 {
00528
00529 if(st == edm::event_processor::sJobReady || st == edm::event_processor::sDone)
00530 evtProcessor_->endJob();
00531 pthread_mutex_lock(&ep_guard_lock_);
00532 delete evtProcessor_;
00533 evtProcessor_ = 0;
00534 pthread_mutex_unlock(&ep_guard_lock_);
00535 epInitialized_ = false;
00536 }
00537 else
00538 {
00539 XCEPT_RAISE(evf::Exception,"EventProcessor stop timed out");
00540 }
00541 allPastLumiProcessed_ = 0;
00542 }
00543
00544 void FWEPWrapper::startMonitoringWorkLoop() throw (evf::Exception)
00545 {
00546 pid_t pid = getpid();
00547 nbProcessed_.value_ = 0;
00548 nbAccepted_.value_ = 0;
00549 struct timezone timezone;
00550 gettimeofday(&monStartTime_,&timezone);
00551
00552 std::ostringstream ost;
00553 ost << "Monitoring" << pid;
00554 try {
00555 wlMonitoring_=
00556 toolbox::task::getWorkLoopFactory()->getWorkLoop(ost.str().c_str(),
00557 "waiting");
00558
00559 if (!wlMonitoring_->isActive()) wlMonitoring_->activate();
00560 asMonitoring_ = toolbox::task::bind(this,&FWEPWrapper::monitoring,
00561 ost.str().c_str());
00562
00563 wlMonitoring_->submit(asMonitoring_);
00564 wlMonitoringActive_ = true;
00565
00566 }
00567 catch (xcept::Exception& e) {
00568 std::string msg = "Failed to start workloop 'Monitoring'.";
00569
00570 XCEPT_RETHROW(evf::Exception,msg,e);
00571 }
00572 }
00573
00574
00575
00576
00577 bool FWEPWrapper::monitoring(toolbox::task::WorkLoop* wl)
00578 {
00579
00580 struct timeval monEndTime;
00581 struct timezone timezone;
00582 gettimeofday(&monEndTime,&timezone);
00583 edm::ServiceRegistry::Operate operate(serviceToken_);
00584 MicroStateService *mss = 0;
00585 if(!hasSubProcesses) monitorInfoSpace_->lock();
00586 if(evtProcessor_)
00587 {
00588 epMState_ = evtProcessor_->currentStateName();
00589 epMAltState_ = (int) evtProcessor_->getState();
00590 }
00591 else
00592 {
00593 epMState_ = "Off";
00594 epMAltState_ = -1;
00595 }
00596 if(0 != evtProcessor_ && evtProcessor_->getState() != edm::event_processor::sInit)
00597 {
00598 try{
00599 mss = edm::Service<MicroStateService>().operator->();
00600 }
00601 catch(...) {
00602 LOG4CPLUS_INFO(log_,
00603 "exception when trying to get service MicroStateService");
00604 }
00605 lsid_ = lumiSectionIndex_.value_;
00606 psid_ = prescaleSetIndex_.value_;
00607 }
00608 if(mss)
00609 {
00610 epmState_ = mss->getMicroState2();
00611 epmAltState_ = modmap_[mss->getMicroState2()];
00612 }
00613 if(evtProcessor_)
00614 {
00615 nbProcessed_ = evtProcessor_->totalEvents();
00616 nbAccepted_ = evtProcessor_->totalEventsPassed();
00617 }
00618 if(!hasSubProcesses) monitorInfoSpace_->unlock();
00619
00620 ::sleep(monSleepSec_.value_);
00621 return true;
00622 }
00623
00624 bool FWEPWrapper::getTriggerReport(bool useLock)
00625 {
00626 edm::ServiceRegistry::Operate operate(serviceToken_);
00627
00628
00629
00630
00631 LOG4CPLUS_DEBUG(log_,"getTriggerReport action invoked");
00632
00633
00634 ModuleWebRegistry *mwr = 0;
00635 try{
00636 if(edm::Service<ModuleWebRegistry>().isAvailable())
00637 mwr = edm::Service<ModuleWebRegistry>().operator->();
00638 }
00639 catch(...) {
00640 LOG4CPLUS_INFO(log_,
00641 "exception when trying to get service ModuleWebRegistry");
00642 return false;
00643 }
00644 edm::TriggerReport tr;
00645 if(mwr==0) return false;
00646
00647 unsigned int ls = 0;
00648 unsigned int ps = 0;
00649 timeval tv;
00650 if(useLock) {
00651 gettimeofday(&tv,0);
00652
00653
00654 mwr->openBackDoor("DaqSource",lsTimeOut_,&waitingForLs_);
00655
00656 }
00657
00658 xdata::Table::iterator it = scalersComplete_.begin();
00659 ps = lastLumiPrescaleIndex_.value_;
00660
00661 it->setField("psid",lastLumiPrescaleIndex_);
00662 psid_ = prescaleSetIndex_.value_;
00663 if(prescaleSvc_ != 0) prescaleSvc_->setIndex(psid_);
00664 ls = lumiSectionIndex_.value_;
00665 localLsIncludingTimeOuts_.value_ = ls;
00666 it->setField("lsid", localLsIncludingTimeOuts_);
00667
00668 lsTriplet lst;
00669 lst.ls = localLsIncludingTimeOuts_.value_;
00670 lst.proc = evtProcessor_->totalEvents()-allPastLumiProcessed_;
00671 lst.acc = evtProcessor_->totalEventsPassed()-
00672 (rollingLsWrap_ ? lumiSectionsCtr_[0].acc : lumiSectionsCtr_[rollingLsIndex_+1].acc);
00673 lumiSectionsCtr_[rollingLsIndex_] = lst;
00674 allPastLumiProcessed_ = evtProcessor_->totalEvents();
00675
00676
00677 evtProcessor_->getTriggerReport(tr);
00678
00679 if(useLock){
00680
00681 mwr->closeBackDoor("DaqSource");
00682
00683 }
00684
00685 trh_.formatReportTable(tr,descs_,pathTable_,false);
00686
00687
00688 trh_.triggerReportUpdate(tr,ls,ps,trh_.checkLumiSection(ls));
00689 ShmOutputModuleRegistry *sor = 0;
00690 try{
00691 if(edm::Service<ShmOutputModuleRegistry>().isAvailable())
00692 sor = edm::Service<ShmOutputModuleRegistry>().operator->();
00693 }
00694 catch(...) {
00695 LOG4CPLUS_INFO(log_,
00696 "exception when trying to get service ShmOutputModuleRegistry");
00697 return false;
00698 }
00699
00700
00701 trh_.packTriggerReport(tr,sor);
00702 it->setField("triggerReport",trh_.getTableWithNames());
00703
00704 return true;
00705 }
00706
00707 bool FWEPWrapper::fireScalersUpdate()
00708 {
00709
00710 scalersUpdateAttempted_++;
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729 if(scalersUpdateAttempted_%10 == 0)
00730 monitorLegendaInfoSpace_->fireItemGroupChanged(namesStatusLegenda_,0);
00731
00732
00733 if(rcms_==0) return false;
00734 try{
00735 if(trh_.getProcThisLumi()!=0U)
00736 createAndSendScalersMessage();
00737 scalersUpdateCounter_++;
00738 }
00739 catch(...){return false;}
00740 return true;
00741 }
00742
00743
00744
00745 void FWEPWrapper::summaryWebPage(xgi::Input *in, xgi::Output *out,const std::string &urn)
00746 {
00747
00748
00749 *out << "<table>" << std::endl;
00750
00751 *out << "<tr valign=\"top\">" << std::endl;
00752 *out << "<td>" << std::endl;
00753
00754 TriggerReportStatic *tr = (TriggerReportStatic *)(trh_.getPackedTriggerReport()->mtext);
00755
00756 *out << "<table border=1 bgcolor=\"#CFCFCF\">" << std::endl;
00757 *out << " <tr>" << std::endl;
00758 *out << " <th colspan=7>" << std::endl;
00759 *out << " " << "Trigger Summary up to LS "
00760 << trh_.getLumiSectionReferenceIndex()-1 << std::endl;
00761 *out << " </th>" << std::endl;
00762 *out << " </tr>" << std::endl;
00763
00764 *out << " <tr >" << std::endl;
00765 *out << " <th >Path</th>" << std::endl;
00766 *out << " <th >Exec</th>" << std::endl;
00767 *out << " <th >Pass</th>" << std::endl;
00768 *out << " <th >Fail</th>" << std::endl;
00769 *out << " <th >Except</th>" << std::endl;
00770 *out << " </tr>" << std::endl;
00771
00772
00773 for(int i=0; i<tr->trigPathsInMenu; i++) {
00774 *out << " <tr>" << std::endl;
00775 *out << " <td>"<< i << "</td>" << std::endl;
00776 *out << " <td>" << trh_.getl1pre(i) << "</td>" << std::endl;
00777 *out << " <td>" << trh_.getaccept(i) << "</td>" << std::endl;
00778 *out << " <td >" << trh_.getfailed(i) << "</td>" << std::endl;
00779 *out << " <td ";
00780 if(trh_.getexcept(i) !=0)
00781 *out << "bgcolor=\"red\"" << std::endl;
00782 *out << ">" << trh_.getexcept(i) << "</td>" << std::endl;
00783 *out << " </tr >" << std::endl;
00784
00785 }
00786 *out << " <tr><th colspan=7>EndPaths</th></tr>" << std::endl;
00787
00788 for(int i=tr->trigPathsInMenu; i<tr->endPathsInMenu + tr->trigPathsInMenu; i++) {
00789 *out << " <tr>" << std::endl;
00790 *out << " <td>"<< i << "</td>" << std::endl;
00791 *out << " <td>" << trh_.getl1pre(i) << "</td>" << std::endl;
00792 *out << " <td>" << trh_.getaccept(i) << "</td>" << std::endl;
00793 *out << " <td >" << trh_.getfailed(i) << "</td>" << std::endl;
00794 *out << " <td ";
00795 if(trh_.getexcept(i) !=0)
00796 *out << "bgcolor=\"red\"" << std::endl;
00797 *out << ">" << trh_.getexcept(i) << "</td>" << std::endl;
00798 *out << " </tr >" << std::endl;
00799
00800 }
00801
00802
00803 *out << "</table>" << std::endl;
00804 *out << "</td>" << std::endl;
00805 *out << "</tr>" << std::endl;
00806 *out << "</table>" << std::endl;
00807 }
00808
00809
00810
00811 void FWEPWrapper::taskWebPage(xgi::Input *in, xgi::Output *out,const std::string &urn)
00812 {
00813
00814 ModuleWebRegistry *mwr = 0;
00815 edm::ServiceRegistry::Operate operate(evtProcessor_->getToken());
00816 try{
00817 if(edm::Service<ModuleWebRegistry>().isAvailable())
00818 mwr = edm::Service<ModuleWebRegistry>().operator->();
00819 }
00820 catch(...) {
00821 LOG4CPLUS_WARN(log_,
00822 "Exception when trying to get service ModuleWebRegistry");
00823 }
00824 TimeProfilerService *tpr = 0;
00825 try{
00826 if(edm::Service<TimeProfilerService>().isAvailable())
00827 tpr = edm::Service<TimeProfilerService>().operator->();
00828 }
00829 catch(...) {
00830 }
00831
00832 *out << "<table>" << std::endl;
00833
00834 *out << "<tr valign=\"top\">" << std::endl;
00835 *out << "<td>" << std::endl;
00836
00837
00838 edm::TriggerReport tr;
00839 evtProcessor_->getTriggerReport(tr);
00840
00841
00842 *out << "<table border=1 bgcolor=\"#CFCFCF\">" << std::endl;
00843 *out << " <tr>" << std::endl;
00844 *out << " <th colspan=7>" << std::endl;
00845 *out << " " << "Trigger Summary" << std::endl;
00846 *out << " </th>" << std::endl;
00847 *out << " </tr>" << std::endl;
00848
00849 *out << " <tr >" << std::endl;
00850 *out << " <th >Path</th>" << std::endl;
00851 *out << " <th >Exec</th>" << std::endl;
00852 *out << " <th >Pass</th>" << std::endl;
00853 *out << " <th >Fail</th>" << std::endl;
00854 *out << " <th >Except</th>" << std::endl;
00855 *out << " <th >TargetPF</th>" << std::endl;
00856 *out << " </tr>" << std::endl;
00857 xdata::Serializable *psid = 0;
00858 try{
00859 psid = applicationInfoSpace_->find("prescaleSetIndex");
00860 }
00861 catch(xdata::exception::Exception e){
00862 }
00863 ShmOutputModuleRegistry *sor = 0;
00864 try{
00865 if(edm::Service<ShmOutputModuleRegistry>().isAvailable())
00866 sor = edm::Service<ShmOutputModuleRegistry>().operator->();
00867 }
00868 catch(...) {
00869 LOG4CPLUS_INFO(log_,
00870 "exception when trying to get service ShmOutputModuleRegistry");
00871 }
00872
00873
00874 for(unsigned int i=0; i<tr.trigPathSummaries.size(); i++) {
00875 *out << " <tr>" << std::endl;
00876 *out << " <td>"<< tr.trigPathSummaries[i].name << "</td>" << std::endl;
00877 *out << " <td>" << tr.trigPathSummaries[i].timesRun << "</td>" << std::endl;
00878
00879 *out << " <td>" << tr.trigPathSummaries[i].timesPassed << "</td>" << std::endl;
00880 *out << " <td >" << tr.trigPathSummaries[i].timesFailed << "</td>" << std::endl;
00881
00882 *out << " <td ";
00883 if(tr.trigPathSummaries[i].timesExcept !=0)
00884 *out << "bgcolor=\"red\"" << std::endl;
00885 *out << ">" << tr.trigPathSummaries[i].timesExcept << "</td>" << std::endl;
00886 if(psid != 0)
00887 {
00888 *out << " <td>"
00889 << prescaleSvc_->getPrescale(tr.trigPathSummaries[i].name)
00890 << "</td>" << std::endl;
00891 }
00892 else *out << " <td>N/A</td>" << std::endl;
00893 *out << " </tr >" << std::endl;
00894
00895 }
00896
00897
00898
00899 for(unsigned int i=0; i<tr.endPathSummaries.size(); i++) {
00900 std::string olab = trh_.findLabelOfModuleTypeInEndPath(tr,descs_,
00901 i,"ShmStreamConsumer");
00902 evf::OutputModule *o = sor->get(olab);
00903 *out << " <tr>" << std::endl;
00904 *out << " <td>"<< tr.endPathSummaries[i].name << "</td>" << std::endl;
00905 *out << " <td>" << tr.endPathSummaries[i].timesRun << "</td>" << std::endl;
00906 *out << " <td>" << (o ? o->getCounts() : -1) << "</td>" << std::endl;
00907 *out << " <td >" << (o ? (tr.endPathSummaries[i].timesRun - o->getCounts()) : -1) << "</td>" << std::endl;
00908 *out << " <td ";
00909 if(tr.endPathSummaries[i].timesExcept !=0)
00910 *out << "bgcolor=\"red\"" << std::endl;
00911 *out << ">" << tr.endPathSummaries[i].timesExcept << "</td>" << std::endl;
00912 *out << " <td>N/A</td>" << std::endl;
00913 *out << " </tr >" << std::endl;
00914
00915 }
00916
00917 *out << "</table>" << std::endl;
00918
00919 *out << "</td>" << std::endl;
00920
00921
00922
00923 *out << "<td>" << std::endl;
00924
00925 *out << "<table frame=\"void\" rules=\"rows\" class=\"modules\">" << std::endl;
00926 *out << " <tr>" << std::endl;
00927 *out << " <th colspan=3>" << std::endl;
00928 *out << " " << "HLT" << std::endl;
00929 if(descs_.size()>0)
00930 *out << " (Process " << descs_[0]->processName() << ")" << std::endl;
00931 *out << " </th>" << std::endl;
00932 *out << " </tr>" << std::endl;
00933
00934 *out << " <tr >" << std::endl;
00935 *out << " <th >" << std::endl;
00936 *out << " Module" << std::endl;
00937 *out << " </th>" << std::endl;
00938 *out << " <th >" << std::endl;
00939 *out << " Label" << std::endl;
00940 *out << " </th>" << std::endl;
00941 *out << " <th >" << std::endl;
00942 *out << " Version" << std::endl;
00943 *out << " </th>" << std::endl;
00944 if(tpr)
00945 {
00946 *out << " <th >" << std::endl;
00947 *out << " first" << std::endl;
00948 *out << " </th>" << std::endl;
00949 *out << " <th >" << std::endl;
00950 *out << " ave" << std::endl;
00951 *out << " </th>" << std::endl;
00952 *out << " <th >" << std::endl;
00953 *out << " max" << std::endl;
00954 *out << " </th>" << std::endl;
00955 }
00956 *out << " </tr>" << std::endl;
00957 if(mwr && mwr->checkWeb("DaqSource"))
00958 *out << " <tr><td ><a href=\"/" << urn
00959 << "module=DaqSource\">DaqSource</a> </td></tr>";
00960
00961 for(unsigned int idesc = 0; idesc < descs_.size(); idesc++)
00962 {
00963 *out << " <tr>" << std::endl;
00964 *out << " <td >";
00965 if(mwr && mwr->checkWeb(descs_[idesc]->moduleName()))
00966 *out << "<a href=\"/" << urn
00967 << "module="
00968 << descs_[idesc]->moduleName() << "\">"
00969 << descs_[idesc]->moduleName() << "</a>";
00970 else
00971 *out << descs_[idesc]->moduleName();
00972 *out << "</td>" << std::endl;
00973 *out << " <td >";
00974 *out << descs_[idesc]->moduleLabel();
00975 *out << "</td>" << std::endl;
00976 *out << " <td >";
00977 *out << descs_[idesc]->releaseVersion();
00978 *out << "</td>" << std::endl;
00979 if(tpr)
00980 {
00981 *out << " <td align=\"right\">";
00982 *out << tpr->getFirst(descs_[idesc]->moduleLabel());
00983 *out << "</td>" << std::endl;
00984 *out << " <td align=\"right\"";
00985 *out << (tpr->getAve(descs_[idesc]->moduleLabel())>1. ? "bgcolor=\"red\"" : "")
00986 << ">";
00987 *out << tpr->getAve(descs_[idesc]->moduleLabel());
00988 *out << "</td>" << std::endl;
00989 *out << " <td align=\"right\">";
00990 *out << tpr->getMax(descs_[idesc]->moduleLabel());
00991 *out << "</td>" << std::endl;
00992 }
00993 *out << " </tr>" << std::endl;
00994 }
00995 *out << "</table>" << std::endl;
00996 *out << "</td>" << std::endl;
00997 }
00998
00999
01000 void FWEPWrapper::moduleWeb(xgi::Input *in, xgi::Output *out)
01001 {
01002 using namespace cgicc;
01003 Cgicc cgi(in);
01004 std::vector<FormEntry> el1;
01005 cgi.getElement("module",el1);
01006 if(evtProcessor_) {
01007 if(el1.size()!=0) {
01008 std::string mod = el1[0].getValue();
01009 edm::ServiceRegistry::Operate operate(evtProcessor_->getToken());
01010 ModuleWebRegistry *mwr = 0;
01011 try{
01012 if(edm::Service<ModuleWebRegistry>().isAvailable())
01013 mwr = edm::Service<ModuleWebRegistry>().operator->();
01014 }
01015 catch(...) {
01016 LOG4CPLUS_WARN(log_,
01017 "Exception when trying to get service ModuleWebRegistry");
01018 }
01019 mwr->invoke(in,out,mod);
01020 }
01021 }
01022 else {
01023 *out<<"EventProcessor just disappeared "<<std::endl;
01024 }
01025 }
01026
01027
01028
01029 void FWEPWrapper::serviceWeb(xgi::Input *in, xgi::Output *out)
01030 {
01031 using namespace cgicc;
01032 Cgicc cgi(in);
01033 std::vector<FormEntry> el1;
01034 cgi.getElement("service",el1);
01035 if(evtProcessor_) {
01036 if(el1.size()!=0) {
01037 std::string ser = el1[0].getValue();
01038 edm::ServiceRegistry::Operate operate(evtProcessor_->getToken());
01039 ServiceWebRegistry *swr = 0;
01040 try{
01041 if(edm::Service<ServiceWebRegistry>().isAvailable())
01042 swr = edm::Service<ServiceWebRegistry>().operator->();
01043 }
01044 catch(...) {
01045 LOG4CPLUS_WARN(log_,
01046 "Exception when trying to get service ModuleWebRegistry");
01047 }
01048 swr->invoke(in,out,ser);
01049 }
01050 }
01051 else {
01052 *out<<"EventProcessor just disappeared "<<std::endl;
01053 }
01054 }
01055
01056
01057 void FWEPWrapper::microState(xgi::Input *in, xgi::Output *out)
01058 {
01059 edm::ServiceRegistry::Operate operate(serviceToken_);
01060 MicroStateService *mss = 0;
01061 std::string micro1 = "unavailable";
01062 if(epInitialized_)
01063 micro1 = "initialized";
01064 std::string micro2 = "unavailable";
01065 if(evtProcessor_!=0 && evtProcessor_->getState() != edm::event_processor::sInit)
01066 {
01067 try{
01068 mss = edm::Service<MicroStateService>().operator->();
01069 }
01070 catch(...) {
01071 LOG4CPLUS_INFO(log_,
01072 "exception when trying to get service MicroStateService");
01073 }
01074 pthread_mutex_lock(&ep_guard_lock_);
01075 if(evtProcessor_!=0) micro1 = evtProcessor_->currentStateName();
01076 pthread_mutex_unlock(&ep_guard_lock_);
01077 }
01078
01079 if(mss) {
01080 micro2 = mss->getMicroState2();
01081 }
01082
01083
01084 *out << "<td>" << micro1 << "</td>";
01085 *out << "<td>" << micro2 << "</td>";
01086 *out << "<td>" << nbAccepted_.value_ << "/" << nbProcessed_.value_
01087 << " (" << float(nbAccepted_.value_)/float(nbProcessed_.value_)*100. <<"%)" << "</td>";
01088 *out << "<td>" << lsid_ << "/" << lsidTimedOutAsString_ << "</td>";
01089 *out << "<td>" << psid_ << "</td>";
01090
01091
01092 }
01093
01094 void FWEPWrapper::lumiSumTable(xgi::Output *out)
01095 {
01096
01097 *out << " <table border=1 bgcolor=\"#CFCFCF\">" << std::endl;
01098 *out << " <tr>" << std::endl;
01099 *out << " <td> LS </td>";
01100 if(rollingLsWrap_)
01101 {
01102 for(unsigned int i = rollingLsIndex_; i < lumiSectionsCtr_.size(); i++)
01103 *out << "<td " << (lumiSectionsTo_[i] ? "bgcolor=\"red\"" : "")
01104 << ">" << lumiSectionsCtr_[i].ls << "</td>" << std::endl;
01105 for(unsigned int i = 0; i < rollingLsIndex_; i++)
01106 *out << "<td " << (lumiSectionsTo_[i] ? "bgcolor=\"red\"" : "")
01107 << ">" << lumiSectionsCtr_[i].ls << "</td>" << std::endl;
01108 }
01109 else
01110 for(unsigned int i = rollingLsIndex_; i < lumiSectionsCtr_.size(); i++)
01111 *out << "<td " << (lumiSectionsTo_[i] ? "bgcolor=\"red\"" : "")
01112 << ">" << lumiSectionsCtr_[i].ls << "</td>" << std::endl;
01113
01114 *out << " </tr>" << std::endl;
01115 *out << " <tr>" << std::endl;
01116 *out << " <td> Ev </td>";
01117 if(rollingLsWrap_)
01118 {
01119 for(unsigned int i = rollingLsIndex_; i < lumiSectionsCtr_.size(); i++)
01120 *out << "<td>" << lumiSectionsCtr_[i].proc << "</td>" << std::endl;
01121 for(unsigned int i = 0; i < rollingLsIndex_; i++)
01122 *out << "<td>" << lumiSectionsCtr_[i].proc << "</td>" << std::endl;
01123 }
01124 else
01125 for(unsigned int i = rollingLsIndex_; i < lumiSectionsCtr_.size(); i++)
01126 *out << "<td>" << lumiSectionsCtr_[i].proc << "</td>" << std::endl;
01127 *out << " </tr>" << std::endl;
01128 *out << " <tr>" << std::endl;
01129 *out << " <td> Acc </td>";
01130 if(rollingLsWrap_)
01131 {
01132 for(unsigned int i = rollingLsIndex_; i < lumiSectionsCtr_.size(); i++)
01133 *out << "<td>" << lumiSectionsCtr_[i].acc << "</td>" << std::endl;
01134 for(unsigned int i = 0; i < rollingLsIndex_; i++)
01135 *out << "<td>" << lumiSectionsCtr_[i].acc << "</td>" << std::endl;
01136 }
01137 else
01138 for(unsigned int i = rollingLsIndex_; i < lumiSectionsCtr_.size(); i++)
01139 *out << "<td>" << lumiSectionsCtr_[i].acc << "</td>" << std::endl;
01140 *out << " </tr>" << std::endl;
01141 *out << "</table>" << std::endl;
01142 }
01143
01144
01145 void FWEPWrapper::sumAndPackTriggerReport(MsgBuf &buf)
01146 {
01147 trh_.sumAndPackTriggerReport(buf);
01148 }
01149 void FWEPWrapper::updateRollingReport()
01150 {
01151 trh_.packedTriggerReportToTable();
01152 if(rollingLsIndex_==0){rollingLsIndex_=lsRollSize_; rollingLsWrap_ = true;}
01153 rollingLsIndex_--;
01154 xdata::UnsignedInteger32* lsp = 0;
01155 xdata::UnsignedInteger32* psp = 0;
01156 TriggerReportStatic *tr = trh_.getPackedTriggerReportAsStruct();
01157 lsTriplet lst;
01158 lst.ls = tr->lumiSection;
01159 lsid_ = tr->lumiSection;
01160 lst.proc = tr->eventSummary.totalEvents;
01161 lst.acc = tr->eventSummary.totalEventsPassed;
01162 xdata::Serializable *psid = 0;
01163 xdata::Serializable *lsid = 0;
01164 xdata::Serializable *nbs = 0;
01165 xdata::Serializable *nbsr = 0;
01166 try{
01167 lsid =applicationInfoSpace_->find("lumiSectionIndex");
01168 if(lsid!=0){
01169 lsp = ((xdata::UnsignedInteger32*)lsid);
01170 lsp->value_= tr->lumiSection;
01171 }
01172 psid = applicationInfoSpace_->find("lastLumiPrescaleIndex");
01173 if(psid!=0) {
01174 psp = ((xdata::UnsignedInteger32*)psid);
01175 if(tr->eventSummary.totalEvents != 0)
01176 psp->value_ = tr->prescaleIndex;
01177 }
01178 nbs = applicationInfoSpace_->find("nbSubProcesses");
01179 nbsr = applicationInfoSpace_->find("nbSubProcessesReporting");
01180 }
01181 catch(xdata::exception::Exception e){
01182 }
01183
01184 xdata::Table::iterator it = scalersComplete_.begin();
01185 if(lsp)
01186 it->setField("lsid", *lsp);
01187 if(psp)
01188 it->setField("psid", *psp);
01189 if(nbs)
01190 it->setField("exprep", *nbs);
01191 else
01192 std::cout << "nbSubProcesses item not found !!!" << std::endl;
01193 if(nbsr)
01194 it->setField("effrep", *nbsr);
01195 else
01196 std::cout << "nbSubProcessesReporting item not found !!!" << std::endl;
01197
01198 it->setField("proc",trh_.getProcThisLumi());
01199 it->setField("acc",trh_.getAccThisLumi());
01200 it->setField("triggerReport",trh_.getTableWithNames());
01201 lumiSectionsCtr_[rollingLsIndex_] = lst;
01202
01203 }
01204
01205
01206 void FWEPWrapper::createAndSendScalersMessage()
01207 {
01208 toolbox::net::URL url(rcms_->getContextDescriptor()->getURL());
01209 toolbox::net::URL at(xappDesc_->getContextDescriptor()->getURL() + "/" + xappDesc_->getURN());
01210 toolbox::net::URL properurl(url.getProtocol(),url.getHost(),url.getPort(),"");
01211 xdaq::ContextDescriptor *ctxdsc = new xdaq::ContextDescriptor(properurl.toString());
01212 xdaq::ApplicationDescriptor *appdesc = new xdaq::ApplicationDescriptorImpl(ctxdsc,rcms_->getClassName(),rcms_->getLocalId(), "pippo");
01213
01214 appdesc->setAttribute("path","/rcms/servlet/monitorreceiver");
01215
01216 xoap::MessageReference msg = xoap::createMessage();
01217 xoap::SOAPEnvelope envelope = msg->getSOAPPart().getEnvelope();
01218 xoap::SOAPName responseName = envelope.createName( "report", xmas::NamespacePrefix, xmas::NamespaceUri);
01219 (void) envelope.getBody().addBodyElement ( responseName );
01220 xoap::SOAPName reportName ("report", xmas::NamespacePrefix, xmas::NamespaceUri);
01221 xoap::SOAPElement reportElement = envelope.getBody().getChildElements(reportName)[0];
01222 reportElement.addNamespaceDeclaration (xmas::sensor::NamespacePrefix, xmas::sensor::NamespaceUri);
01223 xoap::SOAPName sampleName = envelope.createName( "sample", xmas::NamespacePrefix, xmas::NamespaceUri);
01224 xoap::SOAPElement sampleElement = reportElement.addChildElement(sampleName);
01225 xoap::SOAPName flashListName = envelope.createName( "flashlist", "", "");
01226 sampleElement.addAttribute(flashListName,"urn:xdaq-flashlist:scalers");
01227 xoap::SOAPName tagName = envelope.createName( "tag", "", "");
01228 sampleElement.addAttribute(tagName,"tag");
01229 xoap::MimeHeaders* headers = msg->getMimeHeaders();
01230 headers->removeHeader("x-xdaq-tags");
01231 headers->addHeader("x-xdaq-tags", "tag");
01232 tagName = envelope.createName( "originator", "", "");
01233 sampleElement.addAttribute(tagName,at.toString());
01234
01235 xdata::exdr::AutoSizeOutputStreamBuffer outBuffer;
01236 xdata::exdr::Serializer serializer;
01237 try
01238 {
01239 serializer.exportAll( &scalersComplete_, &outBuffer );
01240 }
01241 catch(xdata::exception::Exception & e)
01242 {
01243 LOG4CPLUS_WARN(log_,
01244 "Exception in serialization of scalers table");
01245
01246 throw;
01247 }
01248
01249 xoap::AttachmentPart * attachment = msg->createAttachmentPart(outBuffer.getBuffer(), outBuffer.tellp(), "application/x-xdata+exdr");
01250 attachment->setContentEncoding("binary");
01251 tagName = envelope.createName( "tag", "", "");
01252 sampleElement.addAttribute(tagName,"tag");
01253 std::stringstream contentId;
01254
01255 contentId << "<" << "urn:xdaq-flashlist:scalers" << "@" << at.getHost() << ">";
01256 attachment->setContentId(contentId.str());
01257 std::stringstream contentLocation;
01258 contentId << at.toString();
01259 attachment->setContentLocation(contentLocation.str());
01260
01261 std::stringstream disposition;
01262 disposition << "attachment; filename=" << "urn:xdaq-flashlist:scalers" << ".exdr; creation-date=" << "\"" << "dummy" << "\"";
01263 attachment->addMimeHeader("Content-Disposition",disposition.str());
01264 msg->addAttachmentPart(attachment);
01265
01266 try{
01267 xappCtxt_->postSOAP(msg,*(xappDesc_),*appdesc);
01268 }
01269 catch(xdaq::exception::Exception &ex)
01270 {
01271 std::string message = "exception when posting SOAP message to MonitorReceiver";
01272 message += ex.what();
01273 LOG4CPLUS_WARN(log_,message.c_str());
01274 std::string lmessage = "-W- "+message;
01275 delete appdesc;
01276 delete ctxdsc;
01277 throw;
01278
01279 }
01280 delete appdesc;
01281 delete ctxdsc;
01282 }
01283 }