LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
ISCalcAna_module.cc
Go to the documentation of this file.
1 // 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
10 
18 #include "fhiclcpp/ParameterSet.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")}
61  , fEngine(art::ServiceHandle<rndm::NuRandomService>()->registerAndSeedEngine(
62  createEngine(0, "HepJamesRandom", "NEST"),
63  "HepJamesRandom",
64  "NEST",
65  pset,
66  "SeedNEST"))
67  {
68  std::cout << "ISCalcAna constructor." << std::endl;
69  }
70 
72  {
73  std::cout << "ISCalcAna beginJob." << std::endl;
74  std::cout << "Using " << calcTag.label() << " algorithm to calculate IS." << std::endl;
75 
76  if (calcTag.label() == "Separate")
77  fISAlg = std::make_unique<larg4::ISCalcSeparate>();
78  else if (calcTag.label() == "Correlated") {
79  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService>()->DataForJob();
80  fISAlg = std::make_unique<larg4::ISCalcCorrelated>(detProp, fEngine);
81  }
82  else if (calcTag.label() == "NEST")
83  fISAlg = std::make_unique<larg4::ISCalcNESTLAr>(fEngine);
84  else
85  mf::LogWarning("IonAndScint") << "No ISCalculation set, this can't be good.";
86 
88  fNtuple = tfs->make<TNtuple>(
89  "nt_is",
90  "EDep IS Calc Ntuple",
91  "run:event:t:x:y:z:ds:e:trackid:pdg:e_deposit:n_electron:n_photon:scintyield");
92  }
94  {
95  std::cout << "ISCalcAna endJob." << std::endl;
96  }
97 
99  {
101  if (!event.getByLabel(fEDepTag, edep_handle)) {
102  std::cout << "PDFastSimPAR Module Cannot getByLabel: " << fEDepTag << std::endl;
103  return;
104  }
105 
106  auto const detProp =
108  for (auto const& edepi : *edep_handle) {
109  auto const [energyDeposit, nElectrons, nPhotons, scintYieldRatio] =
110  fISAlg->CalcIonAndScint(detProp, edepi);
111  fNtuple->Fill(event.run(),
112  event.event(),
113  edepi.T(),
114  edepi.X(),
115  edepi.Y(),
116  edepi.Z(),
117  edepi.StepLength(),
118  edepi.Energy(),
119  edepi.TrackID(),
120  edepi.PdgCode(),
121  energyDeposit,
122  nElectrons,
123  nPhotons,
124  scintYieldRatio);
125  }
126 
127  std::cout << "ISCalcAna analyze completed." << std::endl;
128  }
129 }
base_engine_t & createEngine(seed_t seed)
Store parameters for running LArG4.
void beginJob() override
void analyze(art::Event const &event) override
Geant4 interface.
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.cc:6
ISCalcAna & operator=(ISCalcAna const &)=delete
std::string const & label() const noexcept
Definition: InputTag.cc:79
ISCalcAna(fhicl::ParameterSet const &p)
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:65
T get(std::string const &key) const
Definition: ParameterSet.h:314
art::InputTag fEDepTag
art::InputTag calcTag
An art service to assist in the distribution of guaranteed unique seeds to all engines within an art ...
std::unique_ptr< ISCalc > fISAlg
CLHEP::HepRandomEngine & fEngine
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
contains information for a single step in the detector simulation
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
RunNumber_t run() const
Definition: Event.cc:29
Event finding and building.
void endJob() override