CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTFiltCand.cc
Go to the documentation of this file.
1 
12 
14 
29 
34 
37 
39 
40 //
41 // constructors and destructor
42 //
43 
45  photTag_ (iConfig.getParameter<edm::InputTag>("photTag")),
46  elecTag_ (iConfig.getParameter<edm::InputTag>("elecTag")),
47  muonTag_ (iConfig.getParameter<edm::InputTag>("muonTag")),
48  tausTag_ (iConfig.getParameter<edm::InputTag>("tausTag")),
49  jetsTag_ (iConfig.getParameter<edm::InputTag>("jetsTag")),
50  metsTag_ (iConfig.getParameter<edm::InputTag>("metsTag")),
51  mhtsTag_ (iConfig.getParameter<edm::InputTag>("mhtsTag")),
52  trckTag_ (iConfig.getParameter<edm::InputTag>("trckTag")),
53  ecalTag_ (iConfig.getParameter<edm::InputTag>("ecalTag")),
54  photToken_ (consumes<reco::RecoEcalCandidateCollection> (photTag_)),
55  elecToken_ (consumes<reco::ElectronCollection> (elecTag_)),
56  muonToken_ (consumes<reco::RecoChargedCandidateCollection>(muonTag_)),
57  tausToken_ (consumes<reco::CaloJetCollection> (tausTag_)),
58  jetsToken_ (consumes<reco::CaloJetCollection> (jetsTag_)),
59  metsToken_ (consumes<reco::CaloMETCollection> (metsTag_)),
60  mhtsToken_ (consumes<reco::METCollection> (mhtsTag_)),
61  trckToken_ (consumes<reco::RecoChargedCandidateCollection>(trckTag_)),
62  ecalToken_ (consumes<reco::RecoEcalCandidateCollection> (ecalTag_)),
63  min_Pt_ (iConfig.getParameter<double>("MinPt"))
64 {
65  LogDebug("") << "MinPt cut " << min_Pt_
66  << " g: " << photTag_.encode()
67  << " e: " << elecTag_.encode()
68  << " m: " << muonTag_.encode()
69  << " t: " << tausTag_.encode()
70  << " j: " << jetsTag_.encode()
71  << " M: " << metsTag_.encode()
72  << " H: " << mhtsTag_.encode()
73  <<" TR: " << trckTag_.encode()
74  <<" SC: " << ecalTag_.encode()
75  ;
76 }
77 
79 {
80 }
81 
82 //
83 // member functions
84 //
85 
86 void
90  desc.add<edm::InputTag>("photTag",edm::InputTag("photCollection"));
91  desc.add<edm::InputTag>("elecTag",edm::InputTag("elecCollection"));
92  desc.add<edm::InputTag>("muonTag",edm::InputTag("muonCollection"));
93  desc.add<edm::InputTag>("tausTag",edm::InputTag("tausCollection"));
94  desc.add<edm::InputTag>("jetsTag",edm::InputTag("jetsCollection"));
95  desc.add<edm::InputTag>("metsTag",edm::InputTag("metsCollection"));
96  desc.add<edm::InputTag>("mhtsTag",edm::InputTag("mhtsCollection"));
97  desc.add<edm::InputTag>("trckTag",edm::InputTag("trckCollection"));
98  desc.add<edm::InputTag>("ecalTag",edm::InputTag("ecalCollection"));
99  desc.add<double>("MinPt",-1.0);
100  descriptions.add("hltFiltCand", desc);
101 }
102 
103 // ------------ method called to produce the data ------------
104 bool
106 {
107  using namespace std;
108  using namespace edm;
109  using namespace reco;
110  using namespace trigger;
111 
112  // All HLT filters must create and fill an HLT filter object,
113  // recording any reconstructed physics objects satisfying (or not)
114  // this HLT filter, and place it in the Event.
115 
116  // The filter object
117  if (saveTags()) {
118  filterproduct.addCollectionTag(photTag_);
119  filterproduct.addCollectionTag(elecTag_);
120  filterproduct.addCollectionTag(muonTag_);
121  filterproduct.addCollectionTag(tausTag_);
122  filterproduct.addCollectionTag(jetsTag_);
123  filterproduct.addCollectionTag(metsTag_);
124  filterproduct.addCollectionTag(mhtsTag_);
125  filterproduct.addCollectionTag(trckTag_);
126  filterproduct.addCollectionTag(ecalTag_);
127  }
128 
129  // Specific filter code
130 
131  // get hold of products from Event
132 
142 
143  iEvent.getByToken(photToken_,photons );
145  iEvent.getByToken(muonToken_,muons );
146  iEvent.getByToken(tausToken_,taus );
147  iEvent.getByToken(jetsToken_,jets );
148  iEvent.getByToken(metsToken_,mets );
149  iEvent.getByToken(mhtsToken_,mhts );
150  iEvent.getByToken(trckToken_,trcks );
151  iEvent.getByToken(ecalToken_,ecals );
152 
153 
154  // look for at least one g,e,m,t,j,M,H,TR,SC above its pt cut
155 
156  // photons
157  int nphot(0);
158  RecoEcalCandidateCollection::const_iterator aphot(photons->begin());
159  RecoEcalCandidateCollection::const_iterator ophot(photons->end());
160  RecoEcalCandidateCollection::const_iterator iphot;
161  for (iphot=aphot; iphot!=ophot; iphot++) {
162  if (iphot->pt() >= min_Pt_) {
163  nphot++;
165  filterproduct.addObject(TriggerPhoton,ref);
166  }
167  }
168 
169  // electrons
170  int nelec(0);
171  ElectronCollection::const_iterator aelec(electrons->begin());
172  ElectronCollection::const_iterator oelec(electrons->end());
173  ElectronCollection::const_iterator ielec;
174  for (ielec=aelec; ielec!=oelec; ielec++) {
175  if (ielec->pt() >= min_Pt_) {
176  nelec++;
177  ElectronRef ref(ElectronRef(electrons,distance(aelec,ielec)));
178  filterproduct.addObject(-TriggerElectron,ref);
179  }
180  }
181 
182  // muon
183  int nmuon(0);
184  RecoChargedCandidateCollection::const_iterator amuon(muons->begin());
185  RecoChargedCandidateCollection::const_iterator omuon(muons->end());
186  RecoChargedCandidateCollection::const_iterator imuon;
187  for (imuon=amuon; imuon!=omuon; imuon++) {
188  if (imuon->pt() >= min_Pt_) {
189  nmuon++;
191  filterproduct.addObject(TriggerMuon,ref);
192  }
193  }
194 
195  // taus (are stored as jets)
196  int ntaus(0);
197  CaloJetCollection::const_iterator ataus(taus->begin());
198  CaloJetCollection::const_iterator otaus(taus->end());
199  CaloJetCollection::const_iterator itaus;
200  for (itaus=ataus; itaus!=otaus; itaus++) {
201  if (itaus->pt() >= min_Pt_) {
202  ntaus++;
203  CaloJetRef ref(CaloJetRef(taus,distance(ataus,itaus)));
204  filterproduct.addObject(-TriggerTau,ref);
205  }
206  }
207 
208  // jets
209  int njets(0);
210  CaloJetCollection::const_iterator ajets(jets->begin());
211  CaloJetCollection::const_iterator ojets(jets->end());
212  CaloJetCollection::const_iterator ijets;
213  for (ijets=ajets; ijets!=ojets; ijets++) {
214  if (ijets->pt() >= min_Pt_) {
215  njets++;
216  CaloJetRef ref(CaloJetRef(jets,distance(ajets,ijets)));
217  filterproduct.addObject(TriggerJet,ref);
218  }
219  }
220 
221  // mets
222  int nmets(0);
223  CaloMETCollection::const_iterator amets(mets->begin());
224  CaloMETCollection::const_iterator omets(mets->end());
225  CaloMETCollection::const_iterator imets;
226  for (imets=amets; imets!=omets; imets++) {
227  if (imets->pt() >= min_Pt_) {
228  nmets++;
229  CaloMETRef ref(CaloMETRef(mets,distance(amets,imets)));
230  filterproduct.addObject(TriggerMET,ref);
231  }
232  }
233 
234  // mhts
235  int nmhts(0);
236  METCollection::const_iterator amhts(mhts->begin());
237  METCollection::const_iterator omhts(mhts->end());
238  METCollection::const_iterator imhts;
239  for (imhts=amhts; imhts!=omhts; imhts++) {
240  if (imhts->pt() >= min_Pt_) {
241  nmhts++;
242  METRef ref(METRef(mhts,distance(amhts,imhts)));
243  filterproduct.addObject(TriggerMHT,ref);
244  }
245  }
246 
247  // trcks
248  int ntrck(0);
249  RecoChargedCandidateCollection::const_iterator atrcks(trcks->begin());
250  RecoChargedCandidateCollection::const_iterator otrcks(trcks->end());
251  RecoChargedCandidateCollection::const_iterator itrcks;
252  for (itrcks=atrcks; itrcks!=otrcks; itrcks++) {
253  if (itrcks->pt() >= min_Pt_) {
254  ntrck++;
255  RecoChargedCandidateRef ref(RecoChargedCandidateRef(trcks,distance(atrcks,itrcks)));
256  filterproduct.addObject(TriggerTrack,ref);
257  }
258  }
259 
260  // ecals
261  int necal(0);
262  RecoEcalCandidateCollection::const_iterator aecals(ecals->begin());
263  RecoEcalCandidateCollection::const_iterator oecals(ecals->end());
264  RecoEcalCandidateCollection::const_iterator iecals;
265  for (iecals=aecals; iecals!=oecals; iecals++) {
266  if (iecals->pt() >= min_Pt_) {
267  necal++;
268  RecoEcalCandidateRef ref(RecoEcalCandidateRef(ecals,distance(aecals,iecals)));
269  filterproduct.addObject(TriggerCluster,ref);
270  }
271  }
272 
273  // error case
274  // filterproduct.addObject(0,Ref<vector<int> >());
275 
276  // final filter decision:
277  const bool accept ( (nphot>0) && (nelec>0) && (nmuon>0) && (ntaus>0) &&
278  // (njets>0) && (nmets>0) && (nmhts>=0) && (ntrck>0) && (necal>0) );
279  (njets>0) && (nmets>0) && (ntrck>0) && (necal>0) );
280 
281  LogDebug("") << "Number of g/e/m/t/j/M/H/TR/SC objects accepted:"
282  << " " << nphot
283  << " " << nelec
284  << " " << nmuon
285  << " " << ntaus
286  << " " << njets
287  << " " << nmets
288  << " " << nmhts
289  << " " << ntrck
290  << " " << necal
291  ;
292 
293  // return with final filter decision
294  return accept;
295 }
#define LogDebug(id)
edm::InputTag elecTag_
Definition: HLTFiltCand.h:46
edm::EDGetTokenT< reco::RecoChargedCandidateCollection > trckToken_
Definition: HLTFiltCand.h:62
edm::InputTag muonTag_
Definition: HLTFiltCand.h:47
HLTFiltCand(const edm::ParameterSet &)
Definition: HLTFiltCand.cc:44
edm::EDGetTokenT< reco::CaloMETCollection > metsToken_
Definition: HLTFiltCand.h:60
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
edm::EDGetTokenT< reco::ElectronCollection > elecToken_
Definition: HLTFiltCand.h:56
edm::Ref< RecoChargedCandidateCollection > RecoChargedCandidateRef
reference to an object in a collection of RecoChargedCandidate objects
edm::Ref< RecoEcalCandidateCollection > RecoEcalCandidateRef
reference to an object in a collection of RecoEcalCandidate objects
edm::EDGetTokenT< reco::RecoChargedCandidateCollection > muonToken_
Definition: HLTFiltCand.h:57
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:24
edm::Ref< ElectronCollection > ElectronRef
reference to an object in a collection of Electron objects
Definition: ElectronFwd.h:15
std::string encode() const
Definition: InputTag.cc:164
void addObject(int id, const reco::RecoEcalCandidateRef &ref)
setters for L3 collections: (id=physics type, and Ref&lt;C&gt;)
Collection of Calo MET.
edm::EDGetTokenT< reco::RecoEcalCandidateCollection > photToken_
Definition: HLTFiltCand.h:55
int iEvent
Definition: GenABIO.cc:230
edm::InputTag mhtsTag_
Definition: HLTFiltCand.h:51
vector< PseudoJet > jets
edm::InputTag metsTag_
Definition: HLTFiltCand.h:50
edm::EDGetTokenT< reco::CaloJetCollection > tausToken_
Definition: HLTFiltCand.h:58
Collection of MET.
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::vector< Electron > ElectronCollection
collectin of Electron objects
Definition: ElectronFwd.h:9
edm::Ref< CaloJetCollection > CaloJetRef
edm references
edm::EDGetTokenT< reco::CaloJetCollection > jetsToken_
Definition: HLTFiltCand.h:59
std::vector< RecoChargedCandidate > RecoChargedCandidateCollection
collectin of RecoChargedCandidate objects
edm::InputTag photTag_
Definition: HLTFiltCand.h:45
static void makeHLTFilterDescription(edm::ParameterSetDescription &desc)
Definition: HLTFilter.cc:29
edm::EDGetTokenT< reco::RecoEcalCandidateCollection > ecalToken_
Definition: HLTFiltCand.h:63
void addCollectionTag(const edm::InputTag &collectionTag)
collectionTags
void add(std::string const &label, ParameterSetDescription const &psetDescription)
virtual bool hltFilter(edm::Event &, const edm::EventSetup &, trigger::TriggerFilterObjectWithRefs &filterproduct) const override
Definition: HLTFiltCand.cc:105
std::vector< RecoEcalCandidate > RecoEcalCandidateCollection
collectin of RecoEcalCandidate objects
bool saveTags() const
Definition: HLTFilter.h:45
tuple muons
Definition: patZpeak.py:38
edm::InputTag jetsTag_
Definition: HLTFiltCand.h:49
edm::InputTag ecalTag_
Definition: HLTFiltCand.h:53
edm::EDGetTokenT< reco::METCollection > mhtsToken_
Definition: HLTFiltCand.h:61
edm::Ref< CaloMETCollection > CaloMETRef
edm references
Definition: CaloMETFwd.h:13
edm::Ref< METCollection > METRef
edm references
Definition: METFwd.h:13
double min_Pt_
Definition: HLTFiltCand.h:65
edm::InputTag tausTag_
Definition: HLTFiltCand.h:48
edm::InputTag trckTag_
Definition: HLTFiltCand.h:52
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HLTFiltCand.cc:87
std::vector< CaloJet > CaloJetCollection
collection of CaloJet objects