StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StTofrGeometry.h
1 /*******************************************************************
2  *
3  * $Id: StTofrGeometry.h,v 1.10 2018/02/26 23:27:02 smirnovd Exp $
4  *
5  * Authors: Shuwei Ye, Xin Dong
6  *******************************************************************
7  *
8  * Description: Collection of geometry classes for the TOF-MRPC
9  * initializes from GEANT geometry
10  *
11  *******************************************************************/
12 #ifndef STTOFRGEOMETRY_H
13 #define STTOFRGEOMETRY_H
14 
16 // //
17 // group of classes for Tofr Geometry: //
18 // //
19 // StTofrGeometry(v1), StTofNode(v2), StTofrGeomNode(v2)(off) //
20 // StTofrGeomTray(v1), StTofrGeomSensor(v2), StTofrGeomCell(off) //
21 // //
22 // Usage: //
23 // StTofrGeometry* geo = new StTofrGeometry("tofr","tofr geometry"); //
24 // geo->Init(TVolume *starHall, const Int_t TofrConf); //
25 // //
27 #include "TObject.h"
28 #include "TList.h"
29 #include "TNode.h"
30 #include "TBRIK.h"
31 #include "TGeometry.h"
32 #include "StThreeVectorD.hh"
33 #include "StHelixD.hh"
34 #include "TVolume.h"
35 #include "TVolumePosition.h"
36 #include "TVolumeView.h"
37 #include "TVolumeViewIter.h"
38 
39 #include <vector>
40 #ifndef ST_NO_NAMESPACES
41 using std::vector;
42 #endif
43 #ifndef __CINT__
44 #if !defined(ST_NO_TEMPLATE_DEF_ARGS)
45 typedef vector<Int_t> IntVec;
46 typedef vector<Double_t> DoubleVec;
47 typedef vector<StThreeVector<double> > PointVec;
48 #else
49 typedef vector<Int_t, allocator<Int_t> > IntVec;
50 typedef vector<Double_t, allocator<Double_t> > DoubleVec;
51 typedef vector<StThreeVector<double>, allocator<StThreeVector<double>>> PointVec;
52 #endif
53 #endif
54 class StTofrNode;
55 class StTofrGeomNode;
56 class StTofrGeomTray;
57 class StTofrGeomSensor;
58 // class StTofrGeomCell;
59 class StTofrGeometry;
60 
61 
63 //
64 // StTofrGeomNode
65 // ==============
66 //
68 
69 #if 0
70 class StTofrGeomNode : public TNode {
71  protected:
72  Double_t mTransMRS[3]; //Translate vector in MRS
73  Double_t mRotMRS[9]; //RotateMatrix from MRS to this
74  Bool_t mTransFlag; //Flag, kTRUE=if translation/matrix updated
75  // Double_t mCenterRxy; //center position R(xy) in MRS
76  // Double_t mCenterEta; //center position Eta in MRS
77  // Double_t mCenterPhi; //center position Phi in MRS
78  Double_t mEtaMin; //minimum covered Eta in MRS
79  Double_t mEtaMax; //maximum covered Eta in MRS
80  Double_t mPhiMin; //minimum covered Phi in MRS
81  Double_t mPhiMax; //maximum covered Phi in MRS
82  // Bool_t mMatrixUpdated; //is TNode::fRotMatrix updated
83 
84  static Bool_t mDebug;
85 
86  protected:
87  StTofrGeomNode(const char* name, const char* title, TBRIK* brik,
88  const Double_t x, const Double_t y, const Double_t z,
89  TRotMatrix* matrix=0);
90  void UpdateMatrix();
91  void BuildMembers();
92 
93  public:
94  StTofrGeomNode() {}
95  ~StTofrGeomNode();
96 
97  static void DebugOn() { mDebug = kTRUE; }
98  static void DebugOff() { mDebug = kFALSE; }
99  static Bool_t IsDebugOn() { return mDebug; }
100 
101  static void CalcMatrix(TNode* son, Double_t* trans, Double_t* rot,
102  StTofrGeomNode* mother=0);
103  static void ConvertPos( TNode* from, const Double_t* pos_from,
104  StTofrGeomNode* to, Double_t* pos_to);
105  void Local2Master(const Double_t* local, Double_t* master);
106  void Master2Local(const Double_t* master, Double_t* local);
107 
108  StThreeVectorD YZPlaneNormal();
109  StThreeVectorD GetCenterPosition() const;
110  // Double_t GetCenterRxy() const { return mCenterRxy; }
111  // Double_t GetCenterEta() const { return mCenterEta; }
112  // Double_t GetCenterPhi() const { return mCenterPhi; }
113  Double_t GetEtaMin() const { return mEtaMin; }
114  Double_t GetEtaMax() const { return mEtaMax; }
115  Double_t GetPhiMin() const { return mPhiMin; }
116  Double_t GetPhiMax() const { return mPhiMax; }
117  Bool_t IsLocalPointIn(const Double_t x, const Double_t y,
118  const Double_t z) const;
119  Bool_t IsGlobalPointIn(const StThreeVectorD &global);
120  Bool_t HelixCross(const StHelixD &helix,
121  Double_t &pathLen, StThreeVectorD &cross);
122  virtual void Print() const;
123 
124  C_l_assDef(StTofrGeomNode,2) //Virutal TNode for TOFr geometry
125 };
126 #endif
127 
128 class TVolumeView;
129 
131 //
132 // StTofrNode
133 // =========
134 //
136 
137 class StTofrNode : public TObject {
138  protected:
139  TVolumeView *fView;
140  TVolumePosition *pView;
141  TVolumeView *mMasterNode;
142 
143  Double_t mTransMRS[3]; //Translate vector in MRS
144  Double_t mRotMRS[9]; //RotateMatrix from MRS to this
145  Bool_t mTransFlag; //Flag, kTRUE=if translation/matrix updated
146  // Double_t mCenterRxy; //center position R(xy) in MRS
147  // Double_t mCenterEta; //center position Eta in MRS
148  // Double_t mCenterPhi; //center position Phi in MRS
149  Double_t mEtaMin; //minimum covered Eta in MRS
150  Double_t mEtaMax; //maximum covered Eta in MRS
151  Double_t mPhiMin; //minimum covered Phi in MRS
152  Double_t mPhiMax; //maximum covered Phi in MRS
153  // Bool_t mMatrixUpdated; //is TNode::fRotMatrix updated
154 
155  static Bool_t mDebug;
156 
157  protected:
158  // StTofrNode(const StTofrNode& tofnode);
159  StTofrNode(TVolumeView *element, TVolumeView *top);
160 
161  StTofrNode& operator=(const StTofrNode&);
162 
163  void UpdateMatrix();
164  void BuildMembers();
165 
166  public:
167  StTofrNode() {}
168  ~StTofrNode();
169 
170  TVolumeView* GetfView() const { return fView; }
171  TVolumePosition* GetpView() const { return pView; }
172  TVolumeView* GetTopNode() const { return mMasterNode; }
173  static void DebugOn() { mDebug = kTRUE; }
174  static void DebugOff() { mDebug = kFALSE; }
175  static Bool_t IsDebugOn() { return mDebug; }
176 
177  static void CalcMatrix(StTofrNode* son, Double_t* trans, Double_t* rot,
178  StTofrNode* mother=0);
179  static void ConvertPos(StTofrNode* from, const Double_t* pos_from,
180  StTofrNode* to, Double_t* pos_to);
181  void Local2Master(const Double_t* local, Double_t* master);
182  void Master2Local(const Double_t* master, Double_t* local);
183  TShape *GetShape() const { return fView->GetPosition()->GetNode()->GetShape();}
184 
185  StThreeVectorD YZPlaneNormal();
186  StThreeVectorD GetCenterPosition() const;
187  // Double_t GetCenterRxy() const { return mCenterRxy; }
188  // Double_t GetCenterEta() const { return mCenterEta; }
189  // Double_t GetCenterPhi() const { return mCenterPhi; }
190  Double_t GetEtaMin() const { return mEtaMin; }
191  Double_t GetEtaMax() const { return mEtaMax; }
192  Double_t GetPhiMin() const { return mPhiMin; }
193  Double_t GetPhiMax() const { return mPhiMax; }
194  Bool_t IsLocalPointIn(const Double_t x, const Double_t y,
195  const Double_t z);
196  Bool_t IsGlobalPointIn(const StThreeVectorD &global);
197  Bool_t HelixCross(const StHelixD &helix,
198  Double_t &pathLen, StThreeVectorD &cross);
199  virtual void Print(const Option_t *opt="") const;
200 
201  ClassDef(StTofrNode,2) //Virutal TNode for TOFr geometry
202 };
203 
204 
206 //
207 // StTofrGeomTray
208 // ==============
209 //
211 
212 class StTofrGeomTray : public StTofrNode {
213  friend class StTofrGeometry;
214 
215  private:
216  Int_t mTrayIndex; //Tray Index number
217  Int_t mBTOHIndex; // BTOH Index number
218  Int_t mSectorsInBTOH; //number of sectors in one half TOF
219 
220  protected:
221  static Bool_t mDebug;
222 
223  protected:
224  /*
225  StTofrGeomTray(const char* name, const char* title, const TBRIK* brik,
226  const Double_t x, const Double_t y, const Double_t z,
227  const TRotMatrix* matrix, const Int_t itray);*/
228  /* StTofrGeomTray(const char* name, const char* title, TBRIK* brik,
229  const Double_t x, const Double_t y, const Double_t z,
230  TRotMatrix* matrix, const Int_t itray);
231  static void PrepareCopyNode(TNode* node, StTofrGeomNode* top,
232  TShape*& shape, Double_t* pos, TRotMatrix*& newrot);
233  static StTofrGeomTray* CopyNode(TNode* node, const Int_t itray);
234  StTofrGeomSensor* AddNode(TNode* node, const Int_t imodule);
235  */
236 
237  public:
238  StTofrGeomTray(const Int_t ibtoh, TVolumeView *sector, TVolumeView *top);
239  StTofrGeomTray() {}
240  ~StTofrGeomTray();
241 
242  StTofrGeomTray& operator=(const StTofrGeomTray&);
243  static void DebugOn() { mDebug = kTRUE; }
244  static void DebugOff() { mDebug = kFALSE; }
245  static Bool_t IsDebugOn() { return mDebug; }
246 
247  Int_t BTOHIndex() const { return mBTOHIndex; }
248  Int_t Index() const { return mTrayIndex; }
249  StTofrGeomSensor* GetSensor(const Int_t imodule) const;
250  virtual void Print(const Option_t *opt="") const;
251 
252  ClassDef(StTofrGeomTray,1) //Tray node in TOFr geometry
253 };
254 
255 
257 //
258 // StTofrGeomSensor
259 // ================
260 //
262 
263 class StTofrGeomSensor : public StTofrNode {
264  friend class StTofrGeomTray;
265 
266  private:
267  Int_t mModuleIndex; //Module Index number
268  static Int_t const mCells = 6;
269  Double_t mCellY[mCells+1]; //Y Range of cells
270  static Double_t const mSensorDy;// = 10.35; // Actual module length;
271 
272  protected:
273  static Bool_t mDebug;
274 
275  protected:
276  /*
277  StTofrGeomSensor(const char* name, const char* title, const TBRIK* brik,
278  const Double_t x, const Double_t y, const Double_t z,
279  const TRotMatrix* matrix, const Int_t imodule);*/
280  /* StTofrGeomSensor(const char* name, const char* title, TBRIK* brik,
281  const Double_t x, const Double_t y, const Double_t z,
282  TRotMatrix* matrix, const Int_t imodule);*/
283  void CreateGeomCells();
284 
285  public:
286  StTofrGeomSensor(TVolumeView *element, TVolumeView *top);
287 
288  StTofrGeomSensor() {}
289  ~StTofrGeomSensor();
290 
291  StTofrGeomSensor& operator=(const StTofrGeomSensor&);
292  static void DebugOn() { mDebug = kTRUE; }
293  static void DebugOff() { mDebug = kFALSE; }
294  static Bool_t IsDebugOn() { return mDebug; }
295 
296  static Int_t GetCells() { return mCells; }
297 
298  Int_t Index() const { return mModuleIndex; }
299  Double_t GetCellYMin(const Int_t icell) const;
300  Double_t GetCellYMax(const Int_t icell) const;
301  Int_t FindCellIndex(const Double_t* local);
302  Int_t PrevCellIndex(const Int_t icell) const;
303  Int_t NextCellIndex(const Int_t icell) const;
304  StThreeVectorD GetCellPosition(const Int_t icell);
305  virtual void Print(Option_t *opt="") const ;
306 
307  ClassDef(StTofrGeomSensor,2) //Module node in TOFr geometry
308 };
309 
310 //_____________________________________________________________________________
311 inline Int_t StTofrGeomSensor::PrevCellIndex(const Int_t icell)
312 const
313 {
314  Int_t ret = -1;
315  if (icell>mCells) ret=mCells;
316  else if (icell>0) ret=icell-1;
317  return ret;
318 }
319 
320 //_____________________________________________________________________________
321 inline Int_t StTofrGeomSensor::NextCellIndex(const Int_t icell)
322 const
323 {
324  Int_t ret = -1;
325  if (icell<0) ret=0;
326  else if (icell<mCells) ret=icell+1;
327  return ret;
328 }
329 
331 //
332 // StTofrGeometry
333 // ==============
334 //
336 
337 class StTofrGeometry : public TNamed {
338  private:
339  TNamed* mGeoNamed;
340  static Int_t const mNTrays = 120;
341  static Int_t const mNModules = 33;
342 
343  protected:
344  //structure of btof_modr, btof_tray, etc, containing info in btofgeo.g
345  //St_XDFFile* mXdf //!pointer to the xdf file of tables
346  TVolumeView* mTopNode; //top TNode as MRS
347  const char* mRootFile;
348  Int_t mSectorsInBTOH; //number of sectors in one half TOF
349  Int_t mTrays; //amount of TOFr trays
350  Int_t mModulesInTray; //number of modules in a tray
351  Int_t mCellsInModule; //number of cell in a module
352  Bool_t mInitFlag; //flag of initialization, kTRUE if done
353  TVolume* mStarHall;
354  Int_t mTofrConf; //configuration for tray/full (0/1) tofr
355 
356  StTofrGeomTray* mTofrTray[mNTrays];
357  StTofrGeomSensor* mTofrSensor[mNTrays][mNModules];
358  Int_t mNValidTrays;
359  Int_t mNValidModules;
360 
361  static Int_t const mY03TrayIndex = 83; //year03 run tray index
362 
363  static Bool_t mDebug;
364 
365  static const char* const sectorPref ;//= "BSEC";
366  static const char* const trayPref ;//= "BTRA";
367  static const char* const senPref ;//= "BRMD";
368 
369  protected:
370  //void InitFromXdf(const char* xdffile);
371  //void Xdf2Geometry();
372  // Bool_t InitFromRoot(const char* rootfile);
373  // Bool_t CopyTopNode(TNode* top);
374 
375  public:
376  StTofrGeometry(const char* name="tofrGeo",
377  const char* title="Simplified Tofr Geometry");
378  ~StTofrGeometry();
379 
380  // static TRotMatrix* CreateMatrix(const Double_t theta);
381  // static void GetPrefixNodes(const TNode* topNode, const char* key, TList &list);
382 
383  Bool_t IsBSEC(const TVolume* element) const
384  { return !(strcmp(element->GetName(), sectorPref)); }
385  Bool_t IsBTRA(const TVolume* element) const
386  { return !(strcmp(element->GetName(), trayPref)); }
387  Bool_t IsBRMD(const TVolume* element) const
388  { return !(strcmp(element->GetName(), senPref)); }
389 
390  Bool_t ContainOthers(TVolume *element);
391 
392  static Bool_t LackThis(const char* fromWhere);
393 
394  static void DebugOn() { mDebug = kTRUE; }
395  static void DebugOff() { mDebug = kFALSE; }
396  static Bool_t IsDebugOn() { return mDebug; }
397 
398  // void Init(const char* file, Option_t* option="root");
399  // void Init(TVolume *starHall, const Int_t TofrConf=0);
400  // void InitFromStar(TVolume *starHall, const Int_t TofrConf=0);
401  void Init(TVolume *starHall);
402  void InitFromStar(TVolume *starHall);
403  // void InitDaqMap();
404 
405  Bool_t IsInitDone() const { return mInitFlag; }
406  Bool_t IsCellValid(const Int_t icell) const;
407  Bool_t IsSensorValid(const Int_t imodule) const;
408  Bool_t IsTrayValid(const Int_t itray) const;
409 
410  Int_t CalcCellId(const Int_t volumeId, const Double_t* local) const;
411  Int_t CalcCellId(const Int_t volumeId, const Float_t* local) const;
412  Int_t CalcSensorId(const Int_t imodule, const Int_t itray=0) const;
413  Int_t PrevCellId(const Int_t cellId) const;
414  Int_t NextCellId(const Int_t cellId) const;
415  // Int_t CalcCellId(const Int_t icell,
416  // const StTofrGeomSensor* sensor) const;
417  Int_t CalcCellId(const Int_t icell, const Int_t imodule,
418  const Int_t itray=0) const;
419  void DecodeVolumeId(const Int_t volumeId,
420  Int_t &imodule, Int_t &itray) const;
421  Bool_t DecodeSensorId(const Int_t sensorId, Int_t &imodule,
422  Int_t &itray) const;
423  Bool_t DecodeCellId(const Int_t cellId, Int_t &icell,
424  Int_t &imodule, Int_t &itray) const;
425  Int_t GetCellIndex(const Int_t cellId) const;
426 
427  Int_t CellsInModule(const Int_t imodule=0, const Int_t itray=0) const
428  { return StTofrGeomSensor::GetCells(); }
429  Int_t ModulesInTray(const Int_t itray=0) const
430  { return mModulesInTray; }
431  Int_t Trays() const { return mTrays; }
432 
433  const char* GeoRootFile() { return mRootFile; }
434  virtual void Print(Option_t *opt="") const ;
435 
436  TVolumeView* GetTopNode() const { return mTopNode; }
437  StTofrGeomSensor* GetGeomCell(const Int_t cellId) const;
438  StTofrGeomSensor* GetGeomSensor(const Int_t imodule,
439  const Int_t itray=0) const;
440  StTofrGeomTray* GetGeomTray(const Int_t itray=0) const;
441  StTofrGeomTray* GetGeomTrayAt(const Int_t idx=0) const;
442  Int_t GetAtOfTray(const Int_t itray=0) const;
443 
444  Int_t CellIdPointIn(const StThreeVectorD& point) const;
445 #ifndef __CINT__
446  Bool_t HelixCrossCellIds(const StHelixD &helix, IntVec &idVec,
447  DoubleVec &pathVec, PointVec &crossVec) const;
448  Bool_t HelixCrossCellIds(const StHelixD &helix, IntVec validModuleVec, IntVec projTrayVec, IntVec &idVec, DoubleVec &pathVec, PointVec &crossVec) const;
449  Bool_t HelixCross(const StHelixD &helix) const;
450  Bool_t HelixCross(const StHelixD &helix, IntVec validModuleVec, IntVec projTrayVec) const;
451  Bool_t projTrayVector(const StHelixD &helix, IntVec &trayVec) const;
452 #endif
453  ClassDef(StTofrGeometry,2) //Simplified TOFr Geometry
454 };
455 
456 R__EXTERN StTofrGeometry* gTofrGeometry;
457 
458 #endif //end of STTOFRGEOMETRY_H
459 
460 /*******************************************************************
461  * $Log: StTofrGeometry.h,v $
462  * Revision 1.10 2018/02/26 23:27:02 smirnovd
463  * Remove unnecessary guards around ClassDef macro
464  *
465  * Revision 1.9 2018/02/26 23:13:21 smirnovd
466  * Move embedded CVS log messages to the end of file
467  *
468  * Revision 1.8 2008/03/27 00:15:39 dongx
469  * Update for Run8 finished.
470  *
471  * Revision 1.7 2005/07/07 01:22:28 fisyak
472  * Hide typedefs IntVec, DoubleVec, PointVec and methods HelixCrossCellIds,HelixCross, projTrayVector from CINT
473  *
474  * Revision 1.6 2005/07/06 19:24:59 fisyak
475  * Use templated StThreeVector
476  *
477  * Revision 1.5 2004/05/03 23:07:49 dongx
478  * -Introduce data members to save the Tray and Sensor geometries in the initialization.
479  * -Optimize the HelixCrossCellIds() function to save CPU time
480  * -Introduce a new function projTrayVector()
481  * -Update the //classDef number 1->2
482  *
483  *
484  * Revision 1.3 2004/03/09 16:45:16 dongx
485  * Remove InitDaqMap() since a StTofrDaqMap is introduced
486  *
487  * Revision 1.2 2003/09/11 05:49:23 perev
488  * ansi corrs
489  *
490  * Revision 1.1 2003/08/06 23:00:53 geurts
491  * First Release
492  */
static const char *const sectorPref
Control message printing of this class.
void CreateGeomCells()
Control message printing of this class.
Int_t mSectorsInBTOH
the root file of geometry