ATLAS Offline Software
LArBarrelCalibrationCalculator.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /********************************************************************
6 
7 NAME: CalibrationCalculator.cxx
8 PACKAGE: offline/LArCalorimeter/LArG4/LArG4Barrel
9 
10 AUTHORS: G. Unal, L. Carminati (on a template from Bill Selingman)
11 CREATED: September, 2004
12 
13 PURPOSE: This class calculates the values needed for calibration hits
14  in the barrel LAr calorimeter. This calculator is called
15  in calibration runs (see LArBarrelSDConsultant) for calibration
16  hits in the accordion (no presampler).
17 
18 UPDATES:
19 
20 ********************************************************************/
21 
22 //#define DEBUG_HITS
23 
25 
27 
28 #include "G4Step.hh"
29 #include "globals.hh"
30 #include <algorithm>
31 
32 namespace LArG4 {
33 
34  namespace Barrel {
35 
36  CalibrationCalculator::CalibrationCalculator(const std::string& name, ISvcLocator *pSvcLocator)
37  : LArCalibCalculatorSvcImp(name, pSvcLocator)
38  , m_geometryCalculator("LArBarrelGeometry", name)
39  {
40  declareProperty("GeometryCalculator", m_geometryCalculator);
41  }
42 
44  // Initialize the geometry calculator.
45  ATH_CHECK(m_geometryCalculator.retrieve());
46  return StatusCode::SUCCESS;
47  }
48 
49  CalibrationCalculator::~CalibrationCalculator()
50  {
51  }
52 
53 
54  G4bool CalibrationCalculator::Process(const G4Step* step, LArG4Identifier & identifier,
55  std::vector<G4double> & energies,
56  const eCalculatorProcessing process) const
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 #ifdef DEBUG_HITS
65  std::cout << "LArG4::Barrel::CalibrationCalculator::Process"
66  << " calling SimulationEnergies" << std::endl;
67 #endif
68  m_energyCalculator.Energies( step, energies );
69 
70  // First, get the energy.
71  // m_energy = step->GetTotalEnergyDeposit();
72  }
73  else
74  for (unsigned int i=0; i != 4; i++) energies.push_back( 0. );
75 
76 
77  if ( process == kEnergyAndID || process == kOnlyID )
78  {
79  // Calculate the identifier.
80  identifier = m_geometryCalculator->CalculateIdentifier( step );
81  }
82  else
84 
85 
86 #ifdef DEBUG_HITS
87  G4double energy = accumulate(energies.begin(),energies.end(),0.);
88  std::cout << "LArG4::Barrel::CalibrationCalculator::Process"
89  << " ID=" << std::string(identifier)
90  << " energy=" << energy
91  << " energies=(" << energies[0]
92  << "," << energies[1]
93  << "," << energies[2]
94  << "," << energies[3] << ")"
95  << std::endl;
96 #endif
97 
98  // Check for bad result.
99  if ( identifier == LArG4Identifier() )
100  return false;
101 
102  return true;
103  }
104 
105  } // namespace Barrel
106 
107 } // namespace LAr
LArG4Identifier
Definition: LArG4Identifier.h:121
LArCalibCalculatorSvcImp
Definition: LArCalibCalculatorSvcImp.h:12
initialize
void initialize()
Definition: run_EoverP.cxx:894
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
xAOD::identifier
identifier
Definition: UncalibratedMeasurement_v1.cxx:15
LArG4
Definition: LArWheelCalculatorEnums.h:8
LArBarrelCalibrationCalculator.h
SUSY_SimplifiedModel_PostInclude.process
string process
Definition: SUSY_SimplifiedModel_PostInclude.py:42
DetType::Barrel
@ Barrel
Definition: DetType.h:14
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
lumiFormat.i
int i
Definition: lumiFormat.py:92
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LArG4::kOnlyID
@ kOnlyID
Definition: LArG4EnumDefs.h:10
LArG4Identifier.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
LArG4::Barrel::CalibrationCalculator::CalibrationCalculator
CalibrationCalculator(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArBarrelCalibrationCalculator.cxx:66
LArCellBinning.step
step
Definition: LArCellBinning.py:158
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
LArG4::kEnergyAndID
@ kEnergyAndID
Definition: LArG4EnumDefs.h:10
LArG4::eCalculatorProcessing
eCalculatorProcessing
Definition: LArG4EnumDefs.h:10