LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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 
17 #include "fhiclcpp/ParameterSet.h"
20 
21 #include <memory>
22 
29 #include "TNtuple.h"
30 
31 namespace spacecharge {
32  class ShiftEdepSCE;
33 }
34 
35 
37 public:
38  explicit ShiftEdepSCE(fhicl::ParameterSet const & p);
39  // The compiler-generated destructor is fine for non-base
40  // classes without bare pointers or other resource use.
41 
42  // Plugins should not be copied or assigned.
43  ShiftEdepSCE(ShiftEdepSCE const &) = delete;
44  ShiftEdepSCE(ShiftEdepSCE &&) = delete;
45  ShiftEdepSCE & operator = (ShiftEdepSCE const &) = delete;
46  ShiftEdepSCE & operator = (ShiftEdepSCE &&) = delete;
47 
48  // Required functions.
49  void produce(art::Event & e) override;
50  void beginJob() override;
51 
52 private:
53 
54  // Declare member data here.
57  TNtuple* fNtEdepAna;
58 
59  //IS calculationg
61 };
62 
63 
65  : fEDepTag(p.get<art::InputTag>("EDepTag")),
66  fMakeAnaTree(p.get<bool>("MakeAnaTree",true))
67 {
68  produces< std::vector<sim::SimEnergyDeposit> >();
69 }
70 
72 {
73  if(fMakeAnaTree){
75  fNtEdepAna = tfs->make<TNtuple>("nt_edep_ana","Edep PosDiff Ana Ntuple","energy:orig_x:orig_y:orig_z:orig_el:orig_ph:shift_x:shift_y:shift_z:shift_el:shift_ph");
76  }
77 
79  fISAlg.Initialize(lar::providerFrom<detinfo::LArPropertiesService>(),
80  lar::providerFrom<detinfo::DetectorPropertiesService>(),
81  &(*lg4paramHandle),
82  lar::providerFrom<spacecharge::SpaceChargeService>());
83 
84 }
85 
87 {
89  fISAlg.Initialize(lar::providerFrom<detinfo::LArPropertiesService>(),
90  lar::providerFrom<detinfo::DetectorPropertiesService>(),
91  &(*lg4paramHandle),
92  lar::providerFrom<spacecharge::SpaceChargeService>());
93  /*
94  art::ServiceHandle<sim::LArG4Parameters> lg4paramHandle;
95  fISAlg.Initialize(lar::providerFrom<detinfo::LArPropertiesService>(),
96  lar::providerFrom<detinfo::DetectorPropertiesService>(),
97  lg4paramHandle,
98  lar::providerFrom<spacecharge::SpaceChargeService>());
99  */
100  auto sce = lar::providerFrom<spacecharge::SpaceChargeService>();
101 
102  std::unique_ptr< std::vector<sim::SimEnergyDeposit> >
103  outEdepVecPtr(new std::vector<sim::SimEnergyDeposit>() );
104  auto & outEdepVec(*outEdepVecPtr);
105 
107  e.getByLabel(fEDepTag,inEdepHandle);
108  auto const& inEdepVec(*inEdepHandle);
109 
110  outEdepVec.reserve(inEdepVec.size());
111 
112  geo::Vector_t posOffsetsStart{0.0,0.0,0.0};
113  geo::Vector_t posOffsetsEnd{0.0,0.0,0.0};
114  for(auto const& edep : inEdepVec){
115  if(sce->EnableSimSpatialSCE()){
116  posOffsetsStart = sce->GetPosOffsets({edep.StartX(),edep.StartY(),edep.StartZ()});
117  posOffsetsEnd = sce->GetPosOffsets({edep.EndX(),edep.EndY(),edep.EndZ()});
118  }
119  fISAlg.Reset();
121  outEdepVec.emplace_back(fISAlg.NumberScintillationPhotons(),
123  edep.Energy(),
124  geo::Point_t{(float)(edep.StartX()-posOffsetsStart.X()), //x should be subtracted
125  (float)(edep.StartY()+posOffsetsStart.Y()),
126  (float)(edep.StartZ()+posOffsetsStart.Z())},
127  geo::Point_t{(float)(edep.EndX()-posOffsetsEnd.X()), //x should be subtracted
128  (float)(edep.EndY()+posOffsetsEnd.Y()),
129  (float)(edep.EndZ()+posOffsetsEnd.Z())},
130  edep.StartT(),
131  edep.EndT(),
132  edep.TrackID(),
133  edep.PdgCode());
134  if(fMakeAnaTree)
135  fNtEdepAna->Fill(edep.Energy(),
136  edep.X(),edep.Y(),edep.Z(),edep.NumElectrons(),edep.NumPhotons(),
137  outEdepVec.back().X(),outEdepVec.back().Y(),outEdepVec.back().Z(),
138  outEdepVec.back().NumElectrons(),outEdepVec.back().NumPhotons());
139 
140  //std::cout << "space charge position: (" << edep.X() << ", " << edep.Y() << ", " << edep.Z() << ") --> (" << outEdepVec.back().X() << ", " << outEdepVec.back().Y() << ", " << outEdepVec.back().Z() << ")" << std::endl;
141  }
142 
143 
144  e.put(std::move(outEdepVecPtr));
145 }
146 
Store parameters for running LArG4.
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
Definition: geo_vectors.h:167
void Initialize(const detinfo::LArProperties *larp, const detinfo::DetectorProperties *detp, const sim::LArG4Parameters *lgp, const spacecharge::SpaceCharge *sce)
void produce(art::Event &e) override
void CalculateIonizationAndScintillation(sim::SimEnergyDeposit const &edep)
ShiftEdepSCE(fhicl::ParameterSet const &p)
ShiftEdepSCE & operator=(ShiftEdepSCE const &)=delete
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
double NumberScintillationPhotons() const
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:42
Double_t edep
Definition: macro.C:13
T * make(ARGS...args) const
double NumberIonizationElectrons() const
larg4::ISCalcSeparate fISAlg
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
contains information for a single step in the detector simulation
HLT enums.
Float_t e
Definition: plot.C:34
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:187