Skip to content

Commit

Permalink
Merge pull request cms-sw#87 from stahlleiton/HLTBitAnalyzer_L1Stage2…
Browse files Browse the repository at this point in the history
…_TMP

Added Initial L1 Decisions to HLTStage2Info
  • Loading branch information
kurtejung authored Nov 4, 2016
2 parents a84c422 + cca817d commit 9d23c84
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 14 deletions.
1 change: 1 addition & 0 deletions HLTrigger/HLTanalyzers/interface/HLTBitAnalyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,6 @@ class HLTBitAnalyzer : public edm::EDAnalyzer {
TFile* m_file; // pointer to Histogram file
bool _UseTFileService;
bool _UseL1Stage2;
bool _getL1InfoFromEventSetup;

};
6 changes: 4 additions & 2 deletions HLTrigger/HLTanalyzers/interface/HLTStage2Info.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,19 @@ class HLTStage2Info {
int *l1stage2dimuchg, *l1stage2dimuidx1, *l1stage2dimuidx2;
float *l1stage2jtet, *l1stage2jte, *l1stage2jteta, *l1stage2jtphi;
float *l1stage2tauet, *l1stage2taue, *l1stage2taueta, *l1stage2tauphi;
int *l1stage2etset, *l1stage2etsphi;
int *l1stage2etshwet, *l1stage2etshwphi;
float *l1stage2etset, *l1stage2etsphi;
int *l1stage2ctetem, *l1stage2cteth, *l1stage2ctetc, *l1stage2cteta, *l1stage2ctphi;
int *l1stage2etstype;
int *l1stage2egbx, *l1stage2mubx, *l1stage2jtbx, *l1stage2taubx, *l1stage2etsbx, *l1stage2ctbx;
int L1TEvtCnt,HltEvtCnt,nl1stage2eg,nl1stage2mu,nl1stage2dimu,nl1stage2jet,nl1stage2tau,nl1stage2ets;

int *trigflag, *l1TFinalFlag, *trigPrescl, *l1TPrescl;
int *trigflag, *l1TFinalFlag, *l1TInitialFlag, *trigPrescl, *l1TPrescl;

std::map<int,TString> algoBitToName;
std::vector<std::string> dummyBranches_;
bool getPrescales_;
bool getL1InfoFromEventSetup_;

std::unique_ptr<HLTConfigProvider> hltConfigProvider_;
std::unique_ptr<l1t::L1TGlobalUtil> l1tGlobalUtil_;
Expand Down
1 change: 1 addition & 0 deletions HLTrigger/HLTanalyzers/python/HLTBitAnalyser_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

### L1 Stage 2 objects
l1tAlgBlkInputTag = cms.InputTag("gtStage2Digis"), # Needed, fix bug of GlobalAlgBlk uninitialized token
l1tExtBlkInputTag = cms.InputTag("gtStage2Digis"),
gObjectMapRecord = cms.InputTag("hltGtStage2ObjectMap"),
gmtStage2Digis = cms.string("gmtStage2Digis"),
caloStage2Digis = cms.string("caloStage2Digis"),
Expand Down
3 changes: 2 additions & 1 deletion HLTrigger/HLTanalyzers/src/HLTBitAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ HLTBitAnalyzer::HLTBitAnalyzer(edm::ParameterSet const& conf) :
// variables. Example as follows:

_UseL1Stage2 = conf.getUntrackedParameter<bool>("UseL1Stage2",true);
_getL1InfoFromEventSetup = conf.getUntrackedParameter<bool>("getL1InfoFromEventSetup", true);

if (_UseL1Stage2) {
std::cout << " Starting Stage2 HLTBitAnalyzer Analysis " << std::endl;
Expand Down Expand Up @@ -154,7 +155,7 @@ void HLTBitAnalyzer::analyze(edm::Event const& iEvent, edm::EventSetup const& iS

getCollection( iEvent, missing, hltresults, hltresults_, hltresultsToken_, kHltresults );
if (_UseL1Stage2) {
getCollection( iEvent, missing, l1GoMR, gObjectMapRecord_, gObjectMapRecordToken_,"L1 Stage2 Global Object Map Record" );
if(!_getL1InfoFromEventSetup) getCollection( iEvent, missing, l1GoMR, gObjectMapRecord_, gObjectMapRecordToken_,"L1 Stage2 Global Object Map Record" );
getCollection( iEvent, missing, l1stage2eg, m_l1stage2eg, l1stage2egToken_, "L1 Stage2 EGamma objects" );
getCollection( iEvent, missing, l1stage2mu, m_l1stage2mu, l1stage2muToken_, "L1 Stage2 Muon objects" );
getCollection( iEvent, missing, l1stage2jet, m_l1stage2jet, l1stage2jetToken_, "L1 Stage2 Jet objects" );
Expand Down
36 changes: 25 additions & 11 deletions HLTrigger/HLTanalyzers/src/HLTStage2Info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ void HLTStage2Info::setup(const edm::ParameterSet& pSet, TTree* HltTree) {
}

getPrescales_ = pSet.getUntrackedParameter<bool>("getPrescales", false);
getL1InfoFromEventSetup_ = pSet.getUntrackedParameter<bool>("getL1InfoFromEventSetup", true);
dummyBranches_ = pSet.getUntrackedParameter<std::vector<std::string> >("dummyBranches",std::vector<std::string>(0));

HltEvtCnt = 0;
Expand All @@ -66,6 +67,7 @@ void HLTStage2Info::setup(const edm::ParameterSet& pSet, TTree* HltTree) {
trigPrescl = new int[kMaxTrigFlag];
L1TEvtCnt = 0;
const int kMaxL1TFlag = 10000;
l1TInitialFlag = new int[kMaxL1TFlag];
l1TFinalFlag = new int[kMaxL1TFlag];
l1TPrescl = new int[kMaxL1TFlag];
const int kMaxHLTPart = 10000;
Expand Down Expand Up @@ -111,8 +113,10 @@ void HLTStage2Info::setup(const edm::ParameterSet& pSet, TTree* HltTree) {
l1stage2tauphi = new float[kMaxL1Stage2Tau];
l1stage2taubx = new int[kMaxL1Stage2Tau];
const int kMaxL1Stage2EtS = 10000;
l1stage2etset = new int[kMaxL1Stage2EtS];
l1stage2etsphi = new int[kMaxL1Stage2EtS];
l1stage2etset = new float[kMaxL1Stage2EtS];
l1stage2etsphi = new float[kMaxL1Stage2EtS];
l1stage2etshwet = new int[kMaxL1Stage2EtS];
l1stage2etshwphi = new int[kMaxL1Stage2EtS];
l1stage2etstype = new int[kMaxL1Stage2EtS];
l1stage2etsbx = new int[kMaxL1Stage2EtS];

Expand Down Expand Up @@ -158,8 +162,10 @@ void HLTStage2Info::setup(const edm::ParameterSet& pSet, TTree* HltTree) {
HltTree->Branch("L1Stage2TauPhi",l1stage2tauphi,"L1Stage2TauPhi[NL1Stage2Tau]/F");
HltTree->Branch("L1Stage2TauBx",l1stage2taubx,"L1Stage2TauBx[NL1Stage2Tau]/I");
HltTree->Branch("NL1Stage2EtSum",&nl1stage2ets,"NL1Stage2EtSum/I");
HltTree->Branch("L1Stage2EtSumEt",l1stage2etset,"L1Stage2EtSumEt[NL1Stage2EtSum]/I");
HltTree->Branch("L1Stage2EtSumPhi",l1stage2etsphi,"L1Stage2EtSumPhi[NL1Stage2EtSum]/I");
HltTree->Branch("L1Stage2EtSumEt",l1stage2etset,"L1Stage2EtSumEt[NL1Stage2EtSum]/F");
HltTree->Branch("L1Stage2EtSumPhi",l1stage2etsphi,"L1Stage2EtSumPhi[NL1Stage2EtSum]/F");
HltTree->Branch("L1Stage2EtSumHwEt",l1stage2etshwet,"L1Stage2EtSumHwEt[NL1Stage2EtSum]/I");
HltTree->Branch("L1Stage2EtSumHwPhi",l1stage2etshwphi,"L1Stage2EtSumHwPhi[NL1Stage2EtSum]/I");
HltTree->Branch("L1Stage2EtSumType",l1stage2etstype,"L1Stage2EtSumType[NL1Stage2EtSum]/I");
HltTree->Branch("L1Stage2EtSumBx",l1stage2etsbx,"L1Stage2EtSumBx[NL1Stage2EtSum]/I");
}
Expand Down Expand Up @@ -355,8 +361,10 @@ void HLTStage2Info::analyze(const edm::Handle<edm::TriggerResults>
typedef std::vector<l1t::EtSum>::const_iterator l1cand;
for(int iBx = L1Stage2EtSum->getFirstBX(); iBx <= L1Stage2EtSum->getLastBX(); ++iBx) {
for (l1cand etsItr=L1Stage2EtSum->begin(iBx); etsItr!=L1Stage2EtSum->end(iBx); ++etsItr) {
l1stage2etset[il1stage2ets] = etsItr->hwPt();
l1stage2etsphi[il1stage2ets] = etsItr->hwPhi();
l1stage2etset[il1stage2ets] = etsItr->et();
l1stage2etsphi[il1stage2ets] = etsItr->phi();
l1stage2etshwet[il1stage2ets] = etsItr->hwPt();
l1stage2etshwphi[il1stage2ets] = etsItr->hwPhi();
l1stage2etstype[il1stage2ets] = etsItr->getType();
l1stage2etsbx[il1stage2ets] = iBx;
il1stage2ets++;
Expand All @@ -372,16 +380,17 @@ void HLTStage2Info::analyze(const edm::Handle<edm::TriggerResults>
//==============L1 Stage2 information=======================================


if (L1GOMR.isValid()) {
if (L1GOMR.isValid() && !getL1InfoFromEventSetup_) {
// Get the stage2 menu from GlobalObjectMapRecord collection
if (L1TEvtCnt==0){
const std::vector<GlobalObjectMap> gObjectMapRecord = L1GOMR->gtObjectMap();
// 1st event : Book as many branches as trigger paths provided in the input...
const std::vector<GlobalObjectMap> gObjectMapRecord = L1GOMR->gtObjectMap();
std::vector<GlobalObjectMap>::const_iterator gObjectMap = gObjectMapRecord.begin();
// Book branches for algo bits
for (; gObjectMap!=gObjectMapRecord.end(); ++gObjectMap) {
int itrig = gObjectMap->algoBitNumber();
algoBitToName[itrig] = TString( gObjectMap->algoName() );
HltTree->Branch(algoBitToName[itrig],l1TFinalFlag+itrig,algoBitToName[itrig]+"/I");
HltTree->Branch(algoBitToName[itrig]+"_Final",l1TFinalFlag+itrig,algoBitToName[itrig]+"_Final/I");
HltTree->Branch(algoBitToName[itrig]+"_Prescl",l1TPrescl+itrig,algoBitToName[itrig]+"_Prescl/I");
}
}
Expand All @@ -390,6 +399,7 @@ void HLTStage2Info::analyze(const edm::Handle<edm::TriggerResults>
for (; iL1Trig!=algoBitToName.end(); ++iL1Trig) {
std::string name = iL1Trig->second.Data();
int iBit = iL1Trig->first;
l1TInitialFlag[iBit] = false; // The Global Object Collection doesn't have initial L1 decisions
l1TFinalFlag[iBit] = L1GOMR->getObjectMap(name)->algoGtlResult();
if(!(l1tGlobalUtil_->getPrescaleByName(name, l1TPrescl[iBit]))) l1TPrescl[iBit] = -1;
}
Expand All @@ -398,15 +408,17 @@ void HLTStage2Info::analyze(const edm::Handle<edm::TriggerResults>
else {
// Get the stage2 menu from Event Setup
if (L1TEvtCnt==0){
// 1st event : Book as many branches as trigger paths provided in the input...
edm::ESTransientHandle<L1TUtmTriggerMenu> l1GtMenu;
eventSetup.get< L1TUtmTriggerMenuRcd>().get(l1GtMenu);
eventSetup.get<L1TUtmTriggerMenuRcd>().get(l1GtMenu);
if(l1GtMenu.isValid()) {
const L1TUtmTriggerMenu* stage2Menu = l1GtMenu.product();
// Book branches for algo bits
for (auto const & algo: stage2Menu->getAlgorithmMap()) {
int itrig = algo.second.getIndex();
algoBitToName[itrig] = TString( algo.second.getName() );
HltTree->Branch(algoBitToName[itrig],l1TFinalFlag+itrig,algoBitToName[itrig]+"/I");
HltTree->Branch(algoBitToName[itrig]+"_Initial",l1TInitialFlag+itrig,algoBitToName[itrig]+"_Initial/I");
HltTree->Branch(algoBitToName[itrig]+"_Final",l1TFinalFlag+itrig,algoBitToName[itrig]+"_Final/I");
HltTree->Branch(algoBitToName[itrig]+"_Prescl",l1TPrescl+itrig,algoBitToName[itrig]+"_Prescl/I");
}
}
Expand All @@ -419,6 +431,8 @@ void HLTStage2Info::analyze(const edm::Handle<edm::TriggerResults>
bool des = false;
if (!(l1tGlobalUtil_->getFinalDecisionByName(name, des))) l1TFinalFlag[iBit] = false;
else l1TFinalFlag[iBit] = des;
if (!(l1tGlobalUtil_->getInitialDecisionByName(name, des))) l1TInitialFlag[iBit] = false;
else l1TInitialFlag[iBit] = des;
if(!(l1tGlobalUtil_->getPrescaleByName(name, l1TPrescl[iBit]))) l1TPrescl[iBit] = -1;
}
L1TEvtCnt++;
Expand Down

0 comments on commit 9d23c84

Please sign in to comment.