Public Member Functions | Private Attributes | List of all members
gar::rosim::ElectronDriftStandardAlg Class Reference

#include <ElectronDriftStandardAlg.h>

Inheritance diagram for gar::rosim::ElectronDriftStandardAlg:
gar::rosim::ElectronDriftAlg

Public Member Functions

 ElectronDriftStandardAlg (CLHEP::HepRandomEngine &engine, fhicl::ParameterSet const &pset)
 
virtual ~ElectronDriftStandardAlg ()
 
void DriftElectronsToReadout (gar::sdp::EnergyDeposit const &dep, gar::rosim::ElectronDriftInfo &driftInfo)
 
- Public Member Functions inherited from gar::rosim::ElectronDriftAlg
 ElectronDriftAlg (CLHEP::HepRandomEngine &engine, fhicl::ParameterSet const &pset)
 
virtual ~ElectronDriftAlg ()
 

Private Attributes

int fElectronsPerCluster
 Number of electrons to drift in a cluster. More...
 
size_t fMinClusters
 Minimum number of clusters for diffusion integral. More...
 
gar::detinfo::ElecClock fClock
 electronics clock More...
 
const gar::detinfo::DetectorClocksfTime
 electronics clock More...
 
const gar::geo::GeometryCorefGeo
 Geometry. More...
 

Additional Inherited Members

- Protected Attributes inherited from gar::rosim::ElectronDriftAlg
double fDriftVelocity
 electron drift velocity More...
 
double fInverseVelocity
 stored for computational convenience More...
 
double fLifetimeCorrection
 electron lifetime correction in negative ms More...
 
double fLongitudinalDiffusion
 diffusion along the drift in microns/sqrt(cm) More...
 
double fLongDiffConst
 stored for computational convenience in sqrt(cm) More...
 
double fTransverseDiffusion
 diffusion transverse to the drift in microns/sqrt(cm) More...
 
double fTransDiffConst
 stored for computational convenience in sqrt(cm) More...
 
double fFanoFactor
 Fano factor. More...
 
CLHEP::HepRandomEngine & fEngine
 random number engine More...
 

Detailed Description

Definition at line 27 of file ElectronDriftStandardAlg.h.

Constructor & Destructor Documentation

gar::rosim::ElectronDriftStandardAlg::ElectronDriftStandardAlg ( CLHEP::HepRandomEngine &  engine,
fhicl::ParameterSet const &  pset 
)

Definition at line 21 of file ElectronDriftStandardAlg.cxx.

23  : ElectronDriftAlg(engine, pset)
24  {
25  fElectronsPerCluster = pset.get<int>("ElectronsPerCluster");
26  fMinClusters = pset.get<size_t>("MinClusters");
27 
28  // get service providers
29  fGeo = gar::providerFrom<geo::GeometryGAr>();
30  fTime = gar::providerFrom<detinfo::DetectorClocksServiceGAr>();
31  fClock = fTime->TPCClock();
32 
33  }
int fElectronsPerCluster
Number of electrons to drift in a cluster.
gar::detinfo::ElecClock fClock
electronics clock
const gar::detinfo::DetectorClocks * fTime
electronics clock
size_t fMinClusters
Minimum number of clusters for diffusion integral.
ElectronDriftAlg(CLHEP::HepRandomEngine &engine, fhicl::ParameterSet const &pset)
const gar::geo::GeometryCore * fGeo
Geometry.
gar::rosim::ElectronDriftStandardAlg::~ElectronDriftStandardAlg ( )
virtual

Definition at line 36 of file ElectronDriftStandardAlg.cxx.

37  {
38  }

Member Function Documentation

void gar::rosim::ElectronDriftStandardAlg::DriftElectronsToReadout ( gar::sdp::EnergyDeposit const &  dep,
gar::rosim::ElectronDriftInfo driftInfo 
)
virtual

Implements gar::rosim::ElectronDriftAlg.

Definition at line 41 of file ElectronDriftStandardAlg.cxx.

43  {
44  // Reset the Ionization and Scintillation calculator for this step
46 
47  // figure out how many electrons were ionized in the step
48  // if none, just return the empty vector
50 
51  if (electrons <= 0) return;
52 
53  // We need a random number thrower for the diffusion, etc
54  CLHEP::RandGauss GaussRand(fEngine);
55 
56  double g4time = dep.Time();
57 
58  // the XYZ position of the midpoint has to be drifted to the readout,
59  // use the diffusion coefficients to decide where the electrons end up
60  float xyz[3] = {dep.X(),
61  dep.Y(),
62  dep.Z()};
63 
64  MF_LOG_DEBUG("ElectronDriftStandardAlg::DriftElectronsToReadout") << "energy deposition: "
65  << dep.X() << " " << dep.Y() << " " << dep.Z() << std::endl;
66 
67  // The geometry has x = TPCXCent() at the cathode plane. Compute the drift time for a two-drift-volume
68  // TPC. If we only have one drift volume, need to get that information here.
69 
70  double driftD = std::abs(std::abs(xyz[0] - fGeo->TPCXCent()) - fGeo->TPCLength()/2.0); // assume cathode is at x=TPXCent
71  if (fGeo->TPCNumDriftVols() == 1)
72  {
73  driftD = std::max(0.0, fGeo->TPCLength()/2.0 - (xyz[0] - fGeo->TPCXCent()));
74  }
75  double driftT = driftD * fInverseVelocity; // in cm
76  double sqrtDriftD = std::sqrt(driftD);
77  double lifetimeCorr = std::exp(driftT / fLifetimeCorrection);
78 
79  // how many electrons do we expect to make it to the readout?
80  float nElectrons = electrons * lifetimeCorr;
81  size_t nClusters = (size_t)std::ceil(nElectrons / fElectronsPerCluster);
82  nClusters = std::min( (size_t) std::ceil(nElectrons),std::max(nClusters,fMinClusters));
83  int ourelectronspercluster = nearbyint(nElectrons/nClusters);
84 
85  // drift them in sets. The X(Y)(Z)Diff vectors contain the additional
86  // distance to add to the step midpoint to account for diffusion.
87  std::vector<double> XDiff(nClusters, 0.);
88  std::vector<double> YDiff(nClusters, 0.);
89  std::vector<double> ZDiff(nClusters, 0.);
90  std::vector<double> TDiff(nClusters, 0.);
91  std::vector<int > nElec(nClusters, ourelectronspercluster);
92 
93  // the last cluster may have fewer electrons than the configured amount
94  nElec.back() = nearbyint(nElectrons - (nClusters - 1) * ourelectronspercluster);
95 
96  double longDiffSigma = sqrtDriftD * fLongDiffConst;
97  double transDiffSigma = sqrtDriftD * fTransDiffConst;
98 
99  GaussRand.fireArray(nClusters, &XDiff[0], 0., longDiffSigma);
100  GaussRand.fireArray(nClusters, &YDiff[0], 0., transDiffSigma);
101  GaussRand.fireArray(nClusters, &ZDiff[0], 0., transDiffSigma);
102 
103  // set the times and the positions of each cluster
104  for(size_t c = 0; c < nClusters; ++c){
105  TDiff[c] = g4time + driftT + XDiff[c] * fInverseVelocity;
106  XDiff[c] = xyz[0];
107  YDiff[c] += xyz[1];
108  ZDiff[c] += xyz[2];
109 
110  MF_LOG_DEBUG("ElectronDriftStandardAlg::DriftElectronsToReadout")
111  << "g4 time: "
112  << g4time
113  << " drift time "
114  << driftT
115  << " diffusion x:"
116  << XDiff[c]
117  << " y "
118  << YDiff[c]
119  << " z "
120  << ZDiff[c]
121  << " t "
122  << TDiff[c]
123  << " tick period "
124  << fTime->TPCClock().TickPeriod();
125 
126  }
127 
128  // reset the ElectronDriftInfo object with this information
129  driftInfo.Reset(XDiff, YDiff, ZDiff, TDiff, nElec);
130 
131  return;
132  }
double fInverseVelocity
stored for computational convenience
void Reset(std::vector< double > &xPos, std::vector< double > &yPos, std::vector< double > &zPos, std::vector< double > &time, std::vector< int > &size)
int TPCNumDriftVols() const
Returns number of TPC drift volumes.
Definition: GeometryCore.h:771
void Reset(const gar::sdp::EnergyDeposit *dep)
double fLongDiffConst
stored for computational convenience in sqrt(cm)
float TPCXCent() const
Returns the X location of the center of the TPC in cm.
Definition: GeometryCore.h:778
int fElectronsPerCluster
Number of electrons to drift in a cluster.
double TickPeriod() const
A single tick period in nano-second, frequency is in MHz.
Definition: ElecClock.h:125
T abs(T value)
CLHEP::HepRandomEngine & fEngine
random number engine
const gar::detinfo::DetectorClocks * fTime
electronics clock
double fLifetimeCorrection
electron lifetime correction in negative ms
static int max(int a, int b)
static IonizationAndScintillation * Instance()
size_t fMinClusters
Minimum number of clusters for diffusion integral.
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
double fTransDiffConst
stored for computational convenience in sqrt(cm)
#define MF_LOG_DEBUG(id)
virtual const ElecClock & TPCClock() const =0
Borrow a const TPC clock with time set to Trigger time [ns].
float TPCLength() const
Returns the length of the TPC (x direction)
Definition: GeometryCore.h:763
const gar::geo::GeometryCore * fGeo
Geometry.
QTextStream & endl(QTextStream &s)

Member Data Documentation

gar::detinfo::ElecClock gar::rosim::ElectronDriftStandardAlg::fClock
private

electronics clock

Definition at line 42 of file ElectronDriftStandardAlg.h.

int gar::rosim::ElectronDriftStandardAlg::fElectronsPerCluster
private

Number of electrons to drift in a cluster.

Definition at line 40 of file ElectronDriftStandardAlg.h.

const gar::geo::GeometryCore* gar::rosim::ElectronDriftStandardAlg::fGeo
private

Geometry.

Definition at line 44 of file ElectronDriftStandardAlg.h.

size_t gar::rosim::ElectronDriftStandardAlg::fMinClusters
private

Minimum number of clusters for diffusion integral.

Definition at line 41 of file ElectronDriftStandardAlg.h.

const gar::detinfo::DetectorClocks* gar::rosim::ElectronDriftStandardAlg::fTime
private

electronics clock

Definition at line 43 of file ElectronDriftStandardAlg.h.


The documentation for this class was generated from the following files: