ISCalcAna_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: ISCalcAna
3 // Plugin Type: analyzer (art v2_05_00)
4 // File: ISCalcAna_module.cc
5 //
6 // Generated at Tue Mar 7 14:59:03 2017 by Wesley Ketchum using cetskelgen
7 // from cetlib version v1_21_00.
8 // modified at Sept 30, 2019, by muve
9 ////////////////////////////////////////////////////////////////////////
10 
18 #include "fhiclcpp/ParameterSet.h"
20 #include "nurandom/RandomUtils/NuRandomService.h"
21 
22 #include "TNtuple.h"
23 #include "art_root_io/TFileService.h"
24 
29 
35 
36 namespace larg4 {
37  class ISCalcAna : public art::EDAnalyzer {
38  public:
39  explicit ISCalcAna(fhicl::ParameterSet const& p);
40  ISCalcAna(ISCalcAna const&) = delete;
41  ISCalcAna(ISCalcAna&&) = delete;
42  ISCalcAna& operator=(ISCalcAna const&) = delete;
43  ISCalcAna& operator=(ISCalcAna&&) = delete;
44 
45  void analyze(art::Event const& event) override;
46  void beginJob() override;
47  void endJob() override;
48 
49  private:
50  std::unique_ptr<ISCalc> fISAlg;
52  art::InputTag calcTag; // name of calculator to use, NEST or Separate
53  CLHEP::HepRandomEngine& fEngine;
54  TNtuple* fNtuple;
55  };
56 
58  : EDAnalyzer(pset)
59  , fEDepTag{pset.get<art::InputTag>("SimulationLabel")}
60  , calcTag{pset.get<art::InputTag>("ISCalcAlg")}
62  ->createEngine(*this, "HepJamesRandom", "NEST", pset, "SeedNEST"))
63  {
64  std::cout << "ISCalcAna constructor." << std::endl;
65  }
66 
67  void
69  {
70  std::cout << "ISCalcAna beginJob." << std::endl;
71  std::cout << "Using " << calcTag.label() << " algorithm to calculate IS." << std::endl;
72 
73  if (calcTag.label() == "Separate")
74  fISAlg = std::make_unique<larg4::ISCalcSeparate>();
75  else if (calcTag.label() == "Correlated") {
76  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService>()->DataForJob();
77  fISAlg = std::make_unique<larg4::ISCalcCorrelated>(detProp);
78  }
79  else if (calcTag.label() == "NEST")
80  fISAlg = std::make_unique<larg4::ISCalcNESTLAr>(fEngine);
81  else
82  mf::LogWarning("IonAndScint") << "No ISCalculation set, this can't be good.";
83 
85  fNtuple = tfs->make<TNtuple>(
86  "nt_is",
87  "EDep IS Calc Ntuple",
88  "run:event:t:x:y:z:ds:e:trackid:pdg:e_deposit:n_electron:n_photon:scintyield");
89  }
90  void
92  {
93  std::cout << "ISCalcAna endJob." << std::endl;
94  }
95 
96  void
98  {
100  if (!event.getByLabel(fEDepTag, edep_handle)) {
101  std::cout << "PDFastSimPAR Module Cannot getByLabel: " << fEDepTag << std::endl;
102  return;
103  }
104 
105  auto const detProp =
107  for (auto const& edepi : *edep_handle) {
108  auto const [energyDeposit, nElectrons, nPhotons, scintYieldRatio] =
109  fISAlg->CalcIonAndScint(detProp, edepi);
110  fNtuple->Fill(event.run(),
111  event.event(),
112  edepi.T(),
113  edepi.X(),
114  edepi.Y(),
115  edepi.Z(),
116  edepi.StepLength(),
117  edepi.Energy(),
118  edepi.TrackID(),
119  edepi.PdgCode(),
120  energyDeposit,
121  nElectrons,
122  nPhotons,
123  scintYieldRatio);
124  }
125 
126  std::cout << "ISCalcAna analyze completed." << std::endl;
127  }
128 }
Store parameters for running LArG4.
void beginJob() override
void analyze(art::Event const &event) override
Geant4 interface.
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
ISCalcAna & operator=(ISCalcAna const &)=delete
std::string const & label() const noexcept
Definition: InputTag.cc:79
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
ISCalcAna(fhicl::ParameterSet const &p)
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
T get(std::string const &key) const
Definition: ParameterSet.h:271
art::InputTag fEDepTag
p
Definition: test.py:223
RunNumber_t run() const
Definition: DataViewImpl.cc:71
art::InputTag calcTag
std::unique_ptr< ISCalc > fISAlg
CLHEP::HepRandomEngine & fEngine
contains information for a single step in the detector simulation
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
QTextStream & endl(QTextStream &s)
Event finding and building.
void endJob() override