Go to the documentation of this file.00001
00002
00003
00004 #include "DQM/TrigXMonitor/interface/HLTSeedL1LogicScalers.h"
00005
00006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00007
00008 #include "CondFormats/L1TObjects/interface/L1GtTriggerMenu.h"
00009 #include "CondFormats/DataRecord/interface/L1GtTriggerMenuRcd.h"
00010 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"
00011 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetup.h"
00012 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
00013
00014
00015
00016 using namespace edm;
00017 using namespace std;
00018 using namespace trigger;
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 HLTSeedL1LogicScalers::HLTSeedL1LogicScalers(const edm::ParameterSet& iConfig)
00032
00033 {
00034
00035 LogDebug("HLTSeedL1LogicScalers") << "constructor" ;
00036
00037
00039 fL1BeforeMask = iConfig.getParameter<bool>("l1BeforeMask");
00040 fProcessname = iConfig.getParameter<std::string>("processname");
00041
00042
00043 fL1GtDaqReadoutRecordInputTag = iConfig.getParameter<edm::InputTag>("L1GtDaqReadoutRecordInputTag");
00044
00045
00046 fL1GtRecordInputTag = iConfig.getParameter<edm::InputTag>("L1GtRecordInputTag");
00047
00048
00050 fDQMFolder = iConfig.getUntrackedParameter("DQMFolder", string("HLT/HLTSeedL1LogicScalers/HLT_LogicL1"));
00051 fMonitorPaths = iConfig.getUntrackedParameter<std::vector<std::string > >("monitorPaths");
00052
00053 fDbe = Service < DQMStore > ().operator->();
00054
00055 if ( ! fDbe ) {
00056 LogInfo("HLTSeedL1LogicScalers") << "unable to get DQMStore service?";
00057 }
00058 else {
00059 fDbe->setCurrentFolder(fDQMFolder);
00060 }
00061
00062 }
00063
00064
00065 HLTSeedL1LogicScalers::~HLTSeedL1LogicScalers()
00066 {
00067 }
00068
00069 void
00070 HLTSeedL1LogicScalers::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00071 {
00072
00073 LogDebug("HLTSeedL1LogicScalers") << "HLTSeedL1LogicScalers::analyze event " ;
00074
00075
00076
00077
00078
00079
00080 m_l1GtUtils.retrieveL1EventSetup(iSetup);
00081
00082
00083 for (unsigned int i=0;i<fMapMEL1Algos.size();i++) {
00084
00085 MonitorElement* me = fMapMEL1Algos[i].first;
00086 LogTrace("HLTSeedL1LogicScalers") << "ME = " << me->getName() << endl;
00087
00088 const vector<string>& l1Algos = fMapMEL1Algos[i].second;
00089
00090
00091 unsigned int myL1Word = 0;
00092
00093
00094 for (unsigned int j=0;j<l1Algos.size();j++) {
00095
00096
00097 bool l1Pass = analyzeL1GtUtils(iEvent, iSetup, l1Algos[j]);
00098 LogTrace("HLTSeedL1LogicScalers") << "l1Algo = " << l1Algos[j] << " l1Pass = " << l1Pass << endl;
00099 if(l1Pass) {
00100
00101
00102 myL1Word |= (1<<j);
00103
00104 }
00105
00106
00107
00108 }
00109
00110 me->Fill(myL1Word);
00111
00112 }
00113
00114 }
00115
00116
00117
00118 void
00119 HLTSeedL1LogicScalers::beginRun(const edm::Run& run, const edm::EventSetup& iSetup)
00120 {
00121
00122
00123 LogTrace("HLTSeedL1LogicScalers") << "beginRun, run " << run.id();
00124 fDbe->setCurrentFolder(fDQMFolder);
00125
00126
00127
00128 bool changed = false;
00129
00130 if (!fHLTConfig.init(run, iSetup, fProcessname, changed)) {
00131
00132 LogDebug("HLTSeedL1LogicScalers") << "HLTConfigProvider failed to initialize.";
00133 return;
00134
00135
00136
00137
00138
00139 }
00140
00141 const unsigned int n(fHLTConfig.size());
00142
00143 for (unsigned int j=0; j!=n; ++j) {
00144
00145 LogTrace("HLTSeedL1LogicScalers") << "HLTConfig path " << fHLTConfig.triggerName(j) << endl;
00146
00147 }
00148
00149
00150 LogTrace("HLTSeedL1LogicScalers") << "size of vector of paths to monitor = " << fMonitorPaths.size() << endl;
00151 for (unsigned int iPath=0;iPath<fMonitorPaths.size();iPath++) {
00152
00153 string monPath = fMonitorPaths[iPath];
00154 LogTrace("HLTSeedL1LogicScalers") << "monPath = " << monPath << endl;
00155
00156 string folderName = fDQMFolder + "/" + monPath;
00157 fDbe->setCurrentFolder(folderName);
00158
00159
00160 if(fHLTConfig.triggerIndex(monPath) == fHLTConfig.size()) continue;
00161
00162 vector<pair<bool,string> > hltL1GTSeed = fHLTConfig.hltL1GTSeeds(monPath);
00163 LogTrace("HLTSeedL1LogicScalers") << endl << "size of vector of GTSeedL1LogicalExpression = " << hltL1GTSeed.size() << endl;
00164
00165
00166 for (unsigned int iSeed=0;iSeed<hltL1GTSeed.size();iSeed++) {
00167
00168 LogTrace("HLTSeedL1LogicScalers") << " TechBit_flag = " << hltL1GTSeed[iSeed].first << " GTSeedL1LogicalExpression = " << hltL1GTSeed[iSeed].second << endl;;
00169
00170 istringstream totalSString( hltL1GTSeed[iSeed].second );
00171 string temp_string;
00172
00173 vector<string> l1Algos;
00174
00175
00176 while(! hltL1GTSeed[iSeed].first) {
00177
00178 totalSString >> temp_string;
00179
00180 if(! l1Algos.empty()) {
00181
00182 if(temp_string.compare(l1Algos.back()) == 0) break;
00183
00184 }
00185 if(temp_string != "OR" && temp_string != "AND" && temp_string != "NOT" && temp_string != "(" && temp_string != ")" && temp_string != ""){
00186
00187 l1Algos.push_back(temp_string);
00188
00189 }
00190 }
00191
00192 int nL1Algo = l1Algos.size();
00193
00194
00195 if(nL1Algo > 32) {
00196
00197 LogWarning("HLTSeedL1LogicScalers") << " number of l1 Algos grater than 32. Using only the first 32." << endl ;
00198 l1Algos.resize(32);
00199
00200 }
00201 int nBins = 1 << nL1Algo;
00202
00203 for (unsigned int k=0;k< l1Algos.size();k++) {
00204
00205 LogTrace("HLTSeedL1LogicScalers") << " l1 Algo = " << l1Algos[k] << endl;
00206
00207
00208 }
00209
00210
00211
00212
00213 std::stringstream title;
00214 std::stringstream name;
00215
00216 name << monPath << "_Seed_" << iSeed << "_L1BitLogic";
00217 title << monPath << " BitPacked L1Algos of GTSeed " << iSeed << ": '" << hltL1GTSeed[iSeed].second << "'";
00218
00219
00220
00221
00222 LogTrace("HLTSeedL1LogicScalers") << " MonitorElement name = " << name << endl;
00223 LogTrace("HLTSeedL1LogicScalers") << " MonitorElement title = " << title << endl;
00224 LogTrace("HLTSeedL1LogicScalers") << " MonitorElement nBins = " << nBins << endl << endl;
00225
00226 MonitorElement* me = fDbe->book1D(name.str().c_str(), title.str().c_str(), nBins,0,nBins);
00227 me->setAxisTitle("bit-packed word L1 Algorithms");
00228 fMonitorPathsME.push_back(me);
00229
00230
00231
00232
00233
00234
00235 fMapMEL1Algos.push_back(make_pair(me, l1Algos));
00236
00237 }
00238
00239
00240
00241 }
00242
00243 }
00244
00245 void
00246 HLTSeedL1LogicScalers::beginJob()
00247 {
00248 }
00249
00250
00251 void
00252 HLTSeedL1LogicScalers::endJob() {
00253 }
00254
00255 bool HLTSeedL1LogicScalers::analyzeL1GtUtils(const edm::Event& iEvent, const edm::EventSetup& evSetup, const string & l1AlgoName)
00256 {
00257
00258 LogTrace("HLTSeedL1LogicScalers") << "analyzeL1GtUtils..." << endl;
00259
00260
00261
00262
00263 int iErrorCode = -1;
00264
00265
00266 LogTrace("HLTSeedL1LogicScalers") << "l1AlgoName = " << l1AlgoName << endl;
00267
00268 bool decisionAlgTechTrig = false;
00269
00270
00271 if (fL1BeforeMask) {
00272
00273 decisionAlgTechTrig = m_l1GtUtils.decisionBeforeMask(iEvent, fL1GtRecordInputTag, fL1GtDaqReadoutRecordInputTag, l1AlgoName, iErrorCode);
00274
00275 }
00276 else {
00277
00278 decisionAlgTechTrig = m_l1GtUtils.decisionAfterMask(iEvent, fL1GtRecordInputTag, fL1GtDaqReadoutRecordInputTag, l1AlgoName, iErrorCode);
00279
00280 }
00281
00282 LogTrace("HLTSeedL1LogicScalers") << "bool L1BeforeMask = " << fL1BeforeMask << " decisionAlgTechTrig = " << decisionAlgTechTrig << endl;
00283
00284 if (iErrorCode == 0) {
00285
00286 return decisionAlgTechTrig;
00287
00288 } else if (iErrorCode == 1) {
00289
00290
00291 LogWarning("HLTSeedL1LogicScalers") << "L1 algorithm " << l1AlgoName << " not in L1 menu, but HLTConfigProvider found it in L1SeedsLogicalExpression of at least one HLT path of the HLT menu." << endl;
00292 return false;
00293
00294 } else {
00295
00296
00297
00298 return false;
00299
00300 }
00301
00302 return false;
00303
00304 }
00305
00306 bool HLTSeedL1LogicScalers::analyzeL1GtRecord(const edm::Event& iEvent, const edm::EventSetup& evSetup, string l1AlgoName)
00307 {
00308 LogTrace("HLTSeedL1LogicScalers") << "analyzeL1GtRecord.. " << endl;
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330 return false;
00331
00332 }