ATLAS Offline Software
LArStraightElectrodes.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "G4LogicalVolume.hh"
7 #include "G4VSolid.hh"
8 #include "G4Trap.hh"
10 
11 
12 const LArStraightElectrodes* LArStraightElectrodes::GetInstance(const std::string& strDetector)
13 {
14  static const LArStraightElectrodes instance(strDetector);
15  return &instance;
16 }
17 
18 
19 LArStraightElectrodes::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 
40 void 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 = (G4Trap*) lv->GetSolid();
60  const G4LogicalVolume* lv2 = pv2->GetLogicalVolume();
61  const G4Trap* trap2 = (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 
70 double 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 
83 void 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 = (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 = (G4Trap*) lv2->GetSolid();
99  l = trap->GetYHalfLength1()+trap2->GetYHalfLength1();
100  }
101  }
102  m_halflength[cellid][stackid] = l;
103 }
104 
LArStraightElectrodes::m_halflength
double m_halflength[1024][14]
Definition: LArStraightElectrodes.h:21
LArStraightElectrodes::m_cosu
double m_cosu[1024][14]
Definition: LArStraightElectrodes.h:19
LArGeo::VDetectorParameters
Definition: VDetectorParameters.h:29
LArVG4DetectorParameters.h
deg
#define deg
Definition: SbPolyhedron.cxx:17
LArStraightElectrodes::m_xcent
double m_xcent[1024][14]
Definition: LArStraightElectrodes.h:17
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
LArStraightElectrodes::m_parity
int m_parity
Definition: LArStraightElectrodes.h:22
instance
std::map< std::string, double > instance
Definition: Run_To_Get_Tags.h:8
LArStraightElectrodes::initXYCentEle
void initXYCentEle(const PhysicalVolumeAccessor &theElectrodes, int stackid, int cellid)
Definition: LArStraightElectrodes.cxx:40
PhysicalVolumeAccessor
Definition: PhysicalVolumeAccessor.h:18
LArStraightElectrodes
Definition: LArStraightElectrodes.h:11
LArStraightElectrodes.h
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
LArStraightElectrodes::SlantEle
double SlantEle(const PhysicalVolumeAccessor &theElectrodes, int stackid, int cellid) const
Definition: LArStraightElectrodes.cxx:70
LArStraightElectrodes::initHalfLength
void initHalfLength(const PhysicalVolumeAccessor &theElectrodes, int stackid, int cellid)
Definition: LArStraightElectrodes.cxx:83
PhysicalVolumeAccessor::GetPhysicalVolume
const G4VPhysicalVolume * GetPhysicalVolume(int) const
Definition: PhysicalVolumeAccessor.cxx:42
python.changerun.pv
pv
Definition: changerun.py:81
LArStraightElectrodes::GetInstance
static const LArStraightElectrodes * GetInstance(const std::string &strDetector="")
Definition: LArStraightElectrodes.cxx:12
physics_parameters.parameters
parameters
Definition: physics_parameters.py:144
LArGeo::VDetectorParameters::GetInstance
static const VDetectorParameters * GetInstance()
Definition: VDetectorParameters.cxx:29
LArStraightElectrodes::m_ycent
double m_ycent[1024][14]
Definition: LArStraightElectrodes.h:18
LArStraightElectrodes::LArStraightElectrodes
LArStraightElectrodes(const std::string &strDetector="")
Definition: LArStraightElectrodes.cxx:19
LArStraightElectrodes::m_sinu
double m_sinu[1024][14]
Definition: LArStraightElectrodes.h:20