CMS 3D CMS Logo

GeometryTranslator.cc
Go to the documentation of this file.
2 
4 
13 
17 
19 
20 #include <cmath> // for pi
21 
22 using namespace L1TMuon;
23 
24 GeometryTranslator::GeometryTranslator() : _geom_cache_id(0ULL), _magfield_cache_id(0ULL) {}
25 
27 
29  switch (tp.subsystem()) {
30  case L1TMuon::kDT:
31  return calcDTSpecificEta(tp);
32  break;
33  case L1TMuon::kCSC:
34  return calcCSCSpecificEta(tp);
35  break;
36  case L1TMuon::kRPC:
37  return calcRPCSpecificEta(tp);
38  break;
39  case L1TMuon::kGEM:
40  return calcGEMSpecificEta(tp);
41  break;
42  case L1TMuon::kME0:
43  return calcME0SpecificEta(tp);
44  break;
45  default:
46  return std::nan("Invalid TP type!");
47  break;
48  }
49 }
50 
52  switch (tp.subsystem()) {
53  case L1TMuon::kDT:
54  return calcDTSpecificPhi(tp);
55  break;
56  case L1TMuon::kCSC:
57  return calcCSCSpecificPhi(tp);
58  break;
59  case L1TMuon::kRPC:
60  return calcRPCSpecificPhi(tp);
61  break;
62  case L1TMuon::kGEM:
63  return calcGEMSpecificPhi(tp);
64  break;
65  case L1TMuon::kME0:
66  return calcME0SpecificPhi(tp);
67  break;
68  default:
69  return std::nan("Invalid TP type!");
70  break;
71  }
72 }
73 
75  switch (tp.subsystem()) {
76  case L1TMuon::kDT:
77  return calcDTSpecificBend(tp);
78  break;
79  case L1TMuon::kCSC:
80  return calcCSCSpecificBend(tp);
81  break;
82  case L1TMuon::kRPC:
83  return calcRPCSpecificBend(tp);
84  break;
85  case L1TMuon::kGEM:
86  return calcGEMSpecificBend(tp);
87  break;
88  case L1TMuon::kME0:
89  return calcME0SpecificBend(tp);
90  break;
91  default:
92  return std::nan("Invalid TP type!");
93  break;
94  }
95 }
96 
98  switch (tp.subsystem()) {
99  case L1TMuon::kDT:
100  return calcDTSpecificPoint(tp);
101  break;
102  case L1TMuon::kCSC:
103  return getCSCSpecificPoint(tp);
104  break;
105  case L1TMuon::kRPC:
106  return getRPCSpecificPoint(tp);
107  break;
108  case L1TMuon::kGEM:
109  return getGEMSpecificPoint(tp);
110  break;
111  case L1TMuon::kME0:
112  return getME0SpecificPoint(tp);
113  break;
114  default:
116  GlobalPoint::Polar(std::nan("Invalid TP type!"), std::nan("Invalid TP type!"), std::nan("Invalid TP type!")));
117  return ret;
118  break;
119  }
120 }
121 
124  unsigned long long geomid = geom.cacheIdentifier();
125  if (_geom_cache_id != geomid) {
126  geom.get(_geodt);
127  geom.get(_geocsc);
128  geom.get(_georpc);
129  geom.get(_geogem);
130  geom.get(_geome0);
131  _geom_cache_id = geomid;
132  }
133 
135  unsigned long long magfieldid = magfield.cacheIdentifier();
136  if (_magfield_cache_id != magfieldid) {
137  magfield.get(_magfield);
138  _magfield_cache_id = magfieldid;
139  }
140 }
141 
142 // _____________________________________________________________________________
143 // ME0
145  const ME0DetId id(tp.detId<ME0DetId>());
146  const ME0Chamber* chamber = _geome0->chamber(id);
147  const ME0Layer* keylayer = chamber->layer(3); // ME0 key layer is layer 3
148  int partition = tp.getME0Data().partition; // 'partition' is in half-roll unit
149  int iroll = (partition >> 1) + 1;
150  const ME0EtaPartition* roll = keylayer->etaPartition(iroll);
151  assert(roll != nullptr); // failed to get ME0 roll
152  // See L1Trigger/ME0Trigger/src/ME0TriggerPseudoBuilder.cc
153  int phiposition = tp.getME0Data().phiposition; // 'phiposition' is in half-strip unit
154  int istrip = (phiposition >> 1);
155  int phiposition2 = (phiposition & 0x1);
156  float centreOfStrip = istrip + 0.25 + phiposition2 * 0.5;
157  const LocalPoint& lp = roll->centreOfStrip(centreOfStrip);
158  const GlobalPoint& gp = roll->surface().toGlobal(lp);
159  return gp;
160 }
161 
163  return getME0SpecificPoint(tp).eta();
164 }
165 
167  return getME0SpecificPoint(tp).phi();
168 }
169 
171  return tp.getME0Data().deltaphi * (tp.getME0Data().bend == 0 ? 1 : -1);
172 }
173 
174 // _____________________________________________________________________________
175 // GEM
177  const GEMDetId id(tp.detId<GEMDetId>());
178  const GEMEtaPartition* roll = _geogem->etaPartition(id);
179  assert(roll != nullptr); // failed to get GEM roll
180  //const uint16_t pad = tp.getGEMData().pad;
181  // Use half-pad precision, + 0.5 at the end to get the center of the pad (pad starts from 0)
182  const float pad = (0.5 * static_cast<float>(tp.getGEMData().pad_low + tp.getGEMData().pad_hi)) + 0.5f;
183  const LocalPoint& lp = roll->centreOfPad(pad);
184  const GlobalPoint& gp = roll->surface().toGlobal(lp);
185  return gp;
186 }
187 
189  return getGEMSpecificPoint(tp).eta();
190 }
191 
193  return getGEMSpecificPoint(tp).phi();
194 }
195 
196 double GeometryTranslator::calcGEMSpecificBend(const TriggerPrimitive& tp) const { return 0.0; }
197 
198 // _____________________________________________________________________________
199 // RPC
201  const RPCDetId id(tp.detId<RPCDetId>());
202  const RPCRoll* roll = _georpc->roll(id);
203  assert(roll != nullptr); // failed to get RPC roll
204  //const int strip = static_cast<int>(tp.getRPCData().strip);
205  // Use half-strip precision, - 0.5 at the end to get the center of the strip (strip starts from 1)
206  const float strip = (0.5 * static_cast<float>(tp.getRPCData().strip_low + tp.getRPCData().strip_hi)) - 0.5f;
207  const LocalPoint& lp = roll->centreOfStrip(strip);
208  const GlobalPoint& gp = roll->surface().toGlobal(lp);
209  return gp;
210 }
211 
213  return getRPCSpecificPoint(tp).eta();
214 }
215 
217  return getRPCSpecificPoint(tp).phi();
218 }
219 
220 // this function actually does nothing since RPC
221 // hits are point-like objects
222 double GeometryTranslator::calcRPCSpecificBend(const TriggerPrimitive& tp) const { return 0.0; }
223 
224 // _____________________________________________________________________________
225 // CSC
226 //
227 // alot of this is transcription and consolidation of the CSC
228 // global phi calculation code
229 // this works directly with the geometry
230 // rather than using the old phi luts
232  const CSCDetId id(tp.detId<CSCDetId>());
233  // we should change this to weak_ptrs at some point
234  // requires introducing std::shared_ptrs to geometry
235  std::unique_ptr<const CSCChamber> chamb(_geocsc->chamber(id));
236  assert(chamb != nullptr); // failed to get CSC chamber
237  std::unique_ptr<const CSCLayerGeometry> layer_geom(chamb->layer(CSCConstants::KEY_ALCT_LAYER)->geometry());
238  std::unique_ptr<const CSCLayer> layer(chamb->layer(CSCConstants::KEY_ALCT_LAYER));
239 
240  const uint16_t halfstrip = tp.getCSCData().strip;
241  const uint16_t pattern = tp.getCSCData().pattern;
242  const uint16_t keyWG = tp.getCSCData().keywire;
243  //const unsigned maxStrips = layer_geom->numberOfStrips();
244 
245  // so we can extend this later
246  // assume TMB2007 half-strips only as baseline
247  double offset = 0.0;
248  switch (1) {
249  case 1:
251  }
252  const unsigned halfstrip_offs = static_cast<unsigned>(0.5 + halfstrip + offset);
253  const unsigned strip = halfstrip_offs / 2 + 1; // geom starts from 1
254 
255  // the rough location of the hit at the ALCT key layer
256  // we will refine this using the half strip information
257  const LocalPoint& coarse_lp = layer_geom->stripWireGroupIntersection(strip, keyWG);
258  const GlobalPoint& coarse_gp = layer->surface().toGlobal(coarse_lp);
259 
260  // the strip width/4.0 gives the offset of the half-strip
261  // center with respect to the strip center
262  const double hs_offset = layer_geom->stripPhiPitch() / 4.0;
263 
264  // determine handedness of the chamber
265  const bool ccw = isCSCCounterClockwise(layer);
266  // we need to subtract the offset of even half strips and add the odd ones
267  const double phi_offset = ((halfstrip_offs % 2 ? 1 : -1) * (ccw ? -hs_offset : hs_offset));
268 
269  // the global eta calculation uses the middle of the strip
270  // so no need to increment it
271  const GlobalPoint final_gp(
272  GlobalPoint::Polar(coarse_gp.theta(), (coarse_gp.phi().value() + phi_offset), coarse_gp.mag()));
273 
274  // We need to add in some notion of the 'error' on trigger primitives
275  // like the width of the wire group by the width of the strip
276  // or something similar
277 
278  // release ownership of the pointers
279  chamb.release();
280  layer_geom.release();
281  layer.release();
282 
283  return final_gp;
284 }
285 
287  return getCSCSpecificPoint(tp).eta();
288 }
289 
291  return getCSCSpecificPoint(tp).phi();
292 }
293 
294 double GeometryTranslator::calcCSCSpecificBend(const TriggerPrimitive& tp) const { return tp.getCSCData().bend; }
295 
296 bool GeometryTranslator::isCSCCounterClockwise(const std::unique_ptr<const CSCLayer>& layer) const {
297  const int nStrips = layer->geometry()->numberOfStrips();
298  const double phi1 = layer->centerOfStrip(1).phi();
299  const double phiN = layer->centerOfStrip(nStrips).phi();
300  return ((std::abs(phi1 - phiN) < M_PI && phi1 >= phiN) || (std::abs(phi1 - phiN) >= M_PI && phi1 < phiN));
301 }
302 
303 // _____________________________________________________________________________
304 // DT
306  const DTChamberId baseid(tp.detId<DTChamberId>());
307  // do not use this pointer for anything other than creating a trig geom
308  std::unique_ptr<DTChamber> chamb(const_cast<DTChamber*>(_geodt->chamber(baseid)));
309  std::unique_ptr<DTTrigGeom> trig_geom(new DTTrigGeom(chamb.get(), false));
310  chamb.release(); // release it here so no one gets funny ideas
311  // super layer one is the theta superlayer in a DT chamber
312  // station 4 does not have a theta super layer
313  // the BTI index from the theta trigger is an OR of some BTI outputs
314  // so, we choose the BTI that's in the middle of the group
315  // as the BTI that we get theta from
316  // TODO:::::>>> need to make sure this ordering doesn't flip under wheel sign
317  const int NBTI_theta = ((baseid.station() != 4) ? trig_geom->nCell(2) : trig_geom->nCell(3));
318  const int bti_group = tp.getDTData().theta_bti_group;
319  const unsigned bti_actual = bti_group * NBTI_theta / 7 + NBTI_theta / 14 + 1;
320  DTBtiId thetaBTI;
321  if (baseid.station() != 4 && bti_group != -1) {
322  thetaBTI = DTBtiId(baseid, 2, bti_actual);
323  } else {
324  // since this is phi oriented it'll give us theta in the middle
325  // of the chamber
326  thetaBTI = DTBtiId(baseid, 3, 1);
327  }
328  const GlobalPoint& theta_gp = trig_geom->CMSPosition(thetaBTI);
329 
330  // local phi in sector -> global phi
331  double phi = static_cast<double>(tp.getDTData().radialAngle) / 4096.0; // 12 bits for 1 radian
332  phi += tp.getDTData().sector * M_PI / 6.0; // add sector offset, sector is [0,11]
333 
334  return GlobalPoint(GlobalPoint::Polar(theta_gp.theta(), phi, theta_gp.mag()));
335 }
336 
338 
340 
341 // we have the bend except for station 3
343  int bend = tp.getDTData().bendingAngle;
344  double bendf = bend / 512.0;
345  return bendf;
346 }
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:367
RPCRoll
Definition: RPCRoll.h:12
Geom::Phi::value
T1 value() const
Explicit access to value in case implicit conversion not OK.
Definition: Phi.h:75
L1TMuon::GeometryTranslator::getME0SpecificPoint
GlobalPoint getME0SpecificPoint(const TriggerPrimitive &) const
Definition: GeometryTranslator.cc:144
L1TMuon::GeometryTranslator::_magfield_cache_id
unsigned long long _magfield_cache_id
Definition: GeometryTranslator.h:70
L1TMuon::GeometryTranslator::calcGEMSpecificPhi
double calcGEMSpecificPhi(const TriggerPrimitive &) const
Definition: GeometryTranslator.cc:192
L1TMuon::GeometryTranslator::calcME0SpecificPhi
double calcME0SpecificPhi(const TriggerPrimitive &) const
Definition: GeometryTranslator.cc:166
L1TMuon::GeometryTranslator::getCSCSpecificPoint
GlobalPoint getCSCSpecificPoint(const TriggerPrimitive &) const
Definition: GeometryTranslator.cc:231
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
PV3DBase::theta
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72
L1TMuon::GeometryTranslator::calcCSCSpecificPhi
double calcCSCSpecificPhi(const TriggerPrimitive &) const
Definition: GeometryTranslator.cc:290
RPCDetId
Definition: RPCDetId.h:16
GEMEtaPartition
Definition: GEMEtaPartition.h:12
L1TMuon::GeometryTranslator::getGlobalPoint
GlobalPoint getGlobalPoint(const TriggerPrimitive &) const
Definition: GeometryTranslator.cc:97
dqmiodatasetharvest.nan
nan
Definition: dqmiodatasetharvest.py:39
cms::cuda::assert
assert(be >=bs)
DTTrigGeom.h
Geom::Spherical2Cartesian
Definition: CoordinateSets.h:58
CSCConstants::KEY_ALCT_LAYER
Definition: CSCConstants.h:46
RPCGeometry::roll
const RPCRoll * roll(RPCDetId id) const
Return a roll given its id.
Definition: RPCGeometry.cc:50
L1TMuon::GeometryTranslator::_georpc
edm::ESHandle< RPCGeometry > _georpc
Definition: GeometryTranslator.h:66
L1TMuon::GeometryTranslator::_geome0
edm::ESHandle< ME0Geometry > _geome0
Definition: GeometryTranslator.h:68
L1TMuon::GeometryTranslator::calcRPCSpecificEta
double calcRPCSpecificEta(const TriggerPrimitive &) const
Definition: GeometryTranslator.cc:212
DTGeometry::chamber
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
Definition: DTGeometry.cc:90
L1TMuon::GeometryTranslator::calculateGlobalPhi
double calculateGlobalPhi(const TriggerPrimitive &) const
Definition: GeometryTranslator.cc:51
ME0Layer::etaPartition
const ME0EtaPartition * etaPartition(ME0DetId id) const
Return the eta partition corresponding to the given id.
Definition: ME0Layer.cc:27
ME0Geometry::chamber
const ME0Chamber * chamber(ME0DetId id) const
Return a chamber given its id.
Definition: ME0Geometry.cc:43
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
GeomDet::surface
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
L1TMuon::kRPC
Definition: L1TMuonSubsystems.h:5
L1TMuon::GeometryTranslator::calcRPCSpecificPhi
double calcRPCSpecificPhi(const TriggerPrimitive &) const
Definition: GeometryTranslator.cc:216
L1TMuon::GeometryTranslator::_geogem
edm::ESHandle< GEMGeometry > _geogem
Definition: GeometryTranslator.h:67
L1TMuon::kME0
Definition: L1TMuonSubsystems.h:5
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
L1TMuon::GeometryTranslator::_geocsc
edm::ESHandle< CSCGeometry > _geocsc
Definition: GeometryTranslator.h:65
ME0EtaPartition::centreOfStrip
LocalPoint centreOfStrip(int strip) const
Definition: ME0EtaPartition.cc:26
Surface::toGlobal
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
CSCPatternBank::getLegacyPosition
static double getLegacyPosition(int pattern)
Definition: CSCPatternBank.cc:31
L1TMuon::GeometryTranslator::calcGEMSpecificBend
double calcGEMSpecificBend(const TriggerPrimitive &) const
Definition: GeometryTranslator.cc:196
IdealMagneticFieldRecord.h
L1TMuon::GeometryTranslator::calcCSCSpecificEta
double calcCSCSpecificEta(const TriggerPrimitive &) const
Definition: GeometryTranslator.cc:286
CSCConstants.h
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
L1TMuon::TriggerPrimitive
Definition: MuonTriggerPrimitive.h:57
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Point3DBase< float, GlobalTag >
L1TMuon::GeometryTranslator::calcDTSpecificBend
double calcDTSpecificBend(const TriggerPrimitive &) const
Definition: GeometryTranslator.cc:342
L1TMuon::GeometryTranslator::calcGEMSpecificEta
double calcGEMSpecificEta(const TriggerPrimitive &) const
Definition: GeometryTranslator.cc:188
L1TMuon::GeometryTranslator::_magfield
edm::ESHandle< MagneticField > _magfield
Definition: GeometryTranslator.h:71
cmsswSequenceInfo.tp
tp
Definition: cmsswSequenceInfo.py:17
L1TMuon::GeometryTranslator::GeometryTranslator
GeometryTranslator()
Definition: GeometryTranslator.cc:24
L1TMuon::GeometryTranslator::calcME0SpecificEta
double calcME0SpecificEta(const TriggerPrimitive &) const
Definition: GeometryTranslator.cc:162
DTGeometry.h
RPCRoll::centreOfStrip
LocalPoint centreOfStrip(int strip) const
Definition: RPCRoll.cc:26
runTauDisplay.gp
gp
Definition: runTauDisplay.py:431
L1TMuon::kCSC
Definition: L1TMuonSubsystems.h:5
L1TMuon::kDT
Definition: L1TMuonSubsystems.h:5
L1TMuon::GeometryTranslator::getRPCSpecificPoint
GlobalPoint getRPCSpecificPoint(const TriggerPrimitive &) const
Definition: GeometryTranslator.cc:200
L1TMuon::GeometryTranslator::calcCSCSpecificBend
double calcCSCSpecificBend(const TriggerPrimitive &) const
Definition: GeometryTranslator.cc:294
CSCPatternBank.h
ME0Layer
Definition: ME0Layer.h:9
GEMDetId
Definition: GEMDetId.h:18
L1TMuon::GeometryTranslator::checkAndUpdateGeometry
void checkAndUpdateGeometry(const edm::EventSetup &)
Definition: GeometryTranslator.cc:122
CSCDetId
Definition: CSCDetId.h:26
L1TMuon::kGEM
Definition: L1TMuonSubsystems.h:5
PV3DBase::eta
T eta() const
Definition: PV3DBase.h:73
L1TMuon::GeometryTranslator::calculateGlobalEta
double calculateGlobalEta(const TriggerPrimitive &) const
Definition: GeometryTranslator.cc:28
ME0Chamber
Definition: ME0Chamber.h:10
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
topSingleLeptonDQM_PU_cfi.pattern
pattern
Definition: topSingleLeptonDQM_PU_cfi.py:39
MagneticField.h
edm::EventSetup
Definition: EventSetup.h:57
ME0DetId
Definition: ME0DetId.h:16
DTBtiId
Definition: DTBtiId.h:32
GeometryTranslator.h
L1TMuon
Definition: L1TMuonSubsystems.h:4
MuonTriggerPrimitive.h
L1TMuon::GeometryTranslator::calcDTSpecificPhi
double calcDTSpecificPhi(const TriggerPrimitive &) const
Definition: GeometryTranslator.cc:339
me0TriggerPseudoDigis_cff.nStrips
nStrips
1.2 is to make the matching window safely the two nearest strips 0.35 is the size of an ME0 chamber i...
Definition: me0TriggerPseudoDigis_cff.py:26
GEMEtaPartition::centreOfPad
LocalPoint centreOfPad(int pad) const
Definition: GEMEtaPartition.cc:45
L1TMuon::GeometryTranslator::calcME0SpecificBend
double calcME0SpecificBend(const TriggerPrimitive &) const
Definition: GeometryTranslator.cc:170
PV3DBase::mag
T mag() const
Definition: PV3DBase.h:64
ME0Geometry.h
GEMGeometry.h
L1TMuon::GeometryTranslator::isCSCCounterClockwise
bool isCSCCounterClockwise(const std::unique_ptr< const CSCLayer > &) const
Definition: GeometryTranslator.cc:296
L1TMuon::GeometryTranslator::~GeometryTranslator
~GeometryTranslator()
Definition: GeometryTranslator.cc:26
trklet::bend
double bend(double r, double rinv, double stripPitch)
Definition: Util.h:160
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
DTTrigGeom
Definition: DTTrigGeom.h:41
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
EventSetup.h
L1TMuon::GeometryTranslator::calcDTSpecificPoint
GlobalPoint calcDTSpecificPoint(const TriggerPrimitive &) const
Definition: GeometryTranslator.cc:305
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
DTChamberId
Definition: DTChamberId.h:14
MuonGeometryRecord.h
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
L1TMuon::GeometryTranslator::calcRPCSpecificBend
double calcRPCSpecificBend(const TriggerPrimitive &) const
Definition: GeometryTranslator.cc:222
L1TMuon::GeometryTranslator::calculateBendAngle
double calculateBendAngle(const TriggerPrimitive &) const
Definition: GeometryTranslator.cc:74
volumeBasedMagneticField_160812_cfi.magfield
magfield
Definition: volumeBasedMagneticField_160812_cfi.py:11
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
L1TMuon::GeometryTranslator::calcDTSpecificEta
double calcDTSpecificEta(const TriggerPrimitive &) const
Definition: GeometryTranslator.cc:337
RPCGeometry.h
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
CSCGeometry::chamber
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
Definition: CSCGeometry.cc:100
DTChamberId::station
int station() const
Return the station number.
Definition: DTChamberId.h:42
L1TMuon::GeometryTranslator::getGEMSpecificPoint
GlobalPoint getGEMSpecificPoint(const TriggerPrimitive &) const
Definition: GeometryTranslator.cc:176
L1TMuon::GeometryTranslator::_geom_cache_id
unsigned long long _geom_cache_id
Definition: GeometryTranslator.h:63
L1TMuon::GeometryTranslator::_geodt
edm::ESHandle< DTGeometry > _geodt
Definition: GeometryTranslator.h:64
CSCGeometry.h
ME0EtaPartition
Definition: ME0EtaPartition.h:12
GEMGeometry::etaPartition
const GEMEtaPartition * etaPartition(GEMDetId id) const
Return a GEMEtaPartition given its id.
Definition: GEMGeometry.cc:77