CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
AngleConverter Class Reference

#include <AngleConverter.h>

Public Member Functions

 AngleConverter ()
 
void checkAndUpdateGeometry (const edm::EventSetup &)
 Update the Geometry with current Event Setup. More...
 
int getGlobalEta (unsigned int rawid, const L1MuDTChambPhDigi &aDigi, const L1MuDTChambThContainer *dtThDigis)
 Convert local eta coordinate to global digital microGMT scale. More...
 
int getGlobalEta (unsigned int rawid, const CSCCorrelatedLCTDigi &aDigi)
 Convert local eta coordinate to global digital microGMT scale. More...
 
int getGlobalEta (unsigned int rawid, const RPCDigi &aDigi)
 Convert local eta coordinate to global digital microGMT scale. More...
 
int getGlobalPhi (unsigned int rawid, const L1MuDTChambPhDigi &aDigi)
 Convert local phi coordinate to global digital OMTF scale. More...
 
int getGlobalPhi (unsigned int rawid, const CSCCorrelatedLCTDigi &aDigi)
 Convert local phi coordinate to global digital OMTF scale. More...
 
float getGlobalPhi (unsigned int rawid, const RPCDigi &aDigi)
 
 ~AngleConverter ()
 

Private Member Functions

const int findBTIgroup (const L1MuDTChambPhDigi &aDigi, const L1MuDTChambThContainer *dtThDigis)
 Find BTI group. More...
 
bool isCSCCounterClockwise (const std::unique_ptr< const CSCLayer > &layer) const
 Check orientation of strips in given CSC chamber. More...
 

Private Attributes

edm::ESHandle< CSCGeometry_geocsc
 
edm::ESHandle< DTGeometry_geodt
 
unsigned long long _geom_cache_id
 
edm::ESHandle< RPCGeometry_georpc
 

Detailed Description

Definition at line 22 of file AngleConverter.h.

Constructor & Destructor Documentation

AngleConverter::AngleConverter ( )

Definition at line 23 of file AngleConverter.cc.

23 : _geom_cache_id(0ULL) { }
unsigned long long _geom_cache_id
AngleConverter::~AngleConverter ( )

Definition at line 26 of file AngleConverter.cc.

26 { }

Member Function Documentation

void AngleConverter::checkAndUpdateGeometry ( const edm::EventSetup es)

Update the Geometry with current Event Setup.

Definition at line 29 of file AngleConverter.cc.

References _geocsc, _geodt, _geom_cache_id, _georpc, edm::eventsetup::EventSetupRecord::cacheIdentifier(), relativeConstraints::geom, edm::EventSetup::get(), and edm::eventsetup::EventSetupRecord::get().

29  {
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 }
unsigned long long cacheIdentifier() const
unsigned long long _geom_cache_id
void get(HolderT &iHolder) const
const T & get() const
Definition: EventSetup.h:56
edm::ESHandle< CSCGeometry > _geocsc
edm::ESHandle< RPCGeometry > _georpc
edm::ESHandle< DTGeometry > _geodt
const int AngleConverter::findBTIgroup ( const L1MuDTChambPhDigi aDigi,
const L1MuDTChambThContainer dtThDigis 
)
private

Find BTI group.

If there are more than one theta digi we do not take is due to unresolvet ambiguity. In this case we take eta of the middle of the chamber.

Definition at line 276 of file AngleConverter.cc.

References L1MuDTChambPhDigi::bxNum(), L1MuDTChambThContainer::chThetaSegm(), i, L1MuDTChambThDigi::position(), L1MuDTChambPhDigi::scNum(), L1MuDTChambPhDigi::stNum(), and L1MuDTChambPhDigi::whNum().

Referenced by getGlobalEta().

277  {
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 i
Definition: DBlmapReader.cc:9
int position(const int i) const
L1MuDTChambThDigi const * chThetaSegm(int wheel, int stat, int sect, int bx) const
int AngleConverter::getGlobalEta ( unsigned int  rawid,
const L1MuDTChambPhDigi aDigi,
const L1MuDTChambThContainer dtThDigis 
)

Convert local eta coordinate to global digital microGMT scale.

Definition at line 145 of file AngleConverter.cc.

References _geodt, PV3DBase< T, PVType, FrameType >::eta(), findBTIgroup(), L1MuDTChambPhDigi::scNum(), L1MuDTChambPhDigi::stNum(), and L1MuDTChambPhDigi::whNum().

147  {
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 }
const int findBTIgroup(const L1MuDTChambPhDigi &aDigi, const L1MuDTChambThContainer *dtThDigis)
Find BTI group.
T eta() const
Definition: PV3DBase.h:76
edm::ESHandle< DTGeometry > _geodt
int AngleConverter::getGlobalEta ( unsigned int  rawid,
const CSCCorrelatedLCTDigi aDigi 
)

Convert local eta coordinate to global digital microGMT scale.

Code taken from GeometryTranslator.

Will be replaced by direct CSC phi local to global scale transformation as used in FPGA implementation

Definition at line 181 of file AngleConverter.cc.

References _geocsc, PV3DBase< T, PVType, FrameType >::eta(), CSCPatternLUT::get2007Position(), CSCCorrelatedLCTDigi::getKeyWG(), CSCCorrelatedLCTDigi::getPattern(), CSCCorrelatedLCTDigi::getStrip(), isCSCCounterClockwise(), CSCConstants::KEY_ALCT_LAYER, PV3DBase< T, PVType, FrameType >::mag(), hltrates_dqm_sourceclient-live_cfg::offset, listBenchmarks::pattern, PV3DBase< T, PVType, FrameType >::phi(), PV3DBase< T, PVType, FrameType >::theta(), and Geom::Phi< T >::value().

181  {
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 }
int getStrip() const
return the key halfstrip from 0,159
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
T mag() const
Definition: PV3DBase.h:67
bool isCSCCounterClockwise(const std::unique_ptr< const CSCLayer > &layer) const
Check orientation of strips in given CSC chamber.
static double get2007Position(int pattern)
int getPattern() const
return pattern
edm::ESHandle< CSCGeometry > _geocsc
int getKeyWG() const
return the key wire group
int AngleConverter::getGlobalEta ( unsigned int  rawid,
const RPCDigi aDigi 
)

Convert local eta coordinate to global digital microGMT scale.

Definition at line 250 of file AngleConverter.cc.

References _georpc, PV3DBase< T, PVType, FrameType >::eta(), and RPCDigi::strip().

250  {
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 }
int strip() const
Definition: RPCDigi.cc:45
T eta() const
Definition: PV3DBase.h:76
edm::ESHandle< RPCGeometry > _georpc
int AngleConverter::getGlobalPhi ( unsigned int  rawid,
const L1MuDTChambPhDigi aDigi 
)

Convert local phi coordinate to global digital OMTF scale.

Definition at line 60 of file AngleConverter.cc.

References M_PI, OMTFConfiguration::nPhiBins, phi, L1MuDTChambPhDigi::phi(), and L1MuDTChambPhDigi::scNum().

60  {
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 }
static unsigned int nPhiBins
#define M_PI
int AngleConverter::getGlobalPhi ( unsigned int  rawid,
const CSCCorrelatedLCTDigi aDigi 
)

Convert local phi coordinate to global digital OMTF scale.

Code taken from GeometryTranslator. Will be replaced by direct CSC phi local to global scale transformation as used in FPGA implementation

Definition at line 74 of file AngleConverter.cc.

References _geocsc, CSCPatternLUT::get2007Position(), CSCCorrelatedLCTDigi::getKeyWG(), CSCCorrelatedLCTDigi::getPattern(), CSCCorrelatedLCTDigi::getStrip(), isCSCCounterClockwise(), CSCConstants::KEY_ALCT_LAYER, M_PI, PV3DBase< T, PVType, FrameType >::mag(), OMTFConfiguration::nPhiBins, hltrates_dqm_sourceclient-live_cfg::offset, listBenchmarks::pattern, phi, PV3DBase< T, PVType, FrameType >::phi(), PV3DBase< T, PVType, FrameType >::theta(), and Geom::Phi< T >::value().

74  {
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 }
int getStrip() const
return the key halfstrip from 0,159
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
T mag() const
Definition: PV3DBase.h:67
static unsigned int nPhiBins
bool isCSCCounterClockwise(const std::unique_ptr< const CSCLayer > &layer) const
Check orientation of strips in given CSC chamber.
#define M_PI
static double get2007Position(int pattern)
int getPattern() const
return pattern
edm::ESHandle< CSCGeometry > _geocsc
int getKeyWG() const
return the key wire group
float AngleConverter::getGlobalPhi ( unsigned int  rawid,
const RPCDigi aDigi 
)

Convert local phi coordinate to global digital OMTF scale. To maintain backward comtability return float value fo global phi. Later whewn LUT will be used will return int as other methods.

Will be replaced by LUT based transformation as used in FPGA implementation

Definition at line 41 of file AngleConverter.cc.

References _georpc, PV3DBase< T, PVType, FrameType >::phi(), and RPCDigi::strip().

41  {
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 }
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
int strip() const
Definition: RPCDigi.cc:45
edm::ESHandle< RPCGeometry > _georpc
bool AngleConverter::isCSCCounterClockwise ( const std::unique_ptr< const CSCLayer > &  layer) const
private

Check orientation of strips in given CSC chamber.

Definition at line 267 of file AngleConverter.cc.

References funct::abs(), and M_PI.

Referenced by getGlobalEta(), and getGlobalPhi().

267  {
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 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define M_PI

Member Data Documentation

edm::ESHandle<CSCGeometry> AngleConverter::_geocsc
private

Definition at line 64 of file AngleConverter.h.

Referenced by checkAndUpdateGeometry(), getGlobalEta(), and getGlobalPhi().

edm::ESHandle<DTGeometry> AngleConverter::_geodt
private

Definition at line 65 of file AngleConverter.h.

Referenced by checkAndUpdateGeometry(), and getGlobalEta().

unsigned long long AngleConverter::_geom_cache_id
private

Definition at line 62 of file AngleConverter.h.

Referenced by checkAndUpdateGeometry().

edm::ESHandle<RPCGeometry> AngleConverter::_georpc
private

Definition at line 63 of file AngleConverter.h.

Referenced by checkAndUpdateGeometry(), getGlobalEta(), and getGlobalPhi().