CMS 3D CMS Logo

DTTrigGeomUtils.cc
Go to the documentation of this file.
1 /*
2  * \file DTTrigGeomUtils.cc
3  *
4  * \author C. Battilana - CIEMAT
5  *
6 */
7 
9 
10 // Framework
12 
13 // Trigger
15 
16 // Geometry & Segment
24 
25 #include <iostream>
26 
27 using namespace edm;
28 using namespace std;
29 
30 DTTrigGeomUtils::DTTrigGeomUtils(ESHandle<DTGeometry> muonGeom, bool dirInDeg) : muonGeom_(muonGeom) {
31  radToDeg_ = dirInDeg ? 180. / Geom::pi() : 1;
32 
33  for (int ist = 1; ist <= 4; ++ist) {
34  const DTChamberId chId(-2, ist, 4);
35  const DTChamber* chamb = muonGeom_->chamber(chId);
36  const DTSuperLayer* sl1 = chamb->superLayer(DTSuperLayerId(chId, 1));
37  const DTSuperLayer* sl3 = chamb->superLayer(DTSuperLayerId(chId, 3));
38  zcn_[ist - 1] =
39  .5 * (chamb->surface().toLocal(sl1->position()).z() + chamb->surface().toLocal(sl3->position()).z());
40  }
41 
42  const DTChamber* chamb = muonGeom_->chamber(DTChamberId(-2, 4, 13));
43  const DTChamber* scchamb = muonGeom_->chamber(DTChamberId(-2, 4, 4));
44  xCenter_[0] = scchamb->toLocal(chamb->position()).x() * .5;
45  chamb = muonGeom_->chamber(DTChamberId(-2, 4, 14));
46  scchamb = muonGeom_->chamber(DTChamberId(-2, 4, 10));
47  xCenter_[1] = scchamb->toLocal(chamb->position()).x() * .5;
48 }
49 
51 
53  const DTRecSegment4D* track, int& scsec, float& x, float& xdir, float& y, float& ydir) {
54  int sector = track->chamberId().sector();
55  int station = track->chamberId().station();
56  xdir = atan(track->localDirection().x() / track->localDirection().z()) * radToDeg_;
57  ydir = atan(track->localDirection().y() / track->localDirection().z()) * radToDeg_;
58 
59  scsec = sector > 12 ? sector == 13 ? 4 : 10 : sector;
60  float xcenter = (scsec == 4 || scsec == 10)
61  ? (sector - 12.9) / abs(sector - 12.9) * xCenter_[(sector == 10 || sector == 14)]
62  : 0.;
63  x = track->localPosition().x() + xcenter * (station == 4);
64  y = track->localPosition().y();
65 }
66 
67 void DTTrigGeomUtils::phiRange(const DTChamberId& id, float& min, float& max, int& nbins, float step) {
68  int station = id.station();
69  int sector = id.sector();
70 
71  const DTLayer* layer = muonGeom_->layer(DTLayerId(id, 1, 1));
72  const DTTopology& topo = layer->specificTopology();
73  double range = topo.channels() * topo.cellWidth();
74  min = -range * .5;
75  max = range * .5;
76 
77  if (station == 4 && (sector == 4 || sector == 10)) {
78  min = -range - 10;
79  max = range + 10;
80  }
81  nbins = static_cast<int>((max - min) / step);
82 
83  return;
84 }
85 
86 void DTTrigGeomUtils::thetaRange(const DTChamberId& id, float& min, float& max, int& nbins, float step) {
87  const DTLayer* layer = muonGeom_->layer(DTLayerId(id, 2, 1));
88  const DTTopology& topo = layer->specificTopology();
89  double range = topo.channels() * topo.cellWidth();
90  min = -range * .5;
91  max = range * .5;
92 
93  nbins = static_cast<int>((max - min) / step);
94 
95  return;
96 }
97 
99  int wh = trig->whNum();
100  int sec = trig->scNum() + 1;
101  int st = trig->stNum();
102  int phi = trig->phi();
103 
104  float phin = (sec - 1) * Geom::pi() / 6;
105  float phicenter = 0;
106  float r = 0;
107  float xcenter = 0;
108 
109  if (sec == 4 && st == 4) {
110  GlobalPoint gpos = phi > 0 ? muonGeom_->chamber(DTChamberId(wh, st, 13))->position()
111  : muonGeom_->chamber(DTChamberId(wh, st, 4))->position();
112  xcenter = phi > 0 ? xCenter_[0] : -xCenter_[0];
113  phicenter = gpos.phi();
114  r = gpos.perp();
115  } else if (sec == 10 && st == 4) {
116  GlobalPoint gpos = phi > 0 ? muonGeom_->chamber(DTChamberId(wh, st, 14))->position()
117  : muonGeom_->chamber(DTChamberId(wh, st, 10))->position();
118  xcenter = phi > 0 ? xCenter_[1] : -xCenter_[1];
119  phicenter = gpos.phi();
120  r = gpos.perp();
121  } else {
122  GlobalPoint gpos = muonGeom_->chamber(DTChamberId(wh, st, sec))->position();
123  phicenter = gpos.phi();
124  r = gpos.perp();
125  }
126 
127  float deltaphi = phicenter - phin;
128  float x = (tan(phi / 4096.) - tan(deltaphi)) *
129  (r * cos(deltaphi) - zcn_[st - 1]); //zcn is in local coordinates -> z invreases approching to vertex
130  if (hasPosRF(wh, sec)) {
131  x = -x;
132  } // change sign in case of positive wheels
133  x += xcenter;
134 
135  return x;
136 }
137 
139  int wh = trig->whNum();
140  int sec = trig->scNum() + 1;
141  int phi = trig->phi();
142  int phib = trig->phiB();
143 
144  float dir = (phib / 512. + phi / 4096.) * radToDeg_;
145 
146  // change sign in case of negative wheels
147  if (!hasPosRF(wh, sec)) {
148  dir = -dir;
149  }
150 
151  return dir;
152 }
153 
154 // Local Variables:
155 // show-trailing-whitespace: t
156 // truncate-lines: t
157 // End:
virtual ~DTTrigGeomUtils()
Destructor.
T perp() const
Definition: PV3DBase.h:69
void thetaRange(const DTChamberId &id, float &min, float &max, int &nbins, float step=15)
Compute theta range in local chamber coordinates.
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:58
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
float trigDir(const L1MuDTChambPhDigi *trig)
Return local direction (trigger RF) for a given trigger primitive.
LocalPoint toLocal(const GlobalPoint &gp) const
constexpr std::array< uint8_t, layerIndexSize > layer
DTTrigGeomUtils(edm::ESHandle< DTGeometry > muonGeom, bool dirInDeg=true)
Constructor.
const DTSuperLayer * superLayer(const DTSuperLayerId &id) const
Return the superlayer corresponding to the given id.
Definition: DTChamber.cc:53
float cellWidth() const
Returns the cell width.
Definition: DTTopology.h:69
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void phiRange(const DTChamberId &id, float &min, float &max, int &nbins, float step=15)
Compute phi range in local chamber coordinates.
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
bool hasPosRF(int wh, int sec)
Checks id the chamber has positive RF;.
edm::ESHandle< DTGeometry > muonGeom_
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:43
HLT enums.
float x
step
Definition: StallMonitor.cc:98
constexpr double pi()
Definition: Pi.h:31
float trigPos(const L1MuDTChambPhDigi *trig)
Return local position (trigger RF) for a given trigger primitive.
int channels() const
Returns the number of wires in the layer.
Definition: DTTopology.h:76
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
Definition: DTGeometry.cc:90
void computeSCCoordinates(const DTRecSegment4D *track, int &scsec, float &x, float &xdir, float &y, float &ydir)
Compute track coordinates with SC sector numbering.
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
Definition: DTGeometry.cc:96