Skip to content

Commit

Permalink
updates for miniAOD_v2
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomoortona committed Nov 9, 2015
1 parent 4e26541 commit 96312fa
Show file tree
Hide file tree
Showing 4 changed files with 188 additions and 6 deletions.
79 changes: 76 additions & 3 deletions NtupleProducer/plugins/HTauTauNtuplizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ class HTauTauNtuplizer : public edm::EDAnalyzer {

// reco leptons
//std::vector<TLorentzVector> _daughters;
std::vector<string> _trigger_name;
std::vector<Int_t> _trigger_accept;
std::vector<Float_t> _daughters_px;
std::vector<Float_t> _daughters_py;
std::vector<Float_t> _daughters_pz;
Expand Down Expand Up @@ -250,6 +252,7 @@ class HTauTauNtuplizer : public edm::EDAnalyzer {
//Mothers output variables
std::vector<Int_t> _indexDau1;
std::vector<Int_t> _indexDau2;
std::vector<Float_t> _daughters_HLTpt;
//std::vector<Int_t> _genDaughters;
std::vector<Bool_t> _isOSCand;
std::vector<Float_t> _SVmass;
Expand Down Expand Up @@ -297,6 +300,28 @@ class HTauTauNtuplizer : public edm::EDAnalyzer {
std::vector<Float_t> _daughters_depositR03_ecal;
std::vector<Float_t> _daughters_depositR03_hcal;
std::vector<Int_t> _daughters_decayModeFindingOldDMs;
/*std::vector<Float_t> _daughters_againstElectronMVA5category;
std::vector<Float_t> _daughters_againstElectronMVA5raw;
std::vector<Int_t> _daughters_byLooseIsolationMVA3newDMwLT;
std::vector<Int_t> _daughters_byLooseIsolationMVA3oldDMwLT;
std::vector<Int_t> _daughters_byLoosePileupWeightedIsolation3Hits;
std::vector<Int_t> _daughters_byMediumIsolationMVA3newDMwLT;
std::vector<Int_t> _daughters_byMediumIsolationMVA3oldDMwLT;
std::vector<Int_t> _daughters_byMediumPileupWeightedIsolation3Hits;
std::vector<Int_t> _daughters_byPhotonPtSumOutsideSignalCone;
std::vector<Float_t> _daughters_byPileupWeightedIsolationRaw3Hits;
std::vector<Int_t> _daughters_byTightIsolationMVA3newDMwLT;
std::vector<Int_t> _daughters_byTightIsolationMVA3oldDMwLT;
std::vector<Int_t> _daughters_byTightPileupWeightedIsolation3Hits;
std::vector<Int_t> _daughters_byVLooseIsolationMVA3newDMwLT;
std::vector<Int_t> _daughters_byVLooseIsolationMVA3oldDMwLT;
std::vector<Int_t> _daughters_byVTightIsolationMVA3newDMwLT;
std::vector<Int_t> _daughters_byVTightIsolationMVA3oldDMwLT;
std::vector<Int_t> _daughters_byVVTightIsolationMVA3newDMwLT;
std::vector<Int_t> _daughters_byVVTightIsolationMVA3oldDMwLT;
std::vector<Float_t> _daughters_footprintCorrection;
std::vector<Float_t> _daughters_neutralIsoPtSumWeight;
std::vector<Float_t> _daughters_photonPtSumOutsideSignalCone;*/
std::vector<Int_t> _daughters_decayModeFindingNewDMs;
std::vector<Int_t> _daughters_byLooseCombinedIsolationDeltaBetaCorr3Hits;
std::vector<Int_t> _daughters_byMediumCombinedIsolationDeltaBetaCorr3Hits;
Expand Down Expand Up @@ -424,6 +449,8 @@ void HTauTauNtuplizer::Initialize(){
_mothers_e.clear();

//_daughters.clear();
_trigger_name.clear();
_trigger_accept.clear();
_daughters_px.clear();
_daughters_py.clear();
_daughters_pz.clear();
Expand All @@ -445,6 +472,28 @@ void HTauTauNtuplizer::Initialize(){
_daughters_byIsolationMVA3oldDMwoLTraw.clear();
_daughters_byIsolationMVA3oldDMwLTraw.clear();
_daughters_byIsolationMVA3newDMwoLTraw.clear();
/*_daughters_againstElectronMVA5category.clear();
_daughters_againstElectronMVA5raw.clear();
_daughters_byLooseIsolationMVA3newDMwLT.clear();
_daughters_byLooseIsolationMVA3oldDMwLT.clear();
_daughters_byLoosePileupWeightedIsolation3Hits.clear();
_daughters_byMediumIsolationMVA3newDMwLT.clear();
_daughters_byMediumIsolationMVA3oldDMwLT.clear();
_daughters_byMediumPileupWeightedIsolation3Hits.clear();
_daughters_byPhotonPtSumOutsideSignalCone.clear();
_daughters_byPileupWeightedIsolationRaw3Hits.clear();
_daughters_byTightIsolationMVA3newDMwLT.clear();
_daughters_byTightIsolationMVA3oldDMwLT.clear();
_daughters_byTightPileupWeightedIsolation3Hits.clear();
_daughters_byVLooseIsolationMVA3newDMwLT.clear();
_daughters_byVLooseIsolationMVA3oldDMwLT.clear();
_daughters_byVTightIsolationMVA3newDMwLT.clear();
_daughters_byVTightIsolationMVA3oldDMwLT.clear();
_daughters_byVVTightIsolationMVA3newDMwLT.clear();
_daughters_byVVTightIsolationMVA3oldDMwLT.clear();
_daughters_footprintCorrection.clear();
_daughters_neutralIsoPtSumWeight.clear();
_daughters_photonPtSumOutsideSignalCone.clear();*/
_daughters_byIsolationMVA3newDMwLTraw.clear();
_daughters_chargedIsoPtSum.clear();
_daughters_neutralIsoPtSum.clear();
Expand Down Expand Up @@ -531,6 +580,7 @@ void HTauTauNtuplizer::Initialize(){
_SVMetRho.clear();
_SVMetPhi.clear();
_isOSCand.clear();
_daughters_HLTpt.clear();
_metx.clear();
_mety.clear();
_metCov00.clear();
Expand Down Expand Up @@ -607,7 +657,8 @@ void HTauTauNtuplizer::beginJob(){
myTree->Branch("mothers_py",&_mothers_py);
myTree->Branch("mothers_pz",&_mothers_pz);
myTree->Branch("mothers_e",&_mothers_e);

myTree->Branch("trigger_name",&_trigger_name);
myTree->Branch("trigger_accept",&_trigger_accept);
myTree->Branch("daughters_px",&_daughters_px);
myTree->Branch("daughters_py",&_daughters_py);
myTree->Branch("daughters_pz",&_daughters_pz);
Expand All @@ -627,7 +678,6 @@ void HTauTauNtuplizer::beginJob(){
//myTree->Branch("genH_py",&_genH_py);
//myTree->Branch("genH_pz",&_genH_pz);
//myTree->Branch("genH_e",&_genH_e);

myTree->Branch("daughters_genindex",&_daughters_genindex);
myTree->Branch("MC_weight",&_MC_weight,"MC_weight/F");
myTree->Branch("aMCatNLOweight",&_aMCatNLOweight,"aMCatNLOweight/F");
Expand Down Expand Up @@ -742,6 +792,7 @@ void HTauTauNtuplizer::beginJob(){
myTree->Branch("daughters_isGoodTriggerType",&_daughters_isGoodTriggerType);
myTree->Branch("daughters_L3FilterFired",&_daughters_L3FilterFired);
myTree->Branch("daughters_L3FilterFiredLast",&_daughters_L3FilterFiredLast);
myTree->Branch("daughters_HLTpt",&_daughters_HLTpt);

myTree->Branch("JetsNumber",&_numberOfJets,"JetsNumber/I");
myTree->Branch("jets_px",&_jets_px);
Expand Down Expand Up @@ -786,7 +837,7 @@ void HTauTauNtuplizer::analyze(const edm::Event& event, const edm::EventSetup& e
// std::vector<const reco::Candidate *> genZLeps;
if (theisMC) {
Handle<std::vector< PileupSummaryInfo > > PupInfo;
event.getByLabel(edm::InputTag("addPileupInfo"), PupInfo);
event.getByLabel(edm::InputTag("slimmedAddPileupInfo"), PupInfo);
std::vector<PileupSummaryInfo>::const_iterator PVI;
for(PVI = PupInfo->begin(); PVI != PupInfo->end(); ++PVI) {
if(PVI->getBunchCrossing() == 0) {
Expand All @@ -799,6 +850,17 @@ void HTauTauNtuplizer::analyze(const edm::Event& event, const edm::EventSetup& e
}
}
}

edm::Handle<edm::TriggerResults> triggerBits;

event.getByToken(triggerBits_, triggerBits);
const edm::TriggerNames &names = event.triggerNames(*triggerBits);

for (unsigned int i = 0, n = triggerBits->size(); i < n; ++i) {
_trigger_name.push_back( (string) names.triggerName(i));
_trigger_accept.push_back( (int) triggerBits->accept(i));
}


_triggerbit = myTriggerHelper->FindTriggerBit(event,foundPaths,indexOfPath);
_metfilterbit = myTriggerHelper->FindMETBit(event);
Expand Down Expand Up @@ -1293,6 +1355,7 @@ void HTauTauNtuplizer::FillSoftLeptons(const edm::View<reco::Candidate> *daus, c
//TRIGGER MATCHING
int LFtriggerbit=0,L3triggerbit=0,filterFired=0;
int triggertypeIsGood = 0;
float hltpt=0;
for (pat::TriggerObjectStandAlone obj : *triggerObjects) {
//check if the trigger object matches cand
//bool matchCand = false;
Expand All @@ -1310,6 +1373,10 @@ void HTauTauNtuplizer::FillSoftLeptons(const edm::View<reco::Candidate> *daus, c
for (unsigned h = 0, n = pathNamesAll.size(); h < n; ++h) {
bool isLF = obj.hasPathName( pathNamesAll[h], true, false );
bool isL3 = obj.hasPathName( pathNamesAll[h], false, true );
if (type==ParticleType::MUON && obj.hasFilterLabel("hltL3crIsoL1sSingleMu16erL1f0L2f10QL3f17QL3trkIsoFiltered0p09") && (obj.hasPathName("HLT_IsoMu17_eta2p1_v1", false, true ) or obj.hasPathName("HLT_IsoMu17_eta2p1_v1", true, false )))
hltpt = (float) obj.pt();
if (type==ParticleType::ELECTRON && obj.hasFilterLabel("hltSingleEle22WP75GsfTrackIsoFilter") && (obj.hasPathName("HLT_Ele22_eta2p1_WP75_Gsf_v1", false, true ) or obj.hasPathName("HLT_Ele22_eta2p1_WP75_Gsf_v1", true, false )))
hltpt = (float) obj.pt();
int triggerbit = myTriggerHelper->FindTriggerNumber(pathNamesAll[h],true);

/*
Expand Down Expand Up @@ -1356,6 +1423,7 @@ void HTauTauNtuplizer::FillSoftLeptons(const edm::View<reco::Candidate> *daus, c
_daughters_FilterFired.push_back(filterFired);
_daughters_L3FilterFired.push_back(LFtriggerbit);
_daughters_L3FilterFiredLast.push_back(L3triggerbit);
_daughters_HLTpt.push_back(hltpt);
}
}

Expand Down Expand Up @@ -1671,8 +1739,11 @@ bool HTauTauNtuplizer::ComparePairsbyIso(pat::CompositeCandidate i, pat::Composi
else cand1j=1;

//step 1, l;eg 1 ISO
//byCombinedIsolationDeltaBetaCorrRaw3Hits
isoi=userdatahelpers::getUserFloat(i.daughter(cand1i),"combRelIsoPF");
isoj=userdatahelpers::getUserFloat(j.daughter(cand1j),"combRelIsoPF");
if (!i.daughter(cand1i)->isMuon() && !i.daughter(cand1i)->isElectron()) isoi=userdatahelpers::getUserFloat(i.daughter(cand1i),"byCombinedIsolationDeltaBetaCorrRaw3Hits");
if (!j.daughter(cand1j)->isMuon() && !j.daughter(cand1j)->isElectron()) isoj=userdatahelpers::getUserFloat(j.daughter(cand1j),"byCombinedIsolationDeltaBetaCorrRaw3Hits");

if (isoi<isoj)return true;
else if(isoi>isoj)return false;
Expand All @@ -1684,6 +1755,8 @@ bool HTauTauNtuplizer::ComparePairsbyIso(pat::CompositeCandidate i, pat::Composi
//step 3, leg 2 ISO
isoi=userdatahelpers::getUserFloat(i.daughter(1-cand1i),"combRelIsoPF");
isoj=userdatahelpers::getUserFloat(j.daughter(1-cand1j),"combRelIsoPF");
if (!i.daughter(1-cand1i)->isMuon() && !i.daughter(1-cand1i)->isElectron()) isoi=userdatahelpers::getUserFloat(i.daughter(1-cand1i),"byCombinedIsolationDeltaBetaCorrRaw3Hits");
if (!j.daughter(1-cand1j)->isMuon() && !j.daughter(1-cand1j)->isElectron()) isoj=userdatahelpers::getUserFloat(j.daughter(1-cand1j),"byCombinedIsolationDeltaBetaCorrRaw3Hits");

if (isoi<isoj)return true;
else if(isoi>isoj)return false;
Expand Down
44 changes: 44 additions & 0 deletions NtupleProducer/plugins/TauFiller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,50 @@ TauFiller::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
l.addUserFloat("byIsolationMVA3oldDMwLTraw",l.tauID("byIsolationMVA3oldDMwLTraw"));
if (l.isTauIDAvailable("byIsolationMVA3newDMwoLTraw")) l.addUserFloat("byIsolationMVA3newDMwoLTraw",l.tauID("byIsolationMVA3newDMwoLTraw"));
else l.addUserFloat("byIsolationMVA3newDMwoLTraw",-999.);
if (l.isTauIDAvailable("againstElectronMVA5category")) l.addUserInt("againstElectronMVA5category",l.tauID("againstElectronMVA5category"));
else l.addUserInt("againstElectronMVA5category",0);
if (l.isTauIDAvailable("againstElectronMVA5raw")) l.addUserFloat("againstElectronMVA5raw",l.tauID("againstElectronMVA5raw"));
else l.addUserFloat("againstElectronMVA5raw",-999);
if (l.isTauIDAvailable("byLooseIsolationMVA3newDMwLT")) l.addUserInt("byLooseIsolationMVA3newDMwLT",l.tauID("byLooseIsolationMVA3newDMwLT"));
else l.addUserInt("byLooseIsolationMVA3newDMwLT",0);
if (l.isTauIDAvailable("byLooseIsolationMVA3oldDMwLT")) l.addUserInt("byLooseIsolationMVA3oldDMwLT",l.tauID("byLooseIsolationMVA3oldDMwLT"));
else l.addUserFloat("byLooseIsolationMVA3oldDMwLT",0);
if (l.isTauIDAvailable("byLoosePileupWeightedIsolation3Hits")) l.addUserInt("byLoosePileupWeightedIsolation3Hits",l.tauID("byLoosePileupWeightedIsolation3Hits"));
else l.addUserInt("byLoosePileupWeightedIsolation3Hits",0);
if (l.isTauIDAvailable("byMediumIsolationMVA3newDMwLT")) l.addUserInt("byMediumIsolationMVA3newDMwLT",l.tauID("byMediumIsolationMVA3newDMwLT"));
else l.addUserInt("byMediumIsolationMVA3newDMwLT",0);
if (l.isTauIDAvailable("byMediumIsolationMVA3oldDMwLT")) l.addUserInt("byMediumIsolationMVA3oldDMwLT",l.tauID("byMediumIsolationMVA3oldDMwLT"));
else l.addUserInt("byMediumIsolationMVA3oldDMwLT",0);
if (l.isTauIDAvailable("byMediumPileupWeightedIsolation3Hits")) l.addUserInt("byMediumPileupWeightedIsolation3Hits",l.tauID("byMediumPileupWeightedIsolation3Hits"));
else l.addUserInt("byMediumPileupWeightedIsolation3Hits",0);
if (l.isTauIDAvailable("byPhotonPtSumOutsideSignalCone")) l.addUserFloat("byPhotonPtSumOutsideSignalCone",l.tauID("byPhotonPtSumOutsideSignalCone"));
else l.addUserFloat("byPhotonPtSumOutsideSignalCone",-999);
if (l.isTauIDAvailable("byPileupWeightedIsolationRaw3Hits")) l.addUserFloat("byPileupWeightedIsolationRaw3Hits",l.tauID("byPileupWeightedIsolationRaw3Hits"));
else l.addUserFloat("byPileupWeightedIsolationRaw3Hits",-999);
if (l.isTauIDAvailable("byTightIsolationMVA3newDMwLT")) l.addUserInt("byTightIsolationMVA3newDMwLT",l.tauID("byTightIsolationMVA3newDMwLT"));
else l.addUserInt("byTightIsolationMVA3newDMwLT",-999);
if (l.isTauIDAvailable("byTightIsolationMVA3oldDMwLT")) l.addUserInt("byTightIsolationMVA3oldDMwLT",l.tauID("byTightIsolationMVA3oldDMwLT"));
else l.addUserInt("byTightIsolationMVA3oldDMwLT",-999);
if (l.isTauIDAvailable("byTightPileupWeightedIsolation3Hits")) l.addUserInt("byTightPileupWeightedIsolation3Hits",l.tauID("byTightPileupWeightedIsolation3Hits"));
else l.addUserInt("byTightPileupWeightedIsolation3Hits",-999);
if (l.isTauIDAvailable("byVLooseIsolationMVA3newDMwLT")) l.addUserInt("byVLooseIsolationMVA3newDMwLT",l.tauID("byVLooseIsolationMVA3newDMwLT"));
else l.addUserInt("byVLooseIsolationMVA3newDMwLT",0);
if (l.isTauIDAvailable("byVLooseIsolationMVA3oldDMwLT")) l.addUserInt("byVLooseIsolationMVA3oldDMwLT",l.tauID("byVLooseIsolationMVA3oldDMwLT"));
else l.addUserInt("byVLooseIsolationMVA3oldDMwLT",0);
if (l.isTauIDAvailable("byVTightIsolationMVA3newDMwLT")) l.addUserInt("byVTightIsolationMVA3newDMwLT",l.tauID("byVTightIsolationMVA3newDMwLT"));
else l.addUserInt("byVTightIsolationMVA3newDMwLT",0);
if (l.isTauIDAvailable("byVTightIsolationMVA3oldDMwLT")) l.addUserInt("byVTightIsolationMVA3oldDMwLT",l.tauID("byVTightIsolationMVA3oldDMwLT"));
else l.addUserInt("byVTightIsolationMVA3oldDMwLT",0);
if (l.isTauIDAvailable("byVVTightIsolationMVA3newDMwLT")) l.addUserInt("byVVTightIsolationMVA3newDMwLT",l.tauID("byVVTightIsolationMVA3newDMwLT"));
else l.addUserInt("byVVTightIsolationMVA3newDMwLT",0);
if (l.isTauIDAvailable("byVVTightIsolationMVA3oldDMwLT")) l.addUserInt("byVVTightIsolationMVA3oldDMwLT",l.tauID("byVVTightIsolationMVA3oldDMwLT"));
else l.addUserFloat("byVVTightIsolationMVA3oldDMwLT",0);
if (l.isTauIDAvailable("footprintCorrection")) l.addUserFloat("footprintCorrection",l.tauID("footprintCorrection"));
else l.addUserFloat("footprintCorrection",-999);
if (l.isTauIDAvailable("neutralIsoPtSumWeight")) l.addUserFloat("neutralIsoPtSumWeight",l.tauID("neutralIsoPtSumWeight"));
else l.addUserFloat("neutralIsoPtSumWeight",-999);
if (l.isTauIDAvailable("photonPtSumOutsideSignalCone")) l.addUserFloat("photonPtSumOutsideSignalCone",l.tauID("photonPtSumOutsideSignalCone"));
else l.addUserFloat("photonPtSumOutsideSignalCone",-999);
l.addUserFloat("byIsolationMVA3newDMwLTraw",l.tauID("byIsolationMVA3newDMwLTraw"));
l.addUserFloat("chargedIsoPtSum", chargedIsoPtSum);
l.addUserFloat("neutralIsoPtSum", neutralIsoPtSum);
Expand Down
1 change: 1 addition & 0 deletions NtupleProducer/python/HiggsTauTauProducer.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#process.GlobalTag.globaltag = 'PLS170_V6AN1::All'#'GR_70_V2_AN1::All' #MC in 70X, cf https://twiki.cern.ch/twiki/bin/view/CMS/MiniAOD
#process.GlobalTag.globaltag = 'PHYS14_25_V1::All' #MC in PHYS14
process.GlobalTag.globaltag = 'MCRUN2_74_V9::All' #MC Spring 2015
#process.GlobalTag.globaltag = '74X_mcRun2_asymptotic_v2::All' #MC 25 ns miniAODv2
#process.GlobalTag.globaltag = 'PHYS14_ST_V1::All'
else :
process.GlobalTag.globaltag = 'GR_70_V2_AN1::All' # data in 70X, cf https://twiki.cern.ch/twiki/bin/view/CMS/MiniAOD
Expand Down
Loading

1 comment on commit 96312fa

@l-cadamuro
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of questions about the updates:

  • the tau discriminators stored as userfloats are not saved in the ntuples, we must add the corresponding branches (some are already existing but were commented out)
  • do we know which is the impact on the memory to save for each event the trigger name as a string? I think it would be sizeable. As the information is already stored in the output histogram I think we can remove this branch. The same for trigger_accept (unless it is very useful...)
  • does anybody know what are the filter names hardcoded around line 1376?

Please sign in to comment.