CMS 3D CMS Logo

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 
78 HLTFiltCand::~HLTFiltCand() = default;
79 
80 //
81 // member functions
82 //
83 
84 void
88  desc.add<edm::InputTag>("photTag",edm::InputTag("photCollection"));
89  desc.add<edm::InputTag>("elecTag",edm::InputTag("elecCollection"));
90  desc.add<edm::InputTag>("muonTag",edm::InputTag("muonCollection"));
91  desc.add<edm::InputTag>("tausTag",edm::InputTag("tausCollection"));
92  desc.add<edm::InputTag>("jetsTag",edm::InputTag("jetsCollection"));
93  desc.add<edm::InputTag>("metsTag",edm::InputTag("metsCollection"));
94  desc.add<edm::InputTag>("mhtsTag",edm::InputTag("mhtsCollection"));
95  desc.add<edm::InputTag>("trckTag",edm::InputTag("trckCollection"));
96  desc.add<edm::InputTag>("ecalTag",edm::InputTag("ecalCollection"));
97  desc.add<double>("MinPt",-1.0);
98  descriptions.add("hltFiltCand", desc);
99 }
100 
101 // ------------ method called to produce the data ------------
102 bool
104 {
105  using namespace std;
106  using namespace edm;
107  using namespace reco;
108  using namespace trigger;
109 
110  // All HLT filters must create and fill an HLT filter object,
111  // recording any reconstructed physics objects satisfying (or not)
112  // this HLT filter, and place it in the Event.
113 
114  // The filter object
115  if (saveTags()) {
116  filterproduct.addCollectionTag(photTag_);
117  filterproduct.addCollectionTag(elecTag_);
118  filterproduct.addCollectionTag(muonTag_);
119  filterproduct.addCollectionTag(tausTag_);
120  filterproduct.addCollectionTag(jetsTag_);
121  filterproduct.addCollectionTag(metsTag_);
122  filterproduct.addCollectionTag(mhtsTag_);
123  filterproduct.addCollectionTag(trckTag_);
124  filterproduct.addCollectionTag(ecalTag_);
125  }
126 
127  // Specific filter code
128 
129  // get hold of products from Event
130 
140 
141  iEvent.getByToken(photToken_,photons );
142  iEvent.getByToken(elecToken_,electrons);
143  iEvent.getByToken(muonToken_,muons );
144  iEvent.getByToken(tausToken_,taus );
145  iEvent.getByToken(jetsToken_,jets );
146  iEvent.getByToken(metsToken_,mets );
147  iEvent.getByToken(mhtsToken_,mhts );
148  iEvent.getByToken(trckToken_,trcks );
149  iEvent.getByToken(ecalToken_,ecals );
150 
151 
152  // look for at least one g,e,m,t,j,M,H,TR,SC above its pt cut
153 
154  // photons
155  int nphot(0);
156  auto aphot(photons->begin());
157  auto ophot(photons->end());
158  RecoEcalCandidateCollection::const_iterator iphot;
159  for (iphot=aphot; iphot!=ophot; iphot++) {
160  if (iphot->pt() >= min_Pt_) {
161  nphot++;
162  RecoEcalCandidateRef ref(RecoEcalCandidateRef(photons,distance(aphot,iphot)));
163  filterproduct.addObject(TriggerPhoton,ref);
164  }
165  }
166 
167  // electrons
168  int nelec(0);
169  auto aelec(electrons->begin());
170  auto oelec(electrons->end());
171  ElectronCollection::const_iterator ielec;
172  for (ielec=aelec; ielec!=oelec; ielec++) {
173  if (ielec->pt() >= min_Pt_) {
174  nelec++;
175  ElectronRef ref(ElectronRef(electrons,distance(aelec,ielec)));
176  filterproduct.addObject(-TriggerElectron,ref);
177  }
178  }
179 
180  // muon
181  int nmuon(0);
182  auto amuon(muons->begin());
183  auto omuon(muons->end());
184  RecoChargedCandidateCollection::const_iterator imuon;
185  for (imuon=amuon; imuon!=omuon; imuon++) {
186  if (imuon->pt() >= min_Pt_) {
187  nmuon++;
189  filterproduct.addObject(TriggerMuon,ref);
190  }
191  }
192 
193  // taus (are stored as jets)
194  int ntaus(0);
195  auto ataus(taus->begin());
196  auto otaus(taus->end());
197  CaloJetCollection::const_iterator itaus;
198  for (itaus=ataus; itaus!=otaus; itaus++) {
199  if (itaus->pt() >= min_Pt_) {
200  ntaus++;
201  CaloJetRef ref(CaloJetRef(taus,distance(ataus,itaus)));
202  filterproduct.addObject(-TriggerTau,ref);
203  }
204  }
205 
206  // jets
207  int njets(0);
208  auto ajets(jets->begin());
209  auto ojets(jets->end());
210  CaloJetCollection::const_iterator ijets;
211  for (ijets=ajets; ijets!=ojets; ijets++) {
212  if (ijets->pt() >= min_Pt_) {
213  njets++;
214  CaloJetRef ref(CaloJetRef(jets,distance(ajets,ijets)));
215  filterproduct.addObject(TriggerJet,ref);
216  }
217  }
218 
219  // mets
220  int nmets(0);
221  auto amets(mets->begin());
222  auto omets(mets->end());
223  CaloMETCollection::const_iterator imets;
224  for (imets=amets; imets!=omets; imets++) {
225  if (imets->pt() >= min_Pt_) {
226  nmets++;
227  CaloMETRef ref(CaloMETRef(mets,distance(amets,imets)));
228  filterproduct.addObject(TriggerMET,ref);
229  }
230  }
231 
232  // mhts
233  int nmhts(0);
234  auto amhts(mhts->begin());
235  auto omhts(mhts->end());
236  METCollection::const_iterator imhts;
237  for (imhts=amhts; imhts!=omhts; imhts++) {
238  if (imhts->pt() >= min_Pt_) {
239  nmhts++;
240  METRef ref(METRef(mhts,distance(amhts,imhts)));
241  filterproduct.addObject(TriggerMHT,ref);
242  }
243  }
244 
245  // trcks
246  int ntrck(0);
247  auto atrcks(trcks->begin());
248  auto otrcks(trcks->end());
249  RecoChargedCandidateCollection::const_iterator itrcks;
250  for (itrcks=atrcks; itrcks!=otrcks; itrcks++) {
251  if (itrcks->pt() >= min_Pt_) {
252  ntrck++;
253  RecoChargedCandidateRef ref(RecoChargedCandidateRef(trcks,distance(atrcks,itrcks)));
254  filterproduct.addObject(TriggerTrack,ref);
255  }
256  }
257 
258  // ecals
259  int necal(0);
260  auto aecals(ecals->begin());
261  auto oecals(ecals->end());
262  RecoEcalCandidateCollection::const_iterator iecals;
263  for (iecals=aecals; iecals!=oecals; iecals++) {
264  if (iecals->pt() >= min_Pt_) {
265  necal++;
266  RecoEcalCandidateRef ref(RecoEcalCandidateRef(ecals,distance(aecals,iecals)));
267  filterproduct.addObject(TriggerCluster,ref);
268  }
269  }
270 
271  // error case
272  // filterproduct.addObject(0,Ref<vector<int> >());
273 
274  // final filter decision:
275  const bool accept ( (nphot>0) && (nelec>0) && (nmuon>0) && (ntaus>0) &&
276  // (njets>0) && (nmets>0) && (nmhts>=0) && (ntrck>0) && (necal>0) );
277  (njets>0) && (nmets>0) && (ntrck>0) && (necal>0) );
278 
279  LogDebug("") << "Number of g/e/m/t/j/M/H/TR/SC objects accepted:"
280  << " " << nphot
281  << " " << nelec
282  << " " << nmuon
283  << " " << ntaus
284  << " " << njets
285  << " " << nmets
286  << " " << nmhts
287  << " " << ntrck
288  << " " << necal
289  ;
290 
291  // return with final filter decision
292  return accept;
293 }
#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:457
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:30
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:165
void addObject(int id, const reco::RecoEcalCandidateRef &ref)
setters for L3 collections: (id=physics type, and Ref<C>)
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
virtual bool hltFilter(edm::Event &, const edm::EventSetup &, trigger::TriggerFilterObjectWithRefs &filterproduct) const override
Definition: HLTFiltCand.cc:103
void addCollectionTag(const edm::InputTag &collectionTag)
collectionTags
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< RecoEcalCandidate > RecoEcalCandidateCollection
collectin of RecoEcalCandidate objects
fixed size matrix
bool saveTags() const
Definition: HLTFilter.h:45
HLT enums.
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:85
std::vector< CaloJet > CaloJetCollection
collection of CaloJet objects