#include <HLTrigger/HLTexample/interface/HLTProdCand.h>
Public Member Functions | |
HLTProdCand (const edm::ParameterSet &) | |
virtual void | produce (edm::Event &, const edm::EventSetup &) |
~HLTProdCand () | |
Private Attributes | |
edm::InputTag | jetsTag_ |
edm::InputTag | metsTag_ |
See header file for documentation.
Definition at line 25 of file HLTProdCand.h.
HLTProdCand::HLTProdCand | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 49 of file HLTProdCand.cc.
References edm::InputTag::encode(), jetsTag_, LogDebug, and metsTag_.
00049 : 00050 jetsTag_ (iConfig.getParameter<edm::InputTag>("jetsTag")), 00051 metsTag_ (iConfig.getParameter<edm::InputTag>("metsTag")) 00052 { 00053 LogDebug("") << "Inputs: jets/mets: " << jetsTag_.encode() << " / " << metsTag_.encode(); 00054 00055 //register your products 00056 00057 produces<reco::RecoEcalCandidateCollection>("photons"); 00058 produces<reco::ElectronCollection>("electrons"); 00059 produces<reco::RecoChargedCandidateCollection>("muons"); 00060 produces<reco::CaloJetCollection>("taus"); 00061 produces<reco::CaloJetCollection>("jets"); 00062 produces<reco::CaloMETCollection>("mets"); 00063 produces<reco::METCollection>("hts"); 00064 00065 produces<reco::RecoChargedCandidateCollection>("tracks"); 00066 produces<reco::RecoEcalCandidateCollection>("clusters"); 00067 00068 }
HLTProdCand::~HLTProdCand | ( | ) |
void HLTProdCand::produce | ( | edm::Event & | iEvent, | |
const edm::EventSetup & | iSetup | |||
) | [virtual] |
Implements edm::EDProducer.
Definition at line 80 of file HLTProdCand.cc.
References funct::abs(), ReconstructionGR_cff::ecal, edm::Event::getByLabel(), edm::Event::getManyByType(), i, edm::Handle< T >::isValid(), pfTauBenchmarkGeneric_cfi::jets, jetsTag_, LogDebug, metsTag_, metsig::muon, p, p4, gen_jpsi2muons_cfg::ParticleID, edm::Event::put(), HcalSimpleRecAlgoImpl::reco(), and std.
00081 { 00082 using namespace std; 00083 using namespace edm; 00084 using namespace reco; 00085 00086 // produce collections of photons, electrons, muons, taus, jets, MET 00087 auto_ptr<RecoEcalCandidateCollection> phot (new RecoEcalCandidateCollection); 00088 auto_ptr<ElectronCollection> elec (new ElectronCollection); 00089 auto_ptr<RecoChargedCandidateCollection> muon (new RecoChargedCandidateCollection); 00090 auto_ptr<CaloJetCollection> taus (new CaloJetCollection); // stored as jets 00091 auto_ptr<CaloJetCollection> jets (new CaloJetCollection); 00092 auto_ptr<CaloMETCollection> mets (new CaloMETCollection); 00093 auto_ptr<METCollection> hts (new METCollection); 00094 00095 // as well as charged tracks and elmg. superclusters 00096 auto_ptr<RecoChargedCandidateCollection> trck (new RecoChargedCandidateCollection); 00097 auto_ptr<RecoEcalCandidateCollection> ecal (new RecoEcalCandidateCollection); 00098 00099 // jets and MET are special: check whether clustered jets and mets 00100 // exist already 00101 int njets(-1); 00102 edm::Handle<GenJetCollection> mcjets; 00103 iEvent.getByLabel(jetsTag_,mcjets); 00104 if (mcjets.isValid()) njets=mcjets->size(); 00105 LogDebug("") << "MC-truth jets found: " << njets; 00106 for (int i=0; i<njets; i++) { 00107 math::XYZTLorentzVector p4(((*mcjets)[i]).p4()); 00108 CaloJet::Specific specific; 00109 Jet::Constituents jetconst; 00110 jets->push_back(CaloJet(p4,specific,jetconst)); 00111 } 00112 00113 int nmets(-1); 00114 edm::Handle<GenMETCollection> mcmets; 00115 iEvent.getByLabel(metsTag_,mcmets); 00116 if (mcmets.isValid()) nmets=mcmets->size(); 00117 LogDebug("") << "MC-truth mets found: " << nmets; 00118 for (int i=0; i<nmets; i++) { 00119 math::XYZTLorentzVector p4(((*mcmets)[i]).p4()); 00120 SpecificCaloMETData specific; 00121 mets->push_back(CaloMET(specific,p4.Et(),p4,math::XYZPoint(0,0,0))); 00122 } 00123 00124 // photons, electrons, muons and taus: generator level 00125 // tracks: all charged particles; superclusters: electrons and photons 00126 00127 // get hold of generator records 00128 vector<edm::Handle<edm::HepMCProduct> > hepmcs; 00129 edm::Handle<edm::HepMCProduct> hepmc; 00130 iEvent.getManyByType(hepmcs); 00131 LogDebug("") << "Number of HepMC products found: " << hepmcs.size(); 00132 00133 // loop over all final-state particles in all generator records 00134 for (unsigned int i=0; i!=hepmcs.size(); i++) { 00135 hepmc=hepmcs[i]; 00136 const HepMC::GenEvent* evt = hepmc->GetEvent(); 00137 for (HepMC::GenEvent::particle_const_iterator pitr=evt->particles_begin(); pitr!=evt->particles_end(); pitr++) { 00138 00139 // stable particles only! 00140 if ( (*pitr)->status()==1) { 00141 // particle type 00142 const int ipdg((*pitr)->pdg_id()); 00143 // 4-momentum 00144 const HepMC::FourVector p((*pitr)->momentum()); 00145 const math::XYZTLorentzVector 00146 p4(math::XYZTLorentzVector(p.x(),p.y(),p.z(),p.t())); 00147 // charge 00148 const int qX3(HepPDT::ParticleID(ipdg).threeCharge()); 00149 00150 // charged particles yield tracks 00151 if ( qX3 != 0 ) { 00152 trck->push_back(RecoChargedCandidate(qX3/abs(qX3),p4)); 00153 } 00154 00155 if (abs(ipdg)==11) { 00156 // e+ e- 00157 elec->push_back( Electron (-ipdg/abs(ipdg),p4)); 00158 ecal->push_back(RecoEcalCandidate(-ipdg/abs(ipdg),p4)); 00159 } else if (abs(ipdg)==13) { 00160 // mu+ mu- 00161 muon->push_back(RecoChargedCandidate(-ipdg/abs(ipdg),p4)); 00162 } else if (abs(ipdg)==15 || abs(ipdg)==17) { 00163 // tau+ tau- or 4th generation tau'+ tau'- 00164 CaloJet::Specific specific; 00165 Jet::Constituents jetconst; 00166 taus->push_back(CaloJet(p4,specific,jetconst)); 00167 } else if (abs(ipdg)==22) { 00168 // photon 00169 phot->push_back(RecoEcalCandidate(0,p4)); 00170 ecal->push_back(RecoEcalCandidate(0,p4)); 00171 } else if (abs(ipdg)==12 || abs(ipdg)==14 || abs(ipdg)==16 || abs(ipdg)==18) { 00172 // neutrinos (e mu tau 4th generation) 00173 if (nmets==-1) { 00174 // if no prepared mets, each becomes a met on its own (crude)! 00175 SpecificCaloMETData specific; 00176 mets->push_back(CaloMET(specific,p4.Et(),p4,math::XYZPoint(0,0,0))); 00177 } 00178 } else { 00179 // any other particle 00180 if (njets==-1) { 00181 // if no prepared jets, each becomes a jet on its own (crude)! 00182 CaloJet::Specific specific; 00183 Jet::Constituents jetconst; 00184 jets->push_back(CaloJet(p4,specific,jetconst)); 00185 } 00186 } 00187 } 00188 } 00189 } 00190 00191 LogDebug("") << "Number of g/e/m/t/j/M/H/TR/SC objects reconstructed:" 00192 << " " << phot->size() 00193 << " " << elec->size() 00194 << " " << muon->size() 00195 << " " << taus->size() 00196 << " " << jets->size() 00197 << " " << mets->size() 00198 << " " << hts->size() 00199 << " " << trck->size() 00200 << " " << ecal->size() 00201 ; 00202 00203 // put them into the event 00204 00205 iEvent.put(phot,"photons"); 00206 iEvent.put(elec,"electrons"); 00207 iEvent.put(muon,"muons"); 00208 iEvent.put(taus,"taus"); 00209 iEvent.put(jets,"jets"); 00210 iEvent.put(mets,"mets"); 00211 iEvent.put(hts,"hts"); 00212 iEvent.put(trck,"tracks"); 00213 iEvent.put(ecal,"clusters"); 00214 00215 return; 00216 }
edm::InputTag HLTProdCand::jetsTag_ [private] |
edm::InputTag HLTProdCand::metsTag_ [private] |