00001 #include <iostream>
00002 #include <sstream>
00003 #include <istream>
00004 #include <fstream>
00005 #include <iomanip>
00006 #include <string>
00007 #include <cmath>
00008 #include <functional>
00009 #include <stdlib.h>
00010 #include <string.h>
00011
00012 #include "HLTrigger/HLTanalyzers/interface/HLTInfo.h"
00013 #include "FWCore/Common/interface/TriggerNames.h"
00014
00015
00016 #include "L1Trigger/GlobalTriggerAnalyzer/interface/L1GtUtils.h"
00017 #include "CondFormats/L1TObjects/interface/L1GtTriggerMenu.h"
00018 #include "CondFormats/DataRecord/interface/L1GtTriggerMenuRcd.h"
00019 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"
00020 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetup.h"
00021 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
00022
00023
00024 HLTInfo::HLTInfo() {
00025
00026
00027 _Debug=false;
00028 _OR_BXes=false;
00029 UnpackBxInEvent=1;
00030 }
00031
00032 void HLTInfo::beginRun(const edm::Run& run, const edm::EventSetup& c){
00033
00034
00035 bool changed(true);
00036 if (hltConfig_.init(run,c,processName_,changed)) {
00037
00038 if (changed) {
00039
00040
00041 std::cout << "Initalizing HLTConfigProvider" << std::endl;
00042 }
00043 } else {
00044
00045
00046 std::cout << " HLT config extraction failure with process name " << processName_ << std::endl;
00047
00048 }
00049
00050 }
00051
00052
00053 void HLTInfo::setup(const edm::ParameterSet& pSet, TTree* HltTree) {
00054
00055
00056 processName_ = pSet.getParameter<std::string>("HLTProcessName") ;
00057
00058 edm::ParameterSet myHltParams = pSet.getParameter<edm::ParameterSet>("RunParameters") ;
00059 std::vector<std::string> parameterNames = myHltParams.getParameterNames() ;
00060
00061 for ( std::vector<std::string>::iterator iParam = parameterNames.begin();
00062 iParam != parameterNames.end(); iParam++ ){
00063 if ( (*iParam) == "Debug" ) _Debug = myHltParams.getParameter<bool>( *iParam );
00064 }
00065
00066 HltEvtCnt = 0;
00067 const int kMaxTrigFlag = 10000;
00068 trigflag = new int[kMaxTrigFlag];
00069 trigPrescl = new int[kMaxTrigFlag];
00070 L1EvtCnt = 0;
00071 const int kMaxL1Flag = 10000;
00072 l1flag = new int[kMaxL1Flag];
00073 l1flag5Bx = new int[kMaxTrigFlag];
00074 l1Prescl = new int[kMaxL1Flag];
00075 l1techflag = new int[kMaxL1Flag];
00076 l1techflag5Bx = new int[kMaxTrigFlag];
00077 l1techPrescl = new int[kMaxTrigFlag];
00078 const int kMaxHLTPart = 10000;
00079 hltppt = new float[kMaxHLTPart];
00080 hltpeta = new float[kMaxHLTPart];
00081 const int kMaxL1ExtEmI = 10000;
00082 l1extiemet = new float[kMaxL1ExtEmI];
00083 l1extieme = new float[kMaxL1ExtEmI];
00084 l1extiemeta = new float[kMaxL1ExtEmI];
00085 l1extiemphi = new float[kMaxL1ExtEmI];
00086 const int kMaxL1ExtEmN = 10000;
00087 l1extnemet = new float[kMaxL1ExtEmN];
00088 l1extneme = new float[kMaxL1ExtEmN];
00089 l1extnemeta = new float[kMaxL1ExtEmN];
00090 l1extnemphi = new float[kMaxL1ExtEmN];
00091 const int kMaxL1ExtMu = 10000;
00092 l1extmupt = new float[kMaxL1ExtMu];
00093 l1extmue = new float[kMaxL1ExtMu];
00094 l1extmueta = new float[kMaxL1ExtMu];
00095 l1extmuphi = new float[kMaxL1ExtMu];
00096 l1extmuiso = new int[kMaxL1ExtMu];
00097 l1extmumip = new int[kMaxL1ExtMu];
00098 l1extmufor = new int[kMaxL1ExtMu];
00099 l1extmurpc = new int[kMaxL1ExtMu];
00100 l1extmuqul = new int[kMaxL1ExtMu];
00101 l1extmuchg = new int[kMaxL1ExtMu];
00102 const int kMaxL1ExtJtC = 10000;
00103 l1extjtcet = new float[kMaxL1ExtJtC];
00104 l1extjtce = new float[kMaxL1ExtJtC];
00105 l1extjtceta = new float[kMaxL1ExtJtC];
00106 l1extjtcphi = new float[kMaxL1ExtJtC];
00107 const int kMaxL1ExtJtF = 10000;
00108 l1extjtfet = new float[kMaxL1ExtJtF];
00109 l1extjtfe = new float[kMaxL1ExtJtF];
00110 l1extjtfeta = new float[kMaxL1ExtJtF];
00111 l1extjtfphi = new float[kMaxL1ExtJtF];
00112 const int kMaxL1ExtTau = 10000;
00113 l1exttauet = new float[kMaxL1ExtTau];
00114 l1exttaue = new float[kMaxL1ExtTau];
00115 l1exttaueta = new float[kMaxL1ExtTau];
00116 l1exttauphi = new float[kMaxL1ExtTau];
00117
00118 algoBitToName = new TString[128];
00119 techBitToName = new TString[128];
00120
00121 HltTree->Branch("NL1IsolEm",&nl1extiem,"NL1IsolEm/I");
00122 HltTree->Branch("L1IsolEmEt",l1extiemet,"L1IsolEmEt[NL1IsolEm]/F");
00123 HltTree->Branch("L1IsolEmE",l1extieme,"L1IsolEmE[NL1IsolEm]/F");
00124 HltTree->Branch("L1IsolEmEta",l1extiemeta,"L1IsolEmEta[NL1IsolEm]/F");
00125 HltTree->Branch("L1IsolEmPhi",l1extiemphi,"L1IsolEmPhi[NL1IsolEm]/F");
00126 HltTree->Branch("NL1NIsolEm",&nl1extnem,"NL1NIsolEm/I");
00127 HltTree->Branch("L1NIsolEmEt",l1extnemet,"L1NIsolEmEt[NL1NIsolEm]/F");
00128 HltTree->Branch("L1NIsolEmE",l1extneme,"L1NIsolEmE[NL1NIsolEm]/F");
00129 HltTree->Branch("L1NIsolEmEta",l1extnemeta,"L1NIsolEmEta[NL1NIsolEm]/F");
00130 HltTree->Branch("L1NIsolEmPhi",l1extnemphi,"L1NIsolEmPhi[NL1NIsolEm]/F");
00131 HltTree->Branch("NL1Mu",&nl1extmu,"NL1Mu/I");
00132 HltTree->Branch("L1MuPt",l1extmupt,"L1MuPt[NL1Mu]/F");
00133 HltTree->Branch("L1MuE",l1extmue,"L1MuE[NL1Mu]/F");
00134 HltTree->Branch("L1MuEta",l1extmueta,"L1MuEta[NL1Mu]/F");
00135 HltTree->Branch("L1MuPhi",l1extmuphi,"L1MuPhi[NL1Mu]/F");
00136 HltTree->Branch("L1MuIsol",l1extmuiso,"L1MuIsol[NL1Mu]/I");
00137 HltTree->Branch("L1MuMip",l1extmumip,"L1MuMip[NL1Mu]/I");
00138 HltTree->Branch("L1MuFor",l1extmufor,"L1MuFor[NL1Mu]/I");
00139 HltTree->Branch("L1MuRPC",l1extmurpc,"L1MuRPC[NL1Mu]/I");
00140 HltTree->Branch("L1MuQal",l1extmuqul,"L1MuQal[NL1Mu]/I");
00141 HltTree->Branch("L1MuChg",l1extmuchg,"L1MuChg[NL1Mu]/I");
00142 HltTree->Branch("NL1CenJet",&nl1extjetc,"NL1CenJet/I");
00143 HltTree->Branch("L1CenJetEt",l1extjtcet,"L1CenJetEt[NL1CenJet]/F");
00144 HltTree->Branch("L1CenJetE",l1extjtce,"L1CenJetE[NL1CenJet]/F");
00145 HltTree->Branch("L1CenJetEta",l1extjtceta,"L1CenJetEta[NL1CenJet]/F");
00146 HltTree->Branch("L1CenJetPhi",l1extjtcphi,"L1CenJetPhi[NL1CenJet]/F");
00147 HltTree->Branch("NL1ForJet",&nl1extjetf,"NL1ForJet/I");
00148 HltTree->Branch("L1ForJetEt",l1extjtfet,"L1ForJetEt[NL1ForJet]/F");
00149 HltTree->Branch("L1ForJetE",l1extjtfe,"L1ForJetE[NL1ForJet]/F");
00150 HltTree->Branch("L1ForJetEta",l1extjtfeta,"L1ForJetEta[NL1ForJet]/F");
00151 HltTree->Branch("L1ForJetPhi",l1extjtfphi,"L1ForJetPhi[NL1ForJet]/F");
00152 HltTree->Branch("NL1Tau",&nl1exttau,"NL1Tau/I");
00153 HltTree->Branch("L1TauEt",l1exttauet,"L1TauEt[NL1Tau]/F");
00154 HltTree->Branch("L1TauE",l1exttaue,"L1TauE[NL1Tau]/F");
00155 HltTree->Branch("L1TauEta",l1exttaueta,"L1TauEta[NL1Tau]/F");
00156 HltTree->Branch("L1TauPhi",l1exttauphi,"L1TauPhi[NL1Tau]/F");
00157 HltTree->Branch("L1Met",&met,"L1Met/F");
00158 HltTree->Branch("L1MetPhi",&metphi,"L1MetPhi/F");
00159 HltTree->Branch("L1EtTot",&ettot,"L1EtTot/F");
00160 HltTree->Branch("L1Mht",&mht,"L1Mht/F");
00161 HltTree->Branch("L1MhtPhi",&mhtphi,"L1MhtPhi/F");
00162 HltTree->Branch("L1EtHad",ðad,"L1EtHad/F");
00163
00164
00165 HltTree->Branch("L1HfRing1EtSumPositiveEta",&l1hfRing1EtSumPositiveEta,"L1HfRing1EtSumPositiveEta/I");
00166 HltTree->Branch("L1HfRing2EtSumPositiveEta",&l1hfRing2EtSumPositiveEta,"L1HfRing2EtSumPositiveEta/I");
00167 HltTree->Branch("L1HfRing1EtSumNegativeEta",&l1hfRing1EtSumNegativeEta,"L1HfRing1EtSumNegativeEta/I");
00168 HltTree->Branch("L1HfRing2EtSumNegativeEta",&l1hfRing2EtSumNegativeEta,"L1HfRing2EtSumNegativeEta/I");
00169 HltTree->Branch("L1HfTowerCountPositiveEtaRing1",&l1hfTowerCountPositiveEtaRing1,"L1HfTowerCountPositiveEtaRing1/I");
00170 HltTree->Branch("L1HfTowerCountNegativeEtaRing1",&l1hfTowerCountNegativeEtaRing1,"L1HfTowerCountNegativeEtaRing1/I");
00171 HltTree->Branch("L1HfTowerCountPositiveEtaRing2",&l1hfTowerCountPositiveEtaRing2,"L1HfTowerCountPositiveEtaRing2/I");
00172 HltTree->Branch("L1HfTowerCountNegativeEtaRing2",&l1hfTowerCountNegativeEtaRing2,"L1HfTowerCountNegativeEtaRing2/I");
00173
00174 }
00175
00176
00177 void HLTInfo::analyze(const edm::Handle<edm::TriggerResults> & hltresults,
00178 const edm::Handle<l1extra::L1EmParticleCollection> & L1ExtEmIsol,
00179 const edm::Handle<l1extra::L1EmParticleCollection> & L1ExtEmNIsol,
00180 const edm::Handle<l1extra::L1MuonParticleCollection> & L1ExtMu,
00181 const edm::Handle<l1extra::L1JetParticleCollection> & L1ExtJetC,
00182 const edm::Handle<l1extra::L1JetParticleCollection> & L1ExtJetF,
00183 const edm::Handle<l1extra::L1JetParticleCollection> & L1ExtTau,
00184 const edm::Handle<l1extra::L1EtMissParticleCollection> & L1ExtMet,
00185 const edm::Handle<l1extra::L1EtMissParticleCollection> & L1ExtMht,
00186 const edm::Handle<L1GlobalTriggerReadoutRecord> & L1GTRR,
00187 const edm::Handle<L1GctHFBitCountsCollection> & gctBitCounts,
00188 const edm::Handle<L1GctHFRingEtSumsCollection> & gctRingSums,
00189 edm::EventSetup const& eventSetup,
00190 edm::Event const& iEvent,
00191 TTree* HltTree) {
00192
00193
00194
00195
00197 if (hltresults.isValid()) {
00198 int ntrigs = hltresults->size();
00199 if (ntrigs==0){std::cout << "%HLTInfo -- No trigger name given in TriggerResults of the input " << std::endl;}
00200
00201 edm::TriggerNames const& triggerNames = iEvent.triggerNames(*hltresults);
00202
00203
00204 if (HltEvtCnt==0){
00205 for (int itrig = 0; itrig != ntrigs; ++itrig) {
00206 TString trigName = triggerNames.triggerName(itrig);
00207 HltTree->Branch(trigName,trigflag+itrig,trigName+"/I");
00208 HltTree->Branch(trigName+"_Prescl",trigPrescl+itrig,trigName+"_Prescl/I");
00209 }
00210 HltEvtCnt++;
00211 }
00212
00213
00214
00215
00216
00217
00218
00219 for (int itrig = 0; itrig != ntrigs; ++itrig){
00220
00221 std::string trigName=triggerNames.triggerName(itrig);
00222 bool accept = hltresults->accept(itrig);
00223
00224 trigPrescl[itrig] = hltConfig_.prescaleValue(iEvent, eventSetup, trigName);
00225
00226
00227 if (accept){trigflag[itrig] = 1;}
00228 else {trigflag[itrig] = 0;}
00229
00230 if (_Debug){
00231 if (_Debug) std::cout << "%HLTInfo -- Number of HLT Triggers: " << ntrigs << std::endl;
00232 std::cout << "%HLTInfo -- HLTTrigger(" << itrig << "): " << trigName << " = " << accept << std::endl;
00233 }
00234 }
00235 }
00236 else { if (_Debug) std::cout << "%HLTInfo -- No Trigger Result" << std::endl;}
00237
00239
00240 const int maxL1EmIsol = 4;
00241 for (int i=0; i!=maxL1EmIsol; ++i){
00242 l1extiemet[i] = -999.;
00243 l1extieme[i] = -999.;
00244 l1extiemeta[i] = -999.;
00245 l1extiemphi[i] = -999.;
00246 }
00247 if (L1ExtEmIsol.isValid()) {
00248 nl1extiem = maxL1EmIsol;
00249 l1extra::L1EmParticleCollection myl1iems;
00250 myl1iems = * L1ExtEmIsol;
00251 std::sort(myl1iems.begin(),myl1iems.end(),EtGreater());
00252 int il1exem = 0;
00253 for (l1extra::L1EmParticleCollection::const_iterator emItr = myl1iems.begin(); emItr != myl1iems.end(); ++emItr) {
00254 l1extiemet[il1exem] = emItr->et();
00255 l1extieme[il1exem] = emItr->energy();
00256 l1extiemeta[il1exem] = emItr->eta();
00257 l1extiemphi[il1exem] = emItr->phi();
00258 il1exem++;
00259 }
00260 }
00261 else {
00262 nl1extiem = 0;
00263 if (_Debug) std::cout << "%HLTInfo -- No Isolated L1 EM object" << std::endl;
00264 }
00265
00266 const int maxL1EmNIsol = 4;
00267 for (int i=0; i!=maxL1EmNIsol; ++i){
00268 l1extnemet[i] = -999.;
00269 l1extneme[i] = -999.;
00270 l1extnemeta[i] = -999.;
00271 l1extnemphi[i] = -999.;
00272 }
00273 if (L1ExtEmNIsol.isValid()) {
00274 nl1extnem = maxL1EmNIsol;
00275 l1extra::L1EmParticleCollection myl1nems;
00276 myl1nems = * L1ExtEmNIsol;
00277 std::sort(myl1nems.begin(),myl1nems.end(),EtGreater());
00278 int il1exem = 0;
00279 for (l1extra::L1EmParticleCollection::const_iterator emItr = myl1nems.begin(); emItr != myl1nems.end(); ++emItr) {
00280 l1extnemet[il1exem] = emItr->et();
00281 l1extneme[il1exem] = emItr->energy();
00282 l1extnemeta[il1exem] = emItr->eta();
00283 l1extnemphi[il1exem] = emItr->phi();
00284 il1exem++;
00285 }
00286 }
00287 else {
00288 nl1extnem = 0;
00289 if (_Debug) std::cout << "%HLTInfo -- No Non-Isolated L1 EM object" << std::endl;
00290 }
00291
00292 const int maxL1Mu = 4;
00293 for (int i=0; i!=maxL1Mu; ++i){
00294 l1extmupt[i] = -999.;
00295 l1extmue[i] = -999.;
00296 l1extmueta[i] = -999.;
00297 l1extmuphi[i] = -999.;
00298 l1extmuiso[i] = -999;
00299 l1extmumip[i] = -999;
00300 l1extmufor[i] = -999;
00301 l1extmurpc[i] = -999;
00302 l1extmuqul[i] = -999;
00303 l1extmuchg[i] = -999;
00304 }
00305 if (L1ExtMu.isValid()) {
00306 nl1extmu = maxL1Mu;
00307 l1extra::L1MuonParticleCollection myl1mus;
00308 myl1mus = * L1ExtMu;
00309 std::sort(myl1mus.begin(),myl1mus.end(),PtGreater());
00310 int il1exmu = 0;
00311 for (l1extra::L1MuonParticleCollection::const_iterator muItr = myl1mus.begin(); muItr != myl1mus.end(); ++muItr) {
00312 l1extmupt[il1exmu] = muItr->pt();
00313 l1extmue[il1exmu] = muItr->energy();
00314 l1extmueta[il1exmu] = muItr->eta();
00315 l1extmuphi[il1exmu] = muItr->phi();
00316 l1extmuiso[il1exmu] = muItr->isIsolated();
00317 l1extmumip[il1exmu] = muItr->isMip();
00318 l1extmufor[il1exmu] = muItr->isForward();
00319 l1extmurpc[il1exmu] = muItr->isRPC();
00320 l1extmuchg[il1exmu] = muItr->charge();
00321 L1MuGMTExtendedCand gmtCand = muItr->gmtMuonCand();
00322 l1extmuqul[il1exmu] = gmtCand.quality();
00323 il1exmu++;
00324 }
00325 }
00326 else {
00327 nl1extmu = 0;
00328 if (_Debug) std::cout << "%HLTInfo -- No L1 MU object" << std::endl;
00329 }
00330
00331 const int maxL1CenJet = 4;
00332 for (int i=0; i!=maxL1CenJet; ++i){
00333 l1extjtcet[i] = -999.;
00334 l1extjtce[i] = -999.;
00335 l1extjtceta[i] = -999.;
00336 l1extjtcphi[i] = -999.;
00337 }
00338 if (L1ExtJetC.isValid()) {
00339 nl1extjetc = maxL1CenJet;
00340 l1extra::L1JetParticleCollection myl1jetsc;
00341 myl1jetsc = * L1ExtJetC;
00342 std::sort(myl1jetsc.begin(),myl1jetsc.end(),EtGreater());
00343 int il1exjt = 0;
00344 for (l1extra::L1JetParticleCollection::const_iterator jtItr = myl1jetsc.begin(); jtItr != myl1jetsc.end(); ++jtItr) {
00345 l1extjtcet[il1exjt] = jtItr->et();
00346 l1extjtce[il1exjt] = jtItr->energy();
00347 l1extjtceta[il1exjt] = jtItr->eta();
00348 l1extjtcphi[il1exjt] = jtItr->phi();
00349 il1exjt++;
00350 }
00351 }
00352 else {
00353 nl1extjetc = 0;
00354 if (_Debug) std::cout << "%HLTInfo -- No L1 Central JET object" << std::endl;
00355 }
00356
00357 const int maxL1ForJet = 4;
00358 for (int i=0; i!=maxL1ForJet; ++i){
00359 l1extjtfet[i] = -999.;
00360 l1extjtfe[i] = -999.;
00361 l1extjtfeta[i] = -999.;
00362 l1extjtfphi[i] = -999.;
00363 }
00364 if (L1ExtJetF.isValid()) {
00365 nl1extjetf = maxL1ForJet;
00366 l1extra::L1JetParticleCollection myl1jetsf;
00367 myl1jetsf = * L1ExtJetF;
00368 std::sort(myl1jetsf.begin(),myl1jetsf.end(),EtGreater());
00369 int il1exjt = 0;
00370 for (l1extra::L1JetParticleCollection::const_iterator jtItr = myl1jetsf.begin(); jtItr != myl1jetsf.end(); ++jtItr) {
00371 l1extjtfet[il1exjt] = jtItr->et();
00372 l1extjtfe[il1exjt] = jtItr->energy();
00373 l1extjtfeta[il1exjt] = jtItr->eta();
00374 l1extjtfphi[il1exjt] = jtItr->phi();
00375 il1exjt++;
00376 }
00377 }
00378 else {
00379 nl1extjetf = 0;
00380 if (_Debug) std::cout << "%HLTInfo -- No L1 Forward JET object" << std::endl;
00381 }
00382
00383 const int maxL1TauJet = 4;
00384 for (int i=0; i!=maxL1TauJet; ++i){
00385 l1exttauet[i] = -999.;
00386 l1exttaue[i] = -999.;
00387 l1exttaueta[i] = -999.;
00388 l1exttauphi[i] = -999.;
00389 }
00390 if (L1ExtTau.isValid()) {
00391 nl1exttau = maxL1TauJet;
00392 l1extra::L1JetParticleCollection myl1taus;
00393 myl1taus = * L1ExtTau;
00394 std::sort(myl1taus.begin(),myl1taus.end(),EtGreater());
00395 int il1extau = 0;
00396 for (l1extra::L1JetParticleCollection::const_iterator tauItr = myl1taus.begin(); tauItr != myl1taus.end(); ++tauItr) {
00397 l1exttauet[il1extau] = tauItr->et();
00398 l1exttaue[il1extau] = tauItr->energy();
00399 l1exttaueta[il1extau] = tauItr->eta();
00400 l1exttauphi[il1extau] = tauItr->phi();
00401 il1extau++;
00402 }
00403 }
00404 else {
00405 nl1exttau = 0;
00406 if (_Debug) std::cout << "%HLTInfo -- No L1 TAU object" << std::endl;
00407 }
00408
00409 if (L1ExtMet.isValid()) {
00410 met = L1ExtMet->begin()->etMiss();
00411 metphi = L1ExtMet->begin()->phi();
00412 ettot = L1ExtMet->begin()->etTotal();
00413 }
00414 else {
00415 if (_Debug) std::cout << "%HLTInfo -- No L1 MET object" << std::endl;
00416 }
00417
00418 if (L1ExtMht.isValid()) {
00419 mht = L1ExtMht->begin()->etMiss();
00420 mhtphi = L1ExtMht->begin()->phi();
00421 ethad = L1ExtMht->begin()->etTotal();
00422 }
00423 else {
00424 if (_Debug) std::cout << "%HLTInfo -- No L1 MHT object" << std::endl;
00425 }
00426
00427
00428
00429
00430
00431 m_l1GtUtils.retrieveL1EventSetup(eventSetup);
00432 edm::ESHandle<L1GtTriggerMenu> menuRcd;
00433 eventSetup.get<L1GtTriggerMenuRcd>().get(menuRcd) ;
00434 const L1GtTriggerMenu* menu = menuRcd.product();
00435
00436 int iErrorCode = -1;
00437 L1GtUtils::TriggerCategory trigCategory = L1GtUtils::AlgorithmTrigger;
00438 const int pfSetIndexAlgorithmTrigger = m_l1GtUtils.prescaleFactorSetIndex(
00439 iEvent, trigCategory, iErrorCode);
00440 if (iErrorCode == 0) {
00441 if (_Debug) std::cout << "%Prescale set index: " << pfSetIndexAlgorithmTrigger << std::endl;
00442 }else{
00443 std::cout << "%Could not extract Prescale set index from event record. Error code: " << iErrorCode << std::endl;
00444 }
00445
00446
00447 if (L1GTRR.isValid()) {
00448
00449 DecisionWord gtDecisionWord = L1GTRR->decisionWord();
00450 const unsigned int numberTriggerBits(gtDecisionWord.size());
00451 const TechnicalTriggerWord& technicalTriggerWordBeforeMask = L1GTRR->technicalTriggerWord();
00452 const unsigned int numberTechnicalTriggerBits(technicalTriggerWordBeforeMask.size());
00453
00454
00455 if (L1EvtCnt==0){
00456
00457
00458
00459 const edm::Provenance& prov = iEvent.getProvenance(L1GTRR.id());
00460
00461 edm::ParameterSetID setId = prov.psetID();
00462
00463
00464
00465 edm::ParameterSet pSet=getParameterSet(setId);
00466
00467 if (pSet.exists("UnpackBxInEvent")){
00468 UnpackBxInEvent = pSet.getParameter<int>("UnpackBxInEvent");
00469 }
00470 if (_Debug) std::cout << "Number of beam crossings unpacked by GT: " << UnpackBxInEvent << std::endl;
00471 if (UnpackBxInEvent == 5) _OR_BXes = true;
00472
00473
00474 for (CItAlgo algo = menu->gtAlgorithmMap().begin(); algo!=menu->gtAlgorithmMap().end(); ++algo) {
00475 if (_Debug) std::cout << "Name: " << (algo->second).algoName() << " Alias: " << (algo->second).algoAlias() << std::endl;
00476 int itrig = (algo->second).algoBitNumber();
00477 algoBitToName[itrig] = TString( (algo->second).algoName() );
00478 HltTree->Branch(algoBitToName[itrig],l1flag+itrig,algoBitToName[itrig]+"/I");
00479 HltTree->Branch(algoBitToName[itrig]+"_Prescl",l1Prescl+itrig,algoBitToName[itrig]+"_Prescl/I");
00480 if (_OR_BXes)
00481 HltTree->Branch(algoBitToName[itrig]+"_5bx",l1flag5Bx+itrig,algoBitToName[itrig]+"_5bx/I");
00482 }
00483
00484
00485 for (CItAlgo techTrig = menu->gtTechnicalTriggerMap().begin(); techTrig != menu->gtTechnicalTriggerMap().end(); ++techTrig) {
00486 int itrig = (techTrig->second).algoBitNumber();
00487 techBitToName[itrig] = TString( (techTrig->second).algoName() );
00488 if (_Debug) std::cout << "tech bit " << itrig << ": " << techBitToName[itrig] << " " << std::endl;
00489 HltTree->Branch(techBitToName[itrig],l1techflag+itrig,techBitToName[itrig]+"/I");
00490 HltTree->Branch(techBitToName[itrig]+"_Prescl",l1techPrescl+itrig,techBitToName[itrig]+"_Prescl/I");
00491 if (_OR_BXes)
00492 HltTree->Branch(techBitToName[itrig]+"_5bx",l1techflag5Bx+itrig,techBitToName[itrig]+"_5bx/I");
00493 }
00494 }
00495
00496 std::string triggerAlgTechTrig = "PhysicsAlgorithms";
00497 for (unsigned int iBit = 0; iBit < numberTriggerBits; ++iBit) {
00498
00499 l1flag[iBit] = gtDecisionWord[iBit];
00500
00501 std::string l1triggername= std::string (algoBitToName[iBit]);
00502 l1Prescl[iBit] = m_l1GtUtils.prescaleFactor(iEvent,
00503 l1triggername,
00504 iErrorCode);
00505
00506 if (_Debug) std::cout << "L1 TD: "<<iBit<<" "<<algoBitToName[iBit]<<" "
00507 << gtDecisionWord[iBit]<<" "
00508 << l1Prescl[iBit] << std::endl;
00509
00510 }
00511
00512 triggerAlgTechTrig = "TechnicalTriggers";
00513 for (unsigned int iBit = 0; iBit < numberTechnicalTriggerBits; ++iBit) {
00514 l1techflag[iBit] = (int) technicalTriggerWordBeforeMask.at(iBit);
00515
00516 std::string l1triggername= std::string (techBitToName[iBit]);
00517 l1techPrescl[iBit] = m_l1GtUtils.prescaleFactor(iEvent,
00518 l1triggername,
00519 iErrorCode);
00520
00521 if (_Debug) std::cout << "L1 TD: "<<iBit<<" "<<techBitToName[iBit]<<" "
00522 << l1techflag[iBit]<<" "
00523 << l1Prescl[iBit] << std::endl;
00524
00525 }
00526
00527 if (_OR_BXes){
00528
00529
00530 std::vector<DecisionWord> m_gtDecisionWord5Bx;
00531 std::vector<TechnicalTriggerWord> m_gtTechDecisionWord5Bx;
00532 std::vector<int> m_ibxn;
00533
00534 const std::vector<L1GtFdlWord> &m_gtFdlWord(L1GTRR->gtFdlVector());
00535 for (std::vector<L1GtFdlWord>::const_iterator itBx = m_gtFdlWord.begin();
00536 itBx != m_gtFdlWord.end(); ++itBx) {
00537 if (_Debug && L1EvtCnt==0) std::cout << "bx: " << (*itBx).bxInEvent() << " ";
00538 m_gtDecisionWord5Bx.push_back((*itBx).gtDecisionWord());
00539 m_gtTechDecisionWord5Bx.push_back((*itBx).gtTechnicalTriggerWord());
00540 }
00541
00542 for (unsigned int iBit = 0; iBit < numberTriggerBits; ++iBit) {
00543
00544 if (_Debug) std::cout << std::endl << " L1 TD: "<<iBit<<" "<<algoBitToName[iBit]<<" ";
00545 int result=0;
00546 int bitword=0;
00547 for (unsigned int jbx=0; jbx<m_gtDecisionWord5Bx.size(); ++jbx) {
00548 if (_Debug) std::cout << m_gtDecisionWord5Bx[jbx][iBit]<< " ";
00549 result += m_gtDecisionWord5Bx[jbx][iBit];
00550 if (m_gtDecisionWord5Bx[jbx][iBit]>0) bitword |= 1 << jbx;
00551 }
00552 if (_Debug && result>1) {std::cout << "5BxOr=" << result << " Bitword= "<< bitword <<std::endl;
00553 std::cout << "Unpacking: " ;
00554 for (int i = 0; i<UnpackBxInEvent ; ++i){
00555 bool bitOn=bitword & (1 << i);
00556 std::cout << bitOn << " ";
00557 }
00558 std::cout << "\n";
00559 }
00560 l1flag5Bx[iBit] = bitword;
00561 }
00562
00563 for (unsigned int iBit = 0; iBit < m_gtTechDecisionWord5Bx[2].size(); ++iBit) {
00564
00565 if (_Debug) std::cout << std::endl << " L1 TD: "<<iBit<<" "<<techBitToName[iBit]<<" ";
00566 int result=0;
00567 int bitword=0;
00568 for (unsigned int jbx=0; jbx<m_gtTechDecisionWord5Bx.size(); ++jbx) {
00569 if (_Debug) std::cout << m_gtTechDecisionWord5Bx[jbx][iBit]<< " ";
00570 result += m_gtTechDecisionWord5Bx[jbx][iBit];
00571 if (m_gtTechDecisionWord5Bx[jbx][iBit]>0) bitword |= 1 << jbx;
00572 }
00573 if (_Debug && result>1) {std::cout << "5BxOr=" << result << " Bitword= "<< bitword << std::endl;
00574 std::cout << "Unpacking: " ;
00575 for (int i = 0; i<UnpackBxInEvent ; ++i){
00576 bool bitOn=bitword & (1 << i);
00577 std::cout << bitOn << " ";
00578 }
00579 std::cout << "\n";
00580 }
00581 l1techflag5Bx[iBit] = bitword;
00582 }
00583 }
00584
00585 L1EvtCnt++;
00586 }
00587 else {
00588 if (_Debug) std::cout << "%HLTInfo -- No L1 GT ReadoutRecord " << std::endl;
00589 }
00590
00591
00592
00593
00594
00595 if (gctBitCounts.isValid()) {
00596 L1GctHFBitCountsCollection::const_iterator bitCountItr;
00597 for (bitCountItr=gctBitCounts->begin(); bitCountItr!=gctBitCounts->end(); ++bitCountItr) {
00598 if (bitCountItr->bx()==0){
00599 l1hfTowerCountPositiveEtaRing1=bitCountItr->bitCount(0);
00600 l1hfTowerCountNegativeEtaRing1=bitCountItr->bitCount(1);
00601 l1hfTowerCountPositiveEtaRing2=bitCountItr->bitCount(2);
00602 l1hfTowerCountNegativeEtaRing2=bitCountItr->bitCount(3);
00603 }
00604 }
00605 } else {
00606 if (_Debug) std::cout << "%HLTInfo -- No L1 Gct HF BitCounts" << std::endl;
00607 }
00608
00609 if (gctRingSums.isValid()) {
00610 L1GctHFRingEtSumsCollection::const_iterator ringSumsItr;
00611 for (ringSumsItr=gctRingSums->begin(); ringSumsItr!=gctRingSums->end(); ++ringSumsItr) {
00612 if (ringSumsItr->bx()==0){
00613 l1hfRing1EtSumPositiveEta=ringSumsItr->etSum(0);
00614 l1hfRing1EtSumNegativeEta=ringSumsItr->etSum(1);
00615 l1hfRing2EtSumPositiveEta=ringSumsItr->etSum(2);
00616 l1hfRing2EtSumNegativeEta=ringSumsItr->etSum(3);
00617 }
00618 }
00619 } else {
00620 if (_Debug) std::cout << "%HLTInfo -- No L1 Gct HF RingSums" << std::endl;
00621 }
00622
00623 if (_Debug) std::cout << "%HLTInfo -- Done with routine" << std::endl;
00624 }