LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
IonizationAndScintillation.cxx
Go to the documentation of this file.
1 
7 // lar includes
12 
13 // ROOT includes
14 
15 // Framework includes
16 #include "cetlib_except/exception.h"
21 
22 // C/C++ standard libraries
23 #include <cassert>
24 
25 namespace larg4 {
26 
28 
29  //......................................................................
31  (CLHEP::HepRandomEngine& engine)
32  {
33  if(!gInstance) gInstance = new IonizationAndScintillation(engine);
34  return gInstance;
35  }
36 
37  //......................................................................
39  {
40  // the instance must have been created already by CreateInstance()
41  assert(gInstance);
42  return gInstance;
43  }
44 
45  //......................................................................
46  // Constructor.
48  (CLHEP::HepRandomEngine& engine)
49  : fISCalc(0)
50  , fStep(0)
52  , fStepSize(0)
53  , fPhotonsPerStep(0)
54  , fEnergyPerStep(0)
56  , fEngine(engine)
57  {
60 
61  if(fISCalculator.compare("NEST") == 0)
63  else if(fISCalculator.compare("Separate") == 0)
65  else
66  mf::LogWarning("IonizationAndScintillation") << "No ISCalculation set, this can't be good.";
67 
68  // Reset the values for the electrons, photons, and energy to 0
69  // in the calculator
70  fISCalc->Reset();
71  //set the current track and step number values to bogus so that it will run the first reset:
72  fStepNumber=-1;
73  fTrkID=-1;
74 
75  // initialize the calculator
77 
78  // make the histograms
80 
81  fElectronsPerStep = tfs->make<TH1F>("electronsPerStep", ";Electrons;Steps",
82  500, 0., 5000.);
83  fPhotonsPerStep = tfs->make<TH1F>("photonsPerStep", ";Photons;Steps",
84  500, 0., 5000.);
85  fEnergyPerStep = tfs->make<TH1F>("energyPerStep", ";Energy (MeV);Steps",
86  100, 0., 0.5);
87  fStepSize = tfs->make<TH1F>("stepSize", ";Step Size (CLHEP::cm);Steps",
88  500, 0., 0.2);
89  fElectronsPerLength = tfs->make<TH1F>("electronsPerLength", ";Electrons #times 10^{3}/CLHEP::cm;Steps",
90  1000, 0., 1000.);
91  fPhotonsPerLength = tfs->make<TH1F>("photonsPerLength", ";Photons #times 10^{3}/CLHEP::cm;Steps",
92  1000, 0., 1000.);
93  fElectronsPerEDep = tfs->make<TH1F>("electronsPerEDep", ";Electrons #times 10^{3}/MeV;Steps",
94  1000, 0., 1000.);
95  fPhotonsPerEDep = tfs->make<TH1F>("photonsPerEDep", ";Photons #times 10^{3}/MeV;Steps",
96  1000, 0., 1000.);
97 
98  fElectronsVsPhotons = tfs->make<TH2F>("electronsVsPhotons", ";Photons;Electrons",
99  500, 0., 5000., 500, 0., 5000.);
100 
101  return;
102  }
103 
104  //......................................................................
106  {
107  if(fISCalc) delete fISCalc;
108  }
109 
110 
111  //......................................................................
112  void IonizationAndScintillation::Reset(const G4Step* step)
113  {
114 
115  if(fStepNumber==step->GetTrack()->GetCurrentStepNumber() && fTrkID==step->GetTrack()->GetTrackID())
116  return;
117 
118  fStepNumber=step->GetTrack()->GetCurrentStepNumber();
119  fTrkID=step->GetTrack()->GetTrackID();
120 
121  fStep = step;
122 
123  // reset the calculator
124  fISCalc->Reset();
125 
126  // check the material for this step and be sure it is LAr
127  if(step->GetTrack()->GetMaterial()->GetName() != "LAr") return;
128 
129  // double check that the energy deposit is non-zero
130  // then do the calculation if it is
131  if( step->GetTotalEnergyDeposit() > 0 ){
132 
134 
135  LOG_DEBUG("IonizationAndScintillation") << "Step Size: " << fStep->GetStepLength()/CLHEP::cm
136  << "\nEnergy: " << fISCalc->EnergyDeposit()
137  << "\nElectrons: " << fISCalc->NumberIonizationElectrons()
138  << "\nPhotons: " << fISCalc->NumberScintillationPhotons();
139 
140  G4ThreeVector totstep = fStep->GetPostStepPoint()->GetPosition();
141  totstep -= fStep->GetPreStepPoint()->GetPosition();
142 
143  // Fill the histograms
144  fStepSize ->Fill(totstep.mag()/CLHEP::cm);
150  double const stepSize = totstep.mag()/CLHEP::cm;
151  if (stepSize > 0.0) {
152  fElectronsPerLength->Fill(fISCalc->NumberIonizationElectrons()*1.e-3/stepSize);
153  fPhotonsPerLength ->Fill(fISCalc->NumberScintillationPhotons()*1.e-3/stepSize);
154  }
155  double const energyDep = fISCalc->EnergyDeposit();
156  if (energyDep) {
157  fElectronsPerEDep ->Fill(fISCalc->NumberIonizationElectrons()*1.e-3/energyDep);
158  fPhotonsPerEDep ->Fill(fISCalc->NumberScintillationPhotons()*1.e-3/energyDep);
159  }
160 
161  } // end if the energy deposition is non-zero
162 
163  return;
164  }
165 
166 } // namespace
Store parameters for running LArG4.
TH1F * fPhotonsPerEDep
histogram of photons per MeV deposited
TH1F * fElectronsPerEDep
histogram of electrons per MeV deposited
virtual void Initialize()=0
virtual void CalculateIonizationAndScintillation(const G4Step *step)=0
Geant4 interface.
const std::string IonAndScintCalculator() const
Interface to algorithm class for a specific calculation of ionization electrons and scintillation pho...
G4Step const * fStep
pointer to the current G4 step
TH1F * fElectronsPerLength
histogram of electrons per cm
double NumberScintillationPhotons() const
Definition: ISCalculation.h:31
double NumberIonizationElectrons() const
Definition: ISCalculation.h:30
Interface to algorithm class for a specific calculation of ionization electrons and scintillation pho...
virtual void Reset()=0
CLHEP::HepRandomEngine & fEngine
random engine
static IonizationAndScintillation * Instance()
static IonizationAndScintillation * CreateInstance(CLHEP::HepRandomEngine &engine)
TH1F * fStepSize
histogram of the step sizes
TH1F * fElectronsPerStep
histogram of electrons per step
double EnergyDeposit() const
Definition: ISCalculation.h:29
T * make(ARGS...args) const
TH1F * fPhotonsPerStep
histogram of the photons per step
Singleton to access a unified treatment of ionization and scintillation in LAr.
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
TH1F * fEnergyPerStep
histogram of the energy deposited per step
#define LOG_DEBUG(id)
TH1F * fPhotonsPerLength
histogram of photons per cm
TH2F * fElectronsVsPhotons
histogram of electrons vs photons per step
IonizationAndScintillation(CLHEP::HepRandomEngine &engine)
std::string fISCalculator
name of calculator to use, NEST or Separate
static IonizationAndScintillation * gInstance