CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
AngleConverter.cc
Go to the documentation of this file.
3 
6 
10 
14 
15 
20 
21 #include <cmath>
22 
23 AngleConverter::AngleConverter(): _geom_cache_id(0ULL) { }
31  unsigned long long geomid = geom.cacheIdentifier();
32  if( _geom_cache_id != geomid ) {
33  geom.get(_georpc);
34  geom.get(_geocsc);
35  geom.get(_geodt);
36  _geom_cache_id = geomid;
37  }
38 }
41 float AngleConverter::getGlobalPhi(unsigned int rawid, const RPCDigi & aDigi){
42 
45 
46  const RPCDetId id(rawid);
47  std::unique_ptr<const RPCRoll> roll(_georpc->roll(id));
48  const uint16_t strip = aDigi.strip();
49  const LocalPoint lp = roll->centreOfStrip(strip);
50  const GlobalPoint gp = roll->toGlobal(lp);
51  roll.release();
52 
53  //float phi = gp.phi()/(2.0*M_PI);
54  //int iPhi = phi*OMTFConfiguration::nPhiBins;
55 
56  return gp.phi();
57 }
60 int AngleConverter::getGlobalPhi(unsigned int rawid, const L1MuDTChambPhDigi & aDigi){
61 
62  // local phi in sector -> global phi
63  float phi = aDigi.phi()/4096.0;
64  phi += aDigi.scNum()*M_PI/6.0; // add sector offset
65  if(phi>M_PI) phi-=2*M_PI;
66  phi/=2.0*M_PI;
67 
68  int iPhi = phi*OMTFConfiguration::nPhiBins;
69 
70  return iPhi;
71 }
74 int AngleConverter::getGlobalPhi(unsigned int rawid, const CSCCorrelatedLCTDigi & aDigi){
75 
79 
80 
81  // alot of this is transcription and consolidation of the CSC
82  // global phi calculation code
83  // this works directly with the geometry
84  // rather than using the old phi luts
85  const CSCDetId id(rawid);
86  // we should change this to weak_ptrs at some point
87  // requires introducing std::shared_ptrs to geometry
88  std::unique_ptr<const CSCChamber> chamb(_geocsc->chamber(id));
89  std::unique_ptr<const CSCLayerGeometry> layer_geom(
90  chamb->layer(CSCConstants::KEY_ALCT_LAYER)->geometry()
91  );
92  std::unique_ptr<const CSCLayer> layer(
93  chamb->layer(CSCConstants::KEY_ALCT_LAYER)
94  );
95 
96  const uint16_t halfstrip = aDigi.getStrip();
97  const uint16_t pattern = aDigi.getPattern();
98  const uint16_t keyWG = aDigi.getKeyWG();
99  //const unsigned maxStrips = layer_geom->numberOfStrips();
100 
101  // so we can extend this later
102  // assume TMB2007 half-strips only as baseline
103  double offset = 0.0;
104  switch(1) {
105  case 1:
106  offset = CSCPatternLUT::get2007Position(pattern);
107  }
108  const unsigned halfstrip_offs = unsigned(0.5 + halfstrip + offset);
109  const unsigned strip = halfstrip_offs/2 + 1; // geom starts from 1
110 
111  // the rough location of the hit at the ALCT key layer
112  // we will refine this using the half strip information
113  const LocalPoint coarse_lp =
114  layer_geom->stripWireGroupIntersection(strip,keyWG);
115  const GlobalPoint coarse_gp = layer->surface().toGlobal(coarse_lp);
116 
117  // the strip width/4.0 gives the offset of the half-strip
118  // center with respect to the strip center
119  const double hs_offset = layer_geom->stripPhiPitch()/4.0;
120 
121  // determine handedness of the chamber
122  const bool ccw = isCSCCounterClockwise(layer);
123  // we need to subtract the offset of even half strips and add the odd ones
124  const double phi_offset = ( ( halfstrip_offs%2 ? 1 : -1)*
125  ( ccw ? -hs_offset : hs_offset ) );
126 
127  // the global eta calculation uses the middle of the strip
128  // so no need to increment it
129  const GlobalPoint final_gp( GlobalPoint::Polar( coarse_gp.theta(),
130  (coarse_gp.phi().value() +
131  phi_offset),
132  coarse_gp.mag() ) );
133  // release ownership of the pointers
134  chamb.release();
135  layer_geom.release();
136  layer.release();
137 
138  float phi = final_gp.phi()/(2.0*M_PI);
139  int iPhi = phi*OMTFConfiguration::nPhiBins;
140 
141  return iPhi;
142 }
145 int AngleConverter::getGlobalEta(unsigned int rawid,
146  const L1MuDTChambPhDigi &aDigi,
147  const L1MuDTChambThContainer *dtThDigis){
148 
149 
150  const DTChamberId baseid(aDigi.whNum(),aDigi.stNum(),aDigi.scNum()+1);
151 
152  // do not use this pointer for anything other than creating a trig geom
153  std::unique_ptr<DTChamber> chamb(const_cast<DTChamber*>(_geodt->chamber(baseid)));
154 
155  std::unique_ptr<DTTrigGeom> trig_geom( new DTTrigGeom(chamb.get(),false) );
156  chamb.release(); // release it here so no one gets funny ideas
157  // super layer one is the theta superlayer in a DT chamber
158  // station 4 does not have a theta super layer
159  // the BTI index from the theta trigger is an OR of some BTI outputs
160  // so, we choose the BTI that's in the middle of the group
161  // as the BTI that we get theta from
162  // TODO:::::>>> need to make sure this ordering doesn't flip under wheel sign
163  const int NBTI_theta = ( (baseid.station() != 4) ?
164  trig_geom->nCell(2) : trig_geom->nCell(3) );
165  const int bti_group = findBTIgroup(aDigi,dtThDigis);
166  const unsigned bti_actual = bti_group*NBTI_theta/7 + NBTI_theta/14 + 1;
167  DTBtiId thetaBTI;
168  if ( baseid.station() != 4 && bti_group != -1) {
169  thetaBTI = DTBtiId(baseid,2,bti_actual);
170  } else {
171  // since this is phi oriented it'll give us theta in the middle
172  // of the chamber
173  thetaBTI = DTBtiId(baseid,3,1);
174  }
175  const GlobalPoint theta_gp = trig_geom->CMSPosition(thetaBTI);
176  int iEta = theta_gp.eta()/2.61*240;
177  return iEta;
178 }
181 int AngleConverter::getGlobalEta(unsigned int rawid, const CSCCorrelatedLCTDigi &aDigi){
182 
186 
187 
188  // alot of this is transcription and consolidation of the CSC
189  // global phi calculation code
190  // this works directly with the geometry
191  // rather than using the old phi luts
192  const CSCDetId id(rawid);
193  // we should change this to weak_ptrs at some point
194  // requires introducing std::shared_ptrs to geometry
195  std::unique_ptr<const CSCChamber> chamb(_geocsc->chamber(id));
196  std::unique_ptr<const CSCLayerGeometry> layer_geom(
197  chamb->layer(CSCConstants::KEY_ALCT_LAYER)->geometry()
198  );
199  std::unique_ptr<const CSCLayer> layer(
200  chamb->layer(CSCConstants::KEY_ALCT_LAYER)
201  );
202 
203  const uint16_t halfstrip = aDigi.getStrip();
204  const uint16_t pattern = aDigi.getPattern();
205  const uint16_t keyWG = aDigi.getKeyWG();
206  //const unsigned maxStrips = layer_geom->numberOfStrips();
207 
208  // so we can extend this later
209  // assume TMB2007 half-strips only as baseline
210  double offset = 0.0;
211  switch(1) {
212  case 1:
213  offset = CSCPatternLUT::get2007Position(pattern);
214  }
215  const unsigned halfstrip_offs = unsigned(0.5 + halfstrip + offset);
216  const unsigned strip = halfstrip_offs/2 + 1; // geom starts from 1
217 
218  // the rough location of the hit at the ALCT key layer
219  // we will refine this using the half strip information
220  const LocalPoint coarse_lp =
221  layer_geom->stripWireGroupIntersection(strip,keyWG);
222  const GlobalPoint coarse_gp = layer->surface().toGlobal(coarse_lp);
223 
224  // the strip width/4.0 gives the offset of the half-strip
225  // center with respect to the strip center
226  const double hs_offset = layer_geom->stripPhiPitch()/4.0;
227 
228  // determine handedness of the chamber
229  const bool ccw = isCSCCounterClockwise(layer);
230  // we need to subtract the offset of even half strips and add the odd ones
231  const double phi_offset = ( ( halfstrip_offs%2 ? 1 : -1)*
232  ( ccw ? -hs_offset : hs_offset ) );
233 
234  // the global eta calculation uses the middle of the strip
235  // so no need to increment it
236  const GlobalPoint final_gp( GlobalPoint::Polar( coarse_gp.theta(),
237  (coarse_gp.phi().value() +
238  phi_offset),
239  coarse_gp.mag() ) );
240  // release ownership of the pointers
241  chamb.release();
242  layer_geom.release();
243  layer.release();
244 
245  int iEta = final_gp.eta()/2.61*240;
246  return iEta;
247 }
250 int AngleConverter::getGlobalEta(unsigned int rawid, const RPCDigi &aDigi){
251 
252  const RPCDetId id(rawid);
253  std::unique_ptr<const RPCRoll> roll(_georpc->roll(id));
254  const uint16_t strip = aDigi.strip();
255  const LocalPoint lp = roll->centreOfStrip(strip);
256  const GlobalPoint gp = roll->toGlobal(lp);
257  roll.release();
258 
259  float iEta = gp.eta()/2.61*240;
260 
261  return iEta;
262 
263 }
266 bool AngleConverter::
267 isCSCCounterClockwise(const std::unique_ptr<const CSCLayer>& layer) const {
268  const int nStrips = layer->geometry()->numberOfStrips();
269  const double phi1 = layer->centerOfStrip(1).phi();
270  const double phiN = layer->centerOfStrip(nStrips).phi();
271  return ( (std::abs(phi1 - phiN) < M_PI && phi1 >= phiN) ||
272  (std::abs(phi1 - phiN) >= M_PI && phi1 < phiN) );
273 }
277  const L1MuDTChambThContainer *dtThDigis){
278 
279  int bti_group = -1;
280 
281  const L1MuDTChambThDigi *theta_segm = dtThDigis->chThetaSegm(aDigi.whNum(),
282  aDigi.stNum(),
283  aDigi.scNum(),
284  aDigi.bxNum());
285  if(!theta_segm) return bti_group;
286 
287  for(unsigned int i = 0; i < 7; ++i ){
288  if(theta_segm->position(i) && bti_group<0) bti_group = i;
292  else if(theta_segm->position(i) && bti_group>-1) return -1;
293  }
294 
295  return bti_group;
296 }
int getStrip() const
return the key halfstrip from 0,159
unsigned long long cacheIdentifier() const
int i
Definition: DBlmapReader.cc:9
int getGlobalPhi(unsigned int rawid, const L1MuDTChambPhDigi &aDigi)
Convert local phi coordinate to global digital OMTF scale.
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
int getGlobalEta(unsigned int rawid, const L1MuDTChambPhDigi &aDigi, const L1MuDTChambThContainer *dtThDigis)
Convert local eta coordinate to global digital microGMT scale.
unsigned long long _geom_cache_id
int position(const int i) const
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
int strip() const
Definition: RPCDigi.cc:45
T mag() const
Definition: PV3DBase.h:67
void get(HolderT &iHolder) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static unsigned int nPhiBins
const int findBTIgroup(const L1MuDTChambPhDigi &aDigi, const L1MuDTChambThContainer *dtThDigis)
Find BTI group.
bool isCSCCounterClockwise(const std::unique_ptr< const CSCLayer > &layer) const
Check orientation of strips in given CSC chamber.
#define M_PI
T value() const
Explicit access to value in case implicit conversion not OK.
Definition: Phi.h:38
static double get2007Position(int pattern)
const T & get() const
Definition: EventSetup.h:56
L1MuDTChambThDigi const * chThetaSegm(int wheel, int stat, int sect, int bx) const
T eta() const
Definition: PV3DBase.h:76
int getPattern() const
return pattern
edm::ESHandle< CSCGeometry > _geocsc
edm::ESHandle< RPCGeometry > _georpc
int getKeyWG() const
return the key wire group
void checkAndUpdateGeometry(const edm::EventSetup &)
Update the Geometry with current Event Setup.
edm::ESHandle< DTGeometry > _geodt