ATLAS Offline Software
Loading...
Searching...
No Matches
LArStraightAbsorbers.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include "G4LogicalVolume.hh"
7#include "G4VSolid.hh"
8#include "G4Trap.hh"
10
11const LArStraightAbsorbers* LArStraightAbsorbers::GetInstance(const std::string& strDetector)
12{
13 static const LArStraightAbsorbers instance(strDetector);
14 return &instance;
15}
16
17LArStraightAbsorbers::LArStraightAbsorbers(const std::string& strDetector)
18{
20 if (parameters->GetValue("LArEMBPhiAtCurvature",0)>0.) m_parity=0; // first wave goes up
21 else m_parity=1; // first wave goes down
22
23 static const std::string prefix = strDetector.empty() ? "" : strDetector+"::";
24 static const PhysicalVolumeAccessor pva(prefix+"LAr::EMB::STAC",
25 prefix+"LAr::EMB::ThinAbs::Straight");
26
27 for (int stackid=0; stackid<14; stackid++) {
28 for (int cellid=0; cellid<1024; cellid++) {
29 initXYCentAbs(pva, stackid,cellid);
30 initHalfLength(pva, stackid,cellid);
31 const double slant = SlantAbs(pva, stackid,cellid);
32 sincos(slant, &m_sinu[cellid][stackid], &m_cosu[cellid][stackid]);
33 }
34 }
35}
36
37void LArStraightAbsorbers::initXYCentAbs(const PhysicalVolumeAccessor& theAbsorbers, int stackid, int cellid)
38{
39 const int id=cellid+stackid*10000;
40 const G4VPhysicalVolume *pv=theAbsorbers.GetPhysicalVolume(id);
41 if (!pv) {
42 m_xcent[cellid][stackid] = 0;
43 m_ycent[cellid][stackid] = 0;
44 return;
45 }
46 const G4ThreeVector& tv=pv->GetTranslation();
47 const G4VPhysicalVolume *pv2=theAbsorbers.GetPhysicalVolume(1000000+id);
48 if (!pv2) {
49 m_xcent[cellid][stackid] = tv.x();
50 m_ycent[cellid][stackid] = tv.y();
51 }
52 else {
53 const G4ThreeVector& tv2=pv2->GetTranslation();
54 const G4LogicalVolume* lv = pv->GetLogicalVolume();
55 const G4Trap* trap = static_cast<G4Trap*> (lv->GetSolid());
56 const G4LogicalVolume* lv2 = pv2->GetLogicalVolume();
57 const G4Trap* trap2 = static_cast<G4Trap*> (lv2->GetSolid());
58 const double xl1=trap->GetYHalfLength1();
59 const double xl2=trap2->GetYHalfLength1();
60 m_xcent[cellid][stackid] = (tv.x()*xl1+tv2.x()*xl2)/(xl1+xl2);
61 m_ycent[cellid][stackid] = (tv.y()*xl1+tv2.y()*xl2)/(xl1+xl2);
62 }
63}
64
65double LArStraightAbsorbers::SlantAbs(const PhysicalVolumeAccessor& theAbsorbers, int stackid, int cellid) const
66{
67 // both stackid and cellid start from 0 in the following code
68 const int id=cellid+stackid*10000;
69 const G4VPhysicalVolume *pv=theAbsorbers.GetPhysicalVolume(id);
70 if (!pv) return 0.;
71 const G4RotationMatrix *rm=pv->GetRotation();
72 double Slant = (stackid%2 ==m_parity) ? 180*CLHEP::deg-(rm->thetaY()):(rm->thetaY())-180*CLHEP::deg;
73 if((stackid%2 == m_parity) && (rm->phiY() > 0)) Slant = 360.*CLHEP::deg - Slant;
74 if((stackid%2 == (1-m_parity)) && (rm->phiY() < 0)) Slant = - Slant;
75 return Slant;
76}
77
78void LArStraightAbsorbers::initHalfLength(const PhysicalVolumeAccessor& theAbsorbers, int stackid, int cellid)
79{
80 double l = 0.;
81 const int id=cellid+stackid*10000;
82 const G4VPhysicalVolume *pv=theAbsorbers.GetPhysicalVolume(id);
83 if (pv) {
84 const G4LogicalVolume* lv = pv->GetLogicalVolume();
85 const G4Trap* trap = static_cast<G4Trap*> (lv->GetSolid());
86 const G4VPhysicalVolume *pv2=theAbsorbers.GetPhysicalVolume(1000000+id);
87 if (!pv2) l = trap->GetYHalfLength1();
88 else {
89 const G4LogicalVolume* lv2 = pv2->GetLogicalVolume();
90 const G4Trap* trap2 = static_cast<G4Trap*> (lv2->GetSolid());
91 l = trap->GetYHalfLength1()+trap2->GetYHalfLength1();
92 }
93 }
94 m_halflength[cellid][stackid] = l;
95}
96
LArGeo::VDetectorParameters LArVG4DetectorParameters
std::map< std::string, double > instance
static const VDetectorParameters * GetInstance()
double SlantAbs(const PhysicalVolumeAccessor &theAbsorbers, int stackid, int cellid) const
void initXYCentAbs(const PhysicalVolumeAccessor &theAbsorbers, int stackid, int cellid)
LArStraightAbsorbers(const std::string &strDetector="")
void initHalfLength(const PhysicalVolumeAccessor &theAbsorbers, int stackid, int cellid)
double m_halflength[1024][14]
static const LArStraightAbsorbers * GetInstance(const std::string &strDetector="")
const G4VPhysicalVolume * GetPhysicalVolume(int) const