CMS 3D CMS Logo

CSCUpgradeMotherboardLUTGenerator.cc
Go to the documentation of this file.
4 
5 #include <sstream>
6 
7 void CSCUpgradeMotherboardLUTGenerator::generateLUTs(unsigned theEndcap, unsigned theStation, unsigned theSector, unsigned theSubsector, unsigned theTrigChamber) const
8 {
9  if (theStation==1) generateLUTsME11(theEndcap, theSector, theSubsector, theTrigChamber);
10  if (theStation==2) generateLUTsME21(theEndcap, theSector, theSubsector, theTrigChamber);
11 }
12 
13 void CSCUpgradeMotherboardLUTGenerator::generateLUTsME11(unsigned theEndcap, unsigned theSector, unsigned theSubsector, unsigned theTrigChamber) const
14 {
15  bool gemGeometryAvailable(false);
16  if (gem_g != nullptr) {
17  LogTrace("CSCUpgradeMotherboardLUTGenerator")
18  << "+++ generateLUTsME11() called for ME11 chamber! +++ \n";
19  gemGeometryAvailable = true;
20  }
21 
22  // check for GEM geometry
23  if (not gemGeometryAvailable){
24  LogTrace("CSCUpgradeMotherboardLUTGenerator")
25  << "+++ generateLUTsME11() called for ME11 chamber without valid GEM geometry! +++ \n";
26  return;
27  }
28 
29  // CSC trigger geometry
30  const int chid = CSCTriggerNumbering::chamberFromTriggerLabels(theSector, theSubsector, 1, theTrigChamber);
31  const CSCDetId me1bId(theEndcap, 1, 1, chid, 0);
32  const CSCDetId me1aId(theEndcap, 1, 4, chid, 0);
33  const CSCChamber* cscChamberME1b(csc_g->chamber(me1bId));
34  const CSCChamber* cscChamberME1a(csc_g->chamber(me1aId));
35  const CSCLayer* keyLayerME1b(cscChamberME1b->layer(3));
36  const CSCLayer* keyLayerME1a(cscChamberME1a->layer(3));
37 
38  // GEM trigger geometry
39  const int region((theEndcap == 1) ? 1: -1);
40  const GEMDetId gem_id_l1(region, 1, 1, 1, me1bId.chamber(), 0);
41  const GEMDetId gem_id_l2(region, 1, 1, 2, me1bId.chamber(), 0);
42  const GEMChamber* gemChamber_l1(gem_g->chamber(gem_id_l1));
43  const GEMChamber* gemChamber_l2(gem_g->chamber(gem_id_l2));
44  const GEMEtaPartition* randRoll(gemChamber_l1->etaPartition(2));
45 
46  // LUTs
47  std::vector<std::pair<double,double> > gemRollEtaLimits_l1;
48  std::vector<std::pair<double,double> > gemRollEtaLimits_l2;
49  std::vector<std::pair<double,double> > cscWGToEtaLimits;
50  std::vector<std::pair<int,int> > cscWgToGemRoll_l1;
51  std::vector<std::pair<int,int> > cscWgToGemRoll_l2;
52  std::vector<std::pair<int,int> > cscHsToGemPadME1a;
53  std::vector<std::pair<int,int> > cscHsToGemPadME1b;
54  std::vector<int> gemPadToCscHsME1a;
55  std::vector<int> gemPadToCscHsME1b;
56 
57  gemRollToEtaLimitsLUT(gemChamber_l1, gemRollEtaLimits_l1);
58  gemRollToEtaLimitsLUT(gemChamber_l2, gemRollEtaLimits_l2);
59  cscWgToEtaLimitsLUT(keyLayerME1b, cscWGToEtaLimits);
60  cscWgToRollLUT(cscWGToEtaLimits, gemRollEtaLimits_l1, cscWgToGemRoll_l1);
61  cscWgToRollLUT(cscWGToEtaLimits, gemRollEtaLimits_l2, cscWgToGemRoll_l2);
62  cscHsToGemPadLUT(keyLayerME1a, randRoll, 4, 93, cscHsToGemPadME1a);
63  cscHsToGemPadLUT(keyLayerME1b, randRoll, 5, 124, cscHsToGemPadME1b);
64  gemPadToCscHsLUT(keyLayerME1a, randRoll, gemPadToCscHsME1a);
65  gemPadToCscHsLUT(keyLayerME1b, randRoll, gemPadToCscHsME1b);
66 
67  // print LUTs
68  std::stringstream os;
69  os << "ME11 "<< me1bId <<std::endl;
70 
71  os << "GEM L1 roll to eta limits" << std::endl;
72  os << gemRollEtaLimits_l1;
73 
74  os << "GEM L2 roll to eta limits" << std::endl;
75  os << gemRollEtaLimits_l2;
76 
77  os << "ME1b "<< me1bId <<std::endl;
78  os << "WG roll to eta limits" << std::endl;
79  os << cscWGToEtaLimits;
80 
81  os << "WG to Roll L1" << std::endl;
82  os << cscWgToGemRoll_l1;
83 
84  os << "WG to Roll L2" << std::endl;
85  os << cscWgToGemRoll_l2;
86 
87  os << "CSC HS to GEM pad LUT in ME1a" << std::endl;
88  os << cscHsToGemPadME1a;
89 
90  os << "CSC HS to GEM pad LUT in ME1b" << std::endl;
91  os << cscHsToGemPadME1b;
92 
93  os << "GEM pad to CSC HS LUT in ME1a" << std::endl;
94  os << gemPadToCscHsME1a;
95 
96  os << "GEM pad to CSC HS LUT in ME1b" << std::endl;
97  os << gemPadToCscHsME1b;
98 
99  // print LUTs
100  LogTrace("CSCUpgradeMotherboardLUTGenerator") << os.str();
101 }
102 
103 void CSCUpgradeMotherboardLUTGenerator::generateLUTsME21(unsigned theEndcap, unsigned theSector, unsigned theSubsector, unsigned theTrigChamber) const
104 {
105  bool gemGeometryAvailable(false);
106  if (gem_g != nullptr) {
107  LogTrace("CSCUpgradeMotherboardLUTGenerator") << "+++ generateLUTsME11() called for ME21 chamber! +++ \n";
108  gemGeometryAvailable = true;
109  }
110 
111  // check for GEM geometry
112  if (not gemGeometryAvailable){
113  LogTrace("CSCUpgradeMotherboardLUTGenerator") << "+++ generateLUTsME21() called for ME21 chamber without valid GEM geometry! +++ \n";
114  return;
115  }
116 
117  // CSC trigger geometry
118  const int chid = CSCTriggerNumbering::chamberFromTriggerLabels(theSector, theSubsector, 2, theTrigChamber);
119  const CSCDetId csc_id(theEndcap, 2, 1, chid, 0);
120  const CSCChamber* cscChamber(csc_g->chamber(csc_id));
121  const CSCLayer* keyLayer(cscChamber->layer(3));
122 
123  // GEM trigger geometry
124  const int region((theEndcap == 1) ? 1: -1);
125  const GEMDetId gem_id_l1(region, 1, 2, 1, csc_id.chamber(), 0);
126  const GEMDetId gem_id_l2(region, 1, 2, 2, csc_id.chamber(), 0);
127  const GEMChamber* gemChamber_l1(gem_g->chamber(gem_id_l1));
128  const GEMChamber* gemChamber_l2(gem_g->chamber(gem_id_l2));
129  const GEMEtaPartition* randRoll(gemChamber_l1->etaPartition(2));
130 
131  // LUTs
132  std::vector<std::pair<double,double> > gemRollEtaLimits_l1;
133  std::vector<std::pair<double,double> > gemRollEtaLimits_l2;
134  std::vector<std::pair<double,double> > cscWGToEtaLimits;
135  std::vector<std::pair<int,int> > cscWgToGemRoll_l1;
136  std::vector<std::pair<int,int> > cscWgToGemRoll_l2;
137  std::vector<std::pair<int,int> > cscHsToGemPad;
138  std::vector<int> gemPadToCscHs;
139 
140  gemRollToEtaLimitsLUT(gemChamber_l1, gemRollEtaLimits_l1);
141  gemRollToEtaLimitsLUT(gemChamber_l2, gemRollEtaLimits_l2);
142  cscWgToEtaLimitsLUT(keyLayer, cscWGToEtaLimits);
143  cscWgToRollLUT(cscWGToEtaLimits, gemRollEtaLimits_l1, cscWgToGemRoll_l1);
144  cscWgToRollLUT(cscWGToEtaLimits, gemRollEtaLimits_l2, cscWgToGemRoll_l2);
145  cscHsToGemPadLUT(keyLayer, randRoll, 4, 155, cscHsToGemPad);
146  gemPadToCscHsLUT(keyLayer, randRoll, gemPadToCscHs);
147 
148  std::stringstream os;
149  os << "ME21 "<< csc_id <<std::endl;
150 
151  os << "GEM roll to eta limits L1" << std::endl;
152  os << gemRollEtaLimits_l1;
153 
154  os << "GEM roll to eta limits L2" << std::endl;
155  os << gemRollEtaLimits_l2;
156 
157  os << "WG to eta limits" << std::endl;
158  os << cscWGToEtaLimits;
159 
160  os << "WG to Roll L1" << std::endl;
161  os << cscWgToGemRoll_l1;
162 
163  os << "WG to Roll L2" << std::endl;
164  os << cscWgToGemRoll_l2;
165 
166  os << "CSC HS to GEM pad LUT in ME21" << std::endl;
167  os << cscHsToGemPad;
168 
169  os << "GEM pad to CSC HS LUT in ME21" << std::endl;
170  os << gemPadToCscHs;
171 
172  // print LUTs
173  LogTrace("CSCUpgradeMotherboardLUTGenerator") << os.str();
174 }
175 
176 int CSCUpgradeMotherboardLUTGenerator::assignRoll(const std::vector<std::pair<double,double> >& lut_, double eta) const
177 {
178  int result = -99;
179  for(const auto& p : lut_) {
180  const float minEta(p.first);
181  const float maxEta(p.second);
182  if (minEta <= std::abs(eta) and std::abs(eta) < maxEta) {
183  result = p.first;
184  break;
185  }
186  }
187  return result;
188 }
189 
190 void CSCUpgradeMotherboardLUTGenerator::gemRollToEtaLimitsLUT(const GEMChamber* gemChamber, std::vector<std::pair<double,double> >& lut) const
191 {
192  for(const auto& roll : gemChamber->etaPartitions()) {
193  const float half_striplength(roll->specs()->specificTopology().stripLength()/2.);
194  const LocalPoint lp_top(0., half_striplength, 0.);
195  const LocalPoint lp_bottom(0., -half_striplength, 0.);
196  const GlobalPoint gp_top(roll->toGlobal(lp_top));
197  const GlobalPoint gp_bottom(roll->toGlobal(lp_bottom));
198  lut.emplace_back(std::abs(gp_top.eta()), std::abs(gp_bottom.eta()));
199  }
200 }
201 
202 
203 void CSCUpgradeMotherboardLUTGenerator::cscWgToRollLUT(const std::vector<std::pair<double,double> >& inLUT1,
204  const std::vector<std::pair<double,double> >& inLUT2,
205  std::vector<std::pair<int,int> >& outLUT) const
206 {
207  for (const auto& p: inLUT1){
208  double etaMin(p.first);
209  double etaMax(p.second);
210  outLUT.emplace_back(assignRoll(inLUT2, etaMin), assignRoll(inLUT2, etaMax));
211  }
212 }
213 
214 void CSCUpgradeMotherboardLUTGenerator::cscWgToEtaLimitsLUT(const CSCLayer* keyLayer, std::vector<std::pair<double, double> >& lut) const
215 {
216  const CSCLayerGeometry* keyLayerGeometry(keyLayer->geometry());
217  const int numberOfWG(keyLayerGeometry->numberOfWireGroups());
218  for (int i = 0; i< numberOfWG; ++i){
219  const float middle_wire(keyLayerGeometry->middleWireOfGroup(i));
220  const std::pair<LocalPoint, LocalPoint> wire_ends(keyLayerGeometry->wireTopology()->wireEnds(middle_wire));
221  const GlobalPoint gp_top(keyLayer->toGlobal(wire_ends.first));
222  const GlobalPoint gp_bottom(keyLayer->toGlobal(wire_ends.first));
223  lut.emplace_back(gp_top.eta(), gp_bottom.eta());
224  }
225 }
226 
228  const GEMEtaPartition* randRoll,
229  int minH, int maxH, std::vector<std::pair<int,int> >& lut) const
230 {
231  const CSCLayerGeometry* keyLayerGeometry(keyLayer->geometry());
232  auto nStrips(keyLayerGeometry->numberOfStrips());
233  for (float i = 0; i< nStrips; i = i+0.5){
234  const LocalPoint lpCSC(keyLayerGeometry->topology()->localPosition(i));
235  const GlobalPoint gp(keyLayer->toGlobal(lpCSC));
236  const LocalPoint lpGEM(randRoll->toLocal(gp));
237  const int HS(i/0.5);
238  const bool edge(HS < minH or HS > maxH);
239  const float pad(edge ? -99 : randRoll->pad(lpGEM));
240  lut.emplace_back(std::floor(pad),std::ceil(pad));
241  }
242 }
243 
244 void
246  const GEMEtaPartition* randRoll,
247  std::vector<int>& lut) const
248 {
249  const int nGEMPads(randRoll->npads());
250  const CSCLayerGeometry* keyLayerGeometry(keyLayer->geometry());
251  for (int i = 1; i<= nGEMPads; ++i){
252  const LocalPoint lpGEM(randRoll->centreOfPad(i));
253  const GlobalPoint gp(randRoll->toGlobal(lpGEM));
254  const LocalPoint lpCSC(keyLayer->toLocal(gp));
255  const float strip(keyLayerGeometry->strip(lpCSC));
256  lut.push_back( (int) (strip)/0.5 );
257  }
258 }
int chamber() const
Definition: CSCDetId.h:68
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:54
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
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
const std::vector< const GEMEtaPartition * > & etaPartitions() const
Return the eta partitions.
Definition: GEMChamber.cc:39
#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:95
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
Definition: CSCGeometry.cc:133
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)