CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTTrigGeomUtils.cc
Go to the documentation of this file.
1 /*
2  * \file DTTrigGeomUtils.cc
3  *
4  * $Date: 2009/08/03 16:08:38 $
5  * $Revision: 1.2 $
6  * \author C. Battilana - CIEMAT
7  *
8 */
9 
11 
12 // Framework
14 
15 // Trigger
17 
18 // Geometry & Segment
26 
27 #include <iostream>
28 
29 using namespace edm;
30 using namespace std;
31 
32 
33 DTTrigGeomUtils::DTTrigGeomUtils(ESHandle<DTGeometry> muonGeom, bool dirInDeg) : muonGeom_(muonGeom) {
34 
35  radToDeg_ = dirInDeg ? 180./Geom::pi() : 1;
36 
37  for (int ist=1; ist<=4; ++ist) {
38  const DTChamberId chId(-2,ist,4);
39  const DTChamber *chamb = muonGeom_->chamber(chId);
40  const DTSuperLayer *sl1 = chamb->superLayer(DTSuperLayerId(chId,1));
41  const DTSuperLayer *sl3 = chamb->superLayer(DTSuperLayerId(chId,3));
42  zcn_[ist-1] = .5*(chamb->surface().toLocal(sl1->position()).z() + chamb->surface().toLocal(sl3->position()).z());
43  }
44 
45  const DTChamber* chamb = muonGeom_->chamber(DTChamberId(-2,4,13));
46  const DTChamber* scchamb = muonGeom_->chamber(DTChamberId(-2,4,4));
47  xCenter_[0] = scchamb->toLocal(chamb->position()).x()*.5;
48  chamb = muonGeom_->chamber(DTChamberId(-2,4,14));
49  scchamb = muonGeom_->chamber(DTChamberId(-2,4,10));
50  xCenter_[1] = scchamb->toLocal(chamb->position()).x()*.5;
51 
52 
53 }
54 
55 
57 
58 }
59 
60 
61 void DTTrigGeomUtils::computeSCCoordinates(const DTRecSegment4D* track, int& scsec, float& x, float& xdir, float& y, float& ydir){
62 
63  int sector = track->chamberId().sector();
64  int station = track->chamberId().station();
65  xdir = atan(track->localDirection().x()/ track->localDirection().z())*radToDeg_;
66  ydir = atan(track->localDirection().y()/ track->localDirection().z())*radToDeg_;
67 
68 
69  scsec = sector>12 ? sector==13 ? 4 : 10 : sector;
70  float xcenter = (scsec==4||scsec==10) ? (sector-12.9)/abs(sector-12.9)*xCenter_[(sector==10||sector==14)] : 0.;
71  x = track->localPosition().x()+xcenter*(station==4);
72  y = track->localPosition().y();
73 
74 }
75 
76 
77 void DTTrigGeomUtils::phiRange(const DTChamberId& id, float& min, float& max, int& nbins, float step){
78 
79  int station = id.station();
80  int sector = id.sector();
81 
82  const DTLayer *layer = muonGeom_->layer(DTLayerId(id,1,1));
83  DTTopology topo = layer->specificTopology();
84  double range = topo.channels()*topo.cellWidth();
85  min = -range*.5;
86  max = range*.5;
87 
88  if (station==4 && (sector==4 || sector == 10)){
89  min = -range-10;
90  max = range+10;
91  }
92  nbins = static_cast<int>((max-min)/step);
93 
94  return;
95 
96 }
97 
98 
99 void DTTrigGeomUtils::thetaRange(const DTChamberId& id, float& min, float& max, int& nbins, float step){
100 
101  const DTLayer *layer = muonGeom_->layer(DTLayerId(id,2,1));
102  DTTopology topo = layer->specificTopology();
103  double range = topo.channels()*topo.cellWidth();
104  min = -range*.5;
105  max = range*.5;
106 
107  nbins = static_cast<int>((max-min)/step);
108 
109  return;
110 
111 }
112 
113 
115 
116 
117  int wh = trig->whNum();
118  int sec = trig->scNum()+1;
119  int st = trig->stNum();
120  int phi = trig->phi();
121 
122  float phin = (sec-1)*Geom::pi()/6;
123  float phicenter = 0;
124  float r = 0;
125  float xcenter = 0;
126 
127  if (sec==4 && st==4) {
128  GlobalPoint gpos = phi>0 ? muonGeom_->chamber(DTChamberId(wh,st,13))->position() : muonGeom_->chamber(DTChamberId(wh,st,4))->position();
129  xcenter = phi>0 ? xCenter_[0] : -xCenter_[0];
130  phicenter = gpos.phi();
131  r = gpos.perp();
132  } else if (sec==10 && st==4) {
133  GlobalPoint gpos = phi>0 ? muonGeom_->chamber(DTChamberId(wh,st,14))->position() : muonGeom_->chamber(DTChamberId(wh,st,10))->position();
134  xcenter = phi>0 ? xCenter_[1] : -xCenter_[1];
135  phicenter = gpos.phi();
136  r = gpos.perp();
137  } else {
138  GlobalPoint gpos = muonGeom_->chamber(DTChamberId(wh,st,sec))->position();
139  phicenter = gpos.phi();
140  r = gpos.perp();
141  }
142 
143  float deltaphi = phicenter-phin;
144  float x = (tan(phi/4096.)-tan(deltaphi))*(r*cos(deltaphi) - zcn_[st-1]); //zcn is in local coordinates -> z invreases approching to vertex
145  if (hasPosRF(wh,sec)){ x = -x; } // change sign in case of positive wheels
146  x+=xcenter;
147 
148  return x;
149 
150 }
151 
152 
154 
155 
156  int wh = trig->whNum();
157  int sec = trig->scNum()+1;
158  int phi = trig->phi();
159  int phib = trig->phiB();
160 
161  float dir = (phib/512.+phi/4096.)*radToDeg_;
162 
163  // change sign in case of negative wheels
164  if (!hasPosRF(wh,sec)) { dir = -dir; }
165 
166  return dir;
167 
168 }
169 
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:71
list step
Definition: launcher.py:15
float trigDir(const L1MuDTChambPhDigi *trig)
Return local direction (trigger RF) for a given trigger primitive.
DTSuperLayerId
Geom::Phi< T > phi() const
Definition: PV3DBase.h:68
T y() const
Definition: PV3DBase.h:62
float cellWidth() const
Returns the cell width.
Definition: DTTopology.h:70
#define abs(x)
Definition: mlp_lapack.h:159
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:62
#define min(a, b)
Definition: mlp_lapack.h:161
virtual DTChamberId chamberId() const
The (specific) DetId of the chamber on which the segment resides.
double double double z
virtual LocalVector localDirection() const
Local direction in Chamber frame.
const DTTopology & specificTopology() const
Definition: DTLayer.cc:44
DTTrigGeomUtils(edm::ESHandle< DTGeometry > muonGeom, bool dirInDeg=true)
Constructor.
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:41
const T & max(const T &a, const T &b)
LocalPoint toLocal(const GlobalPoint &gp) const
T z() const
Definition: PV3DBase.h:63
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
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:77
bool hasPosRF(int wh, int sec)
Checks id the chamber has positive RF;.
edm::ESHandle< DTGeometry > muonGeom_
const BoundPlane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
double pi()
Definition: Pi.h:31
int sector() const
Definition: DTChamberId.h:63
dbl *** dir
Definition: mlp_gen.cc:35
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:53
x
Definition: VDTMath.h:216
T x() const
Definition: PV3DBase.h:61
void computeSCCoordinates(const DTRecSegment4D *track, int &scsec, float &x, float &xdir, float &y, float &ydir)
Compute track coordinates with SC sector numbering.
const DTSuperLayer * superLayer(DTSuperLayerId id) const
Return the superlayer corresponding to the given id.
Definition: DTChamber.cc:67
Definition: DDAxes.h:10