19 #include "art/Framework/Services/Registry/ServiceHandle.h"
20 #include "art_root_io/TFileService.h"
21 #include "messagefacility/MessageLogger/MessageLogger.h"
26 #include "CLHEP/Units/SystemOfUnits.h"
27 #include "Geant4/G4Step.hh"
36 CLHEP::HepRandomEngine& engine)
55 CLHEP::HepRandomEngine& engine)
58 art::ServiceHandle<sim::LArG4Parameters const> lgp;
59 fISCalculator = lgp->IonAndScintCalculator();
61 if (fISCalculator ==
"Separate")
62 fISCalc = std::make_unique<larg4::ISCalculationSeparate>();
63 else if (fISCalculator ==
"Correlated")
64 fISCalc = std::make_unique<larg4::ISCalculationCorrelated>(
detProp);
65 else if (fISCalculator ==
"NEST")
66 fISCalc = std::make_unique<larg4::ISCalculationNEST>(
fEngine);
68 mf::LogWarning(
"IonizationAndScintillation") <<
"No ISCalculation set, this can't be good.";
78 art::ServiceHandle<art::TFileService const>
tfs;
79 fElectronsPerStep = tfs->make<TH1F>(
"electronsPerStep",
";Electrons;Steps", 500, 0., 5000.);
80 fPhotonsPerStep =
tfs->make<TH1F>(
"photonsPerStep",
";Photons;Steps", 500, 0., 5000.);
81 fEnergyPerStep =
tfs->make<TH1F>(
"energyPerStep",
";Energy (MeV);Steps", 100, 0., 0.5);
82 fStepSize =
tfs->make<TH1F>(
"stepSize",
";Step Size (CLHEP::cm);Steps", 500, 0., 0.2);
83 fElectronsPerLength =
tfs->make<TH1F>(
84 "electronsPerLength",
";Electrons #times 10^{3}/CLHEP::cm;Steps", 1000, 0., 1000.);
85 fPhotonsPerLength =
tfs->make<TH1F>(
86 "photonsPerLength",
";Photons #times 10^{3}/CLHEP::cm;Steps", 1000, 0., 1000.);
88 tfs->make<TH1F>(
"electronsPerEDep",
";Electrons #times 10^{3}/MeV;Steps", 1000, 0., 1000.);
90 tfs->make<TH1F>(
"photonsPerEDep",
";Photons #times 10^{3}/MeV;Steps", 1000, 0., 1000.);
93 tfs->make<TH2F>(
"electronsVsPhotons",
";Photons;Electrons", 500, 0., 5000., 500, 0., 5000.);
101 if (
fStepNumber == step->GetTrack()->GetCurrentStepNumber() &&
102 fTrkID == step->GetTrack()->GetTrackID())
105 fStepNumber = step->GetTrack()->GetCurrentStepNumber();
106 fTrkID = step->GetTrack()->GetTrackID();
113 if (step->GetTrack()->GetMaterial()->GetName() !=
"LAr")
return;
117 if (step->GetTotalEnergyDeposit() > 0) {
121 MF_LOG_DEBUG(
"IonizationAndScintillation")
122 <<
"Step Size: " <<
fStep->GetStepLength() / CLHEP::cm
123 <<
"\nEnergy: " <<
fISCalc->EnergyDeposit()
124 <<
"\nElectrons: " <<
fISCalc->NumberIonizationElectrons()
125 <<
"\nPhotons: " <<
fISCalc->NumberScintillationPhotons();
127 G4ThreeVector totstep =
fStep->GetPostStepPoint()->GetPosition();
128 totstep -=
fStep->GetPreStepPoint()->GetPosition();
131 fStepSize->Fill(totstep.mag() / CLHEP::cm);
136 fISCalc->NumberIonizationElectrons());
137 double const stepSize = totstep.mag() / CLHEP::cm;
138 if (stepSize > 0.0) {
142 double const energyDep =
fISCalc->EnergyDeposit();
Store parameters for running LArG4.
TH1F * fPhotonsPerEDep
histogram of photons per MeV deposited
TH1F * fElectronsPerEDep
histogram of electrons per MeV deposited
int fStepNumber
last StepNumber checked
void Reset(const G4Step *step)
fEngine(art::ServiceHandle< rndm::NuRandomService >() ->createEngine(*this,"HepJamesRandom","ISCalcAlg", pset,"SeedISCalcAlg"))
G4Step const * fStep
pointer to the current G4 step
TH1F * fElectronsPerLength
histogram of electrons per cm
std::unique_ptr< larg4::ISCalculation > fISCalc
Interface to algorithm class for a specific calculation of ionization electrons and scintillation pho...
static IonizationAndScintillation * Instance()
TH1F * fStepSize
histogram of the step sizes
TH1F * fElectronsPerStep
histogram of electrons per step
TH1F * fPhotonsPerStep
histogram of the photons per step
Singleton to access a unified treatment of ionization and scintillation in LAr.
static IonizationAndScintillation * CreateInstance(detinfo::DetectorPropertiesData const &detProp, CLHEP::HepRandomEngine &engine)
TH1F * fEnergyPerStep
histogram of the energy deposited per step
TH1F * fPhotonsPerLength
histogram of photons per cm
art::ServiceHandle< art::TFileService > tfs
TH2F * fElectronsVsPhotons
histogram of electrons vs photons per step
static IonizationAndScintillation * gInstance
int fTrkID
last TrkID checked
IonizationAndScintillation(detinfo::DetectorPropertiesData const &detProp, CLHEP::HepRandomEngine &engine)