void IsoMuonProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup){ auto mu_pt = make_auto(new std::vector<float>); auto mu_phi = make_auto(new std::vector<float>); auto mu_eta = make_auto(new std::vector<float>); auto mu_iso = make_auto(new std::vector<float>); edm::Handle<edm::ValueMap<double> > iso_handle; edm::Handle<std::vector<reco::RecoChargedCandidate> > muon_handle; iEvent.getByToken(iso_token_, iso_handle); iEvent.getByToken(cand_token_, muon_handle); for(auto it = iso_handle->begin(); it != iso_handle->end(); ++it){ for(auto ite = it.begin(); ite != it.end(); ++ite){ mu_iso->push_back(*ite); } } for(auto it = muon_handle->begin(); it != muon_handle->end(); ++it){ mu_pt->push_back(it->pt()); mu_phi->push_back(it->phi()); mu_eta->push_back(it->eta()); } iEvent.put(mu_pt, "mupt"); iEvent.put(mu_phi, "muphi"); iEvent.put(mu_eta, "mueta"); iEvent.put(mu_iso, "muiso"); }
int NeroPF::analyze(const edm::Event& iEvent) { iEvent.getByToken( token , handle); if ( not handle.isValid() ) cout<<"[NeroPF]::[analyze]::[ERROR] handle is not valid"<<endl; return 0; }
int NeroPuppiJets::analyze(const edm::Event& iEvent, const edm::EventSetup &iSetup){ if ( mOnlyMc ) return 0; // maybe handle should be taken before iEvent.getByToken(token, handle); if ( not handle.isValid() ) cout<<"[NeroPuppiJets]::[analyze]::[ERROR] handle is not valid"<<endl; for (const pat::Jet& j : *handle) { if (j.pt() < mMinPt ) continue; if ( fabs(j.eta()) > mMinEta ) continue; if ( !JetId(j,mMinId) ) continue; float charge = 0.; float charge_den = 0.; for( size_t idx =0; idx < j.numberOfDaughters() ; ++idx) { pat::PackedCandidate *cand = ( pat::PackedCandidate* ) j.daughter(idx) ; if (cand->charge() !=0 ) { charge += cand->charge() * cand->puppiWeight() * ( j.px()*cand->px() + j.py()*cand->py() + j.pz()*cand->pz() ) ; charge_den += cand->puppiWeight() * ( j.px()*cand->px() + j.py()*cand->py() + j.pz()*cand->pz() ) ; } } if ( charge_den == 0 ) { charge=0.0 ; charge_den =1.0;} // guard, if no jet id // Fill output object new ( (*p4)[p4->GetEntriesFast()]) TLorentzVector(j.px(), j.py(), j.pz(), j.energy()); rawPt -> push_back (j.pt()*j.jecFactor("Uncorrected")); bDiscr -> push_back( j.bDiscriminator("pfCombinedInclusiveSecondaryVertexV2BJetTags") ); unsigned bits=0; bits |= (1 * JetBaseline); bits |= JetId(j,"monojet") * mjId; bits |= JetId(j,"monojetloose") * mjIdLoose; bits |= JetId(j,"monojet2015") * mjId2015; bits |= JetId(j,"loose") * JetLoose; bits |= JetId(j,"tight") * JetTight; selBits -> push_back( bits); Q -> push_back (charge/charge_den); } if ( int(rawPt -> size()) < mMinNjets ) return 1; return 0; }
int NeroTaus::analyze(const edm::Event & iEvent) { if ( mOnlyMc ) return 0; iEvent.getByToken(token, handle); for (const pat::Tau &tau : *handle) { if (tau.pt() < 18 ) continue; if (tau.pt() < mMinPt ) continue; /// miniaod taus = decayModeFindingNewDMs if ( mMinId != "" and !(tau.tauID(mMinId)) ) continue; // minimum requirement to be saved. if ( mMaxIso >=0 and tau.tauID("byCombinedIsolationDeltaBetaCorrRaw3Hits") >= mMaxIso ) continue; if ( fabs(tau.eta()) > mMinEta ) continue; // ------------ END SELECTION float phoIso = 0.; for(auto cand : tau.isolationGammaCands() ) phoIso += cand->pt();//tau.isolationPFGammaCandsEtSum() ; float chIso = 0.; for(auto cand : tau.isolationChargedHadrCands() ) chIso += cand->pt();//tau.isolationPFChargedHadrCandsPtSum(); float nhIso = 0.; for(auto cand : tau.isolationNeutrHadrCands() ) nhIso += cand->pt(); // PF Cands not exists in miniAOD float totIso = phoIso + chIso + nhIso; //FILL new ( (*p4)[p4->GetEntriesFast()]) TLorentzVector(tau.px(), tau.py(), tau.pz(), tau.energy()); id -> push_back( tau.tauID("decayModeFinding")); Q -> push_back( tau.charge() ); M -> push_back( tau.mass() ); iso -> push_back( totIso ) ; if (IsExtend() ){ chargedIsoPtSum -> push_back( tau.tauID("chargedIsoPtSum") ); neutralIsoPtSum -> push_back( tau.tauID("neutralIsoPtSum") ); isoDeltaBetaCorr -> push_back( tau.tauID("byCombinedIsolationDeltaBetaCorrRaw3Hits")); againstEleLoose -> push_back( tau.tauID("againstElectronLooseMVA5") ); againstEleMedium -> push_back( tau.tauID("againstElectronMediumMVA5") ); againstMuLoose -> push_back( tau.tauID("againstMuonLoose3")); againstMuTight -> push_back( tau.tauID("againstMuonTight3")); } } if( int(id->size()) < mMinNtaus) return 1; return 0; }
int NeroFatJets::analyze(const edm::Event& iEvent){ if ( mOnlyMc ) return 0; // maybe handle should be taken before iEvent.getByToken(token, handle); int ijetRef = -1; int nsubjet = 0; for (const pat::Jet& j : *handle) { ijetRef++; if (j.pt() < 100 ) continue; // JET ID if ( !NeroJets::JetId(j,"loose") ) continue; // GET ValueMaps // Fill output object //p4 -> AddLast(new TLorentzVector(j.px(), j.py(), j.pz(), j.energy()) ); new ( (*p4)[p4->GetEntriesFast()]) TLorentzVector(j.px(), j.py(), j.pz(), j.energy()); rawPt -> push_back (j.pt()*j.jecFactor("Uncorrected")); flavour -> push_back( j.partonFlavour() ); tau1 -> push_back(j.userFloat("NjettinessAK8:tau1")); tau2 -> push_back(j.userFloat("NjettinessAK8:tau2")); tau3 -> push_back(j.userFloat("NjettinessAK8:tau3")); trimmedMass ->push_back(j.userFloat("ak8PFJetsCHSTrimmedMass")); prunedMass ->push_back(j.userFloat("ak8PFJetsCHSPrunedMass")); filteredMass->push_back(j.userFloat("ak8PFJetsCHSFilteredMass")); softdropMass->push_back(j.userFloat("ak8PFJetsCHSSoftDropMass")); ak8jet_hasSubjet->push_back(j.hasSubjets("SoftDrop")); auto Subjets = j.subjets("SoftDrop"); for ( auto const & i : Subjets ) { new ( (*ak8_subjet)[nsubjet]) TLorentzVector(i->px(), i->py(), i->pz(), i->energy()); ak8subjet_btag->push_back(i->bDiscriminator("pfCombinedInclusiveSecondaryVertexV2BJetTags")); nsubjet++; } } return 0; }
int NeroPhotons::analyze(const edm::Event& iEvent){ if ( mOnlyMc ) return 0; // maybe handle should be taken before iEvent.getByToken(token, handle); // ID and ISO iEvent.getByToken(loose_id_token,loose_id); iEvent.getByToken(medium_id_token,medium_id); iEvent.getByToken(tight_id_token,tight_id); iEvent.getByToken(iso_ch_token, iso_ch); iEvent.getByToken(iso_nh_token, iso_nh); iEvent.getByToken(iso_pho_token, iso_pho); int iPho = -1; for (auto &pho : *handle) { ++iPho; if (pho.pt() <15 or pho.chargedHadronIso()/pho.pt() > 0.3) continue; if (fabs(pho.eta()) > mMinEta ) continue; if (pho.pt() < mMinPt) continue; edm::RefToBase<pat::Photon> ref ( edm::Ref< pat::PhotonCollection >(handle, iPho) ) ; float chIso = (*iso_ch) [ref]; float nhIso = (*iso_nh) [ref]; float phIso = (*iso_pho)[ref]; float totIso = chIso + nhIso + phIso; bool isPassLoose = (*loose_id)[ref]; bool isPassMedium = (*medium_id)[ref]; bool isPassTight = (*tight_id)[ref]; if (not isPassLoose) continue; if (mMaxIso >=0 and totIso > mMaxIso) continue; //FILL new ( (*p4)[p4->GetEntriesFast()]) TLorentzVector(pho.px(),pho.py(),pho.pz(),pho.energy()); iso->push_back(totIso); sieie -> push_back( pho. full5x5_sigmaIetaIeta() ); tightid->push_back(isPassTight); mediumid->push_back(isPassMedium); } return 0; }
int NeroTaus::analyze(const edm::Event & iEvent) { if ( mOnlyMc ) return 0; iEvent.getByToken(token, handle); if ( not handle.isValid() ) cout<<"[NeroTaus]::[analyze]::[ERROR] handle is not valid"<<endl; for (const pat::Tau &tau : *handle) { if (tau.pt() < 18 ) continue; if (tau.pt() < mMinPt ) continue; /// miniaod taus = decayModeFindingNewDMs if ( mMinId != "" and !(tau.tauID(mMinId)) ) continue; // minimum requirement to be saved. if ( mMaxIso >=0 and tau.tauID("byCombinedIsolationDeltaBetaCorrRaw3Hits") >= mMaxIso ) continue; if ( fabs(tau.eta()) > mMinEta ) continue; // ------------ END SELECTION float phoIso = 0.; for(auto cand : tau.isolationGammaCands() ) phoIso += cand->pt();//tau.isolationPFGammaCandsEtSum() ; float chIso = 0.; for(auto cand : tau.isolationChargedHadrCands() ) chIso += cand->pt();//tau.isolationPFChargedHadrCandsPtSum(); float nhIso = 0.; for(auto cand : tau.isolationNeutrHadrCands() ) nhIso += cand->pt(); // PF Cands not exists in miniAOD float totIso = phoIso + chIso + nhIso; //FILL new ( (*p4)[p4->GetEntriesFast()]) TLorentzVector(tau.px(), tau.py(), tau.pz(), tau.energy()); unsigned bits = 0; bits |= bool(tau.tauID("decayModeFindingNewDMs") ) * TauDecayModeFindingNewDMs; bits |= bool(tau.tauID("decayModeFinding") ) * TauDecayModeFinding; bits |= bool(tau.tauID("againstElectronLooseMVA6") )* AgainstEleLoose ; // FIXME 76 MVA 6 bits |= bool(tau.tauID("againstElectronMediumMVA6"))* AgainstEleMedium ; bits |= bool(tau.tauID("againstMuonLoose3")) * AgainstMuLoose ; bits |= bool(tau.tauID("againstMuonTight3")) * AgainstMuTight ; // old id the following only in 76 v2 bits |= bool(tau.tauID("byLooseIsolationMVArun2v1DBoldDMwLT")) * byLooseIsolationMVArun2v1DBoldDMwLT; bits |= bool(tau.tauID("byMediumIsolationMVArun2v1DBoldDMwLT")) * byMediumIsolationMVArun2v1DBoldDMwLT; bits |= bool(tau.tauID("byTightIsolationMVArun2v1DBoldDMwLT")) * byTightIsolationMVArun2v1DBoldDMwLT; bits |= bool(tau.tauID("byVTightIsolationMVArun2v1DBoldDMwLT")) * byVTightIsolationMVArun2v1DBoldDMwLT; // new id bits |= bool(tau.tauID("byLooseIsolationMVArun2v1DBnewDMwLT")) * byLooseIsolationMVArun2v1DBnewDMwLT; bits |= bool(tau.tauID("byMediumIsolationMVArun2v1DBnewDMwLT")) * byMediumIsolationMVArun2v1DBnewDMwLT; bits |= bool(tau.tauID("byTightIsolationMVArun2v1DBnewDMwLT")) * byTightIsolationMVArun2v1DBnewDMwLT; bits |= bool(tau.tauID("byVTightIsolationMVArun2v1DBnewDMwLT")) * byVTightIsolationMVArun2v1DBnewDMwLT; // DB ISO WP bits |= bool(tau.tauID("byLooseCombinedIsolationDeltaBetaCorr3Hits")) * byLooseCombinedIsolationDeltaBetaCorr3Hits; bits |= bool(tau.tauID("byMediumCombinedIsolationDeltaBetaCorr3Hits")) * byMediumCombinedIsolationDeltaBetaCorr3Hits; bits |= bool(tau.tauID("byTightCombinedIsolationDeltaBetaCorr3Hits")) * byTightCombinedIsolationDeltaBetaCorr3Hits; switch (tau.decayMode() ) { case reco::PFTau::kOneProng0PiZero : { bits |= OneProng; bits |= ZeroPiZero; break; } case reco::PFTau::kOneProng1PiZero : { bits |= OneProng; bits |= OnePiZero; break; } case reco::PFTau::kOneProng2PiZero : { bits |= OneProng; bits |= TwoPiZero; break; } case reco::PFTau::kOneProng3PiZero : { bits |= OneProng; bits |= ThreePiZero; break; } case reco::PFTau::kOneProngNPiZero : { bits |= OneProng; bits |= ThreePiZero; break; } case reco::PFTau::kTwoProng0PiZero : { bits |= TwoProng; bits |= ZeroPiZero; break; } case reco::PFTau::kTwoProng1PiZero : { bits |= TwoProng; bits |= OnePiZero; break; } case reco::PFTau::kTwoProng2PiZero : { bits |= TwoProng; bits |= TwoPiZero; break; } case reco::PFTau::kTwoProng3PiZero : { bits |= TwoProng; bits |= ThreePiZero; break; } case reco::PFTau::kTwoProngNPiZero : { bits |= TwoProng; // three or moreY bits |= ThreePiZero; break; } case reco::PFTau::kThreeProng0PiZero : { bits |= ThreeProng; bits |= ZeroPiZero; break; } case reco::PFTau::kThreeProng1PiZero : { bits |= ThreeProng; bits |= OnePiZero; break; } case reco::PFTau::kThreeProng2PiZero : { bits |= ThreeProng; bits |= TwoPiZero; break; } case reco::PFTau::kThreeProng3PiZero : { bits |= ThreeProng; bits |= ThreePiZero; break; } case reco::PFTau::kThreeProngNPiZero : { bits |= ThreeProng; // three or moreY bits |= ThreePiZero; break; } case reco::PFTau::kNull : { break; } case reco::PFTau::kRareDecayMode : { break; } } selBits -> push_back(bits); Q -> push_back( tau.charge() ); M -> push_back( tau.mass() ); iso -> push_back( totIso ) ; if (IsExtend() ) { chargedIsoPtSum -> push_back( tau.tauID("chargedIsoPtSum") ); neutralIsoPtSum -> push_back( tau.tauID("neutralIsoPtSum") ); isoDeltaBetaCorr -> push_back( tau.tauID("byCombinedIsolationDeltaBetaCorrRaw3Hits")); //isoPileupWeightedRaw -> push_back( tau.tauID("byPileupWeightedIsolationRaw3Hits")); // not in 80X isoMva -> push_back(tau.tauID("byIsolationMVArun2v1DBnewDMwLTraw") ); } } if( int(selBits->size()) < mMinNtaus) return 1; return 0; }
int NeroTrigger::analyze(const edm::Event& iEvent){ if ( mOnlyMc ) return 0; iEvent.getByToken(token,handle); iEvent.getByToken(prescale_token,prescale_handle); const pat::helper::TriggerMatchHelper matchHelper; triggerFired ->resize( triggerNames->size(),0); triggerPrescale->resize( triggerNames->size(),0); const edm::TriggerNames &names = iEvent.triggerNames(*handle); if ( handle.isValid() and not handle.failedToGet() ) { int ntrigs = (int)names.size(); for (int i = 0; i < ntrigs; i++) { string name = names.triggerName(i); for(unsigned int j=0;j< triggerNames->size() ;++j) // destination loop { if (name.find( (*triggerNames)[j]) != string::npos) (*triggerFired)[j] = 1; (*triggerPrescale)[j] = prescale_handle -> getPrescaleForIndex(i) ; } // my trigger end } // trigger loop } // handle is valid // ---- TRIGGER MATCHING --- if (leps_ !=NULL) triggerLeps -> resize(leps_ -> p4 -> GetEntries() ,0); if (jets_ !=NULL) triggerJets -> resize(jets_ -> p4 -> GetEntries() ,0); if (taus_ !=NULL) triggerTaus -> resize(taus_ -> p4 -> GetEntries() ,0); if (photons_ !=NULL) triggerPhotons -> resize(photons_ -> p4 -> GetEntries() ,0); iEvent.getByToken(object_token,object_handle); for (pat::TriggerObjectStandAlone obj : *object_handle) { obj.unpackPathNames(names); bool isPhoton =false; bool isElectron=false; bool isMuon =false; bool isTau =false; //bool isMet =false; bool isJet =false; bool isBJet =false; for (unsigned h = 0; h < obj.filterIds().size(); ++h) // can be more than one { // HLT: DataFormats/HLTReco/interface/TriggerTypeDefs.h if ( obj.filterIds()[h] == trigger::TriggerPhoton ) isPhoton=true; else if ( obj.filterIds()[h] == trigger::TriggerElectron) isElectron=true; else if ( obj.filterIds()[h] == trigger::TriggerMuon ) isMuon=true; else if ( obj.filterIds()[h] == trigger::TriggerTau ) isTau=true; else if ( obj.filterIds()[h] == trigger::TriggerJet ) isJet=true; else if ( obj.filterIds()[h] == trigger::TriggerBJet ) isBJet=true; //else if ( obj.filterIds()[h] == trigger::TriggerMET ) isMet=true; } std::vector<std::string> pathNamesAll = obj.pathNames(false); std::vector<std::string> pathNamesLast = obj.pathNames(true); // match : if more than one ? best if(VERBOSE)cout<<"[NeroTrigger]::[analize] Matching"<<endl; int muonIndex = -1 ; if( isMuon ) muonIndex = match(leps_,obj,13); int eleIndex=-1 ; if (isElectron) eleIndex = match(leps_,obj,11); int jetIndex=-1; if (isJet or isBJet) jetIndex = match(jets_,obj); int tauIndex=-1; if(isTau) tauIndex = match(taus_,obj); int photonIndex=-1; if (isPhoton) photonIndex = match(photons_,obj); // // Print all trigger paths, for each one record also if the object is associated to a 'l3' filter (always true for the // definition used in the PAT trigger producer) and if it's associated to the last filter of a successfull path (which // means that this object did cause this trigger to succeed; however, it doesn't work on some multi-object triggers) if(VERBOSE)cout<<"[NeroTrigger]::[analize] Lopping on path names and filling"<<endl; for (unsigned h = 0, n = pathNamesAll.size(); h < n; ++h) { if(VERBOSE)cout<<"[NeroTrigger]::[analize] pathNames h="<<h<<endl; bool isBoth = obj.hasPathName( pathNamesAll[h], true, true ); bool isL3 = obj.hasPathName( pathNamesAll[h], false, true ); bool isLF = obj.hasPathName( pathNamesAll[h], true, false ); bool isNone = obj.hasPathName( pathNamesAll[h], false, false ); //std::cout << " " << pathNamesAll[h]; if (isNone && !isBoth && !isL3 && !isLF) continue; for ( unsigned i =0 ; i<triggerNames->size() ;++i) { if(VERBOSE)cout<<"[NeroTrigger]::[analize] triggerNames i="<<i<<endl; if ( pathNamesAll[h].find((*triggerNames)[i] ) !=string::npos ) { if(VERBOSE) cout <<"Considering SUCCESS Path: eleIndex"<< eleIndex <<"/"<<triggerLeps->size()<<" :"<<pathNamesAll[h]<<" and Match string "<<(*triggerNames)[i]<<endl; if(VERBOSE)cout<<"[NeroTrigger]::[analize] ----- Mu "<<muonIndex<<endl; if (muonIndex >=0) (*triggerLeps)[muonIndex] |= 1<<i; if(VERBOSE)cout<<"[NeroTrigger]::[analize] ----- E "<<eleIndex<<endl; if (eleIndex >=0) (*triggerLeps)[eleIndex] |= 1<<i; if(VERBOSE)cout<<"[NeroTrigger]::[analize] ----- Tau "<<tauIndex <<endl; if (tauIndex >=0) (*triggerTaus)[tauIndex] |= 1<<i; if(VERBOSE)cout<<"[NeroTrigger]::[analize] ----- Jet "<< jetIndex<<endl; if (jetIndex >=0) (*triggerJets)[jetIndex] |= 1<<i; if(VERBOSE)cout<<"[NeroTrigger]::[analize] ----- Phot "<<photonIndex<<endl; if (photonIndex >=0) (*triggerPhotons)[photonIndex] |= 1<<i; if(VERBOSE)cout<<"[NeroTrigger]::[analize] ----------"<<endl; } } // end loop for in the trigger names I'm interested in } //end lop pathNames in trigg obj } // end trigger objects loop if(VERBOSE)cout<<"[NeroTrigger]::[analize] === RETURN ==="<<endl; return 0; }
int NeroPhotons::analyze(const edm::Event& iEvent,const edm::EventSetup &iSetup){ if ( mOnlyMc ) return 0; // maybe handle should be taken before iEvent.getByToken(token, handle); // ID and ISO iEvent.getByToken(loose_id_token,loose_id); iEvent.getByToken(medium_id_token,medium_id); iEvent.getByToken(tight_id_token,tight_id); iEvent.getByToken(iso_ch_token, iso_ch); iEvent.getByToken(iso_nh_token, iso_nh); iEvent.getByToken(iso_pho_token, iso_pho); if ( not handle.isValid() ) cout<<"[NeroPhotons]::[analyze]::[ERROR] handle is not valid"<<endl; if ( not loose_id.isValid() ) cout<<"[NeroPhotons]::[analyze]::[ERROR] loose_id is not valid"<<endl; if ( not medium_id.isValid() ) cout<<"[NeroPhotons]::[analyze]::[ERROR] medium_id is not valid"<<endl; if ( not tight_id.isValid() ) cout<<"[NeroPhotons]::[analyze]::[ERROR] tight_id is not valid"<<endl; if ( not iso_ch.isValid() ) cout<<"[NeroPhotons]::[analyze]::[ERROR] iso_ch is not valid"<<endl; if ( not iso_nh.isValid() ) cout<<"[NeroPhotons]::[analyze]::[ERROR] iso_nh is not valid"<<endl; if ( not iso_pho.isValid() ) cout<<"[NeroPhotons]::[analyze]::[ERROR] iso_pho is not valid"<<endl; int iPho = -1; for (auto &pho : *handle) { ++iPho; #ifdef VERBOSE if (VERBOSE>0) cout<<"[NeroPhotons]::[analyze]::[DEBUG] analyzing photon"<<iPho<<" pt="<<pho.pt() <<" pz"<<pho.pz() <<endl; #endif //if ( not pho.passElectronVeto () ) continue; // r9()>0.8 , chargedHadronIso()<20, chargedHadronIso()<0.3*pt() if (pho.pt() <15 or pho.chargedHadronIso()/pho.pt() > 0.3) continue; // 10 -- 14 GeV photons are saved if chargedHadronIso()<10 if (fabs(pho.eta()) > mMaxEta ) continue; if (pho.pt() < mMinPt) continue; #ifdef VERBOSE if (VERBOSE>1) cout<<"[NeroPhotons]::[analize]::[DEBUG2] photonInfo:" <<endl <<" \t pho.chargedHadronIso()/pho.pt() (0.3) "<<pho.chargedHadronIso()/pho.pt() <<endl <<" \t chargedHadronIso() (20) "<<pho.chargedHadronIso()<<endl <<" \t r9 (0.8) "<<pho.r9()<<endl <<" \t SC is non null? "<< pho.superCluster().isNonnull()<<endl <<endl; #endif edm::RefToBase<pat::Photon> ref ( edm::Ref< pat::PhotonCollection >(handle, iPho) ) ; float _chIso_ = (*iso_ch) [ref]; float _nhIso_ = (*iso_nh) [ref]; float _phIso_ = (*iso_pho)[ref]; float _puIso_ = pho.puChargedHadronIso() ; // the other are eff area corrected, no need for this correction float totIso = _chIso_ + _nhIso_ + _phIso_; bool isPassLoose = (*loose_id)[ref]; bool isPassMedium = (*medium_id)[ref]; bool isPassTight = (*tight_id)[ref]; bool isPassVLoose50 = cutBasedPhotonId( pho, "loose_50ns", false, false); // no pho iso , no sieie bool isPassVLoose25 = cutBasedPhotonId( pho, "loose_25ns", false, false); // no pho iso , no sieie //if (not isPassVLoose) continue; if (mMaxIso >=0 and totIso > mMaxIso) continue; unsigned bits=0; bits |= isPassTight * PhoTight; bits |= isPassMedium * PhoMedium; bits |= isPassLoose * PhoLoose; bits |= isPassVLoose50 * PhoVLoose50; bits |= isPassVLoose25 * PhoVLoose25; if (not bits) continue; // even if there is some misalignment ntuples will not be corrupted bits |= pho.passElectronVeto() * PhoElectronVeto; // RC -- with FPR // float _chIsoRC_ = 0; float _nhIsoRC_ = 0; float _phIsoRC_ = 0; float _puIsoRC_ = 0;// not fill for the moment in the FPR TODO if ( pho.chargedHadronIso()< 20 ) { //<<" \t r9 (0.8) "<<pho.r9()<<endl #ifdef VERBOSE if (VERBOSE >0 ) cout <<"[NeroPhotons]::[analyze]::[DEBUG] FPR START"<<endl; #endif fpr -> Config(iSetup); fpr -> SetHandles( pf -> handle, handle, jets-> handle, leps->mu_handle, leps->el_handle ); PFIsolation_struct FPR_out = fpr -> PFIsolation(pho.superCluster(), edm::Ptr<reco::Vertex>(vtx->handle,vtx->firstGoodVertexIdx) ); _chIsoRC_ = FPR_out.chargediso_primvtx_rcone; _nhIsoRC_ = FPR_out.neutraliso_rcone; _phIsoRC_ = FPR_out.photoniso_rcone; #ifdef VERBOSE if (VERBOSE >0 ) cout <<"[NeroPhotons]::[analyze]::[DEBUG] FPR END"<<endl; #endif } else { _chIsoRC_ = -999.; _nhIsoRC_ = -999.; _phIsoRC_ = -999.; _puIsoRC_ = -999.;// not fill for the moment in the FPR TODO } // RC -- without FPR // allowed dphi // -- float dphis[] = { 0.5 * 3.14159 , -.5 *3.14159, 0.25*3.14150 , -0.25*3.14159, 0.75*3.14159,-0.75*3.14159} ; // -- float DR=0.3; // close obj // -- float DRCone=0.3; // default value for iso https://twiki.cern.ch/twiki/bin/view/CMS/EgammaPFBasedIsolationRun2 // -- float dphi = -100; // -- //select dphi // -- for(unsigned i =0 ;i< sizeof(dphis)/sizeof(float) ;++i) // -- { // -- float dphi_cand = dphis[i]; // -- bool close_obj = false; // -- for(auto &j : *jets->handle) // -- { // -- if (j.pt() <20 or j.eta() >2.5) continue; // it's own set of jets // -- TLorentzVector v1,v2; // -- v1.SetPtEtaPhiM( pho.pt(),pho.eta(),pho.phi() + dphi_cand,0 ) ; // -- v2.SetPtEtaPhiM( j.pt(),j.eta(),j.phi(),j.mass() ); // -- if (v1.DeltaR(v2) <DR ) close_obj = true; // -- } // -- if ( not close_obj ) // -- { // -- dphi = dphi_cand; // -- break; // -- } // -- } // -- if (dphi <-99) // -- { // -- _chIsoRC_ = -1; // -- _nhIsoRC_ = -1; // -- _phIsoRC_ = -1; // -- _puIsoRC_ = -1; // -- } // -- else // -- { // -- for( auto &cand : *pf->handle ) // -- { // -- TLorentzVector v1,v2; // -- v1.SetPtEtaPhiM( pho.pt(),pho.eta(),pho.phi() + dphi,0 ) ; // -- v2.SetPtEtaPhiM( cand.pt(),cand.eta(),cand.phi(),cand.mass() ); // -- if (v1.DeltaR(v2) < DRCone ) // -- { // -- // TO BE CHECKED !!! TODO FIXME // -- if (cand.charge() != 0 and abs(cand.pdgId())>20 and fabs( cand.dz() ) <=0.1 and cand.fromPV()>1 and cand.trackHighPurity() ) _chIsoRC_ += cand.pt(); // -- if (cand.charge() == 0 and cand.pdgId() == 22 ) _phIsoRC_ += cand.pt(); // -- if (cand.charge() == 0 and cand.pdgId() != 22 ) _nhIsoRC_ += cand.pt(); // -- if (cand.charge() != 0 and abs(cand.pdgId() )>20 and ( // -- fabs( cand.dz() ) >0.1 or cand.fromPV()<=1 or not cand.trackHighPurity() // -- ) ) _puIsoRC_ += cand.pt(); // -- } // -- } // -- } //FILL new ( (*p4)[p4->GetEntriesFast()]) TLorentzVector(pho.px(),pho.py(),pho.pz(),pho.energy()); iso->push_back(totIso); sieie -> push_back( pho. full5x5_sigmaIetaIeta() ); selBits -> push_back( bits); chIso -> push_back( _chIso_); phoIso -> push_back( _phIso_ ) ; nhIso -> push_back ( _nhIso_ ) ; puIso -> push_back ( _puIso_ ) ; chIsoRC -> push_back( _chIsoRC_); phoIsoRC -> push_back( _phIsoRC_ ) ; nhIsoRC -> push_back ( _nhIsoRC_ ) ; puIsoRC -> push_back ( _puIsoRC_ ) ; } if ( int(selBits -> size()) < mMinNpho ) return 1; return 0; }
void TreeWriter::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { // get gen particles before photons for the truth match edm::Handle<edm::View<reco::GenParticle>> prunedGenParticles; iEvent.getByToken(prunedGenToken_,prunedGenParticles); edm::Handle<edm::ValueMap<bool>> loose_id_dec; edm::Handle<edm::ValueMap<bool>> medium_id_dec; edm::Handle<edm::ValueMap<bool>> tight_id_dec; edm::Handle<edm::ValueMap<float>> mva_value; edm::Handle<edm::ValueMap<vid::CutFlowResult>> loose_id_cutflow; iEvent.getByToken(photonLooseIdMapToken_, loose_id_dec); iEvent.getByToken(photonMediumIdMapToken_, medium_id_dec); iEvent.getByToken(photonTightIdMapToken_, tight_id_dec); iEvent.getByToken(photonMvaValuesMapToken_, mva_value); iEvent.getByToken(phoLooseIdFullInfoMapToken_, loose_id_cutflow); // photon collection edm::Handle<edm::View<pat::Photon>> photonColl; iEvent.getByToken(photonCollectionToken_, photonColl); for (edm::View<pat::Photon>::const_iterator pho = photonColl->begin(); pho != photonColl->end(); pho++) { // some basic selections if (pho->pt() < 15 || pho->hadTowOverEm() > 0.15) continue; const edm::Ptr<pat::Photon> phoPtr(photonColl, pho - photonColl->begin()); pt = pho->pt(); eta = pho->eta(); sigmaIetaIeta=pho->full5x5_sigmaIetaIeta(); hOverE=pho->hadTowOverEm() ; hasPixelSeed=pho->hasPixelSeed() ; passElectronVeto= pho->passElectronVeto() ; r9 = pho->r9(); vid::CutFlowResult cutFlow = (*loose_id_cutflow)[phoPtr]; cIso = cutFlow.getValueCutUpon(4); nIso = cutFlow.getValueCutUpon(5); pIso = cutFlow.getValueCutUpon(6); mvaValue = (*mva_value) [phoPtr]; isLoose = (*loose_id_dec) [phoPtr]; isMedium = (*medium_id_dec)[phoPtr]; isTight = (*tight_id_dec) [phoPtr]; // mc matching bool foundPhoton = false; bool vetoPhoton = false; for (auto& genP: *prunedGenParticles) { if (fabs(genP.pdgId()) == 22 && genP.statusFlags().fromHardProcess() && genP.status() == 1 && ROOT::Math::VectorUtil::DeltaR(pho->p4(), genP.p4())<0.1) { foundPhoton = true; } else if (fabs(genP.pdgId()) == 22 && ROOT::Math::VectorUtil::DeltaR(pho->p4(), genP.p4())<0.4) { vetoPhoton = true; } } if (foundPhoton) { isTrue = true; eventTree_->Fill(); } if (!vetoPhoton) { isTrue = false; eventTree_->Fill(); } } // Get the electron ID data from the event stream edm::Handle<edm::ValueMap<bool>> veto_id_decisions; edm::Handle<edm::ValueMap<bool>> loose_id_decisions; edm::Handle<edm::ValueMap<bool>> medium_id_decisions; edm::Handle<edm::ValueMap<bool>> tight_id_decisions; iEvent.getByToken(electronVetoIdMapToken_, veto_id_decisions); iEvent.getByToken(electronLooseIdMapToken_, loose_id_decisions); iEvent.getByToken(electronMediumIdMapToken_, medium_id_decisions); iEvent.getByToken(electronTightIdMapToken_, tight_id_decisions); edm::Handle<edm::View<pat::Electron>> electronColl; iEvent.getByToken(electronCollectionToken_, electronColl); for (edm::View<pat::Electron>::const_iterator el = electronColl->begin();el != electronColl->end(); el++) { const edm::Ptr<pat::Electron> elPtr (electronColl, el - electronColl->begin() ); bool isLoose = (*loose_id_decisions) [elPtr]; if (isLoose && false ) std::cout << el->pt() << std::endl; } }
int NeroMonteCarlo::analyze(const edm::Event& iEvent){ if ( iEvent.isRealData() ) return 0; isRealData = iEvent.isRealData() ? 1 : 0 ; // private, not the one in the tree TStopwatch sw; if(VERBOSE)sw.Start(); // maybe handle should be taken before iEvent.getByToken(info_token, info_handle); iEvent.getByToken(packed_token, packed_handle); iEvent.getByToken(pruned_token, pruned_handle); iEvent.getByToken(pu_token, pu_handle); iEvent.getByToken(jet_token, jet_handle); if ( not info_handle.isValid() ) cout<<"[NeroMonteCarlo]::[analyze]::[ERROR] info_handle is not valid"<<endl; if ( not packed_handle.isValid() ) cout<<"[NeroMonteCarlo]::[analyze]::[ERROR] packed_handle is not valid"<<endl; if ( not pruned_handle.isValid() ) cout<<"[NeroMonteCarlo]::[analyze]::[ERROR] pruned_handle is not valid"<<endl; if ( not pu_handle.isValid() ) cout<<"[NeroMonteCarlo]::[analyze]::[ERROR] pu_handle is not valid"<<endl; if ( not jet_handle.isValid() ) cout<<"[NeroMonteCarlo]::[analyze]::[ERROR] jet_handle is not valid"<<endl; if(VERBOSE){ sw.Stop() ; cout<<"[NeroMonteCarlo]::[analyze] getToken took "<<sw.CpuTime()<<" Cpu and "<<sw.RealTime()<<" RealTime"<<endl; sw.Reset(); sw.Start();} // INFO if(VERBOSE>1) cout<<"[NeroMonteCarlo]::[analyze]::[DEBUG] mcWeight="<<endl; mcWeight = info_handle -> weight(); if(VERBOSE>1) cout<<" mcWeight="<<mcWeight<<endl; //weights() //--- scale if ( info_handle -> weights() .size() >= 9){ r1f2 = info_handle -> weights() [1] ; r1f5 = info_handle -> weights() [2] ; r2f1 = info_handle -> weights() [3] ; r2f2 = info_handle -> weights() [4] ; r5f1 = info_handle -> weights() [6] ; r5f5 = info_handle -> weights() [8] ; } if (info_handle -> weights().size() > 109) for( int pdfw = 9 ; pdfw<109 ;++pdfw) { pdfRwgt -> push_back( info_handle -> weights() [pdfw] ); } // --- fill pdf Weights // if(VERBOSE>1) cout<<"[NeroMonteCarlo]::[analyze]::[DEBUG] PDF="<<endl; if ( mParticleGun ) { qScale = -999 ; alphaQED = -999 ; alphaQCD = -999 ; x1 = -999 ; x2 = -999 ; pdf1Id = -999 ; pdf2Id = -999 ; scalePdf = -999 ; } else { qScale = info_handle -> qScale(); alphaQED = info_handle -> alphaQED(); alphaQCD = info_handle -> alphaQCD(); x1 = info_handle -> pdf() -> x.first; x2 = info_handle -> pdf() -> x.second; pdf1Id = info_handle -> pdf() -> id.first; pdf2Id = info_handle -> pdf() -> id.second; scalePdf = info_handle -> pdf() -> scalePDF; } if(VERBOSE>1) cout<<" PDF="<<qScale<<" "<< alphaQED<<endl; //PU if(VERBOSE>1){ cout<<endl<<"[NeroMonteCarlo]::[analyze] PU LOOP"<<endl;} puTrueInt = 0; for(const auto & pu : *pu_handle) { //Intime if (pu.getBunchCrossing() == 0) puTrueInt += pu.getTrueNumInteractions(); //puInt += getPU_NumInteractions(); //old //Out-of-time } if(VERBOSE){ sw.Stop() ; cout<<"[NeroMonteCarlo]::[analyze] pu&info took "<<sw.CpuTime()<<" Cpu and "<<sw.RealTime()<<" RealTime"<<endl; sw.Reset(); sw.Start();} // GEN PARTICLES //TLorentzVector genmet(0,0,0,0); //for ( auto & gen : *packed_handle) for ( unsigned int i=0;i < packed_handle->size() ;++i) { const auto gen = & (*packed_handle)[i]; if (gen->pt() < 5 ) continue; if (gen->pt() < mMinGenParticlePt ) continue; int pdg = gen->pdgId(); int apdg = abs(pdg); //neutrinos // --- if ( (apdg != 12 and apdg !=14 and apdg != 16 // --- and apdg > 1000000 neutrinos and neutralinos // --- )//SUSY // --- and fabs(gen->eta() ) <4.7 // --- ) // --- { // --- TLorentzVector tmp( gen->px(),gen->py(),gen->pz(),gen->energy() ); // --- genmet += tmp; // --- } // --- genmet = -genmet; //FILL // e mu photons if ( apdg == 11 or apdg == 13 or apdg == 22 // e - mu - gamma or (apdg >=12 and apdg<=16) // neutrinos or apdg > 1000000 // susy neutrinos and neutralinos ) { new ( (*p4)[p4->GetEntriesFast()]) TLorentzVector(gen->px(), gen->py(), gen->pz(), gen->energy()); pdgId -> push_back( pdg ); flags -> push_back( ComputeFlags( *gen ) ); // compute ISOLATION float iso=0; float isoFx=0; if (apdg == 22 or apdg ==11 or apdg ==13) { TLorentzVector g1(gen->px(),gen->py(),gen->pz(),gen->energy()); vector< pair<float,float> > inIsoFx ; //isoFx, dR, pT for ( unsigned int j=0;j < packed_handle->size() ;++j) { if (i==j) continue; const auto gen2 = & (*packed_handle)[j]; if ( gen2->pt() ==0 ) continue; if (gen2->pz() > 10e8 ) continue; // inf TLorentzVector g2(gen2->px(),gen2->py(),gen2->pz(),gen2->energy()); if (g2.DeltaR(g1) <0.4){ iso += g2.Pt(); // isoFx containes the epsilon inIsoFx.push_back( pair<float,float>(g2.DeltaR(g1) ,g2.Pt() ) ); } } if (apdg==22){ // ONLY for photon Frixione isolation sort(inIsoFx.begin(), inIsoFx.end() ); // sort in DR, first entry float sumEtFx=0; for( const auto & p : inIsoFx ) { const float& pt= p.second ; const float& delta = p.first; sumEtFx += pt / gen->pt(); // relative iso if (delta == 0 ) continue; // guard float isoCandidate = sumEtFx * TMath::Power( (1. - TMath::Cos(0.4) ) / (1. - TMath::Cos(delta ) ), 2) ;// n=2 if (isoFx < isoCandidate) isoFx = isoCandidate; } } } genIso -> push_back(iso); genIsoFrixione -> push_back(isoFx); // computed dressed objects // if (apdg == 11 or apdg == 13) { // only for final state muons and electrons TLorentzVector dressedLepton(gen->px(),gen->py(),gen->pz(),gen->energy()); TLorentzVector lepton(dressedLepton); //original lepton for dR for ( unsigned int j=0;j < packed_handle->size() ;++j) { const auto gen2 = & (*packed_handle)[j]; TLorentzVector photon(gen2->px(),gen2->py(),gen2->pz(),gen2->energy()); if (i != j and abs( gen->pdgId() ) ==22 and lepton.DeltaR( photon ) <0.1 ) dressedLepton += photon; } new ( (*p4)[p4->GetEntriesFast()]) TLorentzVector( dressedLepton ); pdgId -> push_back( pdg ); flags -> push_back( Dressed ); genIso -> push_back (0.) ; genIsoFrixione -> push_back (0.) ; // --- end of dressing } } } //end packed if(VERBOSE){ sw.Stop() ; cout<<"[NeroMonteCarlo]::[analyze] packed took "<<sw.CpuTime()<<" Cpu and "<<sw.RealTime()<<" RealTime"<<endl; sw.Reset(); sw.Start();} // LOOP over PRUNED PARTICLES //for (auto & gen : *pruned_handle) for (unsigned int i=0;i<pruned_handle->size() ;++i) { const auto gen = &(*pruned_handle)[i]; if (gen->pt() < 5 ) continue; if (gen->pt() < mMinGenParticlePt ) continue; int pdg = gen->pdgId(); int apdg = abs(pdg); if (gen->status() == 1) continue; //packed unsigned flag = ComputeFlags(*gen); if ( apdg == 15 or // tau (15) (apdg >= 23 and apdg <26 ) or // Z(23) W(24) H(25) apdg == 37 or // chHiggs: H+(37) apdg <= 6 or // quarks up (2) down (1) charm (4) strange (3) top (6) bottom (5) apdg == 21 or // gluons (21) apdg > 1000000 // susy neutrinos,neutralinos, charginos ... lightest neutralinos (1000022) or ( apdg == 11 and ( flag & HardProcessBeforeFSR) ) or ( apdg == 11 and ( flag & HardProcess) ) or ( apdg == 13 and ( flag & HardProcessBeforeFSR) ) or ( apdg == 13 and ( flag & HardProcess) ) ) { new ( (*p4)[p4->GetEntriesFast()]) TLorentzVector(gen->px(), gen->py(), gen->pz(), gen->energy()); pdgId -> push_back( pdg ); flags -> push_back( flag ); genIso -> push_back (0.) ; genIsoFrixione -> push_back (0.) ; } } if(VERBOSE){ sw.Stop() ; cout<<"[NeroMonteCarlo]::[analyze] pruned took "<<sw.CpuTime()<<" Cpu and "<<sw.RealTime()<<" RealTime"<<endl; sw.Reset(); sw.Start();} // GEN JETS for (const auto & j : *jet_handle) { if (j.pt() < 20 ) continue; if (j.pt() < mMinGenJetPt ) continue; // --- FILL new ( (*jetP4)[jetP4->GetEntriesFast()]) TLorentzVector(j.px(), j.py(), j.pz(), j.energy()); } if(VERBOSE){ sw.Stop() ; cout<<"[NeroMonteCarlo]::[analyze] jets took "<<sw.CpuTime()<<" Cpu and "<<sw.RealTime()<<" RealTime"<<endl; sw.Reset();} return 0; }
int NeroMet::analyze(const edm::Event& iEvent){ if ( mOnlyMc ) return 0; // in principle I would like to have the gen met: TODO // maybe handle should be taken before iEvent.getByToken(token, handle); const pat::MET &met = handle->front(); // FILL new ( (*p4)[p4->GetEntriesFast()]) TLorentzVector( met.px(),met.py(),met.pz(),met.energy() ); ptJESUP -> push_back( met.shiftedPt(pat::MET::JetEnUp) ); ptJESDOWN -> push_back( met.shiftedPt(pat::MET::JetEnDown) ); if (IsExtend()) { //MetNoMu TLorentzVector metnomu(met.px(),met.py(),met.pz(),met.energy()); TLorentzVector pfmet_e3p0(0,0,0,0); TLorentzVector chMet(0,0,0,0); TLorentzVector nhMet(0,0,0,0); TLorentzVector phoMet(0,0,0,0); if ( pf == NULL ) cout<<"[NeroMet]::[analyze]::[ERROR] PF pointer is null. Run NeroPF. "<<endl; for (unsigned int i = 0, n = pf->handle->size(); i < n; ++i) { const pat::PackedCandidate &cand = (*pf->handle)[i]; // only up to eta 3 if (std::abs(cand.eta()) < 3.0) pfmet_e3p0 += TLorentzVector(cand.px(),cand.py(),cand.pz(),cand.energy()); if (std::abs(cand.pdgId()) == 13) metnomu += TLorentzVector(cand.px(),cand.py(),cand.pz(),cand.energy()); // only charge hadrons if ( cand.charge() != 0 and cand.pdgId() > 20 ) chMet += TLorentzVector(cand.px(),cand.py(),cand.pz(),cand.energy()); if ( cand.charge() == 0 and cand.pdgId() == 22 ) phoMet += TLorentzVector(cand.px(),cand.py(),cand.pz(),cand.energy()); if ( cand.charge() == 0 and cand.pdgId() != 22 ) nhMet += TLorentzVector(cand.px(),cand.py(),cand.pz(),cand.energy()); } *metNoMu = TLorentzVector(metnomu); *metChargedHadron = TLorentzVector(chMet); *metNeutralHadron = TLorentzVector(nhMet); *metNeutralEM = TLorentzVector(phoMet); *pfMet_e3p0 = TLorentzVector(pfmet_e3p0); } // GEN INFO if ( not iEvent.isRealData () ){ new ( (*genP4)[genP4->GetEntriesFast()]) TLorentzVector( met.genMET()->px(),met.genMET()->py(),met.genMET()->pz(),met.genMET()->energy() ); } return 0; }
int NeroMetRecluster::analyze(const edm::Event& iEvent){ if ( mOnlyMc ) return 0; // in principle I would like to have the gen met: TODO // maybe handle should be taken before iEvent.getByToken(token, handle); if ( not handle.isValid() ) cout<<"[NeroMetRecluster]::[analyze]::[ERROR] handle is not valid"<<endl; iEvent.getByToken(token_puppi,handle_puppi); if ( not handle_puppi.isValid() ) cout<<"[NeroMetRecluster]::[analyze]::[ERROR] handle_puppi is not valid"<<endl; iEvent.getByToken(token_puppiUncorr,handle_puppiUncorr); if ( not handle_puppiUncorr.isValid() ) cout<<"[NeroMetRecluster]::[analyze]::[ERROR] handle_puppiUncorr is not valid"<<endl; //-- const pat::MET &met = handle->front(); caloMet_Pt = met.caloMETPt(); caloMet_Phi = met.caloMETPhi(); caloMet_SumEt = met.caloMETSumEt(); // FILL new ( (*p4)[p4->GetEntriesFast()]) TLorentzVector( met.px(),met.py(),met.pz(),met.energy() ); sumEtRaw = met.uncorSumEt(); ptJESUP -> push_back( met.shiftedPt(pat::MET::JetEnUp) ); ptJESDOWN -> push_back( met.shiftedPt(pat::MET::JetEnDown) ); rawMet_Pt = met.uncorPt(); rawMet_Phi = met.uncorPhi(); if (IsExtend()) { //MetNoMu TLorentzVector metnomu(met.px(),met.py(),met.pz(),met.energy()); TLorentzVector tkMet(0,0,0,0); TLorentzVector pfmet_3p0(0,0,0,0); if ( pf == NULL ) cout<<"[NeroMetRecluster]::[analyze]::[ERROR] PF pointer is null. Run NeroPF. "<<endl; for (unsigned int i = 0, n = pf->handle->size(); i < n; ++i) { const pat::PackedCandidate &cand = (*pf->handle)[i]; // only up to eta 3 if (std::abs(cand.pdgId()) == 13) metnomu += TLorentzVector(cand.px(),cand.py(),cand.pz(),cand.energy()); // only charge hadrons if ( cand.charge() != 0 ) tkMet += TLorentzVector(cand.px(),cand.py(),cand.pz(),cand.energy()); if (std::abs(cand.eta()) < 3.0 ) pfmet_3p0 += TLorentzVector(cand.px(),cand.py(),cand.pz(),cand.energy()); } *pfMet_e3p0 = TLorentzVector( -pfmet_3p0 ); *metNoMu = TLorentzVector(metnomu); // no minus *trackMet = TLorentzVector( -tkMet ); auto &puppi = handle_puppi->front(); *metPuppi = TLorentzVector( puppi.px(), puppi.py(),puppi.pz(),puppi.energy() ); sumEtRawPuppi = handle_puppiUncorr->front().sumEt(); } // GEN INFO if ( not iEvent.isRealData () ){ new ( (*genP4)[genP4->GetEntriesFast()]) TLorentzVector( met.genMET()->px(),met.genMET()->py(),met.genMET()->pz(),met.genMET()->energy() ); } return 0; }
int NeroPuppiFatJets::analyze(const edm::Event& iEvent) { if ( mOnlyMc ) return 0; if ( mMinId == "none" ) return 0; // maybe handle should be taken before iEvent.getByToken(token, handle); iEvent.getByToken(rho_token,rho_handle); TString tPrefix(cachedPrefix); edm::Handle<reco::PFJetCollection> subjets_handle; edm::InputTag subjetLabel("PFJetsSoftDrop"+tPrefix,"SubJets"); //iEvent.getByLabel(subjetLabel,subjets_handle); iEvent.getByToken(subjets_token,subjets_handle); const reco::PFJetCollection *subjetCol = subjets_handle.product(); assert(subjets_handle.isValid()); edm::Handle<reco::JetTagCollection> btags_handle; //iEvent.getByLabel(edm::InputTag((tPrefix+"PFCombinedInclusiveSecondaryVertexV2BJetTags").Data()),btags_handle); iEvent.getByToken(btags_token,btags_handle); assert((btags_handle.isValid())); FactorizedJetCorrector *corrector = ( iEvent.isRealData() ) ? mDataJetCorrector : mMCJetCorrector; int ijetRef = -1; int nsubjet = 0; for (const pat::Jet& j : *handle) { ijetRef++; if (fabs(j.eta() ) > mMaxEta) continue; if ( !NeroPuppiJets::JetId(j,mMinId) ) continue; // pT cut applied after applying JEC if necessary // GET ValueMaps // Fill output object // this was reclustered from mini AOD, so we have to apply JEC, etc edm::RefToBase<pat::Jet> jetRef(edm::Ref<pat::JetCollection>(handle,ijetRef)); double jecFactor=0; if (fabs(j.eta())<5.191) { corrector->setJetPt(j.pt()); corrector->setJetEta(j.eta()); corrector->setJetPhi(j.phi()); corrector->setJetE(j.energy()); corrector->setRho(*rho_handle); corrector->setJetA(j.jetArea()); corrector->setJetEMF(-99.0); jecFactor = corrector->getCorrection(); } if (j.pt()*jecFactor < mMinPt) continue; rawPt -> push_back (j.pt()); new ( (*p4)[p4->GetEntriesFast()]) TLorentzVector(j.px()*jecFactor, j.py()*jecFactor, j.pz()*jecFactor, j.energy()*jecFactor); tau1 -> push_back(j.userFloat(tPrefix+"Njettiness:tau1")); tau2 -> push_back(j.userFloat(tPrefix+"Njettiness:tau2")); tau3 -> push_back(j.userFloat(tPrefix+"Njettiness:tau3")); softdropMass->push_back(j.userFloat(tPrefix+"SDKinematics:Mass")*jecFactor); unsigned int nsubjetThisJet=0; firstSubjet->push_back(nsubjet); for (reco::PFJetCollection::const_iterator i = subjetCol->begin(); i!=subjetCol->end(); ++i) { if (reco::deltaR(i->eta(),i->phi(),j.eta(),j.phi())>jetRadius) continue; nsubjetThisJet++; new ( (*subjet)[nsubjet]) TLorentzVector(i->px(), i->py(), i->pz(), i->energy()); nsubjet++; reco::JetBaseRef sjBaseRef(reco::PFJetRef(subjets_handle,i-subjetCol->begin())); subjet_btag->push_back((float)(*(btags_handle.product()))[sjBaseRef]); } nSubjets->push_back(nsubjetThisJet); } return 0; }
int NeroMet::analyze(const edm::Event& iEvent){ if ( mOnlyMc ) return 0; // in principle I would like to have the gen met: TODO // maybe handle should be taken before iEvent.getByToken(token, handle); if ( not handle.isValid() ) cout<<"[NeroMet]::[analyze]::[ERROR] handle is not valid"<<endl; if (rerunPuppi) { iEvent.getByToken(token_puppiRerun,handle_puppiRerun); if ( not handle_puppiRerun.isValid() ) cout<<"[NeroMetRecluster]::[analyze]::[ERROR] handle_puppiRerun is not valid"<<endl; iEvent.getByToken(token_puppiRerunUncorr,handle_puppiRerunUncorr); if ( not handle_puppiRerunUncorr.isValid() ) cout<<"[NeroMetRecluster]::[analyze]::[ERROR] handle_puppiRerunUncorr is not valid"<<endl; } else { iEvent.getByToken(token_puppi,handle_puppi); if ( not handle_puppi.isValid() ) cout<<"[NeroMet]::[analyze]::[ERROR] handle_puppi is not valid"<<endl; } // -- iEvent.getByToken(token_puppiUncorr,handle_puppiUncorr); // -- if ( not handle_puppiUncorr.isValid() ) cout<<"[NeroMet]::[analyze]::[ERROR] handle_puppiUncorr is not valid"<<endl; //-- const pat::MET &met = handle->front(); caloMet_Pt = met.caloMETPt(); caloMet_Phi = met.caloMETPhi(); caloMet_SumEt = met.caloMETSumEt(); // FILL new ( (*p4)[p4->GetEntriesFast()]) TLorentzVector( met.px(),met.py(),met.pz(),met.energy() ); sumEtRaw = met.uncorSumEt(); ptJESUP -> push_back( met.shiftedPt(pat::MET::JetEnUp) ); ptJESDOWN -> push_back( met.shiftedPt(pat::MET::JetEnDown) ); rawMet_Pt = met.uncorPt(); rawMet_Phi = met.uncorPhi(); if (IsExtend()) { //MetNoMu TLorentzVector metnomu(met.px(),met.py(),met.pz(),met.energy()); TLorentzVector tkMet(0,0,0,0); TLorentzVector pfmet_3p0(0,0,0,0); if ( pf == NULL ) cout<<"[NeroMet]::[analyze]::[ERROR] PF pointer is null. Run NeroPF. "<<endl; for (unsigned int i = 0, n = pf->handle->size(); i < n; ++i) { const pat::PackedCandidate &cand = (*pf->handle)[i]; // only up to eta 3 if (std::abs(cand.pdgId()) == 13) metnomu += TLorentzVector(cand.px(),cand.py(),cand.pz(),cand.energy()); // only charge hadrons if ( cand.charge() != 0 ) tkMet += TLorentzVector(cand.px(),cand.py(),cand.pz(),cand.energy()); if (std::abs(cand.eta()) < 3.0 ) pfmet_3p0 += TLorentzVector(cand.px(),cand.py(),cand.pz(),cand.energy()); } *pfMet_e3p0 = TLorentzVector( -pfmet_3p0 ); *metNoMu = TLorentzVector(metnomu); // no minus *trackMet = TLorentzVector( -tkMet ); if (rerunPuppi) { auto &puppi = handle_puppiRerun->front(); *metPuppi = TLorentzVector( puppi.px(), puppi.py(),puppi.pz(),puppi.energy() ); sumEtRawPuppi = handle_puppiRerunUncorr->front().sumEt(); } else { auto &puppi = handle_puppi->front(); *metPuppi = TLorentzVector( puppi.px(), puppi.py(),puppi.pz(),puppi.energy() ); //sumEtRawPuppi = handle_puppiUncorr->front().sumEt(); sumEtRawPuppi = puppi.uncorSumEt(); } for(Syst mysyst = (Syst)0; mysyst < MaxSyst ; mysyst = (Syst)((int)mysyst +1 ) ) { pat::MET::METUncertainty miniAODUnc=pat::MET::METUncertaintySize; // JetResUp=0, JetResDown=1, JetEnUp=2, JetEnDown=3, // MuonEnUp=4, MuonEnDown=5, ElectronEnUp=6, ElectronEnDown=7, // TauEnUp=8, TauEnDown=9, UnclusteredEnUp=10, UnclusteredEnDown=11, // PhotonEnUp=12, PhotonEnDown=13, NoShift=14, METUncertaintySize=15, // JetResUpSmear=16, JetResDownSmear=17, METFullUncertaintySize=18 // translate switch (mysyst) { case JesUp : {miniAODUnc = pat::MET::JetEnUp; break;} case JesDown : {miniAODUnc = pat::MET::JetEnDown; break;} case JerUp : {miniAODUnc = pat::MET::JetResUp; break;} case JerDown : {miniAODUnc = pat::MET::JetResDown; break;} case UnclusterUp : {miniAODUnc = pat::MET::UnclusteredEnUp; break;} case UnclusterDown : {miniAODUnc = pat::MET::UnclusteredEnDown; break;} case TauUp : {miniAODUnc = pat::MET::TauEnUp; break;} case TauDown : {miniAODUnc = pat::MET::TauEnDown; break;} case PhotonUp : {miniAODUnc = pat::MET::PhotonEnDown; break;} case PhotonDown : {miniAODUnc = pat::MET::PhotonEnDown; break;} case ElectronUp : {miniAODUnc = pat::MET::ElectronEnUp; break;} case ElectronDown : {miniAODUnc = pat::MET::ElectronEnDown; break;} case MuonUp : {miniAODUnc = pat::MET::MuonEnUp; break;} case MuonDown : {miniAODUnc = pat::MET::MuonEnDown; break;} default : break; } if (miniAODUnc == pat::MET::METUncertaintySize) cout <<"[NeroMet]::[analyze]::[WARNING] unable to translate met syst,"<< int(mysyst) <<endl; /* new ( (*metPuppiSyst)[ mysyst ] ) TLorentzVector( puppi . shiftedP4( miniAODUnc).px(), puppi . shiftedP4(miniAODUnc).py(), puppi . shiftedP4(miniAODUnc).pz(), puppi . shiftedP4(miniAODUnc).energy() ); */ new ( (*metSyst)[ mysyst ] ) TLorentzVector( met . shiftedP4( miniAODUnc).px(), met . shiftedP4(miniAODUnc).py(), met . shiftedP4(miniAODUnc).pz(), met . shiftedP4(miniAODUnc).energy() ); }// end syst loop } // GEN INFO if ( not iEvent.isRealData () ){ new ( (*genP4)[genP4->GetEntriesFast()]) TLorentzVector( met.genMET()->px(),met.genMET()->py(),met.genMET()->pz(),met.genMET()->energy() ); } return 0; }
int NeroPhotons::analyze(const edm::Event& iEvent,const edm::EventSetup &iSetup){ if ( mOnlyMc ) return 0; // maybe handle should be taken before iEvent.getByToken(token, handle); // ID and ISO iEvent.getByToken(loose_id_token,loose_id); iEvent.getByToken(medium_id_token,medium_id); iEvent.getByToken(tight_id_token,tight_id); iEvent.getByToken(iso_ch_token, iso_ch); iEvent.getByToken(iso_nh_token, iso_nh); iEvent.getByToken(iso_pho_token, iso_pho); int iPho = -1; for (auto &pho : *handle) { ++iPho; if (pho.pt() <15 or pho.chargedHadronIso()/pho.pt() > 0.3) continue; if (fabs(pho.eta()) > mMinEta ) continue; if (pho.pt() < mMinPt) continue; edm::RefToBase<pat::Photon> ref ( edm::Ref< pat::PhotonCollection >(handle, iPho) ) ; float _chIso_ = (*iso_ch) [ref]; float _nhIso_ = (*iso_nh) [ref]; float _phIso_ = (*iso_pho)[ref]; float _puIso_ = pho.puChargedHadronIso() ; // the other are eff area corrected, no need for this correction float totIso = _chIso_ + _nhIso_ + _phIso_; bool isPassLoose = (*loose_id)[ref]; bool isPassMedium = (*medium_id)[ref]; bool isPassTight = (*tight_id)[ref]; bool isPassVLoose = cutBasedPhotonId( pho, "loose_50ns", false, false); // no pho iso , no sieie if (not isPassVLoose) continue; if (mMaxIso >=0 and totIso > mMaxIso) continue; // RC -- with FPR // float _chIsoRC_ = 0; float _nhIsoRC_ = 0; float _phIsoRC_ = 0; float _puIsoRC_ = 0;// not fill for the moment in the FPR TODO fpr -> Config(iSetup); fpr -> SetHandles( pf -> handle, handle, jets-> handle, leps->mu_handle, leps->el_handle ); PFIsolation_struct FPR_out = fpr -> PFIsolation(pho.superCluster(), edm::Ptr<reco::Vertex>(vtx->handle,vtx->firstGoodVertexIdx) ); _chIsoRC_ = FPR_out.chargediso_primvtx_rcone; _nhIsoRC_ = FPR_out.neutraliso_rcone; _phIsoRC_ = FPR_out.photoniso_rcone; // RC -- without FPR // allowed dphi // -- float dphis[] = { 0.5 * 3.14159 , -.5 *3.14159, 0.25*3.14150 , -0.25*3.14159, 0.75*3.14159,-0.75*3.14159} ; // -- float DR=0.3; // close obj // -- float DRCone=0.3; // default value for iso https://twiki.cern.ch/twiki/bin/view/CMS/EgammaPFBasedIsolationRun2 // -- float dphi = -100; // -- //select dphi // -- for(unsigned i =0 ;i< sizeof(dphis)/sizeof(float) ;++i) // -- { // -- float dphi_cand = dphis[i]; // -- bool close_obj = false; // -- for(auto &j : *jets->handle) // -- { // -- if (j.pt() <20 or j.eta() >2.5) continue; // it's own set of jets // -- TLorentzVector v1,v2; // -- v1.SetPtEtaPhiM( pho.pt(),pho.eta(),pho.phi() + dphi_cand,0 ) ; // -- v2.SetPtEtaPhiM( j.pt(),j.eta(),j.phi(),j.mass() ); // -- if (v1.DeltaR(v2) <DR ) close_obj = true; // -- } // -- if ( not close_obj ) // -- { // -- dphi = dphi_cand; // -- break; // -- } // -- } // -- if (dphi <-99) // -- { // -- _chIsoRC_ = -1; // -- _nhIsoRC_ = -1; // -- _phIsoRC_ = -1; // -- _puIsoRC_ = -1; // -- } // -- else // -- { // -- for( auto &cand : *pf->handle ) // -- { // -- TLorentzVector v1,v2; // -- v1.SetPtEtaPhiM( pho.pt(),pho.eta(),pho.phi() + dphi,0 ) ; // -- v2.SetPtEtaPhiM( cand.pt(),cand.eta(),cand.phi(),cand.mass() ); // -- if (v1.DeltaR(v2) < DRCone ) // -- { // -- // TO BE CHECKED !!! TODO FIXME // -- if (cand.charge() != 0 and abs(cand.pdgId())>20 and fabs( cand.dz() ) <=0.1 and cand.fromPV()>1 and cand.trackHighPurity() ) _chIsoRC_ += cand.pt(); // -- if (cand.charge() == 0 and cand.pdgId() == 22 ) _phIsoRC_ += cand.pt(); // -- if (cand.charge() == 0 and cand.pdgId() != 22 ) _nhIsoRC_ += cand.pt(); // -- if (cand.charge() != 0 and abs(cand.pdgId() )>20 and ( // -- fabs( cand.dz() ) >0.1 or cand.fromPV()<=1 or not cand.trackHighPurity() // -- ) ) _puIsoRC_ += cand.pt(); // -- } // -- } // -- } //FILL new ( (*p4)[p4->GetEntriesFast()]) TLorentzVector(pho.px(),pho.py(),pho.pz(),pho.energy()); iso->push_back(totIso); sieie -> push_back( pho. full5x5_sigmaIetaIeta() ); tightid->push_back(isPassTight); mediumid->push_back(isPassMedium); looseid->push_back(isPassLoose); chIso -> push_back( _chIso_); phoIso -> push_back( _phIso_ ) ; nhIso -> push_back ( _nhIso_ ) ; puIso -> push_back ( _puIso_ ) ; chIsoRC -> push_back( _chIsoRC_); phoIsoRC -> push_back( _phIsoRC_ ) ; nhIsoRC -> push_back ( _nhIsoRC_ ) ; puIsoRC -> push_back ( _puIsoRC_ ) ; } return 0; }