CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CSCTriggerPrimitivesBuilder.cc
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // Class: CSCTriggerPrimitivesBuilder
4 //
5 // Description: Algorithm to build anode, cathode, and correlated LCTs
6 // in each endcap muon CSC chamber from wire and comparator
7 // digis.
8 //
9 // Author List: S. Valuev, UCLA.
10 //
11 // $Date: 2010/08/04 14:50:12 $
12 // $Revision: 1.20 $
13 //
14 // Modifications:
15 //
16 //-----------------------------------------------------------------------------
17 
21 
23 
27 
28 //------------------
29 // Static variables
30 //------------------
47 
48 //-------------
49 // Constructor
50 //-------------
52  // Receives ParameterSet percolated down from EDProducer.
53 
54  // ORCA way of initializing boards.
55  for (int endc = min_endcap; endc <= max_endcap; endc++) {
56  for (int stat = min_station; stat <= max_station; stat++) {
57  int numsubs = ((stat == 1) ? max_subsector : 1);
58  for (int sect = min_sector; sect <= max_sector; sect++) {
59  for (int subs = min_subsector; subs <= numsubs; subs++) {
60  for (int cham = min_chamber; cham <= max_chamber; cham++) {
61  if ((endc <= 0 || endc > MAX_ENDCAPS) ||
62  (stat <= 0 || stat > MAX_STATIONS) ||
63  (sect <= 0 || sect > MAX_SECTORS) ||
64  (subs <= 0 || subs > MAX_SUBSECTORS) ||
65  (cham <= 0 || stat > MAX_CHAMBERS)) {
66  edm::LogError("L1CSCTPEmulatorSetupError")
67  << "+++ trying to instantiate TMB of illegal CSC id ["
68  << " endcap = " << endc << " station = " << stat
69  << " sector = " << sect << " subsector = " << subs
70  << " chamber = " << cham << "]; skipping it... +++\n";
71  continue;
72  }
73  // When the motherboard is instantiated, it instantiates ALCT
74  // and CLCT processors.
75  tmb_[endc-1][stat-1][sect-1][subs-1][cham-1] =
76  new CSCMotherboard(endc, stat, sect, subs, cham, conf);
77  }
78  }
79  }
80  }
81  }
82 
83  // Get min and max BX to sort LCTs in MPC.
84  m_minBX = conf.getParameter<int>("MinBX");
85  m_maxBX = conf.getParameter<int>("MaxBX");
86 
87  // Init MPC
89 }
90 
91 //------------
92 // Destructor
93 //------------
95  for (int endc = min_endcap; endc <= max_endcap; endc++) {
96  for (int stat = min_station; stat <= max_station; stat++) {
97  int numsubs = ((stat == 1) ? max_subsector : 1);
98  for (int sect = min_sector; sect <= max_sector; sect++) {
99  for (int subs = min_subsector; subs <= numsubs; subs++) {
100  for (int cham = min_chamber; cham <= max_chamber; cham++) {
101  delete tmb_[endc-1][stat-1][sect-1][subs-1][cham-1];
102  }
103  }
104  }
105  }
106  }
107  delete m_muonportcard;
108 }
109 
110 //------------
111 // Operations
112 //------------
113 // Set configuration parameters obtained via EventSetup mechanism.
115  // Receives CSCDBL1TPParameters percolated down from ESProducer.
116 
117  for (int endc = min_endcap; endc <= max_endcap; endc++) {
118  for (int stat = min_station; stat <= max_station; stat++) {
119  int numsubs = ((stat == 1) ? max_subsector : 1);
120  for (int sect = min_sector; sect <= max_sector; sect++) {
121  for (int subs = min_subsector; subs <= numsubs; subs++) {
122  for (int cham = min_chamber; cham <= max_chamber; cham++) {
123  CSCMotherboard* tmb = tmb_[endc-1][stat-1][sect-1][subs-1][cham-1];
124  tmb->setConfigParameters(conf);
125  }
126  }
127  }
128  }
129  }
130 }
131 
132 // Build anode, cathode, and correlated LCTs in each chamber and fill them
133 // into output collections. Pass collections of wire and comparator digis
134 // to Trigger MotherBoard (TMB) processors, which, in turn, pass them to
135 // ALCT and CLCT processors. Up to 2 anode and 2 cathode LCTs can be found
136 // in each chamber during any bunch crossing. The 2 projections are then
137 // combined into three-dimensional "correlated" LCTs in the TMB. Finally,
138 // MPC processor sorts up to 18 LCTs from 9 TMBs and writes collections of
139 // up to 3 best LCTs per (sub)sector into Event (to be used by the Sector
140 // Receiver).
142  const CSCWireDigiCollection* wiredc,
143  const CSCComparatorDigiCollection* compdc,
144  CSCALCTDigiCollection& oc_alct,
145  CSCCLCTDigiCollection& oc_clct,
146  CSCCLCTPreTriggerCollection & oc_pretrig,
148  CSCCorrelatedLCTDigiCollection& oc_sorted_lct) {
149  // CSC geometry.
151 
152  for (int endc = min_endcap; endc <= max_endcap; endc++) {
153  for (int stat = min_station; stat <= max_station; stat++) {
154  int numsubs = ((stat == 1) ? max_subsector : 1);
155  for (int sect = min_sector; sect <= max_sector; sect++) {
156  for (int subs = min_subsector; subs <= numsubs; subs++) {
157  for (int cham = min_chamber; cham <= max_chamber; cham++) {
158  CSCMotherboard* tmb = tmb_[endc-1][stat-1][sect-1][subs-1][cham-1];
159 
160  // Run processors only if chamber exists in geometry.
161  if (tmb != 0 &&
162  theGeom->chamber(endc, stat, sect, subs, cham) != 0) {
163 
164  // Calculate DetId.
165  int ring =
167  int chid =
169  stat, cham);
170  // 0th layer means whole chamber.
171  CSCDetId detid(endc, stat, ring, chid, 0);
172 
173  // Skip chambers marked as bad (includes most of ME4/2 chambers).
174  if (badChambers->isInBadChamber(detid)) continue;
175 
176  std::vector<CSCCorrelatedLCTDigi> lctV = tmb->run(wiredc,compdc);
177 
178  std::vector<CSCALCTDigi> alctV = tmb->alct->readoutALCTs();
179  std::vector<CSCCLCTDigi> clctV = tmb->clct->readoutCLCTs();
180  std::vector<int> preTriggerBXs = tmb->clct->preTriggerBXs();
181 
182  // Skip to next chamber if there are no LCTs to save.
183  if (alctV.empty() && clctV.empty() && lctV.empty()) continue;
184 
185  // Correlated LCTs.
186  if (!lctV.empty()) {
187  LogTrace("L1CSCTrigger")
188  << "Put " << lctV.size() << " LCT digi"
189  << ((lctV.size() > 1) ? "s " : " ") << "in collection\n";
190  oc_lct.put(std::make_pair(lctV.begin(),lctV.end()), detid);
191  }
192 
193  // Anode LCTs.
194  if (!alctV.empty()) {
195  LogTrace("L1CSCTrigger")
196  << "Put " << alctV.size() << " ALCT digi"
197  << ((alctV.size() > 1) ? "s " : " ") << "in collection\n";
198  oc_alct.put(std::make_pair(alctV.begin(),alctV.end()), detid);
199  }
200 
201  // Cathode LCTs.
202  if (!clctV.empty()) {
203  LogTrace("L1CSCTrigger")
204  << "Put " << clctV.size() << " CLCT digi"
205  << ((clctV.size() > 1) ? "s " : " ") << "in collection\n";
206  oc_clct.put(std::make_pair(clctV.begin(),clctV.end()), detid);
207  }
208 
209  // Cathode LCTs pretriggers
210  if (!preTriggerBXs.empty()) {
211  LogTrace("L1CSCTrigger")
212  << "Put " << preTriggerBXs.size() << " CLCT pretriggers"
213  << ((preTriggerBXs.size() > 1) ? "s " : " ") << "in collection\n";
214  oc_pretrig.put(std::make_pair(preTriggerBXs.begin(),preTriggerBXs.end()), detid);
215  }
216  }
217  }
218  }
219  }
220  }
221  }
222 
223  // run MPC simulation
224  m_muonportcard->loadDigis(oc_lct);
225 
226  std::vector<csctf::TrackStub> result;
227  for(int bx = m_minBX; bx <= m_maxBX; ++bx)
228  for(int e = min_endcap; e <= max_endcap; ++e)
229  for(int st = min_station; st <= max_station; ++st)
230  for(int se = min_sector; se <= max_sector; ++se)
231  {
232  if(st == 1)
233  {
234  std::vector<csctf::TrackStub> subs1, subs2;
235  subs1 = m_muonportcard->sort(e, st, se, 1, bx);
236  subs2 = m_muonportcard->sort(e, st, se, 2, bx);
237  result.insert(result.end(), subs1.begin(), subs1.end());
238  result.insert(result.end(), subs2.begin(), subs2.end());
239  }
240  else
241  {
242  std::vector<csctf::TrackStub> sector;
243  sector = m_muonportcard->sort(e, st, se, 0, bx);
244  result.insert(result.end(), sector.begin(), sector.end());
245  }
246  }
247 
248  std::vector<csctf::TrackStub>::const_iterator itr = result.begin();
249  for (; itr != result.end(); itr++) {
250  oc_sorted_lct.insertDigi(CSCDetId(itr->getDetId().rawId()), *(itr->getDigi()));
251  LogDebug("L1CSCTrigger")
252  << "MPC " << *(itr->getDigi()) << " found in ME"
253  << ((itr->endcap() == 1) ? "+" : "-") << itr->station() << "/"
254  << CSCDetId(itr->getDetId().rawId()).ring() << "/"
255  << CSCDetId(itr->getDetId().rawId()).chamber()
256  << " (sector " << itr->sector()
257  << " trig id. " << itr->cscid() << ")" << "\n";
258  }
259 }
#define LogDebug(id)
T getParameter(std::string const &) const
bool isInBadChamber(const CSCDetId &id) const
Is the gven chamber flagged as bad?
std::vector< CSCCLCTDigi > readoutCLCTs()
void run(const std::vector< int > w_time[CSCConstants::NUM_LAYERS][CSCConstants::MAX_NUM_WIRES], const std::vector< int > hs_times[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const std::vector< int > ds_times[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS])
CSCChamber * chamber(unsigned endcap, unsigned station, unsigned sector, unsigned subsector, unsigned tcscid) const
Return the CSCChamber for a corresponding endcap/station/sector/subsector/trigger cscid...
static int minEndcapId()
Definition: CSCDetId.h:238
static int maxTriggerSectorId()
void build(const CSCBadChambers *badChambers, const CSCWireDigiCollection *wiredc, const CSCComparatorDigiCollection *compdc, CSCALCTDigiCollection &oc_alct, CSCCLCTDigiCollection &oc_clct, CSCCLCTPreTriggerCollection &oc_pretrig, CSCCorrelatedLCTDigiCollection &oc_lct, CSCCorrelatedLCTDigiCollection &oc_sorted_lct)
static int maxStationId()
Definition: CSCDetId.h:241
static int minTriggerSectorId()
static int ringFromTriggerLabels(int station, int triggerCSCID)
void setConfigParameters(const CSCDBL1TPParameters *conf)
void loadDigis(const CSCCorrelatedLCTDigiCollection &thedigis)
CSCTriggerPrimitivesBuilder(const edm::ParameterSet &)
static CSCTriggerGeomManager * get()
static int minStationId()
Definition: CSCDetId.h:240
tuple result
Definition: query.py:137
static int maxEndcapId()
Definition: CSCDetId.h:239
CSCMotherboard * tmb_[MAX_ENDCAPS][MAX_STATIONS][MAX_SECTORS][MAX_SUBSECTORS][MAX_CHAMBERS]
#define LogTrace(id)
CSCAnodeLCTProcessor * alct
tuple conf
Definition: dbtoconf.py:185
std::vector< int > preTriggerBXs() const
std::vector< CSCALCTDigi > readoutALCTs()
static int minTriggerSubSectorId()
CSCCathodeLCTProcessor * clct
std::vector< csctf::TrackStub > sort(const unsigned endcap, const unsigned station, const unsigned sector, const unsigned subsector, const int bx)
void setConfigParameters(const CSCDBL1TPParameters *conf)
static int chamberFromTriggerLabels(int TriggerSector, int TriggerSubSector, int station, int TriggerCSCID)
static int maxTriggerSubSectorId()