CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/EventFilter/Processor/src/TriggerReportHelpers.cc

Go to the documentation of this file.
00001 #include "EventFilter/Utilities/interface/Exception.h"
00002 #include "EventFilter/Utilities/interface/ShmOutputModuleRegistry.h"
00003 #include "EventFilter/Modules/src/FUShmOutputModule.h"
00004 #include "TriggerReportHelpers.h"
00005 #include "FWCore/Framework/interface/TriggerReport.h"
00006 #include "DataFormats/Provenance/interface/ModuleDescription.h"
00007 #include "xdata/TableIterator.h"
00008 
00009 #include <iostream>
00010 #include <sstream>
00011 #include <algorithm>
00012 #include <map>
00013 
00014 #include "boost/tokenizer.hpp"
00015 
00016 namespace evf{
00017   namespace fuep{
00018 const std::string TriggerReportHelpers::columns[5] = {"l1Pass","psPass","pAccept","pExcept","pReject"};
00019 void TriggerReportHelpers::triggerReportUpdate(edm::TriggerReport &tr, unsigned int ls, unsigned int ps, bool lumiComplete)
00020 {
00021   if(adjustLsIndex_)
00022     {
00023       lumiSectionIndex_=ls;
00024       adjustLsIndex_ = false;
00025     }
00026   else
00027     lumiSectionIndex_++;  
00028   if(lumiSectionIndex_ != ls)
00029     std::cout << getpid() << " WARNING: ls index mismatch " << ls << " should be " << lumiSectionIndex_ << std::endl;
00030   prescaleIndex_ = ps;
00031 }
00032     
00033 void TriggerReportHelpers::packedTriggerReportToTable()
00034 {
00035 
00036   TriggerReportStatic *trs = getPackedTriggerReportAsStruct();
00037 
00038   eventsProcessed_.value_ = trs->eventSummary.totalEvents;
00039   eventsAccepted_.value_  = trs->eventSummary.totalEventsPassed;
00040   for(int i=0; i<trs->trigPathsInMenu; i++) {
00041     pl1pre_[i] += (l1pre_[i] =trs->trigPathSummaries[i].timesPassedL1);
00042     triggerReportAsTable_.setValueAt(i,columns[0],l1pre_[i]);
00043     triggerReportAsTableWithNames_.setValueAt(i,columns[0],l1pre_[i]);
00044     pps_[i] += (ps_[i] = trs->trigPathSummaries[i].timesPassedPs);
00045     triggerReportAsTable_.setValueAt(i,columns[1],ps_[i]);
00046     triggerReportAsTableWithNames_.setValueAt(i,columns[1],ps_[i]);
00047     paccept_[i] += (accept_[i] = trs->trigPathSummaries[i].timesPassed);
00048     triggerReportAsTable_.setValueAt(i,columns[2], accept_[i]);
00049     triggerReportAsTableWithNames_.setValueAt(i,columns[2], accept_[i]);
00050     pexcept_[i] += (except_[i] = trs->trigPathSummaries[i].timesExcept);
00051     triggerReportAsTable_.setValueAt(i,columns[3], except_[i]);
00052     triggerReportAsTableWithNames_.setValueAt(i,columns[3], except_[i]);
00053     pfailed_[i] += (failed_[i] = trs->trigPathSummaries[i].timesFailed);
00054     triggerReportAsTable_.setValueAt(i,columns[4], failed_[i]);
00055     triggerReportAsTableWithNames_.setValueAt(i,columns[4], failed_[i]);
00056   }
00057   for(int i=0; i<trs->endPathsInMenu; i++) {    
00058     int j = i+trs->trigPathsInMenu;
00059     pl1pre_[j] += (l1pre_[j] = trs->endPathSummaries[i].timesPassedL1);
00060     triggerReportAsTable_.setValueAt(j,columns[0],l1pre_[j]);
00061     triggerReportAsTableWithNames_.setValueAt(j,columns[0],l1pre_[j]);
00062     pps_[j] += (ps_[j] = trs->endPathSummaries[i].timesPassedPs);
00063     triggerReportAsTable_.setValueAt(j,columns[1],ps_[j]);
00064     triggerReportAsTableWithNames_.setValueAt(j,columns[1],ps_[j]);
00065     paccept_[j] += (accept_[j] = trs->endPathSummaries[i].timesPassed);
00066     triggerReportAsTable_.setValueAt(j,columns[2], accept_[j]);
00067     triggerReportAsTableWithNames_.setValueAt(j,columns[2], accept_[j]);
00068     pexcept_[j] += (except_[j] = trs->endPathSummaries[i].timesExcept);
00069     triggerReportAsTable_.setValueAt(j,columns[3], except_[j]);
00070     triggerReportAsTableWithNames_.setValueAt(j,columns[3], except_[j]);
00071     pfailed_[j] += (failed_[j] = trs->endPathSummaries[i].timesFailed);
00072     triggerReportAsTable_.setValueAt(j,columns[4], failed_[j]);
00073     triggerReportAsTableWithNames_.setValueAt(j,columns[4], failed_[j]);
00074   }
00075 }
00076 
00077 void TriggerReportHelpers::fillPathIndexTable(std::string &pathstring)
00078 {
00079   unsigned int i = 0;
00080   if(pathstring == ""){
00081     for(; i<paths_.size(); i++) {
00082       xdata::Table::iterator it = triggerReportAsTableWithNames_.append();
00083       it->setField("pathIndex", pathIndexMap_[paths_[i]]=i);
00084     }
00085   }
00086   else{
00087     boost::char_separator<char> sep(",");
00088     boost::tokenizer<boost::char_separator<char> > tokens(pathstring, sep);
00089     for (boost::tokenizer<boost::char_separator<char> >::iterator tok_iter = tokens.begin();
00090          tok_iter != tokens.end(); ++tok_iter){
00091       unsigned int index = 0;
00092       std::string name;
00093       std::string::size_type pos = tok_iter->find("=");
00094       if(pos!=std::string::npos){
00095         name=tok_iter->substr(0,pos);
00096         index = atoi(tok_iter->substr(pos+1).c_str());
00097         pathIndexMap_[name]=index;
00098       }
00099     }
00100     for(; i<paths_.size(); i++) {
00101       if(pathIndexMap_.find(paths_[i])==pathIndexMap_.end())
00102         pathIndexMap_[paths_[i]] = i;
00103       xdata::Table::iterator it = triggerReportAsTableWithNames_.append();
00104       it->setField("pathIndex",pathIndexMap_[paths_[i]]);
00105     }
00106   }
00107 }
00108 
00109 void TriggerReportHelpers::formatReportTable(edm::TriggerReport &tr, 
00110                                              std::vector<edm::ModuleDescription const*>& descs,
00111                                              std::string &pathIndexTable,
00112                                              bool noNukeLegenda)  
00113 {
00114 
00115   if(tableFormatted_) return;
00116   std::ostringstream ost;
00117   trp_ = tr;
00118   lumiSectionIndex_ = 0;
00119   resetTriggerReport();
00120   TriggerReportStatic *trp = (TriggerReportStatic *)cache_->mtext;
00121 
00122   tableFormatted_ = true;
00123   paths_.resize(tr.trigPathSummaries.size()+tr.endPathSummaries.size());
00124   //adjust number of trigger- and end-paths in static structure
00125   trp->trigPathsInMenu = tr.trigPathSummaries.size();
00126   trp->endPathsInMenu = tr.endPathSummaries.size();
00128 
00129   l1pos_.resize(tr.trigPathSummaries.size()+tr.endPathSummaries.size(),-1);
00130   pspos_.resize(tr.trigPathSummaries.size()+tr.endPathSummaries.size(),-1);
00131   outname_.resize(tr.trigPathSummaries.size()+tr.endPathSummaries.size());
00132   l1pre_.resize(tr.trigPathSummaries.size()+tr.endPathSummaries.size(),0);
00133   ps_.resize(tr.trigPathSummaries.size()+tr.endPathSummaries.size(),0);
00134   accept_.resize(tr.trigPathSummaries.size()+tr.endPathSummaries.size(),0);
00135   except_.resize(tr.trigPathSummaries.size()+tr.endPathSummaries.size(),0);
00136   failed_.resize(tr.trigPathSummaries.size()+tr.endPathSummaries.size(),0);
00137   pl1pre_.resize(tr.trigPathSummaries.size()+tr.endPathSummaries.size(),0);
00138   pps_.resize(tr.trigPathSummaries.size()+tr.endPathSummaries.size(),0);
00139   paccept_.resize(tr.trigPathSummaries.size()+tr.endPathSummaries.size(),0);
00140   pexcept_.resize(tr.trigPathSummaries.size()+tr.endPathSummaries.size(),0);
00141   pfailed_.resize(tr.trigPathSummaries.size()+tr.endPathSummaries.size(),0);
00142   triggerReportAsTable_.clear();
00143   triggerReportAsTableWithNames_.clear();
00144   triggerReportAsTable_.addColumn(columns[0],"unsigned int 32");
00145   triggerReportAsTable_.addColumn(columns[1],"unsigned int 32");
00146   triggerReportAsTable_.addColumn(columns[2],"unsigned int 32");
00147   triggerReportAsTable_.addColumn(columns[3],"unsigned int 32");
00148   triggerReportAsTable_.addColumn(columns[4],"unsigned int 32");
00149   triggerReportAsTableWithNames_ = triggerReportAsTable_;
00150   triggerReportAsTableWithNames_.addColumn("pathIndex","unsigned int 32");
00151 
00152   unsigned int i=0;
00153   for(; i<tr.trigPathSummaries.size(); i++) {
00154     triggerReportAsTable_.append();
00155     paths_[i] = tr.trigPathSummaries[i].name;
00156 
00157     ost << i << "=" << paths_[i] << ", ";
00158 
00159     // reset the l1 and ps positions to pick up modifications of the menu
00160     // that result in paths being displaced up and down
00161     l1pos_[i] = -1;
00162     pspos_[i] = -1;
00163 
00164     for(unsigned int j=0;j<tr.trigPathSummaries[i].moduleInPathSummaries.size();j++) {
00165       std::string label = tr.trigPathSummaries[i].moduleInPathSummaries[j].moduleLabel;
00166       for(unsigned int k = 0; k < descs.size(); k++)
00167         {
00168           if(descs[k]->moduleLabel() == label) 
00169             {
00170               if(descs[k]->moduleName() == "HLTLevel1GTSeed") l1pos_[i] = j;
00171               if(descs[k]->moduleName() == "HLTPrescaler") pspos_[i] = j;
00172             }
00173         }
00174 
00175     }
00176 
00177   }
00178   for(; i<tr.endPathSummaries.size()+tr.trigPathSummaries.size(); i++) {
00179     triggerReportAsTable_.append();
00180     paths_[i] = tr.endPathSummaries[i-tr.trigPathSummaries.size()].name;
00181     ost << i << "=" << paths_[i] << ", ";
00182     // reset the l1 and ps positions to pick up modifications of the menu
00183     // that result in paths being displaced up and down
00184     l1pos_[i] = -1;
00185     pspos_[i] = -1;
00186     outname_[i] = "";
00187 
00188     for(unsigned int j=0;
00189         j<tr.endPathSummaries[i-tr.trigPathSummaries.size()].moduleInPathSummaries.size();
00190         j++) {
00191       std::string label = tr.endPathSummaries[i-tr.trigPathSummaries.size()].moduleInPathSummaries[j].moduleLabel;
00192       for(unsigned int k = 0; k < descs.size(); k++)
00193         {
00194           if(descs[k]->moduleLabel() == label) 
00195             {
00196               if(descs[k]->moduleName() == "TriggerResultsFilter") pspos_[i] = j;
00197               //              if(descs[k]->moduleName() == "HLTPrescaler") l1pos_[i] = j;
00198               if(descs[k]->moduleName() == "ShmStreamConsumer") 
00199                 outname_[i] = descs[k]->moduleLabel();
00200             }
00201         }
00202 
00203     }
00204   }
00205   fillPathIndexTable(pathIndexTable);
00206   if(noNukeLegenda) pathLegenda_ = ost.str().c_str();
00207 
00208 }
00209 
00210 void TriggerReportHelpers::printReportTable()
00211 {
00212   std::cout << "report table for LS #" << lumiSectionIndex_ << std::endl;
00213   triggerReportAsTableWithNames_.writeTo(std::cout);
00214   std::cout << std::endl;
00215 }
00216 void TriggerReportHelpers::printTriggerReport(edm::TriggerReport &tr)
00217 {
00218   std::ostringstream oss;
00219   
00220   oss<<"================================="<<"\n";
00221   oss<<"== BEGINNING OF TRIGGER REPORT =="<<"\n";
00222   oss<<"================================="<<"\n";
00223   oss<<"tr.eventSummary.totalEvents= "<<tr.eventSummary.totalEvents<<"\n" 
00224      <<"tr.eventSummary.totalEventsPassed= "<<tr.eventSummary.totalEventsPassed<<"\n"
00225      <<"tr.eventSummary.totalEventsFailed= "<<tr.eventSummary.totalEventsFailed<<"\n";
00226   
00227   oss<<"TriggerReport::trigPathSummaries"<<"\n";
00228   for(unsigned int i=0; i<tr.trigPathSummaries.size(); i++) {
00229     oss<<"tr.trigPathSummaries["<<i<<"].bitPosition = "
00230        <<tr.trigPathSummaries[i].bitPosition <<"\n" 
00231        <<"tr.trigPathSummaries["<<i<<"].timesRun = "
00232        <<tr.trigPathSummaries[i].timesRun <<"\n"
00233        <<"tr.trigPathSummaries["<<i<<"].timesPassed = "
00234        <<tr.trigPathSummaries[i].timesPassed <<"\n"
00235        <<"tr.trigPathSummaries["<<i<<"].timesFailed = "
00236        <<tr.trigPathSummaries[i].timesFailed <<"\n"
00237        <<"tr.trigPathSummaries["<<i<<"].timesExcept = "
00238        <<tr.trigPathSummaries[i].timesExcept <<"\n"
00239        <<"tr.trigPathSummaries["<<i<<"].name = "
00240        <<tr.trigPathSummaries[i].name <<"\n";
00241     
00242     //TriggerReport::trigPathSummaries::moduleInPathSummaries
00243     for(unsigned int j=0;j<tr.trigPathSummaries[i].moduleInPathSummaries.size();j++) {
00244       oss<<"tr.trigPathSummaries["<<i
00245          <<"].moduleInPathSummaries["<<j<<"].timesVisited = "
00246          <<tr.trigPathSummaries[i].moduleInPathSummaries[j].timesVisited<<"\n"
00247          <<"tr.trigPathSummaries["<<i
00248          <<"].moduleInPathSummaries["<<j<<"].timesPassed = "
00249          <<tr.trigPathSummaries[i].moduleInPathSummaries[j].timesPassed<<"\n"
00250          <<"tr.trigPathSummaries["<<i
00251          <<"].moduleInPathSummaries["<<j<<"].timesFailed = "
00252          <<tr.trigPathSummaries[i].moduleInPathSummaries[j].timesFailed<<"\n"
00253          <<"tr.trigPathSummaries["<<i
00254          <<"].moduleInPathSummaries["<<j<<"].timesExcept = "
00255          <<tr.trigPathSummaries[i].moduleInPathSummaries[j].timesExcept<<"\n"
00256          <<"tr.trigPathSummaries["<<i
00257          <<"].moduleInPathSummaries["<<j<<"].moduleLabel = "
00258          <<tr.trigPathSummaries[i].moduleInPathSummaries[j].moduleLabel<<"\n";
00259     }
00260   }
00261   
00262   //TriggerReport::endPathSummaries
00263   for(unsigned int i=0;i<tr.endPathSummaries.size();i++) {
00264     oss<<"tr.endPathSummaries["<<i<<"].bitPosition = "
00265        <<tr.endPathSummaries[i].bitPosition <<"\n" 
00266        <<"tr.endPathSummaries["<<i<<"].timesRun = "
00267        <<tr.endPathSummaries[i].timesRun <<"\n"
00268        <<"tr.endPathSummaries["<<i<<"].timesPassed = "
00269        <<tr.endPathSummaries[i].timesPassed <<"\n"
00270        <<"tr.endPathSummaries["<<i<<"].timesFailed = "
00271        <<tr.endPathSummaries[i].timesFailed <<"\n"
00272        <<"tr.endPathSummaries["<<i<<"].timesExcept = "
00273        <<tr.endPathSummaries[i].timesExcept <<"\n"
00274        <<"tr.endPathSummaries["<<i<<"].name = "
00275        <<tr.endPathSummaries[i].name <<"\n";
00276     
00277     //TriggerReport::endPathSummaries::moduleInPathSummaries
00278     for(unsigned int j=0;j<tr.endPathSummaries[i].moduleInPathSummaries.size();j++) {
00279       oss<<"tr.endPathSummaries["<<i
00280          <<"].moduleInPathSummaries["<<j<<"].timesVisited = "
00281          <<tr.endPathSummaries[i].moduleInPathSummaries[j].timesVisited <<"\n"
00282          <<"tr.endPathSummaries["<<i
00283          <<"].moduleInPathSummaries["<<j<<"].timesPassed = "
00284          <<tr.endPathSummaries[i].moduleInPathSummaries[j].timesPassed <<"\n"
00285          <<"tr.endPathSummaries["<<i
00286          <<"].moduleInPathSummaries["<<j<<"].timesFailed = "
00287          <<tr.endPathSummaries[i].moduleInPathSummaries[j].timesFailed <<"\n"
00288          <<"tr.endPathSummaries["<<i
00289          <<"].moduleInPathSummaries["<<j<<"].timesExcept = "
00290          <<tr.endPathSummaries[i].moduleInPathSummaries[j].timesExcept <<"\n"
00291          <<"tr.endPathSummaries["<<i
00292          <<"].moduleInPathSummaries["<<j<<"].moduleLabel = "
00293          <<tr.endPathSummaries[i].moduleInPathSummaries[j].moduleLabel <<"\n";
00294     }
00295   }
00296   
00297   //TriggerReport::workerSummaries
00298   for(unsigned int i=0; i<tr.workerSummaries.size(); i++) {
00299     oss<<"tr.workerSummaries["<<i<<"].timesVisited = "
00300        <<tr.workerSummaries[i].timesVisited<<"\n" 
00301        <<"tr.workerSummaries["<<i<<"].timesRun = "
00302        <<tr.workerSummaries[i].timesRun<<"\n"
00303        <<"tr.workerSummaries["<<i<<"].timesPassed = "
00304        <<tr.workerSummaries[i].timesPassed <<"\n"
00305        <<"tr.workerSummaries["<<i<<"].timesFailed = "
00306        <<tr.workerSummaries[i].timesFailed <<"\n"
00307        <<"tr.workerSummaries["<<i<<"].timesExcept = "
00308        <<tr.workerSummaries[i].timesExcept <<"\n"
00309        <<"tr.workerSummaries["<<i<<"].moduleLabel = "
00310        <<tr.workerSummaries[i].moduleLabel <<"\n";
00311   }
00312   
00313   oss<<"==========================="<<"\n";
00314   oss<<"== END OF TRIGGER REPORT =="<<"\n";
00315   oss<<"==========================="<<"\n";
00316   std::cout << oss.str() << std::endl; 
00317   //  LOG4CPLUS_DEBUG(getApplicationLogger(),oss.str());
00318 }
00319 
00320 void TriggerReportHelpers::packTriggerReport(edm::TriggerReport &tr,
00321                                              ShmOutputModuleRegistry *sor)
00322 {
00323   TriggerReportStatic *trp = (TriggerReportStatic *)cache_->mtext;
00324   trp->lumiSection = lumiSectionIndex_;
00325   trp->prescaleIndex = prescaleIndex_;
00326   //copy the event summary
00327   trp->eventSummary.totalEvents = 
00328     tr.eventSummary.totalEvents - trp_.eventSummary.totalEvents;
00329   trp->eventSummary.totalEventsPassed = 
00330     tr.eventSummary.totalEventsPassed - trp_.eventSummary.totalEventsPassed;
00331   trp->eventSummary.totalEventsFailed = 
00332     tr.eventSummary.totalEventsFailed - trp_.eventSummary.totalEventsFailed;
00333 
00334   //get total paths in the menu
00335   trp->trigPathsInMenu = std::min(tr.trigPathSummaries.size(),max_paths);
00336   trp->endPathsInMenu = std::min(tr.endPathSummaries.size(),max_endpaths);
00337   //traverse the trigger report to get a copy of relevant parts in the static structure
00338   // loop on paths
00339 
00340   for(int i = 0; i < trp->trigPathsInMenu; i++)
00341     {
00342 
00343       trp->trigPathSummaries[i].timesRun = 
00344         tr.trigPathSummaries[i].timesRun - trp_.trigPathSummaries[i].timesRun;
00345       trp->trigPathSummaries[i].timesPassed = 
00346         tr.trigPathSummaries[i].timesPassed - trp_.trigPathSummaries[i].timesPassed;
00347       if(l1pos_[i]>=0) {
00348         trp->trigPathSummaries[i].timesPassedL1 =
00349           tr.trigPathSummaries[i].moduleInPathSummaries[l1pos_[i]].timesPassed -
00350           trp_.trigPathSummaries[i].moduleInPathSummaries[l1pos_[i]].timesPassed;
00351       }
00352       else {
00353         trp->trigPathSummaries[i].timesPassedL1 =
00354           tr.trigPathSummaries[i].timesRun - trp_.trigPathSummaries[i].timesRun;
00355       }
00356       if(pspos_[i]>=0) {
00357         trp->trigPathSummaries[i].timesPassedPs =
00358           tr.trigPathSummaries[i].moduleInPathSummaries[pspos_[i]].timesPassed -
00359           trp_.trigPathSummaries[i].moduleInPathSummaries[pspos_[i]].timesPassed;
00360       }
00361       else if(l1pos_[i]>=0) {
00362         trp->trigPathSummaries[i].timesPassedPs =
00363           tr.trigPathSummaries[i].moduleInPathSummaries[l1pos_[i]].timesPassed -
00364           trp_.trigPathSummaries[i].moduleInPathSummaries[l1pos_[i]].timesPassed;
00365       }
00366       else {
00367         trp->trigPathSummaries[i].timesPassedPs =
00368           tr.trigPathSummaries[i].timesRun - trp_.trigPathSummaries[i].timesRun;
00369       }
00370       trp->trigPathSummaries[i].timesFailed = 
00371         tr.trigPathSummaries[i].timesFailed-trp_.trigPathSummaries[i].timesFailed;
00372       trp->trigPathSummaries[i].timesExcept = 
00373         tr.trigPathSummaries[i].timesExcept - trp_.trigPathSummaries[i].timesExcept;
00374     }
00375 
00376   for(int i = 0; i < trp->endPathsInMenu; i++)
00377     {
00378       unsigned int j = i + trp->trigPathsInMenu;
00379       edm::FUShmOutputModule *o = sor->get(outname_[j]);
00380       if(!o) {
00381         //      sor->dumpRegistry();
00382         continue;
00383       }
00384       trp->endPathSummaries[i].timesRun    = 
00385         tr.endPathSummaries[i].timesRun - trp_.endPathSummaries[i].timesRun;
00386       trp->endPathSummaries[i].timesPassed = 
00387         o->getCounts() - trp_.endPathSummaries[i].timesPassed;
00388       trp->endPathSummaries[i].timesFailed = 
00389         (tr.endPathSummaries[i].timesRun - o->getCounts()) 
00390         - trp_.endPathSummaries[i].timesFailed;
00391       trp->endPathSummaries[i].timesExcept = 
00392         tr.endPathSummaries[i].timesExcept - trp_.endPathSummaries[i].timesExcept;
00393 
00394 
00395       if(l1pos_[j]>=0) {
00396         trp->endPathSummaries[i].timesPassedL1 =
00397           tr.endPathSummaries[i].moduleInPathSummaries[l1pos_[j]].timesPassed -
00398           trp_.endPathSummaries[i].moduleInPathSummaries[l1pos_[j]].timesPassed;
00399       }
00400       else {
00401         trp->endPathSummaries[i].timesPassedL1 = trp->endPathSummaries[i].timesRun;
00402       }
00403       if(pspos_[j]>=0) {
00404         trp->endPathSummaries[i].timesPassedPs =
00405           tr.endPathSummaries[i].moduleInPathSummaries[pspos_[j]].timesPassed -
00406           trp_.endPathSummaries[i].moduleInPathSummaries[pspos_[j]].timesPassed;
00407       }
00408       else if(l1pos_[j]>=0) {
00409         trp->endPathSummaries[i].timesPassedPs =
00410           tr.endPathSummaries[i].moduleInPathSummaries[l1pos_[j]].timesPassed -
00411           trp_.endPathSummaries[i].moduleInPathSummaries[l1pos_[j]].timesPassed;
00412       }
00413       else {
00414         trp->endPathSummaries[i].timesPassedPs = trp->endPathSummaries[i].timesRun;
00415       }
00416     }
00417   trp_ = tr;
00418   for(int i = 0; i < trp->endPathsInMenu; i++)
00419     {
00420       edm::FUShmOutputModule *o = sor->get(outname_[i+trp->trigPathsInMenu]);
00421       if(!o) {
00422         //      sor->dumpRegistry();
00423         continue;
00424       }
00425       trp_.endPathSummaries[i].timesPassed = o->getCounts();
00426       trp_.endPathSummaries[i].timesFailed = tr.endPathSummaries[i].timesRun - o->getCounts();
00427     }
00428   
00429 }
00430 
00431 
00432 void TriggerReportHelpers::sumAndPackTriggerReport(MsgBuf &buf)
00433 {
00434 
00435   TriggerReportStatic *trs = (TriggerReportStatic *)cache_->mtext;
00436   TriggerReportStatic *trp = (TriggerReportStatic *)buf->mtext;
00437 
00438   // add check for LS consistency
00439   if(trp->lumiSection != lumiSectionIndex_){
00440     std::cout << "WARNING: lumisection index mismatch from subprocess " << trp->lumiSection
00441               << " should be " << lumiSectionIndex_ << " will be skipped" << std::endl;
00442     return;
00443   }
00444   //get total paths in the menu
00445   if(trs->trigPathsInMenu != trp->trigPathsInMenu) 
00446     {
00447       std::ostringstream ost;
00448       ost << "trig path summary inconsistency " 
00449           << trs->trigPathsInMenu << " vs. " << trp->trigPathsInMenu;
00450       std::cout << ost.str() << std::endl;
00451       XCEPT_RAISE(evf::Exception,ost.str());
00452     }
00453   if(trs->endPathsInMenu != trp->endPathsInMenu)
00454     {
00455       std::ostringstream ost;
00456       ost << "trig endpath summary inconsistency " 
00457           << trs->endPathsInMenu << " vs. " << trp->endPathsInMenu;
00458       std::cout << ost.str() << std::endl;
00459       XCEPT_RAISE(evf::Exception,ost.str());
00460     }
00461   funcs::addToReport(trs,trp,lumiSectionIndex_);
00462   
00463 }  
00464 
00465 void TriggerReportHelpers::resetPackedTriggerReport()
00466 {
00467 
00468   TriggerReportStatic *trp = (TriggerReportStatic *)cache_->mtext;
00469 
00470   funcs::reset(trp);
00471 
00472   lumiSectionIndex_++;
00473 }
00474 
00475 void TriggerReportHelpers::resetTriggerReport()
00476 {
00477 
00478   //copy the event summary
00479   trp_.eventSummary.totalEvents = 0;
00480   trp_.eventSummary.totalEventsPassed = 0;
00481   trp_.eventSummary.totalEventsFailed = 0;
00482 
00483   for(unsigned int i = 0; i < trp_.trigPathSummaries.size(); i++)
00484     {
00485       // reset individual path summaries
00486       trp_.trigPathSummaries[i].timesRun = 0;
00487       trp_.trigPathSummaries[i].timesPassed = 0; 
00488       trp_.trigPathSummaries[i].timesFailed = 0;
00489       trp_.trigPathSummaries[i].timesExcept = 0;
00490 
00491       //loop over modules in path
00492       for(unsigned int j = 0; j<trp_.trigPathSummaries[i].moduleInPathSummaries.size(); j++)
00493         {
00494           //reset module summaries
00495           trp_.trigPathSummaries[i].moduleInPathSummaries[j].timesVisited = 0;
00496           trp_.trigPathSummaries[i].moduleInPathSummaries[j].timesPassed = 0;
00497           trp_.trigPathSummaries[i].moduleInPathSummaries[j].timesFailed = 0;
00498           trp_.trigPathSummaries[i].moduleInPathSummaries[j].timesExcept = 0;
00499         }
00500     }
00501   for(unsigned int i = 0; i < trp_.endPathSummaries.size(); i++)
00502     {
00503       trp_.endPathSummaries[i].timesRun    = 0;
00504       trp_.endPathSummaries[i].timesPassed = 0;
00505       trp_.endPathSummaries[i].timesFailed = 0;
00506       trp_.endPathSummaries[i].timesExcept = 0;
00507       for(unsigned int j = 0; j<trp_.endPathSummaries[i].moduleInPathSummaries.size(); j++)
00508         {
00509           trp_.endPathSummaries[i].moduleInPathSummaries[j].timesVisited = 0;
00510           trp_.endPathSummaries[i].moduleInPathSummaries[j].timesPassed = 0;
00511           trp_.endPathSummaries[i].moduleInPathSummaries[j].timesFailed = 0;
00512           trp_.endPathSummaries[i].moduleInPathSummaries[j].timesExcept = 0;
00513         }
00514     }
00515 
00516 }
00517 std::string TriggerReportHelpers::findLabelOfModuleTypeInEndPath(edm::TriggerReport &tr, 
00518                                                                  std::vector<edm::ModuleDescription const*>& descs,
00519                                                                  unsigned int ind, 
00520                                                                  std::string type)
00521 {
00522   std::string retval;
00523   for(unsigned int j=0;
00524       j<tr.endPathSummaries[ind].moduleInPathSummaries.size();
00525       j++) {
00526     
00527     std::string label = tr.endPathSummaries[ind].moduleInPathSummaries[j].moduleLabel;
00528     for(unsigned int k = 0; k < descs.size(); k++)
00529       {
00530         if(descs[k]->moduleLabel() == label) 
00531           {
00532             if(descs[k]->moduleName() == type) {retval = label; break;}
00533           }
00534       }
00535   }
00536   return retval;
00537 }
00538 
00539 }//end namespace fuep
00540 }//end namespace evf