CMS 3D CMS Logo

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