FairRoot/PandaRoot
PndGeoHandling.h
Go to the documentation of this file.
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);
61  PndGeoHandling(Int_t runID, TString parFile);
62  PndGeoHandling(PndSensorNamePar* SensorNamePar);
63 
64  virtual ~PndGeoHandling(){};
65 
66  virtual void SetParContainers();
67 
68  // static PndGeoHandling* Instance();
69 
70  // TString GetCurrentID(); ///< returns the ID of the current node
71  // TString GetID(TString path); ///< for a given TGeoManager-path the ID is returned
72  // TString GetPath(TString id); ///< for a given ID the path is returned
73 
74  TString GetPath(Int_t shortID);
75  Int_t GetShortID(TString path);
76 
78  std::vector<TString> GetNamesLevel(Int_t level, TString startPath = ""); //, bool fullPath = false); //[R.K.03/2017] unused variable
79  void GetOUVPath(TString path, TVector3& o, TVector3& u, TVector3& v);
80  // 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
81  void GetOUVShortId(Int_t shortId, TVector3& o, TVector3& u, TVector3& v){
82  if (fSensorNamePar != 0)
83  GetOUVPath(GetPath(shortId), o, u, v);
84  }
85 
86  TGeoHMatrix* GetMatrixPath(TString path);
87  // TGeoHMatrix* GetMatrixId(TString id);
88  TGeoHMatrix* GetMatrixShortId(Int_t shortId){
89  return GetMatrixPath(GetPath(shortId));
90  }
91 
92  // TVector3 GetSensorDimensionsId(TString id);
93  TVector3 GetSensorDimensionsPath(TString path);
94  TVector3 GetSensorDimensionsShortId(Int_t shortId){
95  return GetSensorDimensionsPath(GetPath(shortId));
96  }
97 
98  // TVector3 MasterToLocalId(const TVector3& master, const TString& id);
99  TVector3 MasterToLocalPath(const TVector3& master, const TString& id);
100  TVector3 MasterToLocalShortId(const TVector3& master, const Int_t& shortId){
101  return MasterToLocalPath(master, GetPath(shortId));
102  }
103 
104  // TVector3 LocalToMasterId(const TVector3& local, const TString& id);
105  TVector3 LocalToMasterPath(const TVector3& local, const TString& id);
106  TVector3 LocalToMasterShortId(const TVector3& local, const Int_t& shortId){
107  return LocalToMasterPath(local, GetPath(shortId));
108  }
109 
110  // TODO: Recheck the error calculation for 3-vectors
111  // TMatrixD MasterToLocalErrorsId(const TMatrixD& master, const TString& id);
112  TMatrixD MasterToLocalErrorsPath(const TMatrixD& master, const TString& id);
113  TMatrixD MasterToLocalErrorsShortId(const TMatrixD& master, const Int_t& shortId){
114  return MasterToLocalErrorsPath(master, GetPath(shortId));
115  }
116 
117  // TMatrixD LocalToMasterErrorsId(const TMatrixD& local, const TString& id);
118  TMatrixD LocalToMasterErrorsPath(const TMatrixD& local, const TString& id);
119  TMatrixD LocalToMasterErrorsShortId(const TMatrixD& local, const Int_t& shortId){
120  return LocalToMasterErrorsPath(local, GetPath(shortId));
121  }
122 
124 
125  void SetVerbose(Int_t v) { fVerbose = v; }
126  void SetGeoManager(TGeoManager* geo){fGeoMan = geo;};
128 
129  //Bool_t cd(TString id); ///< as the cd command of TGeoManager just with the ID
130  Bool_t cd(Int_t id);
131  void FillLevelNames();
132 
133  TString FindNodePath(TGeoNode* node);
134  void DiveDownToNode(TGeoNode* node);
135  void cd(TGeoNode* node);
136 
138 
139  void CreateUniqueSensorId(TString startName, std::vector<std::string> listOfSensitives);
140  bool VolumeIsSensitive(TString& path, std::vector<std::string>& listOfSensitives);
141 
143  if (fSensorNamePar)
145  }
146 
147  TObjArray* GetSensorNames(){
148  if (fSensorNamePar != 0)
149  return fSensorNamePar->GetSensorNames();
150  else
151  return 0;
152  }
153 
154  std::vector<TString> GetSensorNamesWithString(TString value){
155  if (fSensorNamePar != 0)
157  else {
158  std::vector<TString> empty;
159  return empty;
160  }
161  }
162 
163  Int_t GetRunId(TString mcFile);
164  void GetGeoManager();
165  TGeoManager* GetGeoMan(){return fGeoMan;}
166  void GetSensorNamePar();
169  }
170  void InitRuntimeDb(TString parFileName);
171 
172  PndGeoHandling& operator= (const PndGeoHandling&) {return *this;}
173 
174 protected:
175  InitStatus Init(){
177  return kSUCCESS;
178  }
179 
180  virtual InitStatus ReInit() {fGeoMan =0;fGeoMan=gGeoManager;return kSUCCESS;}
181 
182  private:
185  FairTask(),
186  fGeoMan(gh.fGeoMan),
188  fRtdb(gh.fRtdb),
190  fLevel(gh.fLevel),
191  fFullPath(gh.fFullPath),
192  fRunId(gh.fRunId),
193  fVerbose(gh.fVerbose)
194  {}
195 
196  void DiveDownToFillSensNamePar(std::vector<std::string> listOfSensitives);
197 
198  TGeoManager* fGeoMan;
200  FairRuntimeDb* fRtdb;
201  // static PndGeoHandling* fGeoHandlingInstance;
202 
203  std::vector<TString> fLevelNames;
204  Int_t fLevel;
205  bool fFullPath;
206  Int_t fRunId;
207  Int_t fVerbose;
209 };
210 
211 #endif
TString FindNodePath(TGeoNode *node)
Int_t GetRunId(TString mcFile)
void SetGeoManager(TGeoManager *geo)
void DiveDownToNode(TGeoNode *node)
virtual InitStatus ReInit()
void DiveDownToNodeContainingString(TString name)
runs through the GeoManager until a path is found with a substring which matches to the given string ...
void SetSensorNamePar(PndSensorNamePar *par)
void GetOUVShortId(Int_t shortId, TVector3 &o, TVector3 &u, TVector3 &v)
virtual ~PndGeoHandling()
TGeoHMatrix * GetMatrixPath(TString path)
static void Destroy()
std::vector< TString > fLevelNames
virtual void SetParContainers()
void CreateUniqueSensorId(TString startName, std::vector< std::string > listOfSensitives)
Has to be called during simulation to create unique sensor id.
Double_t par[3]
TVector3 GetSensorDimensionsPath(TString path)
FairRuntimeDb * fRtdb
TGeoManager * gGeoManager
TVector3 MasterToLocalPath(const TVector3 &master, const TString &id)
void FillLevelNames()
fills vector fLevelNames with the names (or the paths) of the volumes down to the level give...
TMatrixD MasterToLocalErrorsShortId(const TMatrixD &master, const Int_t &shortId)
std::vector< TString > GetSensorNamesWithString(TString value)
static PndGeoHandling * fInstance
TString GetPath(Int_t shortID)
for a given shortID the path is returned
__m128 v
Definition: P4_F32vec4.h:4
ClassDef(PndGeoHandling, 3)
TVector3 GetSensorDimensionsShortId(Int_t shortId)
TGeoHMatrix * GetMatrixShortId(Int_t shortId)
TObjArray * GetSensorNames() const
TMatrixD LocalToMasterErrorsShortId(const TMatrixD &local, const Int_t &shortId)
Class to access the naming information of the MVD.
TString GetVolumeID(TString name)
returns the volume ID for a given volume name
void PrintSensorNames()
TString parFile
Definition: hit_dirc.C:14
void GetOUVPath(TString path, TVector3 &o, TVector3 &u, TVector3 &v)
for a volume given by its path the o, u, v vectors for the plane are returned
TMatrixD GetCurrentRotationMatrix()
void InitRuntimeDb(TString parFileName)
TMatrixD LocalToMasterErrorsPath(const TMatrixD &local, const TString &id)
TString mcFile
Definition: runMvdTpcReco.C:22
Bool_t cd(Int_t id)
as the cd command of TGeoManager just with the ID
TObjArray * GetSensorNames()
Int_t GetShortID(TString path)
for a given path the (unique) position of the sensor path in the fSensorNamePar-List is given...
PndGeoHandling(PndGeoHandling &gh)
TVector3 LocalToMasterPath(const TVector3 &local, const TString &id)
static PndGeoHandling * Instance()
TString name
std::vector< TString > GetSensorNamesWithString(TString identifier)
TVector3 MasterToLocalShortId(const TVector3 &master, const Int_t &shortId)
TMatrixD MasterToLocalErrorsPath(const TMatrixD &master, const TString &id)
void DiveDownToFillSensNamePar(std::vector< std::string > listOfSensitives)
void SetVerbose(Int_t v)
bool VolumeIsSensitive(TString &path, std::vector< std::string > &listOfSensitives)
Checks if the path contains a substring which matches one of the given strings in listOfSensitives...
PndGeoHandling & operator=(const PndGeoHandling &)
TGeoManager * GetGeoMan()
InitStatus Init()
TVector3 LocalToMasterShortId(const TVector3 &local, const Int_t &shortId)
PndSensorNamePar * fSensorNamePar
TGeoManager * fGeoMan
TMatrixT< double > TMatrixD
Definition: PndLmdDim.h:52
std::vector< TString > GetNamesLevel(Int_t level, TString startPath="")
PndGeoHandling()
default constructor. Has to be called in SetParContainers if the support of shortId is needed...
Unique match between SensorID and path in TGeoManager.