CMS 3D CMS Logo

CSCTriggerPrimitivesProducer.cc
Go to the documentation of this file.
1 #ifndef L1Trigger_CSCTriggerPrimitives_CSCTriggerPrimitivesProducer_h
2 #define L1Trigger_CSCTriggerPrimitives_CSCTriggerPrimitivesProducer_h
3 
34 
57 
58 // temporarily switch to a "one" module with a CSCTriggerPrimitivesBuilder data member
60 public:
63 
64  void produce(edm::Event&, const edm::EventSetup&) override;
65 
66 private:
67  // master configuration
69 
70  // temporarily switch to a "one" module with a CSCTriggerPrimitivesBuilder data member
71  std::unique_ptr<CSCTriggerPrimitivesBuilder> builder_;
72 
73  // input tags for input collections
77 
78  // tokens
89  // switch to force the use of parameters from config file rather then from DB
91 
92  // switch to for enabling checking against the list of bad chambers
94 
95  // Write out pre-triggers
98 
99  // write out showrs
101 
102  // switches to enable the Run-3 pattern finding
103  bool runCCLUT_; // 'OR' of the two options below
104  bool runCCLUT_TMB_; // ME1/2, ME1/3, ME2/2, ME3/2, ME4/2
105  bool runCCLUT_OTMB_; // ME1/1, ME2/1, ME3/1, ME4/1
106 
107  bool runILT_; // // 'OR' of the two options below
110 };
111 
112 #endif
113 
115  config_ = conf;
116 
117  // if false, parameters will be read in from DB using EventSetup mechanism
118  // else will use all parameters from the config file
119  debugParameters_ = conf.getParameter<bool>("debugParameters");
120 
121  wireDigiProducer_ = conf.getParameter<edm::InputTag>("CSCWireDigiProducer");
122  compDigiProducer_ = conf.getParameter<edm::InputTag>("CSCComparatorDigiProducer");
123  gemPadDigiClusterProducer_ = conf.getParameter<edm::InputTag>("GEMPadDigiClusterProducer");
124 
125  checkBadChambers_ = conf.getParameter<bool>("checkBadChambers");
126 
127  keepCLCTPreTriggers_ = conf.getParameter<bool>("keepCLCTPreTriggers");
128  keepALCTPreTriggers_ = conf.getParameter<bool>("keepALCTPreTriggers");
129  keepShowers_ = conf.getParameter<bool>("keepShowers");
130 
131  // check whether you need to run the integrated local triggers
132  const edm::ParameterSet commonParam(conf.getParameter<edm::ParameterSet>("commonParam"));
133  runCCLUT_TMB_ = commonParam.getParameter<bool>("runCCLUT_TMB");
134  runCCLUT_OTMB_ = commonParam.getParameter<bool>("runCCLUT_OTMB");
136 
137  runME11ILT_ = commonParam.getParameter<bool>("runME11ILT");
138  runME21ILT_ = commonParam.getParameter<bool>("runME21ILT");
140 
141  wire_token_ = consumes<CSCWireDigiCollection>(wireDigiProducer_);
142  comp_token_ = consumes<CSCComparatorDigiCollection>(compDigiProducer_);
143  if (runILT_)
144  gem_pad_cluster_token_ = consumes<GEMPadDigiClusterCollection>(gemPadDigiClusterProducer_);
145 
146  cscToken_ = esConsumes<CSCGeometry, MuonGeometryRecord>();
147  gemToken_ = esConsumes<GEMGeometry, MuonGeometryRecord>();
148  pBadChambersToken_ = esConsumes<CSCBadChambers, CSCBadChambersRcd>();
149  // consume lookup tables only when flags are set
150  if (runCCLUT_)
151  pLookupTableCCLUTToken_ = esConsumes<CSCL1TPLookupTableCCLUT, CSCL1TPLookupTableCCLUTRcd>();
152  if (runME11ILT_)
153  pLookupTableME11ILTToken_ = esConsumes<CSCL1TPLookupTableME11ILT, CSCL1TPLookupTableME11ILTRcd>();
154  if (runME21ILT_)
155  pLookupTableME21ILTToken_ = esConsumes<CSCL1TPLookupTableME21ILT, CSCL1TPLookupTableME21ILTRcd>();
156  confToken_ = esConsumes<CSCDBL1TPParameters, CSCDBL1TPParametersRcd>();
157 
158  // register what this produces
159  produces<CSCALCTDigiCollection>();
160  produces<CSCCLCTDigiCollection>();
161  produces<CSCCLCTPreTriggerCollection>();
162  if (keepCLCTPreTriggers_) {
163  produces<CSCCLCTPreTriggerDigiCollection>();
164  }
165  if (keepALCTPreTriggers_) {
166  produces<CSCALCTPreTriggerDigiCollection>();
167  }
168  produces<CSCCorrelatedLCTDigiCollection>();
169  produces<CSCCorrelatedLCTDigiCollection>("MPCSORTED");
170  if (keepShowers_) {
171  produces<CSCShowerDigiCollection>();
172  produces<CSCShowerDigiCollection>("Anode");
173  produces<CSCShowerDigiCollection>("Cathode");
174  }
175  if (runILT_) {
176  produces<GEMCoPadDigiCollection>();
177  }
178  // temporarily switch to a "one" module with a CSCTriggerPrimitivesBuilder data member
179  builder_ = std::make_unique<CSCTriggerPrimitivesBuilder>(config_);
180 }
181 
183 
185  // get the csc geometry
186  builder_->setCSCGeometry(&setup.getData(cscToken_));
187 
188  // get the gem geometry if it's there
189  edm::ESHandle<GEMGeometry> h_gem = setup.getHandle(gemToken_);
190  if (runILT_) {
191  if (h_gem.isValid()) {
192  builder_->setGEMGeometry(&*h_gem);
193  } else {
194  edm::LogWarning("CSCTriggerPrimitivesProducer|NoGEMGeometry")
195  << "GEM geometry is unavailable. Running CSC-only trigger algorithm. +++\n";
196  }
197  }
198 
199  // Find conditions data for bad chambers.
200  edm::ESHandle<CSCBadChambers> pBadChambers = setup.getHandle(pBadChambersToken_);
201 
202  if (runCCLUT_) {
204  if (conf.product() == nullptr) {
205  edm::LogError("CSCTriggerPrimitivesProducer")
206  << "Failed to find a CSCL1TPLookupTableCCLUTRcd in EventSetup with runCCLUT_ on";
207  return;
208  }
209  builder_->setESLookupTables(conf.product());
210  }
211 
212  if (runME11ILT_) {
214  if (conf.product() == nullptr) {
215  edm::LogError("CSCTriggerPrimitivesProducer")
216  << "Failed to find a CSCL1TPLookupTableME11ILTRcd in EventSetup with runME11ILT_ on";
217  return;
218  }
219  builder_->setESLookupTables(conf.product());
220  }
221 
222  if (runME21ILT_) {
224  if (conf.product() == nullptr) {
225  edm::LogError("CSCTriggerPrimitivesProducer")
226  << "Failed to find a CSCL1TPLookupTableME21ILTRcd in EventSetup with runME21ILT_ on";
227  return;
228  }
229  builder_->setESLookupTables(conf.product());
230  }
231 
232  // If !debugParameters then get config parameters using EventSetup mechanism.
233  // This must be done in produce() for every event and not in beginJob()
234  // (see mail from Jim Brooke sent to hn-cms-L1TrigEmulator on July 30, 2007).
235  if (!debugParameters_) {
237  if (conf.product() == nullptr) {
238  edm::LogError("CSCTriggerPrimitivesProducer|ConfigError")
239  << "+++ Failed to find a CSCDBL1TPParametersRcd in EventSetup! +++\n"
240  << "+++ Cannot continue emulation without these parameters +++\n";
241  return;
242  }
243  builder_->setConfigParameters(conf.product());
244  }
245 
246  // Get the collections of comparator & wire digis from event.
249  ev.getByToken(comp_token_, compDigis);
250  ev.getByToken(wire_token_, wireDigis);
251 
252  // input GEM pad cluster collection for upgrade scenarios
253  edm::Handle<GEMPadDigiClusterCollection> gemPadDigiClusters;
254  const GEMPadDigiClusterCollection* gemPadClusters = nullptr;
255 
256  // Create empty collections of ALCTs, CLCTs, and correlated LCTs upstream
257  // and downstream of MPC.
258  std::unique_ptr<CSCALCTDigiCollection> oc_alct(new CSCALCTDigiCollection);
259  std::unique_ptr<CSCCLCTDigiCollection> oc_clct(new CSCCLCTDigiCollection);
260  std::unique_ptr<CSCCLCTPreTriggerDigiCollection> oc_clctpretrigger(new CSCCLCTPreTriggerDigiCollection);
261  std::unique_ptr<CSCALCTPreTriggerDigiCollection> oc_alctpretrigger(new CSCALCTPreTriggerDigiCollection);
262  std::unique_ptr<CSCCLCTPreTriggerCollection> oc_pretrig(new CSCCLCTPreTriggerCollection);
263  std::unique_ptr<CSCCorrelatedLCTDigiCollection> oc_lct(new CSCCorrelatedLCTDigiCollection);
264  std::unique_ptr<CSCCorrelatedLCTDigiCollection> oc_sorted_lct(new CSCCorrelatedLCTDigiCollection);
265  std::unique_ptr<CSCShowerDigiCollection> oc_shower(new CSCShowerDigiCollection);
266  std::unique_ptr<CSCShowerDigiCollection> oc_shower_anode(new CSCShowerDigiCollection);
267  std::unique_ptr<CSCShowerDigiCollection> oc_shower_cathode(new CSCShowerDigiCollection);
268  std::unique_ptr<GEMCoPadDigiCollection> oc_gemcopad(new GEMCoPadDigiCollection);
269 
270  if (!wireDigis.isValid()) {
271  edm::LogWarning("CSCTriggerPrimitivesProducer|NoInputCollection")
272  << "+++ Warning: Collection of wire digis with label " << wireDigiProducer_.label()
273  << " requested in configuration, but not found in the event..."
274  << " Skipping production of CSC TP digis +++\n";
275  }
276  if (!compDigis.isValid()) {
277  edm::LogWarning("CSCTriggerPrimitivesProducer|NoInputCollection")
278  << "+++ Warning: Collection of comparator digis with label " << compDigiProducer_.label()
279  << " requested in configuration, but not found in the event..."
280  << " Skipping production of CSC TP digis +++\n";
281  }
282  // the GEM-CSC trigger flag is set, so GEM clusters are expected in the event data
283  if (runILT_) {
284  // no valid label, let the user know that GEM clusters are missing
285  // the algorithm should not crash. instead it should just produce the regular CSC LCTs
286  // in ME1/1 and/or ME2/1
287  ev.getByToken(gem_pad_cluster_token_, gemPadDigiClusters);
288  if (!gemPadDigiClusters.isValid()) {
289  edm::LogWarning("CSCTriggerPrimitivesProducer|NoInputCollection")
290  << "+++ Warning: Collection of GEM clusters with label " << gemPadDigiClusterProducer_.label()
291  << " requested in configuration, but not found in the event..."
292  << " Running CSC-only trigger algorithm +++\n";
293  } else {
294  // when the GEM-CSC trigger should be run and the label is not empty, set a valid pointer
295  gemPadClusters = gemPadDigiClusters.product();
296  }
297  }
298 
299  // Fill output collections if valid input collections are available.
300  if (wireDigis.isValid() && compDigis.isValid()) {
301  const CSCBadChambers* temp = checkBadChambers_ ? pBadChambers.product() : new CSCBadChambers;
302  builder_->build(temp,
303  wireDigis.product(),
304  compDigis.product(),
305  gemPadClusters,
306  *oc_alct,
307  *oc_clct,
308  *oc_alctpretrigger,
309  *oc_clctpretrigger,
310  *oc_pretrig,
311  *oc_lct,
312  *oc_sorted_lct,
313  *oc_shower_anode,
314  *oc_shower_cathode,
315  *oc_shower,
316  *oc_gemcopad);
317  if (!checkBadChambers_)
318  delete temp;
319  }
320 
321  // Put collections in event.
322  ev.put(std::move(oc_alct));
323  ev.put(std::move(oc_clct));
324  if (keepALCTPreTriggers_) {
325  ev.put(std::move(oc_alctpretrigger));
326  }
327  if (keepCLCTPreTriggers_) {
328  ev.put(std::move(oc_clctpretrigger));
329  }
330  ev.put(std::move(oc_pretrig));
331  ev.put(std::move(oc_lct));
332  ev.put(std::move(oc_sorted_lct), "MPCSORTED");
333  if (keepShowers_) {
334  ev.put(std::move(oc_shower));
335  ev.put(std::move(oc_shower_anode), "Anode");
336  ev.put(std::move(oc_shower_cathode), "Cathode");
337  }
338  // only put GEM copad collections in the event when the
339  // integrated local triggers are running
340  if (runILT_)
341  ev.put(std::move(oc_gemcopad));
342 }
343 
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
T const * product() const
Definition: Handle.h:70
CSCTriggerPrimitivesProducer(const edm::ParameterSet &)
std::string const & label() const
Definition: InputTag.h:36
Log< level::Error, false > LogError
edm::ESGetToken< CSCGeometry, MuonGeometryRecord > cscToken_
void produce(edm::Event &, const edm::EventSetup &) override
edm::EDGetTokenT< GEMPadDigiClusterCollection > gem_pad_cluster_token_
T const * product() const
Definition: ESHandle.h:86
edm::ESGetToken< CSCL1TPLookupTableME21ILT, CSCL1TPLookupTableME21ILTRcd > pLookupTableME21ILTToken_
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
edm::ESGetToken< CSCDBL1TPParameters, CSCDBL1TPParametersRcd > confToken_
edm::EDGetTokenT< CSCComparatorDigiCollection > comp_token_
bool isValid() const
Definition: ESHandle.h:44
edm::ESGetToken< CSCL1TPLookupTableME11ILT, CSCL1TPLookupTableME11ILTRcd > pLookupTableME11ILTToken_
bool isValid() const
Definition: HandleBase.h:70
std::unique_ptr< CSCTriggerPrimitivesBuilder > builder_
edm::EDGetTokenT< CSCWireDigiCollection > wire_token_
edm::ESGetToken< CSCL1TPLookupTableCCLUT, CSCL1TPLookupTableCCLUTRcd > pLookupTableCCLUTToken_
Log< level::Warning, false > LogWarning
edm::ESGetToken< CSCBadChambers, CSCBadChambersRcd > pBadChambersToken_
def move(src, dest)
Definition: eostools.py:511
edm::ESGetToken< GEMGeometry, MuonGeometryRecord > gemToken_
A container for a generic type of digis indexed by some index, implemented with a map<IndexType...