10 #include "art/Framework/Core/EDProducer.h"
11 #include "art/Framework/Core/ModuleMacros.h"
12 #include "art/Framework/Principal/Event.h"
13 #include "art/Framework/Principal/Handle.h"
14 #include "art_root_io/TFileService.h"
15 #include "canvas/Utilities/InputTag.h"
16 #include "fhiclcpp/ParameterSet.h"
31 namespace spacecharge {
48 void produce(art::Event&
e)
override;
63 , fEDepTag(
p.get<art::InputTag>(
"EDepTag"))
64 , fMakeAnaTree(
p.get<
bool>(
"MakeAnaTree",
true))
66 produces<std::vector<sim::SimEnergyDeposit>>();
73 art::ServiceHandle<art::TFileService const>
tfs;
74 fNtEdepAna = tfs->make<TNtuple>(
76 "Edep PosDiff Ana Ntuple",
77 "energy:orig_x:orig_y:orig_z:orig_el:orig_ph:shift_x:shift_y:shift_z:shift_el:shift_ph");
84 auto sce = lar::providerFrom<spacecharge::SpaceChargeService>();
85 auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(e);
87 auto const& inEdepVec = *e.getValidHandle<std::vector<sim::SimEnergyDeposit>>(fEDepTag);
89 auto outEdepVecPtr = std::make_unique<std::vector<sim::SimEnergyDeposit>>();
90 auto& outEdepVec = *outEdepVecPtr;
91 outEdepVec.reserve(inEdepVec.size());
95 for (
auto const& edep : inEdepVec) {
96 if (sce->EnableSimSpatialSCE()) {
97 posOffsetsStart = sce->GetPosOffsets({edep.StartX(), edep.StartY(), edep.StartZ()});
98 posOffsetsEnd = sce->GetPosOffsets({edep.EndX(), edep.EndY(), edep.EndZ()});
104 auto const isData = fISAlg.CalcIonAndScint(detProp, edep);
105 outEdepVec.emplace_back(
110 geo::Point_t{(float)(edep.StartX() - posOffsetsStart.X()),
111 (
float)(edep.StartY() + posOffsetsStart.Y()),
112 (
float)(edep.StartZ() + posOffsetsStart.Z())},
114 (
float)(edep.EndY() + posOffsetsEnd.Y()),
115 (
float)(edep.EndZ() + posOffsetsEnd.Z())},
121 fNtEdepAna->Fill(edep.Energy(),
127 outEdepVec.back().X(),
128 outEdepVec.back().Y(),
129 outEdepVec.back().Z(),
130 outEdepVec.back().NumElectrons(),
131 outEdepVec.back().NumPhotons());
134 e.put(std::move(outEdepVecPtr));
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
void produce(art::Event &e) override
Utilities related to art service access.
bool out_of_bounds(geo::Vector_t const &offset)
ShiftEdepSCE(fhicl::ParameterSet const &p)
ShiftEdepSCE & operator=(ShiftEdepSCE const &)=delete
Utility function for testing if Space Charge offsets are out of bounds.
larg4::ISCalcSeparate fISAlg
contains information for a single step in the detector simulation
art::ServiceHandle< art::TFileService > tfs
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.