CMS 3D CMS Logo

CSCTriggerPrimitivesBuilder.cc
Go to the documentation of this file.
1 #include <memory>
2 
8 
19 
21  // special configuration parameters for ME11 treatment
22  edm::ParameterSet commonParams = conf.getParameter<edm::ParameterSet>("commonParam");
23  runPhase2_ = commonParams.getParameter<bool>("runPhase2");
24  infoV = commonParams.getParameter<int>("verbosity");
25  disableME42_ = commonParams.getParameter<bool>("disableME42");
26 
27  checkBadChambers_ = conf.getParameter<bool>("checkBadChambers");
28  selectedChambers_ = conf.getParameter<std::vector<std::string>>("selectedChambers");
29 
30  runME11Up_ = commonParams.getParameter<bool>("runME11Up");
31  runME21Up_ = commonParams.getParameter<bool>("runME21Up");
32 
33  runME11ILT_ = commonParams.getParameter<bool>("runME11ILT");
34  runME21ILT_ = commonParams.getParameter<bool>("runME21ILT");
35 
36  // Initializing boards.
37  for (int endc = min_endcap; endc <= max_endcap; endc++) {
38  for (int stat = min_station; stat <= max_station; stat++) {
39  int numsubs = ((stat == 1) ? max_subsector : 1);
40  for (int sect = min_sector; sect <= max_sector; sect++) {
41  for (int subs = min_subsector; subs <= numsubs; subs++) {
42  for (int cham = min_chamber; cham <= max_chamber; cham++) {
43  if ((endc <= 0 || endc > MAX_ENDCAPS) || (stat <= 0 || stat > MAX_STATIONS) ||
44  (sect <= 0 || sect > MAX_SECTORS) || (subs <= 0 || subs > MAX_SUBSECTORS) ||
45  (cham <= 0 || cham > MAX_CHAMBERS)) {
46  edm::LogError("CSCTriggerPrimitivesBuilder|SetupError")
47  << "+++ trying to instantiate TMB of illegal CSC id ["
48  << " endcap = " << endc << " station = " << stat << " sector = " << sect << " subsector = " << subs
49  << " chamber = " << cham << "]; skipping it... +++\n";
50  continue;
51  }
53  // When the motherboard is instantiated, it instantiates ALCT
54  // and CLCT processors.
55 
56  const bool upgrade = runPhase2_ and ring == 1;
57  const bool upgradeGE11 = upgrade and stat == 1 and runME11Up_ and runME11ILT_;
58  const bool upgradeGE21 = upgrade and stat == 2 and runME21Up_ and runME21ILT_;
59 
60  // GE1/1-ME1/1 integrated local trigger or GE2/1-ME2/1 integrated local trigger
61  if (upgradeGE11 or upgradeGE21)
62  tmb_[endc - 1][stat - 1][sect - 1][subs - 1][cham - 1] =
63  std::make_unique<CSCGEMMotherboard>(endc, stat, sect, subs, cham, conf);
64  // default case
65  else
66  tmb_[endc - 1][stat - 1][sect - 1][subs - 1][cham - 1] =
67  std::make_unique<CSCMotherboard>(endc, stat, sect, subs, cham, conf);
68  }
69  }
70  // Init MPC
71  mpc_[endc - 1][stat - 1][sect - 1] = std::make_unique<CSCMuonPortCard>(endc, stat, sect, conf);
72  }
73  }
74  }
75 }
76 
77 //------------
78 // Destructor
79 //------------
81 
83  // Receives CSCDBL1TPParameters percolated down from ESProducer.
84 
85  for (int endc = min_endcap; endc <= max_endcap; endc++) {
86  for (int stat = min_station; stat <= max_station; stat++) {
87  int numsubs = ((stat == 1) ? max_subsector : 1);
88  for (int sect = min_sector; sect <= max_sector; sect++) {
89  for (int subs = min_subsector; subs <= numsubs; subs++) {
90  for (int cham = min_chamber; cham <= max_chamber; cham++) {
91  tmb_[endc - 1][stat - 1][sect - 1][subs - 1][cham - 1]->setConfigParameters(conf);
92  }
93  }
94  }
95  }
96  }
97 }
98 
100  // Receives CSCL1TPLookupTableCCLUT percolated down from ESProducer.
101  for (int endc = min_endcap; endc <= max_endcap; endc++) {
102  for (int stat = min_station; stat <= max_station; stat++) {
103  int numsubs = ((stat == 1) ? max_subsector : 1);
104  for (int sect = min_sector; sect <= max_sector; sect++) {
105  for (int subs = min_subsector; subs <= numsubs; subs++) {
106  for (int cham = min_chamber; cham <= max_chamber; cham++) {
107  tmb_[endc - 1][stat - 1][sect - 1][subs - 1][cham - 1]->setESLookupTables(conf);
108  }
109  }
110  }
111  }
112  }
113 }
114 
116  for (int endc = min_endcap; endc <= max_endcap; endc++) {
117  for (int stat = min_station; stat <= max_station; stat++) {
118  int numsubs = ((stat == 1) ? max_subsector : 1);
119  for (int sect = min_sector; sect <= max_sector; sect++) {
120  for (int subs = min_subsector; subs <= numsubs; subs++) {
121  for (int cham = min_chamber; cham <= max_chamber; cham++) {
122  if (tmb_[endc - 1][stat - 1][sect - 1][subs - 1][cham - 1]->id().isME11())
123  tmb_[endc - 1][stat - 1][sect - 1][subs - 1][cham - 1]->setESLookupTables(conf);
124  }
125  }
126  }
127  }
128  }
129 }
130 
132  for (int endc = min_endcap; endc <= max_endcap; endc++) {
133  for (int stat = min_station; stat <= max_station; stat++) {
134  int numsubs = ((stat == 1) ? max_subsector : 1);
135  for (int sect = min_sector; sect <= max_sector; sect++) {
136  for (int subs = min_subsector; subs <= numsubs; subs++) {
137  for (int cham = min_chamber; cham <= max_chamber; cham++) {
138  if (tmb_[endc - 1][stat - 1][sect - 1][subs - 1][cham - 1]->id().isME21())
139  tmb_[endc - 1][stat - 1][sect - 1][subs - 1][cham - 1]->setESLookupTables(conf);
140  }
141  }
142  }
143  }
144  }
145 }
146 
148  const CSCWireDigiCollection* wiredc,
149  const CSCComparatorDigiCollection* compdc,
150  const GEMPadDigiClusterCollection* gemClusters,
151  CSCALCTDigiCollection& oc_alct,
152  CSCCLCTDigiCollection& oc_clct,
153  CSCALCTPreTriggerDigiCollection& oc_alctpretrigger,
154  CSCCLCTPreTriggerDigiCollection& oc_pretrigger,
155  CSCCLCTPreTriggerCollection& oc_pretrig,
157  CSCCorrelatedLCTDigiCollection& oc_sorted_lct,
158  CSCShowerDigiCollection& oc_shower_anode,
159  CSCShowerDigiCollection& oc_shower_cathode,
160  CSCShowerDigiCollection& oc_shower,
161  GEMCoPadDigiCollection& oc_gemcopad) {
162  // CSC geometry.
163  for (int endc = min_endcap; endc <= max_endcap; endc++) {
164  for (int stat = min_station; stat <= max_station; stat++) {
165  int numsubs = ((stat == 1) ? max_subsector : 1);
166  for (int sect = min_sector; sect <= max_sector; sect++) {
167  for (int subs = min_subsector; subs <= numsubs; subs++) {
168  for (int cham = min_chamber; cham <= max_chamber; cham++) {
169  // extract the ring number
171 
172  // case when you want to ignore ME42
173  if (disableME42_ && stat == 4 && ring == 2)
174  continue;
175 
176  CSCMotherboard* tmb = tmb_[endc - 1][stat - 1][sect - 1][subs - 1][cham - 1].get();
177 
178  tmb->setCSCGeometry(csc_g);
179 
180  // actual chamber number =/= trigger chamber number
182 
183  // 0th layer means whole chamber.
184  CSCDetId detid(endc, stat, ring, chid, 0);
185 
186  // Run processors only if chamber exists in geometry.
187  if (tmb == nullptr || csc_g->chamber(detid) == nullptr)
188  continue;
189 
190  // Skip chambers marked as bad (usually includes most of ME4/2 chambers;
191  // also, there's no ME1/a-1/b separation, it's whole ME1/1)
192  if (checkBadChambers_ && badChambers->isInBadChamber(detid))
193  continue;
194 
195  //only process the selected chambers when selectedChambers is not empty
196  if (!selectedChambers_.empty()) {
197  if (std::find(selectedChambers_.begin(), selectedChambers_.end(), detid.chamberName()) ==
198  selectedChambers_.end()) {
199  continue;
200  }
201  }
202  const bool upgrade = runPhase2_ and ring == 1;
203  const bool upgradeGE11 = upgrade and stat == 1 and runME11Up_ and runME11ILT_;
204  const bool upgradeGE21 = upgrade and stat == 2 and runME21Up_ and runME21ILT_;
205 
206  // GE1/1-ME1/1 integrated local trigger or GE2/1-ME2/1 integrated local trigger
207  if (upgradeGE11 or upgradeGE21) {
208  // run the TMB
209  CSCGEMMotherboard* tmbGEM = static_cast<CSCGEMMotherboard*>(tmb);
210  tmbGEM->setGEMGeometry(gem_g);
211  tmbGEM->setCSCGeometry(csc_g);
212  tmbGEM->run(wiredc, compdc, gemClusters);
213 
214  // 0th layer means whole chamber.
215  GEMDetId gemId(detid.zendcap(), 1, stat, 0, chid, 0);
216  const std::vector<GEMCoPadDigi>& copads = tmbGEM->clusterProc()->readoutCoPads();
217  put(copads, oc_gemcopad, gemId, " GEM coincidence pad");
218  }
219  // default case: regular TMBs and OTMBs without GEMs
220  else {
221  // run the TMB
222  tmb->run(wiredc, compdc);
223  }
224 
225  // get the collections
226 
227  // trigger primitives
228  const std::vector<CSCALCTDigi>& alctV = tmb->alctProc->readoutALCTs();
229  const std::vector<CSCCLCTDigi>& clctV = tmb->clctProc->readoutCLCTs();
230  const std::vector<CSCCorrelatedLCTDigi>& lctV = tmb->readoutLCTs();
231 
232  // pre-triggers
233  const std::vector<int>& preTriggerBXs = tmb->clctProc->preTriggerBXs();
234  const std::vector<CSCCLCTPreTriggerDigi>& pretriggerV = tmb->clctProc->preTriggerDigis();
235  const std::vector<CSCALCTPreTriggerDigi>& alctpretriggerV = tmb->alctProc->preTriggerDigis();
236 
237  // showers
238  const std::vector<CSCShowerDigi>& shower = tmb->readoutShower();
239  const std::vector<CSCShowerDigi>& anodeShower = tmb->alctProc->readoutShower();
240  const std::vector<CSCShowerDigi>& cathodeShower = tmb->clctProc->readoutShower();
241 
242  put(alctV, oc_alct, detid, tmb->getCSCName() + " ALCT digi");
243  put(clctV, oc_clct, detid, tmb->getCSCName() + " CLCT digi");
244  put(lctV, oc_lct, detid, tmb->getCSCName() + " LCT digi");
245 
246  put(preTriggerBXs, oc_pretrig, detid, tmb->getCSCName() + " CLCT pre-trigger BX");
247  put(pretriggerV, oc_pretrigger, detid, tmb->getCSCName() + " CLCT pre-trigger digi");
248  put(alctpretriggerV, oc_alctpretrigger, detid, tmb->getCSCName() + " ALCT pre-trigger digi");
249 
250  put(shower, oc_shower, detid, tmb->getCSCName() + "TMB shower");
251  put(anodeShower, oc_shower_anode, detid, tmb->getCSCName() + "Anode shower");
252  put(cathodeShower, oc_shower_cathode, detid, tmb->getCSCName() + "Cathode shower");
253  //if (shower.isValid())
254  // oc_shower.insertDigi(detid, shower);
255  //if (anodeShower.isValid())
256  // oc_shower_anode.insertDigi(detid, anodeShower);
257  //if (cathodeShower.isValid())
258  // oc_shower_cathode.insertDigi(detid, cathodeShower);
259 
260  if (!(alctV.empty() && clctV.empty() && lctV.empty()) and infoV > 1) {
261  LogTrace("L1CSCTrigger") << "CSCTriggerPrimitivesBuilder got results in " << detid;
262  }
263  } // end loop on cham
264  } // end loop on subs
265  } // end loop on sect
266  } // end loop on stat
267  } // end loop on endc
268 
269  // run MPC simulation
270  // there are 2 x 4 x 6 MPC VME cards
271  for (int endc = min_endcap; endc <= max_endcap; endc++) {
272  for (int stat = min_station; stat <= max_station; stat++) {
273  for (int sect = min_sector; sect <= max_sector; sect++) {
274  auto mpc = mpc_[endc - 1][stat - 1][sect - 1].get();
275 
276  // load the LCTs relevant for this MPC
277  mpc->loadLCTs(oc_lct);
278 
279  // sort and select the LCTs (if applicable)
280  mpc->sortLCTs();
281 
282  // get sorted+selected LCTs
283  const auto& result = mpc->getLCTs();
284 
285  // now convert csctf::TrackStub back into CSCCorrelatedLCTDigi
286  // put MPC stubs into the event
287  for (const auto& lct : result) {
288  oc_sorted_lct.insertDigi(CSCDetId(lct.getDetId().rawId()), *(lct.getDigi()));
289  if (infoV > 1)
290  LogDebug("CSCTriggerPrimitivesBuilder")
291  << "MPC " << *(lct.getDigi()) << " found in ME" << ((lct.endcap() == 1) ? "+" : "-") << lct.station()
292  << "/" << CSCDetId(lct.getDetId().rawId()).ring() << "/" << CSCDetId(lct.getDetId().rawId()).chamber()
293  << " (sector " << lct.sector() << " trig id. " << lct.cscid() << ")"
294  << "\n";
295  }
296  }
297  }
298  }
299 }
void build(const CSCBadChambers *badChambers, const CSCWireDigiCollection *wiredc, const CSCComparatorDigiCollection *compdc, const GEMPadDigiClusterCollection *gemPadClusters, CSCALCTDigiCollection &oc_alct, CSCCLCTDigiCollection &oc_clct, CSCALCTPreTriggerDigiCollection &oc_alctpretrigger, CSCCLCTPreTriggerDigiCollection &oc_clctpretrigger, CSCCLCTPreTriggerCollection &oc_pretrig, CSCCorrelatedLCTDigiCollection &oc_lct, CSCCorrelatedLCTDigiCollection &oc_sorted_lct, CSCShowerDigiCollection &oc_shower_anode, CSCShowerDigiCollection &oc_shower_cathode, CSCShowerDigiCollection &oc_shower, GEMCoPadDigiCollection &oc_gemcopad)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
virtual std::vector< CSCCorrelatedLCTDigi > readoutLCTs() const
std::unique_ptr< CSCMotherboard > tmb_[MAX_ENDCAPS][MAX_STATIONS][MAX_SECTORS][MAX_SUBSECTORS][MAX_CHAMBERS]
short int zendcap() const
Definition: CSCDetId.h:91
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
Definition: CSCGeometry.cc:100
static int minEndcapId()
Definition: CSCDetId.h:234
static std::string chamberName(int endcap, int station, int ring, int chamber)
Definition: CSCDetId.cc:74
void setGEMGeometry(const GEMGeometry *g)
static int maxTriggerSectorId()
std::unique_ptr< CSCMuonPortCard > mpc_[MAX_ENDCAPS][MAX_STATIONS][MAX_SECTORS]
anodeShower
settings for anode showers (counting CSCWireDigi)
Definition: showerParams.py:71
std::unique_ptr< CSCCathodeLCTProcessor > clctProc
std::vector< std::string > selectedChambers_
Log< level::Error, false > LogError
static int maxStationId()
Definition: CSCDetId.h:237
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
static int minTriggerSectorId()
static int ringFromTriggerLabels(int station, int triggerCSCID)
#define LogTrace(id)
void setConfigParameters(const CSCDBL1TPParameters *conf)
CSCTriggerPrimitivesBuilder(const edm::ParameterSet &)
std::string getCSCName() const
Definition: CSCBaseboard.h:31
static int minStationId()
Definition: CSCDetId.h:236
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
static int maxEndcapId()
Definition: CSCDetId.h:235
void setESLookupTables(const CSCL1TPLookupTableCCLUT *conf)
void run(const CSCWireDigiCollection *wiredc, const CSCComparatorDigiCollection *compdc)
static int minTriggerSubSectorId()
void put(const T &, S &, const CSCDetId &, std::string comment)
bool isInBadChamber(IndexType ichamber) const
Is the chamber with index &#39;ichamber&#39; flagged as bad?
void run(const CSCWireDigiCollection *wiredc, const CSCComparatorDigiCollection *compdc, const GEMPadDigiClusterCollection *gemPads)
bool checkBadChambers_
a flag whether to skip chambers from the bad chambers map
std::unique_ptr< CSCAnodeLCTProcessor > alctProc
void setCSCGeometry(const CSCGeometry *g)
cathodeShower
settings for cathode showers (counting CSCComparatorDigi)
Definition: showerParams.py:38
std::vector< CSCShowerDigi > readoutShower() const
static int chamberFromTriggerLabels(int TriggerSector, int TriggerSubSector, int station, int TriggerCSCID)
static int maxTriggerSubSectorId()
std::shared_ptr< GEMClusterProcessor > clusterProc() const
#define LogDebug(id)
A container for a generic type of digis indexed by some index, implemented with a map<IndexType...