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) :
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 saveTags_(iConfig.getUntrackedParameter<bool>("saveTags",false)),
00056 min_Pt_ (iConfig.getParameter<double>("MinPt"))
00057 {
00058 LogDebug("") << "MinPt cut " << min_Pt_
00059 << " g: " << photTag_.encode()
00060 << " e: " << elecTag_.encode()
00061 << " m: " << muonTag_.encode()
00062 << " t: " << tausTag_.encode()
00063 << " j: " << jetsTag_.encode()
00064 << " M: " << metsTag_.encode()
00065 << " H: " << mhtsTag_.encode()
00066 <<" TR: " << trckTag_.encode()
00067 <<" SC: " << ecalTag_.encode()
00068 ;
00069
00070
00071 produces<trigger::TriggerFilterObjectWithRefs>();
00072 }
00073
00074 HLTFiltCand::~HLTFiltCand()
00075 {
00076 }
00077
00078
00079
00080
00081
00082
00083 bool
00084 HLTFiltCand::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
00085 {
00086 using namespace std;
00087 using namespace edm;
00088 using namespace reco;
00089 using namespace trigger;
00090
00091
00092
00093
00094
00095
00096 auto_ptr<TriggerFilterObjectWithRefs>
00097 filterobject (new TriggerFilterObjectWithRefs(path(),module()));
00098 if (saveTags_) {
00099 filterobject->addCollectionTag(photTag_);
00100 filterobject->addCollectionTag(elecTag_);
00101 filterobject->addCollectionTag(muonTag_);
00102 filterobject->addCollectionTag(tausTag_);
00103 filterobject->addCollectionTag(jetsTag_);
00104 filterobject->addCollectionTag(metsTag_);
00105 filterobject->addCollectionTag(mhtsTag_);
00106 filterobject->addCollectionTag(trckTag_);
00107 filterobject->addCollectionTag(ecalTag_);
00108 }
00109
00110
00111
00112
00113
00114 Handle<RecoEcalCandidateCollection> photons;
00115 Handle<ElectronCollection> electrons;
00116 Handle<RecoChargedCandidateCollection> muons;
00117 Handle<CaloJetCollection> taus;
00118 Handle<CaloJetCollection> jets;
00119 Handle<CaloMETCollection> mets;
00120 Handle<METCollection> mhts;
00121 Handle<RecoChargedCandidateCollection> trcks;
00122 Handle<RecoEcalCandidateCollection> ecals;
00123
00124 iEvent.getByLabel(photTag_,photons );
00125 iEvent.getByLabel(elecTag_,electrons);
00126 iEvent.getByLabel(muonTag_,muons );
00127 iEvent.getByLabel(tausTag_,taus );
00128 iEvent.getByLabel(jetsTag_,jets );
00129 iEvent.getByLabel(metsTag_,mets );
00130 iEvent.getByLabel(mhtsTag_,mhts );
00131 iEvent.getByLabel(trckTag_,trcks );
00132 iEvent.getByLabel(ecalTag_,ecals );
00133
00134
00135
00136
00137
00138 int nphot(0);
00139 RecoEcalCandidateCollection::const_iterator aphot(photons->begin());
00140 RecoEcalCandidateCollection::const_iterator ophot(photons->end());
00141 RecoEcalCandidateCollection::const_iterator iphot;
00142 for (iphot=aphot; iphot!=ophot; iphot++) {
00143 if (iphot->pt() >= min_Pt_) {
00144 nphot++;
00145 RecoEcalCandidateRef ref(RecoEcalCandidateRef(photons,distance(aphot,iphot)));
00146 filterobject->addObject(TriggerPhoton,ref);
00147 }
00148 }
00149
00150
00151 int nelec(0);
00152 ElectronCollection::const_iterator aelec(electrons->begin());
00153 ElectronCollection::const_iterator oelec(electrons->end());
00154 ElectronCollection::const_iterator ielec;
00155 for (ielec=aelec; ielec!=oelec; ielec++) {
00156 if (ielec->pt() >= min_Pt_) {
00157 nelec++;
00158 ElectronRef ref(ElectronRef(electrons,distance(aelec,ielec)));
00159 filterobject->addObject(-TriggerElectron,ref);
00160 }
00161 }
00162
00163
00164 int nmuon(0);
00165 RecoChargedCandidateCollection::const_iterator amuon(muons->begin());
00166 RecoChargedCandidateCollection::const_iterator omuon(muons->end());
00167 RecoChargedCandidateCollection::const_iterator imuon;
00168 for (imuon=amuon; imuon!=omuon; imuon++) {
00169 if (imuon->pt() >= min_Pt_) {
00170 nmuon++;
00171 RecoChargedCandidateRef ref(RecoChargedCandidateRef(muons,distance(amuon,imuon)));
00172 filterobject->addObject(TriggerMuon,ref);
00173 }
00174 }
00175
00176
00177 int ntaus(0);
00178 CaloJetCollection::const_iterator ataus(taus->begin());
00179 CaloJetCollection::const_iterator otaus(taus->end());
00180 CaloJetCollection::const_iterator itaus;
00181 for (itaus=ataus; itaus!=otaus; itaus++) {
00182 if (itaus->pt() >= min_Pt_) {
00183 ntaus++;
00184 CaloJetRef ref(CaloJetRef(taus,distance(ataus,itaus)));
00185 filterobject->addObject(-TriggerTau,ref);
00186 }
00187 }
00188
00189
00190 int njets(0);
00191 CaloJetCollection::const_iterator ajets(jets->begin());
00192 CaloJetCollection::const_iterator ojets(jets->end());
00193 CaloJetCollection::const_iterator ijets;
00194 for (ijets=ajets; ijets!=ojets; ijets++) {
00195 if (ijets->pt() >= min_Pt_) {
00196 njets++;
00197 CaloJetRef ref(CaloJetRef(jets,distance(ajets,ijets)));
00198 filterobject->addObject(TriggerJet,ref);
00199 }
00200 }
00201
00202
00203 int nmets(0);
00204 CaloMETCollection::const_iterator amets(mets->begin());
00205 CaloMETCollection::const_iterator omets(mets->end());
00206 CaloMETCollection::const_iterator imets;
00207 for (imets=amets; imets!=omets; imets++) {
00208 if (imets->pt() >= min_Pt_) {
00209 nmets++;
00210 CaloMETRef ref(CaloMETRef(mets,distance(amets,imets)));
00211 filterobject->addObject(TriggerMET,ref);
00212 }
00213 }
00214
00215
00216 int nmhts(0);
00217 METCollection::const_iterator amhts(mhts->begin());
00218 METCollection::const_iterator omhts(mhts->end());
00219 METCollection::const_iterator imhts;
00220 for (imhts=amhts; imhts!=omhts; imhts++) {
00221 if (imhts->pt() >= min_Pt_) {
00222 nmhts++;
00223 METRef ref(METRef(mhts,distance(amhts,imhts)));
00224 filterobject->addObject(TriggerMHT,ref);
00225 }
00226 }
00227
00228
00229 int ntrck(0);
00230 RecoChargedCandidateCollection::const_iterator atrcks(trcks->begin());
00231 RecoChargedCandidateCollection::const_iterator otrcks(trcks->end());
00232 RecoChargedCandidateCollection::const_iterator itrcks;
00233 for (itrcks=atrcks; itrcks!=otrcks; itrcks++) {
00234 if (itrcks->pt() >= min_Pt_) {
00235 ntrck++;
00236 RecoChargedCandidateRef ref(RecoChargedCandidateRef(trcks,distance(atrcks,itrcks)));
00237 filterobject->addObject(TriggerTrack,ref);
00238 }
00239 }
00240
00241
00242 int necal(0);
00243 RecoEcalCandidateCollection::const_iterator aecals(ecals->begin());
00244 RecoEcalCandidateCollection::const_iterator oecals(ecals->end());
00245 RecoEcalCandidateCollection::const_iterator iecals;
00246 for (iecals=aecals; iecals!=oecals; iecals++) {
00247 if (iecals->pt() >= min_Pt_) {
00248 necal++;
00249 RecoEcalCandidateRef ref(RecoEcalCandidateRef(ecals,distance(aecals,iecals)));
00250 filterobject->addObject(TriggerCluster,ref);
00251 }
00252 }
00253
00254
00255
00256
00257
00258 const bool accept ( (nphot>0) && (nelec>0) && (nmuon>0) && (ntaus>0) &&
00259 (njets>0) && (nmets>0) && (nmhts>=0) && (ntrck>0) && (necal>0) );
00260
00261
00262 iEvent.put(filterobject);
00263
00264 LogDebug("") << "Number of g/e/m/t/j/M/H/TR/SC objects accepted:"
00265 << " " << nphot
00266 << " " << nelec
00267 << " " << nmuon
00268 << " " << ntaus
00269 << " " << njets
00270 << " " << nmets
00271 << " " << nmhts
00272 << " " << ntrck
00273 << " " << necal
00274 ;
00275
00276
00277 return accept;
00278 }