StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StETofGeometry.h
1 /***************************************************************************
2  *
3  * $Id: StETofGeometry.h,v 1.4 2019/12/10 16:03:43 fseck Exp $
4  *
5  * Author: Florian Seck, April 2018
6  ***************************************************************************
7  *
8  * Description: Collection of geometry classes for the eTOF:
9  * - StETofNode: generic eTOF geometry object initialized via
10  * TGeoManager
11  * - StETofGeomModule, StETofGeomCounter inherit from StETofNode
12  * - StETofGeometry builds the geometry and features all
13  * necessary methods to match track helices with eTOF hits
14  *
15  ***************************************************************************
16  *
17  * $Log: StETofGeometry.h,v $
18  * Revision 1.4 2019/12/10 16:03:43 fseck
19  * added handling of StPicoHelix in extrapolation & step-wise extrapolation in changing magnetic field
20  *
21  * Revision 1.3 2019/04/23 23:49:08 fseck
22  * added support for StPicoHelix
23  *
24  * Revision 1.2 2019/02/19 20:20:11 fseck
25  * update after second part of eTOF code review
26  *
27  * Revision 1.1 2018/07/25 14:34:40 jeromel
28  * First version, reviewed Raghav+Jerome
29  *
30  *
31  ***************************************************************************/
32 #ifndef STETOFGEOMETRY_H
33 #define STETOFGEOMETRY_H
34 
35 #include <vector>
36 #include <string>
37 
38 #include "TGeoManager.h"
39 
40 #include "StThreeVectorD.hh"
41 #include "StHelixD.hh"
42 #include "StPhysicalHelixD.hh"
43 
44 #include "TVector3.h"
45 #include "StPicoEvent/StPicoPhysicalHelix.h"
46 #include "StPicoEvent/StPicoHelix.h"
47 
48 #include "StETofUtil/StETofConstants.h"
49 
50 class TNamed;
51 
52 class StETofHit;
53 class StMuETofHit;
54 class StPicoETofHit;
55 
56 class StETofGeomCounter;
57 class StarMagField;
58 
59 
61 //
62 // StETofNode
63 // ==========
64 //
66 class StETofNode : public TObject {
67 
68 public:
69  StETofNode() {}
70  ~StETofNode() {}
71 
72  StETofNode( const TGeoPhysicalNode& gpNode );
73  StETofNode( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const StThreeVectorD alignment );
74 
75  void convertPos( StETofNode* from, const double* pos_from, StETofNode* to, double* pos_to );
76 
77  void local2Master( const double* local, double* master );
78  void master2Local( const double* master, double* local );
79 
80  bool isLocalPointIn( const double* local );
81  bool isGlobalPointIn( const StThreeVectorD& global );
82  bool isGlobalPointIn( const TVector3& global );
83 
84  void buildMembers(); // function to fill member variables like center position, min/max eta or phi of the node
85 
86  double calcPhi( const double& rel_local_y, const double& rel_local_x );
87  double calcEta( const double& rel_local_x );
88 
89  StThreeVectorD calcCenterPos();
90  StThreeVectorD calcXYPlaneNormal();
91 
92  bool helixCross( const StHelixD& helix, double& pathLength, StThreeVectorD& cross, double& theta );
93  bool helixCross( const StPicoHelix& helix, double& pathLength, TVector3& cross, double& theta );
94 
95  TGeoHMatrix* geoMatrix() const;
96  TGeoBBox* box() const;
97  double phiMin() const;
98  double phiMax() const;
99  double etaMin() const;
100  double etaMax() const;
101  StThreeVectorD centerPos() const;
102  StThreeVectorD xyPlaneNormal() const;
103 
104  void setSafetyMargins( const double* margins );
105  double safetyMarginX() const;
106  double safetyMarginY() const;
107 
108  void debugOn();
109  void debugOff();
110  bool isDebugOn() const;
111 
112  virtual void print( const Option_t* opt = "" ) const;
113 
114 private:
115  TGeoHMatrix* mGeoMatrix; // 4x4 matrix containing the rotation matrix (3x3) and the translation vector
116  TGeoBBox* mBox; // shape (bounding box) of the node
117  double mPhiMin; // minimal phi at lower edge of node (closest to beamline) from -pi to pi
118  double mPhiMax; // maximal phi -- " --
119  double mEtaMin;
120  double mEtaMax;
121  StThreeVectorD mCenter;
122  StThreeVectorD mNormal;
123  double mSafetyMarginX;
124  double mSafetyMarginY;
125 
126  bool mDebug; // control message printing of this class
127 
128  ClassDef( StETofNode, 1 )
129 };
130 
131 
132 inline TGeoHMatrix* StETofNode::geoMatrix() const { return mGeoMatrix; }
133 inline TGeoBBox* StETofNode::box() const { return mBox; }
134 
135 inline double StETofNode::phiMin() const { return mPhiMin; }
136 inline double StETofNode::phiMax() const { return mPhiMax; }
137 inline double StETofNode::etaMin() const { return mEtaMin; }
138 inline double StETofNode::etaMax() const { return mEtaMax; }
139 
140 inline StThreeVectorD StETofNode::centerPos() const { return mCenter; }
141 inline StThreeVectorD StETofNode::xyPlaneNormal() const { return mNormal; }
142 
143 inline double StETofNode::safetyMarginX() const { return mSafetyMarginX; };
144 inline double StETofNode::safetyMarginY() const { return mSafetyMarginY; };
145 
146 
147 inline void StETofNode::debugOn() { mDebug = true; }
148 inline void StETofNode::debugOff() { mDebug = false; }
149 
150 inline bool StETofNode::isDebugOn() const { return mDebug; }
151 
152 
154 //
155 // StETofGeomModule
156 // ================
157 //
159 class StETofGeomModule : public StETofNode {
160 
161 public:
162  StETofGeomModule() {}
163  ~StETofGeomModule() {}
164 
165  StETofGeomModule( const TGeoPhysicalNode& gpNode, const int moduleId );
166 
167  void addCounter( const TGeoPhysicalNode& gpNode, const int moduleId, const int counterId );
168  void addCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId );
169  void addCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId, const double* safetyMargins, const StThreeVectorD alignment );
170 
171  StETofGeomCounter* counter( const unsigned int i ) const;
172 
173  void clearCounters();
174 
175  int numberOfCounters() const;
176 
177  int calcSector( const int moduleId );
178  int calcPlane( const int moduleId );
179 
180 
181  int moduleIndex() const;
182  int sector() const;
183  int plane() const;
184 
185  void debugOn();
186  void debugOff();
187  bool isDebugOn() const;
188 
189  virtual void print( const Option_t* opt="" ) const;
190 
191 private:
192  int mModuleIndex; // module index number (0-35)
193  int mSector; // sector (13-24)
194  int mPlane; // z-plane (1-3)
195 
196  std::vector< StETofGeomCounter* > mETofCounter;
197 
198  bool mDebug; // control message printing of this class
199 
200 
201  ClassDef( StETofGeomModule, 1 )
202 };
203 
204 
205 inline int StETofGeomModule::numberOfCounters() const { return mETofCounter.size(); }
206 inline int StETofGeomModule::moduleIndex() const { return mModuleIndex; }
207 inline int StETofGeomModule::sector() const { return mSector; }
208 inline int StETofGeomModule::plane() const { return mPlane; }
209 
210 inline void StETofGeomModule::debugOn() { mDebug = true; }
211 inline void StETofGeomModule::debugOff() { mDebug = false; }
212 
213 inline bool StETofGeomModule::isDebugOn() const { return mDebug; }
214 
215 
217 //
218 // StETofGeomCounter
219 // =================
220 //
223 
224 public:
225  StETofGeomCounter() {}
226  ~StETofGeomCounter() {}
227 
228  StETofGeomCounter( const TGeoPhysicalNode& gpNode, const int moduleId, const int counterId );
229  StETofGeomCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId, const StThreeVectorD alignment );
230  void createGeomStrips();
231 
232  int findStrip( const double* local );
233 
234 
235  int calcSector( const int moduleId );
236  int calcPlane( const int moduleId );
237 
238 
239  int moduleIndex() const;
240  int sector() const;
241  int plane() const;
242  int counterIndex() const;
243 
244  void debugOn();
245  void debugOff();
246  bool isDebugOn() const;
247 
248  virtual void print( const Option_t *opt="" ) const;
249 
250 private:
251  int mModuleIndex; // module index number (0-35)
252  int mSector; // sector (13-24)
253  int mPlane; // z-plane (1-3)
254  int mCounterIndex; // counter index (0-2)
255 
256  float mStripX[ eTofConst::nStrips + 1 ]; // X range of strips
257 
258  bool mDebug; // control message printing of this class
259 
260 
261  ClassDef( StETofGeomCounter, 1 )
262 };
263 
264 inline int StETofGeomCounter::moduleIndex() const { return mModuleIndex; }
265 inline int StETofGeomCounter::sector() const { return mSector; }
266 inline int StETofGeomCounter::plane() const { return mPlane; }
267 inline int StETofGeomCounter::counterIndex() const { return mCounterIndex; }
268 
269 inline void StETofGeomCounter::debugOn() { mDebug = true; }
270 inline void StETofGeomCounter::debugOff() { mDebug = false; }
271 
272 inline bool StETofGeomCounter::isDebugOn() const { return mDebug; }
273 
274 
275 
277 //
278 // StETofGeometry
279 // ==============
280 //
282 class StETofGeometry : public TNamed {
283 
284 public:
285  StETofGeometry( const char* name = "etofGeo", const char* title = "simplified ETOF Geometry" );
286  ~StETofGeometry();
287 
288  void init( TGeoManager* geoManager, const double* safetyMargins = 0, const bool useHelixSwimmer = false );
289 
290  void reset();
291 
292  bool isInitDone() const;
293  bool setInitFlag( const bool initFlag );
294 
295  std::string formTGeoPath( const TGeoManager* geoManager, int plane, int sector, int counter = -1 );
296  std::string formTGeoPath( const TGeoManager* geoManager, int plane, int sector, int counter, int gap );
297 
298  int calcModuleIndex( const int& sector, const int& plane );
299  int calcVolumeIndex( const int& sector, const int& plane, const int& counter, const int& strip );
300 
301  void decodeVolumeIndex( const int& volumeId, int& sector, int& plane, int& counter, int& strip );
302 
303  StETofNode* findETofNode( const int moduleId, const int counter );
304 
305  void pointMaster2local( const int moduleId, const int counterId, const double* master, double* local );
306  void hitLocal2Master( const int moduleId, const int counter, const double* local, double* master );
307  StThreeVectorD hitLocal2Master( StETofHit* hit );
308  StThreeVectorD hitLocal2Master( StMuETofHit* hit );
309  TVector3 hitLocal2Master( StPicoETofHit* hit );
310 
311 
312 
313  std::vector< int > sectorAtPhi( const double& angle );
314 
315  //--------------------------------------------------------------------
316  // for the use in the MatchMaker or in running over StEvent/MuDst input
317  StThreeVectorD helixCrossETofPlane( const StHelixD& helix );
318  StThreeVectorD helixCrossPlane( const StHelixD& helix, const double& z );
319 
320  void helixSwimmer( const StPhysicalHelixD& helix, StPhysicalHelixD& swimmerHelix, const double& z, double& pathlength );
321 
322  std::vector< int > helixCrossSector( const StHelixD& helix );
323 
324  void helixCrossCounter( const StPhysicalHelixD& helix, std::vector< int >& idVec, std::vector< StThreeVectorD >& crossVec,
325  std::vector< StThreeVectorD >& localVec, std::vector< double >& thetaVec, std::vector< double >& pathLenVec );
326 
327  void logPoint( const char* text, const StThreeVectorD& point );
328  //--------------------------------------------------------------------
329 
330  //--------------------------------------------------------------------
331  // for the use in running over picoDst input
332  TVector3 helixCrossETofPlane( const StPicoHelix& helix );
333  TVector3 helixCrossPlane( const StPicoHelix& helix, const double& z );
334 
335  void helixSwimmer( const StPicoPhysicalHelix& helix, StPicoPhysicalHelix& swimmerHelix, const double& z, double& pathlength );
336 
337  std::vector< int > helixCrossSector( const StPicoHelix& helix );
338 
339  void helixCrossCounter( const StPicoPhysicalHelix& helix, std::vector< int >& idVec, std::vector< TVector3 >& crossVec,
340  std::vector< TVector3 >& localVec, std::vector< double >& thetaVec );
341 
342  void logPoint( const char* text, const TVector3& point );
343  //--------------------------------------------------------------------
344 
345 
346  //--------------------------------------------------------------------
347  // magnetic field related functions
348  StThreeVectorD getField( const StThreeVectorD& pos );
349  TVector3 getField( const TVector3& pos );
350 
351  double getFieldZ( const StThreeVectorD& pos );
352  double getFieldZ( const TVector3& pos );
353  double getFieldZ( const double& x, const double& y, const double& z );
354  //--------------------------------------------------------------------
355 
356 
357  StETofGeomModule* module( const unsigned int i );
358  unsigned int nValidModules() const;
359 
360  void readAlignmentParameters();
361  void readAlignmentDatabase();
362  void setFileNameAlignParam(std::string FileNameAlignParam);
363 
364  void debugOn();
365  void debugOff();
366  bool isDebugOn() const;
367 
368 
369 private:
370  StETofGeomModule* mETofModule[ eTofConst::nModules ];
371 
372  unsigned int mNValidModules; // amount of loaded modules
373  bool mInitFlag; // flag of initialization, true if done
374  bool mDebug; // control message printing of this class
375 
376  StarMagField* mStarBField;
377 
378  std::string mFileNameAlignParam;
379  std::vector<StThreeVectorD> mAlignmentParameters;
380 
381  ClassDef( StETofGeometry, 1 )
382 };
383 
384 
385 inline bool StETofGeometry::isInitDone() const { return mInitFlag; }
386 inline unsigned int StETofGeometry::nValidModules() const { return mNValidModules; }
387 
388 inline bool StETofGeometry::setInitFlag( const bool initFlag ) { return mInitFlag = initFlag; }
389 
390 
391 inline void StETofGeometry::debugOn() { mDebug = true; }
392 inline void StETofGeometry::debugOff() { mDebug = false; }
393 
394 inline bool StETofGeometry::isDebugOn() const { return mDebug; }
395 inline void StETofGeometry::setFileNameAlignParam(std::string fileNameAlignParam) {mFileNameAlignParam = fileNameAlignParam;}
396 
397 
398 #endif
void helixCrossCounter(const StPhysicalHelixD &helix, std::vector< int > &idVec, std::vector< StThreeVectorD > &crossVec, std::vector< StThreeVectorD > &localVec, std::vector< double > &thetaVec, std::vector< double > &pathLenVec)
std::string formTGeoPath(const TGeoManager *geoManager, int plane, int sector, int counter=-1)
std::vector< int > helixCrossSector(const StHelixD &helix)
Helis parametrization for the particle.
Stores eTOF hit information.
Definition: StPicoETofHit.h:19
Helix parametrization that uses ROOT TVector3.
Definition: StPicoHelix.h:38