LArSoft  v10_04_05
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 88 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 144 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.

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

Member Function Documentation

void detsim::DriftElectronstoPlane::beginJob ( )
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 169 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().

170  {
171  // Define the physical constants we'll use.
172 
173  auto const detProp =
176  detProp
177  .ElectronLifetime(); // Electron lifetime as returned by the DetectorProperties service assumed to be in us;
178  for (int i = 0; i < 3; ++i) {
179  double driftVelocity =
180  detProp.DriftVelocity(detProp.Efield(i),
181  detProp.Temperature()) *
182  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;
183 
184  fRecipDriftVel[i] = 1. / driftVelocity;
185  }
186  MF_LOG_DEBUG("DriftElectronstoPlane")
187  << " e lifetime (ns): " << fElectronLifetime
188  << "\n Temperature (K): " << detProp.Temperature()
189  << "\n Drift velocity (cm/ns): " << 1. / fRecipDriftVel[0] << " " << 1. / fRecipDriftVel[1]
190  << " " << 1. / fRecipDriftVel[2];
191 
192  // Opposite of lifetime. Convert from us to standard LArSoft time units, ns;
194  fLDiff_const = std::sqrt(2. * fLongitudinalDiffusion);
195  fTDiff_const = std::sqrt(2. * fTransverseDiffusion);
196 
197  // For this detector's geometry, save the number of cryostats and the number of TPCs
198  // within each cryostat.
200  fNTPCs.resize(fNCryostats);
201  for (size_t n = 0; n < fNCryostats; ++n)
203  }
unsigned int NTPC(CryostatID const &cryoid=details::cryostat_zero) const
Returns the total number of TPCs in the specified cryostat.
Definition: GeometryCore.h:416
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:303
#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:187
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 206 of file DriftElectronstoPlane_module.cc.

References util::abs(), detsim::ISCalculationSeparate::CalculateIonizationAndScintillation(), geo::vect::coord(), DEFINE_ART_MODULE, geo::TPCGeo::DriftAxisWithSign(), energy, fDriftClusterPos, fElectronClusterSize, fGeometry, fISAlg, fLDiff_const, fLifetimeCorr_const, fLongDiff, fMinNumberOfElCluster, fnElDiff, fnEnDiff, fRandGauss, fRecipDriftVel, fSimModuleLabel, fStoreDriftedElectronClusters, fTDiff_const, fTransDiff1, fTransDiff2, Get, art::ProductRetriever::getByLabel(), geo::TPCGeo::ID(), MF_LOG_DEBUG, detsim::ISCalculationSeparate::Data::numElectrons, larsim::Utils::SCE::out_of_bounds(), pmtana::sign(), geo::to_int(), geo::GeometryCore::TPC(), xx, geo::Y, and geo::Z.

207  {
208  // Fetch the SimEnergyDeposit objects for this event.
209  typedef art::Handle<std::vector<sim::SimEnergyDeposit>> energyDepositHandle_t;
210  energyDepositHandle_t energyDepositHandle;
211  // If there aren't any energy deposits for this event, don't panic. It's possible
212  // someone is doing a study with events outside the TPC, or where there are only
213  // non-ionizing 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 iterator, because we
220  // need the index number to compute the associations near the end of this method.
221  auto const& energyDeposits = *energyDepositHandle;
222  auto energyDepositsSize = energyDeposits.size();
223 
224  auto const detProp =
226 
227  auto const& wireReadoutGeom = art::ServiceHandle<geo::WireReadout>()->Get();
228  // For each energy deposit in this event
229  for (size_t edIndex = 0; edIndex < energyDepositsSize; ++edIndex) {
230  auto const& energyDeposit = energyDeposits[edIndex];
231 
232  // "xyz" is the position of the energy deposit in world coordinates. Note that the
233  // units of distance in 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 cryostat and tpc. If
238  // somehow the step is outside a tpc (e.g., cosmic rays in rock) just move on to the
239  // next one.
240  geo::TPCGeo const& tpcGeo = fGeometry->TPC();
241  geo::TPCID const& tpcid = tpcGeo.ID();
242  unsigned const nplanes = wireReadoutGeom.Nplanes(tpcid);
243 
244  // The drift direction can be either in the positive or negative direction in any
245  // coordinate x, y or z.
246 
247  // Define charge drift direction: driftcoordinate (x, y or z) and driftsign
248  // (positive or negative). Also define coordinates perpendicular to drift direction.
249  auto const [axis, sign] = tpcGeo.DriftAxisWithSign();
250 
251  // For axis == geo::Coordinate::X
252  int driftcoordinate = 0;
253  int transversecoordinate1 = 1;
254  int transversecoordinate2 = 2;
255  if (axis == geo::Coordinate::Y) {
256  transversecoordinate1 = 0;
257  driftcoordinate = 1;
258  transversecoordinate2 = 2;
259  }
260  else if (axis == geo::Coordinate::Z) {
261  transversecoordinate1 = 0;
262  transversecoordinate2 = 1;
263  driftcoordinate = 2;
264  }
265 
266  int const driftsign = to_int(sign); //1: +x, +y or +z, -1: -x, -y or -z
267 
268  //Check for charge deposits behind charge readout planes
269  auto const plane_center = wireReadoutGeom.FirstPlane(tpcid).GetCenter();
270  auto const plane_center_coord = geo::vect::coord(plane_center, driftcoordinate);
271  if (driftsign == 1 && plane_center_coord < xyz[driftcoordinate]) continue;
272  if (driftsign == -1 && plane_center_coord > xyz[driftcoordinate]) continue;
273 
275  // Center of plane is also returned in cm units
276  double DriftDistance = std::abs(xyz[driftcoordinate] - plane_center_coord);
277 
278  // Space-charge effect (SCE): Get SCE {x,y,z} offsets for particular location in TPC
279  geo::Vector_t posOffsets{0.0, 0.0, 0.0};
280  double posOffsetxyz[3] = {
281  0.0, 0.0, 0.0}; //need this array for the driftcoordinate and transversecoordinates
282  auto const* SCE = lar::providerFrom<spacecharge::SpaceChargeService>();
283  if (SCE->EnableSimSpatialSCE() == true) {
284  posOffsets = SCE->GetPosOffsets(mp);
285  if (larsim::Utils::SCE::out_of_bounds(posOffsets)) continue;
286  posOffsetxyz[0] = posOffsets.X();
287  posOffsetxyz[1] = posOffsets.Y();
288  posOffsetxyz[2] = posOffsets.Z();
289  }
290 
291  double avegagetransversePos1 = 0.;
292  double avegagetransversePos2 = 0.;
293 
294  DriftDistance += -1. * posOffsetxyz[driftcoordinate];
295  avegagetransversePos1 = xyz[transversecoordinate1] + posOffsetxyz[transversecoordinate1];
296  avegagetransversePos2 = xyz[transversecoordinate2] + posOffsetxyz[transversecoordinate2];
297 
298  // Space charge distortion could push the energy deposit beyond the wire plane (see
299  // issue #15131). Given that we don't have any subtlety in the simulation of this
300  // region, bringing the deposit exactly on the plane should be enough for the time
301  // being.
302  if (DriftDistance < 0.) DriftDistance = 0.;
303 
304  // Drift time in ns
305  double TDrift = DriftDistance * fRecipDriftVel[0];
306 
307  if (nplanes == 2 &&
308  driftcoordinate ==
309  0) { // special case for ArgoNeuT (Nplanes = 2 and drift direction = x): plane 0
310  // is the second wire plane
311  auto const pitch = wireReadoutGeom.PlanePitch(tpcGeo.ID(), 0, 1);
312  TDrift = ((DriftDistance - pitch) * fRecipDriftVel[0] + pitch * fRecipDriftVel[1]);
313  }
314  const int nIonizedElectrons =
316 
317  const double lifetimecorrection = TMath::Exp(TDrift / fLifetimeCorr_const);
318  const double energy = energyDeposit.Energy();
319 
320  // if we have no electrons (too small energy or too large recombination) we are done
321  // already here
322  if (nIonizedElectrons <= 0) {
323  MF_LOG_DEBUG("DriftElectronstoPlane")
324  << "step " // << energyDeposit << "\n"
325  << "No electrons drifted to readout, " << energy << " MeV lost.";
326  continue;
327  }
328 
329  // includes the effect of lifetime: lifetimecorrection = exp[-tdrift/tau]
330  const double nElectrons = nIonizedElectrons * lifetimecorrection;
331 
332  // Longitudinal & transverse diffusion sigma (cm)
333  double SqrtT = std::sqrt(TDrift);
334  double LDiffSig = SqrtT * fLDiff_const;
335  double TDiffSig = SqrtT * fTDiff_const;
336  double electronclsize = fElectronClusterSize;
337 
338  // Number of electron clusters.
339  int nClus = (int)std::ceil(nElectrons / electronclsize);
340  if (nClus < fMinNumberOfElCluster) {
341  electronclsize = nElectrons / fMinNumberOfElCluster;
342  if (electronclsize < 1.0) { electronclsize = 1.0; }
343  nClus = (int)std::ceil(nElectrons / electronclsize);
344  }
345 
346  // Empty and resize the electron-cluster vectors.
347  fLongDiff.clear();
348  fTransDiff1.clear();
349  fTransDiff2.clear();
350  fnElDiff.clear();
351  fnEnDiff.clear();
352  fLongDiff.resize(nClus);
353  fTransDiff1.resize(nClus);
354  fTransDiff2.resize(nClus);
355  fnElDiff.resize(nClus, electronclsize);
356  fnEnDiff.resize(nClus);
357 
358  // fix the number of electrons in the last cluster, that has a smaller size
359  fnElDiff.back() = nElectrons - (nClus - 1) * electronclsize;
360 
361  for (size_t xx = 0; xx < fnElDiff.size(); ++xx) {
362  if (nElectrons > 0)
363  fnEnDiff[xx] = energy / nElectrons * fnElDiff[xx];
364  else
365  fnEnDiff[xx] = 0.;
366  }
367 
368  // Smear drift times by longitudinal diffusion
369  if (LDiffSig > 0.0)
370  fRandGauss.fireArray(nClus, &fLongDiff[0], 0., LDiffSig);
371  else
372  fLongDiff.assign(nClus, 0.0);
373 
374  if (TDiffSig > 0.0) {
375  // Smear the coordinates in plane perpendicular to drift direction by the transverse diffusion
376  fRandGauss.fireArray(nClus, &fTransDiff1[0], avegagetransversePos1, TDiffSig);
377  fRandGauss.fireArray(nClus, &fTransDiff2[0], avegagetransversePos2, TDiffSig);
378  }
379  else {
380  fTransDiff1.assign(nClus, avegagetransversePos1);
381  fTransDiff2.assign(nClus, avegagetransversePos2);
382  }
383 
384  // make a collection of electrons for each plane
385  for (auto const& plane : wireReadoutGeom.Iterate<geo::PlaneGeo>(tpcGeo.ID())) {
386  auto const plane_center = plane.GetCenter();
387  fDriftClusterPos[driftcoordinate] = geo::vect::coord(plane_center, driftcoordinate);
388 
389  // Drift nClus electron clusters to the induction plane
390  for (int k = 0; k < nClus; ++k) {
391 
392  // Correct drift time for longitudinal diffusion and plane
393  double TDiff = TDrift + fLongDiff[k] * fRecipDriftVel[0];
394 
395  // Take into account different Efields between planes. Also take into account
396  // special case for ArgoNeuT (Nplanes = 2 and drift direction = x): plane 0 is
397  // the second wire plane
398  for (unsigned int ip = 0; ip < plane.ID().Plane; ++ip) {
399  auto const plane_center = wireReadoutGeom.Plane({tpcGeo.ID(), ip}).GetCenter();
400  auto const next_plane_center = wireReadoutGeom.Plane({tpcGeo.ID(), ip + 1}).GetCenter();
401  TDiff += (geo::vect::coord(next_plane_center, driftcoordinate) -
402  geo::vect::coord(plane_center, driftcoordinate)) *
403  fRecipDriftVel[(nplanes == 2 && driftcoordinate == 0) ? ip + 2 : ip + 1];
404  }
405 
406  fDriftClusterPos[transversecoordinate1] = fTransDiff1[k];
407  fDriftClusterPos[transversecoordinate2] = fTransDiff2[k];
408  auto const simTime = energyDeposit.Time();
410  SimDriftedElectronClusterCollection->emplace_back(
411  fnElDiff[k],
412  TDiff + simTime, // timing
413  geo::Point_t{mp.X(), mp.Y(), mp.Z()}, // mean position of the deposited energy
415  fDriftClusterPos[1],
416  fDriftClusterPos[2]}, // final position of the drifted cluster
417  geo::Point_t{
418  LDiffSig, TDiffSig, TDiffSig}, // Longitudinal (X) and transverse (Y,Z) diffusion
419  fnEnDiff[k], //deposited energy that originated this cluster
420  energyDeposit.TrackID());
421 
422  } // end loop over clusters
423  } // end loop over planes
424  } // for each sim::SimEnergyDeposit
425 
426  if (fStoreDriftedElectronClusters) event.put(std::move(SimDriftedElectronClusterCollection));
427  }
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
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.
art::ServiceHandle< geo::Geometry const > fGeometry
Handle to the Geometry service.
Geometry information for a single TPC.
Definition: TPCGeo.h:33
constexpr auto abs(T v)
Returns the absolute value of the argument.
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
Definition: AddMC.C:8
DriftAxis DriftAxisWithSign() const
Returns the expected drift direction based on geometry.
Definition: TPCGeo.h:78
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Definition: PlaneGeo.h:67
double energy
Definition: plottest35.C:25
constexpr int to_int(Coordinate const coord) noexcept
Enumerate the possible plane projections.
Definition: geo_types.h:124
Data CalculateIonizationAndScintillation(detinfo::DetectorPropertiesData const &detProp, sim::SimEnergyDeposit const &edep) const
The data type to uniquely identify a TPC.
Definition: geo_types.h:306
int sign(double val)
Definition: UtilFunc.cxx:104
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
#define MF_LOG_DEBUG(id)
TPCGeo const & TPC(TPCID const &tpcid=details::tpc_zero) const
Returns the specified TPC.
Definition: GeometryCore.h:448
TPCID const & ID() const
Returns the identifier of this TPC.
Definition: TPCGeo.h:147
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 134 of file DriftElectronstoPlane_module.cc.

Referenced by produce().

double detsim::DriftElectronstoPlane::fElectronClusterSize
private

Definition at line 107 of file DriftElectronstoPlane_module.cc.

Referenced by DriftElectronstoPlane(), and produce().

double detsim::DriftElectronstoPlane::fElectronLifetime
private

Definition at line 116 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 136 of file DriftElectronstoPlane_module.cc.

Referenced by beginJob(), and produce().

double detsim::DriftElectronstoPlane::fGeVToElectrons
private

Definition at line 109 of file DriftElectronstoPlane_module.cc.

Referenced by DriftElectronstoPlane().

ISCalculationSeparate detsim::DriftElectronstoPlane::fISAlg
private

Definition at line 139 of file DriftElectronstoPlane_module.cc.

Referenced by DriftElectronstoPlane(), and produce().

double detsim::DriftElectronstoPlane::fLDiff_const
private

Definition at line 118 of file DriftElectronstoPlane_module.cc.

Referenced by beginJob(), and produce().

double detsim::DriftElectronstoPlane::fLifetimeCorr_const
private

Definition at line 117 of file DriftElectronstoPlane_module.cc.

Referenced by beginJob(), and produce().

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

Definition at line 128 of file DriftElectronstoPlane_module.cc.

Referenced by produce().

double detsim::DriftElectronstoPlane::fLongitudinalDiffusion
private

Definition at line 105 of file DriftElectronstoPlane_module.cc.

Referenced by beginJob(), and DriftElectronstoPlane().

int detsim::DriftElectronstoPlane::fMinNumberOfElCluster
private

Definition at line 108 of file DriftElectronstoPlane_module.cc.

Referenced by DriftElectronstoPlane(), and produce().

double detsim::DriftElectronstoPlane::fModBoxA
private

Definition at line 112 of file DriftElectronstoPlane_module.cc.

Referenced by DriftElectronstoPlane().

double detsim::DriftElectronstoPlane::fModBoxB
private

Definition at line 113 of file DriftElectronstoPlane_module.cc.

Referenced by DriftElectronstoPlane().

size_t detsim::DriftElectronstoPlane::fNCryostats
private

Definition at line 124 of file DriftElectronstoPlane_module.cc.

Referenced by beginJob().

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

Definition at line 131 of file DriftElectronstoPlane_module.cc.

Referenced by produce().

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

Definition at line 132 of file DriftElectronstoPlane_module.cc.

Referenced by produce().

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

Definition at line 125 of file DriftElectronstoPlane_module.cc.

Referenced by beginJob().

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

Definition at line 102 of file DriftElectronstoPlane_module.cc.

Referenced by DriftElectronstoPlane(), and produce().

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

Definition at line 120 of file DriftElectronstoPlane_module.cc.

Referenced by beginJob(), and produce().

double detsim::DriftElectronstoPlane::fRecombA
private

Definition at line 110 of file DriftElectronstoPlane_module.cc.

Referenced by DriftElectronstoPlane().

double detsim::DriftElectronstoPlane::fRecombk
private

Definition at line 111 of file DriftElectronstoPlane_module.cc.

Referenced by DriftElectronstoPlane().

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

Definition at line 100 of file DriftElectronstoPlane_module.cc.

Referenced by DriftElectronstoPlane(), and produce().

bool detsim::DriftElectronstoPlane::fStoreDriftedElectronClusters
private

Definition at line 104 of file DriftElectronstoPlane_module.cc.

Referenced by DriftElectronstoPlane(), and produce().

double detsim::DriftElectronstoPlane::fTDiff_const
private

Definition at line 119 of file DriftElectronstoPlane_module.cc.

Referenced by beginJob(), and produce().

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

Definition at line 129 of file DriftElectronstoPlane_module.cc.

Referenced by produce().

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

Definition at line 130 of file DriftElectronstoPlane_module.cc.

Referenced by produce().

double detsim::DriftElectronstoPlane::fTransverseDiffusion
private

Definition at line 106 of file DriftElectronstoPlane_module.cc.

Referenced by beginJob(), and DriftElectronstoPlane().

bool detsim::DriftElectronstoPlane::fUseModBoxRecomb
private

Definition at line 114 of file DriftElectronstoPlane_module.cc.

Referenced by DriftElectronstoPlane().


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