ATLAS Offline Software
Loading...
Searching...
No Matches
LArStraightElectrodes.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
11
12const LArStraightElectrodes* LArStraightElectrodes::GetInstance(const std::string& strDetector)
13{
14 static const LArStraightElectrodes instance(strDetector);
15 return &instance;
16}
17
18
19LArStraightElectrodes::LArStraightElectrodes(const std::string& strDetector)
20{
22 if (parameters->GetValue("LArEMBPhiAtCurvature",0)>0.) m_parity=0; // first wave goes up
23 else m_parity=1; // first wave goes down
24
25 static const std::string prefix = strDetector.empty() ? "" : strDetector+"::";
26 static const PhysicalVolumeAccessor pva(prefix+"LAr::EMB::STAC",
27 prefix+"LAr::EMB::Electrode::Straight");
28
29 for (int stackid=0; stackid<14; stackid++) {
30 for (int cellid=0; cellid<1024; cellid++) {
31 initXYCentEle(pva, stackid, cellid);
32 initHalfLength(pva, stackid, cellid);
33 const double slant = SlantEle(pva, stackid, cellid);
34 sincos(slant, &m_sinu[cellid][stackid], &m_cosu[cellid][stackid]);
35 }
36 }
37}
38
39
40void LArStraightElectrodes::initXYCentEle(const PhysicalVolumeAccessor& theElectrodes, int stackid, int cellid)
41{
42 const int id=cellid+stackid*10000;
43 const G4VPhysicalVolume *pv=theElectrodes.GetPhysicalVolume(id);
44 if (!pv) {
45 m_xcent[cellid][stackid] = 0;
46 m_ycent[cellid][stackid] = 0;
47 return;
48 }
49
50 const G4ThreeVector& tv=pv->GetTranslation();
51 const G4VPhysicalVolume *pv2=theElectrodes.GetPhysicalVolume(1000000+id);
52 if (!pv2) {
53 m_xcent[cellid][stackid] = tv.x();
54 m_ycent[cellid][stackid] = tv.y();
55 }
56 else {
57 const G4ThreeVector& tv2=pv2->GetTranslation();
58 const G4LogicalVolume* lv = pv->GetLogicalVolume();
59 const G4Trap* trap = static_cast<G4Trap*> (lv->GetSolid());
60 const G4LogicalVolume* lv2 = pv2->GetLogicalVolume();
61 const G4Trap* trap2 = static_cast<G4Trap*> (lv2->GetSolid());
62 double xl1=trap->GetYHalfLength1();
63 double xl2=trap2->GetYHalfLength1();
64 m_xcent[cellid][stackid] = (tv.x()*xl1+tv2.x()*xl2)/(xl1+xl2);
65 m_ycent[cellid][stackid] = (tv.y()*xl1+tv2.y()*xl2)/(xl1+xl2);
66 }
67}
68
69
70double LArStraightElectrodes::SlantEle(const PhysicalVolumeAccessor& theElectrodes, int stackid, int cellid) const
71{
72 const int id=cellid+stackid*10000;
73 const G4VPhysicalVolume *pv=theElectrodes.GetPhysicalVolume(id);
74 if (!pv) return 0.;
75 const G4RotationMatrix *rm=pv->GetRotation();
76 double Slant = (stackid%2 ==m_parity) ? 180*CLHEP::deg-(rm->thetaY()):(rm->thetaY())-180*CLHEP::deg;
77 if((stackid%2 == m_parity) && (rm->phiY() > 0)) Slant = 360.*CLHEP::deg - Slant;
78 if((stackid%2 == (1-m_parity)) && (rm->phiY() < 0)) Slant = - Slant;
79 return Slant;
80}
81
82
83void LArStraightElectrodes::initHalfLength(const PhysicalVolumeAccessor& theElectrodes, int stackid, int cellid)
84{
85 double l = 0.;
86 const int id=cellid+stackid*10000;
87 const G4VPhysicalVolume *pv=theElectrodes.GetPhysicalVolume(id);
88 if (!pv){
89 l = 0.;
90 } else {
91 const G4LogicalVolume* lv = pv->GetLogicalVolume();
92 const G4Trap* trap = static_cast<G4Trap*> (lv->GetSolid());
93 const G4VPhysicalVolume *pv2=theElectrodes.GetPhysicalVolume(1000000+id);
94 if (!pv2){
95 l = trap->GetYHalfLength1();
96 } else {
97 const G4LogicalVolume* lv2 = pv2->GetLogicalVolume();
98 const G4Trap* trap2 = static_cast<G4Trap*> (lv2->GetSolid());
99 l = trap->GetYHalfLength1()+trap2->GetYHalfLength1();
100 }
101 }
102 m_halflength[cellid][stackid] = l;
103}
104
LArGeo::VDetectorParameters LArVG4DetectorParameters
std::map< std::string, double > instance
static const VDetectorParameters * GetInstance()
LArStraightElectrodes(const std::string &strDetector="")
static const LArStraightElectrodes * GetInstance(const std::string &strDetector="")
double SlantEle(const PhysicalVolumeAccessor &theElectrodes, int stackid, int cellid) const
void initHalfLength(const PhysicalVolumeAccessor &theElectrodes, int stackid, int cellid)
void initXYCentEle(const PhysicalVolumeAccessor &theElectrodes, int stackid, int cellid)
const G4VPhysicalVolume * GetPhysicalVolume(int) const