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 ()
 
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
 

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  , m_backupCalculator("BarrelCryostatCalibrationLArCalculator",name)
42  {
43  declareProperty("BackupCalculator", m_backupCalculator);
44  }

◆ ~CalibrationMixedCalculator()

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

Definition at line 54 of file CryostatCalibrationMixedCalculator.cxx.

55  {
56  // Cleanup pointers.
57  //delete m_backupCalculator;
58  //m_backupCalculator = 0;
59  }

Member Function Documentation

◆ initialize()

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

Definition at line 46 of file CryostatCalibrationMixedCalculator.cxx.

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

◆ Process()

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

Definition at line 79 of file CryostatCalibrationMixedCalculator.cxx.

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

Member Data Documentation

◆ m_backupCalculator

ServiceHandle<ILArCalibCalculatorSvc> LArG4::BarrelCryostat::CalibrationMixedCalculator::m_backupCalculator
private

◆ m_energyCalculator

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

The documentation for this class was generated from the following files:
test_pyathena.eta
eta
Definition: test_pyathena.py:10
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
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
accumulate
bool accumulate(AccumulateMap &map, std::vector< module_t > const &modules, FPGATrackSimMatrixAccumulator const &acc)
Accumulates an accumulator (e.g.
Definition: FPGATrackSimMatrixAccumulator.cxx:22
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:42
xAOD::phi
setEt phi
Definition: TrigEMCluster_v1.cxx:29
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:148
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
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:221
xAOD::phiBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setPhiMap phiBin
Definition: L2StandAloneMuon_v2.cxx:144
LArG4::BarrelCryostat::CalibrationMixedCalculator::m_energyCalculator
CaloG4::SimulationEnergies m_energyCalculator
Definition: LArG4Barrel/src/CryostatCalibrationMixedCalculator.h:67
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
LArCellBinning.step
step
Definition: LArCellBinning.py:158
LArG4::kEnergyAndID
@ kEnergyAndID
Definition: LArG4EnumDefs.h:10
fitman.rho
rho
Definition: fitman.py:532