Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modified HLTriggerOffline/SUSYBSM package in order to check some HLT pat... #3646

Merged
merged 3 commits into from May 8, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion HLTriggerOffline/SUSYBSM/interface/TriggerValidator.h
Expand Up @@ -121,7 +121,7 @@ class TriggerValidator : public edm::EDAnalyzer {
edm::InputTag muonTag_;
edm::InputTag triggerTag_;
std::string processName_;
std::string triggerName_;
std::vector<std::string> hltPathsToCheck_;
edm::EDGetTokenT<L1GlobalTriggerReadoutRecord> gtDigis_token_;

// name of each L1 algorithm
Expand Down
28 changes: 27 additions & 1 deletion HLTriggerOffline/SUSYBSM/python/SUSYBSM_triggerValidation_cff.py
Expand Up @@ -313,7 +313,33 @@
## Put false for usage in the DQM framework (reduce the number of bins).
triggerTag = cms.InputTag("hltTriggerSummaryAOD"),
hltConfigName = cms.string("HLT"),
triggerName = cms.string("@"),
hltPathsToCheck = cms.vstring(
"HLT_RsqMR45_Rsq0p09_v",
"HLT_RsqMR55_Rsq0p09_MR150_v",
"HLT_IsoMu12_RsqMR30_Rsq0p04_MR200_v",
"HLT_Ele12_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_RsqMR30_Rsq0p04_MR200_v",
"HLT_Photon40_CaloIdL_RsqMR40_Rsq0p09_MR150_v",
"HLT_HT750_v",
"HLT_PFNoPUHT650_v",
"HLT_PFNoPUHT350_PFMET100_v",
"HLT_QuadJet50_v",
"HLT_SixJet45_v",
"HLT_EightJet30_eta3p0_v",
"HLT_PFMET150_v",
"HLT_DiCentralPFNoPUJet50_PFMETORPFMETNoMu80_v",
"HLT_HT200_AlphaT0p57_v",
"HLT_HT250_AlphaT0p55_v",
"HLT_HT300_AlphaT0p53_v",
"HLT_HT350_AlphaT0p52_v",
"HLT_HT400_AlphaT0p51_v",
"HLT_HT450_AlphaT0p51_v",
"HLT_Ele25_CaloIdVT_CaloIsoVL_TrkIdVL_TrkIsoT_TriCentralPFNoPUJet30_v",
"HLT_IsoMu17_eta2p1_TriCentralPFNoPUJet30_30_20_v",
"HLT_CleanPFNoPUHT300_Ele40_CaloIdVT_TrkIdT_v",
"HLT_Mu40_PFNoPUHT350_v",
"HLT_PFNoPUHT350_Mu15_PFMET50_v",
"HLT_PFNoPUHT400_Mu5_PFMET50_v"
),
muonTag = cms.InputTag('muons'),
histoFileName = cms.untracked.string('MonElements_LM1_IDEAL_30x_v1_300pre7.root'),
PlotMakerL1Input = cms.PSet(
Expand Down
Expand Up @@ -311,7 +311,33 @@
## Put false for usage in the DQM framework (reduce the number of bins).
triggerTag = cms.InputTag("hltTriggerSummaryAOD"),
hltConfigName = cms.string("HLT"),
triggerName = cms.string("@"),
hltPathsToCheck = cms.vstring(
"HLT_RsqMR45_Rsq0p09_v",
"HLT_RsqMR55_Rsq0p09_MR150_v",
"HLT_IsoMu12_RsqMR30_Rsq0p04_MR200_v",
"HLT_Ele12_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_RsqMR30_Rsq0p04_MR200_v",
"HLT_Photon40_CaloIdL_RsqMR40_Rsq0p09_MR150_v",
"HLT_HT750_v",
"HLT_PFNoPUHT650_v",
"HLT_PFNoPUHT350_PFMET100_v",
"HLT_QuadJet50_v",
"HLT_SixJet45_v",
"HLT_EightJet30_eta3p0_v",
"HLT_PFMET150_v",
"HLT_DiCentralPFNoPUJet50_PFMETORPFMETNoMu80_v",
"HLT_HT200_AlphaT0p57_v",
"HLT_HT250_AlphaT0p55_v",
"HLT_HT300_AlphaT0p53_v",
"HLT_HT350_AlphaT0p52_v",
"HLT_HT400_AlphaT0p51_v",
"HLT_HT450_AlphaT0p51_v",
"HLT_Ele25_CaloIdVT_CaloIsoVL_TrkIdVL_TrkIsoT_TriCentralPFNoPUJet30_v",
"HLT_IsoMu17_eta2p1_TriCentralPFNoPUJet30_30_20_v",
"HLT_CleanPFNoPUHT300_Ele40_CaloIdVT_TrkIdT_v",
"HLT_Mu40_PFNoPUHT350_v",
"HLT_PFNoPUHT350_Mu15_PFMET50_v",
"HLT_PFNoPUHT400_Mu5_PFMET50_v"
),
muonTag = cms.InputTag('muons'),
histoFileName = cms.untracked.string('MonElements_LM1_IDEAL_30x_v1_300pre7.root'),
PlotMakerL1Input = cms.PSet(
Expand Down
176 changes: 62 additions & 114 deletions HLTriggerOffline/SUSYBSM/src/TriggerValidator.cc
Expand Up @@ -53,6 +53,7 @@ Description: Class to validate the Trigger Performance of the SUSYBSM group
#include "TObjString.h"
#include "TString.h"
#include "TObject.h"
#include "TPRegexp.h"

//
// constants, enums and typedefs
Expand Down Expand Up @@ -91,7 +92,7 @@ TriggerValidator::TriggerValidator(const edm::ParameterSet& iConfig):
muonTag_(iConfig.getParameter<edm::InputTag>("muonTag")),
triggerTag_(iConfig.getParameter<edm::InputTag>("triggerTag")),
processName_(iConfig.getParameter<std::string>("hltConfigName")),
triggerName_(iConfig.getParameter<std::string>("triggerName")),
hltPathsToCheck_(iConfig.getParameter<vector<string>>("hltPathsToCheck")),
gtDigis_token_(consumes<L1GlobalTriggerReadoutRecord>(iConfig.getUntrackedParameter<edm::InputTag>("gtDigis",edm::InputTag("gtDigis"))))
{
//now do what ever initialization is needed
Expand All @@ -118,9 +119,6 @@ TriggerValidator::TriggerValidator(const edm::ParameterSet& iConfig):
if (iConfig.getUntrackedParameter < bool > ("DQMStore", false)) {
dbe_->setVerbose(0);
}




if (dbe_ != 0 ) {
dbe_->setCurrentFolder(dirname_);
Expand Down Expand Up @@ -274,98 +272,72 @@ TriggerValidator::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetu
edm::Handle<TriggerResults> trhv;
iEvent.getByToken(hlt_token_,trhv);
if( ! trhv.isValid() ) {
LogDebug("") << "HL TriggerResults with label ["+hltLabel.encode()+"] not found!";
LogDebug("SUSYBSM") << "HL TriggerResults with label ["+hltLabel.encode()+"] not found!";
return;
}


// if(!trhv.isValid()) {
// std::cout << "invalid handle for HLT TriggerResults" << std::endl;
// }


if(firstEvent) {



//
// The following piece of code concerns efficiencies and so must be moved to the client
//


// //resize the eff and overlap vectors ccording to the number of L1 paths
// effHltBeforeCuts.resize(trhv->size()+1);
// effHltAfterRecoCuts.resize(trhv->size()+1);
// effHltAfterMcCuts.resize(trhv->size()+1);
vCorrHlt.resize(trhv->size());
for(unsigned int i=0; i<trhv->size(); i++) {vCorrHlt[i].resize(trhv->size());}
vCorrNormHlt.resize(trhv->size());
for(unsigned int i=0; i<trhv->size(); i++) {vCorrNormHlt[i].resize(trhv->size());}


//resize the name vector and get the names
const edm::TriggerNames & triggerNames = iEvent.triggerNames(*trhv);
hlNames_=triggerNames.triggerNames();
hlNames_.push_back("Total");
vCorrHlt.resize(hlNames_.size());
for(unsigned int i=0; i<hlNames_.size(); i++) {vCorrHlt[i].resize(hlNames_.size());}
vCorrNormHlt.resize(hlNames_.size());
for(unsigned int i=0; i<hlNames_.size(); i++) {vCorrNormHlt[i].resize(hlNames_.size());}

//set the bin names for the "path" histos
for (unsigned int i=0; i<hlNames_.size(); ++i) {
for(unsigned int i=0; i < hlNames_.size(); i++) {
hHltPathsBeforeCuts->setBinLabel(i+1,hlNames_[i].c_str(),1);
for(unsigned int j=0; j<hHltPathsAfterRecoCuts.size(); ++j) hHltPathsAfterRecoCuts[j]->setBinLabel(i+1,hlNames_[i].c_str(),1);
for(unsigned int j=0; j<hHltPathsAfterMcCuts.size(); ++j) hHltPathsAfterMcCuts[j]->setBinLabel(i+1,hlNames_[i].c_str(),1);
}
}

//fill the eff vectors and histos for HLT
for(unsigned int i=0; i< trhv->size(); i++) {
hltbits.push_back(trhv->at(i).accept());
if(trhv->at(i).accept()) {
numTotHltBitsBeforeCuts[i]++;
hHltBitsBeforeCuts->Fill(i);
hHltPathsBeforeCuts->Fill(i);
for(unsigned int j=0; j<eventRecoSelected.size(); ++j)
if(eventRecoSelected[j]) {
numTotHltBitsAfterRecoCuts[j][i]++;
hHltBitsAfterRecoCuts[j]->Fill(i);
hHltPathsAfterRecoCuts[j]->Fill(i);
}
for(unsigned int j=0; j<eventMcSelected.size(); ++j)
if(eventMcSelected[j]) {
numTotHltBitsAfterMcCuts[j][i]++;
hHltBitsAfterMcCuts[j]->Fill(i);
hHltPathsAfterMcCuts[j]->Fill(i);
}
}
for(unsigned int i=0; i < hlNames_.size(); i++) {
const unsigned int path_index(hltConfig_.triggerIndex(hlNames_[i]));
if ( path_index < hltConfig_.size() ){
hltbits.push_back(trhv->at(path_index).accept());
if( trhv->at(path_index).accept() ) {
numTotHltBitsBeforeCuts[i]++;
hHltBitsBeforeCuts->Fill(i);
hHltPathsBeforeCuts->Fill(i);
for(unsigned int j=0; j<eventRecoSelected.size(); ++j)
if(eventRecoSelected[j]) {
numTotHltBitsAfterRecoCuts[j][i]++;
hHltBitsAfterRecoCuts[j]->Fill(i);
hHltPathsAfterRecoCuts[j]->Fill(i);
}
for(unsigned int j=0; j<eventMcSelected.size(); ++j)
if(eventMcSelected[j]) {
numTotHltBitsAfterMcCuts[j][i]++;
hHltBitsAfterMcCuts[j]->Fill(i);
hHltPathsAfterMcCuts[j]->Fill(i);
}
}
}
}

//Calculate the overlap among HLT paths
for(unsigned int i=0; i< trhv->size(); i++) {
for(unsigned int j=0; j< trhv->size(); j++) {
// cout << "trhv->size() = " << trhv->size() << endl;
// cout << "hltbits["<< i << "] = " << hltbits[i] << endl;
// cout << "hltbits["<< j << "] = " << hltbits[j] << endl;
if(hltbits[i]*hltbits[j]) vCorrHlt[i][j]++;
}
}


//The overlap histos are filled in the endJob() method
for(unsigned int i=0; i< hlNames_.size(); i++) {
for(unsigned int j=0; j< hlNames_.size(); j++) {
if(hltbits[i]*hltbits[j]) vCorrHlt[i][j]++;
}
}

//fill the last bin with the total of events
numTotHltBitsBeforeCuts[trhv->size()]++;
hHltBitsBeforeCuts->Fill(trhv->size());
hHltPathsBeforeCuts->Fill(trhv->size());
numTotHltBitsBeforeCuts[hlNames_.size()]++;
hHltBitsBeforeCuts->Fill(hlNames_.size());
hHltPathsBeforeCuts->Fill(hlNames_.size());
for(unsigned int i=0; i<eventRecoSelected.size(); ++i)
if(eventRecoSelected[i]) {
numTotHltBitsAfterRecoCuts[i][trhv->size()]++;
hHltBitsAfterRecoCuts[i]->Fill(trhv->size());
hHltPathsAfterRecoCuts[i]->Fill(trhv->size());
numTotHltBitsAfterRecoCuts[i][hlNames_.size()]++;
hHltBitsAfterRecoCuts[i]->Fill(hlNames_.size());
hHltPathsAfterRecoCuts[i]->Fill(hlNames_.size());
}
for(unsigned int i=0; i<eventMcSelected.size(); ++i)
if(eventMcSelected[i]) {
numTotHltBitsAfterMcCuts[i][trhv->size()]++;
hHltBitsAfterMcCuts[i]->Fill(trhv->size());
hHltPathsAfterMcCuts[i]->Fill(trhv->size());
numTotHltBitsAfterMcCuts[i][hlNames_.size()]++;
hHltBitsAfterMcCuts[i]->Fill(hlNames_.size());
hHltPathsAfterMcCuts[i]->Fill(hlNames_.size());
}


Expand Down Expand Up @@ -409,51 +381,36 @@ void TriggerValidator::beginRun(const edm::Run& run, const edm::EventSetup& c)
dbe_->setCurrentFolder(dirname_);
}


bool changed(true);
// cout << "hltConfig_.init(run,c,processName_,changed) = " << (int) hltConfig_.init(run,c,processName_,changed) << endl;
// cout << "changed = " << (int) changed << endl;
if (hltConfig_.init(run,c,processName_,changed)) {
// cout << "AAAA" << endl;
if (changed) {
// cout << "BBBBBBB" << endl;
// check if trigger name in (new) config
if (triggerName_!="@") { // "@" means: analyze all triggers in config
// cout << "hltConfig_.size() = " << hltConfig_.size() << endl;
nHltPaths = hltConfig_.size();
const unsigned int triggerIndex(hltConfig_.triggerIndex(triggerName_));
if (triggerIndex>=nHltPaths) {
// cout << "HLTriggerOffline/SUSYBSM"
// << " TriggerName " << triggerName_
// << " not available in (new) config!" << endl;
// cout << "Available TriggerNames are: " << endl;
hltConfig_.dump("Triggers");
}
}
else {
// cout << "CCCCCCCC" << endl;
nHltPaths = hltConfig_.size();
}
}
} else {
// cout << "HLTriggerOffline/SUSYBSM"
// << " config extraction failure with process name "
// << processName_ << endl;
// Initialize hltConfig
bool changed;
if (!hltConfig_.init(run,c,processName_,changed)) {
LogError("SUSYBSM") << "Initialization of HLTConfigProvider failed!!";
return;
}


// Get the set of trigger paths we want to make plots for
for (size_t i = 0; i < hltPathsToCheck_.size(); i++) {
TPRegexp pattern(hltPathsToCheck_[i]);
for (size_t j = 0; j < hltConfig_.triggerNames().size(); j++)
if (TString(hltConfig_.triggerNames()[j]).Contains(pattern))
hlNames_.push_back(hltConfig_.triggerNames()[j]);
}
hlNames_.push_back("Total");
nHltPaths = hlNames_.size();

// cout << "nHltPaths = " << nHltPaths << endl;
nL1Bits = 128;

firstEvent = true;

//resize the vectors ccording to the number of L1 paths
//resize the vectors according to the number of L1 paths
numTotL1BitsBeforeCuts.resize(nL1Bits+1);
numTotL1BitsAfterRecoCuts.resize(reco_parametersets.size());
for(unsigned int i=0; i<numTotL1BitsAfterRecoCuts.size(); ++i) numTotL1BitsAfterRecoCuts[i].resize(nL1Bits+1);
numTotL1BitsAfterMcCuts.resize(mc_parametersets.size());
for(unsigned int i=0; i<numTotL1BitsAfterMcCuts.size(); ++i) numTotL1BitsAfterMcCuts[i].resize(nL1Bits+1);

//resize the vectors ccording to the number of HLT paths
//resize the vectors according to the number of HLT paths
numTotHltBitsBeforeCuts.resize(nHltPaths+1);
numTotHltBitsAfterRecoCuts.resize(reco_parametersets.size());
for(unsigned int i=0; i<numTotHltBitsAfterRecoCuts.size(); ++i) numTotHltBitsAfterRecoCuts[i].resize(nHltPaths+1);
Expand All @@ -474,10 +431,6 @@ void TriggerValidator::beginRun(const edm::Run& run, const edm::EventSetup& c)
//add 1 bin for the Total
hL1BitsBeforeCuts = dbe_->book1D("L1Bits", "L1 Trigger Bits",nL1Bits+1, 0, nL1Bits+1);
hHltBitsBeforeCuts = dbe_->book1D("HltBits","HL Trigger Bits",nHltPaths+1, 0, nHltPaths+1);
// hL1OverlapNormToTotal = dbe_->book2D("L1OverlapNormToTotal" ,"Overlap among L1 paths, norm to the Total number of Events", 1, 0, 1, 1, 0, 1);
// hHltOverlapNormToTotal = dbe_->book2D("HltOverlapNormToTotal" ,"Overlap among Hlt paths, norm to the Total number of Events ", 1, 0, 1, 1, 0, 1);
// hL1OverlapNormToLargestPath = dbe_->book2D("L1OverlapNormToLargestPath" ,"Overlap among L1 paths, norm to the Largest of the couple ", 1, 0, 1, 1, 0, 1);
// hHltOverlapNormToLargestPath = dbe_->book2D("HltOverlapNormToLargestPath","Overlap among Hlt paths, norm to the Largest of the couple ", 1, 0, 1, 1, 0, 1);

for(unsigned int i=0; i<myRecoSelector.size(); ++i)
{
Expand Down Expand Up @@ -516,20 +469,17 @@ void TriggerValidator::beginRun(const edm::Run& run, const edm::EventSetup& c)
dbe_->setCurrentFolder(dirname_+triggerBitsDir);
TH1F* hTemp = (TH1F*) (hL1BitsBeforeCuts->getTH1F())->Clone("L1Paths");
hL1PathsBeforeCuts = dbe_->book1D("L1Paths", hTemp);
// hL1PathsBeforeCuts = dbe_->book1D("L1Paths", hL1BitsBeforeCuts->getTH1F());
hTemp = (TH1F*) (hHltBitsBeforeCuts->getTH1F())->Clone("HltPaths");
hHltPathsBeforeCuts = dbe_->book1D("HltPaths", hTemp);

for(unsigned int i=0; i<myRecoSelector.size(); ++i)
{
string path_name = myRecoSelector[i]->GetName();
char histo_name[256];
//sprintf(histo_name, "L1Paths");
sprintf(histo_name, "L1Paths_%s", path_name.c_str());
dbe_->setCurrentFolder(dirname_+recoSelBitsDir+"/"+path_name);
hTemp = (TH1F*) (hL1BitsAfterRecoCuts[i]->getTH1F())->Clone(histo_name);
hL1PathsAfterRecoCuts.push_back(dbe_->book1D(histo_name, hTemp));
//sprintf(histo_name, "HltPaths");
sprintf(histo_name, "HltPaths_%s", path_name.c_str());
hTemp = (TH1F*) (hHltBitsAfterRecoCuts[i]->getTH1F())->Clone(histo_name);
hHltPathsAfterRecoCuts.push_back(dbe_->book1D(histo_name, hTemp));
Expand All @@ -539,12 +489,10 @@ void TriggerValidator::beginRun(const edm::Run& run, const edm::EventSetup& c)
{
string path_name = myMcSelector[i]->GetName();
char histo_name[256];
//sprintf(histo_name, "L1Paths");
sprintf(histo_name, "L1Paths_%s", path_name.c_str());
dbe_->setCurrentFolder(dirname_+mcSelBitsDir+"/"+path_name);
hTemp = (TH1F*) (hL1BitsAfterMcCuts[i]->getTH1F())->Clone(histo_name);
hL1PathsAfterMcCuts.push_back(dbe_->book1D(histo_name, hTemp));
//sprintf(histo_name, "HltPaths");
sprintf(histo_name, "HltPaths_%s", path_name.c_str());
hTemp = (TH1F*) (hHltBitsAfterMcCuts[i]->getTH1F())->Clone(histo_name);
hHltPathsAfterMcCuts.push_back(dbe_->book1D(histo_name, hTemp));
Expand Down