EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PndGeoHandling.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PndGeoHandling.h
1 
25 #ifndef PNDGEOHANDLING_H
26 #define PNDGEOHANDLING_H
27 
28 #include "PndSensorNamePar.h"
29 
30 #include "FairRun.h"
31 #include "FairRuntimeDb.h"
32 #include "FairTask.h"
33 
34 #include "TGeoManager.h"
35 #include "TGeoMatrix.h"
36 #include "TString.h"
37 #include "TVector3.h"
38 #include "TMatrixD.h"
39 
40 #include <string>
41 #include <iostream>
42 #include <vector>
43 
44 class PndGeoHandling : public FairTask {
45 public:
46 
49  PndGeoHandling();
50  static PndGeoHandling* Instance();
51 
52  static void Destroy(){
53  if (fInstance){
54  delete fInstance;
55  fInstance = 0;
56  }
57  }
58 
59  //PndGeoHandling(TGeoManager* aGeoMan);
60  PndGeoHandling(TString mcFile, TString parFile);
61  PndGeoHandling(Int_t runID, TString parFile);
62 
63  virtual ~PndGeoHandling(){};
64 
65  virtual void SetParContainers();
66 
67  // static PndGeoHandling* Instance();
68 
69  // TString GetCurrentID(); ///< returns the ID of the current node
70  // TString GetID(TString path); ///< for a given TGeoManager-path the ID is returned
71  // TString GetPath(TString id); ///< for a given ID the path is returned
72 
73  TString GetPath(Int_t shortID);
74  Int_t GetShortID(TString path);
75 
76  TString GetVolumeID(TString name);
77  std::vector<TString> GetNamesLevel(Int_t level, TString startPath = "", bool fullPath = false);
78  void GetOUVPath(TString path, TVector3& o, TVector3& u, TVector3& v);
79  // void GetOUVId(TString id, TVector3& o, TVector3& u, TVector3& v); ///< for a volume given by its ID the o, u, v vectors for the plane are returned
80  void GetOUVShortId(Int_t shortId, TVector3& o, TVector3& u, TVector3& v){
81  if (fSensorNamePar != 0)
82  GetOUVPath(GetPath(shortId), o, u, v);
83  }
84 
85  TGeoHMatrix* GetMatrixPath(TString path);
86  // TGeoHMatrix* GetMatrixId(TString id);
87  TGeoHMatrix* GetMatrixShortId(Int_t shortId){
88  return GetMatrixPath(GetPath(shortId));
89  }
90 
91  // TVector3 GetSensorDimensionsId(TString id);
92  TVector3 GetSensorDimensionsPath(TString path);
93  TVector3 GetSensorDimensionsShortId(Int_t shortId){
94  return GetSensorDimensionsPath(GetPath(shortId));
95  }
96 
97  // TVector3 MasterToLocalId(const TVector3& master, const TString& id);
98  TVector3 MasterToLocalPath(const TVector3& master, const TString& id);
99  TVector3 MasterToLocalShortId(const TVector3& master, const Int_t& shortId){
100  return MasterToLocalPath(master, GetPath(shortId));
101  }
102 
103  // TVector3 LocalToMasterId(const TVector3& local, const TString& id);
104  TVector3 LocalToMasterPath(const TVector3& local, const TString& id);
105  TVector3 LocalToMasterShortId(const TVector3& local, const Int_t& shortId){
106  return LocalToMasterPath(local, GetPath(shortId));
107  }
108 
109  // TODO: Recheck the error calculation for 3-vectors
110  // TMatrixD MasterToLocalErrorsId(const TMatrixD& master, const TString& id);
111  TMatrixD MasterToLocalErrorsPath(const TMatrixD& master, const TString& id);
112  TMatrixD MasterToLocalErrorsShortId(const TMatrixD& master, const Int_t& shortId){
113  return MasterToLocalErrorsPath(master, GetPath(shortId));
114  }
115 
116  // TMatrixD LocalToMasterErrorsId(const TMatrixD& local, const TString& id);
117  TMatrixD LocalToMasterErrorsPath(const TMatrixD& local, const TString& id);
118  TMatrixD LocalToMasterErrorsShortId(const TMatrixD& local, const Int_t& shortId){
119  return LocalToMasterErrorsPath(local, GetPath(shortId));
120  }
121 
122  TMatrixD GetCurrentRotationMatrix();
123 
124  void SetVerbose(Int_t v) { fVerbose = v; }
125  void SetGeoManager(TGeoManager* geo){fGeoMan = geo;};
127 
128  //Bool_t cd(TString id); ///< as the cd command of TGeoManager just with the ID
129  Bool_t cd(Int_t id);
130  void FillLevelNames();
131 
132  TString FindNodePath(TGeoNode* node);
133  void DiveDownToNode(TGeoNode* node);
134  void cd(TGeoNode* node);
135 
136  void DiveDownToNodeContainingString(TString name);
137 
138  void CreateUniqueSensorId(TString startName, std::vector<std::string> listOfSensitives);
139  bool VolumeIsSensitive(TString& path, std::vector<std::string>& listOfSensitives);
140 
142  if (fSensorNamePar)
144  }
145 
146  TObjArray* GetSensorNames(){
147  if (fSensorNamePar != 0)
148  return fSensorNamePar->GetSensorNames();
149  else
150  return 0;
151  }
152 
153  Int_t GetRunId(TString mcFile);
154  void GetGeoManager();
155  void GetSensorNamePar();
156  void InitRuntimeDb(TString parFileName);
157 
160  return kSUCCESS;
161  }
162 
163  virtual InitStatus ReInit() {fGeoMan =0;fGeoMan=gGeoManager;return kSUCCESS;}
164 
165  PndGeoHandling& operator= (const PndGeoHandling&) {return *this;}
166 
167  private:
170  fGeoMan(gh.fGeoMan),
172  fRtdb(gh.fRtdb),
174  fLevel(gh.fLevel),
175  fFullPath(gh.fFullPath),
176  fVerbose(gh.fVerbose),
177  fRunId(gh.fRunId)
178  {}
179 
180  void DiveDownToFillSensNamePar(std::vector<std::string> listOfSensitives);
181 
182  TGeoManager* fGeoMan;
185  // static PndGeoHandling* fGeoHandlingInstance;
186 
187  std::vector<TString> fLevelNames;
188  Int_t fLevel;
189  bool fFullPath;
190  Int_t fVerbose;
191  Int_t fRunId;
193 };
194 
195 #endif