MDetector/Pixel.cc
Go to the documentation of this file.
1 #include <mdet/Pixel.h>
2 
3 #include <mdet/MHierarchyInfo.h>
4 //
5 #include <utl/RandomEngine.h>
6 #include <utl/MathConstants.h>
7 //
8 #include <fwk/RandomEngineRegistry.h>
9 //
10 #include <cmath>
11 //
12 #include <CLHEP/RandomObjects/RandMultiGauss.h>
13 
14 namespace mdet {
15 
16  const char* const
18 
19  const char* const
21 
22  const char * const
24  "amplitudeAndCharge",
25  "amplitudeAndStandardDeviation",
26  "chargeAndStandardDeviation"
27  };
28 
30  (int pId, const det::VManager::IndexMap& parentMap, const PMT& parent) :
31  MDetectorComponent<Pixel>::Type(pId, parentMap),
32  fPMT(parent)
33  {
34  Register(fCrossTalkNormalizationFactor);
35  Register(fPulseParametrization);
36  Register(fPulseAmplitudeMean);
37  Register(fPulseAmplitudeStdDev);
38  Register(fPulseStdDevMean);
39  Register(fPulseStdDevStdDev);
40  Register(fPulseChargeMean);
41  Register(fPulseChargeStdDev);
42  Register(fPulseRelevantWidth);
43  }
44 
45  const CrossTalkContainer&
47  const
48  {
49  // Note that's shared: so once initialized no further loading
50  // will be done.
51  return GetData<CrossTalkContainer,utl::ThrowOnZeroDereference,utl::ShadowPtr>(fNeighborsCrossTalk, "neighborsCrossTalkInside");
52  }
53 
54  const CrossTalkContainer&
56  const
57  {
58  // see the other getters.
59  return GetData<CrossTalkContainer,utl::ThrowOnZeroDereference,utl::ShadowPtr>(fNeighborsCrossTalk, "neighborsCrossTalkSide");
60  }
61 
62  const CrossTalkContainer&
64  const
65  {
66  // see the other getters.
67  return GetData<CrossTalkContainer,utl::ThrowOnZeroDereference,utl::ShadowPtr>(fNeighborsCrossTalk, "neighborsCrossTalkCorner");
68  }
69 
70  const IdsContainer&
72  const
73  {
74  // see the other getters.
75  return GetData<IdsContainer,utl::ThrowOnZeroDereference,utl::ShadowPtr>(fChannelScintillatorFiberIds, "channelScintillatorFiberIds");
76  }
77 
80  const
81  {
82  return PulseParametrizationCreator::Create(GetData(fPulseParametrization, "pulseParametrization"));
83  }
84 
85  double
87  const
88  {
89  return GetData(fPulseAmplitudeMean, "pulseAmplitudeMean");
90  }
91 
92  double
94  const
95  {
96  return GetData(fPulseAmplitudeStdDev, "pulseAmplitudeStdDev");
97  }
98 
99  double
101  const
102  {
103  return GetData(fPulseStdDevMean, "pulseStdDevMean");
104  }
105 
106  double
108  const
109  {
110  return GetData(fPulseStdDevStdDev, "pulseStdDevStdDev");
111  }
112 
113  double
115  const
116  {
117  return GetData(fPulseChargeMean, "pulseChargeMean");
118  }
119 
120  double
122  const
123  {
124  return GetData(fPulseChargeStdDev, "pulseChargeStdDev");
125  }
126 
127  double
129  const
130  {
131  return GetData(fPulseParametersCorrelation, "pulseParametersCorrelation");
132  }
133 
134  double
136  const
137  {
138  return GetData(fPulseRelevantWidth, "pulseRelevantWidth");
139  }
140 
141  Pixel::SPE
143  const
144  {
145  utl::RandomEngine& rnd = fwk::RandomEngineRegistry::GetInstance().Get(fwk::RandomEngineRegistry::eDetector);
146  // Provide spurious initialization for not-so-clever compilers: the following switch/case always enter in some case.
147  double mu1 = 0;
148  double mu2 = 0;
149  double sigma1 = 0;
150  double sigma2 = 0;
152  /*
153  * Retrieve _the_ two parameters as of the chosen parametrization.
154  * Take the name of the enumeration to denote the order of the parameters.
155  */
156  switch (p) {
157  case eAmplitudeAndCharge:
158  mu1 = GetPulseAmplitudeMean();
159  sigma1 = GetPulseAmplitudeStdDev();
160  mu2 = GetPulseChargeMean();
161  sigma2 = GetPulseChargeStdDev();
162  break;
164  mu1 = GetPulseAmplitudeMean();
165  sigma1 = GetPulseAmplitudeStdDev();
166  mu2 = GetPulseStdDevMean();
167  sigma2 = GetPulseStdDevStdDev();
168  break;
170  mu1 = GetPulseChargeMean();
171  sigma1 = GetPulseChargeStdDev();
172  mu2 = GetPulseStdDevMean();
173  sigma2 = GetPulseStdDevStdDev();
174  break;
175  }
176  // Construct the parameters for the multivariate distro.
177  CLHEP::HepSymMatrix covariance(2);
178  covariance[0][0] = sigma1 * sigma1;
179  covariance[1][1] = sigma2 * sigma2;
180  // Recall that it's symmetric by construction: only one position set.
181  covariance[1][0] = GetPulseParametersCorrelation() * sigma1 * sigma2;
182  // Vector with the two means.
183  CLHEP::HepVector means(2);
184  means[0] = mu1;
185  means[1] = mu2;
186  /*
187  * Construct the object to be shoot several times.
188  *
189  * Be careful to pass references to this class, if you pass a pointer
190  * it accepts it anyway, but then the destructor delete the pointed-to
191  * random engine: the common random engine gets deleted!
192  */
193  CLHEP::RandMultiGauss multiGauss(rnd.GetEngine(), means, covariance);
194  /*
195  * Take random numbers.
196  * But take care to have them positive:
197  * it's non sensical to have negative deviation
198  * and, in this case, negative amplitude, or negative charge.
199  */
200  bool anyNegative; // Loop go-on condition.
201  CLHEP::HepVector r; // Collect the results.
202  do {
203  r = multiGauss.fire();
204  anyNegative = false;
205  for (int i = 0; i < r.num_row() && !anyNegative; ++i)
206  anyNegative = r[i] < 0; // Note that we have a shortcut in the condition for the for-loop.
207  } while (anyNegative);
208  /*
209  * Compute the parameters needed for the pulse, given the configured ones.
210  * The parametrization is defined in terms of amplitude and standard-deviation;
211  * if it's charge what's given, then obtain the final parameter according to the
212  * relation
213  * Q = A * sigma * sqrt(2*pi)
214  * where Q is the integral of the pulse all along the real axis.
215  *
216  * As before, provide spurious initialization to please compilers.
217  */
218  double a = 0;
219  double s = 0;
220  switch (p) {
221  case eAmplitudeAndCharge:
222  a = r[0];
223  s = r[1] / r[0] / std::sqrt(utl::kTwoPi);
224  break;
226  a = r[0];
227  s = r[1];
228  break;
230  a = r[0] / r[1] / std::sqrt(utl::kTwoPi);
231  s = r[1];
232  break;
233  }
234  return SPE(*this, a, t, s);
235  }
236 
237  void
238  Pixel::Update(bool invalidateData, bool invalidateComponents)
239  {
240  MDetectorComponent<Pixel>::Type::Update(invalidateData, invalidateComponents);
241  // XXX The particular case of a shadow pointer doesn't fall into the VValidated
242  // category...of course something could be abstracted...this is the only one case
243  // so far....keep this here and that's it.
244  if (invalidateData) {
247  }
248  }
249 
250 }
utl::Validated< double > fPulseAmplitudeStdDev
double GetPulseStdDevStdDev() const
Standard deviation of time spread in SPE pulses.
Amplitude and standard deviation.
static EnumType Create(const int k)
int version of the overloaded creation method.
RandomEngineType & GetEngine()
Definition: RandomEngine.h:32
utl::Validated< double > fPulseStdDevStdDev
static const char *const kComponentsNames[13]
PulseParametrization
SPE can be parametrized fixing two of three parameters.
det::DetectorComponent< C, MManagerProvider > Type
Type specializing det::DetectorComponent for Muon hierarchy.
utl::Validated< double > fPulseParametersCorrelation
std::vector< double > CrossTalkContainer
Typedef for mdet::Pixel crosstalk container.
Definition: PMT_helper.h:21
void Update(std::vector< double > &init, const std::vector< double > &res)
Definition: Util.h:100
utl::Validated< double > fPulseRelevantWidth
static const char *const kComponentsIds[13]
const CrossTalkContainer & GetNeighborsCrossTalkCorner() const
Cross-talk coeffcient for neighbors of corner located pixel.
double GetPulseStdDevMean() const
Mean standard deviation in SPE pulses (time spread).
PulseParametrization GetPulseParametrization() const
Type of SPE parametrization actually employed.
T & GetData(P< T > &d, const std::string &p) const
Common utility function for configuration.
static const char *const kComponentName
double GetPulseChargeStdDev() const
Standard deviation of total charge in SPE pulses.
double GetPulseRelevantWidth() const
Pulse relevant time width.
constexpr double s
Definition: AugerUnits.h:163
utl::Validated< PulseParametrizationForConfig > fPulseParametrization
utl::Validated< double > fPulseAmplitudeMean
Wraps the random number engine used to generate distributions.
Definition: RandomEngine.h:27
constexpr double kTwoPi
Definition: MathConstants.h:27
std::vector< int > IdsContainer
Typedef for container of corresponding Channel, Scintillator, Fiber indices.
double GetPulseAmplitudeMean() const
Mean amplitude of SPE pulses.
Multiple-pixel photo-multiplier tube.
Definition: MDetector/PMT.h:49
utl::Validated< double > fPulseStdDevMean
utl::ShadowPtr< CrossTalkContainer > fNeighborsCrossTalk
Container for cross-talk coefficients.
utl::Validated< double > fPulseChargeMean
double GetPulseParametersCorrelation() const
The correlation between the two selected parameters.
std::map< std::string, std::string > IndexMap
Definition: VManager.h:133
Charge and standard deviation.
Pixel(const int pId, const det::VManager::IndexMap &parentMap, const PMT &parent)
Constructs the pixel.
static const char *const PulseParametrizationTags[]
Tags for textual representation.
static const char *const kComponentId
utl::Validated< double > fPulseChargeStdDev
void Update(const bool invalidateData, const bool invalidateComponents)
double GetPulseChargeMean() const
Mean total charge in SPE pulses.
utl::ShadowPtr< IdsContainer > fChannelScintillatorFiberIds
Container for indices of corresponding Channel, Scintillator, Fiber.
const IdsContainer & GetChannelScintillatorFiberIds() const
Indices for Channel, Scintillator, Fiber of corrresponding Pixel.
const CrossTalkContainer & GetNeighborsCrossTalkSide() const
Cross-talk coeffcient for neighbors of a side (not corner) located pixel.
SPE MakeSPEAt(const double t) const
Constructs an SPE according to this pixel&#39;s characteristics.
const CrossTalkContainer & GetNeighborsCrossTalkInside() const
Cross-talk coeffcient for neighbors of a pixel located inside the pixel matrix.
double GetPulseAmplitudeStdDev() const
Standard deviation of amplitude in SPE pulses.

, generated on Tue Sep 26 2023.