CMS 3D CMS Logo

CSCUpgradeMotherboardLUTGenerator.cc
Go to the documentation of this file.
5 
6 #include <sstream>
7 
8 void CSCUpgradeMotherboardLUTGenerator::generateLUTs(unsigned theEndcap, unsigned theStation, unsigned theSector, unsigned theSubsector, unsigned theTrigChamber) const
9 {
10  if (theStation==1) generateLUTsME11(theEndcap, theSector, theSubsector, theTrigChamber);
11  if (theStation==2) generateLUTsME21(theEndcap, theSector, theSubsector, theTrigChamber);
12  if (theStation==3) generateLUTsME3141(theEndcap, 3, theSector, theSubsector, theTrigChamber);
13  if (theStation==4) generateLUTsME3141(theEndcap, 4, theSector, theSubsector, theTrigChamber);
14 }
15 
16 void CSCUpgradeMotherboardLUTGenerator::generateLUTsME11(unsigned theEndcap, unsigned theSector, unsigned theSubsector, unsigned theTrigChamber) const
17 {
18  bool gemGeometryAvailable(false);
19  if (gem_g != nullptr) {
20  LogTrace("CSCUpgradeMotherboardLUTGenerator")
21  << "+++ generateLUTsME11() called for ME11 chamber! +++ \n";
22  gemGeometryAvailable = true;
23  }
24 
25  // check for GEM geometry
26  if (not gemGeometryAvailable){
27  LogTrace("CSCUpgradeMotherboardLUTGenerator")
28  << "+++ generateLUTsME11() called for ME11 chamber without valid GEM geometry! +++ \n";
29  return;
30  }
31 
32  // CSC trigger geometry
33  const int chid = CSCTriggerNumbering::chamberFromTriggerLabels(theSector, theSubsector, 1, theTrigChamber);
34  const CSCDetId me1bId(theEndcap, 1, 1, chid, 0);
35  const CSCDetId me1aId(theEndcap, 1, 4, chid, 0);
36  const CSCChamber* cscChamberME1b(csc_g->chamber(me1bId));
37  const CSCChamber* cscChamberME1a(csc_g->chamber(me1aId));
38  const CSCLayer* keyLayerME1b(cscChamberME1b->layer(3));
39  const CSCLayer* keyLayerME1a(cscChamberME1a->layer(3));
40 
41  // GEM trigger geometry
42  const int region((theEndcap == 1) ? 1: -1);
43  const GEMDetId gem_id_l1(region, 1, 1, 1, me1bId.chamber(), 0);
44  const GEMDetId gem_id_l2(region, 1, 1, 2, me1bId.chamber(), 0);
45  const GEMChamber* gemChamber_l1(gem_g->chamber(gem_id_l1));
46  const GEMChamber* gemChamber_l2(gem_g->chamber(gem_id_l2));
47  const GEMEtaPartition* randRoll(gemChamber_l1->etaPartition(2));
48 
49  // LUTs
50  std::vector<std::pair<double,double> > gemRollEtaLimits_l1;
51  std::vector<std::pair<double,double> > gemRollEtaLimits_l2;
52  std::vector<std::pair<double,double> > cscWGToEtaLimits;
53  std::vector<std::pair<int,int> > cscWgToGemRoll_l1;
54  std::vector<std::pair<int,int> > cscWgToGemRoll_l2;
55  std::vector<std::pair<int,int> > cscHsToGemPadME1a;
56  std::vector<std::pair<int,int> > cscHsToGemPadME1b;
57  std::vector<int> gemPadToCscHsME1a;
58  std::vector<int> gemPadToCscHsME1b;
59 
60  gemRollToEtaLimitsLUT(gemChamber_l1, gemRollEtaLimits_l1);
61  gemRollToEtaLimitsLUT(gemChamber_l2, gemRollEtaLimits_l2);
62  cscWgToEtaLimitsLUT(keyLayerME1b, cscWGToEtaLimits);
63  cscWgToRollLUT(cscWGToEtaLimits, gemRollEtaLimits_l1, cscWgToGemRoll_l1);
64  cscWgToRollLUT(cscWGToEtaLimits, gemRollEtaLimits_l2, cscWgToGemRoll_l2);
65  cscHsToGemPadLUT(keyLayerME1a, randRoll, 4, 93, cscHsToGemPadME1a);
66  cscHsToGemPadLUT(keyLayerME1b, randRoll, 5, 124, cscHsToGemPadME1b);
67  gemPadToCscHsLUT(keyLayerME1a, randRoll, gemPadToCscHsME1a);
68  gemPadToCscHsLUT(keyLayerME1b, randRoll, gemPadToCscHsME1b);
69 
70  // print LUTs
71  std::stringstream os;
72  os << "ME11 "<< me1bId <<std::endl;
73 
74  os << "GEM L1 roll to eta limits" << std::endl;
75  os << gemRollEtaLimits_l1;
76 
77  os << "GEM L2 roll to eta limits" << std::endl;
78  os << gemRollEtaLimits_l2;
79 
80  os << "ME1b "<< me1bId <<std::endl;
81  os << "WG roll to eta limits" << std::endl;
82  os << cscWGToEtaLimits;
83 
84  os << "WG to Roll L1" << std::endl;
85  os << cscWgToGemRoll_l1;
86 
87  os << "WG to Roll L2" << std::endl;
88  os << cscWgToGemRoll_l2;
89 
90  os << "CSC HS to GEM pad LUT in ME1a" << std::endl;
91  os << cscHsToGemPadME1a;
92 
93  os << "CSC HS to GEM pad LUT in ME1b" << std::endl;
94  os << cscHsToGemPadME1b;
95 
96  os << "GEM pad to CSC HS LUT in ME1a" << std::endl;
97  os << gemPadToCscHsME1a;
98 
99  os << "GEM pad to CSC HS LUT in ME1b" << std::endl;
100  os << gemPadToCscHsME1b;
101 
102  // print LUTs
103  LogTrace("CSCUpgradeMotherboardLUTGenerator") << os.str();
104 }
105 
106 void CSCUpgradeMotherboardLUTGenerator::generateLUTsME21(unsigned theEndcap, unsigned theSector, unsigned theSubsector, unsigned theTrigChamber) const
107 {
108  bool gemGeometryAvailable(false);
109  if (gem_g != nullptr) {
110  LogTrace("CSCUpgradeMotherboardLUTGenerator") << "+++ generateLUTsME11() called for ME21 chamber! +++ \n";
111  gemGeometryAvailable = true;
112  }
113 
114  // check for GEM geometry
115  if (not gemGeometryAvailable){
116  LogTrace("CSCUpgradeMotherboardLUTGenerator") << "+++ generateLUTsME21() called for ME21 chamber without valid GEM geometry! +++ \n";
117  return;
118  }
119 
120  // CSC trigger geometry
121  const int chid = CSCTriggerNumbering::chamberFromTriggerLabels(theSector, theSubsector, 2, theTrigChamber);
122  const CSCDetId csc_id(theEndcap, 2, 1, chid, 0);
123  const CSCChamber* cscChamber(csc_g->chamber(csc_id));
124  const CSCLayer* keyLayer(cscChamber->layer(3));
125 
126  // GEM trigger geometry
127  const int region((theEndcap == 1) ? 1: -1);
128  const GEMDetId gem_id_l1(region, 1, 2, 1, csc_id.chamber(), 0);
129  const GEMDetId gem_id_l2(region, 1, 2, 2, csc_id.chamber(), 0);
130  const GEMChamber* gemChamber_l1(gem_g->chamber(gem_id_l1));
131  const GEMChamber* gemChamber_l2(gem_g->chamber(gem_id_l2));
132  const GEMEtaPartition* randRoll(gemChamber_l1->etaPartition(2));
133 
134  // LUTs
135  std::vector<std::pair<double,double> > gemRollEtaLimits_l1;
136  std::vector<std::pair<double,double> > gemRollEtaLimits_l2;
137  std::vector<std::pair<double,double> > cscWGToEtaLimits;
138  std::vector<std::pair<int,int> > cscWgToGemRoll_l1;
139  std::vector<std::pair<int,int> > cscWgToGemRoll_l2;
140  std::vector<std::pair<int,int> > cscHsToGemPad;
141  std::vector<int> gemPadToCscHs;
142 
143  gemRollToEtaLimitsLUT(gemChamber_l1, gemRollEtaLimits_l1);
144  gemRollToEtaLimitsLUT(gemChamber_l2, gemRollEtaLimits_l2);
145  cscWgToEtaLimitsLUT(keyLayer, cscWGToEtaLimits);
146  cscWgToRollLUT(cscWGToEtaLimits, gemRollEtaLimits_l1, cscWgToGemRoll_l1);
147  cscWgToRollLUT(cscWGToEtaLimits, gemRollEtaLimits_l2, cscWgToGemRoll_l2);
148  cscHsToGemPadLUT(keyLayer, randRoll, 4, 155, cscHsToGemPad);
149  gemPadToCscHsLUT(keyLayer, randRoll, gemPadToCscHs);
150 
151  std::stringstream os;
152  os << "ME21 "<< csc_id <<std::endl;
153 
154  os << "GEM roll to eta limits L1" << std::endl;
155  os << gemRollEtaLimits_l1;
156 
157  os << "GEM roll to eta limits L2" << std::endl;
158  os << gemRollEtaLimits_l2;
159 
160  os << "WG to eta limits" << std::endl;
161  os << cscWGToEtaLimits;
162 
163  os << "WG to Roll L1" << std::endl;
164  os << cscWgToGemRoll_l1;
165 
166  os << "WG to Roll L2" << std::endl;
167  os << cscWgToGemRoll_l2;
168 
169  os << "CSC HS to GEM pad LUT in ME21" << std::endl;
170  os << cscHsToGemPad;
171 
172  os << "GEM pad to CSC HS LUT in ME21" << std::endl;
173  os << gemPadToCscHs;
174 
175  // print LUTs
176  LogTrace("CSCUpgradeMotherboardLUTGenerator") << os.str();
177 }
178 
179 void CSCUpgradeMotherboardLUTGenerator::generateLUTsME3141(unsigned theEndcap, unsigned theStation, unsigned theSector, unsigned theSubsector, unsigned theTrigChamber) const
180 {
181  bool rpcGeometryAvailable(false);
182  if (rpc_g != nullptr) {
183  LogTrace("CSCUpgradeMotherboardLUTGenerator")<< "+++ generateLUTsME3141() called for ME3141 chamber! +++ \n";
184  rpcGeometryAvailable = true;
185  }
186 
187  if (not rpcGeometryAvailable){
188  LogTrace("CSCUpgradeMotherboardLUTGenerator") << "+++ generateLUTsME3141() called for ME3141 chamber without valid RPC geometry! +++ \n";
189  return;
190  }
191 
192  // CSC trigger geometry
193  const int chid = CSCTriggerNumbering::chamberFromTriggerLabels(theSector, theSubsector, theStation, theTrigChamber);
194  const CSCDetId csc_id(theEndcap, theStation, 1, chid, 0);
195  const CSCChamber* cscChamber(csc_g->chamber(csc_id));
196  const CSCLayer* keyLayer(cscChamber->layer(3));
197 
198  // RPC trigger geometry
199  const RPCDetId rpc_id(getRPCfromCSC(csc_id));
200  const RPCChamber* rpcChamber(rpc_g->chamber(rpc_id));
201  const RPCRoll* randRoll(rpcChamber->roll(2));
202 
203  // LUTs
204  std::vector<std::pair<double,double> > rpcRollToEtaLimits;
205  std::vector<std::pair<double,double> > cscWGToEtaLimits;
206  std::vector<std::pair<int,int> > cscWgToRpcRoll;
207  std::vector<std::pair<int,int> > cscHsToRpcStrip;
208  std::vector<int> rpcStripToCscHs;
209 
210  rpcRollToEtaLimitsLUT(rpcChamber, rpcRollToEtaLimits);
211  cscWgToEtaLimitsLUT(keyLayer, cscWGToEtaLimits);
212  cscWgToRollLUT(cscWGToEtaLimits, rpcRollToEtaLimits, cscWgToRpcRoll);
213  cscHsToRpcStripLUT(keyLayer, randRoll, 5, 155, cscHsToRpcStrip);
214  rpcStripToCscHsLUT(keyLayer, randRoll, rpcStripToCscHs);
215 
216  std::stringstream os;
217  os << "ME31/41 "<< csc_id <<std::endl;
218 
219  os << "RPC roll to eta limits" << std::endl;
220  os << rpcRollToEtaLimits;
221 
222  os << "WG to eta limits" << std::endl;
223  os << cscWGToEtaLimits;
224 
225  os << "WG to Roll" << std::endl;
226  os << cscWgToRpcRoll;
227 
228  os << "CSC HS to RPC strip LUT in ME3141" << std::endl;
229  os << cscHsToRpcStrip;
230 
231  os << "RPC strip to CSC HS LUT in ME3141" << std::endl;
232  os << rpcStripToCscHs;
233 
234  // print LUTs
235  LogTrace("CSCUpgradeMotherboardLUTGenerator") << os.str();
236 }
237 
238 int CSCUpgradeMotherboardLUTGenerator::assignRoll(const std::vector<std::pair<double,double> >& lut_, double eta) const
239 {
240  int result = -99;
241  for(const auto& p : lut_) {
242  const float minEta(p.first);
243  const float maxEta(p.second);
244  if (minEta <= std::abs(eta) and std::abs(eta) < maxEta) {
245  result = p.first;
246  break;
247  }
248  }
249  return result;
250 }
251 
252 void CSCUpgradeMotherboardLUTGenerator::gemRollToEtaLimitsLUT(const GEMChamber* gemChamber, std::vector<std::pair<double,double> >& lut) const
253 {
254  for(const auto& roll : gemChamber->etaPartitions()) {
255  const float half_striplength(roll->specs()->specificTopology().stripLength()/2.);
256  const LocalPoint lp_top(0., half_striplength, 0.);
257  const LocalPoint lp_bottom(0., -half_striplength, 0.);
258  const GlobalPoint gp_top(roll->toGlobal(lp_top));
259  const GlobalPoint gp_bottom(roll->toGlobal(lp_bottom));
260  lut.emplace_back(std::abs(gp_top.eta()), std::abs(gp_bottom.eta()));
261  }
262 }
263 
264 
265 void CSCUpgradeMotherboardLUTGenerator::rpcRollToEtaLimitsLUT(const RPCChamber* rpcChamber, std::vector<std::pair<double,double> >& lut) const
266 {
267  for(const auto& roll : rpcChamber->rolls()) {
268  const float half_striplength(roll->specs()->specificTopology().stripLength()/2.);
269  const LocalPoint lp_top(0., half_striplength, 0.);
270  const LocalPoint lp_bottom(0., -half_striplength, 0.);
271  const GlobalPoint gp_top(roll->toGlobal(lp_top));
272  const GlobalPoint gp_bottom(roll->toGlobal(lp_bottom));
273  lut.push_back(std::make_pair(std::abs(gp_top.eta()), std::abs(gp_bottom.eta())));
274  }
275 }
276 
277 void CSCUpgradeMotherboardLUTGenerator::cscWgToRollLUT(const std::vector<std::pair<double,double> >& inLUT1,
278  const std::vector<std::pair<double,double> >& inLUT2,
279  std::vector<std::pair<int,int> >& outLUT) const
280 {
281  for (const auto& p: inLUT1){
282  double etaMin(p.first);
283  double etaMax(p.second);
284  outLUT.emplace_back(assignRoll(inLUT2, etaMin), assignRoll(inLUT2, etaMax));
285  }
286 }
287 
288 void CSCUpgradeMotherboardLUTGenerator::cscWgToEtaLimitsLUT(const CSCLayer* keyLayer, std::vector<std::pair<double, double> >& lut) const
289 {
290  const CSCLayerGeometry* keyLayerGeometry(keyLayer->geometry());
291  const int numberOfWG(keyLayerGeometry->numberOfWireGroups());
292  for (int i = 0; i< numberOfWG; ++i){
293  const float middle_wire(keyLayerGeometry->middleWireOfGroup(i));
294  const std::pair<LocalPoint, LocalPoint> wire_ends(keyLayerGeometry->wireTopology()->wireEnds(middle_wire));
295  const GlobalPoint gp_top(keyLayer->toGlobal(wire_ends.first));
296  const GlobalPoint gp_bottom(keyLayer->toGlobal(wire_ends.first));
297  lut.emplace_back(gp_top.eta(), gp_bottom.eta());
298  }
299 }
300 
302  const GEMEtaPartition* randRoll,
303  int minH, int maxH, std::vector<std::pair<int,int> >& lut) const
304 {
305  const CSCLayerGeometry* keyLayerGeometry(keyLayer->geometry());
306  auto nStrips(keyLayerGeometry->numberOfStrips());
307  for (float i = 0; i< nStrips; i = i+0.5){
308  const LocalPoint lpCSC(keyLayerGeometry->topology()->localPosition(i));
309  const GlobalPoint gp(keyLayer->toGlobal(lpCSC));
310  const LocalPoint lpGEM(randRoll->toLocal(gp));
311  const int HS(i/0.5);
312  const bool edge(HS < minH or HS > maxH);
313  const float pad(edge ? -99 : randRoll->pad(lpGEM));
314  lut.emplace_back(std::floor(pad),std::ceil(pad));
315  }
316 }
317 
318 void
320  const GEMEtaPartition* randRoll,
321  std::vector<int>& lut) const
322 {
323  const int nGEMPads(randRoll->npads());
324  const CSCLayerGeometry* keyLayerGeometry(keyLayer->geometry());
325  for (int i = 1; i<= nGEMPads; ++i){
326  const LocalPoint lpGEM(randRoll->centreOfPad(i));
327  const GlobalPoint gp(randRoll->toGlobal(lpGEM));
328  const LocalPoint lpCSC(keyLayer->toLocal(gp));
329  const float strip(keyLayerGeometry->strip(lpCSC));
330  lut.push_back( (int) (strip)/0.5 );
331  }
332 }
333 
334 void
336  const RPCRoll* randRoll,
337  int minH, int maxH, std::vector<std::pair<int,int> >& lut) const
338 {
339  const CSCLayerGeometry* keyLayerGeometry(keyLayer->geometry());
340  auto nStrips(keyLayerGeometry->numberOfStrips());
341  for (float i = 0; i< nStrips; i = i+0.5){
342  const LocalPoint lpCSC(keyLayerGeometry->topology()->localPosition(i));
343  const GlobalPoint gp(keyLayer->toGlobal(lpCSC));
344  const LocalPoint lpRPC(randRoll->toLocal(gp));
345  const int HS(i/0.5);
346  const bool edge(HS < minH or HS > maxH);
347  const float strip(edge ? -99 : randRoll->strip(lpRPC));
348  lut.emplace_back(std::floor(strip),std::ceil(strip));
349  }
350 }
351 
352 void
354  const RPCRoll* randRoll, std::vector<int>& lut) const
355 {
356  const int nRPCStrips(randRoll->nstrips());
357  const CSCLayerGeometry* keyLayerGeometry(keyLayer->geometry());
358  for (int i = 1; i<= nRPCStrips; ++i){
359  const LocalPoint lpRPC(randRoll->centreOfStrip(i));
360  const GlobalPoint gp(randRoll->toGlobal(lpRPC));
361  const LocalPoint lpCSC(keyLayer->toLocal(gp));
362  const float strip(keyLayerGeometry->strip(lpCSC));
363  lut.push_back( (int) (strip-0.25)/0.5 );
364  }
365 }
int chamber() const
Definition: CSCDetId.h:68
float strip(const LocalPoint &lp) const
Definition: RPCRoll.cc:71
LocalPoint centreOfStrip(int strip) const
Definition: RPCRoll.cc:52
void cscHsToRpcStripLUT(const CSCLayer *, const RPCRoll *, int minH, int maxH, std::vector< std::pair< int, int > > &) const
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:54
void generateLUTsME3141(unsigned e, unsigned s, unsigned se, unsigned sb, unsigned c) const
int nstrips() const
Definition: RPCRoll.cc:46
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:69
double maxEta
int assignRoll(const std::vector< std::pair< double, double > > &, double eta) const
const RPCChamber * chamber(RPCDetId id) const
Definition: RPCGeometry.cc:71
void cscHsToGemPadLUT(const CSCLayer *, const GEMEtaPartition *, int minH, int maxH, std::vector< std::pair< int, int > > &) const
void gemRollToEtaLimitsLUT(const GEMChamber *c, std::vector< std::pair< double, double > > &) const
float pad(const LocalPoint &lp) const
returns FRACTIONAL pad number [0.,npads] for a point
const std::vector< const RPCRoll * > & rolls() const
Return the Rolls.
Definition: RPCChamber.cc:68
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int npads() const
number of GEM-CSC trigger readout pads in partition
void rpcStripToCscHsLUT(const CSCLayer *, const RPCRoll *, std::vector< int > &) const
void cscWgToEtaLimitsLUT(const CSCLayer *, std::vector< std::pair< double, double > > &) const
const std::vector< const GEMEtaPartition * > & etaPartitions() const
Return the eta partitions.
Definition: GEMChamber.cc:39
#define LogTrace(id)
void rpcRollToEtaLimitsLUT(const RPCChamber *c, std::vector< std::pair< double, double > > &) const
void cscWgToRollLUT(const std::vector< std::pair< double, double > > &, const std::vector< std::pair< double, double > > &, std::vector< std::pair< int, int > > &) const
const GEMChamber * chamber(GEMDetId id) const
Definition: GEMGeometry.cc:95
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
Definition: CSCGeometry.cc:118
void generateLUTsME21(unsigned e, unsigned se, unsigned sb, unsigned c) const
LocalPoint centreOfPad(int pad) const
void generateLUTs(unsigned e, unsigned s, unsigned se, unsigned sb, unsigned c) const
generate and print LUT
void generateLUTsME11(unsigned e, unsigned se, unsigned sb, unsigned c) const
void gemPadToCscHsLUT(const CSCLayer *, const GEMEtaPartition *, std::vector< int > &) const
const CSCLayerGeometry * geometry() const
Definition: CSCLayer.h:47
static int chamberFromTriggerLabels(int TriggerSector, int TriggerSubSector, int station, int TriggerCSCID)