CMS 3D CMS Logo

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