LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
phot::PhotonLibrary Class Reference

#include "PhotonLibrary.h"

Inheritance diagram for phot::PhotonLibrary:
phot::IPhotonLibrary

Public Types

using Counts_t = const float *
 Type for visibility count per optical channel. More...
 
using T0s_t = const float *
 Type for time of arrival per optical channel. More...
 
using Params_t = std::vector< float > const *
 
using Functions_t = TF1 *
 

Public Member Functions

 PhotonLibrary (art::TFileDirectory *pDir=nullptr)
 If no valid pDir is provided, storage features will not be supported. More...
 
TTree * ProduceTTree () const
 
virtual float GetCount (size_t Voxel, size_t OpChannel) const override
 
void SetCount (size_t Voxel, size_t OpChannel, float Count)
 
float GetTimingPar (size_t Voxel, size_t OpChannel, size_t parnum) const
 
void SetTimingPar (size_t Voxel, size_t OpChannel, float Count, size_t parnum)
 
void SetTimingTF1 (size_t Voxel, size_t OpChannel, TF1 func)
 
virtual float GetReflCount (size_t Voxel, size_t OpChannel) const override
 
void SetReflCount (size_t Voxel, size_t OpChannel, float Count)
 
virtual float GetReflT0 (size_t Voxel, size_t OpChannel) const override
 
void SetReflT0 (size_t Voxel, size_t OpChannel, float reflT0)
 
virtual float const * GetCounts (size_t Voxel) const override
 Returns a pointer to NOpChannels() visibility values, one per channel. More...
 
const std::vector< float > * GetTimingPars (size_t Voxel) const
 
TF1 * GetTimingTF1s (size_t Voxel) const
 
virtual float const * GetReflCounts (size_t Voxel) const override
 
virtual float const * GetReflT0s (size_t Voxel) const override
 
bool hasTiming () const
 Returns whether the current library deals with time propagation distributions. More...
 
virtual bool hasReflected () const override
 Returns whether the current library deals with reflected light count. More...
 
virtual bool hasReflectedT0 () const override
 Returns whether the current library deals with reflected light timing. More...
 
void StoreLibraryToFile (std::string LibraryFile, bool storeReflected=false, bool storeReflT0=false, size_t storeTiming=0) const
 
void LoadLibraryFromFile (std::string LibraryFile, size_t NVoxels, bool storeReflected=false, bool storeReflT0=false, size_t storeTiming=0, int maxrange=200)
 
void CreateEmptyLibrary (size_t NVoxels, size_t NChannels, bool storeReflected=false, bool storeReflT0=false, size_t storeTiming=0)
 
size_t LibrarySize () const
 Returns the number of elements in the library. More...
 
Metadata: voxel information
bool hasVoxelDef () const
 Returns whether voxel metadata is available. More...
 
sim::PhotonVoxelDef const & GetVoxelDef () const
 
void SetVoxelDef (sim::PhotonVoxelDef const &voxelDef)
 

Private Member Functions

virtual int NOpChannels () const override
 
virtual int NVoxels () const override
 
virtual bool isVoxelValid (size_t Voxel) const override
 
bool isVoxelValidImpl (size_t Voxel) const
 
size_t uncheckedIndex (size_t Voxel, size_t OpChannel) const
 Returns the index of visibility of specified voxel and cell. More...
 
float uncheckedAccess (size_t Voxel, size_t OpChannel) const
 Unchecked access to a visibility datum. More...
 
float & uncheckedAccess (size_t Voxel, size_t OpChannel)
 Unchecked access to a visibility datum. More...
 
float uncheckedAccessRefl (size_t Voxel, size_t OpChannel) const
 Unchecked access to a reflected visibility datum. More...
 
float & uncheckedAccessRefl (size_t Voxel, size_t OpChannel)
 Unchecked access to a reflected visibility datum. More...
 
float uncheckedAccessReflT (size_t Voxel, size_t OpChannel) const
 Unchecked access to a reflected T0 visibility datum. More...
 
float & uncheckedAccessReflT (size_t Voxel, size_t OpChannel)
 Unchecked access to a reflected T0 visibility datum. More...
 
float uncheckedAccessTimingPar (size_t Voxel, size_t OpChannel, size_t parnum) const
 Unchecked access to a parameter the time distribution. More...
 
float & uncheckedAccessTimingPar (size_t Voxel, size_t OpChannel, size_t parnum)
 Unchecked access to a parameter of the time distribution. More...
 
TF1 & uncheckedAccessTimingTF1 (size_t Voxel, size_t OpChannel)
 Unchecked access to a parameter of the time distribution. More...
 
const TF1 & uncheckedAccessTimingTF1 (size_t Voxel, size_t OpChannel) const
 Unchecked access to a parameter of the time distribution. More...
 
void LoadMetadata (TDirectory &srcDir)
 Reads the metadata from specified ROOT directory and sets it as current. More...
 
void StoreMetadata () const
 Writes the current metadata (if any) into the ROOT output file. More...
 

Static Private Member Functions

static size_t ExtractNOpChannels (TTree *tree)
 Returns the number of optical channels in the specified tree. More...
 
static int size_t2int (size_t val)
 Converts size_t into integer. More...
 

Private Attributes

bool fHasReflected = false
 Whether the current library deals with reflected light counts. More...
 
bool fHasReflectedT0
 Whether the current library deals with reflected light timing. More...
 
size_t fHasTiming
 Whether the current library deals with time propagation distribution. More...
 
util::LazyVector< float > fLookupTable
 
util::LazyVector< float > fReflLookupTable
 
util::LazyVector< float > fReflTLookupTable
 
util::LazyVector< std::vector< float > > fTimingParLookupTable
 
util::LazyVector< TF1 > fTimingParTF1LookupTable
 
std::string fTimingParFormula
 
size_t fTimingParNParameters
 
size_t fNOpChannels
 
size_t fNVoxels
 
std::optional< sim::PhotonVoxelDeffVoxelDef
 Voxel definition loaded from library metadata. More...
 
art::TFileDirectory * fDir = nullptr
 ROOT directory where to write data. More...
 

Static Private Attributes

static std::string const OpChannelBranchName = "OpChannel"
 Name of the optical channel number in the input tree. More...
 

Detailed Description

Definition at line 25 of file PhotonLibrary.h.

Member Typedef Documentation

using phot::IPhotonLibrary::Counts_t = const float*
inherited

Type for visibility count per optical channel.

Definition at line 17 of file IPhotonLibrary.h.

using phot::IPhotonLibrary::Functions_t = TF1*
inherited

Type for parametrization function (which is not part of this interface yet).

Definition at line 28 of file IPhotonLibrary.h.

using phot::IPhotonLibrary::Params_t = std::vector<float> const*
inherited

Type for function parameters (which is not part of this interface yet).

Definition at line 24 of file IPhotonLibrary.h.

using phot::IPhotonLibrary::T0s_t = const float*
inherited

Type for time of arrival per optical channel.

Definition at line 20 of file IPhotonLibrary.h.

Constructor & Destructor Documentation

phot::PhotonLibrary::PhotonLibrary ( art::TFileDirectory *  pDir = nullptr)

If no valid pDir is provided, storage features will not be supported.

Definition at line 45 of file PhotonLibrary.cxx.

45 : fDir(pDir) {}
art::TFileDirectory * fDir
ROOT directory where to write data.

Member Function Documentation

void phot::PhotonLibrary::CreateEmptyLibrary ( size_t  NVoxels,
size_t  NChannels,
bool  storeReflected = false,
bool  storeReflT0 = false,
size_t  storeTiming = 0 
)

Definition at line 131 of file PhotonLibrary.cxx.

References util::LazyVector< T, A >::clear(), fHasReflected, fHasReflectedT0, fHasTiming, fLookupTable, fNOpChannels, fNVoxels, fReflLookupTable, fReflTLookupTable, fTimingParLookupTable, fTimingParTF1LookupTable, phot::IPhotonLibrary::LibrarySize(), NOpChannels(), NVoxels(), and util::LazyVector< T, A >::resize().

137  {
143 
144  fNVoxels = NVoxels;
146 
148  fHasReflected = storeReflected;
149  if (storeReflected) fReflLookupTable.resize(LibrarySize());
150  fHasReflectedT0 = storeReflT0;
151  if (storeReflT0) fReflTLookupTable.resize(LibrarySize());
152  fHasTiming = storeTiming;
153  if (storeTiming != 0) {
156  }
157  }
size_t fHasTiming
Whether the current library deals with time propagation distribution.
util::LazyVector< float > fReflLookupTable
bool fHasReflectedT0
Whether the current library deals with reflected light timing.
virtual int NOpChannels() const override
void clear()
Removes all stored data and sets the nominal size to 0.
Definition: LazyVector.h:587
util::LazyVector< float > fLookupTable
bool fHasReflected
Whether the current library deals with reflected light counts.
util::LazyVector< TF1 > fTimingParTF1LookupTable
size_t LibrarySize() const
Returns the number of elements in the library.
void resize(size_type newSize)
Changes the nominal size of the container.
Definition: LazyVector.h:567
util::LazyVector< std::vector< float > > fTimingParLookupTable
util::LazyVector< float > fReflTLookupTable
virtual int NVoxels() const override
size_t phot::PhotonLibrary::ExtractNOpChannels ( TTree *  tree)
staticprivate

Returns the number of optical channels in the specified tree.

Definition at line 557 of file PhotonLibrary.cxx.

References MF_LOG_DEBUG, art::errors::NotFound, and OpChannelBranchName.

Referenced by LoadLibraryFromFile().

558  {
559  TBranch* channelBranch = tree->GetBranch(OpChannelBranchName.c_str());
560  if (!channelBranch) {
562  << "Tree '" << tree->GetName() << "' has no branch 'OpChannel'";
563  }
564 
565  // fix a new local address for the branch
566  char* oldAddress = channelBranch->GetAddress();
567  Int_t channel;
568  channelBranch->SetAddress(&channel);
569  Int_t maxChannel = -1;
570 
571  // read all the channel values and pick the largest one
572  Long64_t iEntry = 0;
573  while (channelBranch->GetEntry(iEntry++)) {
574  if (channel > maxChannel) maxChannel = channel;
575  } // while
576 
577  MF_LOG_DEBUG("PhotonLibrary") << "Detected highest channel to be " << maxChannel << " from "
578  << iEntry << " tree entries";
579 
580  // restore the old branch address
581  channelBranch->SetAddress(oldAddress);
582 
583  return size_t(maxChannel + 1);
584 
585  } // PhotonLibrary::ExtractNOpChannels()
static std::string const OpChannelBranchName
Name of the optical channel number in the input tree.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
#define MF_LOG_DEBUG(id)
float phot::PhotonLibrary::GetCount ( size_t  Voxel,
size_t  OpChannel 
) const
overridevirtual

Implements phot::IPhotonLibrary.

Definition at line 305 of file PhotonLibrary.cxx.

References fNOpChannels, fNVoxels, and uncheckedAccess().

306  {
307  if ((Voxel >= fNVoxels) || (OpChannel >= fNOpChannels))
308  return 0;
309  else
310  return uncheckedAccess(Voxel, OpChannel);
311  }
float uncheckedAccess(size_t Voxel, size_t OpChannel) const
Unchecked access to a visibility datum.
float const * phot::PhotonLibrary::GetCounts ( size_t  Voxel) const
overridevirtual

Returns a pointer to NOpChannels() visibility values, one per channel.

Implements phot::IPhotonLibrary.

Definition at line 392 of file PhotonLibrary.cxx.

References util::LazyVector< T, A >::data_address(), fLookupTable, fNVoxels, and uncheckedIndex().

393  {
394  if (Voxel >= fNVoxels)
395  return nullptr;
396  else
397  return fLookupTable.data_address(uncheckedIndex(Voxel, 0));
398  }
const_pointer data_address(size_type pos) const
Returns a constant pointer to the specified element.
Definition: LazyVector.h:549
size_t uncheckedIndex(size_t Voxel, size_t OpChannel) const
Returns the index of visibility of specified voxel and cell.
util::LazyVector< float > fLookupTable
float phot::PhotonLibrary::GetReflCount ( size_t  Voxel,
size_t  OpChannel 
) const
overridevirtual

Implements phot::IPhotonLibrary.

Definition at line 322 of file PhotonLibrary.cxx.

References fNOpChannels, fNVoxels, and uncheckedAccessRefl().

323  {
324  if ((Voxel >= fNVoxels) || (OpChannel >= fNOpChannels))
325  return 0;
326  else
327  return uncheckedAccessRefl(Voxel, OpChannel);
328  }
float uncheckedAccessRefl(size_t Voxel, size_t OpChannel) const
Unchecked access to a reflected visibility datum.
float const * phot::PhotonLibrary::GetReflCounts ( size_t  Voxel) const
overridevirtual

Implements phot::IPhotonLibrary.

Definition at line 440 of file PhotonLibrary.cxx.

References util::LazyVector< T, A >::data_address(), fNVoxels, fReflLookupTable, and uncheckedIndex().

441  {
442  if (Voxel >= fNVoxels)
443  return nullptr;
444  else
445  return fReflLookupTable.data_address(uncheckedIndex(Voxel, 0));
446  }
const_pointer data_address(size_type pos) const
Returns a constant pointer to the specified element.
Definition: LazyVector.h:549
util::LazyVector< float > fReflLookupTable
size_t uncheckedIndex(size_t Voxel, size_t OpChannel) const
Returns the index of visibility of specified voxel and cell.
float phot::PhotonLibrary::GetReflT0 ( size_t  Voxel,
size_t  OpChannel 
) const
overridevirtual

Implements phot::IPhotonLibrary.

Definition at line 331 of file PhotonLibrary.cxx.

References fNOpChannels, fNVoxels, and uncheckedAccessReflT().

332  {
333  if ((Voxel >= fNVoxels) || (OpChannel >= fNOpChannels))
334  return 0;
335  else
336  return uncheckedAccessReflT(Voxel, OpChannel);
337  }
float uncheckedAccessReflT(size_t Voxel, size_t OpChannel) const
Unchecked access to a reflected T0 visibility datum.
float const * phot::PhotonLibrary::GetReflT0s ( size_t  Voxel) const
overridevirtual

Implements phot::IPhotonLibrary.

Definition at line 450 of file PhotonLibrary.cxx.

References util::LazyVector< T, A >::data_address(), fNVoxels, fReflTLookupTable, and uncheckedIndex().

451  {
452  if (Voxel >= fNVoxels)
453  return nullptr;
454  else
456  }
const_pointer data_address(size_type pos) const
Returns a constant pointer to the specified element.
Definition: LazyVector.h:549
size_t uncheckedIndex(size_t Voxel, size_t OpChannel) const
Returns the index of visibility of specified voxel and cell.
util::LazyVector< float > fReflTLookupTable
float phot::PhotonLibrary::GetTimingPar ( size_t  Voxel,
size_t  OpChannel,
size_t  parnum 
) const

Definition at line 314 of file PhotonLibrary.cxx.

References fNOpChannels, fNVoxels, and uncheckedAccessTimingPar().

Referenced by phot::PhotonVisibilityService::GetLibraryTimingParEntry().

315  {
316  if ((Voxel >= fNVoxels) || (OpChannel >= fNOpChannels))
317  return 0;
318  else
319  return uncheckedAccessTimingPar(Voxel, OpChannel, parnum);
320  } //----------------------------------------------------
float uncheckedAccessTimingPar(size_t Voxel, size_t OpChannel, size_t parnum) const
Unchecked access to a parameter the time distribution.
const std::vector< float > * phot::PhotonLibrary::GetTimingPars ( size_t  Voxel) const

Definition at line 402 of file PhotonLibrary.cxx.

References util::LazyVector< T, A >::data_address(), fNVoxels, fTimingParLookupTable, and uncheckedIndex().

Referenced by phot::PhotonVisibilityService::GetLibraryTimingParEntries().

403  {
404  if (Voxel >= fNVoxels)
405  return nullptr;
406  else
408  }
const_pointer data_address(size_type pos) const
Returns a constant pointer to the specified element.
Definition: LazyVector.h:549
size_t uncheckedIndex(size_t Voxel, size_t OpChannel) const
Returns the index of visibility of specified voxel and cell.
util::LazyVector< std::vector< float > > fTimingParLookupTable
TF1 * phot::PhotonLibrary::GetTimingTF1s ( size_t  Voxel) const

Definition at line 412 of file PhotonLibrary.cxx.

References util::LazyVector< T, A >::data_address(), fNVoxels, fTimingParTF1LookupTable, and uncheckedIndex().

Referenced by phot::PhotonVisibilityService::GetLibraryTimingTF1Entries().

413  {
414  if (Voxel >= fNVoxels) return nullptr;
415  /*
416  * Sorry, Universe, but we can't undergo ROOT's bad design hell.
417  * TF1::GetRandom() is non-const member, because it uses some internal
418  * integral information which can be produced on the spot instead than
419  * always be present. That's called caching, it's Good, but it must not
420  * interfere with constantness of the interface (in fact, this is one of
421  * the few acceptable uses of `mutable` members).
422  * Because of this, this method can't return a constant `TF1`, therefore
423  * it can't be constant, therefore the underlying access returning a
424  * constant object is not acceptable.
425  * So I do the Bad thing.
426  * Plus I opened JIRA ROOT-9549
427  * (https://sft.its.cern.ch/jira/browse/ROOT-9549).
428  * After that is solved, this method should become:
429  *
430  * TF1 const* PhotonLibrary::GetTimingTF1s(size_t Voxel) const
431  *
432  * and the users should update their code accordingly.
433  */
434  else
435  return const_cast<TF1*>(fTimingParTF1LookupTable.data_address(uncheckedIndex(Voxel, 0)));
436  }
const_pointer data_address(size_type pos) const
Returns a constant pointer to the specified element.
Definition: LazyVector.h:549
size_t uncheckedIndex(size_t Voxel, size_t OpChannel) const
Returns the index of visibility of specified voxel and cell.
util::LazyVector< TF1 > fTimingParTF1LookupTable
sim::PhotonVoxelDef const& phot::PhotonLibrary::GetVoxelDef ( ) const
inline

Returns the current voxel metadata (undefined behaviour if none).

See also
hasVoxelDef()

Definition at line 89 of file PhotonLibrary.h.

Referenced by phot::PhotonVisibilityService::LoadLibrary(), LoadLibraryFromFile(), and StoreMetadata().

90  {
91  assert(fVoxelDef);
92  return *fVoxelDef;
93  }
std::optional< sim::PhotonVoxelDef > fVoxelDef
Voxel definition loaded from library metadata.
virtual bool phot::PhotonLibrary::hasReflected ( ) const
inlineoverridevirtual

Returns whether the current library deals with reflected light count.

Implements phot::IPhotonLibrary.

Definition at line 59 of file PhotonLibrary.h.

Referenced by StoreLibraryToFile().

59 { return fHasReflected; }
bool fHasReflected
Whether the current library deals with reflected light counts.
virtual bool phot::PhotonLibrary::hasReflectedT0 ( ) const
inlineoverridevirtual

Returns whether the current library deals with reflected light timing.

Implements phot::IPhotonLibrary.

Definition at line 62 of file PhotonLibrary.h.

Referenced by StoreLibraryToFile().

62 { return fHasReflectedT0; }
bool fHasReflectedT0
Whether the current library deals with reflected light timing.
bool phot::PhotonLibrary::hasTiming ( ) const
inline

Returns whether the current library deals with time propagation distributions.

Definition at line 56 of file PhotonLibrary.h.

Referenced by StoreLibraryToFile().

56 { return fHasTiming; }
size_t fHasTiming
Whether the current library deals with time propagation distribution.
bool phot::PhotonLibrary::hasVoxelDef ( ) const
inline

Returns whether voxel metadata is available.

Definition at line 85 of file PhotonLibrary.h.

Referenced by phot::PhotonVisibilityService::LoadLibrary(), LoadLibraryFromFile(), and StoreMetadata().

85 { return fVoxelDef.has_value(); }
std::optional< sim::PhotonVoxelDef > fVoxelDef
Voxel definition loaded from library metadata.
virtual bool phot::PhotonLibrary::isVoxelValid ( size_t  Voxel) const
inlineoverrideprivatevirtual

Reimplemented from phot::IPhotonLibrary.

Definition at line 106 of file PhotonLibrary.h.

106 { return isVoxelValidImpl(Voxel); }
bool isVoxelValidImpl(size_t Voxel) const
bool phot::PhotonLibrary::isVoxelValidImpl ( size_t  Voxel) const
inlineprivate

Definition at line 134 of file PhotonLibrary.h.

134 { return Voxel < fNVoxels; }
size_t phot::IPhotonLibrary::LibrarySize ( ) const
inlineinherited

Returns the number of elements in the library.

Definition at line 53 of file IPhotonLibrary.h.

References phot::IPhotonLibrary::NOpChannels(), and phot::IPhotonLibrary::NVoxels().

Referenced by CreateEmptyLibrary(), and LoadLibraryFromFile().

53 { return NVoxels() * NOpChannels(); }
virtual int NOpChannels() const =0
virtual int NVoxels() const =0
void phot::PhotonLibrary::LoadLibraryFromFile ( std::string  LibraryFile,
size_t  NVoxels,
bool  storeReflected = false,
bool  storeReflT0 = false,
size_t  storeTiming = 0,
int  maxrange = 200 
)

Definition at line 161 of file PhotonLibrary.cxx.

References util::LazyVector< T, A >::clear(), util::LazyVector< T, A >::data_init(), ExtractNOpChannels(), f, fHasReflected, fHasReflectedT0, fHasTiming, fLookupTable, fNOpChannels, fNVoxels, fReflLookupTable, fReflTLookupTable, fTimingParFormula, fTimingParLookupTable, fTimingParNParameters, fTimingParTF1LookupTable, GetVoxelDef(), hasVoxelDef(), phot::IPhotonLibrary::LibrarySize(), LoadMetadata(), n, NVoxels(), util::LazyVector< T, A >::resize(), uncheckedAccess(), uncheckedAccessRefl(), uncheckedAccessReflT(), and uncheckedAccessTimingTF1().

Referenced by phot::PhotonVisibilityService::LoadLibrary().

167  {
173 
174  mf::LogInfo("PhotonLibrary") << "Reading photon library from input file: "
175  << LibraryFile.c_str() << std::endl;
176 
177  TFile* f = nullptr;
178  TTree* tt = nullptr;
179  TDirectory* pSrcDir = nullptr;
180 
181  try {
182  f = TFile::Open(LibraryFile.c_str());
183  tt = (TTree*)f->Get("PhotonLibraryData");
184  if (tt) { pSrcDir = f; }
185  else { // Library not in the top directory
186  TKey* key = f->FindKeyAny("PhotonLibraryData");
187  if (key) {
188  tt = (TTree*)key->ReadObj();
189  pSrcDir = key->GetMotherDir();
190  }
191  else {
192  mf::LogError("PhotonLibrary") << "PhotonLibraryData not found in file" << LibraryFile;
193  }
194  }
195  }
196  catch (...) {
197  throw cet::exception("PhotonLibrary")
198  << "Error in ttree load, reading photon library: " << LibraryFile << "\n";
199  }
200 
201  Int_t Voxel;
202  Int_t OpChannel;
203  Float_t Visibility;
204  Float_t ReflVisibility;
205  Float_t ReflTfirst;
206  std::vector<Float_t> timing_par;
207 
208  tt->SetBranchAddress("Voxel", &Voxel);
209  tt->SetBranchAddress("OpChannel", &OpChannel);
210  tt->SetBranchAddress("Visibility", &Visibility);
211 
212  fHasTiming = getTiming;
213 
214  fHasReflected = getReflected;
215  if (getReflected) tt->SetBranchAddress("ReflVisibility", &ReflVisibility);
216  fHasReflectedT0 = getReflT0;
217  if (getReflT0) tt->SetBranchAddress("ReflTfirst", &ReflTfirst);
218 
219  fNVoxels = NVoxels;
220  fNOpChannels = PhotonLibrary::ExtractNOpChannels(tt); // EXPENSIVE!!!
221 
222  // with STL vectors, where `resize()` directly controls the allocation of
223  // memory, reserving the space is redundant; not so with `util::LazyVector`,
224  // where `resize()` never increases the memory; `data_init()` allocates
225  // all the storage we need at once, effectively suppressing the laziness
226  // of the vector (by design, that was only relevant in `CreateEmptyLibrary()`)
229 
230  if (fHasTiming != 0) {
231  timing_par.resize(getTiming);
232  tt->SetBranchAddress("timing_par", timing_par.data());
234  // should be pSrcDir->Get()? kept as is for backward compatibility
235  TNamed* n = (TNamed*)f->Get("fTimingParFormula");
236  if (!n)
237  mf::LogError("PhotonLibrary")
238  << "Error reading the photon propagation formula. Please check the photon library."
239  << std::endl;
240  fTimingParFormula = n->GetTitle();
243  mf::LogInfo("PhotonLibrary")
244  << "Time parametrization is activated. Using the formula: " << fTimingParFormula << " with "
245  << fTimingParNParameters << " parameters." << std::endl;
246  }
247  if (fHasReflected) {
250  }
251  if (fHasReflectedT0) {
254  }
255 
256  size_t NEntries = tt->GetEntries();
257 
258  for (size_t i = 0; i != NEntries; ++i) {
259 
260  tt->GetEntry(i);
261 
262  // Set the visibility at this optical channel
263  uncheckedAccess(Voxel, OpChannel) = Visibility;
264 
265  if (fHasReflected) uncheckedAccessRefl(Voxel, OpChannel) = ReflVisibility;
266  if (fHasReflectedT0) uncheckedAccessReflT(Voxel, OpChannel) = ReflTfirst;
267  if (fHasTiming != 0) {
268  // TODO: use TF1::Copy
269  TF1 timingfunction(Form("timing_%i_%i", Voxel, OpChannel),
270  fTimingParFormula.c_str(),
271  timing_par[0],
272  fTimingMaxRange);
273  timingfunction.SetParameter(
274  0,
275  0.0); //first parameter is now in the range. Let's do this to keep compatible with old libraries.
276  for (size_t k = 1; k < fTimingParNParameters; k++) {
277  timingfunction.SetParameter(k, timing_par[k]);
278  }
279 
280  uncheckedAccessTimingTF1(Voxel, OpChannel) = timingfunction;
281  }
282  } // for entries
283 
284  LoadMetadata(*pSrcDir);
285  {
286  mf::LogInfo log("PhotonLibrary");
287  log << "Photon lookup table size : " << NVoxels << " voxels, " << fNOpChannels
288  << " channels";
289  if (hasVoxelDef())
290  log << "; " << GetVoxelDef();
291  else
292  log << " (no voxel geometry included)";
293  }
294 
295  try {
296  f->Close();
297  }
298  catch (...) {
299  mf::LogError("PhotonLibrary") << "Error in closing file : " << LibraryFile;
300  }
301  }
size_t fHasTiming
Whether the current library deals with time propagation distribution.
util::LazyVector< float > fReflLookupTable
bool fHasReflectedT0
Whether the current library deals with reflected light timing.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
sim::PhotonVoxelDef const & GetVoxelDef() const
Definition: PhotonLibrary.h:89
bool hasVoxelDef() const
Returns whether voxel metadata is available.
Definition: PhotonLibrary.h:85
void data_init(size_type startIndex, size_type endIndex)
Allocates the specified range and stores default values for it.
Definition: LazyVector.h:609
void clear()
Removes all stored data and sets the nominal size to 0.
Definition: LazyVector.h:587
float uncheckedAccess(size_t Voxel, size_t OpChannel) const
Unchecked access to a visibility datum.
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
float uncheckedAccessReflT(size_t Voxel, size_t OpChannel) const
Unchecked access to a reflected T0 visibility datum.
std::string fTimingParFormula
TFile f
Definition: plotHisto.C:6
util::LazyVector< float > fLookupTable
static size_t ExtractNOpChannels(TTree *tree)
Returns the number of optical channels in the specified tree.
Definition: type_traits.h:61
bool fHasReflected
Whether the current library deals with reflected light counts.
TF1 & uncheckedAccessTimingTF1(size_t Voxel, size_t OpChannel)
Unchecked access to a parameter of the time distribution.
util::LazyVector< TF1 > fTimingParTF1LookupTable
float uncheckedAccessRefl(size_t Voxel, size_t OpChannel) const
Unchecked access to a reflected visibility datum.
size_t LibrarySize() const
Returns the number of elements in the library.
Char_t n[5]
void resize(size_type newSize)
Changes the nominal size of the container.
Definition: LazyVector.h:567
util::LazyVector< std::vector< float > > fTimingParLookupTable
util::LazyVector< float > fReflTLookupTable
virtual int NVoxels() const override
void LoadMetadata(TDirectory &srcDir)
Reads the metadata from specified ROOT directory and sets it as current.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void phot::PhotonLibrary::LoadMetadata ( TDirectory &  srcDir)
private

Reads the metadata from specified ROOT directory and sets it as current.

Definition at line 459 of file PhotonLibrary.cxx.

References fVoxelDef.

Referenced by LoadLibraryFromFile().

460  {
461 
462  constexpr std::size_t NExpectedKeys = 9U;
463 
464  std::vector<std::string> missingKeys;
465 
466  RooReader<RooInt, Int_t> readInt{srcDir, missingKeys};
467  RooReader<RooDouble, Double_t> readDouble{srcDir, missingKeys};
468 
469  // FIXME: Not sure initializing to 0 is appropriate.
470  double xMin{};
471  double xMax{};
472  int xN{};
473  double yMin{};
474  double yMax{};
475  int yN{};
476  double zMin{};
477  double zMax{};
478  int zN{};
479  if (auto metaValue = readDouble("MinX")) xMin = *metaValue;
480  if (auto metaValue = readDouble("MaxX")) xMax = *metaValue;
481  if (auto metaValue = readInt("NDivX")) xN = *metaValue;
482  if (auto metaValue = readDouble("MinY")) yMin = *metaValue;
483  if (auto metaValue = readDouble("MaxY")) yMax = *metaValue;
484  if (auto metaValue = readInt("NDivY")) yN = *metaValue;
485  if (auto metaValue = readDouble("MinZ")) zMin = *metaValue;
486  if (auto metaValue = readDouble("MaxZ")) zMax = *metaValue;
487  if (auto metaValue = readInt("NDivZ")) zN = *metaValue;
488 
489  if (!missingKeys.empty()) {
490  if (missingKeys.size() != NExpectedKeys) {
491  mf::LogError log("PhotonLibrary");
492  log << "Photon library at '" << srcDir.GetPath() << "' is missing " << missingKeys.size()
493  << " metadata elements:";
494  for (auto const& key : missingKeys)
495  log << " '" << key << "'";
496  }
497  else {
498  mf::LogTrace("PhotonLibrary") << "No voxel metadata found in '" << srcDir.GetPath() << "'";
499  }
500  return;
501  } // if missing keys
502 
503  fVoxelDef.emplace(xMin, xMax, xN, yMin, yMax, yN, zMin, zMax, zN);
504 
505  } // PhotonLibrary::LoadMetadata()
std::optional< sim::PhotonVoxelDef > fVoxelDef
Voxel definition loaded from library metadata.
MaybeLogger_< ELseverityLevel::ELsev_success, true > LogTrace
virtual int phot::PhotonLibrary::NOpChannels ( ) const
inlineoverrideprivatevirtual

Implements phot::IPhotonLibrary.

Definition at line 103 of file PhotonLibrary.h.

Referenced by CreateEmptyLibrary().

103 { return fNOpChannels; }
virtual int phot::PhotonLibrary::NVoxels ( ) const
inlineoverrideprivatevirtual

Implements phot::IPhotonLibrary.

Definition at line 104 of file PhotonLibrary.h.

Referenced by CreateEmptyLibrary(), and LoadLibraryFromFile().

104 { return fNVoxels; }
TTree* phot::PhotonLibrary::ProduceTTree ( ) const
void phot::PhotonLibrary::SetCount ( size_t  Voxel,
size_t  OpChannel,
float  Count 
)

Definition at line 341 of file PhotonLibrary.cxx.

References fNOpChannels, fNVoxels, and uncheckedAccess().

Referenced by phot::PhotonVisibilityService::SetLibraryEntry().

342  {
343  if ((Voxel >= fNVoxels) || (OpChannel >= fNOpChannels))
344  mf::LogError("PhotonLibrary")
345  << "Error - attempting to set count in voxel " << Voxel << " which is out of range";
346  else
347  uncheckedAccess(Voxel, OpChannel) = Count;
348  }
float uncheckedAccess(size_t Voxel, size_t OpChannel) const
Unchecked access to a visibility datum.
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
void phot::PhotonLibrary::SetReflCount ( size_t  Voxel,
size_t  OpChannel,
float  Count 
)

Definition at line 371 of file PhotonLibrary.cxx.

References fNOpChannels, fNVoxels, and uncheckedAccessRefl().

Referenced by phot::PhotonVisibilityService::SetLibraryEntry().

372  {
373  if ((Voxel >= fNVoxels) || (OpChannel >= fNOpChannels))
374  mf::LogError("PhotonLibrary")
375  << "Error - attempting to set count in voxel " << Voxel << " which is out of range";
376  else
377  uncheckedAccessRefl(Voxel, OpChannel) = Count;
378  }
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
float uncheckedAccessRefl(size_t Voxel, size_t OpChannel) const
Unchecked access to a reflected visibility datum.
void phot::PhotonLibrary::SetReflT0 ( size_t  Voxel,
size_t  OpChannel,
float  reflT0 
)

Definition at line 381 of file PhotonLibrary.cxx.

References fNOpChannels, fNVoxels, and uncheckedAccessReflT().

Referenced by phot::PhotonVisibilityService::SetLibraryReflT0Entry().

382  {
383  if ((Voxel >= fNVoxels) || (OpChannel >= fNOpChannels))
384  mf::LogError("PhotonLibrary")
385  << "Error - attempting to set count in voxel " << Voxel << " which is out of range";
386  else
387  uncheckedAccessReflT(Voxel, OpChannel) = Count;
388  }
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
float uncheckedAccessReflT(size_t Voxel, size_t OpChannel) const
Unchecked access to a reflected T0 visibility datum.
void phot::PhotonLibrary::SetTimingPar ( size_t  Voxel,
size_t  OpChannel,
float  Count,
size_t  parnum 
)

Definition at line 351 of file PhotonLibrary.cxx.

References fNOpChannels, fNVoxels, and uncheckedAccessTimingPar().

Referenced by phot::PhotonVisibilityService::SetLibraryTimingParEntry().

352  {
353  if ((Voxel >= fNVoxels) || (OpChannel >= fNOpChannels))
354  mf::LogError("PhotonLibrary") << "Error - attempting to set timing t0 count in voxel "
355  << Voxel << " which is out of range";
356  else
357  uncheckedAccessTimingPar(Voxel, OpChannel, parnum) = Count;
358  }
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
float uncheckedAccessTimingPar(size_t Voxel, size_t OpChannel, size_t parnum) const
Unchecked access to a parameter the time distribution.
void phot::PhotonLibrary::SetTimingTF1 ( size_t  Voxel,
size_t  OpChannel,
TF1  func 
)

Definition at line 361 of file PhotonLibrary.cxx.

References fNOpChannels, fNVoxels, and uncheckedAccessTimingTF1().

Referenced by phot::PhotonVisibilityService::SetLibraryTimingTF1Entry().

362  {
363  if ((Voxel >= fNVoxels) || (OpChannel >= fNOpChannels))
364  mf::LogError("PhotonLibrary") << "Error - attempting to set a propagation function in voxel "
365  << Voxel << " which is out of range";
366  else
367  uncheckedAccessTimingTF1(Voxel, OpChannel) = func;
368  }
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
TF1 & uncheckedAccessTimingTF1(size_t Voxel, size_t OpChannel)
Unchecked access to a parameter of the time distribution.
void phot::PhotonLibrary::SetVoxelDef ( sim::PhotonVoxelDef const &  voxelDef)
inline

Copies the specified voxel definition into our own (overwrites the existing metadata if any).

Definition at line 97 of file PhotonLibrary.h.

Referenced by phot::PhotonVisibilityService::LoadLibrary().

97 { fVoxelDef = voxelDef; }
std::optional< sim::PhotonVoxelDef > fVoxelDef
Voxel definition loaded from library metadata.
static int phot::PhotonLibrary::size_t2int ( size_t  val)
inlinestaticprivate

Converts size_t into integer.

Definition at line 216 of file PhotonLibrary.h.

Referenced by StoreLibraryToFile().

217  {
218  constexpr size_t int_max_as_size_t{std::numeric_limits<int>::max()};
219  return val <= int_max_as_size_t ? static_cast<int>(val) : -1;
220  }
void phot::PhotonLibrary::StoreLibraryToFile ( std::string  LibraryFile,
bool  storeReflected = false,
bool  storeReflT0 = false,
size_t  storeTiming = 0 
) const

Definition at line 49 of file PhotonLibrary.cxx.

References fDir, fLookupTable, fNOpChannels, fNVoxels, fReflLookupTable, fTimingParLookupTable, hasReflected(), hasReflectedT0(), hasTiming(), OpChannelBranchName, util::LazyVector< T, A >::size(), size_t2int(), StoreMetadata(), uncheckedAccess(), uncheckedAccessRefl(), uncheckedAccessReflT(), and uncheckedAccessTimingPar().

Referenced by phot::PhotonVisibilityService::StoreLibrary().

53  {
54  mf::LogInfo("PhotonLibrary") << "Writing photon library to file";
55 
56  if (!fDir) {
57  throw cet::exception("PhotonLibrary")
58  << "StoreLibraryToFile(): no ROOT file provided, can't store anything.\n";
59  }
60 
61  TTree* tt = fDir->make<TTree>("PhotonLibraryData", "PhotonLibraryData");
62 
63  Int_t Voxel = 0;
64  Int_t OpChannel = 0;
65  Float_t Visibility = 0;
66  Float_t ReflVisibility = 0;
67  Float_t ReflTfirst = 0;
68  Float_t* timing_par = nullptr;
69 
70  tt->Branch("Voxel", &Voxel, "Voxel/I");
71  tt->Branch(OpChannelBranchName.c_str(), &OpChannel, (OpChannelBranchName + "/I").c_str());
72  tt->Branch("Visibility", &Visibility, "Visibility/F");
73 
74  if (storeTiming != 0) {
75  if (!hasTiming()) {
76  // if this happens, you need to call CreateEmptyLibrary() with storeReflected set true
77  throw cet::exception("PhotonLibrary")
78  << "StoreLibraryToFile() requested to store the time propagation distribution "
79  "parameters, which was not simulated.";
80  }
81  tt->Branch("timing_par", timing_par, Form("timing_par[%i]/F", size_t2int(storeTiming)));
83  throw cet::exception(" Photon Library ")
84  << "Time propagation lookup table is different size than Direct table \n"
85  << "this should not be happening. ";
86  }
87 
88  if (storeReflected) {
89  if (!hasReflected()) {
90  // if this happens, you need to call CreateEmptyLibrary() with storeReflected set true
91  throw cet::exception("PhotonLibrary")
92  << "StoreLibraryToFile() requested to store reflected light, which was not simulated.";
93  }
94  tt->Branch("ReflVisibility", &ReflVisibility, "ReflVisibility/F");
96  throw cet::exception(" Photon Library ")
97  << "Reflected light lookup table is different size than Direct table \n"
98  << "this should not be happening. ";
99  }
100  if (storeReflT0) {
101  if (!hasReflectedT0()) {
102  // if this happens, you need to call CreateEmptyLibrary() with storeReflectedT0 set true
103  throw cet::exception("PhotonLibrary") << "StoreLibraryToFile() requested to store "
104  "reflected light timing, which was not simulated.";
105  }
106  tt->Branch("ReflTfirst", &ReflTfirst, "ReflTfirst/F");
107  }
108  for (size_t ivox = 0; ivox != fNVoxels; ++ivox) {
109  for (size_t ichan = 0; ichan != fNOpChannels; ++ichan) {
110  Visibility = uncheckedAccess(ivox, ichan);
111  if (storeReflected) ReflVisibility = uncheckedAccessRefl(ivox, ichan);
112  if (storeReflT0) ReflTfirst = uncheckedAccessReflT(ivox, ichan);
113  if (storeTiming != 0) {
114  for (size_t i = 0; i < storeTiming; i++)
115  timing_par[i] = uncheckedAccessTimingPar(ivox, ichan, i);
116  }
117  if (Visibility > 0 || ReflVisibility > 0) {
118  Voxel = ivox;
119  OpChannel = ichan;
120  // visibility(ies) is(are) already set
121  tt->Fill();
122  }
123  }
124  }
125 
126  StoreMetadata();
127  }
static int size_t2int(size_t val)
Converts size_t into integer.
util::LazyVector< float > fReflLookupTable
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
static std::string const OpChannelBranchName
Name of the optical channel number in the input tree.
float uncheckedAccess(size_t Voxel, size_t OpChannel) const
Unchecked access to a visibility datum.
float uncheckedAccessReflT(size_t Voxel, size_t OpChannel) const
Unchecked access to a reflected T0 visibility datum.
util::LazyVector< float > fLookupTable
virtual bool hasReflectedT0() const override
Returns whether the current library deals with reflected light timing.
Definition: PhotonLibrary.h:62
Definition: type_traits.h:61
size_type size() const noexcept
Returns the size of the vector.
Definition: LazyVector.h:149
void StoreMetadata() const
Writes the current metadata (if any) into the ROOT output file.
float uncheckedAccessRefl(size_t Voxel, size_t OpChannel) const
Unchecked access to a reflected visibility datum.
virtual bool hasReflected() const override
Returns whether the current library deals with reflected light count.
Definition: PhotonLibrary.h:59
util::LazyVector< std::vector< float > > fTimingParLookupTable
art::TFileDirectory * fDir
ROOT directory where to write data.
bool hasTiming() const
Returns whether the current library deals with time propagation distributions.
Definition: PhotonLibrary.h:56
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
float uncheckedAccessTimingPar(size_t Voxel, size_t OpChannel, size_t parnum) const
Unchecked access to a parameter the time distribution.
void phot::PhotonLibrary::StoreMetadata ( ) const
private

Writes the current metadata (if any) into the ROOT output file.

Definition at line 508 of file PhotonLibrary.cxx.

References fDir, fNOpChannels, fNVoxels, sim::PhotonVoxelDef::GetRegionLowerCorner(), sim::PhotonVoxelDef::GetRegionUpperCorner(), sim::PhotonVoxelDef::GetSteps(), GetVoxelDef(), sim::PhotonVoxelDef::GetVoxelSize(), and hasVoxelDef().

Referenced by StoreLibraryToFile().

509  {
510 
511  assert(fDir);
512 
513  // NVoxels
514  fDir->makeAndRegister<RooInt>("NVoxels", "Total number of voxels in the library", fNVoxels);
515 
516  // NChannels
517  fDir->makeAndRegister<RooInt>(
518  "NChannels", "Total number of optical detector channels in the library", fNOpChannels);
519 
520  if (!hasVoxelDef()) return;
521  sim::PhotonVoxelDef const& voxelDef = GetVoxelDef();
522 
523  // lower point
524  geo::Point_t const& lower = voxelDef.GetRegionLowerCorner();
525  fDir->makeAndRegister<RooDouble>(
526  "MinX", "Lower x coordinate covered by the library (world coordinates, cm)", lower.X());
527  fDir->makeAndRegister<RooDouble>(
528  "MinY", "Lower y coordinate covered by the library (world coordinates, cm)", lower.Y());
529  fDir->makeAndRegister<RooDouble>(
530  "MinZ", "Lower z coordinate covered by the library (world coordinates, cm)", lower.Z());
531 
532  // upper point
533  geo::Point_t const& upper = voxelDef.GetRegionUpperCorner();
534  fDir->makeAndRegister<RooDouble>(
535  "MaxX", "Upper x coordinate covered by the library (world coordinates, cm)", upper.X());
536  fDir->makeAndRegister<RooDouble>(
537  "MaxY", "Upper y coordinate covered by the library (world coordinates, cm)", upper.Y());
538  fDir->makeAndRegister<RooDouble>(
539  "MaxZ", "Upper z coordinate covered by the library (world coordinates, cm)", upper.Z());
540 
541  // steps
542  geo::Vector_t const& stepSizes = voxelDef.GetVoxelSize();
543  fDir->makeAndRegister<RooDouble>("StepX", "Size on x direction of a voxel (cm)", stepSizes.X());
544  fDir->makeAndRegister<RooDouble>("StepY", "Size on y direction of a voxel (cm)", stepSizes.Y());
545  fDir->makeAndRegister<RooDouble>("StepZ", "Size on z direction of a voxel (cm)", stepSizes.Z());
546 
547  // divisions
548  auto const& steps = voxelDef.GetSteps();
549  fDir->makeAndRegister<RooInt>("NDivX", "Steps on the x direction", steps[0]);
550  fDir->makeAndRegister<RooInt>("NDivY", "Steps on the y direction", steps[1]);
551  fDir->makeAndRegister<RooInt>("NDivZ", "Steps on the z direction", steps[2]);
552 
553  } // PhotonLibrary::StoreMetadata()
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
Definition: geo_vectors.h:160
sim::PhotonVoxelDef const & GetVoxelDef() const
Definition: PhotonLibrary.h:89
Vector GetVoxelSize() const
Returns a vector describing the span of a single voxel in x, y an z [cm].
Definition: PhotonVoxels.h:208
bool hasVoxelDef() const
Returns whether voxel metadata is available.
Definition: PhotonLibrary.h:85
Representation of a region of space diced into voxels.
Definition: PhotonVoxels.h:58
decltype(auto) GetRegionUpperCorner() const
Returns the volume vertex (type Point) with the highest coordinates.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:180
std::array< unsigned int, 3U > GetSteps() const
Returns the number of voxels along each of the three dimensions.
art::TFileDirectory * fDir
ROOT directory where to write data.
decltype(auto) GetRegionLowerCorner() const
Returns the volume vertex (type Point) with the lowest coordinates.
float phot::PhotonLibrary::uncheckedAccess ( size_t  Voxel,
size_t  OpChannel 
) const
inlineprivate

Unchecked access to a visibility datum.

Definition at line 143 of file PhotonLibrary.h.

Referenced by GetCount(), LoadLibraryFromFile(), SetCount(), and StoreLibraryToFile().

144  {
145  return fLookupTable[uncheckedIndex(Voxel, OpChannel)];
146  }
size_t uncheckedIndex(size_t Voxel, size_t OpChannel) const
Returns the index of visibility of specified voxel and cell.
util::LazyVector< float > fLookupTable
float& phot::PhotonLibrary::uncheckedAccess ( size_t  Voxel,
size_t  OpChannel 
)
inlineprivate

Unchecked access to a visibility datum.

Definition at line 149 of file PhotonLibrary.h.

150  {
151  return fLookupTable[uncheckedIndex(Voxel, OpChannel)];
152  }
size_t uncheckedIndex(size_t Voxel, size_t OpChannel) const
Returns the index of visibility of specified voxel and cell.
util::LazyVector< float > fLookupTable
float phot::PhotonLibrary::uncheckedAccessRefl ( size_t  Voxel,
size_t  OpChannel 
) const
inlineprivate

Unchecked access to a reflected visibility datum.

Definition at line 155 of file PhotonLibrary.h.

Referenced by GetReflCount(), LoadLibraryFromFile(), SetReflCount(), and StoreLibraryToFile().

156  {
157  return fReflLookupTable[uncheckedIndex(Voxel, OpChannel)];
158  }
util::LazyVector< float > fReflLookupTable
size_t uncheckedIndex(size_t Voxel, size_t OpChannel) const
Returns the index of visibility of specified voxel and cell.
float& phot::PhotonLibrary::uncheckedAccessRefl ( size_t  Voxel,
size_t  OpChannel 
)
inlineprivate

Unchecked access to a reflected visibility datum.

Definition at line 161 of file PhotonLibrary.h.

162  {
163  return fReflLookupTable[uncheckedIndex(Voxel, OpChannel)];
164  }
util::LazyVector< float > fReflLookupTable
size_t uncheckedIndex(size_t Voxel, size_t OpChannel) const
Returns the index of visibility of specified voxel and cell.
float phot::PhotonLibrary::uncheckedAccessReflT ( size_t  Voxel,
size_t  OpChannel 
) const
inlineprivate

Unchecked access to a reflected T0 visibility datum.

Definition at line 167 of file PhotonLibrary.h.

Referenced by GetReflT0(), LoadLibraryFromFile(), SetReflT0(), and StoreLibraryToFile().

168  {
169  return fReflTLookupTable[uncheckedIndex(Voxel, OpChannel)];
170  }
size_t uncheckedIndex(size_t Voxel, size_t OpChannel) const
Returns the index of visibility of specified voxel and cell.
util::LazyVector< float > fReflTLookupTable
float& phot::PhotonLibrary::uncheckedAccessReflT ( size_t  Voxel,
size_t  OpChannel 
)
inlineprivate

Unchecked access to a reflected T0 visibility datum.

Definition at line 173 of file PhotonLibrary.h.

174  {
175  return fReflTLookupTable[uncheckedIndex(Voxel, OpChannel)];
176  }
size_t uncheckedIndex(size_t Voxel, size_t OpChannel) const
Returns the index of visibility of specified voxel and cell.
util::LazyVector< float > fReflTLookupTable
float phot::PhotonLibrary::uncheckedAccessTimingPar ( size_t  Voxel,
size_t  OpChannel,
size_t  parnum 
) const
inlineprivate

Unchecked access to a parameter the time distribution.

Definition at line 179 of file PhotonLibrary.h.

Referenced by GetTimingPar(), SetTimingPar(), and StoreLibraryToFile().

180  {
181  return fTimingParLookupTable[uncheckedIndex(Voxel, OpChannel)][parnum];
182  }
size_t uncheckedIndex(size_t Voxel, size_t OpChannel) const
Returns the index of visibility of specified voxel and cell.
util::LazyVector< std::vector< float > > fTimingParLookupTable
float& phot::PhotonLibrary::uncheckedAccessTimingPar ( size_t  Voxel,
size_t  OpChannel,
size_t  parnum 
)
inlineprivate

Unchecked access to a parameter of the time distribution.

Definition at line 185 of file PhotonLibrary.h.

186  {
187  return fTimingParLookupTable[uncheckedIndex(Voxel, OpChannel)][parnum];
188  }
size_t uncheckedIndex(size_t Voxel, size_t OpChannel) const
Returns the index of visibility of specified voxel and cell.
util::LazyVector< std::vector< float > > fTimingParLookupTable
TF1& phot::PhotonLibrary::uncheckedAccessTimingTF1 ( size_t  Voxel,
size_t  OpChannel 
)
inlineprivate

Unchecked access to a parameter of the time distribution.

Definition at line 191 of file PhotonLibrary.h.

Referenced by LoadLibraryFromFile(), and SetTimingTF1().

192  {
193  return fTimingParTF1LookupTable[uncheckedIndex(Voxel, OpChannel)];
194  }
size_t uncheckedIndex(size_t Voxel, size_t OpChannel) const
Returns the index of visibility of specified voxel and cell.
util::LazyVector< TF1 > fTimingParTF1LookupTable
const TF1& phot::PhotonLibrary::uncheckedAccessTimingTF1 ( size_t  Voxel,
size_t  OpChannel 
) const
inlineprivate

Unchecked access to a parameter of the time distribution.

Definition at line 197 of file PhotonLibrary.h.

References util::LazyVector< T, A >::data_address().

198  {
199  // note that this will produce a segmentation fault if the formula is not there
200  return *(fTimingParTF1LookupTable.data_address(uncheckedIndex(Voxel, OpChannel)));
201  }
const_pointer data_address(size_type pos) const
Returns a constant pointer to the specified element.
Definition: LazyVector.h:549
size_t uncheckedIndex(size_t Voxel, size_t OpChannel) const
Returns the index of visibility of specified voxel and cell.
util::LazyVector< TF1 > fTimingParTF1LookupTable
size_t phot::PhotonLibrary::uncheckedIndex ( size_t  Voxel,
size_t  OpChannel 
) const
inlineprivate

Returns the index of visibility of specified voxel and cell.

Definition at line 137 of file PhotonLibrary.h.

Referenced by GetCounts(), GetReflCounts(), GetReflT0s(), GetTimingPars(), and GetTimingTF1s().

138  {
139  return Voxel * fNOpChannels + OpChannel;
140  }

Member Data Documentation

art::TFileDirectory* phot::PhotonLibrary::fDir = nullptr
private

ROOT directory where to write data.

Definition at line 132 of file PhotonLibrary.h.

Referenced by StoreLibraryToFile(), and StoreMetadata().

bool phot::PhotonLibrary::fHasReflected = false
private

Whether the current library deals with reflected light counts.

Definition at line 108 of file PhotonLibrary.h.

Referenced by CreateEmptyLibrary(), and LoadLibraryFromFile().

bool phot::PhotonLibrary::fHasReflectedT0
private
Initial value:
=
false

Whether the current library deals with reflected light timing.

Definition at line 109 of file PhotonLibrary.h.

Referenced by CreateEmptyLibrary(), and LoadLibraryFromFile().

size_t phot::PhotonLibrary::fHasTiming
private
Initial value:
=
0

Whether the current library deals with time propagation distribution.

Definition at line 112 of file PhotonLibrary.h.

Referenced by CreateEmptyLibrary(), and LoadLibraryFromFile().

util::LazyVector<float> phot::PhotonLibrary::fLookupTable
private
util::LazyVector<float> phot::PhotonLibrary::fReflLookupTable
private
util::LazyVector<float> phot::PhotonLibrary::fReflTLookupTable
private

Definition at line 119 of file PhotonLibrary.h.

Referenced by CreateEmptyLibrary(), GetReflT0s(), and LoadLibraryFromFile().

std::string phot::PhotonLibrary::fTimingParFormula
private

Definition at line 122 of file PhotonLibrary.h.

Referenced by LoadLibraryFromFile().

util::LazyVector<std::vector<float> > phot::PhotonLibrary::fTimingParLookupTable
private
size_t phot::PhotonLibrary::fTimingParNParameters
private

Definition at line 123 of file PhotonLibrary.h.

Referenced by LoadLibraryFromFile().

util::LazyVector<TF1> phot::PhotonLibrary::fTimingParTF1LookupTable
private

Definition at line 121 of file PhotonLibrary.h.

Referenced by CreateEmptyLibrary(), GetTimingTF1s(), and LoadLibraryFromFile().

std::optional<sim::PhotonVoxelDef> phot::PhotonLibrary::fVoxelDef
private

Voxel definition loaded from library metadata.

Definition at line 129 of file PhotonLibrary.h.

Referenced by LoadMetadata().

std::string const phot::PhotonLibrary::OpChannelBranchName = "OpChannel"
staticprivate

Name of the optical channel number in the input tree.

Definition at line 210 of file PhotonLibrary.h.

Referenced by ExtractNOpChannels(), and StoreLibraryToFile().


The documentation for this class was generated from the following files: