CMS 3D CMS Logo

CSCGEMTriggerLUTGenerator.cc
Go to the documentation of this file.
4 
5 void CSCGEMTriggerLUTGenerator::generateLUTsME11(unsigned theEndcap, unsigned theStation, unsigned theSector, unsigned theSubsector, unsigned theTrigChamber)
6 {
7  bool gemGeometryAvailable(false);
8  if (gem_g != nullptr) {
9  LogTrace("CSCGEMTriggerLUTGenerator")
10  << "+++ generateLUTsME11() called for ME11 chamber! +++ \n";
11  gemGeometryAvailable = true;
12  }
13 
14  // CSC geometry
16  const CSCChamber* cscChamberME1b(geo_manager->chamber(theEndcap, theStation, theSector, theSubsector, theTrigChamber));
17  const CSCDetId me1bId(cscChamberME1b->id());
18  const CSCDetId me1aId(me1bId.endcap(), 1, 4, me1bId.chamber());
19  const CSCChamber* cscChamberME1a(csc_g->chamber(me1aId));
20 
21  // check for GEM geometry
22  if (not gemGeometryAvailable){
23  LogTrace("CSCGEMTriggerLUTGenerator")
24  << "+++ generateLUTsME11() called for ME11 chamber without valid GEM geometry! +++ \n";
25  return;
26  }
27 
28  // CSC trigger geometry
29  const CSCLayer* keyLayerME1b(cscChamberME1b->layer(3));
30  const CSCLayerGeometry* keyLayerGeometryME1b(keyLayerME1b->geometry());
31  const CSCLayer* keyLayerME1a(cscChamberME1a->layer(3));
32  const CSCLayerGeometry* keyLayerGeometryME1a(keyLayerME1a->geometry());
33 
34  const int region((theEndcap == 1) ? 1: -1);
35  const GEMDetId gem_id(region, 1, theStation, 1, me1bId.chamber(), 0);
36  const GEMChamber* gemChamber(gem_g->chamber(gem_id));
37 
38  // LUT<roll,<etaMin,etaMax> >
39  std::vector<std::pair<double,double> > gemRollToEtaLimits_;
40 
41  for(auto roll : gemChamber->etaPartitions()) {
42  const float half_striplength(roll->specs()->specificTopology().stripLength()/2.);
43  const LocalPoint lp_top(0., half_striplength, 0.);
44  const LocalPoint lp_bottom(0., -half_striplength, 0.);
45  const GlobalPoint gp_top(roll->toGlobal(lp_top));
46  const GlobalPoint gp_bottom(roll->toGlobal(lp_bottom));
47  gemRollToEtaLimits_.push_back(std::make_pair(gp_top.eta(), gp_bottom.eta()));
48  }
49 
50  LogTrace("CSCGEMTriggerLUTGenerator") << "GEM roll to eta limits" << std::endl;
51  for(auto p : gemRollToEtaLimits_) {
52  LogTrace("CSCGEMTriggerLUTGenerator") << "{" << p.first << ", " << p.second << "}, " << std::endl;
53  }
54 
55  // LUT<WG,<etaMin,etaMax> >
56  std::vector<std::pair<double,double> > cscWGToEtaLimits_;
57 
58  const int numberOfWG(keyLayerGeometryME1b->numberOfWireGroups());
59  for (int i = 0; i< numberOfWG; ++i){
60  const float middle_wire(keyLayerGeometryME1b->middleWireOfGroup(i));
61  const std::pair<LocalPoint, LocalPoint> wire_ends(keyLayerGeometryME1b->wireTopology()->wireEnds(middle_wire));
62 
63  const GlobalPoint gp_top(keyLayerME1b->toGlobal(wire_ends.first));
64  const GlobalPoint gp_bottom(keyLayerME1b->toGlobal(wire_ends.first));
65  cscWGToEtaLimits_.push_back(std::make_pair(gp_top.eta(), gp_bottom.eta()));
66  }
67 
68  LogTrace("CSCGEMTriggerLUTGenerator") << "ME1b "<< me1bId <<std::endl;
69  LogTrace("CSCGEMTriggerLUTGenerator") << "WG roll to eta limits" << std::endl;
70  for(auto p : cscWGToEtaLimits_) {
71  LogTrace("CSCGEMTriggerLUTGenerator") << "{" << p.first << ", " << p.second << "}, " << std::endl;
72  }
73 
74  // LUT <WG,rollMin,rollMax>
75  std::vector<std::pair<int,int> > cscWgToGemRoll_;
76 
77  for (int i = 0; i< numberOfWG; ++i){
78  auto etaMin(cscWGToEtaLimits_[i].first);
79  auto etaMax(cscWGToEtaLimits_[i].second);
80  cscWgToGemRoll_.push_back(std::make_pair(assignGEMRoll(gemRollToEtaLimits_, etaMin), assignGEMRoll(gemRollToEtaLimits_, etaMax)));
81  }
82  int i = 0;
83  LogTrace("CSCGEMTriggerLUTGenerator") << "WG to ROLL" << std::endl;
84  for(auto p : cscWgToGemRoll_) {
85  LogTrace("CSCGEMTriggerLUTGenerator") << "{" << p.first << ", " << p.second << "}, " << std::endl;
86  if (i%8==0) LogTrace("CSCGEMTriggerLUTGenerator") << std::endl;
87  i++;
88  }
89 
90 
91  // map of HS to pad
92  std::vector<std::pair<int,int> > cscHsToGemPadME1a_;
93  std::vector<std::pair<int,int> > cscHsToGemPadME1b_;
94 
95  // pick any roll
96  auto randRoll(gemChamber->etaPartition(2));
97 
98  // ME1a
99  auto nStripsME1a(keyLayerGeometryME1a->numberOfStrips());
100  for (float i = 0; i< nStripsME1a; i = i+0.5){
101  const LocalPoint lpCSC(keyLayerGeometryME1a->topology()->localPosition(i));
102  const GlobalPoint gp(keyLayerME1a->toGlobal(lpCSC));
103  const LocalPoint lpGEM(randRoll->toLocal(gp));
104  const int HS(i/0.5);
105  const bool edge(HS < 4 or HS > 93);
106  const float pad(edge ? -99 : randRoll->pad(lpGEM));
107  cscHsToGemPadME1a_.push_back(std::make_pair(std::floor(pad),std::ceil(pad)));
108  }
109 
110  // ME1b
111  auto nStripsME1b(keyLayerGeometryME1b->numberOfStrips());
112  for (float i = 0; i< nStripsME1b; i = i+0.5){
113  const LocalPoint lpCSC(keyLayerGeometryME1b->topology()->localPosition(i));
114  const GlobalPoint gp(keyLayerME1b->toGlobal(lpCSC));
115  const LocalPoint lpGEM(randRoll->toLocal(gp));
116  const int HS(i/0.5);
117  const bool edge(HS < 5 or HS > 124);
118  const float pad(edge ? -99 : randRoll->pad(lpGEM));
119  cscHsToGemPadME1b_.push_back(std::make_pair(std::floor(pad),std::ceil(pad)));
120  }
121 
122  LogTrace("CSCGEMTriggerLUTGenerator") << "CSC HS to GEM pad LUT in ME1a";
123  i = 1;
124  for(auto p : cscHsToGemPadME1a_) {
125  LogTrace("CSCGEMTriggerLUTGenerator") << "{" << p.first << ", " << p.second << "}, " << std::endl;
126  if (i%8==0) LogTrace("CSCGEMTriggerLUTGenerator") << std::endl;
127  i++;
128  }
129  LogTrace("CSCGEMTriggerLUTGenerator") << "CSC HS to GEM pad LUT in ME1b";
130  i = 1;
131  for(auto p : cscHsToGemPadME1b_) {
132  LogTrace("CSCGEMTriggerLUTGenerator") << "{" << p.first << ", " << p.second << "}, " << std::endl;
133  if (i%8==0) LogTrace("CSCGEMTriggerLUTGenerator") << std::endl;
134  i++;
135  }
136 
137  // map pad to HS
138  std::vector<int> gemPadToCscHsME1a_;
139  std::vector<int> gemPadToCscHsME1b_;
140 
141  const int nGEMPads(randRoll->npads());
142  for (int i = 0; i< nGEMPads; ++i){
143  const LocalPoint lpGEM(randRoll->centreOfPad(i));
144  const GlobalPoint gp(randRoll->toGlobal(lpGEM));
145  const LocalPoint lpCSCME1a(keyLayerME1a->toLocal(gp));
146  const LocalPoint lpCSCME1b(keyLayerME1b->toLocal(gp));
147  const float stripME1a(keyLayerGeometryME1a->strip(lpCSCME1a));
148  const float stripME1b(keyLayerGeometryME1b->strip(lpCSCME1b));
149  gemPadToCscHsME1a_.push_back( (int) (stripME1a)/0.5);
150  gemPadToCscHsME1b_.push_back( (int) (stripME1b)/0.5);
151  }
152 
153  LogTrace("CSCGEMTriggerLUTGenerator") << "GEM pad to CSC HS LUT in ME1a";
154  i = 1;
155  for(auto p : gemPadToCscHsME1a_) {
156  LogTrace("CSCGEMTriggerLUTGenerator") << p;
157  if (i%8==0) LogTrace("CSCGEMTriggerLUTGenerator") << std::endl;
158  i++;
159  }
160  LogTrace("CSCGEMTriggerLUTGenerator") << "GEM pad to CSC HS LUT in ME1b";
161  i = 1;
162  for(auto p : gemPadToCscHsME1b_) {
163  LogTrace("CSCGEMTriggerLUTGenerator") << p;
164  if (i%8==0) LogTrace("CSCGEMTriggerLUTGenerator") << std::endl;
165  i++;
166  }
167 }
168 
169 void CSCGEMTriggerLUTGenerator::generateLUTsME21(unsigned theEndcap, unsigned theStation, unsigned theSector, unsigned theSubsector, unsigned theTrigChamber)
170 {
171  bool gemGeometryAvailable(false);
172  if (gem_g != nullptr) {
173  LogTrace("CSCGEMTriggerLUTGenerator") << "+++ generateLUTsME11() called for ME21 chamber! +++ \n";
174  gemGeometryAvailable = true;
175  }
176 
177  // retrieve CSCChamber geometry
179  const CSCChamber* cscChamber(geo_manager->chamber(theEndcap, theStation, theSector, theSubsector, theTrigChamber));
180  const CSCDetId csc_id(cscChamber->id());
181 
182  // check for GEM geometry
183  if (not gemGeometryAvailable){
184  LogTrace("CSCGEMTriggerLUTGenerator") << "+++ generateLUTsME11() called for ME21 chamber without valid GEM geometry! +++ \n";
185  return;
186  }
187 
188  // trigger geometry
189  const CSCLayer* keyLayer(cscChamber->layer(3));
190  const CSCLayerGeometry* keyLayerGeometry(keyLayer->geometry());
191 
192  const int region((theEndcap == 1) ? 1: -1);
193  const GEMDetId gem_id(region, 1, 2, 1, csc_id.chamber(), 0);
194  const GEMChamber* gemChamber(gem_g->chamber(gem_id));
195 
196  LogTrace("CSCGEMTriggerLUTGenerator") << "ME21 "<< csc_id <<std::endl;
197 
198  // LUT<roll,<etaMin,etaMax> >
199  std::vector<std::pair<double,double> > gemRollToEtaLimits_;
200  int n = 1;
201  for(auto roll : gemChamber->etaPartitions()) {
202  const float half_striplength(roll->specs()->specificTopology().stripLength()/2.);
203  const LocalPoint lp_top(0., half_striplength, 0.);
204  const LocalPoint lp_bottom(0., -half_striplength, 0.);
205  const GlobalPoint gp_top(roll->toGlobal(lp_top));
206  const GlobalPoint gp_bottom(roll->toGlobal(lp_bottom));
207  gemRollToEtaLimits_[n] = std::make_pair(gp_top.eta(), gp_bottom.eta());
208  ++n;
209  }
210 
211  LogTrace("CSCGEMTriggerLUTGenerator") << "GEM roll to eta limits" << std::endl;
212  for(auto p : gemRollToEtaLimits_) {
213  LogTrace("CSCGEMTriggerLUTGenerator") << "{"<< p.first << ", " << p.second << "}, " << std::endl;
214  }
215 
216  // LUT<WG,<etaMin,etaMax> >
217  std::vector<double> cscWGToEtaLimits_;
218  const int numberOfWG(keyLayerGeometry->numberOfWireGroups());
219  n = 1;
220  for (int i = 0; i< numberOfWG; ++i){
221  const LocalPoint wire_loc(keyLayerGeometry->localCenterOfWireGroup(i));
222  const GlobalPoint gp(keyLayer->toGlobal(wire_loc));
223  cscWGToEtaLimits_.push_back( gp.eta() );
224  ++n;
225  }
226 
227  LogTrace("CSCGEMTriggerLUTGenerator") << "WG to eta limits" << std::endl;
228  for(auto p : cscWGToEtaLimits_) {
229  LogTrace("CSCGEMTriggerLUTGenerator") << p << std::endl;
230  }
231 
232  // LUT <WG,rollMin,rollMax>
233  std::vector<int> cscWgToGemRoll_;
234  for (int i = 0; i< numberOfWG; ++i){
235  auto eta(cscWGToEtaLimits_[i]);
236  cscWgToGemRoll_.push_back( assignGEMRoll(gemRollToEtaLimits_, eta) );
237  }
238 
239  LogTrace("CSCGEMTriggerLUTGenerator") << "WG to roll" << std::endl;
240  int i = 1;
241  for(auto p : cscWgToGemRoll_) {
242  LogTrace("CSCGEMTriggerLUTGenerator") << p;
243  if (i%8==0) LogTrace("CSCGEMTriggerLUTGenerator") << std::endl;
244  i++;
245  }
246 
247  // vector of pad to HS
248  std::vector<int> gemPadToCscHs_;
249  std::vector<std::pair<int,int>> cscHsToGemPad_;
250 
251  auto randRoll(gemChamber->etaPartition(2));
252  auto nStrips(keyLayerGeometry->numberOfStrips());
253  for (float i = 0; i< nStrips; i = i+0.5){
254  const LocalPoint lpCSC(keyLayerGeometry->topology()->localPosition(i));
255  const GlobalPoint gp(keyLayer->toGlobal(lpCSC));
256  const LocalPoint lpGEM(randRoll->toLocal(gp));
257  const int HS(i/0.5);
258  const bool edge(HS < 5 or HS > 155);
259  const float pad(edge ? -99 : randRoll->pad(lpGEM));
260  // HS are wrapped-around
261  cscHsToGemPad_.push_back( std::make_pair(std::floor(pad),std::ceil(pad)) );
262  }
263 
264  LogTrace("CSCGEMTriggerLUTGenerator") << "CSC HS to GEM pad LUT in ME21";
265  i = 1;
266  for(auto p : cscHsToGemPad_) {
267  LogTrace("CSCGEMTriggerLUTGenerator") << "{"<< p.first << ", " << p.second << "}, " << std::endl;
268  if (i%8==0) LogTrace("CSCGEMTriggerLUTGenerator") << std::endl;
269  i++;
270  }
271 
272  // pick any roll
273  const int nGEMPads(randRoll->npads());
274  for (int i = 0; i< nGEMPads; ++i){
275  const LocalPoint lpGEM(randRoll->centreOfPad(i));
276  const GlobalPoint gp(randRoll->toGlobal(lpGEM));
277  const LocalPoint lpCSC(keyLayer->toLocal(gp));
278  const float strip(keyLayerGeometry->strip(lpCSC));
279  // HS are wrapped-around
280  gemPadToCscHs_.push_back( (int) (strip)/0.5 );
281  }
282 
283  LogTrace("CSCGEMTriggerLUTGenerator") << "GEM pad to CSC HS LUT in ME21";
284  i = 1;
285  for(auto p : gemPadToCscHs_) {
286  LogTrace("CSCGEMTriggerLUTGenerator") << p;
287  if (i%8==0) LogTrace("CSCGEMTriggerLUTGenerator") << std::endl;
288  i++;
289  }
290 }
291 
292 
293 int CSCGEMTriggerLUTGenerator::assignGEMRoll(const std::vector<std::pair<double,double> >& gemRollToEtaLimits_, double eta)
294 {
295  int roll = 1;
296  for(auto p : gemRollToEtaLimits_) {
297  roll++;
298  const float minEta(p.first);
299  const float maxEta(p.second);
300  if (minEta <= eta and eta <= maxEta) {
301  return roll;
302  }
303  }
304  return -99;
305 }
CSCChamber * chamber(unsigned endcap, unsigned station, unsigned sector, unsigned subsector, unsigned tcscid) const
Return the CSCChamber for a corresponding endcap/station/sector/subsector/trigger cscid...
double maxEta
U second(std::pair< T, U > const &p)
static CSCTriggerGeomManager * get()
int assignGEMRoll(const std::vector< std::pair< double, double > > &, double eta)
void generateLUTsME11(unsigned theEndcap, unsigned theStation, unsigned theSector, unsigned theSubSector, unsigned theTrigChamber)
#define LogTrace(id)
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 theEndcap, unsigned theStation, unsigned theSector, unsigned theSubSector, unsigned theTrigChamber)