Belle II Software  release-05-02-19
ECLGeometryPar.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Poyuan Chen *
7  * *
8  * This software is provided "as is" without any warranty. *
9  * *
10  * 7/31: Poyuan *
11  * *
12  * *
13  **************************************************************************/
14 #ifndef ECLGEOMETRYPAR_H
15 #define ECLGEOMETRYPAR_H
16 
17 #include <vector>
18 #include <map>
19 #include <G4ThreeVector.hh>
20 #include <TVector3.h>
21 
22 typedef int EclIdentifier;
23 typedef double EclGeV;
24 typedef double EclCM;
25 typedef double EclRad;
26 
27 class G4VTouchable;
28 namespace HepGeom {
29  class Transform3D;
30 }
31 typedef HepGeom::Transform3D G4Transform3D;
32 
33 namespace Belle2 {
38  namespace ECL {
39 
40 
42 
46 
47  public:
48 
51 
53  virtual ~ECLGeometryPar();
54 
56 
59  static ECLGeometryPar* Instance();
60 
62  void clear();
63 
65  void Print() const;
66 
68  void read();
69 
71  void Mapping(int cid);
72 
74  int GetCellID(int ThetaId, int PhiId);
76  int GetCellID() {return mPar_cellID;};
78  int GetThetaID() {return mPar_thetaID;};
80  int GetPhiID() {return mPar_phiID;};
82  int ECLVolumeToCellID(const G4VTouchable*);
83  int TouchableToCellID(const G4VTouchable*);
85  int TouchableDiodeToCellID(const G4VTouchable*);
88  G4ThreeVector getCrystalPos(int cid)
89  {
90  if (cid != m_ini_cid) InitCrystal(cid);
91  return m_current_crystal.pos;
92  }
93 
95  G4ThreeVector getCrystalVec(int cid)
96  {
97  if (cid != m_ini_cid) InitCrystal(cid);
98  return m_current_crystal.dir;
99  }
100 
102  TVector3 GetCrystalPos(int cid)
103  {
104  if (cid != m_ini_cid) InitCrystal(cid);
105  const G4ThreeVector& t = m_current_crystal.pos;
106  return TVector3(t.x(), t.y(), t.z());
107  }
108 
110  TVector3 GetCrystalVec(int cid)
111  {
112  if (cid != m_ini_cid) InitCrystal(cid);
113  const G4ThreeVector& t = m_current_crystal.dir;
114  return TVector3(t.x(), t.y(), t.z());
115  }
116 
117  double time2sensor(int cid, const G4ThreeVector& hit_pos);
118  private:
120  G4Transform3D* m_ECLForwardGlobalT = nullptr;
122  G4Transform3D* m_ECLBackwardGlobalT = nullptr;
124  G4Transform3D* m_ECLBarrelGlobalT = nullptr;
126  void InitCrystal(int cid);
128  struct CrystalGeom_t {
129  G4ThreeVector pos, dir;
130  };
132  std::vector<CrystalGeom_t> m_crystals;
145  };
146 
147 
149  class EclNbr {
150  // friend classses and functions
151 
152  public:
154  typedef EclIdentifier Identifier ;
155 
157  EclNbr();
159  EclNbr(const EclNbr& aNbr);
161  EclNbr(
162  const std::vector< Identifier >& aNbrs ,
163  const std::vector< Identifier >::size_type aNearSize
164  ) ;
165 
167  virtual ~EclNbr();
168 
169  // member functions
170 
171  // const member functions
173  const std::vector< Identifier >& nbrs() const ;
175  const std::vector< Identifier >::const_iterator nearBegin() const ;
177  const std::vector< Identifier >::const_iterator nearEnd() const ;
179  const std::vector< Identifier >::const_iterator nextBegin() const ;
181  const std::vector< Identifier >::const_iterator nextEnd() const ;
183  std::vector< Identifier >::size_type nearSize() const ;
185  std::vector< Identifier >::size_type nextSize() const ;
186 
188  EclNbr& operator=(const EclNbr& aNbr);
190  EclNbr getNbr(const Identifier aCellId);
192  void printNbr();
194  void Mapping(int cid);
195  int GetCellID(int ThetaId, int PhiId);
197  int GetCellID() {return mNbr_cellID;};
198  int GetThetaID() {return mNbr_thetaID;};
199  int GetPhiID() {return mNbr_phiID;};
201  protected:
202  // protected member functions
203 
204  // protected const member functions
205 
206  private:
207  // Constructors and destructor
208 
209  // private member functions
210 
211  // private const member functions
212 
214  int mNbr_cellID;
217  std::vector< Identifier >& m_nbrs ;
218  std::vector< Identifier >::size_type m_nearSize ;
220  // static data members
221 
222  };
223 
226  // friend classes and functions
227 
228  public:
229  // constants, enums and typedefs
230 
232  typedef EclIdentifier Identifier;
233 
235 
237  {
238  }
241  : fId(ahit.Id()), fEnergy(ahit.Energy()), fCellId(ahit.CellId())
242  {
243  }
246  const Identifier hid, const EclGeV energy, const Identifier cid)
247  : fId(hid), fEnergy(energy), fCellId(cid)
248  {
249  }
251  virtual ~TEclEnergyHit() { }
252 
255  {
256  if (this != &hit) {
257  fId = hit.fId;
258  fEnergy = hit.fEnergy;
259  fCellId = hit.fCellId;
260  }
261  return *this;
262  }
263 
264  // member functions
266  Identifier Id(void) const
267  {
268  return fId;
269  }
272  {
273  return fId = id;
274  }
276  Identifier CellId(void) const
277  {
278  return fCellId;
279  }
282  {
283  return fCellId = cId;
284  }
285 
286 
287 
289  EclGeV Energy(void) const
290  {
291  return fEnergy;
292  }
294  EclGeV Energy(EclGeV energy)
295  {
296  return fEnergy = energy;
297  }
298 
299  // const member functions
300 
301  // static member functions
302 
304  bool operator<(const TEclEnergyHit& rhs) const
305  {
306  return
307  fId < rhs.Id();
308  }
310  bool operator>(const TEclEnergyHit& rhs) const
311  {
312  return
313  fId > rhs.Id();
314  }
316  bool operator==(const TEclEnergyHit& rhs) const
317  {
318  return
319  (fId == rhs.Id())
320  && (fEnergy == rhs.Energy())
321  && (fCellId == rhs.CellId())
322  ;
323  }
325  bool operator!=(const TEclEnergyHit& rhs) const
326  {
327  return
328  (fId != rhs.Id())
329  || (fEnergy != rhs.Energy())
330  || (fCellId != rhs.CellId())
331  ;
332  }
333 
335  struct less_Energy {
337  bool operator()(const TEclEnergyHit& lhs, const TEclEnergyHit& rhs)
338  const
339  {
340  return
341  lhs.Energy() < rhs.Energy();
342  }
343  };
345  struct less_CellId {
347  bool operator()(const TEclEnergyHit& lhs, const TEclEnergyHit& rhs)
348  const
349  {
350  return
351  lhs.CellId() < rhs.CellId();
352  }
353  };
355  struct greater_Energy {
357  bool operator()(const TEclEnergyHit& lhs, const TEclEnergyHit& rhs)
358  const
359  {
360  return
361  lhs.Energy() > rhs.Energy();
362  }
363  };
365  struct greater_CellId {
367  bool operator()(const TEclEnergyHit& lhs, const TEclEnergyHit& rhs)
368  const
369  {
370  return
371  lhs.CellId() > rhs.CellId();
372  }
373  };
374 
375 
376  protected:
377  // protected member functions
378 
379  // protected const member functions
380 
381  private:
382  // Constructors and destructor
383 
384 
385  // private member functions
386 
387  // private const member functions
388  // private const member functions
389 
392  EclGeV fEnergy;
393  int fCellId;
394  // static data members
395 
396  };
397 
399  typedef std::map <TEclEnergyHit::Identifier, TEclEnergyHit,
400  std::less<TEclEnergyHit::Identifier> > EclEnergyHitMap;
401 
402  } // end of namespace ECL
404 } // end of namespace Belle2
405 #endif
Belle2::ECL::TEclEnergyHit::Energy
EclGeV Energy(EclGeV energy)
set Energy
Definition: ECLGeometryPar.h:294
Belle2::ECL::EclNbr::printNbr
void printNbr()
print crystals nbrs
Definition: ECLGeometryPar.cc:537
Belle2::ECL::ECLGeometryPar::InitCrystal
void InitCrystal(int cid)
initialise the crystal
Definition: ECLGeometryPar.cc:345
Belle2::ECL::ECLGeometryPar::GetCrystalVec
TVector3 GetCrystalVec(int cid)
The direction of crystal.
Definition: ECLGeometryPar.h:110
Belle2::ECL::TEclEnergyHit::less_Energy::operator()
bool operator()(const TEclEnergyHit &lhs, const TEclEnergyHit &rhs) const
operator
Definition: ECLGeometryPar.h:337
Belle2::ECL::TEclEnergyHit::fCellId
int fCellId
Cell Id
Definition: ECLGeometryPar.h:393
Belle2::ECL::TEclEnergyHit::greater_CellId
struct greater_CellId
Definition: ECLGeometryPar.h:365
Belle2::ECL::EclNbr::m_nearSize
std::vector< Identifier >::size_type m_nearSize
size of near brs
Definition: ECLGeometryPar.h:218
Belle2::ECL::ECLGeometryPar::getCrystalVec
G4ThreeVector getCrystalVec(int cid)
The direction of crystal.
Definition: ECLGeometryPar.h:95
Belle2::ECL::TEclEnergyHit::fEnergy
EclGeV fEnergy
Energy
Definition: ECLGeometryPar.h:392
Belle2::ECL::TEclEnergyHit::fId
Identifier fId
data members
Definition: ECLGeometryPar.h:391
Belle2::ECL::EclNbr::operator=
EclNbr & operator=(const EclNbr &aNbr)
assignment operator(s)
Definition: ECLGeometryPar.cc:555
Belle2::ECL::EclNbr::GetCellID
int GetCellID(int ThetaId, int PhiId)
Get Cell Id.
Definition: ECLGeometryPar.cc:619
Belle2::ECL::EclNbr::getNbr
EclNbr getNbr(const Identifier aCellId)
get crystals nbr
Definition: ECLGeometryPar.cc:634
Belle2::ECL::ECLGeometryPar::m_ECLBarrelGlobalT
G4Transform3D * m_ECLBarrelGlobalT
Global transformations for the barrel part.
Definition: ECLGeometryPar.h:124
Belle2::ECL::TEclEnergyHit::operator>
bool operator>(const TEclEnergyHit &rhs) const
comparison operators
Definition: ECLGeometryPar.h:310
Belle2::ECL::ECLGeometryPar::CrystalGeom_t
crystal geometry
Definition: ECLGeometryPar.h:128
Belle2::ECL::TEclEnergyHit::less_Energy
struct less_Energy
Definition: ECLGeometryPar.h:335
Belle2::ECL::EclNbr::mNbr_thetaID
int mNbr_thetaID
The Theta ID information.
Definition: ECLGeometryPar.h:215
Belle2::ECL::ECLGeometryPar::m_ECLBackwardGlobalT
G4Transform3D * m_ECLBackwardGlobalT
Global transformations for the backward part.
Definition: ECLGeometryPar.h:122
Belle2::ECL::ECLGeometryPar::read
void read()
Gets geometry parameters from PhysicalVolumeStore.
Definition: ECLGeometryPar.cc:236
Belle2::ECL::TEclEnergyHit::operator==
bool operator==(const TEclEnergyHit &rhs) const
comparison operators
Definition: ECLGeometryPar.h:316
Belle2::ECL::EclNbr::nearBegin
const std::vector< Identifier >::const_iterator nearBegin() const
get crystals nearBegin
Definition: ECLGeometryPar.cc:583
Belle2::ECL::ECLGeometryPar::mPar_cellID
int mPar_cellID
The Cell ID information.
Definition: ECLGeometryPar.h:136
Belle2::ECL::EclNbr::GetThetaID
int GetThetaID()
Get Cell Id.
Definition: ECLGeometryPar.h:198
Belle2::ECL::TEclEnergyHit::operator=
TEclEnergyHit & operator=(const TEclEnergyHit &hit)
assignment operator(s)
Definition: ECLGeometryPar.h:254
Belle2::ECL::TEclEnergyHit::greater_Energy
struct greater_Energy
Definition: ECLGeometryPar.h:355
Belle2::ECL::ECLGeometryPar::TouchableToCellID
int TouchableToCellID(const G4VTouchable *)
The same as above but without sanity checks.
Definition: ECLGeometryPar.cc:398
Belle2::ECL::TEclEnergyHit::less_CellId::operator()
bool operator()(const TEclEnergyHit &lhs, const TEclEnergyHit &rhs) const
operator
Definition: ECLGeometryPar.h:347
Belle2::ECL::TEclEnergyHit::Energy
EclGeV Energy(void) const
get Energy
Definition: ECLGeometryPar.h:289
Belle2::ECL::ECLGeometryPar::mPar_phiID
int mPar_phiID
The Phi ID information.
Definition: ECLGeometryPar.h:140
Belle2::ECL::TEclEnergyHit::greater_Energy::operator()
bool operator()(const TEclEnergyHit &lhs, const TEclEnergyHit &rhs) const
operator
Definition: ECLGeometryPar.h:357
Belle2::ECL::ECLGeometryPar::Instance
static ECLGeometryPar * Instance()
Static method to get a reference to the ECLGeometryPar instance.
Definition: ECLGeometryPar.cc:151
Belle2::ECL::EclNbr
EclNbr class
Definition: ECLGeometryPar.h:149
Belle2::ECL::ECLGeometryPar::TouchableDiodeToCellID
int TouchableDiodeToCellID(const G4VTouchable *)
Mapping from G4VTouchable copyNumbers to Crystal CellID.
Definition: ECLGeometryPar.cc:393
Belle2::ECL::ECLGeometryPar::GetCellID
int GetCellID()
Get Cell Id.
Definition: ECLGeometryPar.h:76
Belle2::ECL::ECLGeometryPar::m_B4ECLGeometryParDB
static ECLGeometryPar * m_B4ECLGeometryParDB
Pointer that saves the instance of this class.
Definition: ECLGeometryPar.h:144
Belle2::ECL::EclNbr::nbrs
const std::vector< Identifier > & nbrs() const
get crystals nbrs
Definition: ECLGeometryPar.cc:577
Belle2::ECL::ECLGeometryPar::Print
void Print() const
Print some debug information.
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::ECL::ECLGeometryPar::~ECLGeometryPar
virtual ~ECLGeometryPar()
Destructor.
Definition: ECLGeometryPar.cc:164
Belle2::ECL::ECLGeometryPar::Mapping
void Mapping(int cid)
Mapping theta, phi Id.
Definition: ECLGeometryPar.cc:387
Belle2::ECL::TEclEnergyHit::TEclEnergyHit
TEclEnergyHit(const TEclEnergyHit &ahit)
Constructor of TEclEnergyHit.
Definition: ECLGeometryPar.h:240
Belle2::ECL::TEclEnergyHit::greater_CellId::operator()
bool operator()(const TEclEnergyHit &lhs, const TEclEnergyHit &rhs) const
operator
Definition: ECLGeometryPar.h:367
Belle2::ECL::TEclEnergyHit::TEclEnergyHit
TEclEnergyHit()
Constructors and destructor.
Definition: ECLGeometryPar.h:236
Belle2::ECL::ECLGeometryPar::ECLVolumeToCellID
int ECLVolumeToCellID(const G4VTouchable *)
Get Cell Id (LEP: new way)
Definition: ECLGeometryPar.cc:461
Belle2::ECL::ECLGeometryPar::mPar_thetaID
int mPar_thetaID
The Theta ID information.
Definition: ECLGeometryPar.h:138
Belle2::ECL::EclNbr::Mapping
void Mapping(int cid)
Mapping theta, phi Id.
Definition: ECLGeometryPar.cc:627
Belle2::ECL::ECLGeometryPar::clear
void clear()
Clears.
Definition: ECLGeometryPar.cc:175
Belle2::ECL::TEclEnergyHit::less_CellId
struct less_CellId
Definition: ECLGeometryPar.h:345
Belle2::ECL::ECLGeometryPar::m_crystals
std::vector< CrystalGeom_t > m_crystals
the crystals
Definition: ECLGeometryPar.h:132
Belle2::ECL::TEclEnergyHit::TEclEnergyHit
TEclEnergyHit(const Identifier hid, const EclGeV energy, const Identifier cid)
Constructor of TEclEnergyHit.
Definition: ECLGeometryPar.h:245
Belle2::ECL::EclNbr::GetPhiID
int GetPhiID()
Get Theta Id.
Definition: ECLGeometryPar.h:199
Belle2::ECL::TEclEnergyHit::CellId
Identifier CellId(void) const
get Cell Id
Definition: ECLGeometryPar.h:276
Belle2::ECL::ECLGeometryPar::GetCrystalPos
TVector3 GetCrystalPos(int cid)
The Position of crystal.
Definition: ECLGeometryPar.h:102
Belle2::ECL::ECLGeometryPar::getCrystalPos
G4ThreeVector getCrystalPos(int cid)
The Position of crystal.
Definition: ECLGeometryPar.h:88
Belle2::ECL::TEclEnergyHit::Id
Identifier Id(void) const
get Id
Definition: ECLGeometryPar.h:266
Belle2::ECL::EclNbr::nextSize
std::vector< Identifier >::size_type nextSize() const
get crystals nextSize
Definition: ECLGeometryPar.cc:613
Belle2::ECL::ECLGeometryPar::m_ini_cid
int m_ini_cid
Definition: ECLGeometryPar.h:142
Belle2::ECL::TEclEnergyHit::Id
Identifier Id(Identifier id)
set Id
Definition: ECLGeometryPar.h:271
Belle2::ECL::EclNbr::nextBegin
const std::vector< Identifier >::const_iterator nextBegin() const
get crystals nextBegin
Definition: ECLGeometryPar.cc:595
Belle2::ECL::ECLGeometryPar::GetPhiID
int GetPhiID()
Get Phi Id.
Definition: ECLGeometryPar.h:80
Belle2::ECL::EclNbr::mNbr_phiID
int mNbr_phiID
The Phi ID information.
Definition: ECLGeometryPar.h:216
Belle2::ECL::ECLGeometryPar
The Class for ECL Geometry Parameters.
Definition: ECLGeometryPar.h:45
Belle2::ECL::ECLGeometryPar::m_ECLForwardGlobalT
G4Transform3D * m_ECLForwardGlobalT
Global transformations for the forward part.
Definition: ECLGeometryPar.h:120
Belle2::ECL::ECLGeometryPar::ECLGeometryPar
ECLGeometryPar()
Constructor.
Definition: ECLGeometryPar.cc:157
Belle2::ECL::TEclEnergyHit::Identifier
EclIdentifier Identifier
type define Identifier
Definition: ECLGeometryPar.h:232
Belle2::ECL::TEclEnergyHit::CellId
Identifier CellId(int cId)
set Cell Id
Definition: ECLGeometryPar.h:281
Belle2::ECL::EclNbr::m_nbrs
std::vector< Identifier > & m_nbrs
id of m_brs
Definition: ECLGeometryPar.h:217
Belle2::ECL::TEclEnergyHit::operator!=
bool operator!=(const TEclEnergyHit &rhs) const
comparison operators
Definition: ECLGeometryPar.h:325
Belle2::ECL::EclNbr::mNbr_cellID
int mNbr_cellID
Get Phi Id.
Definition: ECLGeometryPar.h:199
Belle2::ECL::ECLGeometryPar::GetThetaID
int GetThetaID()
Get Theta Id.
Definition: ECLGeometryPar.h:78
Belle2::ECL::EclNbr::~EclNbr
virtual ~EclNbr()
destructor
Definition: ECLGeometryPar.cc:516
Belle2::ECL::TEclEnergyHit::~TEclEnergyHit
virtual ~TEclEnergyHit()
destructor
Definition: ECLGeometryPar.h:251
Belle2::ECL::ECLGeometryPar::m_current_crystal
CrystalGeom_t m_current_crystal
the current crystal
Definition: ECLGeometryPar.h:134
Belle2::ECL::EclNbr::nearSize
std::vector< Identifier >::size_type nearSize() const
get crystals nearSize
Definition: ECLGeometryPar.cc:607
Belle2::ECL::EclNbr::nearEnd
const std::vector< Identifier >::const_iterator nearEnd() const
get crystals nearEnd
Definition: ECLGeometryPar.cc:589
Belle2::ECL::TEclEnergyHit
define class TEclEnergyHit
Definition: ECLGeometryPar.h:225
Belle2::ECL::TEclEnergyHit::operator<
bool operator<(const TEclEnergyHit &rhs) const
comparison operators
Definition: ECLGeometryPar.h:304
Belle2::ECL::EclNbr::Identifier
EclIdentifier Identifier
constants, enums and typedefs
Definition: ECLGeometryPar.h:154
Belle2::ECL::EclNbr::EclNbr
EclNbr()
Constructors and destructor.
Definition: ECLGeometryPar.cc:487
Belle2::ECL::EclNbr::nextEnd
const std::vector< Identifier >::const_iterator nextEnd() const
get crystals nextEnd
Definition: ECLGeometryPar.cc:601