ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
LArG4::BarrelCryostat::CalibrationMixedCalculator Class Reference

#include <CryostatCalibrationMixedCalculator.h>

Inheritance diagram for LArG4::BarrelCryostat::CalibrationMixedCalculator:
Collaboration diagram for LArG4::BarrelCryostat::CalibrationMixedCalculator:

Public Member Functions

 CalibrationMixedCalculator (const std::string &name, ISvcLocator *pSvcLocator)
 
StatusCode initialize () override final
 
virtual ~CalibrationMixedCalculator ()=default
 
virtual G4bool Process (const G4Step *step, LArG4Identifier &identifier, std::vector< G4double > &energies, const eCalculatorProcessing process=kEnergyAndID) const override final
 

Private Attributes

CaloG4::SimulationEnergies m_energyCalculator {}
 
ServiceHandle< ILArCalibCalculatorSvcm_backupCalculator {this, "BackupCalculator", "BarrelCryostatCalibrationLArCalculator"}
 

Detailed Description

Definition at line 44 of file LArG4Barrel/src/CryostatCalibrationMixedCalculator.h.

Constructor & Destructor Documentation

◆ CalibrationMixedCalculator()

LArG4::BarrelCryostat::CalibrationMixedCalculator::CalibrationMixedCalculator ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Definition at line 39 of file CryostatCalibrationMixedCalculator.cxx.

40  : LArCalibCalculatorSvcImp(name, pSvcLocator)
41  {
42  }

◆ ~CalibrationMixedCalculator()

virtual LArG4::BarrelCryostat::CalibrationMixedCalculator::~CalibrationMixedCalculator ( )
virtualdefault

Member Function Documentation

◆ initialize()

StatusCode LArG4::BarrelCryostat::CalibrationMixedCalculator::initialize ( )
finaloverride

Definition at line 44 of file CryostatCalibrationMixedCalculator.cxx.

44  {
45  // Get a "backup" calculator.
46  ATH_CHECK(m_backupCalculator.retrieve());
47  return StatusCode::SUCCESS;
48  }

◆ Process()

G4bool LArG4::BarrelCryostat::CalibrationMixedCalculator::Process ( const G4Step *  step,
LArG4Identifier identifier,
std::vector< G4double > &  energies,
const eCalculatorProcessing  process = kEnergyAndID 
) const
finaloverridevirtual

Definition at line 68 of file CryostatCalibrationMixedCalculator.cxx.

71  {
72  // Use the calculators to determine the energies and the
73  // identifier associated with this G4Step. Note that the
74  // default is to process both the energy and the ID.
75 
76  if ( process == kEnergyAndID || process == kOnlyEnergy ) {
77  m_energyCalculator.Energies( step, energies );
78  }
79  else {
80  for (unsigned int i=0; i != 4; i++) energies.push_back( 0. );
81  }
82 
83  identifier.clear();
84  if ( process == kEnergyAndID || process == kOnlyID )
85  {
86  // Calculate the identifier.
87 
88  // Note:
89  // LArG4::BarrelCryostat::CryostatCalibrationCalculator uses
90  // a table-based approach to determine the identifier. The
91  // following code uses an "if-statement" approach.
92 
93  // The fixed parameters (only a couple of which are readily
94  // accessible from the database):
95 
96  constexpr double oneOverDeta = 10.; // 1/Deta = 1./0.1 = 10.
97  constexpr double oneOverDphi = 32./M_PI; // 1/Dphi
98 
99  // Calculate the mid-point of the step, and the simple geometry variables.
100  G4VPhysicalVolume* physical = step->GetPreStepPoint()->GetPhysicalVolume();
101  //G4int copyNumber = physical->GetCopyNo();
102  G4String volumeName = physical->GetLogicalVolume()->GetName();
103 
104  G4StepPoint* pre_step_point = step->GetPreStepPoint();
105  G4StepPoint* post_step_point = step->GetPostStepPoint();
106 
107  G4ThreeVector startPoint = pre_step_point->GetPosition();
108  G4ThreeVector endPoint = post_step_point->GetPosition();
109  G4ThreeVector p = (startPoint + endPoint) * 0.5;
110 
111  G4double rho = p.perp();
112  G4double eta = fabs( p.pseudoRapidity() );
113  G4double phi = p.phi();
114  if ( phi < 0. ) phi += 2.*M_PI; // Normalize for phiBin calculation
115 
116  // Initialize identifier variables with (invalid) default
117  // values (INT_MIN is defined in <climits>).
118  G4int sampling = INT_MIN;
119  G4int region = INT_MIN;
120  G4int etaBin = INT_MIN;
121  // subdet = +/-4 "+" or " -" according to sign of Z in World coorinate
122  G4int subdet = ( p.z() > 0.) ? 4 : -4;
123  G4int type = 1;
124  G4int phiBin = (int) ( phi * oneOverDphi );
125  if (phiBin>63) phiBin=0;
126 
127  constexpr double rho12 = 1386.+10.; // use old hardcoded 1386 for Sampling 1-2 transition
128  // and add 10mm for safety (misalignment)
129 
130  if ( eta < 1.0 )
131  {
132  if ( rho < rho12) // LAr::Barrel::Cryostat::OuterWall
133  {
134  sampling = 1;
135  region = 1;
136  etaBin = (int) ( eta * oneOverDeta );
137  }
138  else
139  {
140  sampling = 2;
141  region = 0;
142  etaBin = (int) ( eta * oneOverDeta );
143  }
144  }
145  else if ( eta < 1.5 )
146  {
147  if ( rho < rho12) // LAr::Barrel::Cryostat::OuterWall
148  {
149  sampling = 1;
150  region = 1;
151  etaBin = (int) ( eta * oneOverDeta );
152  }
153  else
154  {
155  sampling = 2;
156  region = 2;
157  etaBin = (int) ( (eta-1.) * oneOverDeta );
158  }
159  }
160  else if ( eta < 1.6 )
161  {
162  sampling = 1;
163  region = 4;
164  etaBin = (int) ( (eta-1.5) * oneOverDeta );
165  }
166  else if ( eta < 1.8 )
167  {
168  sampling = 1;
169  region = 5;
170  etaBin = (int) ( (eta-1.5) * oneOverDeta );
171  }
172  else
173  {
174  sampling = 1;
175  region = 6;
176  etaBin = (int) ( (eta-1.3) * oneOverDeta );
177  }
178 
179  // What if we have a G4Step that isn't handled by the above
180  // code? Answer: Use a "backup" calculator to try to
181  // process the step.
182 
183  if ( type == INT_MIN ||
184  region == INT_MIN ||
185  sampling == INT_MIN ||
186  etaBin == INT_MIN ||
187  phiBin < 0 )
188  {
189 #if defined (DEBUG_VOLUMES) || defined (DEBUG_HITS)
190  constexpr G4int messageMax = 10;
191  static std::atomic<G4int> messageCount = 0;
192  if ( messageCount++ < messageMax )
193  {
194  std::cout << "LArG4::BarrelCryostat::CalibrationMixedCalculator::Process"
195  << " (error " << messageCount << " of " << messageMax << " max displayed)"
196  << std::endl
197  << " G4Step in '"
198  << step->GetPreStepPoint()->GetPhysicalVolume()->GetName()
199  << "', using backup calculator"
200  << std::endl;
201  }
202 #endif
203  m_backupCalculator->Process(step, identifier, energies, process);
204  }
205  else
206  {
207  // Append the cell ID to the (empty) identifier.
208  identifier << 10 // Calorimeter
209  << subdet // LAr +/-4 where "+" or " -" according to
210  // the sign of Z in World coorinate
211  << type
212  << sampling
213  << region
214  << etaBin
215  << phiBin;
216  }
217  }
218 
219 #ifdef DEBUG_HITS
220  G4double energy = accumulate(energies.begin(),energies.end(),0.);
221  std::cout << "LArG4::BarrelCryostat::CalibrationMixedCalculator::Process"
222  << " ID=" << std::string(identifier)
223  << " energy=" << energy
224  << " energies=(" << energies[0]
225  << "," << energies[1]
226  << "," << energies[2]
227  << "," << energies[3] << ")"
228  << std::endl;
229 #endif
230 
231  // Check for bad result.
232  return ( identifier != LArG4Identifier() );
233  }

Member Data Documentation

◆ m_backupCalculator

ServiceHandle<ILArCalibCalculatorSvc> LArG4::BarrelCryostat::CalibrationMixedCalculator::m_backupCalculator {this, "BackupCalculator", "BarrelCryostatCalibrationLArCalculator"}
private

◆ m_energyCalculator

CaloG4::SimulationEnergies LArG4::BarrelCryostat::CalibrationMixedCalculator::m_energyCalculator {}
private

The documentation for this class was generated from the following files:
CaloG4::SimulationEnergies::Energies
void Energies(const G4Step *, std::vector< G4double > &) const
The simple method to call from a calibration calculator: Examine the G4Step and return the energies r...
LArG4Identifier
Definition: LArG4Identifier.h:121
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
LArG4::kOnlyEnergy
@ kOnlyEnergy
Definition: LArG4EnumDefs.h:10
M_PI
#define M_PI
Definition: ActiveFraction.h:11
xAOD::identifier
identifier
Definition: UncalibratedMeasurement_v1.cxx:15
SUSY_SimplifiedModel_PostInclude.process
string process
Definition: SUSY_SimplifiedModel_PostInclude.py:43
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
LArG4::BarrelCryostat::CalibrationMixedCalculator::m_backupCalculator
ServiceHandle< ILArCalibCalculatorSvc > m_backupCalculator
Definition: LArG4Barrel/src/CryostatCalibrationMixedCalculator.h:69
xAOD::etaBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap etaBin
Definition: L2StandAloneMuon_v1.cxx:149
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
lumiFormat.i
int i
Definition: lumiFormat.py:85
LArCalibCalculatorSvcImp::LArCalibCalculatorSvcImp
LArCalibCalculatorSvcImp(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArCalibCalculatorSvcImp.cxx:7
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LArG4::kOnlyID
@ kOnlyID
Definition: LArG4EnumDefs.h:10
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
xAOD::phiBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setPhiMap phiBin
Definition: L2StandAloneMuon_v2.cxx:145
runIDAlign.accumulate
accumulate
Update flags based on parser line args.
Definition: runIDAlign.py:107
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
LArG4::BarrelCryostat::CalibrationMixedCalculator::m_energyCalculator
CaloG4::SimulationEnergies m_energyCalculator
Definition: LArG4Barrel/src/CryostatCalibrationMixedCalculator.h:67
LArCellBinning.step
step
Definition: LArCellBinning.py:158
LArG4::kEnergyAndID
@ kEnergyAndID
Definition: LArG4EnumDefs.h:10
fitman.rho
rho
Definition: fitman.py:532