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

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  , m_parameters(nullptr)
43  , m_defaultCalculator("CalibrationDefaultCalculator",name)
44  {
45  declareProperty("DefaultCalculator",m_defaultCalculator);
46  }

◆ ~CalibrationLArCalculator()

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

Definition at line 58 of file CryostatCalibrationLArCalculator.cxx.

59  {
60  // Cleanup pointers.
61  //delete m_defaultCalculator;
62  //m_defaultCalculator = 0;
63  }

Member Function Documentation

◆ initialize()

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

Definition at line 48 of file CryostatCalibrationLArCalculator.cxx.

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

◆ Process()

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

Definition at line 65 of file CryostatCalibrationLArCalculator.cxx.

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

Member Data Documentation

◆ m_defaultCalculator

ServiceHandle<ILArCalibCalculatorSvc> LArG4::BarrelCryostat::CalibrationLArCalculator::m_defaultCalculator
private

◆ m_energyCalculator

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

◆ m_parameters

const LArVG4DetectorParameters* LArG4::BarrelCryostat::CalibrationLArCalculator::m_parameters
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
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
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::etaBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap etaBin
Definition: L2StandAloneMuon_v1.cxx:148
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
lumiFormat.i
int i
Definition: lumiFormat.py:92
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:195
xAOD::phiBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setPhiMap phiBin
Definition: L2StandAloneMuon_v2.cxx:144
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
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
LArCellBinning.step
step
Definition: LArCellBinning.py:158
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
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