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

#include <CryostatCalibrationLArCalculator.h>

Inheritance diagram for LArG4::BarrelCryostat::CalibrationLArCalculator:
Collaboration diagram for LArG4::BarrelCryostat::CalibrationLArCalculator:

Public Member Functions

 CalibrationLArCalculator (const std::string &name, ISvcLocator *pSvcLocator)
 
StatusCode initialize () override final
 
virtual ~CalibrationLArCalculator ()=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 {}
 
const LArVG4DetectorParametersm_parameters {nullptr}
 
ServiceHandle< ILArCalibCalculatorSvcm_defaultCalculator {this, "DefaultCalculator", "CalibrationDefaultCalculator"}
 

Detailed Description

Definition at line 46 of file LArG4Barrel/src/CryostatCalibrationLArCalculator.h.

Constructor & Destructor Documentation

◆ CalibrationLArCalculator()

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

Definition at line 40 of file CryostatCalibrationLArCalculator.cxx.

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

◆ ~CalibrationLArCalculator()

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

Member Function Documentation

◆ initialize()

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

Definition at line 45 of file CryostatCalibrationLArCalculator.cxx.

45  {
46  // Get the default calculator (hopefully a temporary piece of code):
47  ATH_CHECK(m_defaultCalculator.retrieve());
48 
49  // Access source of detector parameters.
51  return StatusCode::SUCCESS;
52  }

◆ Process()

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

Definition at line 54 of file CryostatCalibrationLArCalculator.cxx.

57  {
58  // Use the calculators to determine the energies and the
59  // identifier associated with this G4Step. Note that the
60  // default is to process both the energy and the ID.
61 
62  if ( process == kEnergyAndID || process == kOnlyEnergy )
63  {
64  m_energyCalculator.Energies( step, energies );
65  }
66  else
67  for (unsigned int i=0; i != 4; i++) energies.push_back( 0. );
68 
69 
70  identifier.clear();
71  if ( process == kEnergyAndID || process == kOnlyID )
72  {
73  // Calculate the identifier.
74 
75  // Note:
76  // LArG4::BarrelCryostat::CryostatCalibrationCalculator uses
77  // a table-based approach to determine the identifier. The
78  // following code uses an "if-statement" approach.
79 
80  // The fixed parameters (only a couple of which are readily
81  // accessible from the database):
82 
83  constexpr double oneOverDeta = 10.; // 1/Deta = 1./0.1 = 10.
84  constexpr double oneOverDphi = 32./M_PI; // 1/Dphi
85 
86  constexpr double rhoMinPresamplerMother = 1385.*CLHEP::mm;
87  constexpr double rhoMiddlePresampler = (1385.*CLHEP::mm + 1447.*CLHEP::mm)/2.;
88  // from PresParameterDef.icc
89  // rMinPresamplerMother = 1385*CLHEP::mm;
90  // rMaxPresamplerMother = 1447*CLHEP::mm - 0.001*CLHEP::mm;
91 
92  constexpr double rhoAlignmentSafety = 10.*CLHEP::mm;
93  constexpr double rhoInFrontOfColdWall = rhoMinPresamplerMother - rhoAlignmentSafety;
94  static const double RIN_AC = m_parameters->GetValue("LArEMBRadiusInnerAccordion"); // 1500.024*CLHEP::mm; from ACCG
95  constexpr double RCUT12 = 1593.9*CLHEP::mm;
96  constexpr double RCUT23 = 1866.1*CLHEP::mm;
97  static const double ROUT_AC = m_parameters->GetValue("LArEMBRadiusOuterAccordion"); // 1960.*CLHEP::mm;
98  static const double rhoOuterAccordionWithSafety = ROUT_AC - rhoAlignmentSafety;
99  static const double LArEMBZmax = m_parameters->GetValue("LArEMBZmax"); // 3165.*CLHEP::mm
100 
101  static const double zMaxAccordionWithSafety = LArEMBZmax - 10.*CLHEP::mm;
102 
103 
104  // Calculate the mid-point of the step, and the simple geometry variables.
105 
106  G4StepPoint* pre_step_point = step->GetPreStepPoint();
107  G4StepPoint* post_step_point = step->GetPostStepPoint();
108 
109  G4ThreeVector startPoint = pre_step_point->GetPosition();
110  G4ThreeVector endPoint = post_step_point->GetPosition();
111  G4ThreeVector p = (startPoint + endPoint) * 0.5;
112 
113  G4double rho = p.perp();
114  G4double eta = fabs( p.pseudoRapidity() );
115  G4double phi = p.phi();
116  if ( phi < 0. ) phi += 2.*M_PI; // Normalize for phiBin calculation
117 
118  // subdet = +/-4 "+" or " -" according to sign of Z in World coorinate
119  G4int subdet = ( p.z() > 0.) ? 4 : -4;
120  G4int phiBin = (int) ( phi * oneOverDphi );
121  if (phiBin>63) phiBin=0;
122 
123  // Initialize identifier variables with (invalid) default
124  // values (INT_MIN is defined in <climits>).
125  G4int type = INT_MIN;
126  G4int sampling = INT_MIN;
127  G4int region = INT_MIN;
128  G4int etaBin = INT_MIN;
129 
130 
131  if(std::fabs(p.z())< 10 && eta < 0.1 && rho > rhoMinPresamplerMother && rho < ROUT_AC )
132  {
133  // type = 2 dead materials in "internal" cracks:
134  // real crack for nominal geometry at this level is +-3mm
135  // add some margin to allow for misalignement
136 
137  type = 2;
138 
139  // sampling = 0,1,2,3 (follow the corresponding calorimeter structure)
140  if ( rho < RIN_AC ) { sampling = 0; }
141  else if ( rho < RCUT12 ) { sampling = 1; }
142  else if ( rho < RCUT23 ) { sampling = 2; }
143  else { sampling = 3; }
144 
145  // region = 0 - between two halves of EMB,
146  region = 0;
147  etaBin = 0;
148  }
149  else
150  {
151  // type = 1 dead materials outside accordion and active presampler layers
152  type = 1;
153 
154  if( eta < 1.5 )
155  {
156  if ( rho < rhoInFrontOfColdWall ) // and in LAr::Barrel::MotherVolume
157 
158  // The region is defined correctly for a radial mis-alignments
159  // up to 10mm because ColdWallThickness >= 20mm and
160  // rhoAlignmentSafety = 10.*mm;
161  // The E-deposit in the Cold Wall itself is handled by
162  // another calculator.
163  {
164  sampling = 1;
165  region = 0;
166  etaBin = (int) ( eta * oneOverDeta );
167  }
168  else if ( rho < rhoMiddlePresampler )
169  // The region is defined correctly for a radial mis-alignments
170  // up to (1447.*mm - 1385.*mm)/2
171  // The E-deposit in the Presampler itself is handled by
172  // other calculator.
173  {
174  sampling = 1;
175  region = 2;
176  etaBin = (int) ( eta * oneOverDeta );
177  }
178  else if ( rho < rhoOuterAccordionWithSafety &&
179  fabs( p.z()) < zMaxAccordionWithSafety )
180  // The region is defined correctly for a radial mis-alignments
181  // up to 10mm because rhoAlignmentSafety = 10.*mm;
182  // The E-deposit in the Barrel Accordion itself is handled by
183  // other calculator.
184  {
185  sampling = 1;
186  region = 3;
187  etaBin = (int) ( eta * oneOverDeta );
188  }
189  else // rho > ROUT_AC or |z| >= zMaxAccordionWithSafety
190  {
191  sampling = 2;
192 
193  if( eta < 1.0 )
194  {
195  region = 0;
196  etaBin = (int) ( eta * oneOverDeta );
197  }
198  else // 1.0 <= eta < 1.5
199  {
200  region = 2;
201  etaBin = (int) ( (eta-1.) * oneOverDeta );
202  }
203  }
204  }
205  else if ( eta < 1.6 )
206  {
207  sampling = 1;
208  region = 4;
209  etaBin = (int) ( (eta-1.5) * oneOverDeta );
210  }
211  else if ( eta < 1.8 )
212  {
213  sampling = 1;
214  region = 5;
215  etaBin = (int) ( (eta-1.6) * oneOverDeta );
216  }
217  else if ( eta < 3.2 )
218  {
219  sampling = 1;
220  region = 6;
221  etaBin = (int) ( (eta-1.8) * oneOverDeta );
222  }
223  }
224 
225  // This is a "quick fix" for a complex issue: We're still
226  // developing code for the cryostat. What if, somehow, we have
227  // a G4Step in a LAr volume that isn't handled by the above
228  // code? Answer: Use the default calibration calculator (the
229  // same one used for volumes without sensitive detectors) to get
230  // the identifier.
231 
232  if ( type == INT_MIN ||
233  region == INT_MIN ||
234  sampling == INT_MIN ||
235  etaBin == INT_MIN ||
236  phiBin < 0 )
237  {
238 #if defined (DEBUG_VOLUMES) || defined (DEBUG_HITS)
239  constexpr G4int messageMax = 10;
240  static std::atomic<G4int> messageCount = 0;
241  if ( messageCount++ < messageMax )
242  {
243  std::cout << "LArG4::BarrelCryostat::CalibrationLArCalculator::Process"
244  << " (error " << messageCount << " of " << messageMax << " max displayed)"
245  << std::endl
246  << " G4Step in LAr at unexpected place: (x,y,z) [mm] = ("
247  << p.x()/CLHEP::mm << ","
248  << p.y()/CLHEP::mm << ","
249  << p.z()/CLHEP::mm
250  << "); eta=" << eta
251  << ", phi=" << phi << std::endl
252  << " using default calculator"
253  << std::endl;
254  }
255 #endif
256  m_defaultCalculator->Process(step, identifier, energies, process);
257  }
258  else
259  {
260  // Append the cell ID to the (empty) identifier.
261  identifier << 10 // Calorimeter
262  << subdet // LAr +/-4 where "+" or " -" according to
263  // the sign of Z in World coorinate
264  << type
265  << sampling
266  << region
267  << etaBin
268  << phiBin;
269  }
270  }
271 
272 #ifdef DEBUG_HITS
273  G4double energy = accumulate(energies.begin(),energies.end(),0.);
274  std::cout << "LArG4::BarrelCryostat::CalibrationLArCalculator::Process"
275  << " ID=" << std::string(identifier)
276  << " energy=" << energy
277  << " energies=(" << energies[0]
278  << "," << energies[1]
279  << "," << energies[2]
280  << "," << energies[3] << ")"
281  << std::endl;
282 #endif
283 
284  // Check for bad result.
285  if ( identifier == LArG4Identifier() )
286  return false;
287 
288  return true;
289  }

Member Data Documentation

◆ m_defaultCalculator

ServiceHandle<ILArCalibCalculatorSvc> LArG4::BarrelCryostat::CalibrationLArCalculator::m_defaultCalculator {this, "DefaultCalculator", "CalibrationDefaultCalculator"}
private

◆ m_energyCalculator

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

◆ m_parameters

const LArVG4DetectorParameters* LArG4::BarrelCryostat::CalibrationLArCalculator::m_parameters {nullptr}
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
python.SystemOfUnits.mm
float mm
Definition: SystemOfUnits.py:98
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
xAOD::phi
setEt phi
Definition: TrigEMCluster_v1.cxx:29
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
LArG4::BarrelCryostat::CalibrationLArCalculator::m_energyCalculator
CaloG4::SimulationEnergies m_energyCalculator
Definition: LArG4Barrel/src/CryostatCalibrationLArCalculator.h:69
LArGeo::VDetectorParameters::GetValue
virtual double GetValue(const std::string &, const int i0=INT_MIN, const int i1=INT_MIN, const int i2=INT_MIN, const int i3=INT_MIN, const int i4=INT_MIN) const =0
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
LArG4::BarrelCryostat::CalibrationLArCalculator::m_parameters
const LArVG4DetectorParameters * m_parameters
Definition: LArG4Barrel/src/CryostatCalibrationLArCalculator.h:72
LArG4::BarrelCryostat::CalibrationLArCalculator::m_defaultCalculator
ServiceHandle< ILArCalibCalculatorSvc > m_defaultCalculator
Definition: LArG4Barrel/src/CryostatCalibrationLArCalculator.h:74
runIDAlign.accumulate
accumulate
Update flags based on parser line args.
Definition: runIDAlign.py:60
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
LArCellBinning.step
step
Definition: LArCellBinning.py:158
LArG4::kEnergyAndID
@ kEnergyAndID
Definition: LArG4EnumDefs.h:10
LArGeo::VDetectorParameters::GetInstance
static const VDetectorParameters * GetInstance()
Definition: VDetectorParameters.cxx:29
fitman.rho
rho
Definition: fitman.py:532