CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GeometryTranslator.cc
Go to the documentation of this file.
3 
4 // event setup stuff / geometries
7 
11 
15 
16 #include <cmath> // for pi
17 
18 using namespace l1t;
19 
21  _geom_cache_id(0ULL) {
22 }
23 
25 }
26 
27 double
29  switch(tp.subsystem()) {
31  return calcDTSpecificEta(tp);
32  break;
34  return calcCSCSpecificEta(tp);
35  break;
37  return calcRPCSpecificEta(tp);
38  break;
39  default:
40  return std::nan("Invalid TP type!");
41  break;
42  }
43 }
44 
45 double
47  switch(tp.subsystem()) {
49  return calcDTSpecificPhi(tp);
50  break;
52  return calcCSCSpecificPhi(tp);
53  break;
55  return calcRPCSpecificPhi(tp);
56  break;
57  default:
58  return std::nan("Invalid TP type!");
59  break;
60  }
61 }
62 
63 double
65  switch(tp.subsystem()) {
67  return calcDTSpecificBend(tp);
68  break;
70  return calcCSCSpecificBend(tp);
71  break;
73  return calcRPCSpecificBend(tp);
74  break;
75  default:
76  return std::nan("Invalid TP type!");
77  break;
78  }
79 }
80 
83  unsigned long long geomid = geom.cacheIdentifier();
84  if( _geom_cache_id != geomid ) {
85  geom.get(_georpc);
86  geom.get(_geocsc);
87  geom.get(_geodt);
88  _geom_cache_id = geomid;
89  }
90 }
91 
94  const RPCDetId id(tp.detId<RPCDetId>());
95  std::unique_ptr<const RPCRoll> roll(_georpc->roll(id));
96  const uint16_t strip = tp.getRPCData().strip;
97  const LocalPoint lp = roll->centreOfStrip(strip);
98  const GlobalPoint gp = roll->toGlobal(lp);
99 
100  roll.release();
101 
102  return gp;
103 }
104 
105 double
107  return getRPCSpecificPoint(tp).eta();
108 }
109 
110 double
112  return getRPCSpecificPoint(tp).phi();
113 }
114 
115 // this function actually does nothing since RPC
116 // hits are point-like objects
117 double
119  return 0.0;
120 }
121 
122 
123 // alot of this is transcription and consolidation of the CSC
124 // global phi calculation code
125 // this works directly with the geometry
126 // rather than using the old phi luts
129  const CSCDetId id(tp.detId<CSCDetId>());
130  // we should change this to weak_ptrs at some point
131  // requires introducing std::shared_ptrs to geometry
132  std::unique_ptr<const CSCChamber> chamb(_geocsc->chamber(id));
133  std::unique_ptr<const CSCLayerGeometry> layer_geom(
134  chamb->layer(CSCConstants::KEY_ALCT_LAYER)->geometry()
135  );
136  std::unique_ptr<const CSCLayer> layer(
137  chamb->layer(CSCConstants::KEY_ALCT_LAYER)
138  );
139 
140  const uint16_t halfstrip = tp.getCSCData().strip;
141  const uint16_t pattern = tp.getCSCData().pattern;
142  const uint16_t keyWG = tp.getCSCData().keywire;
143  //const unsigned maxStrips = layer_geom->numberOfStrips();
144 
145  // so we can extend this later
146  // assume TMB2007 half-strips only as baseline
147  double offset = 0.0;
148  switch(1) {
149  case 1:
150  offset = CSCPatternLUT::get2007Position(pattern);
151  }
152  const unsigned halfstrip_offs = unsigned(0.5 + halfstrip + offset);
153  const unsigned strip = halfstrip_offs/2 + 1; // geom starts from 1
154 
155  // the rough location of the hit at the ALCT key layer
156  // we will refine this using the half strip information
157  const LocalPoint coarse_lp =
158  layer_geom->stripWireGroupIntersection(strip,keyWG);
159  const GlobalPoint coarse_gp = layer->surface().toGlobal(coarse_lp);
160 
161  // the strip width/4.0 gives the offset of the half-strip
162  // center with respect to the strip center
163  const double hs_offset = layer_geom->stripPhiPitch()/4.0;
164 
165  // determine handedness of the chamber
166  const bool ccw = isCSCCounterClockwise(layer);
167  // we need to subtract the offset of even half strips and add the odd ones
168  const double phi_offset = ( ( halfstrip_offs%2 ? 1 : -1)*
169  ( ccw ? -hs_offset : hs_offset ) );
170 
171  // the global eta calculation uses the middle of the strip
172  // so no need to increment it
173  const GlobalPoint final_gp( GlobalPoint::Polar( coarse_gp.theta(),
174  (coarse_gp.phi().value() +
175  phi_offset),
176  coarse_gp.mag() ) );
177 
178  // We need to add in some notion of the 'error' on trigger primitives
179  // like the width of the wire group by the width of the strip
180  // or something similar
181 
182  // release ownership of the pointers
183  chamb.release();
184  layer_geom.release();
185  layer.release();
186 
187  return final_gp;
188 }
189 
190 double
192  return getCSCSpecificPoint(tp).eta();
193 }
194 
195 double
197  return getCSCSpecificPoint(tp).phi();
198 }
199 
200 double
202  return 0.0;
203 }
204 
207  const DTChamberId baseid(tp.detId<DTChamberId>());
208  // do not use this pointer for anything other than creating a trig geom
209  std::unique_ptr<DTChamber> chamb(
210  const_cast<DTChamber*>(_geodt->chamber(baseid))
211  );
212  std::unique_ptr<DTTrigGeom> trig_geom( new DTTrigGeom(chamb.get(),false) );
213  chamb.release(); // release it here so no one gets funny ideas
214  // super layer one is the theta superlayer in a DT chamber
215  // station 4 does not have a theta super layer
216  // the BTI index from the theta trigger is an OR of some BTI outputs
217  // so, we choose the BTI that's in the middle of the group
218  // as the BTI that we get theta from
219  // TODO:::::>>> need to make sure this ordering doesn't flip under wheel sign
220  const int NBTI_theta = ( (baseid.station() != 4) ?
221  trig_geom->nCell(2) : trig_geom->nCell(3) );
222  const int bti_group = tp.getDTData().theta_bti_group;
223  const unsigned bti_actual = bti_group*NBTI_theta/7 + NBTI_theta/14 + 1;
224  DTBtiId thetaBTI;
225  if ( baseid.station() != 4 && bti_group != -1) {
226  thetaBTI = DTBtiId(baseid,2,bti_actual);
227  } else {
228  // since this is phi oriented it'll give us theta in the middle
229  // of the chamber
230  thetaBTI = DTBtiId(baseid,3,1);
231  }
232  const GlobalPoint theta_gp = trig_geom->CMSPosition(thetaBTI);
233 
234  // local phi in sector -> global phi
235  double phi = ((double)tp.getDTData().radialAngle)/4096.0;
236  phi += tp.getDTData().sector*M_PI/6.0; // add sector offset
237 
238  return GlobalPoint( GlobalPoint::Polar( theta_gp.theta(),
239  phi,
240  theta_gp.mag() ) );
241 }
242 
243 double
245  return calcDTSpecificPoint(tp).eta();
246 }
247 
248 double
250  return calcDTSpecificPoint(tp).phi();
251 }
252 
253 // we have the bend except for station 3
254 double
256  int bend = tp.getDTData().bendingAngle;
257  double bendf = bend/512.0;
258  return bendf;
259 }
260 
262 isCSCCounterClockwise(const std::unique_ptr<const CSCLayer>& layer) const {
263  const int nStrips = layer->geometry()->numberOfStrips();
264  const double phi1 = layer->centerOfStrip(1).phi();
265  const double phiN = layer->centerOfStrip(nStrips).phi();
266  return ( (std::abs(phi1 - phiN) < M_PI && phi1 >= phiN) ||
267  (std::abs(phi1 - phiN) >= M_PI && phi1 < phiN) );
268 }
unsigned long long cacheIdentifier() const
const DTData getDTData() const
double calcDTSpecificPhi(const MuonTriggerPrimitive &) const
double calcCSCSpecificEta(const MuonTriggerPrimitive &) const
GlobalPoint getRPCSpecificPoint(const MuonTriggerPrimitive &) const
double calcCSCSpecificBend(const MuonTriggerPrimitive &) const
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
double calcRPCSpecificEta(const MuonTriggerPrimitive &) const
double calcCSCSpecificPhi(const MuonTriggerPrimitive &) const
double calcDTSpecificBend(const MuonTriggerPrimitive &) const
unsigned long long _geom_cache_id
double calculateGlobalEta(const MuonTriggerPrimitive &) const
edm::ESHandle< RPCGeometry > _georpc
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
T mag() const
Definition: PV3DBase.h:67
void checkAndUpdateGeometry(const edm::EventSetup &)
void get(HolderT &iHolder) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const RPCData getRPCData() const
edm::ESHandle< DTGeometry > _geodt
#define M_PI
double calcRPCSpecificPhi(const MuonTriggerPrimitive &) const
T value() const
Explicit access to value in case implicit conversion not OK.
Definition: Phi.h:38
GlobalPoint getCSCSpecificPoint(const MuonTriggerPrimitive &) const
edm::ESHandle< CSCGeometry > _geocsc
static double get2007Position(int pattern)
const subsystem_type subsystem() const
const T & get() const
Definition: EventSetup.h:56
Geom::Phi< T > phi() const
const CSCData getCSCData() const
T eta() const
Definition: PV3DBase.h:76
GlobalPoint calcDTSpecificPoint(const MuonTriggerPrimitive &) const
bool isCSCCounterClockwise(const std::unique_ptr< const CSCLayer > &) const
double calculateBendAngle(const MuonTriggerPrimitive &) const
int station() const
Return the station number.
Definition: DTChamberId.h:51
double calcRPCSpecificBend(const MuonTriggerPrimitive &) const
double calculateGlobalPhi(const MuonTriggerPrimitive &) const
double calcDTSpecificEta(const MuonTriggerPrimitive &) const