Belle II Software development
ECLGeometryPar Class Reference

The Class for ECL Geometry Parameters. More...

#include <ECLGeometryPar.h>

Classes

struct  CrystalGeom_t
 crystal geometry More...
 

Public Member Functions

 ECLGeometryPar ()
 Constructor.
 
virtual ~ECLGeometryPar ()
 Destructor.
 
void clear ()
 Clears.
 
void Print () const
 Print some debug information.
 
void read ()
 Gets geometry parameters from PhysicalVolumeStore.
 
void Mapping (int cid)
 Mapping theta, phi Id.
 
int GetCellID (int ThetaId, int PhiId)
 Get Cell Id.
 
int GetCellID ()
 Get Cell Id.
 
int GetThetaID ()
 Get Theta Id.
 
int GetPhiID ()
 Get Phi Id.
 
int ECLVolumeToCellID (const G4VTouchable *)
 Get Cell Id (LEP: new way)
 
int TouchableToCellID (const G4VTouchable *)
 The same as above but without sanity checks.
 
int TouchableDiodeToCellID (const G4VTouchable *)
 Mapping from G4VTouchable copyNumbers to Crystal CellID.
 
G4ThreeVector getCrystalPos (int cid)
 The Position of crystal.
 
G4ThreeVector getCrystalVec (int cid)
 The direction of crystal.
 
ROOT::Math::XYZVector GetCrystalPos (int cid)
 The Position of crystal.
 
ROOT::Math::XYZVector GetCrystalVec (int cid)
 The direction of crystal.
 
double time2sensor (int cid, const G4ThreeVector &hit_pos)
 function to calculate flight time to diode sensor
 

Static Public Member Functions

static ECLGeometryParInstance ()
 Static method to get a reference to the ECLGeometryPar instance.
 

Private Member Functions

void InitCrystal (int cid)
 initialise the crystal
 

Private Attributes

G4Transform3D * m_ECLForwardGlobalT = nullptr
 Global transformations for the forward part.
 
G4Transform3D * m_ECLBackwardGlobalT = nullptr
 Global transformations for the backward part.
 
G4Transform3D * m_ECLBarrelGlobalT = nullptr
 Global transformations for the barrel part.
 
std::vector< CrystalGeom_tm_crystals
 the crystals
 
CrystalGeom_t m_current_crystal
 the current crystal
 
int mPar_cellID
 The Cell ID information.
 
int mPar_thetaID
 The Theta ID information.
 
int mPar_phiID
 The Phi ID information.
 
int m_ini_cid
 initial crystal ID
 

Static Private Attributes

static ECLGeometryParm_B4ECLGeometryParDB = 0
 Pointer that saves the instance of this class.
 

Detailed Description

The Class for ECL Geometry Parameters.

This class provides ECL geometry parameters for simulation, reconstruction and so on. These parameters are got from geometry description

Definition at line 44 of file ECLGeometryPar.h.

Constructor & Destructor Documentation

◆ ECLGeometryPar()

Constructor.

Definition at line 174 of file ECLGeometryPar.cc.

175{
176 clear();
177 // delay crystal positions fetching to a moment when it actually needed and geometry is already built
178 // read();
179}

◆ ~ECLGeometryPar()

~ECLGeometryPar ( )
virtual

Destructor.

Definition at line 181 of file ECLGeometryPar.cc.

182{
185 B2DEBUG(150, "m_B4ECLGeometryParDB deleted ");
186 }
190}
G4Transform3D * m_ECLBarrelGlobalT
Global transformations for the barrel part.
static ECLGeometryPar * m_B4ECLGeometryParDB
Pointer that saves the instance of this class.
G4Transform3D * m_ECLBackwardGlobalT
Global transformations for the backward part.
G4Transform3D * m_ECLForwardGlobalT
Global transformations for the forward part.

Member Function Documentation

◆ clear()

void clear ( )

Clears.

Definition at line 192 of file ECLGeometryPar.cc.

193{
194 m_ini_cid = -1;
195 mPar_cellID = 0;
196 mPar_thetaID = 0;
197 mPar_phiID = 0;
198}
int mPar_cellID
The Cell ID information.
int mPar_thetaID
The Theta ID information.
int mPar_phiID
The Phi ID information.
int m_ini_cid
initial crystal ID

◆ ECLVolumeToCellID()

int ECLVolumeToCellID ( const G4VTouchable *  touch)

Get Cell Id (LEP: new way)

Mapping from G4VTouchable copyNumbers to Crystal CellID

Definition at line 478 of file ECLGeometryPar.cc.

479{
480 int depth = touch->GetHistoryDepth();
481 if ((depth != 3) && (depth != 5)) {
482 B2WARNING("ECLGeometryPar::ECLVolumeToCellID: History depth = " << depth << " is out of range: should be 3 or 5.");
483 return -1;
484 }
485 const G4String& vname = touch->GetVolume()->GetName();
486 std::size_t pos0 = vname.find("lv_forward_crystal_");
487 std::size_t pos1 = vname.find("lv_barrel_crystal_");
488 std::size_t pos2 = vname.find("lv_backward_crystal_");
489 if (pos0 == string::npos && pos1 == string::npos && pos2 == string::npos) {
490 B2WARNING("ECLGeometryPar::ECLVolumeToCellID: Volume name does not match pattern. NAME=" << vname);
491 return -1;
492 }
493 return TouchableToCellID(touch);
494}
int TouchableToCellID(const G4VTouchable *)
The same as above but without sanity checks.

◆ GetCellID() [1/2]

int GetCellID ( )
inline

Get Cell Id.

Definition at line 75 of file ECLGeometryPar.h.

75{return mPar_cellID;};

◆ GetCellID() [2/2]

int GetCellID ( int  ThetaId,
int  PhiId 
)

Get Cell Id.

Definition at line 399 of file ECLGeometryPar.cc.

400{
401 return Mapping_t::CellID(ThetaId, PhiId);
402}
static int CellID(int ThetaId, int PhiId)
return cell id as a function of theta id and phi id

◆ getCrystalPos()

G4ThreeVector getCrystalPos ( int  cid)
inline

The Position of crystal.

Definition at line 87 of file ECLGeometryPar.h.

88 {
89 if (cid != m_ini_cid) InitCrystal(cid);
91 }
CrystalGeom_t m_current_crystal
the current crystal
void InitCrystal(int cid)
initialise the crystal
G4ThreeVector pos
position of crystal

◆ GetCrystalPos()

ROOT::Math::XYZVector GetCrystalPos ( int  cid)
inline

The Position of crystal.

Definition at line 101 of file ECLGeometryPar.h.

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 }

◆ getCrystalVec()

G4ThreeVector getCrystalVec ( int  cid)
inline

The direction of crystal.

Definition at line 94 of file ECLGeometryPar.h.

95 {
96 if (cid != m_ini_cid) InitCrystal(cid);
98 }
G4ThreeVector dir
direction of crystal

◆ GetCrystalVec()

ROOT::Math::XYZVector GetCrystalVec ( int  cid)
inline

The direction of crystal.

Definition at line 109 of file ECLGeometryPar.h.

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 }

◆ GetPhiID()

int GetPhiID ( )
inline

Get Phi Id.

Definition at line 79 of file ECLGeometryPar.h.

79{return mPar_phiID;};

◆ GetThetaID()

int GetThetaID ( )
inline

Get Theta Id.

Definition at line 77 of file ECLGeometryPar.h.

77{return mPar_thetaID;};

◆ InitCrystal()

void InitCrystal ( int  cid)
private

initialise the crystal

Definition at line 362 of file ECLGeometryPar.cc.

363{
364 if (m_crystals.size() == 0) read();
365 int thetaid, phiid, nreplica, indx;
366 Mapping_t::Mapping(cid, thetaid, phiid, nreplica, indx);
367 // cout<<cid<<" "<<thetaid<<" "<<phiid<<" "<<nreplica<<" "<<indx<<endl;
368 const CrystalGeom_t& t = m_crystals[indx];
369 double s, c;
370 if (indx > 131)
371 sincos<72>(ss72, nreplica, s, c);
372 else
373 sincos<16>(ss16, nreplica, s, c);
374
375 G4Transform3D* T;
376 if (ECLElementNumbers::isForward(cid + 1)) {
378 } else if (ECLElementNumbers::isBarrel(cid + 1)) {
380 } else {
382 c = -c;
383 }
384 double xp = c * t.pos.x() - s * t.pos.y();
385 double yp = s * t.pos.x() + c * t.pos.y();
386 // m_current_crystal.pos.set(xp, yp, t.pos.z());
387
388 double xv = c * t.dir.x() - s * t.dir.y();
389 double yv = s * t.dir.x() + c * t.dir.y();
390 // m_current_crystal.dir.set(xv, yv, t.dir.z());
391
392 m_current_crystal.pos = (1 / CLHEP::cm) * (*T * G4Point3D(xp, yp, t.pos.z()));
393 m_current_crystal.dir = *T * G4Vector3D(xv, yv, t.dir.z());
394
395 // cout<<t.pos<<" "<<t.dir<<" "<<m_current_crystal.pos<<" "<<m_current_crystal.dir<<endl;
396 m_ini_cid = cid;
397}
void read()
Gets geometry parameters from PhysicalVolumeStore.
std::vector< CrystalGeom_t > m_crystals
the crystals
static void Mapping(int id, int &ThetaId, int &PhiId)
Retrieving theta and phi id of crystal.
bool isForward(int cellId)
Check whether the crystal is in forward ECL.
bool isBarrel(int cellId)
Check whether the crystal is in barrel ECL.

◆ Instance()

ECLGeometryPar * Instance ( )
static

Static method to get a reference to the ECLGeometryPar instance.

Returns
A reference to an instance of this class.

Definition at line 168 of file ECLGeometryPar.cc.

◆ Mapping()

void Mapping ( int  cid)

Mapping theta, phi Id.

Definition at line 404 of file ECLGeometryPar.cc.

◆ read()

void read ( )

Gets geometry parameters from PhysicalVolumeStore.

Definition at line 253 of file ECLGeometryPar.cc.

254{
255 m_crystals.clear();
256 m_crystals.reserve(46 * 2 + 132); // 10752 bytes
257
258 // Endcap sectors are rotated since behaviour of G4Replica class. It
259 // requires a physical volume during phi replication to be symmetric
260 // around phi=0. So we need to rotate it by -((2*pi)/16)/2 angle at the
261 // geometry description are return back here.
262
263 G4Point3D p0(0, 0, 0); G4Vector3D v0(0, 0, 1);
264
265 {
266 m_ECLForwardGlobalT = new G4Transform3D(getT("ECLForwardPhysical"));
267 G4Transform3D T = getT("ECLForwardCrystalSectorPhysical_1");
268 G4String tnamef("ECLForwardWrappedCrystal_Physical_");
269 for (int i = 0; i < 72; i++) {
270 G4String vname(tnamef); vname += to_string(i);
271 G4Transform3D cT = T * getT(vname);
272 CrystalGeom_t c = {cT * p0, cT * v0};
273 m_crystals.push_back(c);
274 // G4cout << i << " " << c.pos << " " << c.dir << G4endl;
275 }
276 }
277
278 {
279 m_ECLBackwardGlobalT = new G4Transform3D(getT("ECLBackwardPhysical"));
280 G4Transform3D T = getT("ECLBackwardCrystalSectorPhysical_0");
281 G4String tnamef("ECLBackwardWrappedCrystal_Physical_");
282 for (int i = 0; i < 60; i++) {
283 G4String vname(tnamef); vname += to_string(i);
284 G4Transform3D cT = T * getT(vname);
285 CrystalGeom_t c = {cT * p0, cT * v0};
286 m_crystals.push_back(c);
287 // G4cout << i << " " << c.pos << " " << c.dir << G4endl;
288 }
289 }
290
291 {
292 // get barrel sector (between two septums) transformation
293
294 // extract global barrel movements assuming we know transformation of the sector in axial symmetric situation
295 m_ECLBarrelGlobalT = new G4Transform3D(getT("ECLBarrelSectorPhysical_0") * G4RotateZ3D(M_PI / 2));
296 G4Transform3D Ts = G4RotateZ3D(-M_PI / 2);
297 // since barrel sector is symmetric around phi=0 we need to
298 // translate crystal with negative phi back to positive rotating
299 // crystal position by (2*M_PI/72) angle
300 G4Transform3D Ts1 = G4RotateZ3D(M_PI / 36) * Ts;
301
302 G4String tname("ECLBarrelWrappedCrystal_Physical_");
303 for (int i = 0; i < 2 * 46; i++) {
304 G4String vname(tname); vname += to_string(i);
305 G4Transform3D cT = ((i % 2) ? Ts1 : Ts) * getT(vname);
306 CrystalGeom_t c = {cT * p0, cT * v0};
307 m_crystals.push_back(c);
308 // G4cout << i << " " << c.pos << " " <<c.dir<<G4endl;
309 }
310 }
311
312 B2DEBUG(150, "ECLGeometryPar::read() initialized with " << m_crystals.size() << " crystals.");
313}

◆ time2sensor()

double time2sensor ( int  cid,
const G4ThreeVector &  hit_pos 
)

function to calculate flight time to diode sensor

Definition at line 496 of file ECLGeometryPar.cc.

497{
498 if (cid != m_ini_cid) InitCrystal(cid);
499 double z = 15. - (hit_pos - m_current_crystal.pos) * m_current_crystal.dir; // position along the vector of crystal axis
500 double dt = 6.05 + z * (0.0749 - z * 0.00112); // flight time to diode sensor in nanoseconds
501 return dt;
502}

◆ TouchableDiodeToCellID()

int TouchableDiodeToCellID ( const G4VTouchable *  touch)

Mapping from G4VTouchable copyNumbers to Crystal CellID.

Definition at line 410 of file ECLGeometryPar.cc.

411{
412 return TouchableToCellID(touch);
413}

◆ TouchableToCellID()

int TouchableToCellID ( const G4VTouchable *  touch)

The same as above but without sanity checks.

Definition at line 415 of file ECLGeometryPar.cc.

416{
417 // touch->GetCopyNumber() is a virtual call, avoid it by using
418 // directly G4NavigationHistory so we will have only one virtual
419 // call instead of three here
420 const G4NavigationHistory* h = touch->GetHistory();
421 int hd = h->GetDepth();
422 int i1 = h->GetReplicaNo(hd - 1); // index of each volume is set at physical volume creation
423 int i2 = h->GetReplicaNo(hd - 2); // go up in volume hierarchy
424
425 int ThetaId = Mapping_t::Indx2ThetaId(i1);
426 int NCryst = Mapping_t::ThetaId2NCry(ThetaId); // the number of crystals in a sector at given ThetaId
427 int Offset = Mapping_t::Offset(ThetaId);
428
429 int ik = i1 - Offset;
430 int PhiId;
431 if (NCryst == 2) {
432 PhiId = (i2 - (ik % 2)) * NCryst + ik;
433 if (PhiId < 0) PhiId += 144;
434 } else {
435 int i3 = h->GetReplicaNo(hd - 3); // go up in volume hierarchy
436 if (ThetaId < 13)
437 PhiId = (i2 + 2 * i3) * NCryst + ik;
438 else {
439 // int tt[] = {3,2,1,0,7,6,5,4};
440 // if(i3r!=tt[i3]){
441 // cout<<i3<<" "<<i3<<" "<<tt[i3]<<endl;
442 // exit(0);
443 // }
444 int i3r = (3 - (i3 % 4)) + 4 * (i3 / 4);
445 PhiId = (2 * i3r + (1 - i2)) * NCryst + ik;
446 }
447 }
448
449 int cellID = Offset * 16 + PhiId;
450 // cout<<"ECLGeometryPar::TouchableToCellID "<<h->GetVolume(hd-1)->GetName()<<" "<<i1<<" "<<i2<<" "<<h->GetReplicaNo(hd - 3)<<" "<<ThetaId<<" "<<NCryst<<" "<<Offset<<" "<<PhiId<<endl;
451
452 // test of the position and direction of crystal
453 if (0) {
454 G4AffineTransform t = h->GetTopTransform();
455 G4ThreeVector o(0, 0, 0), n(0, 0, 1);
456 G4ThreeVector ro = t.Inverse().TransformPoint(o);
457 G4ThreeVector rn = t.Inverse().TransformAxis(n);
458
459 InitCrystal(cellID);
460 ro *= 1 / CLHEP::cm;
461
462 G4ThreeVector dr = m_current_crystal.pos - ro, dn = m_current_crystal.dir - rn;
463 if (dr.mag() > 1e-10 || dn.mag() > 1e-10) {
464 cout << "Mismatch " << h->GetVolume(hd - 1)->GetName() << " " << cellID << " " << ThetaId << " " << PhiId << " " << NCryst << " "
465 << hd << " " << i2 << " " << i1 << " " << m_current_crystal.pos << " " << ro << " " << rn << " " << dr << " " << dn << endl;
466
467 for (int i = 0; i < 144; i++) {
468 int ci = Mapping_t::CellID(ThetaId, i);
469 InitCrystal(ci);
470 dr = m_current_crystal.pos - ro;
471 if (dr.mag() < 1e-10) cout << "best PhiId = " << i << endl;
472 }
473 }
474 }
475 return cellID;
476}
static int Indx2ThetaId(int indx)
getter for theta
static int Offset(int ThetaId)
return offset based on theta id
static int ThetaId2NCry(int ThetaId)
getter for number of crystals
TString rn()
Get random string.
Definition: tools.h:38

Member Data Documentation

◆ m_B4ECLGeometryParDB

ECLGeometryPar * m_B4ECLGeometryParDB = 0
staticprivate

Pointer that saves the instance of this class.

Definition at line 145 of file ECLGeometryPar.h.

◆ m_crystals

std::vector<CrystalGeom_t> m_crystals
private

the crystals

Definition at line 133 of file ECLGeometryPar.h.

◆ m_current_crystal

CrystalGeom_t m_current_crystal
private

the current crystal

Definition at line 135 of file ECLGeometryPar.h.

◆ m_ECLBackwardGlobalT

G4Transform3D* m_ECLBackwardGlobalT = nullptr
private

Global transformations for the backward part.

Definition at line 122 of file ECLGeometryPar.h.

◆ m_ECLBarrelGlobalT

G4Transform3D* m_ECLBarrelGlobalT = nullptr
private

Global transformations for the barrel part.

Definition at line 124 of file ECLGeometryPar.h.

◆ m_ECLForwardGlobalT

G4Transform3D* m_ECLForwardGlobalT = nullptr
private

Global transformations for the forward part.

Definition at line 120 of file ECLGeometryPar.h.

◆ m_ini_cid

int m_ini_cid
private

initial crystal ID

Definition at line 143 of file ECLGeometryPar.h.

◆ mPar_cellID

int mPar_cellID
private

The Cell ID information.

Definition at line 137 of file ECLGeometryPar.h.

◆ mPar_phiID

int mPar_phiID
private

The Phi ID information.

Definition at line 141 of file ECLGeometryPar.h.

◆ mPar_thetaID

int mPar_thetaID
private

The Theta ID information.

Definition at line 139 of file ECLGeometryPar.h.


The documentation for this class was generated from the following files: