All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PMTGainFluctuations1Dynode_tool.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Specific class tool for PMTGainFluctuations
3 // File: PMTGainFluctuations1Dynode_tool.hh
4 // Base class: PMTGainFluctuations.hh
5 // Algorithm based on function
6 // 'multiplicationStageGain(unsigned int i /* = 1 */) const'
7 // in icaruscode/PMT/Algorithms/PMTsimulationAlg.cxx
8 ////////////////////////////////////////////////////////////////////////
9 
10 #include "fhiclcpp/ParameterSet.h"
11 #include "messagefacility/MessageLogger/MessageLogger.h"
12 #include "art/Utilities/ToolMacros.h"
13 #include "art/Utilities/make_tool.h"
14 #include "art/Utilities/ToolConfigTable.h"
15 #include "nurandom/RandomUtils/NuRandomService.h"
16 #include "CLHEP/Random/RandPoissonQ.h"
17 #include "fhiclcpp/types/Atom.h"
18 #include "fhiclcpp/types/Sequence.h"
19 
20 #include <vector>
21 
23 
24 
25 namespace opdet {
26  class PMTGainFluctuations1Dynode;
27 }
28 
29 
31 public:
32 
33  //Configuration parameters
34  struct Config {
35  using Name = fhicl::Name;
36  using Comment = fhicl::Comment;
37 
38  fhicl::Atom<double> dynodeK {
39  Name("DynodeK"),
40  Comment("Gain at each stage is proportional to pow(Voltage,DynodeK)")
41  };
42 
43  fhicl::Atom<double> gain {
44  Name("Gain"),
45  Comment("PMT total gain")
46  };
47 
48  fhicl::Sequence<double> voltageDistribution {
49  Name("VoltageDistribution"),
50  Comment("PMT voltage distribution ratio at each dynode")
51  };
52 
53  };
54 
55  explicit PMTGainFluctuations1Dynode(art::ToolConfigTable<Config> const& config);
56 
57  //Returns fluctuated factor for SPR
58  double GainFluctuation(unsigned int npe, CLHEP::HepRandomEngine* eng) override;
59 
60 private:
61  //Configuration parameters
62  double fDynodeK;
63  double fGain;
64  std::vector<double> fVoltageDistribution;
65 
66  double fDynodeGain;
67 
68  double DynodeGain(unsigned int dynstage);
69 };
70 
71 
72 opdet::PMTGainFluctuations1Dynode::PMTGainFluctuations1Dynode(art::ToolConfigTable<Config> const& config)
73  : fDynodeK { config().dynodeK() }
74  , fGain { config().gain() }
75  , fVoltageDistribution { config().voltageDistribution() }
76  , fDynodeGain { DynodeGain(1) }
77 {
78 }
79 
80 
81 double opdet::PMTGainFluctuations1Dynode::DynodeGain(unsigned int dynstage){
82  double prodRho = 1.0;
83  for(double rho: fVoltageDistribution) prodRho *= rho;
84  double const aVk = std::pow(fGain / std::pow(prodRho, fDynodeK), 1.0/static_cast<double>(fVoltageDistribution.size()));
85  return aVk * std::pow(fVoltageDistribution.at(dynstage - 1), fDynodeK);
86 }
87 
88 
89 double opdet::PMTGainFluctuations1Dynode::GainFluctuation(unsigned int npe, CLHEP::HepRandomEngine* eng){
90  return CLHEP::RandPoissonQ::shoot(eng, npe*fDynodeGain)/fDynodeGain;
91 }
92 
93 
94 DEFINE_ART_CLASS_TOOL(opdet::PMTGainFluctuations1Dynode)
PMTGainFluctuations1Dynode(art::ToolConfigTable< Config > const &config)
double GainFluctuation(unsigned int npe, CLHEP::HepRandomEngine *eng) override
BEGIN_PROLOG vertical distance to the surface Name