CMS 3D CMS Logo

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