CMS 3D CMS Logo

GeometryTranslator.cc
Go to the documentation of this file.
3 
4 // event setup stuff / geometries
7 
11 
16 
19 
20 #include <cmath> // for pi
21 
22 using namespace L1TMuon;
23 
25  _geom_cache_id(0ULL), _magfield_cache_id(0ULL) {
26 }
27 
29 }
30 
31 double
33  switch(tp.subsystem()) {
35  return calcDTSpecificEta(tp);
36  break;
38  return calcCSCSpecificEta(tp);
39  break;
41  return calcRPCSpecificEta(tp);
42  break;
44  return calcGEMSpecificEta(tp);
45  break;
46  default:
47  return std::nan("Invalid TP type!");
48  break;
49  }
50 }
51 
52 double
54  switch(tp.subsystem()) {
56  return calcDTSpecificPhi(tp);
57  break;
59  return calcCSCSpecificPhi(tp);
60  break;
62  return calcRPCSpecificPhi(tp);
63  break;
65  return calcGEMSpecificPhi(tp);
66  break;
67  default:
68  return std::nan("Invalid TP type!");
69  break;
70  }
71 }
72 
73 double
75  switch(tp.subsystem()) {
77  return calcDTSpecificBend(tp);
78  break;
80  return calcCSCSpecificBend(tp);
81  break;
83  return calcRPCSpecificBend(tp);
84  break;
86  return calcGEMSpecificBend(tp);
87  break;
88  default:
89  return std::nan("Invalid TP type!");
90  break;
91  }
92 }
93 
96  switch(tp.subsystem()) {
98  return calcDTSpecificPoint(tp);
99  break;
101  return getCSCSpecificPoint(tp);
102  break;
104  return getRPCSpecificPoint(tp);
105  break;
107  return getGEMSpecificPoint(tp);
108  break;
109  default:
110  GlobalPoint ret(GlobalPoint::Polar(std::nan("Invalid TP type!"), std::nan("Invalid TP type!"), std::nan("Invalid TP type!")));
111  return ret;
112  break;
113  }
114 }
115 
118  unsigned long long geomid = geom.cacheIdentifier();
119  if( _geom_cache_id != geomid ) {
120  geom.get(_geogem);
121  geom.get(_georpc);
122  geom.get(_geocsc);
123  geom.get(_geodt);
124  _geom_cache_id = geomid;
125  }
126 
127  const IdealMagneticFieldRecord& magfield = es.get<IdealMagneticFieldRecord>();
128  unsigned long long magfieldid = magfield.cacheIdentifier();
129  if( _magfield_cache_id != magfieldid ) {
130  magfield.get(_magfield);
131  _magfield_cache_id = magfieldid;
132  }
133 }
134 
137  const GEMDetId id(tp.detId<GEMDetId>());
138  const GEMEtaPartition * roll = _geogem->etaPartition(id);
139  const uint16_t pad = tp.getGEMData().pad;
140  const LocalPoint lp = roll->centreOfPad(pad);
141  const GlobalPoint gp = roll->toGlobal(lp);
142 
143  //roll.release();
144 
145  return gp;
146 }
147 
148 double
150  return getGEMSpecificPoint(tp).eta();
151 }
152 
153 double
155  return getGEMSpecificPoint(tp).phi();
156 }
157 
158 // this function actually does nothing since GEM
159 // hits are point-like objects
160 double
162  return 0.0;
163 }
164 
165 
168  const RPCDetId id(tp.detId<RPCDetId>());
169  const RPCRoll * roll = _georpc->roll(id);
170  //const int strip = static_cast<int>(tp.getRPCData().strip);
171  // Use half-strip precision, - 0.5 at the end to get the center of the strip
172  const float strip = (0.5 * static_cast<float>(tp.getRPCData().strip_low + tp.getRPCData().strip_hi)) - 0.5;
173  const LocalPoint lp = roll->centreOfStrip(strip);
174  const GlobalPoint gp = roll->toGlobal(lp);
175 
176  //roll.release();
177 
178  return gp;
179 }
180 
181 double
183  return getRPCSpecificPoint(tp).eta();
184 }
185 
186 double
188  return getRPCSpecificPoint(tp).phi();
189 }
190 
191 // this function actually does nothing since RPC
192 // hits are point-like objects
193 double
195  return 0.0;
196 }
197 
198 
199 // alot of this is transcription and consolidation of the CSC
200 // global phi calculation code
201 // this works directly with the geometry
202 // rather than using the old phi luts
205  const CSCDetId id(tp.detId<CSCDetId>());
206  // we should change this to weak_ptrs at some point
207  // requires introducing std::shared_ptrs to geometry
208  std::unique_ptr<const CSCChamber> chamb(_geocsc->chamber(id));
209  std::unique_ptr<const CSCLayerGeometry> layer_geom(
210  chamb->layer(CSCConstants::KEY_ALCT_LAYER)->geometry()
211  );
212  std::unique_ptr<const CSCLayer> layer(
213  chamb->layer(CSCConstants::KEY_ALCT_LAYER)
214  );
215 
216  const uint16_t halfstrip = tp.getCSCData().strip;
217  const uint16_t pattern = tp.getCSCData().pattern;
218  const uint16_t keyWG = tp.getCSCData().keywire;
219  //const unsigned maxStrips = layer_geom->numberOfStrips();
220 
221  // so we can extend this later
222  // assume TMB2007 half-strips only as baseline
223  double offset = 0.0;
224  switch(1) {
225  case 1:
226  offset = CSCPatternLUT::get2007Position(pattern);
227  }
228  const unsigned halfstrip_offs = unsigned(0.5 + halfstrip + offset);
229  const unsigned strip = halfstrip_offs/2 + 1; // geom starts from 1
230 
231  // the rough location of the hit at the ALCT key layer
232  // we will refine this using the half strip information
233  const LocalPoint coarse_lp =
234  layer_geom->stripWireGroupIntersection(strip,keyWG);
235  const GlobalPoint coarse_gp = layer->surface().toGlobal(coarse_lp);
236 
237  // the strip width/4.0 gives the offset of the half-strip
238  // center with respect to the strip center
239  const double hs_offset = layer_geom->stripPhiPitch()/4.0;
240 
241  // determine handedness of the chamber
242  const bool ccw = isCSCCounterClockwise(layer);
243  // we need to subtract the offset of even half strips and add the odd ones
244  const double phi_offset = ( ( halfstrip_offs%2 ? 1 : -1)*
245  ( ccw ? -hs_offset : hs_offset ) );
246 
247  // the global eta calculation uses the middle of the strip
248  // so no need to increment it
249  const GlobalPoint final_gp( GlobalPoint::Polar( coarse_gp.theta(),
250  (coarse_gp.phi().value() +
251  phi_offset),
252  coarse_gp.mag() ) );
253 
254  // We need to add in some notion of the 'error' on trigger primitives
255  // like the width of the wire group by the width of the strip
256  // or something similar
257 
258  // release ownership of the pointers
259  chamb.release();
260  layer_geom.release();
261  layer.release();
262 
263  return final_gp;
264 }
265 
266 double
268  return getCSCSpecificPoint(tp).eta();
269 }
270 
271 double
273  return getCSCSpecificPoint(tp).phi();
274 }
275 
276 double
278  return tp.getCSCData().bend;
279 }
280 
283  const DTChamberId baseid(tp.detId<DTChamberId>());
284  // do not use this pointer for anything other than creating a trig geom
285  std::unique_ptr<DTChamber> chamb(
286  const_cast<DTChamber*>(_geodt->chamber(baseid))
287  );
288  std::unique_ptr<DTTrigGeom> trig_geom( new DTTrigGeom(chamb.get(),false) );
289  chamb.release(); // release it here so no one gets funny ideas
290  // super layer one is the theta superlayer in a DT chamber
291  // station 4 does not have a theta super layer
292  // the BTI index from the theta trigger is an OR of some BTI outputs
293  // so, we choose the BTI that's in the middle of the group
294  // as the BTI that we get theta from
295  // TODO:::::>>> need to make sure this ordering doesn't flip under wheel sign
296  const int NBTI_theta = ( (baseid.station() != 4) ?
297  trig_geom->nCell(2) : trig_geom->nCell(3) );
298  const int bti_group = tp.getDTData().theta_bti_group;
299  const unsigned bti_actual = bti_group*NBTI_theta/7 + NBTI_theta/14 + 1;
300  DTBtiId thetaBTI;
301  if ( baseid.station() != 4 && bti_group != -1) {
302  thetaBTI = DTBtiId(baseid,2,bti_actual);
303  } else {
304  // since this is phi oriented it'll give us theta in the middle
305  // of the chamber
306  thetaBTI = DTBtiId(baseid,3,1);
307  }
308  const GlobalPoint theta_gp = trig_geom->CMSPosition(thetaBTI);
309 
310  // local phi in sector -> global phi
311  double phi = ((double)tp.getDTData().radialAngle)/4096.0;
312  phi += tp.getDTData().sector*M_PI/6.0; // add sector offset
313 
314  return GlobalPoint( GlobalPoint::Polar( theta_gp.theta(),
315  phi,
316  theta_gp.mag() ) );
317 }
318 
319 double
321  return calcDTSpecificPoint(tp).eta();
322 }
323 
324 double
326  return calcDTSpecificPoint(tp).phi();
327 }
328 
329 // we have the bend except for station 3
330 double
332  int bend = tp.getDTData().bendingAngle;
333  double bendf = bend/512.0;
334  return bendf;
335 }
336 
338 isCSCCounterClockwise(const std::unique_ptr<const CSCLayer>& layer) const {
339  const int nStrips = layer->geometry()->numberOfStrips();
340  const double phi1 = layer->centerOfStrip(1).phi();
341  const double phiN = layer->centerOfStrip(nStrips).phi();
342  return ( (std::abs(phi1 - phiN) < M_PI && phi1 >= phiN) ||
343  (std::abs(phi1 - phiN) >= M_PI && phi1 < phiN) );
344 }
unsigned long long cacheIdentifier() const
edm::ESHandle< DTGeometry > _geodt
LocalPoint centreOfStrip(int strip) const
Definition: RPCRoll.cc:52
const subsystem_type subsystem() const
const DTData getDTData() const
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
Definition: DTGeometry.cc:99
const GEMData getGEMData() const
unsigned long long _geom_cache_id
double calcRPCSpecificBend(const TriggerPrimitive &) const
double calcDTSpecificEta(const TriggerPrimitive &) const
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:54
double calcGEMSpecificEta(const TriggerPrimitive &) const
edm::ESHandle< RPCGeometry > _georpc
edm::ESHandle< GEMGeometry > _geogem
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
GlobalPoint getRPCSpecificPoint(const TriggerPrimitive &) const
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
GlobalPoint getCSCSpecificPoint(const TriggerPrimitive &) const
const CSCData getCSCData() const
const GEMEtaPartition * etaPartition(GEMDetId id) const
Return a GEMEtaPartition given its id.
Definition: GEMGeometry.cc:99
const RPCData getRPCData() const
double calcGEMSpecificPhi(const TriggerPrimitive &) const
double calcRPCSpecificPhi(const TriggerPrimitive &) const
edm::ESHandle< MagneticField > _magfield
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
T mag() const
Definition: PV3DBase.h:67
double calculateBendAngle(const TriggerPrimitive &) const
void checkAndUpdateGeometry(const edm::EventSetup &)
edm::ESHandle< CSCGeometry > _geocsc
void get(HolderT &iHolder) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double calcCSCSpecificPhi(const TriggerPrimitive &) const
#define M_PI
double calculateGlobalPhi(const TriggerPrimitive &) const
static double get2007Position(int pattern)
double calcDTSpecificBend(const TriggerPrimitive &) const
const T & get() const
Definition: EventSetup.h:58
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
Definition: CSCGeometry.cc:118
double calcCSCSpecificEta(const TriggerPrimitive &) const
GlobalPoint calcDTSpecificPoint(const TriggerPrimitive &) const
T eta() const
Definition: PV3DBase.h:76
LocalPoint centreOfPad(int pad) const
double calcDTSpecificPhi(const TriggerPrimitive &) const
GlobalPoint getGEMSpecificPoint(const TriggerPrimitive &) const
int station() const
Return the station number.
Definition: DTChamberId.h:51
unsigned long long _magfield_cache_id
double calculateGlobalEta(const TriggerPrimitive &) const
double calcGEMSpecificBend(const TriggerPrimitive &) const
bool isCSCCounterClockwise(const std::unique_ptr< const CSCLayer > &) const
const RPCRoll * roll(RPCDetId id) const
Return a roll given its id.
Definition: RPCGeometry.cc:75
double calcRPCSpecificEta(const TriggerPrimitive &) const
GlobalPoint getGlobalPoint(const TriggerPrimitive &) const
double calcCSCSpecificBend(const TriggerPrimitive &) const