LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
detsim::DriftElectronstoPlane Class Reference
Inheritance diagram for detsim::DriftElectronstoPlane:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Types

using ModuleType = EDProducer
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 

Public Member Functions

 DriftElectronstoPlane (fhicl::ParameterSet const &pset)
 
void produce (art::Event &evt) override
 
void beginJob () override
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
void fillProductDescriptions ()
 
void registerProducts (ProductDescriptions &productsToRegister)
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
std::unique_ptr< Worker > makeWorker (WorkerParams const &wp)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Protected Member Functions

ConsumesCollector & consumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Private Attributes

art::InputTag fSimModuleLabel
 
CLHEP::RandGauss fRandGauss
 
bool fStoreDriftedElectronClusters
 
double fLongitudinalDiffusion
 
double fTransverseDiffusion
 
double fElectronClusterSize
 
int fMinNumberOfElCluster
 
double fGeVToElectrons
 
double fRecombA
 
double fRecombk
 
double fModBoxA
 
double fModBoxB
 
bool fUseModBoxRecomb
 
double fElectronLifetime
 
double fLifetimeCorr_const
 
double fLDiff_const
 
double fTDiff_const
 
double fRecipDriftVel [3]
 
size_t fNCryostats
 
std::vector< size_t > fNTPCs
 
std::vector< double > fLongDiff
 
std::vector< double > fTransDiff1
 
std::vector< double > fTransDiff2
 
std::vector< double > fnElDiff
 
std::vector< double > fnEnDiff
 
double fDriftClusterPos [3]
 
art::ServiceHandle< geo::Geometry const > fGeometry
 Handle to the Geometry service. More...
 
ISCalculationSeparate fISAlg
 

Detailed Description

Definition at line 87 of file DriftElectronstoPlane_module.cc.

Member Typedef Documentation

Definition at line 17 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::detail::Producer::Table = Modifier::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 26 of file Producer.h.

Constructor & Destructor Documentation

detsim::DriftElectronstoPlane::DriftElectronstoPlane ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 143 of file DriftElectronstoPlane_module.cc.

References art::detail::EngineCreator::createEngine(), fElectronClusterSize, fGeVToElectrons, fISAlg, fLongitudinalDiffusion, fMinNumberOfElCluster, fModBoxA, fModBoxB, fRandGauss, fRecombA, fRecombk, fSimModuleLabel, fStoreDriftedElectronClusters, fTransverseDiffusion, and fUseModBoxRecomb.

144  : art::EDProducer{pset}
145  , fSimModuleLabel{pset.get<art::InputTag>("SimulationLabel")}
146  // create a default random engine; obtain the random seed from
147  // NuRandomService, unless overridden in configuration with key
148  // "Seed"
150  -> registerAndSeedEngine(createEngine(0), pset, "Seed")}
151  , fStoreDriftedElectronClusters{pset.get<bool>("StoreDriftedElectronClusters", true)}
152  , fLongitudinalDiffusion{pset.get<double>("LongitudinalDiffusion", 6.2e-9)}
153  , fTransverseDiffusion{pset.get<double>("TransverseDiffusion", 16.3e-9)}
154  , fElectronClusterSize{pset.get<double>("ElectronClusterSize", 600.0)}
155  , fMinNumberOfElCluster{pset.get<int>("MinNumberOfElCluster", 0)}
156  , fGeVToElectrons{pset.get<double>("GeVToElectrons", 4.237e+07)}
157  , fRecombA{pset.get<double>("RecombA", 0.800)}
158  , fRecombk{pset.get<double>("Recombk", 0.0486)}
159  , fModBoxA{pset.get<double>("ModBoxA", 0.930)}
160  , fModBoxB{pset.get<double>("ModBoxB", 0.212)}
161  , fUseModBoxRecomb{pset.get<bool>("UseModBoxRecomb", true)}
162  , fISAlg{pset}
163  {
164  if (fStoreDriftedElectronClusters) { produces<std::vector<sim::SimDriftedElectronCluster>>(); }
165  }
base_engine_t & createEngine(seed_t seed)

Member Function Documentation

void detsim::DriftElectronstoPlane::beginJob ( )
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 168 of file DriftElectronstoPlane_module.cc.

References e, fElectronLifetime, fGeometry, fLDiff_const, fLifetimeCorr_const, fLongitudinalDiffusion, fNCryostats, fNTPCs, fRecipDriftVel, fTDiff_const, fTransverseDiffusion, MF_LOG_DEBUG, n, geo::GeometryCore::Ncryostats(), and geo::GeometryCore::NTPC().

169  {
170  // Define the physical constants we'll use.
171 
172  auto const detProp =
175  detProp
176  .ElectronLifetime(); // Electron lifetime as returned by the DetectorProperties service assumed to be in us;
177  for (int i = 0; i < 3; ++i) {
178  double driftVelocity =
179  detProp.DriftVelocity(detProp.Efield(i),
180  detProp.Temperature()) *
181  1.e-3; // Drift velocity as returned by the DetectorProperties service assumed to be in cm/us. Multiply by 1.e-3 to convert into LArSoft standard velocity units, cm/ns;
182 
183  fRecipDriftVel[i] = 1. / driftVelocity;
184  }
185  MF_LOG_DEBUG("DriftElectronstoPlane")
186  << " e lifetime (ns): " << fElectronLifetime
187  << "\n Temperature (K): " << detProp.Temperature()
188  << "\n Drift velocity (cm/ns): " << 1. / fRecipDriftVel[0] << " " << 1. / fRecipDriftVel[1]
189  << " " << 1. / fRecipDriftVel[2];
190 
191  // Opposite of lifetime. Convert from us to standard LArSoft time units, ns;
193  fLDiff_const = std::sqrt(2. * fLongitudinalDiffusion);
194  fTDiff_const = std::sqrt(2. * fTransverseDiffusion);
195 
196  // For this detector's geometry, save the number of cryostats and
197  // the number of TPCs within each cryostat.
199  fNTPCs.resize(fNCryostats);
200  for (size_t n = 0; n < fNCryostats; ++n)
202  }
unsigned int NTPC(CryostatID const &cryoid=cryostat_zero) const
Returns the total number of TPCs in the specified cryostat.
Definition: GeometryCore.h:686
art::ServiceHandle< geo::Geometry const > fGeometry
Handle to the Geometry service.
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
Definition: GeometryCore.h:430
#define MF_LOG_DEBUG(id)
Char_t n[5]
Float_t e
Definition: plot.C:35
The data type to uniquely identify a cryostat.
Definition: geo_types.h:192
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::consumes ( InputTag const &  tag)
protectedinherited

Definition at line 61 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumes().

62  {
63  return collector_.consumes<T, BT>(tag);
64  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ProductToken< T > consumes(InputTag const &)
ConsumesCollector & art::ModuleBase::consumesCollector ( )
protectedinherited

Definition at line 57 of file ModuleBase.cc.

References art::ModuleBase::collector_.

58  {
59  return collector_;
60  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::consumesMany ( )
protectedinherited

Definition at line 75 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesMany().

76  {
77  collector_.consumesMany<T, BT>();
78  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::consumesView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::consumesView ( InputTag const &  tag)
inherited

Definition at line 68 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesView().

69  {
70  return collector_.consumesView<T, BT>(tag);
71  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > consumesView(InputTag const &)
void art::detail::Producer::doBeginJob ( SharedResources const &  resources)
inherited

Definition at line 22 of file Producer.cc.

References art::detail::Producer::beginJobWithFrame(), and art::detail::Producer::setupQueues().

23  {
24  setupQueues(resources);
25  ProcessingFrame const frame{ScheduleID{}};
26  beginJobWithFrame(frame);
27  }
virtual void setupQueues(SharedResources const &)=0
virtual void beginJobWithFrame(ProcessingFrame const &)=0
bool art::detail::Producer::doBeginRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 65 of file Producer.cc.

References art::detail::Producer::beginRunWithFrame(), art::RangeSet::forRun(), art::RunPrincipal::makeRun(), r, art::RunPrincipal::runID(), and art::ModuleContext::scheduleID().

66  {
67  auto r = rp.makeRun(mc, RangeSet::forRun(rp.runID()));
68  ProcessingFrame const frame{mc.scheduleID()};
69  beginRunWithFrame(r, frame);
70  r.commitProducts();
71  return true;
72  }
TRandom r
Definition: spectrum.C:23
virtual void beginRunWithFrame(Run &, ProcessingFrame const &)=0
static RangeSet forRun(RunID)
Definition: RangeSet.cc:51
bool art::detail::Producer::doBeginSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 85 of file Producer.cc.

References art::detail::Producer::beginSubRunWithFrame(), art::RangeSet::forSubRun(), art::SubRunPrincipal::makeSubRun(), art::ModuleContext::scheduleID(), and art::SubRunPrincipal::subRunID().

86  {
87  auto sr = srp.makeSubRun(mc, RangeSet::forSubRun(srp.subRunID()));
88  ProcessingFrame const frame{mc.scheduleID()};
89  beginSubRunWithFrame(sr, frame);
90  sr.commitProducts();
91  return true;
92  }
virtual void beginSubRunWithFrame(SubRun &, ProcessingFrame const &)=0
static RangeSet forSubRun(SubRunID)
Definition: RangeSet.cc:57
void art::detail::Producer::doEndJob ( )
inherited

Definition at line 30 of file Producer.cc.

References art::detail::Producer::endJobWithFrame().

31  {
32  ProcessingFrame const frame{ScheduleID{}};
33  endJobWithFrame(frame);
34  }
virtual void endJobWithFrame(ProcessingFrame const &)=0
bool art::detail::Producer::doEndRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 75 of file Producer.cc.

References art::detail::Producer::endRunWithFrame(), art::RunPrincipal::makeRun(), r, art::ModuleContext::scheduleID(), and art::Principal::seenRanges().

76  {
77  auto r = rp.makeRun(mc, rp.seenRanges());
78  ProcessingFrame const frame{mc.scheduleID()};
79  endRunWithFrame(r, frame);
80  r.commitProducts();
81  return true;
82  }
TRandom r
Definition: spectrum.C:23
virtual void endRunWithFrame(Run &, ProcessingFrame const &)=0
bool art::detail::Producer::doEndSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 95 of file Producer.cc.

References art::detail::Producer::endSubRunWithFrame(), art::SubRunPrincipal::makeSubRun(), art::ModuleContext::scheduleID(), and art::Principal::seenRanges().

96  {
97  auto sr = srp.makeSubRun(mc, srp.seenRanges());
98  ProcessingFrame const frame{mc.scheduleID()};
99  endSubRunWithFrame(sr, frame);
100  sr.commitProducts();
101  return true;
102  }
virtual void endSubRunWithFrame(SubRun &, ProcessingFrame const &)=0
bool art::detail::Producer::doEvent ( EventPrincipal ep,
ModuleContext const &  mc,
std::atomic< std::size_t > &  counts_run,
std::atomic< std::size_t > &  counts_passed,
std::atomic< std::size_t > &  counts_failed 
)
inherited

Definition at line 105 of file Producer.cc.

References art::detail::Producer::checkPutProducts_, e, art::EventPrincipal::makeEvent(), art::detail::Producer::produceWithFrame(), and art::ModuleContext::scheduleID().

110  {
111  auto e = ep.makeEvent(mc);
112  ++counts_run;
113  ProcessingFrame const frame{mc.scheduleID()};
114  produceWithFrame(e, frame);
115  e.commitProducts(checkPutProducts_, &expectedProducts<InEvent>());
116  ++counts_passed;
117  return true;
118  }
bool const checkPutProducts_
Definition: Producer.h:70
Float_t e
Definition: plot.C:35
virtual void produceWithFrame(Event &, ProcessingFrame const &)=0
void art::detail::Producer::doRespondToCloseInputFile ( FileBlock const &  fb)
inherited

Definition at line 44 of file Producer.cc.

References art::detail::Producer::respondToCloseInputFileWithFrame().

45  {
46  ProcessingFrame const frame{ScheduleID{}};
48  }
virtual void respondToCloseInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToCloseOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 58 of file Producer.cc.

References art::detail::Producer::respondToCloseOutputFilesWithFrame().

59  {
60  ProcessingFrame const frame{ScheduleID{}};
62  }
virtual void respondToCloseOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToOpenInputFile ( FileBlock const &  fb)
inherited

Definition at line 37 of file Producer.cc.

References art::detail::Producer::respondToOpenInputFileWithFrame().

38  {
39  ProcessingFrame const frame{ScheduleID{}};
41  }
virtual void respondToOpenInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToOpenOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 51 of file Producer.cc.

References art::detail::Producer::respondToOpenOutputFilesWithFrame().

52  {
53  ProcessingFrame const frame{ScheduleID{}};
55  }
virtual void respondToOpenOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::Modifier::fillProductDescriptions ( )
inherited

Definition at line 10 of file Modifier.cc.

References art::ProductRegistryHelper::fillDescriptions(), and art::ModuleBase::moduleDescription().

11  {
13  }
void fillDescriptions(ModuleDescription const &md)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
std::array< std::vector< ProductInfo >, NumBranchTypes > const & art::ModuleBase::getConsumables ( ) const
inherited

Definition at line 43 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::getConsumables().

44  {
45  return collector_.getConsumables();
46  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables() const
std::unique_ptr< Worker > art::ModuleBase::makeWorker ( WorkerParams const &  wp)
inherited

Definition at line 37 of file ModuleBase.cc.

References art::ModuleBase::doMakeWorker(), and art::NumBranchTypes.

38  {
39  return doMakeWorker(wp);
40  }
virtual std::unique_ptr< Worker > doMakeWorker(WorkerParams const &wp)=0
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::mayConsume ( InputTag const &  tag)
protectedinherited

Definition at line 82 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsume().

83  {
84  return collector_.mayConsume<T, BT>(tag);
85  }
ProductToken< T > mayConsume(InputTag const &)
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::mayConsumeMany ( )
protectedinherited

Definition at line 96 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeMany().

97  {
98  collector_.mayConsumeMany<T, BT>();
99  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::mayConsumeView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::mayConsumeView ( InputTag const &  tag)
inherited

Definition at line 89 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeView().

90  {
91  return collector_.mayConsumeView<T, BT>(tag);
92  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > mayConsumeView(InputTag const &)
ModuleDescription const & art::ModuleBase::moduleDescription ( ) const
inherited

Definition at line 13 of file ModuleBase.cc.

References art::errors::LogicError.

Referenced by art::OutputModule::doRespondToOpenInputFile(), art::OutputModule::doWriteEvent(), art::Modifier::fillProductDescriptions(), art::OutputModule::makePlugins_(), art::OutputWorker::OutputWorker(), reco::shower::LArPandoraModularShowerCreation::produce(), art::Modifier::registerProducts(), and art::OutputModule::registerProducts().

14  {
15  if (md_.has_value()) {
16  return *md_;
17  }
18 
20  "There was an error while calling moduleDescription().\n"}
21  << "The moduleDescription() base-class member function cannot be called\n"
22  "during module construction. To determine which module is "
23  "responsible\n"
24  "for calling it, find the '<module type>:<module "
25  "label>@Construction'\n"
26  "tag in the message prefix above. Please contact artists@fnal.gov\n"
27  "for guidance.\n";
28  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
void detsim::DriftElectronstoPlane::produce ( art::Event evt)
overridevirtual
Todo:
think about effects of drift between planes.
Todo:
think about effects of drift between planes

Implements art::EDProducer.

Definition at line 205 of file DriftElectronstoPlane_module.cc.

References util::abs(), detsim::ISCalculationSeparate::CalculateIonizationAndScintillation(), geo::vect::coord(), DEFINE_ART_MODULE, geo::TPCGeo::DetectDriftDirection(), energy, fDriftClusterPos, fElectronClusterSize, fGeometry, fISAlg, fLDiff_const, fLifetimeCorr_const, fLongDiff, fMinNumberOfElCluster, fnElDiff, fnEnDiff, fRandGauss, fRecipDriftVel, fSimModuleLabel, fStoreDriftedElectronClusters, fTDiff_const, fTransDiff1, fTransDiff2, art::ProductRetriever::getByLabel(), geo::PlaneGeo::GetCenter(), MF_LOG_DEBUG, geo::TPCGeo::Nplanes(), detsim::ISCalculationSeparate::Data::numElectrons, larsim::Utils::SCE::out_of_bounds(), geo::TPCGeo::Plane(), geo::TPCGeo::PlanePitch(), geo::GeometryCore::TPC(), and xx.

206  {
207  // Fetch the SimEnergyDeposit objects for this event.
208  typedef art::Handle<std::vector<sim::SimEnergyDeposit>> energyDepositHandle_t;
209  energyDepositHandle_t energyDepositHandle;
210  // If there aren't any energy deposits for this event, don't
211  // panic. It's possible someone is doing a study with events
212  // outside the TPC, or where there are only non-ionizing
213  // particles, or something like that.
214  if (!event.getByLabel(fSimModuleLabel, energyDepositHandle)) return;
215  // Container for the SimDriftedElectronCluster objects
216  std::unique_ptr<std::vector<sim::SimDriftedElectronCluster>>
217  SimDriftedElectronClusterCollection(new std::vector<sim::SimDriftedElectronCluster>);
218 
219  // We're going through the input vector by index, rather than by
220  // iterator, because we need the index number to compute the
221  // associations near the end of this method.
222  auto const& energyDeposits = *energyDepositHandle;
223  auto energyDepositsSize = energyDeposits.size();
224 
225  auto const detProp =
227  // For each energy deposit in this event
228  for (size_t edIndex = 0; edIndex < energyDepositsSize; ++edIndex) {
229  auto const& energyDeposit = energyDeposits[edIndex];
230 
231  // "xyz" is the position of the energy deposit in world
232  // coordinates. Note that the units of distance in
233  // sim::SimEnergyDeposit are supposed to be cm.
234  auto const mp = energyDeposit.MidPoint();
235  double const xyz[3] = {mp.X(), mp.Y(), mp.Z()};
236 
237  // From the position in world coordinates, determine the
238  // cryostat and tpc. If somehow the step is outside a tpc
239  // (e.g., cosmic rays in rock) just move on to the next one.
240  const geo::TPCGeo& tpcGeo = fGeometry->TPC();
241 
242  // The drift direction can be either in the positive
243  // or negative direction in any coordinate x, y or z.
244  // Charge drift in ...
245  // +x: tpcGeo.DetectDriftDirection()==1
246  // -x: tpcGeo.DetectDriftDirection()==-1
247  // +y: tpcGeo.DetectDriftDirection()==2
248  // -y tpcGeo.DetectDriftDirection()==-2
249  // +z: tpcGeo.DetectDriftDirection()==3
250  // -z: tpcGeo.DetectDriftDirection()==-3
251 
252  //Define charge drift direction: driftcoordinate (x, y or z) and driftsign (positive or negative). Also define coordinates perpendicular to drift direction.
253  int driftcoordinate = std::abs(tpcGeo.DetectDriftDirection()) - 1; //x:0, y:1, z:2
254 
255  int transversecoordinate1 = 0;
256  int transversecoordinate2 = 0;
257  if (driftcoordinate == 0) {
258  transversecoordinate1 = 1;
259  transversecoordinate2 = 2;
260  }
261  else if (driftcoordinate == 1) {
262  transversecoordinate1 = 0;
263  transversecoordinate2 = 2;
264  }
265  else if (driftcoordinate == 2) {
266  transversecoordinate1 = 0;
267  transversecoordinate2 = 1;
268  }
269 
270  if (transversecoordinate1 == transversecoordinate2)
271  continue; //this is the case when driftcoordinate != 0, 1 or 2
272 
273  int driftsign = 0; //1: +x, +y or +z, -1: -x, -y or -z
274  if (tpcGeo.DetectDriftDirection() > 0)
275  driftsign = 1;
276  else
277  driftsign = -1;
278 
279  //Check for charge deposits behind charge readout planes
280  auto const plane_center = tpcGeo.Plane(0).GetCenter();
281  auto const plane_center_coord = geo::vect::coord(plane_center, driftcoordinate);
282  if (driftsign == 1 && plane_center_coord < xyz[driftcoordinate]) continue;
283  if (driftsign == -1 && plane_center_coord > xyz[driftcoordinate]) continue;
284 
286  // Center of plane is also returned in cm units
287  double DriftDistance = std::abs(xyz[driftcoordinate] - plane_center_coord);
288 
289  // Space-charge effect (SCE): Get SCE {x,y,z} offsets for
290  // particular location in TPC
291  geo::Vector_t posOffsets{0.0, 0.0, 0.0};
292  double posOffsetxyz[3] = {
293  0.0, 0.0, 0.0}; //need this array for the driftcoordinate and transversecoordinates
294  auto const* SCE = lar::providerFrom<spacecharge::SpaceChargeService>();
295  if (SCE->EnableSimSpatialSCE() == true) {
296  posOffsets = SCE->GetPosOffsets(mp);
297  if (larsim::Utils::SCE::out_of_bounds(posOffsets)) continue;
298  posOffsetxyz[0] = posOffsets.X();
299  posOffsetxyz[1] = posOffsets.Y();
300  posOffsetxyz[2] = posOffsets.Z();
301  }
302 
303  double avegagetransversePos1 = 0.;
304  double avegagetransversePos2 = 0.;
305 
306  DriftDistance += -1. * posOffsetxyz[driftcoordinate];
307  avegagetransversePos1 = xyz[transversecoordinate1] + posOffsetxyz[transversecoordinate1];
308  avegagetransversePos2 = xyz[transversecoordinate2] + posOffsetxyz[transversecoordinate2];
309 
310  // Space charge distortion could push the energy deposit beyond the wire
311  // plane (see issue #15131). Given that we don't have any subtlety in the
312  // simulation of this region, bringing the deposit exactly on the plane
313  // should be enough for the time being.
314  if (DriftDistance < 0.) DriftDistance = 0.;
315 
316  // Drift time in ns
317  double TDrift = DriftDistance * fRecipDriftVel[0];
318 
319  if (
320  tpcGeo.Nplanes() == 2 &&
321  driftcoordinate ==
322  0) { // special case for ArgoNeuT (Nplanes = 2 and drift direction = x): plane 0 is the second wire plane
323  TDrift = ((DriftDistance - tpcGeo.PlanePitch(0, 1)) * fRecipDriftVel[0] +
324  tpcGeo.PlanePitch(0, 1) * fRecipDriftVel[1]);
325  }
326  const int nIonizedElectrons =
328 
329  const double lifetimecorrection = TMath::Exp(TDrift / fLifetimeCorr_const);
330  const double energy = energyDeposit.Energy();
331 
332  // if we have no electrons (too small energy or too large recombination)
333  // we are done already here
334  if (nIonizedElectrons <= 0) {
335  MF_LOG_DEBUG("DriftElectronstoPlane")
336  << "step " // << energyDeposit << "\n"
337  << "No electrons drifted to readout, " << energy << " MeV lost.";
338  continue;
339  }
340 
341  // includes the effect of lifetime: lifetimecorrection = exp[-tdrift/tau]
342  const double nElectrons = nIonizedElectrons * lifetimecorrection;
343 
344  // Longitudinal & transverse diffusion sigma (cm)
345  double SqrtT = std::sqrt(TDrift);
346  double LDiffSig = SqrtT * fLDiff_const;
347  double TDiffSig = SqrtT * fTDiff_const;
348  double electronclsize = fElectronClusterSize;
349 
350  // Number of electron clusters.
351  int nClus = (int)std::ceil(nElectrons / electronclsize);
352  if (nClus < fMinNumberOfElCluster) {
353  electronclsize = nElectrons / fMinNumberOfElCluster;
354  if (electronclsize < 1.0) { electronclsize = 1.0; }
355  nClus = (int)std::ceil(nElectrons / electronclsize);
356  }
357 
358  // Empty and resize the electron-cluster vectors.
359  fLongDiff.clear();
360  fTransDiff1.clear();
361  fTransDiff2.clear();
362  fnElDiff.clear();
363  fnEnDiff.clear();
364  fLongDiff.resize(nClus);
365  fTransDiff1.resize(nClus);
366  fTransDiff2.resize(nClus);
367  fnElDiff.resize(nClus, electronclsize);
368  fnEnDiff.resize(nClus);
369 
370  // fix the number of electrons in the last cluster, that has a smaller size
371  fnElDiff.back() = nElectrons - (nClus - 1) * electronclsize;
372 
373  for (size_t xx = 0; xx < fnElDiff.size(); ++xx) {
374  if (nElectrons > 0)
375  fnEnDiff[xx] = energy / nElectrons * fnElDiff[xx];
376  else
377  fnEnDiff[xx] = 0.;
378  }
379 
380  // Smear drift times by longitudinal diffusion
381  if (LDiffSig > 0.0)
382  fRandGauss.fireArray(nClus, &fLongDiff[0], 0., LDiffSig);
383  else
384  fLongDiff.assign(nClus, 0.0);
385 
386  if (TDiffSig > 0.0) {
387  // Smear the coordinates in plane perpendicular to drift direction by the transverse diffusion
388  fRandGauss.fireArray(nClus, &fTransDiff1[0], avegagetransversePos1, TDiffSig);
389  fRandGauss.fireArray(nClus, &fTransDiff2[0], avegagetransversePos2, TDiffSig);
390  }
391  else {
392  fTransDiff1.assign(nClus, avegagetransversePos1);
393  fTransDiff2.assign(nClus, avegagetransversePos2);
394  }
395 
396  // make a collection of electrons for each plane
397  for (size_t p = 0; p < tpcGeo.Nplanes(); ++p) {
398  auto const plane_center = tpcGeo.Plane(p).GetCenter();
399  fDriftClusterPos[driftcoordinate] = geo::vect::coord(plane_center, driftcoordinate);
400 
401  // Drift nClus electron clusters to the induction plane
402  for (int k = 0; k < nClus; ++k) {
403 
404  // Correct drift time for longitudinal diffusion and plane
405  double TDiff = TDrift + fLongDiff[k] * fRecipDriftVel[0];
406 
407  // Take into account different Efields between planes
408  // Also take into account special case for ArgoNeuT (Nplanes = 2 and drift direction = x): plane 0 is the second wire plane
409  for (size_t ip = 0; ip < p; ++ip) {
410  auto const plane_center = tpcGeo.Plane(ip).GetCenter();
411  auto const next_plane_center = tpcGeo.Plane(ip + 1).GetCenter();
412  TDiff +=
413  (geo::vect::coord(next_plane_center, driftcoordinate) -
414  geo::vect::coord(plane_center, driftcoordinate)) *
415  fRecipDriftVel[(tpcGeo.Nplanes() == 2 && driftcoordinate == 0) ? ip + 2 : ip + 1];
416  }
417 
418  fDriftClusterPos[transversecoordinate1] = fTransDiff1[k];
419  fDriftClusterPos[transversecoordinate2] = fTransDiff2[k];
420  auto const simTime = energyDeposit.Time();
422  SimDriftedElectronClusterCollection->emplace_back(
423  fnElDiff[k],
424  TDiff + simTime, // timing
425  geo::Point_t{mp.X(), mp.Y(), mp.Z()}, // mean position of the deposited energy
427  fDriftClusterPos[1],
428  fDriftClusterPos[2]}, // final position of the drifted cluster
429  geo::Point_t{
430  LDiffSig, TDiffSig, TDiffSig}, // Longitudinal (X) and transverse (Y,Z) diffusion
431  fnEnDiff[k], //deposited energy that originated this cluster
432  energyDeposit.TrackID());
433 
434  } // end loop over clusters
435  } // end loop over planes
436  } // for each sim::SimEnergyDeposit
437 
438  if (fStoreDriftedElectronClusters) event.put(std::move(SimDriftedElectronClusterCollection));
439  }
double PlanePitch(unsigned int p1=0, unsigned int p2=1) const
Returns the center of the TPC volume in world coordinates [cm].
Definition: TPCGeo.cxx:361
Double_t xx
Definition: macro.C:12
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
Definition: geo_vectors.h:160
Point_t const & GetCenter() const
Returns the centre of the wire plane in world coordinates [cm].
Definition: PlaneGeo.h:435
bool out_of_bounds(geo::Vector_t const &offset)
auto coord(Vector &v, unsigned int n) noexcept
Returns an object to manage the coordinate n of a vector.
unsigned int Nplanes() const
Number of planes in this tpc.
Definition: TPCGeo.h:137
art::ServiceHandle< geo::Geometry const > fGeometry
Handle to the Geometry service.
Geometry information for a single TPC.
Definition: TPCGeo.h:36
constexpr auto abs(T v)
Returns the absolute value of the argument.
TPCGeo const & TPC(TPCID const &tpcid=tpc_zero) const
Returns the specified TPC.
Definition: GeometryCore.h:722
double energy
Definition: plottest35.C:25
Data CalculateIonizationAndScintillation(detinfo::DetectorPropertiesData const &detProp, sim::SimEnergyDeposit const &edep) const
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:180
short int DetectDriftDirection() const
Returns the expected drift direction based on geometry.
Definition: TPCGeo.cxx:149
#define MF_LOG_DEBUG(id)
PlaneGeo const & Plane(geo::View_t view) const
Return the plane in the tpc with View_t view.
Definition: TPCGeo.cxx:252
Event finding and building.
void art::Modifier::registerProducts ( ProductDescriptions productsToRegister)
inherited

Definition at line 16 of file Modifier.cc.

References art::ModuleBase::moduleDescription(), and art::ProductRegistryHelper::registerProducts().

17  {
18  ProductRegistryHelper::registerProducts(productsToRegister,
20  }
void registerProducts(ProductDescriptions &productsToRegister, ModuleDescription const &md)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
void art::ModuleBase::setModuleDescription ( ModuleDescription const &  md)
inherited

Definition at line 31 of file ModuleBase.cc.

References art::ModuleBase::md_.

32  {
33  md_ = md;
34  }
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
void art::ModuleBase::sortConsumables ( std::string const &  current_process_name)
inherited

Definition at line 49 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::sortConsumables().

50  {
51  // Now that we know we have seen all the consumes declarations,
52  // sort the results for fast lookup later.
53  collector_.sortConsumables(current_process_name);
54  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
void sortConsumables(std::string const &current_process_name)

Member Data Documentation

double detsim::DriftElectronstoPlane::fDriftClusterPos[3]
private

Definition at line 133 of file DriftElectronstoPlane_module.cc.

Referenced by produce().

double detsim::DriftElectronstoPlane::fElectronClusterSize
private

Definition at line 106 of file DriftElectronstoPlane_module.cc.

Referenced by DriftElectronstoPlane(), and produce().

double detsim::DriftElectronstoPlane::fElectronLifetime
private

Definition at line 115 of file DriftElectronstoPlane_module.cc.

Referenced by beginJob().

art::ServiceHandle<geo::Geometry const> detsim::DriftElectronstoPlane::fGeometry
private

Handle to the Geometry service.

Definition at line 135 of file DriftElectronstoPlane_module.cc.

Referenced by beginJob(), and produce().

double detsim::DriftElectronstoPlane::fGeVToElectrons
private

Definition at line 108 of file DriftElectronstoPlane_module.cc.

Referenced by DriftElectronstoPlane().

ISCalculationSeparate detsim::DriftElectronstoPlane::fISAlg
private

Definition at line 138 of file DriftElectronstoPlane_module.cc.

Referenced by DriftElectronstoPlane(), and produce().

double detsim::DriftElectronstoPlane::fLDiff_const
private

Definition at line 117 of file DriftElectronstoPlane_module.cc.

Referenced by beginJob(), and produce().

double detsim::DriftElectronstoPlane::fLifetimeCorr_const
private

Definition at line 116 of file DriftElectronstoPlane_module.cc.

Referenced by beginJob(), and produce().

std::vector<double> detsim::DriftElectronstoPlane::fLongDiff
private

Definition at line 127 of file DriftElectronstoPlane_module.cc.

Referenced by produce().

double detsim::DriftElectronstoPlane::fLongitudinalDiffusion
private

Definition at line 104 of file DriftElectronstoPlane_module.cc.

Referenced by beginJob(), and DriftElectronstoPlane().

int detsim::DriftElectronstoPlane::fMinNumberOfElCluster
private

Definition at line 107 of file DriftElectronstoPlane_module.cc.

Referenced by DriftElectronstoPlane(), and produce().

double detsim::DriftElectronstoPlane::fModBoxA
private

Definition at line 111 of file DriftElectronstoPlane_module.cc.

Referenced by DriftElectronstoPlane().

double detsim::DriftElectronstoPlane::fModBoxB
private

Definition at line 112 of file DriftElectronstoPlane_module.cc.

Referenced by DriftElectronstoPlane().

size_t detsim::DriftElectronstoPlane::fNCryostats
private

Definition at line 123 of file DriftElectronstoPlane_module.cc.

Referenced by beginJob().

std::vector<double> detsim::DriftElectronstoPlane::fnElDiff
private

Definition at line 130 of file DriftElectronstoPlane_module.cc.

Referenced by produce().

std::vector<double> detsim::DriftElectronstoPlane::fnEnDiff
private

Definition at line 131 of file DriftElectronstoPlane_module.cc.

Referenced by produce().

std::vector<size_t> detsim::DriftElectronstoPlane::fNTPCs
private

Definition at line 124 of file DriftElectronstoPlane_module.cc.

Referenced by beginJob().

CLHEP::RandGauss detsim::DriftElectronstoPlane::fRandGauss
private

Definition at line 101 of file DriftElectronstoPlane_module.cc.

Referenced by DriftElectronstoPlane(), and produce().

double detsim::DriftElectronstoPlane::fRecipDriftVel[3]
private

Definition at line 119 of file DriftElectronstoPlane_module.cc.

Referenced by beginJob(), and produce().

double detsim::DriftElectronstoPlane::fRecombA
private

Definition at line 109 of file DriftElectronstoPlane_module.cc.

Referenced by DriftElectronstoPlane().

double detsim::DriftElectronstoPlane::fRecombk
private

Definition at line 110 of file DriftElectronstoPlane_module.cc.

Referenced by DriftElectronstoPlane().

art::InputTag detsim::DriftElectronstoPlane::fSimModuleLabel
private

Definition at line 99 of file DriftElectronstoPlane_module.cc.

Referenced by DriftElectronstoPlane(), and produce().

bool detsim::DriftElectronstoPlane::fStoreDriftedElectronClusters
private

Definition at line 103 of file DriftElectronstoPlane_module.cc.

Referenced by DriftElectronstoPlane(), and produce().

double detsim::DriftElectronstoPlane::fTDiff_const
private

Definition at line 118 of file DriftElectronstoPlane_module.cc.

Referenced by beginJob(), and produce().

std::vector<double> detsim::DriftElectronstoPlane::fTransDiff1
private

Definition at line 128 of file DriftElectronstoPlane_module.cc.

Referenced by produce().

std::vector<double> detsim::DriftElectronstoPlane::fTransDiff2
private

Definition at line 129 of file DriftElectronstoPlane_module.cc.

Referenced by produce().

double detsim::DriftElectronstoPlane::fTransverseDiffusion
private

Definition at line 105 of file DriftElectronstoPlane_module.cc.

Referenced by beginJob(), and DriftElectronstoPlane().

bool detsim::DriftElectronstoPlane::fUseModBoxRecomb
private

Definition at line 113 of file DriftElectronstoPlane_module.cc.

Referenced by DriftElectronstoPlane().


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