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  CSCBaseboard::Parameters baseparams(conf);
38  for (int endc = min_endcap; endc <= max_endcap; endc++) {
39  for (int stat = min_station; stat <= max_station; stat++) {
40  int numsubs = ((stat == 1) ? max_subsector : 1);
41  for (int sect = min_sector; sect <= max_sector; sect++) {
42  for (int subs = min_subsector; subs <= numsubs; subs++) {
43  for (int cham = min_chamber; cham <= max_chamber; cham++) {
44  if ((endc <= 0 || endc > MAX_ENDCAPS) || (stat <= 0 || stat > MAX_STATIONS) ||
45  (sect <= 0 || sect > MAX_SECTORS) || (subs <= 0 || subs > MAX_SUBSECTORS) ||
46  (cham <= 0 || cham > MAX_CHAMBERS)) {
47  edm::LogError("CSCTriggerPrimitivesBuilder|SetupError")
48  << "+++ trying to instantiate TMB of illegal CSC id ["
49  << " endcap = " << endc << " station = " << stat << " sector = " << sect << " subsector = " << subs
50  << " chamber = " << cham << "]; skipping it... +++\n";
51  continue;
52  }
54  // When the motherboard is instantiated, it instantiates ALCT
55  // and CLCT processors.
56 
57  const bool upgrade = runPhase2_ and ring == 1;
58  const bool upgradeGE11 = upgrade and stat == 1 and runME11Up_ and runME11ILT_;
59  const bool upgradeGE21 = upgrade and stat == 2 and runME21Up_ and runME21ILT_;
60 
61  // GE1/1-ME1/1 integrated local trigger or GE2/1-ME2/1 integrated local trigger
62  if (upgradeGE11 or upgradeGE21)
63  tmb_[endc - 1][stat - 1][sect - 1][subs - 1][cham - 1] =
64  std::make_unique<CSCGEMMotherboard>(endc, stat, sect, subs, cham, baseparams);
65  // default case
66  else
67  tmb_[endc - 1][stat - 1][sect - 1][subs - 1][cham - 1] =
68  std::make_unique<CSCMotherboard>(endc, stat, sect, subs, cham, baseparams);
69  }
70  }
71  // Init MPC
72  mpc_[endc - 1][stat - 1][sect - 1] = std::make_unique<CSCMuonPortCard>(endc, stat, sect, conf);
73  }
74  }
75  }
76 }
77 
78 //------------
79 // Destructor
80 //------------
82 
84  const CSCWireDigiCollection* wiredc,
85  const CSCComparatorDigiCollection* compdc,
86  const GEMPadDigiClusterCollection* gemClusters,
87  const BuildContext& context,
88  CSCALCTDigiCollection& oc_alct,
89  CSCCLCTDigiCollection& oc_clct,
90  CSCALCTPreTriggerDigiCollection& oc_alctpretrigger,
91  CSCCLCTPreTriggerDigiCollection& oc_pretrigger,
92  CSCCLCTPreTriggerCollection& oc_pretrig,
94  CSCCorrelatedLCTDigiCollection& oc_sorted_lct,
95  CSCShowerDigiCollection& oc_shower_anode,
96  CSCShowerDigiCollection& oc_shower_cathode,
97  CSCShowerDigiCollection& oc_shower,
98  GEMCoPadDigiCollection& oc_gemcopad) {
99  // CSC geometry.
100  CSCMotherboard::RunContext mbcontext{
101  context.cscgeom_, context.cclut_, context.me11ilt_, context.me21ilt_, context.parameters_};
102 
103  for (int endc = min_endcap; endc <= max_endcap; endc++) {
104  for (int stat = min_station; stat <= max_station; stat++) {
105  int numsubs = ((stat == 1) ? max_subsector : 1);
106  for (int sect = min_sector; sect <= max_sector; sect++) {
107  for (int subs = min_subsector; subs <= numsubs; subs++) {
108  for (int cham = min_chamber; cham <= max_chamber; cham++) {
109  // extract the ring number
111 
112  // case when you want to ignore ME42
113  if (disableME42_ && stat == 4 && ring == 2)
114  continue;
115 
116  CSCMotherboard* tmb = tmb_[endc - 1][stat - 1][sect - 1][subs - 1][cham - 1].get();
117 
118  // actual chamber number =/= trigger chamber number
120 
121  // 0th layer means whole chamber.
122  CSCDetId detid(endc, stat, ring, chid, 0);
123 
124  // Run processors only if chamber exists in geometry.
125  if (tmb == nullptr || context.cscgeom_->chamber(detid) == nullptr)
126  continue;
127 
128  // Skip chambers marked as bad (usually includes most of ME4/2 chambers;
129  // also, there's no ME1/a-1/b separation, it's whole ME1/1)
130  if (checkBadChambers_ && badChambers->isInBadChamber(detid))
131  continue;
132 
133  //only process the selected chambers when selectedChambers is not empty
134  if (!selectedChambers_.empty()) {
135  if (std::find(selectedChambers_.begin(), selectedChambers_.end(), detid.chamberName()) ==
136  selectedChambers_.end()) {
137  continue;
138  }
139  }
140  const bool upgrade = runPhase2_ and ring == 1;
141  const bool upgradeGE11 = upgrade and stat == 1 and runME11Up_ and runME11ILT_;
142  const bool upgradeGE21 = upgrade and stat == 2 and runME21Up_ and runME21ILT_;
143 
144  // GE1/1-ME1/1 integrated local trigger or GE2/1-ME2/1 integrated local trigger
145  if (upgradeGE11 or upgradeGE21) {
146  // run the TMB
148  context.cscgeom_,
149  context.cclut_,
150  context.me11ilt_,
151  context.me21ilt_,
152  context.parameters_};
153  CSCGEMMotherboard* tmbGEM = static_cast<CSCGEMMotherboard*>(tmb);
154  tmbGEM->run(wiredc, compdc, gemClusters, c);
155 
156  // 0th layer means whole chamber.
157  GEMDetId gemId(detid.zendcap(), 1, stat, 0, chid, 0);
158  const std::vector<GEMCoPadDigi>& copads = tmbGEM->clusterProc()->readoutCoPads();
159  put(copads, oc_gemcopad, gemId, " GEM coincidence pad");
160  }
161  // default case: regular TMBs and OTMBs without GEMs
162  else {
163  // run the TMB
164  tmb->run(wiredc, compdc, mbcontext);
165  }
166 
167  // get the collections
168 
169  // trigger primitives
170  const std::vector<CSCALCTDigi>& alctV = tmb->alctProc->readoutALCTs();
171  const std::vector<CSCCLCTDigi>& clctV = tmb->clctProc->readoutCLCTs();
172  const std::vector<CSCCorrelatedLCTDigi>& lctV = tmb->readoutLCTs();
173 
174  // pre-triggers
175  const std::vector<int>& preTriggerBXs = tmb->clctProc->preTriggerBXs();
176  const std::vector<CSCCLCTPreTriggerDigi>& pretriggerV = tmb->clctProc->preTriggerDigis();
177  const std::vector<CSCALCTPreTriggerDigi>& alctpretriggerV = tmb->alctProc->preTriggerDigis();
178 
179  // showers
180  const std::vector<CSCShowerDigi>& shower = tmb->readoutShower();
181  const std::vector<CSCShowerDigi>& anodeShower = tmb->alctProc->readoutShower();
182  const std::vector<CSCShowerDigi>& cathodeShower = tmb->clctProc->readoutShower();
183 
184  put(alctV, oc_alct, detid, tmb->getCSCName() + " ALCT digi");
185  put(clctV, oc_clct, detid, tmb->getCSCName() + " CLCT digi");
186  put(lctV, oc_lct, detid, tmb->getCSCName() + " LCT digi");
187 
188  put(preTriggerBXs, oc_pretrig, detid, tmb->getCSCName() + " CLCT pre-trigger BX");
189  put(pretriggerV, oc_pretrigger, detid, tmb->getCSCName() + " CLCT pre-trigger digi");
190  put(alctpretriggerV, oc_alctpretrigger, detid, tmb->getCSCName() + " ALCT pre-trigger digi");
191 
192  put(shower, oc_shower, detid, tmb->getCSCName() + "TMB shower");
193  put(anodeShower, oc_shower_anode, detid, tmb->getCSCName() + "Anode shower");
194  put(cathodeShower, oc_shower_cathode, detid, tmb->getCSCName() + "Cathode shower");
195  //if (shower.isValid())
196  // oc_shower.insertDigi(detid, shower);
197  //if (anodeShower.isValid())
198  // oc_shower_anode.insertDigi(detid, anodeShower);
199  //if (cathodeShower.isValid())
200  // oc_shower_cathode.insertDigi(detid, cathodeShower);
201 
202  if (!(alctV.empty() && clctV.empty() && lctV.empty()) and infoV > 1) {
203  LogTrace("L1CSCTrigger") << "CSCTriggerPrimitivesBuilder got results in " << detid;
204  }
205  } // end loop on cham
206  } // end loop on subs
207  } // end loop on sect
208  } // end loop on stat
209  } // end loop on endc
210 
211  // run MPC simulation
212  // there are 2 x 4 x 6 MPC VME cards
213  for (int endc = min_endcap; endc <= max_endcap; endc++) {
214  for (int stat = min_station; stat <= max_station; stat++) {
215  for (int sect = min_sector; sect <= max_sector; sect++) {
216  auto mpc = mpc_[endc - 1][stat - 1][sect - 1].get();
217 
218  // load the LCTs relevant for this MPC
219  mpc->loadLCTs(oc_lct);
220 
221  // sort and select the LCTs (if applicable)
222  mpc->sortLCTs();
223 
224  // get sorted+selected LCTs
225  const auto& result = mpc->getLCTs();
226 
227  // now convert csctf::TrackStub back into CSCCorrelatedLCTDigi
228  // put MPC stubs into the event
229  for (const auto& lct : result) {
230  oc_sorted_lct.insertDigi(CSCDetId(lct.getDetId().rawId()), *(lct.getDigi()));
231  if (infoV > 1)
232  LogDebug("CSCTriggerPrimitivesBuilder")
233  << "MPC " << *(lct.getDigi()) << " found in ME" << ((lct.endcap() == 1) ? "+" : "-") << lct.station()
234  << "/" << CSCDetId(lct.getDetId().rawId()).ring() << "/" << CSCDetId(lct.getDetId().rawId()).chamber()
235  << " (sector " << lct.sector() << " trig id. " << lct.cscid() << ")"
236  << "\n";
237  }
238  }
239  }
240  }
241 }
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
static int minEndcapId()
Definition: CSCDetId.h:234
static std::string chamberName(int endcap, int station, int ring, int chamber)
Definition: CSCDetId.cc:74
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
void run(const CSCWireDigiCollection *wiredc, const CSCComparatorDigiCollection *compdc, const GEMPadDigiClusterCollection *gemPads, RunContext const &)
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 run(const CSCWireDigiCollection *wiredc, const CSCComparatorDigiCollection *compdc, const RunContext &)
CSCTriggerPrimitivesBuilder(const edm::ParameterSet &)
std::string getCSCName() const
Definition: CSCBaseboard.h:61
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
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?
bool checkBadChambers_
a flag whether to skip chambers from the bad chambers map
std::unique_ptr< CSCAnodeLCTProcessor > alctProc
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
void build(const CSCBadChambers *badChambers, const CSCWireDigiCollection *wiredc, const CSCComparatorDigiCollection *compdc, const GEMPadDigiClusterCollection *gemPadClusters, const BuildContext &context, 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)
#define LogDebug(id)
A container for a generic type of digis indexed by some index, implemented with a map<IndexType...