CMS 3D CMS Logo

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