CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
TriggerObjectTableProducer Class Reference
Inheritance diagram for TriggerObjectTableProducer:
edm::stream::EDProducer<>

Classes

struct  SelectedObject
 

Public Member Functions

 TriggerObjectTableProducer (const edm::ParameterSet &iConfig)
 
 ~TriggerObjectTableProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Member Functions

void produce (edm::Event &, edm::EventSetup const &) override
 

Private Attributes

std::string bitsDoc_
 
std::string idDoc_
 
edm::EDGetTokenT< l1t::EGammaBxCollectionl1EG_
 
edm::EDGetTokenT< l1t::JetBxCollectionl1Jet_
 
edm::EDGetTokenT< l1t::MuonBxCollectionl1Muon_
 
edm::EDGetTokenT< l1t::EtSumBxCollectionl1Sum_
 
edm::EDGetTokenT< l1t::TauBxCollectionl1Tau_
 
std::string name_
 
std::vector< SelectedObjectsels_
 
edm::EDGetTokenT< std::vector< pat::TriggerObjectStandAlone > > src_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 27 of file TriggerObjectTableProducer.cc.

Constructor & Destructor Documentation

◆ TriggerObjectTableProducer()

TriggerObjectTableProducer::TriggerObjectTableProducer ( const edm::ParameterSet iConfig)
inlineexplicit

Definition at line 29 of file TriggerObjectTableProducer.cc.

References bitsDoc_, edm::ParameterSet::getParameter(), idDoc_, muonDTDigis_cfi::pset, and sels_.

30  : name_(iConfig.getParameter<std::string>("name")),
31  src_(consumes<std::vector<pat::TriggerObjectStandAlone>>(iConfig.getParameter<edm::InputTag>("src"))),
32  l1EG_(consumes<l1t::EGammaBxCollection>(iConfig.getParameter<edm::InputTag>("l1EG"))),
33  l1Sum_(consumes<l1t::EtSumBxCollection>(iConfig.getParameter<edm::InputTag>("l1Sum"))),
34  l1Jet_(consumes<l1t::JetBxCollection>(iConfig.getParameter<edm::InputTag>("l1Jet"))),
35  l1Muon_(consumes<l1t::MuonBxCollection>(iConfig.getParameter<edm::InputTag>("l1Muon"))),
36  l1Tau_(consumes<l1t::TauBxCollection>(iConfig.getParameter<edm::InputTag>("l1Tau"))) {
37  std::vector<edm::ParameterSet> selPSets = iConfig.getParameter<std::vector<edm::ParameterSet>>("selections");
38  sels_.reserve(selPSets.size());
39  std::stringstream idstr, qualitystr;
40  idstr << "ID of the object: ";
41  for (auto &pset : selPSets) {
42  sels_.emplace_back(pset);
43  idstr << sels_.back().id << " = " << sels_.back().name;
44  if (sels_.size() < selPSets.size())
45  idstr << ", ";
46  if (!sels_.back().qualityBitsDoc.empty()) {
47  qualitystr << sels_.back().qualityBitsDoc << " for " << sels_.back().name << "; ";
48  }
49  }
50  idDoc_ = idstr.str();
51  bitsDoc_ = qualitystr.str();
52 
53  produces<nanoaod::FlatTable>();
54  }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::EDGetTokenT< l1t::JetBxCollection > l1Jet_
edm::EDGetTokenT< std::vector< pat::TriggerObjectStandAlone > > src_
edm::EDGetTokenT< l1t::MuonBxCollection > l1Muon_
edm::EDGetTokenT< l1t::TauBxCollection > l1Tau_
std::vector< SelectedObject > sels_
edm::EDGetTokenT< l1t::EGammaBxCollection > l1EG_
edm::EDGetTokenT< l1t::EtSumBxCollection > l1Sum_

◆ ~TriggerObjectTableProducer()

TriggerObjectTableProducer::~TriggerObjectTableProducer ( )
inlineoverride

Definition at line 56 of file TriggerObjectTableProducer.cc.

56 {}

Member Function Documentation

◆ produce()

void TriggerObjectTableProducer::produce ( edm::Event iEvent,
edm::EventSetup const &  iSetup 
)
overrideprivate

Definition at line 115 of file TriggerObjectTableProducer.cc.

References funct::abs(), gpuClustering::pixelStatus::bits, bitsDoc_, HLTMuonOfflineAnalyzer_cfi::deltaR2, MillePedeFileConverter_cfg::e, PVValHelper::eta, mps_fire::i, triggerObjects_cff::id, idDoc_, iEvent, createfilelist::int, dqmiolumiharvest::j, L1Analysis::kMissingEt, L1Analysis::kMissingEtHF, L1Analysis::kMissingHt, L1Analysis::kMissingHtHF, L1Analysis::kTotalEt, L1Analysis::kTotalEtEm, L1Analysis::kTotalHt, L1Analysis::kTotalHtHF, triggerObjects_cff::l1EG, l1EG_, triggerObjects_cff::l1Jet, l1Jet_, triggerObjects_cff::l1Muon, l1Muon_, triggerObjects_cff::l1Sum, l1Sum_, triggerObjects_cff::l1Tau, l1Tau_, eostools::move(), name_, getGTfromDQMFile::obj, phi, DiDispStaMuonMonitor_cfi::pt, fileCollector::seed, EgammaValidation_Wenu_cff::sel, sels_, pat::TriggerObject::setCollection(), TrackRefitter_38T_cff::src, src_, trigger::TriggerL1EG, trigger::TriggerL1ETM, trigger::TriggerL1ETT, trigger::TriggerL1HTM, trigger::TriggerL1HTT, trigger::TriggerL1Jet, trigger::TriggerL1Mu, and trigger::TriggerL1Tau.

115  {
117  iEvent.getByToken(src_, src);
118 
119  std::vector<std::pair<const pat::TriggerObjectStandAlone *, const SelectedObject *>> selected;
120  for (const auto &obj : *src) {
121  for (const auto &sel : sels_) {
122  if (sel.match(obj) && (sel.skipObjectsNotPassingQualityBits ? (int(sel.qualityBits(obj)) > 0) : true)) {
123  selected.emplace_back(&obj, &sel);
124  // cave canem: the object will be taken by whichever selection it matches first, so it
125  // depends on the order of the selections in the VPSet
126  break;
127  }
128  }
129  }
130 
131  // Self-cleaning
132  std::map<const pat::TriggerObjectStandAlone *, int> selected_bits;
133  for (unsigned int i = 0; i < selected.size(); ++i) {
134  const auto &obj = *selected[i].first;
135  const auto &sel = *selected[i].second;
136  selected_bits[&obj] = int(sel.qualityBits(obj));
137 
138  for (unsigned int j = 0; j < i; ++j) {
139  const auto &obj2 = *selected[j].first;
140  const auto &sel2 = *selected[j].second;
141  if (sel.id == sel2.id && abs(obj.pt() - obj2.pt()) < 1e-6 && deltaR2(obj, obj2) < 1e-6) {
142  selected_bits[&obj2] |= selected_bits[&obj]; //Keep filters from all the objects
143  selected.erase(selected.begin() + i);
144  i--;
145  }
146  }
147  }
148 
154  iEvent.getByToken(l1EG_, l1EG);
155  iEvent.getByToken(l1Sum_, l1Sum);
156  iEvent.getByToken(l1Jet_, l1Jet);
157  iEvent.getByToken(l1Muon_, l1Muon);
158  iEvent.getByToken(l1Tau_, l1Tau);
159 
160  std::vector<pair<pat::TriggerObjectStandAlone, int>> l1Objects;
161 
162  for (l1t::EGammaBxCollection::const_iterator it = l1EG->begin(0); it != l1EG->end(0); it++) {
163  pat::TriggerObjectStandAlone l1obj(it->p4());
164  l1obj.setCollection("L1EG");
165  l1obj.addTriggerObjectType(trigger::TriggerL1EG);
166  l1Objects.emplace_back(l1obj, it->hwIso());
167  }
168 
169  for (l1t::EtSumBxCollection::const_iterator it = l1Sum->begin(0); it != l1Sum->end(0); it++) {
170  pat::TriggerObjectStandAlone l1obj(it->p4());
171 
172  switch (it->getType()) {
174  l1obj.addTriggerObjectType(trigger::TriggerL1ETM);
175  l1obj.setCollection("L1ETM");
176  break;
177 
179  l1obj.addTriggerObjectType(trigger::TriggerL1ETM);
180  l1obj.setCollection("L1ETMHF");
181  break;
182 
184  l1obj.addTriggerObjectType(trigger::TriggerL1ETT);
185  l1obj.setCollection("L1ETT");
186  break;
187 
189  l1obj.addTriggerObjectType(trigger::TriggerL1ETT);
190  l1obj.setCollection("L1ETEm");
191  break;
192 
194  l1obj.addTriggerObjectType(trigger::TriggerL1HTT);
195  l1obj.setCollection("L1HTT");
196  break;
197 
199  l1obj.addTriggerObjectType(trigger::TriggerL1HTT);
200  l1obj.setCollection("L1HTTHF");
201  break;
202 
204  l1obj.addTriggerObjectType(trigger::TriggerL1HTM);
205  l1obj.setCollection("L1HTM");
206  break;
207 
209  l1obj.addTriggerObjectType(trigger::TriggerL1HTM);
210  l1obj.setCollection("L1HTMHF");
211  break;
212 
213  default:
214  continue;
215  }
216 
217  l1Objects.emplace_back(l1obj, it->hwIso());
218  }
219 
220  for (l1t::JetBxCollection::const_iterator it = l1Jet->begin(0); it != l1Jet->end(0); it++) {
221  pat::TriggerObjectStandAlone l1obj(it->p4());
222  l1obj.setCollection("L1Jet");
223  l1obj.addTriggerObjectType(trigger::TriggerL1Jet);
224  l1Objects.emplace_back(l1obj, it->hwIso());
225  }
226 
227  for (l1t::MuonBxCollection::const_iterator it = l1Muon->begin(0); it != l1Muon->end(0); it++) {
228  pat::TriggerObjectStandAlone l1obj(it->p4());
229  l1obj.setCollection("L1Mu");
230  l1obj.addTriggerObjectType(trigger::TriggerL1Mu);
231  l1obj.setCharge(it->charge());
232  l1Objects.emplace_back(l1obj, it->hwIso());
233  }
234 
235  for (l1t::TauBxCollection::const_iterator it = l1Tau->begin(0); it != l1Tau->end(0); it++) {
236  pat::TriggerObjectStandAlone l1obj(it->p4());
237  l1obj.setCollection("L1Tau");
238  l1obj.addTriggerObjectType(trigger::TriggerL1Tau);
239  l1Objects.emplace_back(l1obj, it->hwIso());
240  }
241 
242  unsigned int nobj = selected.size();
243  std::vector<float> pt(nobj, 0), eta(nobj, 0), phi(nobj, 0), l1pt(nobj, 0), l1pt_2(nobj, 0), l2pt(nobj, 0);
244  std::vector<int> id(nobj, 0), bits(nobj, 0), l1iso(nobj, 0), l1charge(nobj, 0);
245  for (unsigned int i = 0; i < nobj; ++i) {
246  const auto &obj = *selected[i].first;
247  const auto &sel = *selected[i].second;
248  pt[i] = obj.pt();
249  eta[i] = obj.eta();
250  phi[i] = obj.phi();
251  id[i] = sel.id;
252  bits[i] = selected_bits[&obj];
253  if (sel.l1DR2 > 0) {
254  float best = sel.l1DR2;
255  for (const auto &l1obj : l1Objects) {
256  const auto &seed = l1obj.first;
257  float dr2 = deltaR2(seed, obj);
258  if (dr2 < best && sel.l1cut(seed)) {
259  best = dr2;
260  l1pt[i] = seed.pt();
261  l1iso[i] = l1obj.second;
262  l1charge[i] = seed.charge();
263  }
264  }
265  }
266  if (sel.l1DR2_2 > 0) {
267  float best = sel.l1DR2_2;
268  for (const auto &l1obj : l1Objects) {
269  const auto &seed = l1obj.first;
270  float dr2 = deltaR2(seed, obj);
271  if (dr2 < best && sel.l1cut_2(seed)) {
272  best = dr2;
273  l1pt_2[i] = seed.pt();
274  }
275  }
276  }
277  if (sel.l2DR2 > 0) {
278  float best = sel.l2DR2;
279  for (const auto &seed : *src) {
280  float dr2 = deltaR2(seed, obj);
281  if (dr2 < best && sel.l2cut(seed)) {
282  best = dr2;
283  l2pt[i] = seed.pt();
284  }
285  }
286  }
287  }
288 
289  auto tab = std::make_unique<nanoaod::FlatTable>(nobj, name_, false, false);
290  tab->addColumn<int>("id", id, idDoc_);
291  tab->addColumn<float>("pt", pt, "pt", 12);
292  tab->addColumn<float>("eta", eta, "eta", 12);
293  tab->addColumn<float>("phi", phi, "phi", 12);
294  tab->addColumn<float>("l1pt", l1pt, "pt of associated L1 seed", 8);
295  tab->addColumn<int>("l1iso", l1iso, "iso of associated L1 seed");
296  tab->addColumn<int>("l1charge", l1charge, "charge of associated L1 seed");
297  tab->addColumn<float>("l1pt_2", l1pt_2, "pt of associated secondary L1 seed", 8);
298  tab->addColumn<float>("l2pt", l2pt, "pt of associated 'L2' seed (i.e. HLT before tracking/PF)", 10);
299  tab->addColumn<int>("filterBits", bits, "extra bits of associated information: " + bitsDoc_);
300  iEvent.put(std::move(tab));
301 }
enum start value shifted to 81 so as to avoid clashes with PDG codes
constexpr uint32_t bits
Definition: gpuClustering.h:23
edm::EDGetTokenT< l1t::JetBxCollection > l1Jet_
std::vector< T >::const_iterator const_iterator
Definition: BXVector.h:18
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< std::vector< pat::TriggerObjectStandAlone > > src_
void setCollection(const std::string &collName)
Methods.
Definition: TriggerObject.h:79
edm::EDGetTokenT< l1t::MuonBxCollection > l1Muon_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::EDGetTokenT< l1t::TauBxCollection > l1Tau_
std::vector< SelectedObject > sels_
edm::EDGetTokenT< l1t::EGammaBxCollection > l1EG_
edm::EDGetTokenT< l1t::EtSumBxCollection > l1Sum_
def move(src, dest)
Definition: eostools.py:511
Analysis-level trigger object class (stand-alone)

Member Data Documentation

◆ bitsDoc_

std::string TriggerObjectTableProducer::bitsDoc_
private

Definition at line 63 of file TriggerObjectTableProducer.cc.

Referenced by produce(), and TriggerObjectTableProducer().

◆ idDoc_

std::string TriggerObjectTableProducer::idDoc_
private

Definition at line 63 of file TriggerObjectTableProducer.cc.

Referenced by produce(), and TriggerObjectTableProducer().

◆ l1EG_

edm::EDGetTokenT<l1t::EGammaBxCollection> TriggerObjectTableProducer::l1EG_
private

Definition at line 65 of file TriggerObjectTableProducer.cc.

Referenced by produce().

◆ l1Jet_

edm::EDGetTokenT<l1t::JetBxCollection> TriggerObjectTableProducer::l1Jet_
private

Definition at line 67 of file TriggerObjectTableProducer.cc.

Referenced by produce().

◆ l1Muon_

edm::EDGetTokenT<l1t::MuonBxCollection> TriggerObjectTableProducer::l1Muon_
private

Definition at line 68 of file TriggerObjectTableProducer.cc.

Referenced by produce().

◆ l1Sum_

edm::EDGetTokenT<l1t::EtSumBxCollection> TriggerObjectTableProducer::l1Sum_
private

Definition at line 66 of file TriggerObjectTableProducer.cc.

Referenced by produce().

◆ l1Tau_

edm::EDGetTokenT<l1t::TauBxCollection> TriggerObjectTableProducer::l1Tau_
private

Definition at line 69 of file TriggerObjectTableProducer.cc.

Referenced by produce().

◆ name_

std::string TriggerObjectTableProducer::name_
private

Definition at line 61 of file TriggerObjectTableProducer.cc.

Referenced by produce().

◆ sels_

std::vector<SelectedObject> TriggerObjectTableProducer::sels_
private

Definition at line 111 of file TriggerObjectTableProducer.cc.

Referenced by produce(), and TriggerObjectTableProducer().

◆ src_

edm::EDGetTokenT<std::vector<pat::TriggerObjectStandAlone> > TriggerObjectTableProducer::src_
private

Definition at line 62 of file TriggerObjectTableProducer.cc.

Referenced by produce().