Belle II Software  release-06-02-00
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 #include <vector>
12 #include <map>
13 #include <G4ThreeVector.hh>
14 #include <TVector3.h>
15 
16 typedef int EclIdentifier;
17 typedef double EclGeV;
18 typedef double EclCM;
19 typedef double EclRad;
20 
21 class G4VTouchable;
22 namespace HepGeom {
23  class Transform3D;
24 }
25 typedef HepGeom::Transform3D G4Transform3D;
26 
27 namespace Belle2 {
32  namespace ECL {
33 
34 
36 
40 
41  public:
42 
45 
47  virtual ~ECLGeometryPar();
48 
50 
53  static ECLGeometryPar* Instance();
54 
56  void clear();
57 
59  void Print() const;
60 
62  void read();
63 
65  void Mapping(int cid);
66 
68  int GetCellID(int ThetaId, int PhiId);
70  int GetCellID() {return mPar_cellID;};
72  int GetThetaID() {return mPar_thetaID;};
74  int GetPhiID() {return mPar_phiID;};
76  int ECLVolumeToCellID(const G4VTouchable*);
77  int TouchableToCellID(const G4VTouchable*);
79  int TouchableDiodeToCellID(const G4VTouchable*);
82  G4ThreeVector getCrystalPos(int cid)
83  {
84  if (cid != m_ini_cid) InitCrystal(cid);
85  return m_current_crystal.pos;
86  }
87 
89  G4ThreeVector getCrystalVec(int cid)
90  {
91  if (cid != m_ini_cid) InitCrystal(cid);
92  return m_current_crystal.dir;
93  }
94 
96  TVector3 GetCrystalPos(int cid)
97  {
98  if (cid != m_ini_cid) InitCrystal(cid);
99  const G4ThreeVector& t = m_current_crystal.pos;
100  return TVector3(t.x(), t.y(), t.z());
101  }
102 
104  TVector3 GetCrystalVec(int cid)
105  {
106  if (cid != m_ini_cid) InitCrystal(cid);
107  const G4ThreeVector& t = m_current_crystal.dir;
108  return TVector3(t.x(), t.y(), t.z());
109  }
110 
111  double time2sensor(int cid, const G4ThreeVector& hit_pos);
112  private:
114  G4Transform3D* m_ECLForwardGlobalT = nullptr;
116  G4Transform3D* m_ECLBackwardGlobalT = nullptr;
118  G4Transform3D* m_ECLBarrelGlobalT = nullptr;
120  void InitCrystal(int cid);
122  struct CrystalGeom_t {
123  G4ThreeVector pos, dir;
124  };
126  std::vector<CrystalGeom_t> m_crystals;
139  };
140 
141 
143  class EclNbr {
144  // friend classses and functions
145 
146  public:
148  typedef EclIdentifier Identifier ;
149 
151  EclNbr();
153  EclNbr(const EclNbr& aNbr);
155  EclNbr(
156  const std::vector< Identifier >& aNbrs ,
157  const std::vector< Identifier >::size_type aNearSize
158  ) ;
159 
161  virtual ~EclNbr();
162 
163  // member functions
164 
165  // const member functions
167  const std::vector< Identifier >& nbrs() const ;
169  const std::vector< Identifier >::const_iterator nearBegin() const ;
171  const std::vector< Identifier >::const_iterator nearEnd() const ;
173  const std::vector< Identifier >::const_iterator nextBegin() const ;
175  const std::vector< Identifier >::const_iterator nextEnd() const ;
177  std::vector< Identifier >::size_type nearSize() const ;
179  std::vector< Identifier >::size_type nextSize() const ;
180 
182  EclNbr& operator=(const EclNbr& aNbr);
184  EclNbr getNbr(const Identifier aCellId);
186  void printNbr();
188  void Mapping(int cid);
189  int GetCellID(int ThetaId, int PhiId);
191  int GetCellID() {return mNbr_cellID;};
192  int GetThetaID() {return mNbr_thetaID;};
193  int GetPhiID() {return mNbr_phiID;};
195  protected:
196  // protected member functions
197 
198  // protected const member functions
199 
200  private:
201  // Constructors and destructor
202 
203  // private member functions
204 
205  // private const member functions
206 
211  std::vector< Identifier >& m_nbrs ;
212  std::vector< Identifier >::size_type m_nearSize ;
214  // static data members
215 
216  };
217 
220  // friend classes and functions
221 
222  public:
223  // constants, enums and typedefs
224 
226  typedef EclIdentifier Identifier;
227 
229 
231  {
232  }
235  : fId(ahit.Id()), fEnergy(ahit.Energy()), fCellId(ahit.CellId())
236  {
237  }
240  const Identifier hid, const EclGeV energy, const Identifier cid)
241  : fId(hid), fEnergy(energy), fCellId(cid)
242  {
243  }
245  virtual ~TEclEnergyHit() { }
246 
249  {
250  if (this != &hit) {
251  fId = hit.fId;
252  fEnergy = hit.fEnergy;
253  fCellId = hit.fCellId;
254  }
255  return *this;
256  }
257 
258  // member functions
260  Identifier Id(void) const
261  {
262  return fId;
263  }
266  {
267  return fId = id;
268  }
270  Identifier CellId(void) const
271  {
272  return fCellId;
273  }
276  {
277  return fCellId = cId;
278  }
279 
280 
281 
283  EclGeV Energy(void) const
284  {
285  return fEnergy;
286  }
288  EclGeV Energy(EclGeV energy)
289  {
290  return fEnergy = energy;
291  }
292 
293  // const member functions
294 
295  // static member functions
296 
298  bool operator<(const TEclEnergyHit& rhs) const
299  {
300  return
301  fId < rhs.Id();
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  && (fEnergy == rhs.Energy())
315  && (fCellId == rhs.CellId())
316  ;
317  }
319  bool operator!=(const TEclEnergyHit& rhs) const
320  {
321  return
322  (fId != rhs.Id())
323  || (fEnergy != rhs.Energy())
324  || (fCellId != rhs.CellId())
325  ;
326  }
327 
329  struct less_Energy {
331  bool operator()(const TEclEnergyHit& lhs, const TEclEnergyHit& rhs)
332  const
333  {
334  return
335  lhs.Energy() < rhs.Energy();
336  }
337  };
339  struct less_CellId {
341  bool operator()(const TEclEnergyHit& lhs, const TEclEnergyHit& rhs)
342  const
343  {
344  return
345  lhs.CellId() < rhs.CellId();
346  }
347  };
349  struct greater_Energy {
351  bool operator()(const TEclEnergyHit& lhs, const TEclEnergyHit& rhs)
352  const
353  {
354  return
355  lhs.Energy() > rhs.Energy();
356  }
357  };
359  struct greater_CellId {
361  bool operator()(const TEclEnergyHit& lhs, const TEclEnergyHit& rhs)
362  const
363  {
364  return
365  lhs.CellId() > rhs.CellId();
366  }
367  };
368 
369 
370  protected:
371  // protected member functions
372 
373  // protected const member functions
374 
375  private:
376  // Constructors and destructor
377 
378 
379  // private member functions
380 
381  // private const member functions
382  // private const member functions
383 
386  EclGeV fEnergy;
387  int fCellId;
388  // static data members
389 
390  };
391 
393  typedef std::map <TEclEnergyHit::Identifier, TEclEnergyHit,
394  std::less<TEclEnergyHit::Identifier> > EclEnergyHitMap;
395 
396  } // end of namespace ECL
398 } // 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.
TVector3 GetCrystalVec(int cid)
The direction of crystal.
void InitCrystal(int cid)
initialise the crystal
TVector3 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.
G4Transform3D * m_ECLForwardGlobalT
Global transformations for the forward part.
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 Theta 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
Get Phi Id.
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.
int GetCellID(int ThetaId, int PhiId)
Get Cell 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 Cell Id.
EclNbr & operator=(const EclNbr &aNbr)
assignment operator(s)
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.
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