FdLightCollectionEfficiency.h
Go to the documentation of this file.
1 #ifndef _FdLightCollectionEfficiency_FdLightCollectionEfficiency_h_
2 #define _FdLightCollectionEfficiency_FdLightCollectionEfficiency_h_
3 
12 #include "SubModule.h"
13 
14 #include <fwk/VModule.h>
15 #include <map>
16 #include <vector>
17 #include <string>
18 #include <utl/Trace.h>
19 #include <fevt/FdConstants.h>
20 #include <atm/Atmosphere.h>
21 
22 
23 namespace evt {
24  class ShowerFRecData;
25  class ShowerSimData;
26  class Event;
27 }
28 
29 namespace utl {
30  class TabulatedFunctionErrors;
31 }
32 
33 namespace fevt {
34  class FEvent;
35  class Eye;
36  class Telescope;
37 }
38 
39 namespace FdLightCollectionEfficiencyKG {
40  class PixelToApertureLightConverter;
41 
53 
54  public:
58 
59  private:
61  eFixed = 0,
65  };
66  private:
69 
71  fwk::VModule::ResultFlag DoInitialReconstruction(evt::Event& event, std::map<int, evt::ShowerFRecData*>& dataSets);
72 
74  std::pair<fwk::VModule::ResultFlag, unsigned int>
76  unsigned int nRayTracingIterations,
77  const fevt::FdConstants::LightSource lightSource);
78 
80  void FillSimEvent(evt::Event& event,
81  const evt::ShowerFRecData& recData);
82 
91  double CalculateAdditionalIterationsToMeetTarget(const fevt::FEvent& theRealFEvent,
92  const fevt::FEvent& theSimFEvent,
93  const fevt::FdConstants::LightSource& lightSource,
94  const double targetRelUncertainty,
95  const double minRelevantEfficiency);
96 
111  double CalculateTargetRelUncertainty(const fevt::FEvent& theRealFEvent,
112  const fevt::FEvent& theSimFEvent,
113  const fevt::FdConstants::LightSource& lightSource,
114  const double minRelevantEfficiency,
115  const double maxUncertaintyChangeFraction);
116 
118  bool CalculateEfficiency(const evt::Event& simEvent, evt::Event& realEvent,
119  const int eyeId, const unsigned int nRayTracingIterations,
120  const fevt::FdConstants::LightSource lightSource);
121 
123  bool CalculateTelescopeEfficiency(const fevt::Telescope& simTel, fevt::Telescope& realTel,
124  const fevt::Eye& realEye, const unsigned int nRayTracingIterations,
125  const fevt::FdConstants::LightSource lightSource);
126 
129  const fevt::FdConstants::LightSource component,
130  const atm::Atmosphere::EmissionMode lightType);
131 
134  const fevt::FdConstants::LightSource component,
135  const double simTimeOffset,
136  const std::vector<std::vector<unsigned int> >& pixelsInZeta,
137  const utl::TabulatedFunctionErrors& realApLight);
138 
146  const utl::TraceD& apertureTrace,
147  const utl::TraceI& nRayTracedTrace,
148  const double nRayTracingIterations);
149 
155  template<typename T>
156  double
157  CalcTraceBinContent(const utl::Trace<T>& trace, const double start, const double end)
158  {
159  const double binSize = trace.GetBinning();
160 
161  const double maxBin = trace.GetSize()-1;
162 
163  const double relBinStart = start / binSize;
164  const double relBinEnd = end / binSize;
165 
166  const unsigned int relBinStartInt = (unsigned int)relBinStart;
167  const unsigned int relBinEndInt = (unsigned int)relBinEnd;
168 
169  if (relBinStartInt > maxBin)
170  return 0.;
171 
172  if (relBinStartInt == relBinEndInt) {
173  // target bin is part of a single source trace bin
174  const double traceBinFactor = relBinEnd-relBinStart;
175  return trace.At(relBinStartInt) * traceBinFactor;
176  }
177 
178  double binSignal = 0.;
179  // signal from first, partial bin
180  const double startBinFactor = 1. - (relBinStart - relBinStartInt);
181  binSignal += trace.At(relBinStartInt) * startBinFactor;
182 
183  if (relBinEndInt > maxBin)
184  return binSignal;
185 
186  // signal from last, partial bin
187  const double endBinFactor = relBinEnd - relBinEndInt;
188  binSignal += trace.At(relBinEndInt) * endBinFactor;
189 
190  // signal from all intermediate, full bins
191  if (relBinEndInt > maxBin) {
192  for (unsigned int iBin = relBinStartInt+1; iBin < maxBin; ++iBin)
193  binSignal += trace.At(iBin);
194  } else {
195  for (unsigned int iBin = relBinStartInt+1; iBin < relBinEndInt; ++iBin)
196  binSignal += trace.At(iBin);
197  }
198 
199  return binSignal;
200  }
201 
202  void WriteDebugInfo(const int eyeId, const int simTelId, const double simTimeOffset,
203  const fevt::FdConstants::LightSource component,
204  const utl::TabulatedFunctionErrors& totalPixelTrace,
205  const utl::TraceD& totalWlTrace,
206  const utl::TabulatedFunctionErrors& realApLightFlux,
207  const utl::TabulatedFunctionErrors& telEff);
208 
209  // XML configuration flags
210  // Note: Let's keep the use of these globals confined to the central
211  // Init/Run/Finish functions and use parameter passing elsewhere!
212  // One exception for now: verbosity
213 
216 
219 
223  unsigned int fMaxIterations;
226 
231 
235  bool fUseZeta;
236 
243 
246 
247  std::map<std::string, SubModule> fSubModulesList;
248 
249  // Yes, these are officially global variables. Sue me.
251  std::map<unsigned int, utl::TraceD>* fTimeCorrectedApertureTraces;
252 
253  std::vector<fevt::FdConstants::LightSource> fLightComponents;
254 
255  REGISTER_MODULE("FdLightCollectionEfficiencyKG", FdLightCollectionEfficiency);
256  };
257 
258  }
259 
260 #endif
261 
262 // Configure (x)emacs for this file ...
263 // Local Variables:
264 // mode: c++
265 // End:
void WriteDebugInfo(const int eyeId, const int simTelId, const double simTimeOffset, const fevt::FdConstants::LightSource component, const utl::TabulatedFunctionErrors &totalPixelTrace, const utl::TraceD &totalWlTrace, const utl::TabulatedFunctionErrors &realApLightFlux, const utl::TabulatedFunctionErrors &telEff)
T & At(const SizeType i)
trace entry with checked address
Definition: Trace.h:205
std::vector< fevt::FdConstants::LightSource > fLightComponents
utl::TabulatedFunctionErrors CalcTraceDivision(const utl::TabulatedFunctionErrors &pixelTrace, const utl::TraceD &apertureTrace, const utl::TraceI &nRayTracedTrace, const double nRayTracingIterations)
Fluorescence Detector Eye Event.
Definition: FEvent/Eye.h:29
EStopCondition fStopCondition
Condition for stopping the ray tracing loop: eFixed/eTargetUncertainty/eBootstrap.
REGISTER_MODULE("FdLightCollectionEfficiencyKG", FdLightCollectionEfficiency)
for easy iteration over the relevant light components
Utility class to do (cached!) conversion from photons at the pixel to photons at aperture.
double fTargetWorstCaseLAtApUncertaintyChange
Target worst-case change of light at aperture uncertainty.
double GetBinning() const
size of one slot
Definition: Trace.h:138
fwk::VModule::ResultFlag DoInitialReconstruction(evt::Event &event, std::map< int, evt::ShowerFRecData * > &dataSets)
Runs the FdProfileReconstructor before the efficiency calculation.
bool fUseZeta
Collect light within zeta only or in the whole camera?
LightSource
Possible light sources.
Definition: FdConstants.h:9
unsigned int fMaxIterations
Hard limit for the number of iterations. Intended for a fallback, HIGH upper limit.
bool CalculateEfficiency(const evt::Event &simEvent, evt::Event &realEvent, const int eyeId, const unsigned int nRayTracingIterations, const fevt::FdConstants::LightSource lightSource)
Calculates the light collection efficiency of a sim shower.
fwk::VModule::ResultFlag Init()
Initialize: invoked at beginning of run (NOT beginning of event)
void FillSimEvent(evt::Event &event, const evt::ShowerFRecData &recData)
Fill the simulated shower with data from the initial reconstruction.
fwk::VModule::ResultFlag Finish()
Finish: invoked at end of the run (NOT end of the event)
utl::TabulatedFunctionErrors CalculatePixelTraceSum(const fevt::Telescope &tel, const fevt::FdConstants::LightSource component, const double simTimeOffset, const std::vector< std::vector< unsigned int > > &pixelsInZeta, const utl::TabulatedFunctionErrors &realApLight)
Calculate the sum of pixel traces (simTimeOffset in ns)
double CalcTraceBinContent(const utl::Trace< T > &trace, const double start, const double end)
SizeType GetSize() const
Definition: Trace.h:156
Top of Fluorescence Detector event hierarchy.
Definition: FEvent.h:33
Module interface.
Definition: VModule.h:53
double CalculateAdditionalIterationsToMeetTarget(const fevt::FEvent &theRealFEvent, const fevt::FEvent &theSimFEvent, const fevt::FdConstants::LightSource &lightSource, const double targetRelUncertainty, const double minRelevantEfficiency)
std::pair< fwk::VModule::ResultFlag, unsigned int > RunPhotonGenerationRayTracingLoop(evt::Event &event, evt::Event &realEvent, unsigned int nRayTracingIterations, const fevt::FdConstants::LightSource lightSource)
Runs the ShowerPhotonGenerator and TelescopeSimulator nRayTracingIterations times.
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
Light collection efficiency correction for profile reconstruction.
Interface class to access to Fluorescence reconstruction of a Shower.
fwk::VModule::ResultFlag ProcessEvent(evt::Event &realEvent)
Main entry point. Run() is just a proxy.
double fLightAtDiaBinning
Relative time binning factor for the light at diaphragm simulation (default: 10 =&gt; slowish) ...
int fNRayTracingIterations
Number of photon-gen/ray-trace loop iterations.
Fluorescence Detector Telescope Event.
fwk::VModule::ResultFlag Run(evt::Event &event)
Run: invoked once per event.
double CalculateTargetRelUncertainty(const fevt::FEvent &theRealFEvent, const fevt::FEvent &theSimFEvent, const fevt::FdConstants::LightSource &lightSource, const double minRelevantEfficiency, const double maxUncertaintyChangeFraction)
bool CalculateTelescopeEfficiency(const fevt::Telescope &simTel, fevt::Telescope &realTel, const fevt::Eye &realEye, const unsigned int nRayTracingIterations, const fevt::FdConstants::LightSource lightSource)
Calculates the light collection efficiency of a telescope.
double fLowerUncertaintyLimit
Lower limit of the required uncertainty in eSmallEnough mode.
double fProfileXBinning
Depth-binning of the GH =&gt; dEdX/Ne calculation.
utl::TraceD CalculateTelescopeTraceSum(const fevt::Telescope &tel, const fevt::FdConstants::LightSource component, const atm::Atmosphere::EmissionMode lightType)
Calculate the wavelength-efficiency weighted sum of light-at-aperture traces.

, generated on Tue Sep 26 2023.