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