00001
00012 #include "HLTrigger/HLTfilters/interface/HLTFiltCand.h"
00013
00014 #include "DataFormats/Common/interface/Handle.h"
00015
00016 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
00017 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidateFwd.h"
00018 #include "DataFormats/EgammaCandidates/interface/Electron.h"
00019 #include "DataFormats/EgammaCandidates/interface/ElectronFwd.h"
00020 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
00021 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidateFwd.h"
00022 #include "DataFormats/JetReco/interface/CaloJet.h"
00023 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
00024 #include "DataFormats/Candidate/interface/CompositeCandidate.h"
00025 #include "DataFormats/Candidate/interface/CompositeCandidateFwd.h"
00026 #include "DataFormats/METReco/interface/CaloMET.h"
00027 #include "DataFormats/METReco/interface/CaloMETFwd.h"
00028 #include "DataFormats/METReco/interface/MET.h"
00029 #include "DataFormats/METReco/interface/METFwd.h"
00030
00031 #include "DataFormats/JetReco/interface/GenJet.h"
00032 #include "DataFormats/JetReco/interface/GenJetCollection.h"
00033 #include "DataFormats/METReco/interface/GenMET.h"
00034 #include "DataFormats/METReco/interface/GenMETCollection.h"
00035
00036 #include "DataFormats/Common/interface/Ref.h"
00037 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
00038
00039 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00040
00041
00042
00043
00044
00045 HLTFiltCand::HLTFiltCand(const edm::ParameterSet& iConfig) : HLTFilter(iConfig),
00046 photTag_ (iConfig.getParameter<edm::InputTag>("photTag")),
00047 elecTag_ (iConfig.getParameter<edm::InputTag>("elecTag")),
00048 muonTag_ (iConfig.getParameter<edm::InputTag>("muonTag")),
00049 tausTag_ (iConfig.getParameter<edm::InputTag>("tausTag")),
00050 jetsTag_ (iConfig.getParameter<edm::InputTag>("jetsTag")),
00051 metsTag_ (iConfig.getParameter<edm::InputTag>("metsTag")),
00052 mhtsTag_ (iConfig.getParameter<edm::InputTag>("mhtsTag")),
00053 trckTag_ (iConfig.getParameter<edm::InputTag>("trckTag")),
00054 ecalTag_ (iConfig.getParameter<edm::InputTag>("ecalTag")),
00055 min_Pt_ (iConfig.getParameter<double>("MinPt"))
00056 {
00057 LogDebug("") << "MinPt cut " << min_Pt_
00058 << " g: " << photTag_.encode()
00059 << " e: " << elecTag_.encode()
00060 << " m: " << muonTag_.encode()
00061 << " t: " << tausTag_.encode()
00062 << " j: " << jetsTag_.encode()
00063 << " M: " << metsTag_.encode()
00064 << " H: " << mhtsTag_.encode()
00065 <<" TR: " << trckTag_.encode()
00066 <<" SC: " << ecalTag_.encode()
00067 ;
00068 }
00069
00070 HLTFiltCand::~HLTFiltCand()
00071 {
00072 }
00073
00074
00075
00076
00077
00078
00079 bool
00080 HLTFiltCand::hltFilter(edm::Event& iEvent, const edm::EventSetup& iSetup, trigger::TriggerFilterObjectWithRefs & filterproduct)
00081 {
00082 using namespace std;
00083 using namespace edm;
00084 using namespace reco;
00085 using namespace trigger;
00086
00087
00088
00089
00090
00091
00092 if (saveTags()) {
00093 filterproduct.addCollectionTag(photTag_);
00094 filterproduct.addCollectionTag(elecTag_);
00095 filterproduct.addCollectionTag(muonTag_);
00096 filterproduct.addCollectionTag(tausTag_);
00097 filterproduct.addCollectionTag(jetsTag_);
00098 filterproduct.addCollectionTag(metsTag_);
00099 filterproduct.addCollectionTag(mhtsTag_);
00100 filterproduct.addCollectionTag(trckTag_);
00101 filterproduct.addCollectionTag(ecalTag_);
00102 }
00103
00104
00105
00106
00107
00108 Handle<RecoEcalCandidateCollection> photons;
00109 Handle<ElectronCollection> electrons;
00110 Handle<RecoChargedCandidateCollection> muons;
00111 Handle<CaloJetCollection> taus;
00112 Handle<CaloJetCollection> jets;
00113 Handle<CaloMETCollection> mets;
00114 Handle<METCollection> mhts;
00115 Handle<RecoChargedCandidateCollection> trcks;
00116 Handle<RecoEcalCandidateCollection> ecals;
00117
00118 iEvent.getByLabel(photTag_,photons );
00119 iEvent.getByLabel(elecTag_,electrons);
00120 iEvent.getByLabel(muonTag_,muons );
00121 iEvent.getByLabel(tausTag_,taus );
00122 iEvent.getByLabel(jetsTag_,jets );
00123 iEvent.getByLabel(metsTag_,mets );
00124 iEvent.getByLabel(mhtsTag_,mhts );
00125 iEvent.getByLabel(trckTag_,trcks );
00126 iEvent.getByLabel(ecalTag_,ecals );
00127
00128
00129
00130
00131
00132 int nphot(0);
00133 RecoEcalCandidateCollection::const_iterator aphot(photons->begin());
00134 RecoEcalCandidateCollection::const_iterator ophot(photons->end());
00135 RecoEcalCandidateCollection::const_iterator iphot;
00136 for (iphot=aphot; iphot!=ophot; iphot++) {
00137 if (iphot->pt() >= min_Pt_) {
00138 nphot++;
00139 RecoEcalCandidateRef ref(RecoEcalCandidateRef(photons,distance(aphot,iphot)));
00140 filterproduct.addObject(TriggerPhoton,ref);
00141 }
00142 }
00143
00144
00145 int nelec(0);
00146 ElectronCollection::const_iterator aelec(electrons->begin());
00147 ElectronCollection::const_iterator oelec(electrons->end());
00148 ElectronCollection::const_iterator ielec;
00149 for (ielec=aelec; ielec!=oelec; ielec++) {
00150 if (ielec->pt() >= min_Pt_) {
00151 nelec++;
00152 ElectronRef ref(ElectronRef(electrons,distance(aelec,ielec)));
00153 filterproduct.addObject(-TriggerElectron,ref);
00154 }
00155 }
00156
00157
00158 int nmuon(0);
00159 RecoChargedCandidateCollection::const_iterator amuon(muons->begin());
00160 RecoChargedCandidateCollection::const_iterator omuon(muons->end());
00161 RecoChargedCandidateCollection::const_iterator imuon;
00162 for (imuon=amuon; imuon!=omuon; imuon++) {
00163 if (imuon->pt() >= min_Pt_) {
00164 nmuon++;
00165 RecoChargedCandidateRef ref(RecoChargedCandidateRef(muons,distance(amuon,imuon)));
00166 filterproduct.addObject(TriggerMuon,ref);
00167 }
00168 }
00169
00170
00171 int ntaus(0);
00172 CaloJetCollection::const_iterator ataus(taus->begin());
00173 CaloJetCollection::const_iterator otaus(taus->end());
00174 CaloJetCollection::const_iterator itaus;
00175 for (itaus=ataus; itaus!=otaus; itaus++) {
00176 if (itaus->pt() >= min_Pt_) {
00177 ntaus++;
00178 CaloJetRef ref(CaloJetRef(taus,distance(ataus,itaus)));
00179 filterproduct.addObject(-TriggerTau,ref);
00180 }
00181 }
00182
00183
00184 int njets(0);
00185 CaloJetCollection::const_iterator ajets(jets->begin());
00186 CaloJetCollection::const_iterator ojets(jets->end());
00187 CaloJetCollection::const_iterator ijets;
00188 for (ijets=ajets; ijets!=ojets; ijets++) {
00189 if (ijets->pt() >= min_Pt_) {
00190 njets++;
00191 CaloJetRef ref(CaloJetRef(jets,distance(ajets,ijets)));
00192 filterproduct.addObject(TriggerJet,ref);
00193 }
00194 }
00195
00196
00197 int nmets(0);
00198 CaloMETCollection::const_iterator amets(mets->begin());
00199 CaloMETCollection::const_iterator omets(mets->end());
00200 CaloMETCollection::const_iterator imets;
00201 for (imets=amets; imets!=omets; imets++) {
00202 if (imets->pt() >= min_Pt_) {
00203 nmets++;
00204 CaloMETRef ref(CaloMETRef(mets,distance(amets,imets)));
00205 filterproduct.addObject(TriggerMET,ref);
00206 }
00207 }
00208
00209
00210 int nmhts(0);
00211 METCollection::const_iterator amhts(mhts->begin());
00212 METCollection::const_iterator omhts(mhts->end());
00213 METCollection::const_iterator imhts;
00214 for (imhts=amhts; imhts!=omhts; imhts++) {
00215 if (imhts->pt() >= min_Pt_) {
00216 nmhts++;
00217 METRef ref(METRef(mhts,distance(amhts,imhts)));
00218 filterproduct.addObject(TriggerMHT,ref);
00219 }
00220 }
00221
00222
00223 int ntrck(0);
00224 RecoChargedCandidateCollection::const_iterator atrcks(trcks->begin());
00225 RecoChargedCandidateCollection::const_iterator otrcks(trcks->end());
00226 RecoChargedCandidateCollection::const_iterator itrcks;
00227 for (itrcks=atrcks; itrcks!=otrcks; itrcks++) {
00228 if (itrcks->pt() >= min_Pt_) {
00229 ntrck++;
00230 RecoChargedCandidateRef ref(RecoChargedCandidateRef(trcks,distance(atrcks,itrcks)));
00231 filterproduct.addObject(TriggerTrack,ref);
00232 }
00233 }
00234
00235
00236 int necal(0);
00237 RecoEcalCandidateCollection::const_iterator aecals(ecals->begin());
00238 RecoEcalCandidateCollection::const_iterator oecals(ecals->end());
00239 RecoEcalCandidateCollection::const_iterator iecals;
00240 for (iecals=aecals; iecals!=oecals; iecals++) {
00241 if (iecals->pt() >= min_Pt_) {
00242 necal++;
00243 RecoEcalCandidateRef ref(RecoEcalCandidateRef(ecals,distance(aecals,iecals)));
00244 filterproduct.addObject(TriggerCluster,ref);
00245 }
00246 }
00247
00248
00249
00250
00251
00252 const bool accept ( (nphot>0) && (nelec>0) && (nmuon>0) && (ntaus>0) &&
00253
00254 (njets>0) && (nmets>0) && (ntrck>0) && (necal>0) );
00255
00256 LogDebug("") << "Number of g/e/m/t/j/M/H/TR/SC objects accepted:"
00257 << " " << nphot
00258 << " " << nelec
00259 << " " << nmuon
00260 << " " << ntaus
00261 << " " << njets
00262 << " " << nmets
00263 << " " << nmhts
00264 << " " << ntrck
00265 << " " << necal
00266 ;
00267
00268
00269 return accept;
00270 }