CMS 3D CMS Logo

CSCTriggerPrimitivesProducer.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: CSCTriggerPrimitivesProducer
4 //
5 // Description: Steering routine of the local Level-1 Cathode Strip Chamber
6 // trigger.
7 //
8 // Author List: S. Valuev, UCLA.
9 //
10 //
11 // Modifications:
12 //
13 //--------------------------------------------------
14 
17 
21 
25 
32 
33 // Configuration via EventSetup
36 
38  config_ = conf;
39 
40  // if false, parameters will be read in from DB using EventSetup mechanism
41  // else will use all parameters from the config file
42  debugParameters_ = conf.getParameter<bool>("debugParameters");
43 
44  wireDigiProducer_ = conf.getParameter<edm::InputTag>("CSCWireDigiProducer");
45  compDigiProducer_ = conf.getParameter<edm::InputTag>("CSCComparatorDigiProducer");
46  gemPadDigiProducer_ = conf.existsAs<edm::InputTag>("GEMPadDigiProducer")
47  ? conf.getParameter<edm::InputTag>("GEMPadDigiProducer")
48  : edm::InputTag("");
49  checkBadChambers_ = conf.getParameter<bool>("checkBadChambers");
50 
51  savePreTriggers_ = conf.getParameter<bool>("savePreTriggers");
52 
53  // check whether you need to run the integrated local triggers
54  const edm::ParameterSet commonParam(conf.getParameter<edm::ParameterSet>("commonParam"));
55  runME11ILT_ = commonParam.existsAs<bool>("runME11ILT") ? commonParam.getParameter<bool>("runME11ILT") : false;
56  runME21ILT_ = commonParam.existsAs<bool>("runME21ILT") ? commonParam.getParameter<bool>("runME21ILT") : false;
57 
58  wire_token_ = consumes<CSCWireDigiCollection>(wireDigiProducer_);
59  comp_token_ = consumes<CSCComparatorDigiCollection>(compDigiProducer_);
60  gem_pad_token_ = consumes<GEMPadDigiCollection>(gemPadDigiProducer_);
61  gem_pad_cluster_token_ = consumes<GEMPadDigiClusterCollection>(gemPadDigiClusterProducer_);
62 
63  // register what this produces
64  produces<CSCALCTDigiCollection>();
65  produces<CSCCLCTDigiCollection>();
66  produces<CSCCLCTPreTriggerDigiCollection>();
67  produces<CSCCLCTPreTriggerCollection>();
68  produces<CSCALCTPreTriggerDigiCollection>();
69  produces<CSCCorrelatedLCTDigiCollection>();
70  produces<CSCCorrelatedLCTDigiCollection>("MPCSORTED");
72  produces<GEMCoPadDigiCollection>();
73 }
74 
76 
78  // Remark: access builder using "streamCache(iID)"
79 
80  // get the csc geometry
82  setup.get<MuonGeometryRecord>().get(h);
83  streamCache(iID)->setCSCGeometry(&*h);
84 
85  // get the gem geometry if it's there
87  setup.get<MuonGeometryRecord>().get(h_gem);
88  if (h_gem.isValid()) {
89  streamCache(iID)->setGEMGeometry(&*h_gem);
90  } else {
91  edm::LogInfo("CSCTriggerPrimitivesProducer|NoGEMGeometry")
92  << "+++ Info: GEM geometry is unavailable. Running CSC-only trigger algorithm. +++\n";
93  }
94 
95  // Find conditions data for bad chambers.
96  edm::ESHandle<CSCBadChambers> pBadChambers;
97  setup.get<CSCBadChambersRcd>().get(pBadChambers);
98 
99  // If !debugParameters then get config parameters using EventSetup mechanism.
100  // This must be done in produce() for every event and not in beginJob()
101  // (see mail from Jim Brooke sent to hn-cms-L1TrigEmulator on July 30, 2007).
102  if (!debugParameters_) {
104  setup.get<CSCDBL1TPParametersRcd>().get(conf);
105  if (conf.product() == nullptr) {
106  edm::LogError("CSCTriggerPrimitivesProducer|ConfigError")
107  << "+++ Failed to find a CSCDBL1TPParametersRcd in EventSetup! +++\n"
108  << "+++ Cannot continue emulation without these parameters +++\n";
109  return;
110  }
111  streamCache(iID)->setConfigParameters(conf.product());
112  }
113 
114  // Get the collections of comparator & wire digis from event.
117  ev.getByToken(comp_token_, compDigis);
118  ev.getByToken(wire_token_, wireDigis);
119 
120  // input GEM pad collection for upgrade scenarios
121  const GEMPadDigiCollection* gemPads = nullptr;
122  if (!gemPadDigiProducer_.label().empty()) {
124  ev.getByToken(gem_pad_token_, gemPadDigis);
125  gemPads = gemPadDigis.product();
126  }
127 
128  // input GEM pad cluster collection for upgrade scenarios
129  const GEMPadDigiClusterCollection* gemPadClusters = nullptr;
130  if (!gemPadDigiClusterProducer_.label().empty()) {
131  edm::Handle<GEMPadDigiClusterCollection> gemPadDigiClusters;
132  ev.getByToken(gem_pad_cluster_token_, gemPadDigiClusters);
133  gemPadClusters = gemPadDigiClusters.product();
134  }
135 
136  // Create empty collections of ALCTs, CLCTs, and correlated LCTs upstream
137  // and downstream of MPC.
138  std::unique_ptr<CSCALCTDigiCollection> oc_alct(new CSCALCTDigiCollection);
139  std::unique_ptr<CSCCLCTDigiCollection> oc_clct(new CSCCLCTDigiCollection);
140  std::unique_ptr<CSCCLCTPreTriggerDigiCollection> oc_clctpretrigger(new CSCCLCTPreTriggerDigiCollection);
141  std::unique_ptr<CSCALCTPreTriggerDigiCollection> oc_alctpretrigger(new CSCALCTPreTriggerDigiCollection);
142  std::unique_ptr<CSCCLCTPreTriggerCollection> oc_pretrig(new CSCCLCTPreTriggerCollection);
143  std::unique_ptr<CSCCorrelatedLCTDigiCollection> oc_lct(new CSCCorrelatedLCTDigiCollection);
144  std::unique_ptr<CSCCorrelatedLCTDigiCollection> oc_sorted_lct(new CSCCorrelatedLCTDigiCollection);
145  std::unique_ptr<GEMCoPadDigiCollection> oc_gemcopad(new GEMCoPadDigiCollection);
146 
147  if (!wireDigis.isValid()) {
148  edm::LogWarning("CSCTriggerPrimitivesProducer|NoInputCollection")
149  << "+++ Warning: Collection of wire digis with label " << wireDigiProducer_.label()
150  << " requested in configuration, but not found in the event..."
151  << " Skipping production of CSC TP digis +++\n";
152  }
153  if (!compDigis.isValid()) {
154  edm::LogWarning("CSCTriggerPrimitivesProducer|NoInputCollection")
155  << "+++ Warning: Collection of comparator digis with label " << compDigiProducer_.label()
156  << " requested in configuration, but not found in the event..."
157  << " Skipping production of CSC TP digis +++\n";
158  }
159  // Fill output collections if valid input collections are available.
160  if (wireDigis.isValid() && compDigis.isValid()) {
161  const CSCBadChambers* temp = checkBadChambers_ ? pBadChambers.product() : new CSCBadChambers;
162  streamCache(iID)->build(temp,
163  wireDigis.product(),
164  compDigis.product(),
165  gemPads,
166  gemPadClusters,
167  *oc_alct,
168  *oc_clct,
169  *oc_alctpretrigger,
170  *oc_clctpretrigger,
171  *oc_pretrig,
172  *oc_lct,
173  *oc_sorted_lct,
174  *oc_gemcopad);
175  if (!checkBadChambers_)
176  delete temp;
177  }
178 
179  // Put collections in event.
180  ev.put(std::move(oc_alct));
181  ev.put(std::move(oc_clct));
182  if (savePreTriggers_) {
183  ev.put(std::move(oc_alctpretrigger));
184  ev.put(std::move(oc_clctpretrigger));
185  }
186  ev.put(std::move(oc_pretrig));
187  ev.put(std::move(oc_lct));
188  ev.put(std::move(oc_sorted_lct), "MPCSORTED");
189  // only put GEM copad collections in the event when the
190  // integrated local triggers are running
192  ev.put(std::move(oc_gemcopad));
193 }
T getParameter(std::string const &) const
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:160
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
bool ev
CSCTriggerPrimitivesProducer(const edm::ParameterSet &)
edm::EDGetTokenT< GEMPadDigiClusterCollection > gem_pad_cluster_token_
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
bool isValid() const
Definition: HandleBase.h:70
edm::EDGetTokenT< CSCComparatorDigiCollection > comp_token_
edm::EDGetTokenT< GEMPadDigiCollection > gem_pad_token_
T const * product() const
Definition: Handle.h:69
std::string const & label() const
Definition: InputTag.h:36
edm::EDGetTokenT< CSCWireDigiCollection > wire_token_
T get() const
Definition: EventSetup.h:73
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
bool isValid() const
Definition: ESHandle.h:44
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:511
A container for a generic type of digis indexed by some index, implemented with a map<IndexType...