00001 #include "TriggerReportHelpers.h"
00002 #include "FWCore/Framework/interface/TriggerReport.h"
00003 #include "DataFormats/Provenance/interface/ModuleDescription.h"
00004 #include "xdata/TableIterator.h"
00005
00006 #include <iostream>
00007 #include <sstream>
00008
00009 namespace evf{
00010 namespace fuep{
00011 const std::string TriggerReportHelpers::columns[6] = {"pathName","l1Pass","psPass","pAccept","pExcept","pReject"};
00012 void TriggerReportHelpers::triggerReportToTable(edm::TriggerReport &tr, unsigned int ls, bool lumiComplete)
00013 {
00014
00015 lumiSectionIndex_ = ls;
00016 for(unsigned int i=0; i<tr.trigPathSummaries.size(); i++) {
00017 if(l1pos_[i]>=0) {
00018 l1pre_[i] = tr.trigPathSummaries[i].moduleInPathSummaries[l1pos_[i]].timesPassed
00019 + (lumiComplete ? - pl1pre_[i] : l1pre_[i].value_);
00020 pl1pre_[i] = tr.trigPathSummaries[i].moduleInPathSummaries[l1pos_[i]].timesPassed;
00021 }
00022 else {
00023 l1pre_[i] = tr.trigPathSummaries[i].timesRun
00024 + (lumiComplete ? - pl1pre_[i] : l1pre_[i].value_);
00025 pl1pre_[i] = tr.trigPathSummaries[i].timesRun;
00026 }
00027 triggerReportAsTable_.setValueAt(i,columns[1],l1pre_[i]);
00028 if(pspos_[i]>=0) {
00029 ps_[i] = tr.trigPathSummaries[i].moduleInPathSummaries[pspos_[i]].timesPassed
00030 + (lumiComplete ? - pps_[i] : ps_[i].value_);
00031 pps_[i] = tr.trigPathSummaries[i].moduleInPathSummaries[pspos_[i]].timesPassed;
00032 }
00033 else if(l1pos_[i]>=0) {
00034 ps_[i] = tr.trigPathSummaries[i].moduleInPathSummaries[l1pos_[i]].timesPassed
00035 + (lumiComplete ? - pps_[i] : ps_[i].value_);
00036 pps_[i] = tr.trigPathSummaries[i].moduleInPathSummaries[l1pos_[i]].timesPassed;
00037 }
00038 else {
00039 ps_[i] = tr.trigPathSummaries[i].timesRun
00040 + (lumiComplete ? - pps_[i] : ps_[i].value_);
00041 pps_[i] = tr.trigPathSummaries[i].timesRun;
00042 }
00043 triggerReportAsTable_.setValueAt(i,columns[2],ps_[i]);
00044 accept_[i] = tr.trigPathSummaries[i].timesPassed
00045 + (lumiComplete ? - paccept_[i] : accept_[i].value_);
00046 paccept_[i] = tr.trigPathSummaries[i].timesPassed;
00047 triggerReportAsTable_.setValueAt(i,columns[3], accept_[i]);
00048 except_[i] = tr.trigPathSummaries[i].timesExcept
00049 + (lumiComplete ? - pexcept_[i] : except_[i].value_);
00050 pexcept_[i] = tr.trigPathSummaries[i].timesExcept;
00051 triggerReportAsTable_.setValueAt(i,columns[4], except_[i]);
00052 failed_[i] = tr.trigPathSummaries[i].timesFailed
00053 + (lumiComplete ? - pfailed_[i] : failed_[i].value_);
00054 pfailed_[i] = tr.trigPathSummaries[i].timesFailed;
00055 triggerReportAsTable_.setValueAt(i,columns[5], failed_[i]);
00056 }
00057 }
00058
00059 void TriggerReportHelpers::formatReportTable(edm::TriggerReport &tr, std::vector<edm::ModuleDescription const*>& descs)
00060 {
00061 if(tableFormatted_) return;
00062 tableFormatted_ = true;
00063 paths_.resize(tr.trigPathSummaries.size());
00064 l1pos_.resize(tr.trigPathSummaries.size(),-1);
00065 pspos_.resize(tr.trigPathSummaries.size(),-1);
00066 l1pre_.resize(tr.trigPathSummaries.size(),0);
00067 ps_.resize(tr.trigPathSummaries.size(),0);
00068 accept_.resize(tr.trigPathSummaries.size(),0);
00069 except_.resize(tr.trigPathSummaries.size(),0);
00070 failed_.resize(tr.trigPathSummaries.size(),0);
00071 pl1pre_.resize(tr.trigPathSummaries.size(),0);
00072 pps_.resize(tr.trigPathSummaries.size(),0);
00073 paccept_.resize(tr.trigPathSummaries.size(),0);
00074 pexcept_.resize(tr.trigPathSummaries.size(),0);
00075 pfailed_.resize(tr.trigPathSummaries.size(),0);
00076 triggerReportAsTable_.clear();
00077 triggerReportAsTable_.addColumn(columns[0],"string");
00078 triggerReportAsTable_.addColumn(columns[1],"unsigned int 32");
00079 triggerReportAsTable_.addColumn(columns[2],"unsigned int 32");
00080 triggerReportAsTable_.addColumn(columns[3],"unsigned int 32");
00081 triggerReportAsTable_.addColumn(columns[4],"unsigned int 32");
00082 triggerReportAsTable_.addColumn(columns[5],"unsigned int 32");
00083 for(unsigned int i=0; i<tr.trigPathSummaries.size(); i++) {
00084 xdata::Table::iterator it = triggerReportAsTable_.append();
00085 paths_[i] = tr.trigPathSummaries[i].name;
00086 it->setField(columns[0],paths_[i]);
00087 for(unsigned int j=0;j<tr.trigPathSummaries[i].moduleInPathSummaries.size();j++) {
00088 std::string label = tr.trigPathSummaries[i].moduleInPathSummaries[j].moduleLabel;
00089 for(unsigned int k = 0; k < descs.size(); k++)
00090 {
00091 if(descs[k]->moduleLabel() == label)
00092 {
00093 if(descs[k]->moduleName() == "HLTLevel1GTSeed") l1pos_[i] = j;
00094 if(descs[k]->moduleName() == "HLTPrescaler") pspos_[i] = j;
00095 }
00096 }
00097 }
00098 }
00099 }
00100
00101 void TriggerReportHelpers::printReportTable()
00102 {
00103 std::cout << "report table for LS #" << lumiSectionIndex_ << std::endl;
00104 triggerReportAsTable_.writeTo(std::cout);
00105 }
00106 void TriggerReportHelpers::printTriggerReport(edm::TriggerReport &tr)
00107 {
00108 std::ostringstream oss;
00109
00110 oss<<"================================="<<"\n";
00111 oss<<"== BEGINNING OF TRIGGER REPORT =="<<"\n";
00112 oss<<"================================="<<"\n";
00113 oss<<"tr.eventSummary.totalEvents= "<<tr.eventSummary.totalEvents<<"\n"
00114 <<"tr.eventSummary.totalEventsPassed= "<<tr.eventSummary.totalEventsPassed<<"\n"
00115 <<"tr.eventSummary.totalEventsFailed= "<<tr.eventSummary.totalEventsFailed<<"\n";
00116
00117 oss<<"TriggerReport::trigPathSummaries"<<"\n";
00118 for(unsigned int i=0; i<tr.trigPathSummaries.size(); i++) {
00119 oss<<"tr.trigPathSummaries["<<i<<"].bitPosition = "
00120 <<tr.trigPathSummaries[i].bitPosition <<"\n"
00121 <<"tr.trigPathSummaries["<<i<<"].timesRun = "
00122 <<tr.trigPathSummaries[i].timesRun <<"\n"
00123 <<"tr.trigPathSummaries["<<i<<"].timesPassed = "
00124 <<tr.trigPathSummaries[i].timesPassed <<"\n"
00125 <<"tr.trigPathSummaries["<<i<<"].timesFailed = "
00126 <<tr.trigPathSummaries[i].timesFailed <<"\n"
00127 <<"tr.trigPathSummaries["<<i<<"].timesExcept = "
00128 <<tr.trigPathSummaries[i].timesExcept <<"\n"
00129 <<"tr.trigPathSummaries["<<i<<"].name = "
00130 <<tr.trigPathSummaries[i].name <<"\n";
00131
00132
00133 for(unsigned int j=0;j<tr.trigPathSummaries[i].moduleInPathSummaries.size();j++) {
00134 oss<<"tr.trigPathSummaries["<<i
00135 <<"].moduleInPathSummaries["<<j<<"].timesVisited = "
00136 <<tr.trigPathSummaries[i].moduleInPathSummaries[j].timesVisited<<"\n"
00137 <<"tr.trigPathSummaries["<<i
00138 <<"].moduleInPathSummaries["<<j<<"].timesPassed = "
00139 <<tr.trigPathSummaries[i].moduleInPathSummaries[j].timesPassed<<"\n"
00140 <<"tr.trigPathSummaries["<<i
00141 <<"].moduleInPathSummaries["<<j<<"].timesFailed = "
00142 <<tr.trigPathSummaries[i].moduleInPathSummaries[j].timesFailed<<"\n"
00143 <<"tr.trigPathSummaries["<<i
00144 <<"].moduleInPathSummaries["<<j<<"].timesExcept = "
00145 <<tr.trigPathSummaries[i].moduleInPathSummaries[j].timesExcept<<"\n"
00146 <<"tr.trigPathSummaries["<<i
00147 <<"].moduleInPathSummaries["<<j<<"].moduleLabel = "
00148 <<tr.trigPathSummaries[i].moduleInPathSummaries[j].moduleLabel<<"\n";
00149 }
00150 }
00151
00152
00153 for(unsigned int i=0;i<tr.endPathSummaries.size();i++) {
00154 oss<<"tr.endPathSummaries["<<i<<"].bitPosition = "
00155 <<tr.endPathSummaries[i].bitPosition <<"\n"
00156 <<"tr.endPathSummaries["<<i<<"].timesRun = "
00157 <<tr.endPathSummaries[i].timesRun <<"\n"
00158 <<"tr.endPathSummaries["<<i<<"].timesPassed = "
00159 <<tr.endPathSummaries[i].timesPassed <<"\n"
00160 <<"tr.endPathSummaries["<<i<<"].timesFailed = "
00161 <<tr.endPathSummaries[i].timesFailed <<"\n"
00162 <<"tr.endPathSummaries["<<i<<"].timesExcept = "
00163 <<tr.endPathSummaries[i].timesExcept <<"\n"
00164 <<"tr.endPathSummaries["<<i<<"].name = "
00165 <<tr.endPathSummaries[i].name <<"\n";
00166
00167
00168 for(unsigned int j=0;j<tr.endPathSummaries[i].moduleInPathSummaries.size();j++) {
00169 oss<<"tr.endPathSummaries["<<i
00170 <<"].moduleInPathSummaries["<<j<<"].timesVisited = "
00171 <<tr.endPathSummaries[i].moduleInPathSummaries[j].timesVisited <<"\n"
00172 <<"tr.endPathSummaries["<<i
00173 <<"].moduleInPathSummaries["<<j<<"].timesPassed = "
00174 <<tr.endPathSummaries[i].moduleInPathSummaries[j].timesPassed <<"\n"
00175 <<"tr.endPathSummaries["<<i
00176 <<"].moduleInPathSummaries["<<j<<"].timesFailed = "
00177 <<tr.endPathSummaries[i].moduleInPathSummaries[j].timesFailed <<"\n"
00178 <<"tr.endPathSummaries["<<i
00179 <<"].moduleInPathSummaries["<<j<<"].timesExcept = "
00180 <<tr.endPathSummaries[i].moduleInPathSummaries[j].timesExcept <<"\n"
00181 <<"tr.endPathSummaries["<<i
00182 <<"].moduleInPathSummaries["<<j<<"].moduleLabel = "
00183 <<tr.endPathSummaries[i].moduleInPathSummaries[j].moduleLabel <<"\n";
00184 }
00185 }
00186
00187
00188 for(unsigned int i=0; i<tr.workerSummaries.size(); i++) {
00189 oss<<"tr.workerSummaries["<<i<<"].timesVisited = "
00190 <<tr.workerSummaries[i].timesVisited<<"\n"
00191 <<"tr.workerSummaries["<<i<<"].timesRun = "
00192 <<tr.workerSummaries[i].timesRun<<"\n"
00193 <<"tr.workerSummaries["<<i<<"].timesPassed = "
00194 <<tr.workerSummaries[i].timesPassed <<"\n"
00195 <<"tr.workerSummaries["<<i<<"].timesFailed = "
00196 <<tr.workerSummaries[i].timesFailed <<"\n"
00197 <<"tr.workerSummaries["<<i<<"].timesExcept = "
00198 <<tr.workerSummaries[i].timesExcept <<"\n"
00199 <<"tr.workerSummaries["<<i<<"].moduleLabel = "
00200 <<tr.workerSummaries[i].moduleLabel <<"\n";
00201 }
00202
00203 oss<<"==========================="<<"\n";
00204 oss<<"== END OF TRIGGER REPORT =="<<"\n";
00205 oss<<"==========================="<<"\n";
00206 std::cout << oss.str() << std::endl;
00207
00208 }
00209 }
00210 }