CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTSurvey.cc
Go to the documentation of this file.
1 #include <fstream>
2 
8 
10 #include <iostream>
11 
12 DTSurvey::DTSurvey(const std::string& Wheel, const std::string& Chambers, int n)
13  : chambers(0) {
14 
15  nameOfWheelInfoFile = Wheel;
16  nameOfChamberInfoFile = Chambers;
17  id = n;
18 
19  FillWheelInfo();
20 }
21 
22 
24  delete [] chambers;
25 }
26 
27 
29  for(int stationCounter = 0; stationCounter < 4; stationCounter++) {
30  for(int sectorCounter = 0; sectorCounter < 14; sectorCounter++) {
31  if(chambers[stationCounter][sectorCounter]->getNumberPoints() > 2) {
32  chambers[stationCounter][sectorCounter]->compute();
33  }
34  }
35  }
36 }
37 
38 
39 const DTSurveyChamber * DTSurvey::getChamber(int station, int sector) const {return chambers[station][sector];}
40 
42 
43  //Create the chambers
44  chambers = new DTSurveyChamber ** [4];
45  for (int cont_stat = 0; cont_stat < 4; cont_stat++) {
46  chambers[cont_stat] = new DTSurveyChamber * [14];
47  for(int cont_sect = 0; cont_sect < 14; cont_sect++) {
48  DTChamberId mId(id, cont_stat+1, cont_sect+1);
49  chambers[cont_stat][cont_sect] = new DTSurveyChamber(id, cont_stat+1, cont_sect+1, mId.rawId());
50  }
51  }
52 
53  std::cout << nameOfChamberInfoFile << std::endl;
54  std::ifstream file(nameOfChamberInfoFile.c_str());
55  while(!file.eof()) {
56  int code, station, sector;
57  double x, y, z, rms, dx, dy, dz;
58  file >> code >> x >> y >> z >> rms >> dx >> dy >> dz;
59  if(file.eof()) break;
60  x = x/10.0; y=y/10.0; z=z/10.0; dx=dx/10.0; dy=dy/10.0; dz=dz/10.0;rms=rms/10.0;
61  station = code/10000 - 1;
62  sector = (code-(station+1)*10000)/100 - 1;
63  //De momento vamos a actuar como si no hubiera otra forma de resolver esto
64  TMatrixD r(3,1);
65  r(0,0) = x; r(1,0) = y;r(2,0) = z+OffsetZ;
66  TMatrixD disp(3,1);
67  disp(0,0) = dx; disp(1,0) = dy; disp(2,0) = dz;
68  TMatrixD rp = Rot*r-delta;
69  disp = disp-r+rp;
70 
71  GlobalPoint rg(r(0,0), r(1,0), r(2,0));
72  GlobalPoint rt(r(0,0)-disp(0,0), r(1,0)-disp(1,0), r(2,0)-disp(2,0));
73  DTChamberId mId(id, station+1, sector+1);
74  const DTChamber *mChamber = static_cast<const DTChamber *>(pDD->idToDet(mId));
75  LocalPoint rl = mChamber->toLocal(rg);
76  LocalPoint rtl = mChamber->toLocal(rt);
77  TMatrixD rLocal(3,1);
78  rLocal(0,0) = rl.x(); rLocal(1,0) = rl.y(); rLocal(2,0) = rl.z();
79  TMatrixD rTeo(3,1);
80  rTeo(0,0) = rtl.x(); rTeo(1,0) = rtl.y(); rTeo(2,0) = rtl.z();
81  TMatrixD diff = rLocal-rTeo;
82  TMatrixD errors(3,1);
83  errors(0,0) = rms; errors(1,0) = rms; errors(2,0) = rms;
84  chambers[station][sector]->addPoint(code, rLocal, diff, errors);
85  }
86  file.close();
87 }
88 
89 /*
90 void DTSurvey::ToDB(MuonAlignment *myMuonAlignment) {
91 
92  for(int station = 0; station < 4; station++) {
93  for(int sector = 0; sector < 14; sector++) {
94  if(chambers[station][sector]->getNumberPoints() > 2) {
95  std::vector<float> displacements;
96  std::vector<float> rotations;
97  displacements.push_back(chambers[station][sector]->getDeltaX());
98  displacements.push_back(chambers[station][sector]->getDeltaY());
99  displacements.push_back(chambers[station][sector]->getDeltaZ());
100  rotations.push_back(chambers[station][sector]->getAlpha());
101  rotations.push_back(chambers[station][sector]->getBeta());
102  rotations.push_back(chambers[station][sector]->getGamma());
103  DTChamberId mId(id, station+1, sector+1);
104  myMuonAlignment->moveAlignableLocalCoord(mId, displacements, rotations);
105  }
106  }
107  }
108 }
109 */
110 
112 
113  std::ifstream wheeltowheel(nameOfWheelInfoFile.c_str());
114  float zOffset, deltax, deltay, deltaz, alpha, beta, gamma;
115  wheeltowheel >> zOffset >> deltax >> deltay >> deltaz >> alpha >> beta >> gamma;
116  wheeltowheel.close();
117 
118  OffsetZ = zOffset;
119 
120  //Build displacement vector
121  delta.ResizeTo(3,1);
122  delta(0,0) = deltax/10.0;
123  delta(1,0) = deltay/10.0;
124  delta(2,0) = deltaz/10.0;
125 
126  //Build rotation matrix
127  Rot.ResizeTo(3,3);
128  TMatrixD alpha_m(3,3);
129  TMatrixD beta_m(3,3);
130  TMatrixD gamma_m(3,3);
131  alpha_m.Zero();
132  beta_m.Zero();
133  gamma_m.Zero();
134  for(int k = 0; k < 3; k++) {
135  alpha_m(k,k) = 1.0;
136  beta_m(k,k) = 1.0;
137  gamma_m(k,k) = 1.0;
138  }
139  alpha /= 1000.0; //New scale: angles in radians
140  beta /= 1000.0;
141  gamma /= 1000.0;
142  alpha_m(1,1) = cos(alpha);
143  alpha_m(1,2) = sin(alpha);
144  alpha_m(2,1) = -sin(alpha);
145  alpha_m(2,2) = cos(alpha);
146  beta_m(0,0) = cos(beta);
147  beta_m(0,2) = -sin(beta);
148  beta_m(2,0) = sin(beta);
149  beta_m(2,2) = cos(beta);
150  gamma_m(0,0) = cos(gamma);
151  gamma_m(0,1) = sin(gamma);
152  gamma_m(1,0) = -sin(gamma);
153  gamma_m(1,1) = cos(gamma);
154  Rot = alpha_m*beta_m*gamma_m;
155 }
156 
157 
158 std::ostream &operator<<(std::ostream & flux, const DTSurvey& obj) {
159 
160  for(int stationCounter = 0; stationCounter < 4; stationCounter++) {
161  for(int sectorCounter = 0; sectorCounter < 14; sectorCounter++) {
162  if(obj.getChamber(stationCounter,sectorCounter)->getNumberPoints() > 2) {
163  const DTSurveyChamber *m_chamber = obj.getChamber(stationCounter, sectorCounter);
164  flux << *m_chamber;
165  }
166  }
167  }
168  return flux;
169 }
const double beta
float alpha
Definition: AMPTWrapper.h:95
~DTSurvey()
Definition: DTSurvey.cc:23
TMatrixD Rot
Definition: DTSurvey.h:49
void ReadChambers(edm::ESHandle< DTGeometry >)
Definition: DTSurvey.cc:41
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T y() const
Definition: PV3DBase.h:63
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:69
int getNumberPoints() const
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:188
list diff
Definition: mps_update.py:85
std::string nameOfWheelInfoFile
Definition: DTSurvey.h:43
void CalculateChambers()
Definition: DTSurvey.cc:28
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
TMatrixD delta
Definition: DTSurvey.h:48
const DTSurveyChamber * getChamber(int, int) const
Definition: DTSurvey.cc:39
float OffsetZ
Definition: DTSurvey.h:47
T z() const
Definition: PV3DBase.h:64
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
DTSurveyChamber *** chambers
Definition: DTSurvey.h:51
void addPoint(int, const TMatrixD &, const TMatrixD &, const TMatrixD &)
std::string nameOfChamberInfoFile
Definition: DTSurvey.h:43
DTSurvey(const std::string &, const std::string &, int)
Definition: DTSurvey.cc:12
tuple cout
Definition: gather_cfg.py:145
static char chambers[264][20]
Definition: ReadPGInfo.cc:243
void FillWheelInfo()
Definition: DTSurvey.cc:111
T x() const
Definition: PV3DBase.h:62