77 #include "CLHEP/Random/RandGauss.h" 151 -> registerAndSeedEngine(
createEngine(0), pset,
"Seed")}
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)}
178 for (
int i = 0; i < 3; ++i) {
179 double driftVelocity =
180 detProp.DriftVelocity(detProp.Efield(i),
181 detProp.Temperature()) *
188 <<
"\n Temperature (K): " << detProp.Temperature()
210 energyDepositHandle_t energyDepositHandle;
216 std::unique_ptr<std::vector<sim::SimDriftedElectronCluster>>
217 SimDriftedElectronClusterCollection(
new std::vector<sim::SimDriftedElectronCluster>);
221 auto const& energyDeposits = *energyDepositHandle;
222 auto energyDepositsSize = energyDeposits.size();
229 for (
size_t edIndex = 0; edIndex < energyDepositsSize; ++edIndex) {
230 auto const& energyDeposit = energyDeposits[edIndex];
234 auto const mp = energyDeposit.MidPoint();
235 double const xyz[3] = {mp.X(), mp.Y(), mp.Z()};
242 unsigned const nplanes = wireReadoutGeom.Nplanes(tpcid);
252 int driftcoordinate = 0;
253 int transversecoordinate1 = 1;
254 int transversecoordinate2 = 2;
256 transversecoordinate1 = 0;
258 transversecoordinate2 = 2;
261 transversecoordinate1 = 0;
262 transversecoordinate2 = 1;
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;
276 double DriftDistance =
std::abs(xyz[driftcoordinate] - plane_center_coord);
280 double posOffsetxyz[3] = {
282 auto const* SCE = lar::providerFrom<spacecharge::SpaceChargeService>();
283 if (SCE->EnableSimSpatialSCE() ==
true) {
284 posOffsets = SCE->GetPosOffsets(mp);
286 posOffsetxyz[0] = posOffsets.X();
287 posOffsetxyz[1] = posOffsets.Y();
288 posOffsetxyz[2] = posOffsets.Z();
291 double avegagetransversePos1 = 0.;
292 double avegagetransversePos2 = 0.;
294 DriftDistance += -1. * posOffsetxyz[driftcoordinate];
295 avegagetransversePos1 = xyz[transversecoordinate1] + posOffsetxyz[transversecoordinate1];
296 avegagetransversePos2 = xyz[transversecoordinate2] + posOffsetxyz[transversecoordinate2];
302 if (DriftDistance < 0.) DriftDistance = 0.;
311 auto const pitch = wireReadoutGeom.PlanePitch(tpcGeo.
ID(), 0, 1);
312 TDrift = ((DriftDistance - pitch) * fRecipDriftVel[0] + pitch * fRecipDriftVel[1]);
314 const int nIonizedElectrons =
318 const double energy = energyDeposit.Energy();
322 if (nIonizedElectrons <= 0) {
325 <<
"No electrons drifted to readout, " << energy <<
" MeV lost.";
330 const double nElectrons = nIonizedElectrons * lifetimecorrection;
333 double SqrtT = std::sqrt(TDrift);
339 int nClus = (int)std::ceil(nElectrons / electronclsize);
342 if (electronclsize < 1.0) { electronclsize = 1.0; }
343 nClus = (int)std::ceil(nElectrons / electronclsize);
355 fnElDiff.resize(nClus, electronclsize);
359 fnElDiff.back() = nElectrons - (nClus - 1) * electronclsize;
374 if (TDiffSig > 0.0) {
385 for (
auto const& plane : wireReadoutGeom.Iterate<
geo::PlaneGeo>(tpcGeo.
ID())) {
386 auto const plane_center = plane.GetCenter();
390 for (
int k = 0; k < nClus; ++k) {
393 double TDiff = TDrift +
fLongDiff[k] * fRecipDriftVel[0];
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();
403 fRecipDriftVel[(nplanes == 2 && driftcoordinate == 0) ? ip + 2 : ip + 1];
408 auto const simTime = energyDeposit.Time();
410 SimDriftedElectronClusterCollection->emplace_back(
416 fDriftClusterPos[2]},
418 LDiffSig, TDiffSig, TDiffSig},
420 energyDeposit.TrackID());
base_engine_t & createEngine(seed_t seed)
Utilities related to art service access.
contains objects relating to SimDriftedElectronCluster
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
std::vector< double > fnElDiff
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 NTPC(CryostatID const &cryoid=details::cryostat_zero) const
Returns the total number of TPCs in the specified cryostat.
art::ServiceHandle< geo::Geometry const > fGeometry
Handle to the Geometry service.
EDProducer(fhicl::ParameterSet const &pset)
Geometry information for a single TPC.
Detector simulation of raw signals on wires.
constexpr auto abs(T v)
Returns the absolute value of the argument.
double fLifetimeCorr_const
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
std::vector< double > fTransDiff1
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
DriftAxis DriftAxisWithSign() const
Returns the expected drift direction based on geometry.
std::vector< size_t > fNTPCs
double fElectronClusterSize
bool fStoreDriftedElectronClusters
double fLongitudinalDiffusion
double fDriftClusterPos[3]
#define DEFINE_ART_MODULE(klass)
CLHEP::RandGauss fRandGauss
Utility function for testing if Space Charge offsets are out of bounds.
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
constexpr int to_int(Coordinate const coord) noexcept
Enumerate the possible plane projections.
Data CalculateIonizationAndScintillation(detinfo::DetectorPropertiesData const &detProp, sim::SimEnergyDeposit const &edep) const
The data type to uniquely identify a TPC.
An art service to assist in the distribution of guaranteed unique seeds to all engines within an art ...
std::vector< double > fnEnDiff
double fTransverseDiffusion
void produce(art::Event &evt) override
ISCalculationSeparate fISAlg
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
art::InputTag fSimModuleLabel
contains information for a single step in the detector simulation
DriftElectronstoPlane(fhicl::ParameterSet const &pset)
std::vector< double > fTransDiff2
TPCGeo const & TPC(TPCID const &tpcid=details::tpc_zero) const
Returns the specified TPC.
int fMinNumberOfElCluster
TPCID const & ID() const
Returns the identifier of this TPC.
art framework interface to geometry description
Event finding and building.
The data type to uniquely identify a cryostat.
std::vector< double > fLongDiff