Belle II Software  release-08-01-10
ECLGeometryPar.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 #pragma once
10 
11 /* Geant4 headers. */
12 #include <G4ThreeVector.hh>
13 
14 /* ROOT headers. */
15 #include <Math/Vector3D.h>
16 
17 /* C++ headers. */
18 #include <map>
19 #include <vector>
20 
21 typedef int EclIdentifier;
22 typedef double EclGeV;
23 typedef double EclCM;
24 typedef double EclRad;
25 
26 class G4VTouchable;
27 namespace HepGeom {
28  class Transform3D;
29 }
30 typedef HepGeom::Transform3D G4Transform3D;
31 
32 namespace Belle2 {
37  namespace ECL {
38 
39 
41 
45 
46  public:
47 
50 
52  virtual ~ECLGeometryPar();
53 
55 
58  static ECLGeometryPar* Instance();
59 
61  void clear();
62 
64  void Print() const;
65 
67  void read();
68 
70  void Mapping(int cid);
71 
73  int GetCellID(int ThetaId, int PhiId);
75  int GetCellID() {return mPar_cellID;};
77  int GetThetaID() {return mPar_thetaID;};
79  int GetPhiID() {return mPar_phiID;};
81  int ECLVolumeToCellID(const G4VTouchable*);
82  int TouchableToCellID(const G4VTouchable*);
84  int TouchableDiodeToCellID(const G4VTouchable*);
87  G4ThreeVector getCrystalPos(int cid)
88  {
89  if (cid != m_ini_cid) InitCrystal(cid);
90  return m_current_crystal.pos;
91  }
92 
94  G4ThreeVector getCrystalVec(int cid)
95  {
96  if (cid != m_ini_cid) InitCrystal(cid);
97  return m_current_crystal.dir;
98  }
99 
101  ROOT::Math::XYZVector GetCrystalPos(int cid)
102  {
103  if (cid != m_ini_cid) InitCrystal(cid);
104  const G4ThreeVector& t = m_current_crystal.pos;
105  return ROOT::Math::XYZVector(t.x(), t.y(), t.z());
106  }
107 
109  ROOT::Math::XYZVector GetCrystalVec(int cid)
110  {
111  if (cid != m_ini_cid) InitCrystal(cid);
112  const G4ThreeVector& t = m_current_crystal.dir;
113  return ROOT::Math::XYZVector(t.x(), t.y(), t.z());
114  }
115 
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;
130  G4ThreeVector dir;
131  };
133  std::vector<CrystalGeom_t> m_crystals;
146  };
147 
148 
150  class EclNbr {
151  // friend classses and functions
152 
153  public:
155  typedef EclIdentifier Identifier ;
156 
158  EclNbr();
160  EclNbr(const EclNbr& aNbr);
162  EclNbr(
163  const std::vector< Identifier >& aNbrs,
164  const std::vector< Identifier >::size_type aNearSize
165  ) ;
166 
168  virtual ~EclNbr();
169 
170  // member functions
171 
172  // const member functions
174  const std::vector< Identifier >& nbrs() const ;
176  const std::vector< Identifier >::const_iterator nearBegin() const ;
178  const std::vector< Identifier >::const_iterator nearEnd() const ;
180  const std::vector< Identifier >::const_iterator nextBegin() const ;
182  const std::vector< Identifier >::const_iterator nextEnd() const ;
184  std::vector< Identifier >::size_type nearSize() const ;
186  std::vector< Identifier >::size_type nextSize() const ;
187 
189  EclNbr& operator=(const EclNbr& aNbr);
191  EclNbr getNbr(const Identifier aCellId);
193  void printNbr();
195  void Mapping(int cid);
196  int GetCellID(int ThetaId, int PhiId);
199  int GetCellID() {return mNbr_cellID;};
201  int GetThetaID() {return mNbr_thetaID;};
203  int GetPhiID() {return mNbr_phiID;};
204 
205  protected:
206  // protected member functions
207 
208  // protected const member functions
209 
210  private:
211  // Constructors and destructor
212 
213  // private member functions
214 
215  // private const member functions
216 
221  std::vector< Identifier >& m_nbrs ;
222  std::vector< Identifier >::size_type m_nearSize ;
224  // static data members
225 
226  };
227 
230  // friend classes and functions
231 
232  public:
233  // constants, enums and typedefs
234 
236  typedef EclIdentifier Identifier;
237 
239 
241  {
242  }
245  : fId(ahit.Id()), fEnergy(ahit.Energy()), fCellId(ahit.CellId())
246  {
247  }
250  const Identifier hid, const EclGeV energy, const Identifier cid)
251  : fId(hid), fEnergy(energy), fCellId(cid)
252  {
253  }
255  virtual ~TEclEnergyHit() { }
256 
259  {
260  if (this != &hit) {
261  fId = hit.fId;
262  fEnergy = hit.fEnergy;
263  fCellId = hit.fCellId;
264  }
265  return *this;
266  }
267 
268  // member functions
270  Identifier Id(void) const
271  {
272  return fId;
273  }
276  {
277  return fId = id;
278  }
280  Identifier CellId(void) const
281  {
282  return fCellId;
283  }
286  {
287  return fCellId = cId;
288  }
289 
290 
291 
293  EclGeV Energy(void) const
294  {
295  return fEnergy;
296  }
298  EclGeV Energy(EclGeV energy)
299  {
300  return fEnergy = energy;
301  }
302 
303  // const member functions
304 
305  // static member functions
306 
308  bool operator<(const TEclEnergyHit& rhs) const
309  {
310  return
311  fId < rhs.Id();
312  }
314  bool operator>(const TEclEnergyHit& rhs) const
315  {
316  return
317  fId > rhs.Id();
318  }
320  bool operator==(const TEclEnergyHit& rhs) const
321  {
322  return
323  (fId == rhs.Id())
324  && (fEnergy == rhs.Energy())
325  && (fCellId == rhs.CellId())
326  ;
327  }
329  bool operator!=(const TEclEnergyHit& rhs) const
330  {
331  return
332  (fId != rhs.Id())
333  || (fEnergy != rhs.Energy())
334  || (fCellId != rhs.CellId())
335  ;
336  }
337 
339  struct less_Energy {
341  bool operator()(const TEclEnergyHit& lhs, const TEclEnergyHit& rhs)
342  const
343  {
344  return
345  lhs.Energy() < rhs.Energy();
346  }
347  };
349  struct less_CellId {
351  bool operator()(const TEclEnergyHit& lhs, const TEclEnergyHit& rhs)
352  const
353  {
354  return
355  lhs.CellId() < rhs.CellId();
356  }
357  };
359  struct greater_Energy {
361  bool operator()(const TEclEnergyHit& lhs, const TEclEnergyHit& rhs)
362  const
363  {
364  return
365  lhs.Energy() > rhs.Energy();
366  }
367  };
369  struct greater_CellId {
371  bool operator()(const TEclEnergyHit& lhs, const TEclEnergyHit& rhs)
372  const
373  {
374  return
375  lhs.CellId() > rhs.CellId();
376  }
377  };
378 
379 
380  protected:
381  // protected member functions
382 
383  // protected const member functions
384 
385  private:
386  // Constructors and destructor
387 
388 
389  // private member functions
390 
391  // private const member functions
392  // private const member functions
393 
396  EclGeV fEnergy;
397  int fCellId;
398  // static data members
399 
400  };
401 
403  typedef std::map <TEclEnergyHit::Identifier, TEclEnergyHit,
404  std::less<TEclEnergyHit::Identifier> > EclEnergyHitMap;
405 
406  } // end of namespace ECL
408 } // end of namespace Belle2
The Class for ECL Geometry Parameters.
int mPar_cellID
The Cell ID information.
virtual ~ECLGeometryPar()
Destructor.
G4ThreeVector getCrystalVec(int cid)
The direction of crystal.
static ECLGeometryPar * Instance()
Static method to get a reference to the ECLGeometryPar instance.
CrystalGeom_t m_current_crystal
the current crystal
G4Transform3D * m_ECLBarrelGlobalT
Global transformations for the barrel part.
static ECLGeometryPar * m_B4ECLGeometryParDB
Pointer that saves the instance of this class.
int TouchableToCellID(const G4VTouchable *)
The same as above but without sanity checks.
G4ThreeVector getCrystalPos(int cid)
The Position of crystal.
double time2sensor(int cid, const G4ThreeVector &hit_pos)
function to calculate flight time to diode sensor
void InitCrystal(int cid)
initialise the crystal
ROOT::Math::XYZVector GetCrystalPos(int cid)
The Position of crystal.
void read()
Gets geometry parameters from PhysicalVolumeStore.
void Mapping(int cid)
Mapping theta, phi Id.
std::vector< CrystalGeom_t > m_crystals
the crystals
G4Transform3D * m_ECLBackwardGlobalT
Global transformations for the backward part.
int mPar_thetaID
The Theta ID information.
void Print() const
Print some debug information.
int mPar_phiID
The Phi ID information.
ROOT::Math::XYZVector GetCrystalVec(int cid)
The direction of crystal.
G4Transform3D * m_ECLForwardGlobalT
Global transformations for the forward part.
int m_ini_cid
initial crystal ID
int GetThetaID()
Get Theta Id.
int GetCellID()
Get Cell Id.
int TouchableDiodeToCellID(const G4VTouchable *)
Mapping from G4VTouchable copyNumbers to Crystal CellID.
int ECLVolumeToCellID(const G4VTouchable *)
Get Cell Id (LEP: new way)
std::vector< Identifier >::size_type nextSize() const
get crystals nextSize
const std::vector< Identifier >::const_iterator nextEnd() const
get crystals nextEnd
EclNbr getNbr(const Identifier aCellId)
get crystals nbr
int GetPhiID()
Get Phi Id.
EclNbr()
Constructors and destructor.
int mNbr_thetaID
The Theta ID information.
std::vector< Identifier >::size_type m_nearSize
size of near brs
virtual ~EclNbr()
destructor
const std::vector< Identifier > & nbrs() const
get crystals nbrs
int mNbr_cellID
data members
const std::vector< Identifier >::const_iterator nearEnd() const
get crystals nearEnd
int mNbr_phiID
The Phi ID information.
void printNbr()
print crystals nbrs
void Mapping(int cid)
Mapping theta, phi Id.
const std::vector< Identifier >::const_iterator nearBegin() const
get crystals nearBegin
const std::vector< Identifier >::const_iterator nextBegin() const
get crystals nextBegin
EclIdentifier Identifier
constants, enums and typedefs
std::vector< Identifier >::size_type nearSize() const
get crystals nearSize
std::vector< Identifier > & m_nbrs
id of m_brs
int GetThetaID()
Get Theta Id.
EclNbr & operator=(const EclNbr &aNbr)
assignment operator(s)
int GetCellID()
Get Cell Id.
define class TEclEnergyHit
Identifier Id(Identifier id)
set Id
Identifier Id(void) const
get Id
EclGeV Energy(EclGeV energy)
set Energy
TEclEnergyHit(const TEclEnergyHit &ahit)
Constructor of TEclEnergyHit.
virtual ~TEclEnergyHit()
destructor
bool operator!=(const TEclEnergyHit &rhs) const
comparison operators
bool operator<(const TEclEnergyHit &rhs) const
comparison operators
Identifier fId
data members
EclGeV Energy(void) const
get Energy
Identifier CellId(int cId)
set Cell Id
TEclEnergyHit()
Constructors and destructor.
Identifier CellId(void) const
get Cell Id
EclIdentifier Identifier
type define Identifier
TEclEnergyHit & operator=(const TEclEnergyHit &hit)
assignment operator(s)
bool operator>(const TEclEnergyHit &rhs) const
comparison operators
bool operator==(const TEclEnergyHit &rhs) const
comparison operators
TEclEnergyHit(const Identifier hid, const EclGeV energy, const Identifier cid)
Constructor of TEclEnergyHit.
Abstract base class for different kinds of events.
G4ThreeVector pos
position of crystal
G4ThreeVector dir
direction of crystal
bool operator()(const TEclEnergyHit &lhs, const TEclEnergyHit &rhs) const
operator
bool operator()(const TEclEnergyHit &lhs, const TEclEnergyHit &rhs) const
operator
bool operator()(const TEclEnergyHit &lhs, const TEclEnergyHit &rhs) const
operator
bool operator()(const TEclEnergyHit &lhs, const TEclEnergyHit &rhs) const
operator