LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
ShiftEdepSCE_module.cc
Go to the documentation of this file.
1 // Class: ShiftEdepSCE
3 // Plugin Type: producer (art v2_05_01)
4 // File: ShiftEdepSCE_module.cc
5 //
6 // Generated at Thu Apr 19 00:41:18 2018 by Wesley Ketchum using cetskelgen
7 // from cetlib version v1_21_00.
9 
14 #include "art_root_io/TFileService.h"
16 #include "fhiclcpp/ParameterSet.h"
17 
18 #include <memory>
19 #include <utility>
20 
21 #include "TNtuple.h"
22 
30 
31 namespace spacecharge {
32  class ShiftEdepSCE;
33 }
34 
36 public:
37  explicit ShiftEdepSCE(fhicl::ParameterSet const& p);
38  // The compiler-generated destructor is fine for non-base
39  // classes without bare pointers or other resource use.
40 
41  // Plugins should not be copied or assigned.
42  ShiftEdepSCE(ShiftEdepSCE const&) = delete;
43  ShiftEdepSCE(ShiftEdepSCE&&) = delete;
44  ShiftEdepSCE& operator=(ShiftEdepSCE const&) = delete;
45  ShiftEdepSCE& operator=(ShiftEdepSCE&&) = delete;
46 
47  // Required functions.
48  void produce(art::Event& e) override;
49  void beginJob() override;
50 
51 private:
52  // Declare member data here.
55  TNtuple* fNtEdepAna;
56 
57  //IS calculationg
59 };
60 
62  : EDProducer{p}
63  , fEDepTag(p.get<art::InputTag>("EDepTag"))
64  , fMakeAnaTree(p.get<bool>("MakeAnaTree", true))
65 {
66  produces<std::vector<sim::SimEnergyDeposit>>();
67 }
68 
70 {
71  if (fMakeAnaTree) {
73  fNtEdepAna = tfs->make<TNtuple>(
74  "nt_edep_ana",
75  "Edep PosDiff Ana Ntuple",
76  "energy:orig_x:orig_y:orig_z:orig_el:orig_ph:shift_x:shift_y:shift_z:shift_el:shift_ph");
77  }
78 }
79 
81 {
82  auto sce = lar::providerFrom<spacecharge::SpaceChargeService>();
83  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(e);
84 
85  auto const& inEdepVec = *e.getValidHandle<std::vector<sim::SimEnergyDeposit>>(fEDepTag);
86 
87  auto outEdepVecPtr = std::make_unique<std::vector<sim::SimEnergyDeposit>>();
88  auto& outEdepVec = *outEdepVecPtr;
89  outEdepVec.reserve(inEdepVec.size());
90 
91  geo::Vector_t posOffsetsStart{0.0, 0.0, 0.0};
92  geo::Vector_t posOffsetsEnd{0.0, 0.0, 0.0};
93  for (auto const& edep : inEdepVec) {
94  if (sce->EnableSimSpatialSCE()) {
95  posOffsetsStart = sce->GetPosOffsets({edep.StartX(), edep.StartY(), edep.StartZ()});
96  posOffsetsEnd = sce->GetPosOffsets({edep.EndX(), edep.EndY(), edep.EndZ()});
97  if (larsim::Utils::SCE::out_of_bounds(posOffsetsStart) ||
98  larsim::Utils::SCE::out_of_bounds(posOffsetsEnd)) {
99  continue;
100  }
101  }
102  auto const isData = fISAlg.CalcIonAndScint(detProp, edep);
103  outEdepVec.emplace_back(
104  isData.numPhotons,
105  isData.numElectrons,
106  0.0,
107  edep.Energy(),
108  geo::Point_t{(float)(edep.StartX() - posOffsetsStart.X()), //x should be subtracted
109  (float)(edep.StartY() + posOffsetsStart.Y()),
110  (float)(edep.StartZ() + posOffsetsStart.Z())},
111  geo::Point_t{(float)(edep.EndX() - posOffsetsEnd.X()), //x should be subtracted
112  (float)(edep.EndY() + posOffsetsEnd.Y()),
113  (float)(edep.EndZ() + posOffsetsEnd.Z())},
114  edep.StartT(),
115  edep.EndT(),
116  edep.TrackID(),
117  edep.PdgCode());
118  if (fMakeAnaTree)
119  fNtEdepAna->Fill(edep.Energy(),
120  edep.X(),
121  edep.Y(),
122  edep.Z(),
123  edep.NumElectrons(),
124  edep.NumPhotons(),
125  outEdepVec.back().X(),
126  outEdepVec.back().Y(),
127  outEdepVec.back().Z(),
128  outEdepVec.back().NumElectrons(),
129  outEdepVec.back().NumPhotons());
130  }
131 
132  e.put(std::move(outEdepVecPtr));
133 }
134 
void produce(art::Event &e) override
Utilities related to art service access.
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)
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.cc:6
ShiftEdepSCE(fhicl::ParameterSet const &p)
ISCalcData CalcIonAndScint(detinfo::DetectorPropertiesData const &detProp, sim::SimEnergyDeposit const &edep) override
ShiftEdepSCE & operator=(ShiftEdepSCE const &)=delete
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Event.h:77
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:65
Utility function for testing if Space Charge offsets are out of bounds.
Double_t edep
Definition: macro.C:13
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
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
larg4::ISCalcSeparate fISAlg
contains information for a single step in the detector simulation
Float_t e
Definition: plot.C:35