本文整理汇总了C++中edm::Event::getByToken方法的典型用法代码示例。如果您正苦于以下问题:C++ Event::getByToken方法的具体用法?C++ Event::getByToken怎么用?C++ Event::getByToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edm::Event
的用法示例。
在下文中一共展示了Event::getByToken方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: produce
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");
}
示例2: analyze
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;
}
示例3: analyze
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;
}
示例4: analyze
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;
}
示例5: analyze
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;
}
示例6: analyze
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;
}
示例7: analyze
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;
}
//.........这里部分代码省略.........
示例8: analyze
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;
//.........这里部分代码省略.........
示例9: analyze
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;
//.........这里部分代码省略.........
示例10: phoPtr
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;
}
}
示例11: analyze
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;
// --- }
//.........这里部分代码省略.........
示例12: analyze
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;
}
示例13: analyze
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;
}
示例14: analyze
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;
}
示例15: analyze
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;}
//.........这里部分代码省略.........