CMS 3D CMS Logo

CSCUpgradeMotherboardLUTGenerator.cc
Go to the documentation of this file.
4 
5 #include <sstream>
6 
8  unsigned theEndcap, unsigned theStation, unsigned theSector, unsigned theSubsector, unsigned theTrigChamber) const {
9  if (theStation == 1)
10  generateLUTsME11(theEndcap, theSector, theSubsector, theTrigChamber);
11  if (theStation == 2)
12  generateLUTsME21(theEndcap, theSector, theSubsector, theTrigChamber);
13 }
14 
16  unsigned theSector,
17  unsigned theSubsector,
18  unsigned theTrigChamber) const {
19  bool gemGeometryAvailable(false);
20  if (gem_g != nullptr) {
21  LogTrace("CSCUpgradeMotherboardLUTGenerator") << "+++ 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(4));
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  std::vector<int> gemRollToCscWg1b;
60 
61  gemRollToEtaLimitsLUT(gemChamber_l1, gemRollEtaLimits_l1);
62  gemRollToEtaLimitsLUT(gemChamber_l2, gemRollEtaLimits_l2);
63  cscWgToEtaLimitsLUT(keyLayerME1b, cscWGToEtaLimits);
64  cscWgToRollLUT(cscWGToEtaLimits, gemRollEtaLimits_l1, cscWgToGemRoll_l1);
65  cscWgToRollLUT(cscWGToEtaLimits, gemRollEtaLimits_l2, cscWgToGemRoll_l2);
66  cscHsToGemPadLUT(keyLayerME1a, randRoll, 2, 94, cscHsToGemPadME1a);
67  cscHsToGemPadLUT(keyLayerME1b, randRoll, 4, 124, cscHsToGemPadME1b);
68  gemPadToCscHsLUT(keyLayerME1a, randRoll, gemPadToCscHsME1a);
69  gemPadToCscHsLUT(keyLayerME1b, randRoll, gemPadToCscHsME1b);
70  gemRollToCscWgLUT(keyLayerME1b, gemChamber_l1, gemRollToCscWg1b);
71 
72  // print LUTs
73  std::stringstream os;
74  os << "ME11 " << me1bId << std::endl;
75 
76  os << "GEM L1 roll to eta limits" << std::endl;
77  os << gemRollEtaLimits_l1;
78 
79  os << "GEM L2 roll to eta limits" << std::endl;
80  os << gemRollEtaLimits_l2;
81 
82  os << "ME1b " << me1bId << std::endl;
83  os << "WG roll to eta limits" << std::endl;
84  os << cscWGToEtaLimits;
85 
86  os << "WG to Roll L1" << std::endl;
87  os << cscWgToGemRoll_l1;
88 
89  os << "WG to Roll L2" << std::endl;
90  os << cscWgToGemRoll_l2;
91 
92  os << "CSC HS to GEM pad LUT in ME1a" << std::endl;
93  os << cscHsToGemPadME1a;
94 
95  os << "CSC HS to GEM pad LUT in ME1b" << std::endl;
96  os << cscHsToGemPadME1b;
97 
98  os << "GEM pad to CSC HS LUT in ME1a" << std::endl;
99  os << gemPadToCscHsME1a;
100 
101  os << "GEM pad to CSC HS LUT in ME1b" << std::endl;
102  os << gemPadToCscHsME1b;
103 
104  os << "GEM roll to CSC WG" << std::endl;
105  os << gemRollToCscWg1b;
106 
107  // print LUTs
108  LogTrace("CSCUpgradeMotherboardLUTGenerator") << os.str();
109 }
110 
112  unsigned theSector,
113  unsigned theSubsector,
114  unsigned theTrigChamber) const {
115  bool gemGeometryAvailable(false);
116  if (gem_g != nullptr) {
117  LogTrace("CSCUpgradeMotherboardLUTGenerator") << "+++ generateLUTsME11() called for ME21 chamber! +++ \n";
118  gemGeometryAvailable = true;
119  }
120 
121  // check for GEM geometry
122  if (not gemGeometryAvailable) {
123  LogTrace("CSCUpgradeMotherboardLUTGenerator")
124  << "+++ generateLUTsME21() called for ME21 chamber without valid GEM geometry! +++ \n";
125  return;
126  }
127 
128  // CSC trigger geometry
129  const int chid = CSCTriggerNumbering::chamberFromTriggerLabels(theSector, theSubsector, 2, theTrigChamber);
130  const CSCDetId csc_id(theEndcap, 2, 1, chid, 0);
131  const CSCChamber* cscChamber(csc_g->chamber(csc_id));
132  const CSCLayer* keyLayer(cscChamber->layer(3));
133 
134  // GEM trigger geometry
135  const int region((theEndcap == 1) ? 1 : -1);
136  const GEMDetId gem_id_l1(region, 1, 2, 1, csc_id.chamber(), 0);
137  const GEMDetId gem_id_l2(region, 1, 2, 2, csc_id.chamber(), 0);
138  const GEMChamber* gemChamber_l1(gem_g->chamber(gem_id_l1));
139  const GEMChamber* gemChamber_l2(gem_g->chamber(gem_id_l2));
140  const GEMEtaPartition* randRoll(gemChamber_l1->etaPartition(4));
141 
142  // LUTs
143  std::vector<std::pair<double, double> > gemRollEtaLimits_l1;
144  std::vector<std::pair<double, double> > gemRollEtaLimits_l2;
145  std::vector<std::pair<double, double> > cscWGToEtaLimits;
146  std::vector<std::pair<int, int> > cscWgToGemRoll_l1;
147  std::vector<std::pair<int, int> > cscWgToGemRoll_l2;
148  std::vector<std::pair<int, int> > cscHsToGemPad;
149  std::vector<int> gemPadToCscHs;
150  std::vector<int> gemRollToCscWg;
151 
152  gemRollToEtaLimitsLUT(gemChamber_l1, gemRollEtaLimits_l1);
153  gemRollToEtaLimitsLUT(gemChamber_l2, gemRollEtaLimits_l2);
154  cscWgToEtaLimitsLUT(keyLayer, cscWGToEtaLimits);
155  cscWgToRollLUT(cscWGToEtaLimits, gemRollEtaLimits_l1, cscWgToGemRoll_l1);
156  cscWgToRollLUT(cscWGToEtaLimits, gemRollEtaLimits_l2, cscWgToGemRoll_l2);
157  cscHsToGemPadLUT(keyLayer, randRoll, 4, 155, cscHsToGemPad);
158  gemPadToCscHsLUT(keyLayer, randRoll, gemPadToCscHs);
159  gemRollToCscWgLUT(keyLayer, gemChamber_l1, gemRollToCscWg);
160 
161  std::stringstream os;
162  os << "ME21 " << csc_id << std::endl;
163 
164  os << "GEM roll to eta limits L1" << std::endl;
165  os << gemRollEtaLimits_l1;
166 
167  os << "GEM roll to eta limits L2" << std::endl;
168  os << gemRollEtaLimits_l2;
169 
170  os << "WG to eta limits" << std::endl;
171  os << cscWGToEtaLimits;
172 
173  os << "WG to Roll L1" << std::endl;
174  os << cscWgToGemRoll_l1;
175 
176  os << "WG to Roll L2" << std::endl;
177  os << cscWgToGemRoll_l2;
178 
179  os << "CSC HS to GEM pad LUT in ME21" << std::endl;
180  os << cscHsToGemPad;
181 
182  os << "GEM pad to CSC HS LUT in ME21" << std::endl;
183  os << gemPadToCscHs;
184 
185  os << "GEM roll to CSC WG" << std::endl;
186  os << gemRollToCscWg;
187 
188  // print LUTs
189  LogTrace("CSCUpgradeMotherboardLUTGenerator") << os.str();
190 }
191 
192 int CSCUpgradeMotherboardLUTGenerator::assignRoll(const std::vector<std::pair<double, double> >& lut,
193  double eta) const {
194  int result = -99;
195  int iRoll = 0;
196  for (const auto& p : lut) {
197  iRoll++;
198  const float minEta(p.first);
199  const float maxEta(p.second);
200  if (minEta <= std::abs(eta) and std::abs(eta) < maxEta) {
201  result = iRoll;
202  break;
203  }
204  }
205  return result;
206 }
207 
209  std::vector<std::pair<double, double> >& lut) const {
210  for (const auto& roll : gemChamber->etaPartitions()) {
211  const float half_striplength(roll->specs()->specificTopology().stripLength() / 2.);
212  const LocalPoint lp_top(0., half_striplength, 0.);
213  const LocalPoint lp_bottom(0., -half_striplength, 0.);
214  const GlobalPoint gp_top(roll->toGlobal(lp_top));
215  const GlobalPoint gp_bottom(roll->toGlobal(lp_bottom));
216  const double bottom_eta(std::abs(gp_bottom.eta()));
217  const double top_eta(std::abs(gp_top.eta()));
218  lut.emplace_back(std::min(bottom_eta, top_eta), std::max(bottom_eta, top_eta));
219  }
220 }
221 
222 void CSCUpgradeMotherboardLUTGenerator::cscWgToRollLUT(const std::vector<std::pair<double, double> >& inLUT1,
223  const std::vector<std::pair<double, double> >& inLUT2,
224  std::vector<std::pair<int, int> >& outLUT) const {
225  for (const auto& p : inLUT1) {
226  double etaMin(p.first);
227  double etaMax(p.second);
228  outLUT.emplace_back(assignRoll(inLUT2, etaMin), assignRoll(inLUT2, etaMax));
229  }
230 }
231 
233  std::vector<std::pair<double, double> >& lut) const {
234  const CSCLayerGeometry* keyLayerGeometry(keyLayer->geometry());
235  const int numberOfWG(keyLayerGeometry->numberOfWireGroups());
236  for (int i = 0; i < numberOfWG; ++i) {
237  const float middle_wire(keyLayerGeometry->middleWireOfGroup(i));
238  const std::pair<LocalPoint, LocalPoint> wire_ends(keyLayerGeometry->wireTopology()->wireEnds(middle_wire));
239  const GlobalPoint gp_top(keyLayer->toGlobal(wire_ends.first));
240  const GlobalPoint gp_bottom(keyLayer->toGlobal(wire_ends.second));
241  const double bottom_eta(std::abs(gp_bottom.eta()));
242  const double top_eta(std::abs(gp_top.eta()));
243  lut.emplace_back(std::min(bottom_eta, top_eta), std::max(bottom_eta, top_eta));
244  }
245 }
246 
248  const GEMEtaPartition* randRoll,
249  int minH,
250  int maxH,
251  std::vector<std::pair<int, int> >& lut) const {
252  const CSCLayerGeometry* keyLayerGeometry(keyLayer->geometry());
253  auto nStrips(keyLayerGeometry->numberOfStrips());
254  for (float i = 0; i < nStrips; i = i + 0.5) {
255  const LocalPoint lpCSC(keyLayerGeometry->topology()->localPosition(i));
256  const GlobalPoint gp(keyLayer->toGlobal(lpCSC));
257  const LocalPoint lpGEM(randRoll->toLocal(gp));
258  const float pad(randRoll->pad(lpGEM));
259  lut.emplace_back(std::floor(pad), std::ceil(pad));
260  }
261 }
262 
264  const GEMEtaPartition* randRoll,
265  std::vector<int>& lut) const {
266  const int nGEMPads(randRoll->npads());
267  const CSCLayerGeometry* keyLayerGeometry(keyLayer->geometry());
268  for (int i = 0; i < nGEMPads; ++i) {
269  const LocalPoint lpGEM(randRoll->centreOfPad(i));
270  const GlobalPoint gp(randRoll->toGlobal(lpGEM));
271  const LocalPoint lpCSC(keyLayer->toLocal(gp));
272  const float strip(keyLayerGeometry->strip(lpCSC));
273  lut.push_back(int(strip * 2));
274  }
275 }
276 
278  const GEMChamber* gemChamber,
279  std::vector<int>& lut) const {
280  const CSCLayerGeometry* keyLayerGeometry(keyLayer->geometry());
281  for (const auto& roll : gemChamber->etaPartitions()) {
282  const float half_striplength(roll->specs()->specificTopology().stripLength() / 2.);
283  const LocalPoint lp_top(0., half_striplength, 0.);
284  const LocalPoint lp_bottom(0., -half_striplength, 0.);
285  const GlobalPoint gp_top(roll->toGlobal(lp_top));
286  const GlobalPoint gp_bottom(roll->toGlobal(lp_bottom));
287  float x, y, z;
288  x = (gp_top.x() + gp_bottom.x()) / 2.;
289  y = (gp_top.y() + gp_bottom.y()) / 2.;
290  z = (gp_top.z() + gp_bottom.z()) / 2.;
291  const GlobalPoint gp_ave(x, y, z);
292  const LocalPoint lp_ave(keyLayer->toLocal(gp_ave));
293  const int wire(keyLayerGeometry->nearestWire(lp_ave));
294  const int wg(keyLayerGeometry->wireGroup(wire));
295  lut.emplace_back(wg);
296  }
297 }
int chamber() const
Definition: CSCDetId.h:62
constexpr float minEta
Definition: Common.h:9
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
void gemRollToCscWgLUT(const CSCLayer *, const GEMChamber *, std::vector< int > &) const
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:58
double maxEta
constexpr int32_t ceil(float num)
nStrips
1.2 is to make the matching window safely the two nearest strips 0.35 is the size of an ME0 chamber i...
int assignRoll(const std::vector< std::pair< double, double > > &, double eta) const
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
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int npads() const
number of GEM-CSC trigger readout pads in partition
void cscWgToEtaLimitsLUT(const CSCLayer *, std::vector< std::pair< double, double > > &) const
T min(T a, T b)
Definition: MathUtil.h:58
const std::vector< const GEMEtaPartition * > & etaPartitions() const
Return the eta partitions.
Definition: GEMChamber.cc:29
#define LogTrace(id)
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:73
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
Definition: CSCGeometry.cc:100
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:44
static int chamberFromTriggerLabels(int TriggerSector, int TriggerSubSector, int station, int TriggerCSCID)