CMS 3D CMS Logo

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);
134  iEvent.getByToken(elecToken_, electrons);
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 }
ConfigurationDescriptions.h
HLTFiltCand::trckToken_
edm::EDGetTokenT< reco::RecoChargedCandidateCollection > trckToken_
Definition: HLTFiltCand.h:63
trigger::TriggerRefsCollections::addObject
void addObject(int id, const reco::RecoEcalCandidateRef &ref)
setters for L3 collections: (id=physics type, and Ref<C>)
Definition: TriggerRefsCollections.h:235
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
reco::CaloMETRef
edm::Ref< CaloMETCollection > CaloMETRef
edm references
Definition: CaloMETFwd.h:13
trigger::TriggerFilterObjectWithRefs
Definition: TriggerFilterObjectWithRefs.h:35
CaloJetCollection.h
GenJetCollection.h
reco::RecoEcalCandidateCollection
std::vector< RecoEcalCandidate > RecoEcalCandidateCollection
collectin of RecoEcalCandidate objects
Definition: RecoEcalCandidateFwd.h:9
Handle.h
HLTFiltCand::muonTag_
edm::InputTag muonTag_
Definition: HLTFiltCand.h:48
CaloJet.h
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
trigger::TriggerElectron
Definition: TriggerTypeDefs.h:67
MessageLogger.h
CompositeCandidate.h
HLTFiltCand::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HLTFiltCand.cc:77
HLTFiltCand::muonToken_
edm::EDGetTokenT< reco::RecoChargedCandidateCollection > muonToken_
Definition: HLTFiltCand.h:58
GenMETCollection.h
Tau3MuMonitor_cff.taus
taus
Definition: Tau3MuMonitor_cff.py:7
edm
HLT enums.
Definition: AlignableModifier.h:19
HLTFiltCand::elecTag_
edm::InputTag elecTag_
Definition: HLTFiltCand.h:47
trigger::TriggerTau
Definition: TriggerTypeDefs.h:69
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
trigger::TriggerFilterObjectWithRefs::addCollectionTag
void addCollectionTag(const edm::InputTag &collectionTag)
collectionTags
Definition: TriggerFilterObjectWithRefs.h:55
HLTFiltCand::metsToken_
edm::EDGetTokenT< reco::CaloMETCollection > metsToken_
Definition: HLTFiltCand.h:61
HLT_2018_cff.distance
distance
Definition: HLT_2018_cff.py:6417
TriggerFilterObjectWithRefs.h
trigger::TriggerMHT
Definition: TriggerTypeDefs.h:75
trigger::TriggerTrack
Definition: TriggerTypeDefs.h:76
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
reco::RecoChargedCandidateRef
edm::Ref< RecoChargedCandidateCollection > RecoChargedCandidateRef
reference to an object in a collection of RecoChargedCandidate objects
Definition: RecoChargedCandidateFwd.h:15
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
singleTopDQM_cfi.mets
mets
Definition: singleTopDQM_cfi.py:43
HLTFiltCand::photToken_
edm::EDGetTokenT< reco::RecoEcalCandidateCollection > photToken_
Definition: HLTFiltCand.h:56
edm::Handle
Definition: AssociativeIterator.h:50
HLTFilter
Definition: HLTFilter.h:28
reco::ElectronRef
edm::Ref< ElectronCollection > ElectronRef
reference to an object in a collection of Electron objects
Definition: ElectronFwd.h:15
CaloMETFwd.h
reco::RecoChargedCandidateCollection
std::vector< RecoChargedCandidate > RecoChargedCandidateCollection
collectin of RecoChargedCandidate objects
Definition: RecoChargedCandidateFwd.h:9
edm::Ref
Definition: AssociativeIterator.h:58
HLTFiltCand::elecToken_
edm::EDGetTokenT< reco::ElectronCollection > elecToken_
Definition: HLTFiltCand.h:57
accept
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:30
trigger::TriggerMET
Definition: TriggerTypeDefs.h:72
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
CaloMET.h
trigger::TriggerMuon
Definition: TriggerTypeDefs.h:68
TauSpinnerFilter_cfi.ntaus
ntaus
Definition: TauSpinnerFilter_cfi.py:5
HLTFiltCand::metsTag_
edm::InputTag metsTag_
Definition: HLTFiltCand.h:51
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
HLTFiltCand::photTag_
edm::InputTag photTag_
Definition: HLTFiltCand.h:46
GenMET.h
CompositeCandidateFwd.h
ElectronFwd.h
HLTFiltCand::ecalToken_
edm::EDGetTokenT< reco::RecoEcalCandidateCollection > ecalToken_
Definition: HLTFiltCand.h:64
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
HLTFilter::saveTags
bool saveTags() const
Definition: HLTFilter.h:46
HLTFiltCand::tausToken_
edm::EDGetTokenT< reco::CaloJetCollection > tausToken_
Definition: HLTFiltCand.h:59
reco::RecoEcalCandidateRef
edm::Ref< RecoEcalCandidateCollection > RecoEcalCandidateRef
reference to an object in a collection of RecoEcalCandidate objects
Definition: RecoEcalCandidateFwd.h:15
HLTFiltCand::mhtsTag_
edm::InputTag mhtsTag_
Definition: HLTFiltCand.h:52
iEvent
int iEvent
Definition: GenABIO.cc:224
reco::CaloJetCollection
std::vector< CaloJet > CaloJetCollection
collection of CaloJet objects
Definition: CaloJetCollection.h:15
reco::METRef
edm::Ref< METCollection > METRef
edm references
Definition: METFwd.h:13
HLTFiltCand::jetsTag_
edm::InputTag jetsTag_
Definition: HLTFiltCand.h:50
edm::InputTag::encode
std::string encode() const
Definition: InputTag.cc:159
BPHMonitor_cfi.photons
photons
Definition: BPHMonitor_cfi.py:91
edm::EventSetup
Definition: EventSetup.h:57
HLTFiltCand::ecalTag_
edm::InputTag ecalTag_
Definition: HLTFiltCand.h:54
trigger::TriggerCluster
Definition: TriggerTypeDefs.h:77
reco::ElectronCollection
std::vector< Electron > ElectronCollection
collectin of Electron objects
Definition: ElectronFwd.h:9
HLTFiltCand::mhtsToken_
edm::EDGetTokenT< reco::METCollection > mhtsToken_
Definition: HLTFiltCand.h:62
MET.h
Electron.h
std
Definition: JetResolutionObject.h:76
Ref.h
RecoEcalCandidate.h
pwdgSkimBPark_cfi.electrons
electrons
Definition: pwdgSkimBPark_cfi.py:6
HLTFiltCand::jetsToken_
edm::EDGetTokenT< reco::CaloJetCollection > jetsToken_
Definition: HLTFiltCand.h:60
BTaggingMonitoring_cff.njets
njets
Definition: BTaggingMonitoring_cff.py:10
RecoChargedCandidate.h
METFwd.h
HLTFiltCand::trckTag_
edm::InputTag trckTag_
Definition: HLTFiltCand.h:53
HLTFilter::makeHLTFilterDescription
static void makeHLTFilterDescription(edm::ParameterSetDescription &desc)
Definition: HLTFilter.cc:25
HLTFiltCand::min_Pt_
double min_Pt_
Definition: HLTFiltCand.h:66
RecoEcalCandidateFwd.h
trigger
Definition: HLTPrescaleTableCond.h:8
HLTFiltCand::tausTag_
edm::InputTag tausTag_
Definition: HLTFiltCand.h:49
reco::CaloJetRef
edm::Ref< CaloJetCollection > CaloJetRef
edm references
Definition: CaloJetCollection.h:17
METCollection
Collection of MET.
CaloMETCollection
Collection of Calo MET.
GenJet.h
HLTFiltCand::hltFilter
bool hltFilter(edm::Event &, const edm::EventSetup &, trigger::TriggerFilterObjectWithRefs &filterproduct) const override
Definition: HLTFiltCand.cc:94
trigger::TriggerPhoton
HLT.
Definition: TriggerTypeDefs.h:66
HLTFiltCand::~HLTFiltCand
~HLTFiltCand() override
edm::Event
Definition: Event.h:73
RecoChargedCandidateFwd.h
edm::InputTag
Definition: InputTag.h:15
HLTFiltCand.h
HLTFiltCand::HLTFiltCand
HLTFiltCand(const edm::ParameterSet &)
Definition: HLTFiltCand.cc:44
trigger::TriggerJet
Definition: TriggerTypeDefs.h:70