All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
SiStripGeomFTD.cc
Go to the documentation of this file.
1 
2 #include "SiStripGeomFTD.h"
3 
4 // Include standard header files
5 #include "Colours.h"
6 #include "PhysicalConstants.h"
7 
8 #include <cstdlib>
9 #include <iomanip>
10 #include <algorithm>
11 #include <cmath>
12 
13 // Include CLHEP header files
14 #include <CLHEP/Vector/EulerAngles.h>
15 #include <CLHEP/Vector/Rotation.h>
16 
17 // Include Gear header files
18 #include <gear/BField.h>
19 //#include <gear/GearParameters.h>
20 #include <gearimpl/FTDParametersImpl.h>
21 #include <gearimpl/FTDLayerLayoutImpl.h>
22 #include <gearimpl/Vector3D.h>
23 
24 // Include Marlin
25 #include <marlin/Global.h>
26 #include <streamlog/streamlog.h>
27 
28 // Include Encoder stuff
29 #include "UTIL/LCTrackerConf.h"
30 #include <UTIL/ILDConf.h>
31 
32 
33 
34 namespace sistrip
35 {
36 
37 SiStripGeomFTD::SiStripGeomFTD(const std::string & detector, const double & pitchFront,
38  const double & pitchRear):
39  SiStripGeom(detector),_ftdParams(0),_ftdLayer(0),_pitchFront(pitchFront),
40  _pitchRear(pitchRear)
41 {
42  if( _gearType != "FTD")
43  {
44  streamlog_out(ERROR) << "Wrong instantiation of the class. " <<
45  "See SiStripBuilder class, should have an incoherence!" <<
46  std::endl;
47  exit(0);
48  }
49 }
50 
52 {
53 }
54 
55 
56 // Method initializing this class - reads Gear parameters from XML file
58 {
59 
60  // BField: needed for every tracker detector
61  try
62  {
63  const gear::BField & bField = marlin::Global::GEAR->getBField();
64 
65  gear::Vector3D auxvec(0.0,0.0,0.0);
66 
67  _magField.setX( (bField.at( auxvec )).x() * T);
68  _magField.setY( (bField.at( auxvec )).y() * T);
69  _magField.setZ( (bField.at( auxvec )).z() * T);
70  }
71  catch(gear::UnknownParameterException& e)
72  {
73  std::cout << "No magnetic field found in gear file!" << std::endl;
74  }
75 
76  //------Get the geometry from the gear file-----//
77  try
78  {
79  _ftdParams = const_cast<gear::FTDParameters *>(
80  &(marlin::Global::GEAR->getFTDParameters()) );
81  }
82  catch(gear::UnknownParameterException& e)
83  {
84  std::cout << "No FTD found in gear file" << std::endl;
85  exit(-1);
86  }
87 
88  try
89  {
90  _ftdLayer = const_cast<gear::FTDLayerLayout *>(
91  &_ftdParams->getFTDLayerLayout() );
92  }
93  catch(gear::UnknownParameterException & e)
94  {
95  std::cout << "Unexpected Error! No FTDLayerLayout found in"
96  << " FTDParameters class" << std::endl;
97  exit(-1);
98  }
99 
100  // Initializing the data members, extracting from gear
101 
102  _numberOfLayers = _ftdLayer->getNLayers();
103  // Layers goes from 0,..., 2N-1
104  _layerType.reserve(2*_numberOfLayers);
105  _layerZ.reserve(2*_numberOfLayers);
106  _layerRadius.reserve(2*_numberOfLayers);
107  _layerPhi0.reserve(2*_numberOfLayers);
108  _layerHalfPhi.reserve(2*_numberOfLayers);
111  _sensorThick.reserve(2*_numberOfLayers);
112  _sensorWidth.reserve(2*_numberOfLayers);
113  _sensorWidth2.reserve(2*_numberOfLayers);
114  _sensorLength.reserve(2*_numberOfLayers);
115  _layerRealID.reserve(2*_numberOfLayers);
116  _ladderThick.reserve(2*_numberOfLayers);
117  _ladderOffsetZ.reserve(2*_numberOfLayers);
120  _ladderLength.reserve(2*_numberOfLayers);
121  for(int i = 0; i < _numberOfLayers; ++i)
122  {
123  _layerType.push_back(_ftdLayer->getSensorType(i));
124  _layerZ.push_back(_ftdLayer->getZposition(i)*mm);
125  _layerRadius.push_back( _ftdLayer->getSensitiveRinner(i)*mm);
126  _layerPhi0.push_back(_ftdLayer->getPhi0(i));
127  _layerHalfPhi.push_back(_ftdLayer->getPhiHalfDistance(i));
128  _layerPetalOpAngle.push_back(_ftdLayer->getPhiHalfDistance(i));
129  _layerOuterRadius.push_back(_ftdLayer->getSensitiveRinner(i)+
130  _sensorLength[i]*mm);
131  _layerRealID.push_back(i+1);
132 
133  _sensorThick.push_back(_ftdLayer->getSensitiveThickness(i)*mm);
134  _sensorWidth.push_back(_ftdLayer->getSensitiveLengthMax(i)*mm);// x-direction
135  _sensorWidth2.push_back(_ftdLayer->getSensitiveLengthMin(i)*mm);// x-direction
136  _sensorLength.push_back(_ftdLayer->getSensitiveWidth(i)*mm); // y-direction
137  _ladderThick.push_back(_ftdLayer->getSupportThickness(i)*mm);
138  _ladderZOffsetSign0.push_back(_ftdLayer->getZoffsetSign0(i));
139  _ladderOffsetZ.push_back(_ftdLayer->getZoffset(i)*mm);
140  _numberOfLadders.push_back(_ftdLayer->getNPetals(i));
141  _ladderLength.push_back(_ftdLayer->getSupportWidth(i)*mm);
142  }
143  // Negative layers
144  const unsigned int ridsize = _layerRealID.size();
145  for(unsigned int i=0; i < ridsize; ++i)
146  {
147  _layerRealID.push_back(-1*_layerRealID.at(i));
148  }
149  _layerType.insert(_layerType.end(),_layerType.begin(),_layerType.end());
150  _layerZ.insert(_layerZ.end(),_layerZ.begin(),_layerZ.end());
151  _layerRadius.insert(_layerRadius.end(),_layerRadius.begin(),_layerRadius.end());
152  _layerPhi0.insert(_layerPhi0.end(),_layerPhi0.begin(),_layerPhi0.end());
153  _layerHalfPhi.insert(_layerHalfPhi.end(),_layerHalfPhi.begin(),_layerHalfPhi.end());
155  _layerPetalOpAngle.end());
157  _layerOuterRadius.end());
158  _sensorThick.insert(_sensorThick.end(),_sensorThick.begin(),_sensorThick.end());
159  _sensorWidth.insert(_sensorWidth.end(),_sensorWidth.begin(),_sensorWidth.end());
160  _sensorWidth2.insert(_sensorWidth2.end(),_sensorWidth2.begin(),_sensorWidth2.end());
161  _sensorLength.insert(_sensorLength.end(),_sensorLength.begin(),
162  _sensorLength.end());
163  _ladderThick.insert(_ladderThick.end(),_ladderThick.begin(),_ladderThick.end());
164  _ladderOffsetZ.insert(_ladderOffsetZ.end(),_ladderOffsetZ.begin(),
165  _ladderOffsetZ.end());
167  _ladderZOffsetSign0.end());
169  _numberOfLadders.end());
170  _ladderLength.insert(_ladderLength.end(),_ladderLength.begin(),
171  _ladderLength.end());
172 
173  _sensorPitchInFront = std::vector<double>(2*_numberOfLayers,_pitchFront);//*um);
174  _sensorNStripsInFront.reserve(2*_numberOfLayers);
175  _sensorPitchInRear = std::vector<double>(2*_numberOfLayers,_pitchRear);//*um);
176  _sensorNStripsInRear.reserve(2*_numberOfLayers);
177  for(int i = 0; i < _numberOfLayers; ++i)
178  {
179  // Pitch defined in the middle
180  const double xmaxsensorup = _ftdLayer->getSensitiveLengthMax(i)*mm;
181  const double ymiddlesensorup = _ftdLayer->getSensitiveWidth(i)*mm/2.0;
182  const double widthmiddle = xmaxsensorup-
183  (2.0*tan(_ftdLayer->getPhiHalfDistance(i))*ymiddlesensorup);
184 
185  _sensorNStripsInFront.push_back( (int)(widthmiddle/_sensorPitchInFront[i])+1 );
186  _sensorNStripsInRear.push_back( (int)(widthmiddle/_sensorPitchInRear[i])+1 );
187  }
189  _sensorNStripsInFront.end());
191  _sensorNStripsInRear.end());
192 }
193 
194 
195 void SiStripGeomFTD::updateCanonicalCellID(const int & cellID, const int & stripType,
196  const int & stripID, UTIL::BitField64 * cellEnc)
197 {
198  std::map<std::string,int> bfmap = decodeCellID(cellID);
199  (*cellEnc)["subdet"]=ILDDetID::FTD;
200  short int layer = bfmap["layer"];
201  short int module= bfmap["module"];
202  short int sensor= bfmap["sensor"];
203 
204  //decodeCellID(layer,module,sensor,cellID);
205 
206  int realLayer = getLayerRealID(layer);
207 
208  (*cellEnc)["side"]=abs(realLayer)/realLayer;
209  (*cellEnc)["layer"]=abs(realLayer);
210  (*cellEnc)["module"]=module+1; // Note that we want to keep the geant4 style
211  (*cellEnc)["sensor"]=sensor;
212  (*cellEnc)["stripType"]=stripType;
213  (*cellEnc)["stripID"]=stripID;
214 }
215 
216 //
217 //! Returns the input cellID0 where the field sensor is put to 0
218 int SiStripGeomFTD::cellID0withSensor0(const int & cellID0) const
219 {
220  UTIL::BitField64 cellDec(LCTrackerCellID::encoding_string());
221  cellDec.setValue((lcio::long64)cellID0);
222 
223  cellDec["sensor"] = 0;
224 
225  return cellDec.lowWord();
226 }
227 
228 //
229 // Decode Strip type and Strip ID (CellID1) (int version)
230 std::pair<StripType,int> SiStripGeomFTD::decodeStripID(const int & cellID1) const
231 {
232  UTIL::BitField64 cellDec("stripType:2,stripID:11");
233  cellDec.setValue((lcio::long64)cellID1);
234 
235  StripType stripType = static_cast<StripType>( cellDec["stripType"].value() );
236  int stripID = cellDec["stripID"];
237 
238  return std::pair<StripType,int>(stripType,stripID);
239 }
240 
241 //
242 // Decode Strip type and Strip ID (CellID1) (BitField version)
243 std::pair<StripType,int> SiStripGeomFTD::decodeStripID(const UTIL::BitField64 & cellDec) const
244 {
245  if(cellDec["subdet"] != ILDDetID::FTD)
246  {
247  streamlog_out(ERROR) << "SiStripGeomFTD::decodeStripID "
248  << " - subdetector is not FTD!!"
249  << std::endl;
250  exit(-1);
251  }
252 
253  StripType stripType = static_cast<StripType>( cellDec["stripType"].value() );
254  int stripID = cellDec["stripID"];
255 
256  return std::pair<StripType,int>(stripType,stripID);
257 }
258 
259 // FIXME: TO BE PUT IN GEAR ??
260 // Returns the layer, module and sensor id. It returns in C-type indexs:
261 //---- The notation used in this code:
262 // Layer: 0,...., 6 (Positive Z)
263 // 7,....,13 (Negative Z)
264 // Petal: 0,....,15
265 // Sensor: 1 2 3 4
266 // Argument codified as string
267 std::map<std::string,int> SiStripGeomFTD::decodeCellID(const int & cellID) const
268 {
269  UTIL::BitField64 cellDec(LCTrackerCellID::encoding_string());
270  cellDec.setValue((lcio::long64)cellID);
271 
272  return decodeCellID(cellDec);
273 }
274 
275 // FIXME: TO BE PUT IN GEAR ??
276 // Returns the layer, module and sensor id. It returns in C-type indexs:
277 //---- The notation used in this code:
278 // Layer: 0,...., 6 (Positive Z)
279 // 7,....,13 (Negative Z)
280 // Petal: 0,....,15
281 // Sensor: 1 2 3 4
282 // Argument codified in the BitField64 class
283 std::map<std::string,int> SiStripGeomFTD::decodeCellID(const UTIL::BitField64 & cellDec) const
284 {
285  //FIXME: Quizas incluir un decodeCellID0 en gear??
286 
287  // Checking we are using the canonical codification
288  //FIXME:: los strings son diferentes!! pensar como solucionar
289  /*if(cellDec.fielDescription() != LCTrackerCellID::encoding_string())
290  {
291  streamlog_out(ERROR) << "SiStripGeomFTD::decodeCellID0 "
292  << " - the codification used is not the canonical.\n "
293  << " Canonical codification string: " << cellDec.fieldDescription()
294  << " " << LCTrackerCellID::encoding_string()
295  << std::endl;
296  exit(-1);
297  }*/
298 
299  if(cellDec["subdet"] != ILDDetID::FTD)
300  {
301  streamlog_out(ERROR) << "SiStripGeomFTD::decodeCellID0 "
302  << " - subdetector is not FTD!!"
303  << std::endl;
304  exit(-1);
305  }
306 
307  // Recall: codification in Mokka/G4:
308  // Layer: 1,...7; Side: -1,+1; Petal: 1...16; Sensor: 1,2,3,4
309  std::map<std::string,int> codmap;
310  codmap["layer"] = getLayerIDCTypeNo( cellDec["side"]*cellDec["layer"] );
311  codmap["module"]= cellDec["module"]-1;
312  codmap["sensor"]= cellDec["sensor"];
313 
314  return codmap;
315 }
316 
317 // Added
318 double SiStripGeomFTD::getLadderOffsetX(const short int & layerID) const
319 {
320 
321  if( _sensorWidth.size() < (unsigned int)layerID )
322  {
323  streamlog_out(ERROR) <<
324  "SiStripGeomFTD::getLadderOffsetX - layerID: " <<
325  layerID << " out of range!!!" << std::endl;
326  }
327 
328  return _sensorWidth[layerID]/2.0;
329 }
330 
331 // TRANSFORMATION METHODS - GLOBAL REF. SYSTEM
332 
333 // The Local Reference Frame system (LRF) is defined in the way that:
334 // - is defined positive
335 // - the electric drift field is oriented in the negative direction
336 // of the X-axis
337 // - all the hits inside a sensors have positive local coordinates
338 // - the strips collecting holes (Single Side as Double side sensors)
339 // are faced to the IP
340 // - the strips collecting holes are in the sensor plane X=0 (the holes
341 // are collected by the strips oriented in Z-direction).
342 // These requerimemts make placing the LRF:
343 //
344 // --------
345 // | | Face near IP
346 // 1 and 2 sensors | |
347 // |__| X <---
348 //
349 //
350 // --------
351 // | |
352 // 3 and 4 sensors | | Face far IP
353 // ---> X |__|
354 //
355 
356 
357 //
358 // Method transforming given point from global ref. system to local ref. system
359 // (parameters: diskID, petalID, sensorID and space point in global ref. system)
360 //
361 CLHEP::Hep3Vector SiStripGeomFTD::transformPointToLocal(short int diskID, short int petalID, short int sensorID, const CLHEP::Hep3Vector & globalPoint)
362 {
363  // Initialize local point
364  CLHEP::Hep3Vector localPoint(globalPoint);
365 
366  // Phi Angle of the Petal (on the centroid of the petal with respect the x-axis)
367  const double phi0 = _ftdLayer->getPhiPetalCd(diskID,petalID);
368 
369  //
370  // RECALL: ftd gear have the convention mm (distance), here we have cm
371  //
372 
373  // Extract the Z of the sensor: diferent position depending the sensor
374  const double zsensorCd = _ftdLayer->getSensitiveZposition(diskID,petalID,sensorID)*mm;
375  const int zsign = (int)(zsensorCd/fabs(zsensorCd));
376  const double sensorthickness = _ftdLayer->getSensitiveThickness(diskID)*mm;
377  // Sensor 3 and 4: Displacing to the trapezoid farest the IP
378  double zsensor = zsensorCd+zsign*sensorthickness/2.0;
379  // Sensor 1 and 2: Displacing to the trapezoid facing the IP
380  if( sensorID < 3 )
381  {
382  zsensor = zsensorCd-zsign*sensorthickness/2.0;
383  }
384 
385  // And the X and Y CentroiD position: over the smallest side of the trapezoid
386  const int xsign = (int)(fabs(globalPoint.getX())/globalPoint.getX());
387  const double xsensorCd = xsign*(_ftdLayer->getSensitiveRinner(diskID)*mm)*
388  fabs(cos(phi0));
389 
390  const int ysign = (int)(fabs(globalPoint.getY())/globalPoint.getY());
391  const double ysensorCd = ysign*(_ftdLayer->getSensitiveRinner(diskID)*mm)*
392  fabs(sin(phi0));
393 
394  // The (0,0,0) position of LFR
395  CLHEP::Hep3Vector localOrigin(xsensorCd, ysensorCd, zsensor);
396 
397  // Translating the globalPoint to the local Origin
398  localPoint -= localOrigin;
399 
400  // Perform rotation to get the system local:
401  // Z-positives sensors 1,2 |
402  // Z-negatives sensors 3,4 |-- Same transformation
403  //
404  // Z-positives sensors 3,4 | ---> La antigua
405  // Z-negatives sensors 1,2 |-- Same transformation
406  double rotZangle = -phi0;
407  double rotYangle = -M_PI/2.0;
408  if( (sensorID < 3 && zsign > 0) ||
409  (sensorID > 2 && zsign < 0) )
410  {
411  rotZangle = M_PI-phi0;
412  rotYangle = M_PI/2.0;
413  }
414  localPoint.rotateZ(rotZangle);
415  localPoint.rotateY(rotYangle);
416 
417  // Avoiding X,Y and Z negative values--> displacing from the
418  // centroid to the edge
419  const double longtrapezoidedge = _ftdLayer->getSensitiveLengthMax(diskID)*mm;
420  localPoint += CLHEP::Hep3Vector(0.0,longtrapezoidedge/2.,0.0);
421 
422  streamlog_out(DEBUG4) <<
423  "============================================\n"
424  << "SiStripGeomFTD::transformPointToLocal \n"
425  << " Sensor ID (C-vector style): \n "
426  << " DISK: "<<diskID<<" PETAL: "<<petalID<<" SENSOR: " << sensorID << "\n"
427  << " Petal Phi: " << phi0*180.0/M_PI << "\n"
428  << std::setprecision(3)
429  << " Origen of Local frame [mm]: (" << xsensorCd/mm <<","
430  << ysensorCd/mm << "," << zsensor/mm << ")\n"
431  << " Hit (Global ref. frame) [mm]:" << globalPoint/mm << "\n"
432  << " Hit (Local ref. frame) [mm]:" << localPoint/mm << "\n"
433  << " Maximum dimensions: x < " << sensorthickness/mm
434  << ", y < " << longtrapezoidedge/mm << ", z < "
435  << _ftdLayer->getSensitiveWidth(diskID)*mm/mm << " [mm]\n"
436  << "============================================" << std::endl;
437 
438  // Return space point in local ref. system
439  return localPoint;
440 }
441 
442 //
443 // Method transforming given vector from global ref. system to local ref. system
444 // (parameters: layerID, ladderID, sensorID and vector in global ref. system)
445 //
446 CLHEP::Hep3Vector SiStripGeomFTD::transformVecToLocal(short int diskID, short int petalID,
447  short int sensorID, const CLHEP::Hep3Vector & globalVec)
448 {
449  // Initialize local vector
450  CLHEP::Hep3Vector localVec(globalVec);
451 
452  const double phi0 = _ftdLayer->getPhiPetalCd(diskID,petalID);
453  // Extract z-sign and
454  const int realLayerID = getLayerRealID(diskID);
455  const int zsign = abs(realLayerID)/realLayerID;
456  // Sensors 3,4 z-positive and 1,2 z-negative
457  double rotZangle = -phi0;
458  double rotYangle = -M_PI/2.0;
459  // Sensors 1,2 z-positive and 3,4 z-negative
460  if( (sensorID < 3 && zsign > 0) ||
461  (sensorID > 2 && zsign < 0) )
462  {
463  rotZangle = M_PI-phi0;
464  rotYangle = M_PI/2.0;
465  }
466  localVec.rotateZ(rotZangle);
467  localVec.rotateY(rotYangle);
468 
469  // Return vector in local ref. system
470  return localVec;
471 }
472 
473 //
474 // Method transforming given matrix 3x3 from global ref. system to local ref. system
475 // (parameters: layerID, ladderID, sensorID and matrix in global ref. system)
476 //
477 CLHEP::HepMatrix SiStripGeomFTD::transformMatxToLocal(short int layerID, short int ladderID, const CLHEP::HepMatrix & globalMatrix)
478 {
479  // FIXME: NOT DONE YET
480  std::cout << "SiStripGeomFTD::transformMatxToLocal -- METHOD NOT IMPLEMENTED"
481  << std::endl;
482  exit(0);
483  // Initialize local matrix 3x3 to zero values
484  CLHEP::HepMatrix localMatrix(3,3,0);
485 
486  // Initialize rotation matrices: R, R^T (transposition)
487  CLHEP::HepMatrix rotMatrix(3,3,0);
488  CLHEP::HepMatrix rotMatrixT(3,3,0);
489 
490  // Gear type: VXD
491  if (_gearType == "VXD") {
492 
493  // Calculate rotation angles
494  double theta = getLadderTheta(layerID); // ALWAYS M_PI/2
495  double phi = getLadderPhi(layerID, ladderID);
496 
497  // Calculate rotation matrices - help
498  CLHEP::HepRotation rotMatrixZ(CLHEP::Hep3Vector(0,0,1),-phi);
499  CLHEP::HepRotation rotMatrixY(CLHEP::Hep3Vector(0,1,0),+theta);
500  CLHEP::HepRotation rotMatrixHelp(rotMatrixY*rotMatrixZ);
501 
502  CLHEP::HepRotation rotMatrixHelpT(rotMatrixHelp.inverse());
503 
504  for (int i=0; i<3; ++i) {
505  for (int j=0; j<3; ++j) {
506  rotMatrix[i][j] = rotMatrixHelp[i][j];
507  rotMatrixT[i][j] = rotMatrixHelpT[i][j];
508  }
509  }
510  }
511 
512  // Gear type: unknown - error
513  else {
514  streamlog_out(ERROR) << "Unknown gear type!"
515  << std::endl;
516 
517  exit(0);
518  }
519 
520  // Transform given matrix - rotation wrt global ref. system
521  localMatrix = rotMatrix*globalMatrix*rotMatrixT;
522 
523  // Return matrix in local ref. system
524  return localMatrix;
525 }
526 
527 
528 // TRANSFORMATION METHODS - LOCAL REF. SYSTEM
529 
530 //
531 // Method transforming given point from local ref. system to global ref. system
532 // (parameters: layerID, ladderID, sensorID and space point in local ref. system)
533 //
534 CLHEP::Hep3Vector SiStripGeomFTD::transformPointToGlobal(short int diskID,
535  short int petalID, short int sensorID, const CLHEP::Hep3Vector & localPoint)
536 {
537  // Initialize global point
538  CLHEP::Hep3Vector globalPoint(localPoint);
539 
540  // Calculate rotation angles
541  double theta = getLadderTheta(diskID); // ALWAYS M_PI/2.0
542  double phi = getLadderPhi(diskID, petalID);
543 
544  // Taking account of the z-side
545  const int realLayerID = getLayerRealID(diskID);
546  const int zsign = abs(realLayerID)/realLayerID;
547  double rotZangle = -phi;
548  double rotYangle = -theta;
549  if( (sensorID < 3 && zsign > 0) ||
550  (sensorID > 2 && zsign < 0) )
551  {
552  rotZangle = M_PI-phi;
553  rotYangle = theta;
554  }
555 
556  // Perform translation - to the center of a petal (in local frame)
557  // Note that the center of the petal we decide defining in the back face
558  // of the sensor
559  const double xlocalCd = 0.0; // Already in the back face_ftdLayer->getSensitiveThickness(diskID)*mm;
560  const double ylocalCd = _ftdLayer->getSensitiveLengthMax(diskID)/2.0*mm;
561  const double zlocalCd = 0.0; // already in the low edge of the petal (see ysensorCd)
562 
563  globalPoint -= CLHEP::Hep3Vector(xlocalCd,ylocalCd,zlocalCd);
564 
565  // Perform rotation - with respect to the local centre of a ladder
566  globalPoint.rotateY(-rotYangle);
567  globalPoint.rotateZ(-rotZangle);
568  // Now we have the vector in global coordinates from the center of the petal
569  // to the hit
570 
571  // Find (0,0,0) position of local coordinate system (in global coord.)
572  // Extract the Z of the sensor
573  const double zsensorCd = _ftdLayer->getSensitiveZposition(diskID,petalID,sensorID)*mm;
574  const double sensorthickness = _ftdLayer->getSensitiveThickness(diskID)*mm;
575  // Sensor 3 and 4: Displacing to the trapezoid farest the IP
576  double zsensor = zsensorCd+zsign*sensorthickness/2.0;
577  // Sensor 1 and 2: Displacing to the trapezoid facing the IP
578  if( sensorID < 3 )
579  {
580  zsensor = zsensorCd-zsign*sensorthickness/2.0;
581  }
582  /* OLD
583  // Sensors 3 and 4: Displacing to the backed the IP face
584  double zsensorback = zsensor+zsign*sensorthickness/2.0;
585  if( sensorID < 3 )
586  {
587  zsensorback = zsensor-zsign*sensorthickness/2.0;
588  } END OLD*/
589  // And the X and Y CentroiD position: over the smallest side of the trapezoid
590  const double xsensorCd = _ftdLayer->getSensitiveRinner(diskID)*mm*cos(phi);
591  const double ysensorCd = _ftdLayer->getSensitiveRinner(diskID)*mm*sin(phi);
592  CLHEP::Hep3Vector localOrigin(xsensorCd,ysensorCd,zsensor);
593 
594  // Perform translation - to the global system
595  globalPoint += localOrigin;
596 
597  streamlog_out(DEBUG4) <<
598  "============================================\n"
599  << "SiStripGeomFTD::transformPointToGlobal \n"
600  << " Sensor ID (C-vector style): \n "
601  << " DISK: "<<diskID<<" PETAL: "<<petalID<<" SENSOR: " << sensorID << "\n"
602  << " Petal Phi: " << phi*180.0/M_PI << "\n"
603  << std::setprecision(3)
604  << " Origen of Local frame [mm]: (" << xsensorCd/mm <<","
605  << ysensorCd/mm << "," << zsensor/mm << ")\n"
606  << " Hit (Global ref. frame) [mm]:" << globalPoint/mm << "\n"
607  << " Hit (Local ref. frame) [mm]:" << localPoint/mm << "\n"
608  << "============================================" << std::endl;
609 
610  // Return space point in global ref. system
611  return globalPoint;
612 }
613 
614 //
615 // Method transforming given vector from local ref. system to global ref. system
616 // (parameters: layerID, ladderID, sensorID and vector in local ref. system)
617 //
618 CLHEP::Hep3Vector SiStripGeomFTD::transformVecToGlobal(short int diskID, short int petalID,
619  short int sensorID, const CLHEP::Hep3Vector & localVec)
620 {
621  // Initialize global vector
622  CLHEP::Hep3Vector globalVec(localVec);
623 
624 
625  // Calculate rotation angles
626  double theta = getLadderTheta(diskID); // ALWAYS PI/2
627  double phi = getLadderPhi(diskID, petalID);
628 
629  const int realLayerID = getLayerRealID(diskID);
630  const int zsign = abs(realLayerID)/realLayerID;
631  double rotZangle = -phi;
632  double rotYangle = -theta;
633  if( (sensorID < 3 && zsign > 0) ||
634  (sensorID > 2 && zsign < 0) )
635  {
636  rotZangle = M_PI-phi;
637  rotYangle = theta;
638  }
639  globalVec.rotateY(-rotYangle);
640  globalVec.rotateZ(-rotZangle);
641 
642  // Return vector in global ref. system
643  return globalVec;
644 }
645 
646 //
647 // Method transforming given matrix 3x3 from local ref. system to global ref. system
648 // (parameters: layerID, ladderID, sensorID and matrix in local ref. system)
649 //
650 CLHEP::HepMatrix SiStripGeomFTD::transformMatxToGlobal(short int layerID, short int ladderID, const CLHEP::HepMatrix & localMatrix)
651 {
652  // FIXME: NOT DONE YET
653  std::cout << "SiStripGeomFTD::transformMatxToGlobal -- METHOD NOT IMPLEMENTED"
654  << std::endl;
655  exit(0);
656  // Initialize local matrix 3x3 to zero values
657  CLHEP::HepMatrix globalMatrix(3,3,0);
658 
659  // Initialize rotation matrices: R, R^T (transposition)
660  CLHEP::HepMatrix rotMatrix(3,3,0);
661  CLHEP::HepMatrix rotMatrixT(3,3,0);
662 
663  // Gear type: VXD
664  if (_gearType == "VXD") {
665 
666  // Calculate rotation angles
667  double theta = getLadderTheta(layerID);
668  double phi = getLadderPhi(layerID, ladderID);
669 
670  // Calculate rotation matrices - help
671  CLHEP::HepRotation rotMatrixY(CLHEP::Hep3Vector(0,1,0),-theta);
672  CLHEP::HepRotation rotMatrixZ(CLHEP::Hep3Vector(0,0,1),+phi);
673  CLHEP::HepRotation rotMatrixHelp(rotMatrixZ*rotMatrixY);
674 
675  CLHEP::HepRotation rotMatrixHelpT(rotMatrixHelp.inverse());
676 
677  for (int i=0; i<3; ++i) {
678  for (int j=0; j<3; ++j) {
679  rotMatrix[i][j] = rotMatrixHelp[i][j];
680  rotMatrixT[i][j] = rotMatrixHelpT[i][j];
681  }
682  }
683  }
684 
685  // Gear type: unknown - error
686  else {
687  streamlog_out(ERROR) << "Unknown gear type!"
688  << std::endl;
689 
690  exit(0);
691  }
692 
693  // Transform given matrix - rotation wrt local ref. system
694  globalMatrix = rotMatrix*localMatrix*rotMatrixT;
695 
696  // Return matrix in global ref. system
697  return globalMatrix;
698 }
699 
700 
701 // OTHER METHODS - GLOBAL REF. SYSTEM
702 
703 //
704 // Get info whether the given point is inside of Si sensor (parameters: layerID,
705 // space point in local ref. system)
706 //
707 bool SiStripGeomFTD::isPointInsideSensor (short int diskID, short int petalID,
708  short int sensorID, const CLHEP::Hep3Vector & point) const
709 {
710  // Angle defining the petals
711  const double phi0 = _ftdLayer->getPhiHalfDistance(diskID);
712 
713  // Calculate the maximum of each axis
714  const double xmax = _ftdLayer->getSensitiveThickness(diskID)*mm;
715  const double ygap = (_ftdLayer->getSensitiveWidth(diskID)*mm - point.getZ())*tan(phi0);
716  const double ymax = _ftdLayer->getSensitiveLengthMax(diskID)*mm-ygap;
717  const double zmax = _ftdLayer->getSensitiveWidth(diskID)*mm;
718 
719  bool isIn = true;
720  // Boundary set +- epsilon
721  if( (point.getX() > xmax+EPS*um) || (point.getX() < -EPS*um) )
722  {
723  streamlog_out(ERROR) << std::setprecision(3)
724  << " position out of sensor! X [um] = "
725  << point.getX()/um << " (Maximum x: " << xmax/um << ")" << std::endl;
726  isIn = false;
727  }
728 
729  if( (point.getY() > ymax+EPS*um) || (point.getY() < ygap-EPS*um) )
730  {
731  //FIXME: HAY UN PUNTO EN simHitFTD.slcio que sale del detector: investigar
732  streamlog_out(ERROR) << std::setprecision(3)
733  << " position out of sensor! Y [mm] = "
734  << point.getY()/mm << " (Maximum y: " << ymax/mm
735  << ", Minimum y:" << ygap/mm << ")" << std::endl;
736  isIn = false;
737  }
738 
739  if( (point.getZ() > zmax+EPS*um) || (point.getZ() < -EPS*um) )
740  {
741  streamlog_out(ERROR) << std::setprecision(3)
742  << " position out of sensor! Z [mm] = "
743  << point.getZ()/mm << " (Maximum z: " << zmax/mm << ")" << std::endl;
744  isIn = false;
745  }
746 
747  // Return if out or not
748  return isIn;
749 }
750 
751 
752 // OTHER METHODS - LOCAL REF. SYSTEM
753 
754 //
755 // Get info whether the given point is out of Si sensor (parameters: layerID,
756 // space point in local ref. system)
757 //
758 bool SiStripGeomFTD::isPointOutOfSensor(short int layerID, const CLHEP::Hep3Vector & point) const
759 {
760 
761  bool isOut = false;
762 
763  // Boundary set +- epsilon
764  double tanAlpha = (getSensorWidthMax(layerID) - getSensorWidthMin(layerID))
765  /2./getSensorLength(layerID);
766  double actualSensorWidth = (getSensorWidthMax(layerID) - 2*tanAlpha*point.getZ());
767 
768  // Recalculate point into "local" local system (width depends on posZ)
769  CLHEP::Hep3Vector recalcPoint(point.getX(), point.getY() -
770  getSensorWidthMax(layerID)/2. + actualSensorWidth/2., point.getZ());
771 
772  if( (recalcPoint.getX() > (getSensorThick(layerID) +EPS*um)) ||
773  (recalcPoint.getX() < (-EPS*um)) ||
774  (recalcPoint.getY() > (actualSensorWidth+EPS*um))
775  || (recalcPoint.getY() < (-EPS*um)) ||
776  (recalcPoint.getZ() > (getSensorLength(layerID)+EPS*um)) ||
777  (recalcPoint.getZ() < (-EPS*um)) )
778  {
779  isOut = true;
780  }
781 
782  // Return if out or not
783  return isOut;
784 }
785 
786 
787 //
788 // Get number of strips in sensors
789 //
790 int SiStripGeomFTD::getSensorNStrips(const int & diskID, const int & sensorID) const
791 {
792  std::vector<int> const * sensorNStrips = 0;
793 
794  if(sensorID == 1 || sensorID == 2)
795  {
796  sensorNStrips = &_sensorNStripsInFront;
797  }
798  else if(sensorID == 3 || sensorID == 4)
799  {
800  sensorNStrips = &_sensorNStripsInRear;
801  }
802  else
803  {
804  streamlog_out(ERROR) << "SiStripGeomFTD::getSensorNStrips "
805  << " - Inconsistent ID of sensor: '" << sensorID << "'" << std::endl;
806  exit(-1);
807  }
808 
809  if(sensorNStrips->size()>(unsigned short int)diskID)
810  {
811  return (*sensorNStrips)[diskID];
812  }
813  else
814  {
815  return 0;
816  }
817 }
818 
819 //
820 // Get strip ID for RPhi (perpendicular to the beam axis),
821 // points are given in local ref. system.
822 //
823 //NOTES: Necesitem la posRPhi per designar quin strip estic utilitzant,
824 // la pos Z es necesaria per definir a quina zona del trapezoide
825 // estem, recorda que la Pitch= Pitch(Z)
826 /*int SiStripGeomFTD::getStripIDInRPhi(short int diskID, double posRPhi, double posZ ) const
827 {
828  // Get pitch
829  double sensPitch = getSensorPitchInRPhi(diskID,posZ);
830  if(sensPitch == 0)
831  {
832  streamlog_out(ERROR) << "SiStripGeomFTD::getStripIDInRPhi "
833  << "- division by zero (sensPitch is zero)!!!"
834  << std::endl;
835  exit(-1);
836  }
837  // Get number of strips
838  int sensNStrips = getSensorNStripsInRPhi(diskID);
839 
840  int stripID;
841  // Calculate stripID
842  if(posRPhi <= 0.)
843  {
844  stripID = 0;
845  }
846  else
847  {
848  stripID = floor(posRPhi/sensPitch);
849  if(stripID >= sensNStrips)
850  {
851  stripID = sensNStrips - 1;
852  }
853  }
854  // Error
855  if(stripID >= sensNStrips)
856  {
857  streamlog_out(ERROR) << "SiStripGeom::getStripIDInRPhi "
858  << "- stripID in RPhi greater than number of strips!!!"
859  << std::endl;
860  exit(-1);
861  }
862 std::cout << " SiStripGeomFTD::getStripIDInRPhi" << std::endl;
863 std::cout << "----> " << posRPhi << std::endl;
864 std::cout << "----> " << sensPitch << std::endl;
865 std::cout << "----> " << sensNStrips << std::endl;
866 std::cout << "----> " << stripID << " (en zlocal=" << posZ << ")" << std::endl;
867 std::cout << "----> " << sensPitch*stripID << " (Y-position)" << std::endl;
868 std::cout << "END SiStripGeomFTD::getStripIDInRPhi" << std::endl;
869  return stripID;
870 }*/
871 //! Get director vector of a strip (inside the local Ref. system)
872 //! The vector is defined to describe the strip from z_local=0
873 CLHEP::Hep3Vector SiStripGeomFTD::getStripUnitVector(const int & diskID, const int & sensorID,
874  const int & stripID) const
875 {
876  // Extract y in z=0 and in z=L
877  const double yatz0 = getStripPosY(diskID,sensorID,stripID,0.0);
878  const double yatzL = getStripPosY(diskID,sensorID,stripID,getSensorLength(diskID));
879  // Defining positive u-component if yatz0 > Width/2.0
880  const double Dy = yatzL-yatz0;
881  const int u_sign = fabs(Dy)/Dy;
882 
883  const double alpha = fabs(atan(Dy/getSensorLength(diskID)));
884  //FIXME: Control that alpha<pi/2
885 
886  return CLHEP::Hep3Vector(0.0,((double)u_sign)*sin(alpha),cos(alpha));
887 }
888 
889 //
890 // Get the point crossing two strips. The returned point is placed in the middle
891 // of the Front sensor (x=getSensorThick/2.0)
892 //
893 CLHEP::Hep3Vector SiStripGeomFTD::getCrossLinePoint(const int & diskID, const int & petalID,
894  const int & stripIDFront, const int & stripIDRear) const
895 {
896  // Extract y in z=0 in front and rear
897  const double yatz0Front = getStripPosY(diskID,1,stripIDFront,0.0);
898  const double yatz0Rear = getStripPosY(diskID,3,stripIDRear,0.0);
899  // And putting them in the same reference system (the front ref. local system)
900  const double yatz0RearPrime = getSensorWidthMax(diskID)-yatz0Rear;
901 
902  // Director vectors of the strips
903  CLHEP::Hep3Vector uFront = getStripUnitVector(diskID,1,stripIDFront);
904  CLHEP::Hep3Vector uRear = getStripUnitVector(diskID,3,stripIDRear);
905  // Reference system front
906  uRear.rotateZ(-M_PI);
907 
908  // Strip line parametrized with t => r = (yatz0,0)+t(uz,uy)
909  const double extProd = uFront.getY()*uRear.getZ()-uFront.getZ()*uRear.getY();
910  const double tR = (yatz0RearPrime-yatz0Front)*uFront.getZ()/extProd;
911 
912  const double y = yatz0RearPrime+tR*uRear.getY();
913  const double z = tR*uRear.getZ();
914 
915  return CLHEP::Hep3Vector(getSensorThick(diskID)/2.0,y,z);
916 }
917 
918 //
919 // Get the stereo angle given a sensor
920 //
921 double SiStripGeomFTD::getStereoAngle(const int & diskID, const int & sensorID) const
922 {
923  // Stereo angle (if proceed)
924  double stAngle = 0.0;
925 
926  if(sensorID == 3 || sensorID == 4)
927  {
928  stAngle = 50e-3;
929  }
930 
931  return stAngle;
932 }
933 
934 //double SiStripGeomFTD::get
935 
936 
937 //
938 // Get strip ID, point is given in local ref. system
939 //
940 //
941 int SiStripGeomFTD::getStripID(const int & diskID, const int & sensorID,
942  const double & posRPhi, const double & posZ) const
943 {
944  //FIXME: BORRA
945  double zRot = 0.0;
946  double posRPhiRot=0.;
947  double yorigen=0.0;
948  // Get pitch
949  double sensPitch = getSensorPitch(diskID,sensorID,posZ);
950  if(sensPitch < 1e-40)
951  {
952  streamlog_out(ERROR) << "SiStripGeomFTD::getStripID "
953  << "- division by zero (sensPitch is zero)!!!"
954  << std::endl;
955  exit(-1);
956  }
957  // Get number of strips
958  int sensNStrips = getSensorNStrips(diskID,sensorID);
959 
960  int stripID;
961  // Calculate stripID
962  if(posRPhi <= 0.)
963  {
964  stripID = 0;
965  }
966  else
967  {
968  CLHEP::Hep3Vector pointRot = transformPointToRotatedLocal(diskID,sensorID,
969  CLHEP::Hep3Vector(0.0,posRPhi,posZ) );
970  posRPhiRot = pointRot.getY();
971  zRot = pointRot.getZ();
972  // Put the strip 0 in the edge of the petal (recall
973  // the y=0 of the local system begins in the long edge)
974  const double tanPhi = tan(_ftdLayer->getPhiHalfDistance(diskID));
975  yorigen = (getSensorLength(diskID)-pointRot.getZ())*tanPhi;
976 
977  stripID = floor((posRPhiRot-yorigen)/sensPitch);
978  if(stripID >= sensNStrips)
979  {
980  stripID = sensNStrips - 1;
981  }
982  }
983  // Error
984  if(stripID >= sensNStrips)
985  {
986  streamlog_out(ERROR) << "SiStripGeom::getStripID "
987  << "- stripID in RPhi greater than number of strips!!!"
988  << std::endl;
989  exit(-1);
990  }
991 
992 /*std::cout << "-----+ SiStripGeomFTD::getStripID" << std::endl;
993 std::cout << "----> Y =" << posRPhi << " (y/Pitch):" << (posRPhi-yorigen)/sensPitch << std::endl;
994 std::cout << "----> YRot =" << posRPhiRot << " (y/Pitch):" << (posRPhiRot-yorigen)/sensPitch << std::endl;
995 std::cout << "----> Pitch=" << sensPitch << std::endl;
996 std::cout << "----> Number Strips:" << sensNStrips << std::endl;
997 std::cout << "----> StripID:" << stripID << std::endl;
998 std::cout << "----> yOrigenRot:" << yorigen << std::endl;
999 std::cout << "----> zRot:" << zRot << std::endl;
1000 std::cout << "----> NS*sID=" << (yorigen+sensPitch*stripID) << " (Y-position)" << std::endl;
1001 std::cout << "-----+END SiStripGeomFTD::getStripIDInRPhi +------" << std::endl;*/
1002  return stripID;
1003 }
1004 
1005 // METHODS TO IDENTIFY
1006 
1007 //
1008 // Get sensor pitch for RPhi strips (perpendicular to the beam axis).
1009 // Currently it means the front face to the IP sensors of the petals.
1010 // The posZ is needed because the trapezoid shape of the sensors therefore pitch=pitch(Z)
1011 //
1012 /*double SiStripGeomFTD::getSensorPitchInRPhi(short int diskID, double posZ) const
1013 {
1014  if( (getLayerType(diskID) == strip) &&
1015  (_sensorPitchInFront.size() > (unsigned int)diskID) )
1016  {
1017  const double tanAlpha = tan(_ftdLayer->getPhiHalfDistance(diskID));
1018  if( (posZ*um>-EPS*um) && (posZ<(getSensorLength(diskID) + EPS*um)) ) //FIXME::::
1019  {
1020  return ((getSensorWidth(diskID) - 2.0*tanAlpha*posZ)
1021  /getSensorNStripsInRPhi(diskID));
1022  }
1023  else {
1024  std::cout << getSensorLength(diskID) << std::endl;
1025  std::cout << posZ << " -EPS:" << -EPS*um << " Cumple?: " << (posZ*um>-EPS*um) << std::endl;
1026  streamlog_out(ERROR)
1027  << std::setiosflags(std::ios::fixed | std::ios::internal )
1028  << std::setprecision(2)
1029  << "SiStripGeomFTD::getSensorPitchInRPhi - posZ: "
1030  << std::setw(4) << posZ << " out of range!!!"
1031  << std::resetiosflags(std::ios::showpos)
1032  << std::setprecision(0)
1033  << std::endl;
1034  exit(0);;
1035  }
1036  }
1037  else
1038  {
1039  return 0.;
1040  }
1041 }*/
1042 
1043 
1044 //
1045 // Get sensor pitch
1046 // The posZ is needed because the trapezoid shape of the sensors therefore pitch=pitch(Z)
1047 // The posZ is in the local ref. system
1048 //
1049 double SiStripGeomFTD::getSensorPitch(const int & diskID, const int & sensorID,
1050  const double & posZ) const
1051 {
1052  if( (posZ < -EPS*um) && (posZ > (getSensorLength(diskID) + EPS*um)) )
1053  {
1054  streamlog_out(ERROR)
1055  << std::setiosflags(std::ios::fixed | std::ios::internal )
1056  << std::setprecision(2)
1057  << "SiStripGeomFTD::getSensorPitch - posZ: "
1058  << std::setw(4) << posZ << " out of range!!!"
1059  << std::resetiosflags(std::ios::showpos)
1060  << std::setprecision(0)
1061  << std::endl;
1062  exit(0);
1063  }
1064 
1065  // Changing reference system: rotate the petal in its centroid point
1066  // to obtain the strips with the stereo angle
1067  const double tanPhi = tan(_ftdLayer->getPhiHalfDistance(diskID));
1068  CLHEP::Hep3Vector point = transformPointToRotatedLocal( diskID, sensorID,
1069  CLHEP::Hep3Vector(0.,0.0,posZ) );
1070 
1071  // Now we can deal the petal in the usual way.
1072  const double width_z = 2.0*(getSensorLength(diskID)-point.getZ())*tanPhi;
1073 
1074  double totalwidth = getSensorWidthMax(diskID);
1075 
1076  return ((totalwidth-width_z)/getSensorNStrips(diskID,sensorID));
1077 }
1078 
1079 //
1080 // Get the Y position (in the local ref. frame) for the given strip, posZ
1081 // is the point in the local reference system of the petal
1082 //
1083 double SiStripGeomFTD::getStripPosY(const int & diskID, const int & sensorID,
1084  const int & stripID, const double & posZ) const
1085 {
1086  // Can't be stripID = 0
1087  if(stripID <= 0)
1088  {
1089  streamlog_out(ERROR) << "SoStripGeomFTD::getStripPosY "
1090  << "- incoherent stripID=" << stripID << "!!"
1091  << std::endl;
1092  exit(-1);
1093  }
1094 
1095  // Extract zPos position in the local rotated frame (if proceed)
1096  const double zPosPrime = transformPointToRotatedLocal( diskID,
1097  sensorID, CLHEP::Hep3Vector(0.0,0.0,posZ) ).getZ();
1098  // Extract origen of the sensitive part
1099  const double tanPhi = tan(_ftdLayer->getPhiHalfDistance(diskID));
1100  const double yorigen = (getSensorLength(diskID)-zPosPrime)*tanPhi;
1101 
1102  // Get pitch (da el pitch teniendo en cuenta lo que tiene que tener)
1103  double sensPitch = getSensorPitch(diskID,sensorID,posZ);
1104  if(sensPitch < 1e-40)
1105  {
1106  streamlog_out(ERROR) << "SiStripGeomFTD::getStripPosY "
1107  << "- division by zero (sensPitch is zero)!!!"
1108  << std::endl;
1109  exit(-1);
1110  }
1111 
1112  // Calculate position (Center of the strip)
1113  double posRPhi = yorigen+sensPitch*(stripID + 0.5);
1114  // Error
1115  if ( (posRPhi<0.) || (posRPhi>getSensorWidthMax(diskID)) )
1116  {
1117  streamlog_out(ERROR)
1118  << "SiStripGeomFTD::getStripPosY - position out of sensor!!!"
1119  << std::endl;
1120  exit(-1);
1121  }
1122 
1123  // Return R-Phi position of given strip in local ref. system
1124  CLHEP::Hep3Vector pointInSRL = transformPointFromRotatedLocal(diskID,
1125  sensorID,CLHEP::Hep3Vector(0.0,posRPhi,zPosPrime));
1126 
1127  return pointInSRL.getY();
1128 }
1129 
1130 //
1131 // Transforming a given point to the local ref. frame of a petal which is rotated
1132 // around its center an angle stAngle
1133 //
1134 
1135 CLHEP::Hep3Vector SiStripGeomFTD::transformPointToRotatedLocal(const int & diskID,
1136  const int & sensorID, const CLHEP::Hep3Vector & point) const
1137 {
1138  CLHEP::Hep3Vector pointPrime(point);
1139 
1140  const double stAngle = getStereoAngle(diskID,sensorID);
1141 
1142  // Changing reference system: rotate the petal in its centroid point
1143  // to obtain the strips with the stereo angle
1144  double ycentre = getSensorWidthMax(diskID)/2.0;
1145  const double zcentre = getSensorLength(diskID)/2.0;
1146 
1147  // The centre of the rotation
1148  CLHEP::Hep3Vector rotcentre(0.0,ycentre,zcentre);
1149  // Translating Zpos to the new ref. system
1150  pointPrime -= rotcentre;
1151 
1152  // Now we have the hit point from the system placed in the centre
1153  // of the sensor and rotated the stereo angle
1154 
1155  // We need to return to the local ref. frame (defined along this code)
1156  // placed in a petal 'rotated'
1157  rotcentre.rotateX(-stAngle);
1158  // And extract the point in that system
1159  pointPrime += rotcentre;
1160 
1161  // Rotating the vector to the new coordinate system--->NOOO
1162  //pointPrime.rotateX(-stAngle);
1163  // Consistency Check
1164  /*CLHEP::Hep3Vector Orig(0.,0.,0.);
1165  Orig = CLHEP::Hep3Vector(0.0,ycentre,zcentre)-rotcentre;
1166  std::cout << "To-- pointPrime+O =? P :" << pointPrime + Orig << " =? " << point << std::endl;*/
1167 
1168  return pointPrime;
1169 }
1170 
1171 //
1172 // Inverse transformation of transformPointToRotatedLocal (see this function)
1173 //
1174 
1175 CLHEP::Hep3Vector SiStripGeomFTD::transformPointFromRotatedLocal(const int & diskID,
1176  const int & sensorID, const CLHEP::Hep3Vector & pointPrime) const
1177 {
1178  CLHEP::Hep3Vector point(pointPrime);
1179 
1180  const double stAngle = getStereoAngle(diskID,sensorID);
1181 
1182  // center of the petal
1183  double ycentre = getSensorWidthMax(diskID)/2.0;
1184  const double zcentre = getSensorLength(diskID)/2.0;
1185 
1186  CLHEP::Hep3Vector rotcentre(0.0,ycentre,zcentre);
1187  rotcentre.rotateX(-stAngle);
1188 
1189  // Positioning in the center of the rotating frame
1190  point -= rotcentre;
1191 
1192  // And positioning in the origin
1193  point += CLHEP::Hep3Vector(0.0,ycentre,zcentre);
1194 
1195 /* // Consistency Check
1196  CLHEP::Hep3Vector Orig(0.,0.,0.);
1197  Orig = CLHEP::Hep3Vector(0.0,ycentre,zcentre)-rotcentre;
1198  std::cout << " pointPrime+O =? P :" << pointPrime + Orig << " =? " << point << std::endl;*/
1199 
1200  return point;
1201 }
1202 
1203 // PRINT METHODS
1204 
1205 //
1206 // Method printing general Gear parameters
1207 //
1208 
1210 {
1211  streamlog_out(MESSAGE3) << std::endl
1212  << " "
1213  << DUNDERL
1214  << DBLUE
1215  << "Gear parameters:"
1216  << ENDCOLOR
1217  << " "
1218  << std::endl << std::endl;
1219 
1220  // Gear type: BField
1221  streamlog_out(MESSAGE3) << " B field [T]: "
1222  << _magField/T
1223  << std::endl << std::endl;
1224 
1225  // Gear type: VXD
1226  if (_gearType == "VXD") {
1227 
1228  // Print general info
1229  for (int i=0; i<_numberOfLayers; ++i){
1230 
1231  streamlog_out(MESSAGE2) << std::endl;
1232  streamlog_out(MESSAGE2) << " Layer: " << _layerRealID[i] << std::endl;
1233  if (_layerType[i]==pixel) {
1234  streamlog_out(MESSAGE2) << " LayerType: " << "pixel" << std::endl;
1235  }
1236  else {
1237  streamlog_out(MESSAGE2) << " LayerType: " << "strip" << std::endl;
1238  }
1239  streamlog_out(MESSAGE2) << " NumberOfLadders: " << _numberOfLadders[i] << std::endl;
1240  streamlog_out(MESSAGE2) << " Radius[mm]: " << _layerRadius[i]/mm << std::endl;
1241  streamlog_out(MESSAGE2) << " Width[mm]: " << _ladderWidth[i]/mm << std::endl;
1242  streamlog_out(MESSAGE2) << " Length[mm]: " << _ladderLength[i]/mm << std::endl;
1243  streamlog_out(MESSAGE2) << " Petal SemiAngle: " << _layerHalfPhi[i] << std::endl;
1244  streamlog_out(MESSAGE2) << " Phi0: " << _layerPhi0[i] << std::endl;
1245  streamlog_out(MESSAGE2) << " Theta: " << _layerTheta[i] << std::endl;
1246  streamlog_out(MESSAGE2) << " OffsetY[mm]: " << _ladderOffsetY[i]/mm << std::endl;
1247  // streamlog_out(MESSAGE2) << " OffsetZ[mm]: " << _ladderOffsetZ[i]/mm << std::endl; OUT//
1248  }
1249 
1250  }
1251  // Gear type: unknown - error
1252  else {
1253  streamlog_out(ERROR) << "Unknown gear type!"
1254  << std::endl;
1255 
1256  exit(0);
1257  }
1258 }
1259 //
1260 // Method printing sensor Gear parameters (parameters: sensorID)
1261 //
1262 void SiStripGeomFTD::printSensorParams(short int layerID) const
1263 {
1264  // Print sensor parameters
1265  streamlog_out(MESSAGE2) << " * Parameters: " << _sensorThick[layerID]/um << "um thick, "
1266  << "with " << _sensorPitchInRear[layerID]/um << "um pitch "
1267  << "and " << _sensorNStripsInRear[layerID] << " strips in Z"
1268  << ", resp. " << _sensorPitchInFront[layerID]/um << "um pitch "
1269  << "and " << _sensorNStripsInFront[layerID] << " strips in R-Phi."
1270  << std::endl;
1271 }
1272 
1273 } // Namespace;
1274 
std::vector< double > _sensorWidth
Definition: SiStripGeom.h:309
static const float mm
virtual double getSensorThick(short int layerID) const
Get sensor thickness.
Definition: SiStripGeom.cc:421
virtual double getLadderPhi(short int layerID, short int ladderID) const
Get ladder rotation - phi angle.
Definition: SiStripGeom.cc:333
virtual ~SiStripGeomFTD()
Destructor.
std::vector< int > _sensorNStripsInRear
Definition: SiStripGeom.h:305
std::vector< double > _ladderOffsetZ
Definition: SiStripGeom.h:300
static const float um
std::vector< double > _ladderThick
Definition: SiStripGeom.h:296
#define DBLUE
Definition: Colours.h:16
virtual bool isPointOutOfSensor(short int layerID, const CLHEP::Hep3Vector &point) const
Get info whether the given point is out of Si sensor (parameters: layerID, space point in local ref...
std::vector< int > _numberOfLadders
Definition: SiStripGeom.h:288
CLHEP::Hep3Vector Vector3D
virtual int cellID0withSensor0(const int &cellID0) const
Returns the input cellID0 where the field sensor is put to 0.
gear::FTDLayerLayout * _ftdLayer
double getLadderOffsetX(const short int &layerID) const
virtual double getSensorLength(short int layerID) const
Get sensor length.
Definition: SiStripGeom.cc:467
CLHEP::Hep3Vector _magField
Definition: SiStripGeom.h:270
std::vector< double > _layerHalfPhi
Definition: SiStripGeom.h:275
virtual double getLadderTheta(short int diskID) const
Method impossed by consistent with the mother class.
#define ENDCOLOR
Definition: Colours.h:21
Gear geometry class - holds all geometry information about silicon strip sensors. ...
Definition: SiStripGeom.h:59
std::vector< int > _layerRealID
Definition: SiStripGeom.h:281
virtual CLHEP::Hep3Vector transformPointToGlobal(short int layerID, short int ladderID, short int sensorID, const CLHEP::Hep3Vector &point)
Transform given point from local ref. system (sensor) to global ref. system.
virtual short int getLayerIDCTypeNo(int realLayerID) const
Transform real layer ID to C-type numbering 0 - n ...
Definition: SiStripGeom.cc:142
std::vector< double > _ladderOffsetY
Definition: SiStripGeom.h:299
virtual double getSensorWidthMin(short int layerID) const
Get sensor width 2 (the narrower one for forward-type sensors)
Definition: SiStripGeom.cc:452
virtual CLHEP::Hep3Vector getCrossLinePoint(const int &diskID, const int &sensorID, const int &stripIDFront, const int &stripIDRear) const
Get the point which crosses two strips.
virtual double getSensorPitch(const int &diskID, const int &sensorID, const double &posZ) const
Get sensor pitch for strips in the local ref.
std::vector< double > _sensorPitchInRear
Definition: SiStripGeom.h:307
virtual CLHEP::Hep3Vector transformVecToGlobal(short int layerID, short int ladderID, short int sensorID, const CLHEP::Hep3Vector &vec)
Transform given vector from local ref. system (sensor) to global ref. system.
virtual CLHEP::HepMatrix transformMatxToGlobal(short int layerID, short int ladderID, const CLHEP::HepMatrix &matrix)
Transform given diagonal matrix from local ref. system (sensor) to global ref. system.
std::vector< double > _layerTheta
Definition: SiStripGeom.h:285
std::vector< int > _layerType
Definition: SiStripGeom.h:282
std::vector< double > _sensorThick
Definition: SiStripGeom.h:308
#define DUNDERL
Definition: Colours.h:20
virtual std::pair< StripType, int > decodeStripID(const int &encodedStripID) const
Method to extract strip and strip type (cellID1)
double getStereoAngle(const int &diskID, const int &sensorID) const
Get the stereo angle of the strips.
virtual bool isPointInsideSensor(short int layerID, short int ladderID, short int sensorID, const CLHEP::Hep3Vector &point) const
Get info whether the given point is inside of Si sensor.
static const float T
std::vector< double > _layerZ
Definition: SiStripGeom.h:279
virtual CLHEP::Hep3Vector transformVecToLocal(short int layerID, short int ladderID, short int sensorID, const CLHEP::Hep3Vector &vec)
Transform given vector from global ref. system to local ref. system (sensor)
std::vector< double > _ladderLength
Definition: SiStripGeom.h:298
std::vector< double > _ladderZOffsetSign0
virtual CLHEP::HepMatrix transformMatxToLocal(short int layerID, short int ladderID, const CLHEP::HepMatrix &matrix)
Transform given matrix from global ref. system to local ref. system (sensor)
short int _numberOfLayers
Definition: SiStripGeom.h:273
#define EPS
Definition: SiStripGeom.h:27
std::vector< int > _sensorNStripsInFront
Definition: SiStripGeom.h:304
virtual CLHEP::Hep3Vector transformPointToRotatedLocal(const int &diskID, const int &sensorID, const CLHEP::Hep3Vector &point) const
Transforming a given point to the local ref.
std::vector< double > _sensorWidth2
Definition: SiStripGeom.h:310
static const float e
virtual double getStripPosY(const int &diskID, const int &sensorID, const int &stripID, const double &posZ) const
Get Y-centered position in the local ref. system for the stripID.
std::vector< double > _ladderWidth
Definition: SiStripGeom.h:297
SiStripGeomFTD(const std::string &, const double &pitchFront, const double &pitchRear)
Constructor.
virtual void updateCanonicalCellID(const int &cellID, const int &stripType, const int &stripID, UTIL::BitField64 *bf)
Stores the cellID0 and cellID1 of the LCIO object to the file.
std::vector< double > _layerRadius
Definition: SiStripGeom.h:278
virtual void printGearParams() const
Method printing general Gear parameters.
std::vector< double > _sensorPitchInFront
Definition: SiStripGeom.h:306
virtual std::map< std::string, int > decodeCellID(const UTIL::BitField64 &cellID) const
Method to extract codification ID,.
virtual int getStripID(const int &diskID, const int &sensorID, const double &posRPhi, const double &posZ) const
Get strip ID (in Phi), points are given in local ref.
virtual CLHEP::Hep3Vector transformPointFromRotatedLocal(const int &diskID, const int &sensorID, const CLHEP::Hep3Vector &point) const
Transforming a given point from the reference system rotated around the center of a petal to its loca...
std::vector< double > _layerPetalOpAngle
gear::FTDParameters * _ftdParams
std::vector< double > _sensorLength
Definition: SiStripGeom.h:311
virtual void printSensorParams(short int layerID) const
Method printing sensor Gear parameters.
virtual int getSensorNStrips(const int &diskID, const int &sensorID) const
Get number of strips per sensor.
virtual int getLayerRealID(short int layerID) const
Get layer real ID.
Definition: SiStripGeom.cc:123
virtual double getSensorWidthMax(short int layerID) const
Get sensor width (the wider one for forward-type sensors)
Definition: SiStripGeom.cc:435
std::vector< double > _layerPhi0
Definition: SiStripGeom.h:284
virtual void initGearParams()
Method initializing class - reads Gear parameters from XML file.
virtual CLHEP::Hep3Vector getStripUnitVector(const int &diskID, const int &sensorID, const int &stripID) const
Get director vector of a strip (inside the local Ref.
virtual CLHEP::Hep3Vector transformPointToLocal(short int layerID, short int ladderID, short int sensorID, const CLHEP::Hep3Vector &point)
Transform given point from global ref. system to local ref. system (sensor)
std::vector< double > _layerOuterRadius
std::string _gearType
Definition: SiStripGeom.h:267