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