All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
phot::PhotonLibrary Class Reference

#include <PhotonLibrary.h>

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

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)
 
 PhotonLibrary ()
 
 ~PhotonLibrary ()
 
float GetCount (size_t Voxel, size_t OpChannel)
 
void SetCount (size_t Voxel, size_t OpChannel, float Count)
 
const std::vector< float > * GetCounts (size_t Voxel) const
 Returns a pointer to NOpChannels() visibility values, one per channel. More...
 
const std::vector< std::vector
< float > > & 
GetData () const
 
void StoreLibraryToFile (std::string LibraryFile)
 
void LoadLibraryFromFile (std::string LibraryFile, size_t NVoxels)
 
void CreateEmptyLibrary (size_t NVoxels, size_t NChannels)
 
int NOpChannels () const
 
int NVoxels () const
 
Metadata: voxel information
bool hasVoxelDef () const
 Returns whether voxel metadata is available. More...
 
sim::PhotonVoxelDef const & GetVoxelDef () const
 
void SetVoxelDef (sim::PhotonVoxelDef const &voxelDef)
 
- Public Member Functions inherited from phot::IPhotonLibrary
virtual ~IPhotonLibrary ()=default
 
size_t LibrarySize () const
 Returns the number of elements in the library. More...
 

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...
 
static std::vector< float > * EmptyList ()
 

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::PhotonVoxelDef
fVoxelDef
 Voxel definition loaded from library metadata. More...
 
art::TFileDirectory * fDir = nullptr
 ROOT directory where to write data. More...
 
std::vector< std::vector< float > > fLookupTable
 

Static Private Attributes

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

Additional Inherited Members

- Public Types inherited from phot::IPhotonLibrary
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 *
 

Detailed Description

Definition at line 25 of file larsim/larsim/PhotonPropagation/PhotonLibrary.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 46 of file larsim/larsim/PhotonPropagation/PhotonLibrary.cxx.

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

Definition at line 23 of file sbncode/sbncode/OpT0Finder/flashmatch/Base/FMWKTools/PhotonLibrary.cxx.

24  {
26  }
void clear()
Removes all stored data and sets the nominal size to 0.
Definition: LazyVector.h:622
phot::PhotonLibrary::~PhotonLibrary ( )

Definition at line 31 of file sbncode/sbncode/OpT0Finder/flashmatch/Base/FMWKTools/PhotonLibrary.cxx.

32  {
34  }
void clear()
Removes all stored data and sets the nominal size to 0.
Definition: LazyVector.h:622

Member Function Documentation

void phot::PhotonLibrary::CreateEmptyLibrary ( size_t  NVoxels,
size_t  NChannels 
)

Definition at line 77 of file sbncode/sbncode/OpT0Finder/flashmatch/Base/FMWKTools/PhotonLibrary.cxx.

78  {
80 
81  fNVoxels = NVoxels;
83 
85 
86  for(size_t ivox=0; ivox!=NVoxels; ivox++)
87  {
89  }
90  }
void clear()
Removes all stored data and sets the nominal size to 0.
Definition: LazyVector.h:622
void resize(size_type newSize)
Changes the nominal size of the container.
Definition: LazyVector.h:602
void phot::PhotonLibrary::CreateEmptyLibrary ( size_t  NVoxels,
size_t  NChannels,
bool  storeReflected = false,
bool  storeReflT0 = false,
size_t  storeTiming = 0 
)

Definition at line 134 of file larsim/larsim/PhotonPropagation/PhotonLibrary.cxx.

140  {
146 
147  fNVoxels = NVoxels;
149 
151  fHasReflected = storeReflected;
152  if (storeReflected) fReflLookupTable.resize(LibrarySize());
153  fHasReflectedT0 = storeReflT0;
154  if (storeReflT0) fReflTLookupTable.resize(LibrarySize());
155  fHasTiming = storeTiming;
156  if (storeTiming != 0) {
159  }
160  }
size_t fHasTiming
Whether the current library deals with time propagation distribution.
bool fHasReflectedT0
Whether the current library deals with reflected light timing.
void clear()
Removes all stored data and sets the nominal size to 0.
Definition: LazyVector.h:622
bool fHasReflected
Whether the current library deals with reflected light counts.
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:602
util::LazyVector< std::vector< float > > fTimingParLookupTable
static std::vector<float>* phot::PhotonLibrary::EmptyList ( )
inlinestaticprivate
size_t phot::PhotonLibrary::ExtractNOpChannels ( TTree *  tree)
staticprivate

Returns the number of optical channels in the specified tree.

Definition at line 577 of file larsim/larsim/PhotonPropagation/PhotonLibrary.cxx.

578  {
579  TBranch* channelBranch = tree->GetBranch(OpChannelBranchName.c_str());
580  if (!channelBranch) {
581  throw art::Exception(art::errors::NotFound)
582  << "Tree '" << tree->GetName() << "' has no branch 'OpChannel'";
583  }
584 
585  // fix a new local address for the branch
586  char* oldAddress = channelBranch->GetAddress();
587  Int_t channel;
588  channelBranch->SetAddress(&channel);
589  Int_t maxChannel = -1;
590 
591  // read all the channel values and pick the largest one
592  Long64_t iEntry = 0;
593  while (channelBranch->GetEntry(iEntry++)) {
594  if (channel > maxChannel) maxChannel = channel;
595  } // while
596 
597  MF_LOG_DEBUG("PhotonLibrary") << "Detected highest channel to be " << maxChannel << " from "
598  << iEntry << " tree entries";
599 
600  // restore the old branch address
601  channelBranch->SetAddress(oldAddress);
602 
603  return size_t(maxChannel + 1);
604 
605  } // PhotonLibrary::ExtractNOpChannels()
static std::string const OpChannelBranchName
Name of the optical channel number in the input tree.
float phot::PhotonLibrary::GetCount ( size_t  Voxel,
size_t  OpChannel 
)

Definition at line 186 of file sbncode/sbncode/OpT0Finder/flashmatch/Base/FMWKTools/PhotonLibrary.cxx.

187  {
188  //if(/*(Voxel<0)||*/(Voxel>=fNVoxels)||/*(OpChannel<0)||*/(OpChannel>=fNOpChannels))
189  // return 0;
190  //else
191  return fLookupTable[Voxel][OpChannel];
192  }
float phot::PhotonLibrary::GetCount ( size_t  Voxel,
size_t  OpChannel 
) const
overridevirtual

Implements phot::IPhotonLibrary.

Definition at line 310 of file larsim/larsim/PhotonPropagation/PhotonLibrary.cxx.

311  {
312  if ((Voxel >= fNVoxels) || (OpChannel >= fNOpChannels))
313  return 0;
314  else
315  return uncheckedAccess(Voxel, OpChannel);
316  }
float uncheckedAccess(size_t Voxel, size_t OpChannel) const
Unchecked access to a visibility datum.
const std::vector<float>* phot::PhotonLibrary::GetCounts ( size_t  Voxel) const
virtual

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

Implements phot::IPhotonLibrary.

const std::vector< float > * phot::PhotonLibrary::GetCounts ( size_t  Voxel) const
overridevirtual

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

Implements phot::IPhotonLibrary.

Definition at line 406 of file larsim/larsim/PhotonPropagation/PhotonLibrary.cxx.

407  {
408  if (Voxel >= fNVoxels)
409  return nullptr;
410  else
411  return fLookupTable.data_address(uncheckedIndex(Voxel, 0));
412  }
const_pointer data_address(size_type pos) const
Returns a constant pointer to the specified element.
Definition: LazyVector.h:584
size_t uncheckedIndex(size_t Voxel, size_t OpChannel) const
Returns the index of visibility of specified voxel and cell.
const std::vector<std::vector<float> >& phot::PhotonLibrary::GetData ( ) const
inline
float phot::PhotonLibrary::GetReflCount ( size_t  Voxel,
size_t  OpChannel 
) const
overridevirtual

Implements phot::IPhotonLibrary.

Definition at line 329 of file larsim/larsim/PhotonPropagation/PhotonLibrary.cxx.

330  {
331  if ((Voxel >= fNVoxels) || (OpChannel >= fNOpChannels))
332  return 0;
333  else
334  return uncheckedAccessRefl(Voxel, OpChannel);
335  }
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 457 of file larsim/larsim/PhotonPropagation/PhotonLibrary.cxx.

458  {
459  if (Voxel >= fNVoxels)
460  return nullptr;
461  else
462  return fReflLookupTable.data_address(uncheckedIndex(Voxel, 0));
463  }
const_pointer data_address(size_type pos) const
Returns a constant pointer to the specified element.
Definition: LazyVector.h:584
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 339 of file larsim/larsim/PhotonPropagation/PhotonLibrary.cxx.

340  {
341  if ((Voxel >= fNVoxels) || (OpChannel >= fNOpChannels))
342  return 0;
343  else
344  return uncheckedAccessReflT(Voxel, OpChannel);
345  }
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 468 of file larsim/larsim/PhotonPropagation/PhotonLibrary.cxx.

469  {
470  if (Voxel >= fNVoxels)
471  return nullptr;
472  else
474  }
const_pointer data_address(size_type pos) const
Returns a constant pointer to the specified element.
Definition: LazyVector.h:584
size_t uncheckedIndex(size_t Voxel, size_t OpChannel) const
Returns the index of visibility of specified voxel and cell.
float phot::PhotonLibrary::GetTimingPar ( size_t  Voxel,
size_t  OpChannel,
size_t  parnum 
) const

Definition at line 320 of file larsim/larsim/PhotonPropagation/PhotonLibrary.cxx.

321  {
322  if ((Voxel >= fNVoxels) || (OpChannel >= fNOpChannels))
323  return 0;
324  else
325  return uncheckedAccessTimingPar(Voxel, OpChannel, parnum);
326  } //----------------------------------------------------
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 417 of file larsim/larsim/PhotonPropagation/PhotonLibrary.cxx.

418  {
419  if (Voxel >= fNVoxels)
420  return nullptr;
421  else
423  }
const_pointer data_address(size_type pos) const
Returns a constant pointer to the specified element.
Definition: LazyVector.h:584
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 428 of file larsim/larsim/PhotonPropagation/PhotonLibrary.cxx.

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

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

See Also
hasVoxelDef()

Definition at line 106 of file larsim/larsim/PhotonPropagation/PhotonLibrary.h.

107  {
108  assert(fVoxelDef);
109  return *fVoxelDef;
110  }
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 64 of file larsim/larsim/PhotonPropagation/PhotonLibrary.h.

65  {
66  return fHasReflected;
67  }
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 71 of file larsim/larsim/PhotonPropagation/PhotonLibrary.h.

72  {
73  return fHasReflectedT0;
74  }
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 57 of file larsim/larsim/PhotonPropagation/PhotonLibrary.h.

58  {
59  return fHasTiming;
60  }
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 98 of file larsim/larsim/PhotonPropagation/PhotonLibrary.h.

99  {
100  return fVoxelDef.has_value();
101  }
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 136 of file larsim/larsim/PhotonPropagation/PhotonLibrary.h.

137  {
138  return isVoxelValidImpl(Voxel);
139  }
bool phot::PhotonLibrary::isVoxelValidImpl ( size_t  Voxel) const
inlineprivate

Definition at line 168 of file larsim/larsim/PhotonPropagation/PhotonLibrary.h.

169  {
170  return Voxel < fNVoxels;
171  }
void phot::PhotonLibrary::LoadLibraryFromFile ( std::string  LibraryFile,
size_t  NVoxels 
)

Definition at line 95 of file sbncode/sbncode/OpT0Finder/flashmatch/Base/FMWKTools/PhotonLibrary.cxx.

96  {
98 
99  std::cout<< "Reading photon library from input file: " << LibraryFile.c_str()<<std::endl;
100 
101  TFile *f = nullptr;
102  TTree *tt = nullptr;
103 
104  try
105  {
106  f = TFile::Open(LibraryFile.c_str());
107  if(!f) {
108  std::cerr<<"\033[95m<<"<<__FUNCTION__<<">>\033[00m " << "Failed to open a ROOT file: " << LibraryFile.c_str()<<std::endl;
109  std::cerr<<"If you don't have photon library data file, download from below URL..."<<std::endl;
110  std::cerr<<"/cvmfs/icarus.opensciencegrid.org/products/icarus/icarus_data/v08_28_00/icarus_data/PhotonLibrary/PhotonLibrary-20180801.root"<<std::endl<<std::endl;
111  throw std::exception();
112  }
113  tt = (TTree*)f->Get("PhotonLibraryData");
114  if (!tt) { // Library not in the top directory
115  TKey *key = f->FindKeyAny("PhotonLibraryData");
116  if (key)
117  tt = (TTree*)key->ReadObj();
118  else {
119  std::cerr << "PhotonLibraryData not found in file" <<LibraryFile<<std::endl;
120  }
121  }
122  }
123  catch(...)
124  {
125  std::cerr << "Error in ttree load, reading photon library: " << LibraryFile.c_str()<<std::endl;
126  }
127 
128  Int_t Voxel;
129  Int_t OpChannel;
130  Float_t Visibility;
131 
132  tt->SetBranchAddress("Voxel", &Voxel);
133  tt->SetBranchAddress("OpChannel", &OpChannel);
134  tt->SetBranchAddress("Visibility", &Visibility);
135 
136 
137 
138 
139  fNVoxels = NVoxels;
140  fNOpChannels = 1; // Minimum default, overwritten by library reading
141 
142 
144 
145 
146  size_t NEntries = tt->GetEntries();
147 
148  for(size_t i=0; i!=NEntries; ++i) {
149  tt->GetEntry(i);
150 
151  // Set # of optical channels to 1 more than largest one seen
152  if (OpChannel >= (int)fNOpChannels)
153  fNOpChannels = OpChannel+1;
154 
155  // Expand this voxel's vector if needed
156  if (fLookupTable[Voxel].size() < fNOpChannels)
157  fLookupTable[Voxel].resize(fNOpChannels, 0);
158 
159  // Set the visibility at this optical channel
160  fLookupTable[Voxel][OpChannel] = Visibility;
161  }
162 
163  // Go through the table and fill in any missing 0's
164  for(size_t ivox=0; ivox!=NVoxels; ivox++)
165  {
166  if (fLookupTable[ivox].size() < fNOpChannels)
167  fLookupTable[ivox].resize(fNOpChannels,0);
168  }
169 
170 
171  std::cout << NVoxels << " voxels, " << fNOpChannels<<" channels" <<std::endl;
172 
173 
174  try
175  {
176  f->Close();
177  }
178  catch(...)
179  {
180  std::cerr << "Error in closing file : " << LibraryFile.c_str()<<std::endl;
181  }
182  }
BEGIN_PROLOG could also be cerr
void clear()
Removes all stored data and sets the nominal size to 0.
Definition: LazyVector.h:622
std::size_t size(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:561
void resize(size_type newSize)
Changes the nominal size of the container.
Definition: LazyVector.h:602
BEGIN_PROLOG could also be cout
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 165 of file larsim/larsim/PhotonPropagation/PhotonLibrary.cxx.

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

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

Definition at line 478 of file larsim/larsim/PhotonPropagation/PhotonLibrary.cxx.

479  {
480 
481  constexpr std::size_t NExpectedKeys = 9U;
482 
483  std::vector<std::string> missingKeys;
484 
485  RooReader<RooInt, Int_t> readInt{srcDir, missingKeys};
486  RooReader<RooDouble, Double_t> readDouble{srcDir, missingKeys};
487 
488  double xMin;
489  double xMax;
490  int xN;
491  double yMin;
492  double yMax;
493  int yN;
494  double zMin;
495  double zMax;
496  int zN;
497  if (auto metaValue = readDouble("MinX")) xMin = *metaValue;
498  if (auto metaValue = readDouble("MaxX")) xMax = *metaValue;
499  if (auto metaValue = readInt("NDivX")) xN = *metaValue;
500  if (auto metaValue = readDouble("MinY")) yMin = *metaValue;
501  if (auto metaValue = readDouble("MaxY")) yMax = *metaValue;
502  if (auto metaValue = readInt("NDivY")) yN = *metaValue;
503  if (auto metaValue = readDouble("MinZ")) zMin = *metaValue;
504  if (auto metaValue = readDouble("MaxZ")) zMax = *metaValue;
505  if (auto metaValue = readInt("NDivZ")) zN = *metaValue;
506 
507  if (!missingKeys.empty()) {
508  if (missingKeys.size() != NExpectedKeys) {
509  mf::LogError log("PhotonLibrary");
510  log << "Photon library at '" << srcDir.GetPath() << "' is missing " << missingKeys.size()
511  << " metadata elements:";
512  for (auto const& key : missingKeys)
513  log << " '" << key << "'";
514  }
515  else {
516  mf::LogTrace("PhotonLibrary") << "No voxel metadata found in '" << srcDir.GetPath() << "'";
517  }
518  return;
519  } // if missing keys
520 
521  fVoxelDef.emplace(xMin, xMax, xN, yMin, yMax, yN, zMin, zMax, zN);
522 
523  } // PhotonLibrary::LoadMetadata()
std::optional< sim::PhotonVoxelDef > fVoxelDef
Voxel definition loaded from library metadata.
int phot::PhotonLibrary::NOpChannels ( ) const
inlinevirtual
virtual int phot::PhotonLibrary::NOpChannels ( ) const
inlineoverrideprivatevirtual
int phot::PhotonLibrary::NVoxels ( ) const
inlinevirtual
virtual int phot::PhotonLibrary::NVoxels ( ) const
inlineoverrideprivatevirtual
TTree* phot::PhotonLibrary::ProduceTTree ( ) const
void phot::PhotonLibrary::SetCount ( size_t  Voxel,
size_t  OpChannel,
float  Count 
)
void phot::PhotonLibrary::SetCount ( size_t  Voxel,
size_t  OpChannel,
float  Count 
)

Definition at line 350 of file larsim/larsim/PhotonPropagation/PhotonLibrary.cxx.

351  {
352  if ((Voxel >= fNVoxels) || (OpChannel >= fNOpChannels))
353  mf::LogError("PhotonLibrary")
354  << "Error - attempting to set count in voxel " << Voxel << " which is out of range";
355  else
356  uncheckedAccess(Voxel, OpChannel) = Count;
357  }
float uncheckedAccess(size_t Voxel, size_t OpChannel) const
Unchecked access to a visibility datum.
void phot::PhotonLibrary::SetReflCount ( size_t  Voxel,
size_t  OpChannel,
float  Count 
)

Definition at line 383 of file larsim/larsim/PhotonPropagation/PhotonLibrary.cxx.

384  {
385  if ((Voxel >= fNVoxels) || (OpChannel >= fNOpChannels))
386  mf::LogError("PhotonLibrary")
387  << "Error - attempting to set count in voxel " << Voxel << " which is out of range";
388  else
389  uncheckedAccessRefl(Voxel, OpChannel) = Count;
390  }
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 394 of file larsim/larsim/PhotonPropagation/PhotonLibrary.cxx.

395  {
396  if ((Voxel >= fNVoxels) || (OpChannel >= fNOpChannels))
397  mf::LogError("PhotonLibrary")
398  << "Error - attempting to set count in voxel " << Voxel << " which is out of range";
399  else
400  uncheckedAccessReflT(Voxel, OpChannel) = Count;
401  }
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 361 of file larsim/larsim/PhotonPropagation/PhotonLibrary.cxx.

362  {
363  if ((Voxel >= fNVoxels) || (OpChannel >= fNOpChannels))
364  mf::LogError("PhotonLibrary") << "Error - attempting to set timing t0 count in voxel "
365  << Voxel << " which is out of range";
366  else
367  uncheckedAccessTimingPar(Voxel, OpChannel, parnum) = Count;
368  }
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 372 of file larsim/larsim/PhotonPropagation/PhotonLibrary.cxx.

373  {
374  if ((Voxel >= fNVoxels) || (OpChannel >= fNOpChannels))
375  mf::LogError("PhotonLibrary") << "Error - attempting to set a propagation function in voxel "
376  << Voxel << " which is out of range";
377  else
378  uncheckedAccessTimingTF1(Voxel, OpChannel) = func;
379  }
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 115 of file larsim/larsim/PhotonPropagation/PhotonLibrary.h.

116  {
117  fVoxelDef = voxelDef;
118  }
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 265 of file larsim/larsim/PhotonPropagation/PhotonLibrary.h.

266  {
267  constexpr size_t int_max_as_size_t{std::numeric_limits<int>::max()};
268  return val <= int_max_as_size_t ? static_cast<int>(val) : -1;
269  }
void phot::PhotonLibrary::StoreLibraryToFile ( std::string  LibraryFile)

Definition at line 38 of file sbncode/sbncode/OpT0Finder/flashmatch/Base/FMWKTools/PhotonLibrary.cxx.

39  {
40  std::cout << "Writing photon library to input file: " << LibraryFile.c_str()<<std::endl;
41 
42  TFile fout(LibraryFile.c_str(),"RECREATE");
43 
44  TTree *tt = new TTree("PhotonLibraryData","PhotonLibraryData");
45 
46  Int_t Voxel;
47  Int_t OpChannel;
48  Float_t Visibility;
49 
50 
51  tt->Branch("Voxel", &Voxel, "Voxel/I");
52  tt->Branch("OpChannel", &OpChannel, "OpChannel/I");
53  tt->Branch("Visibility", &Visibility, "Visibility/F");
54 
55 
56  for(size_t ivox=0; ivox!=fLookupTable.size(); ++ivox)
57  {
58  for(size_t ichan=0; ichan!=fLookupTable.at(ivox).size(); ++ichan)
59  {
60  if(fLookupTable[ivox].at(ichan) > 0)
61  {
62  Voxel = ivox;
63  OpChannel = ichan;
64  Visibility = fLookupTable[ivox][ichan];
65  tt->Fill();
66  }
67  }
68  }
69  fout.cd();
70  tt->Write();
71  fout.Close();
72  }
size_type size() const noexcept
Returns the size of the vector.
Definition: LazyVector.h:156
value_type at(size_type pos) const
Returns a reference to the specified element, throws an exception if not present. ...
Definition: LazyVector.h:529
BEGIN_PROLOG could also be cout
void phot::PhotonLibrary::StoreLibraryToFile ( std::string  LibraryFile,
bool  storeReflected = false,
bool  storeReflT0 = false,
size_t  storeTiming = 0 
) const

Definition at line 51 of file larsim/larsim/PhotonPropagation/PhotonLibrary.cxx.

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

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

Definition at line 527 of file larsim/larsim/PhotonPropagation/PhotonLibrary.cxx.

528  {
529 
530  assert(fDir);
531 
532  // NVoxels
533  fDir->makeAndRegister<RooInt>("NVoxels", "Total number of voxels in the library", fNVoxels);
534 
535  // NChannels
536  fDir->makeAndRegister<RooInt>(
537  "NChannels", "Total number of optical detector channels in the library", fNOpChannels);
538 
539  if (!hasVoxelDef()) return;
540  sim::PhotonVoxelDef const& voxelDef = GetVoxelDef();
541 
542  // lower point
543  geo::Point_t const& lower = voxelDef.GetRegionLowerCorner();
544  fDir->makeAndRegister<RooDouble>(
545  "MinX", "Lower x coordinate covered by the library (world coordinates, cm)", lower.X());
546  fDir->makeAndRegister<RooDouble>(
547  "MinY", "Lower y coordinate covered by the library (world coordinates, cm)", lower.Y());
548  fDir->makeAndRegister<RooDouble>(
549  "MinZ", "Lower z coordinate covered by the library (world coordinates, cm)", lower.Z());
550 
551  // upper point
552  geo::Point_t const& upper = voxelDef.GetRegionUpperCorner();
553  fDir->makeAndRegister<RooDouble>(
554  "MaxX", "Upper x coordinate covered by the library (world coordinates, cm)", upper.X());
555  fDir->makeAndRegister<RooDouble>(
556  "MaxY", "Upper y coordinate covered by the library (world coordinates, cm)", upper.Y());
557  fDir->makeAndRegister<RooDouble>(
558  "MaxZ", "Upper z coordinate covered by the library (world coordinates, cm)", upper.Z());
559 
560  // steps
561  geo::Vector_t const& stepSizes = voxelDef.GetVoxelSize();
562  fDir->makeAndRegister<RooDouble>("StepX", "Size on x direction of a voxel (cm)", stepSizes.X());
563  fDir->makeAndRegister<RooDouble>("StepY", "Size on y direction of a voxel (cm)", stepSizes.Y());
564  fDir->makeAndRegister<RooDouble>("StepZ", "Size on z direction of a voxel (cm)", stepSizes.Z());
565 
566  // divisions
567  auto const& steps = voxelDef.GetSteps();
568  fDir->makeAndRegister<RooInt>("NDivX", "Steps on the x direction", steps[0]);
569  fDir->makeAndRegister<RooInt>("NDivY", "Steps on the y direction", steps[1]);
570  fDir->makeAndRegister<RooInt>("NDivZ", "Steps on the z direction", steps[2]);
571 
572  } // 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:164
Vector GetVoxelSize() const
Returns a vector describing the span of a single voxel in x, y an z [cm].
sim::PhotonVoxelDef const & GetVoxelDef() const
bool hasVoxelDef() const
Returns whether voxel metadata is available.
std::array< unsigned int, 3U > GetSteps() const
Returns the number of voxels along each of the three dimensions.
Representation of a region of space diced into voxels.
decltype(auto) GetRegionLowerCorner() const
Returns the volume vertex (type Point) with the lowest coordinates.
decltype(auto) GetRegionUpperCorner() const
Returns the volume vertex (type Point) with the highest coordinates.
art::TFileDirectory * fDir
ROOT directory where to write data.
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:184
float phot::PhotonLibrary::uncheckedAccess ( size_t  Voxel,
size_t  OpChannel 
) const
inlineprivate

Unchecked access to a visibility datum.

Definition at line 182 of file larsim/larsim/PhotonPropagation/PhotonLibrary.h.

183  {
184  return fLookupTable[uncheckedIndex(Voxel, OpChannel)];
185  }
size_t uncheckedIndex(size_t Voxel, size_t OpChannel) const
Returns the index of visibility of specified voxel and cell.
float& phot::PhotonLibrary::uncheckedAccess ( size_t  Voxel,
size_t  OpChannel 
)
inlineprivate

Unchecked access to a visibility datum.

Definition at line 189 of file larsim/larsim/PhotonPropagation/PhotonLibrary.h.

190  {
191  return fLookupTable[uncheckedIndex(Voxel, OpChannel)];
192  }
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 
) const
inlineprivate

Unchecked access to a reflected visibility datum.

Definition at line 196 of file larsim/larsim/PhotonPropagation/PhotonLibrary.h.

197  {
198  return fReflLookupTable[uncheckedIndex(Voxel, OpChannel)];
199  }
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 203 of file larsim/larsim/PhotonPropagation/PhotonLibrary.h.

204  {
205  return fReflLookupTable[uncheckedIndex(Voxel, OpChannel)];
206  }
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 210 of file larsim/larsim/PhotonPropagation/PhotonLibrary.h.

211  {
212  return fReflTLookupTable[uncheckedIndex(Voxel, OpChannel)];
213  }
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 
)
inlineprivate

Unchecked access to a reflected T0 visibility datum.

Definition at line 217 of file larsim/larsim/PhotonPropagation/PhotonLibrary.h.

218  {
219  return fReflTLookupTable[uncheckedIndex(Voxel, OpChannel)];
220  }
size_t uncheckedIndex(size_t Voxel, size_t OpChannel) const
Returns the index of visibility of specified voxel and cell.
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 224 of file larsim/larsim/PhotonPropagation/PhotonLibrary.h.

225  {
226  return fTimingParLookupTable[uncheckedIndex(Voxel, OpChannel)][parnum];
227  }
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 231 of file larsim/larsim/PhotonPropagation/PhotonLibrary.h.

232  {
233  return fTimingParLookupTable[uncheckedIndex(Voxel, OpChannel)][parnum];
234  }
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 238 of file larsim/larsim/PhotonPropagation/PhotonLibrary.h.

239  {
240  return fTimingParTF1LookupTable[uncheckedIndex(Voxel, OpChannel)];
241  }
size_t uncheckedIndex(size_t Voxel, size_t OpChannel) const
Returns the index of visibility of specified voxel and cell.
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 245 of file larsim/larsim/PhotonPropagation/PhotonLibrary.h.

246  {
247  // note that this will produce a segmentation fault if the formula is not there
248  return *(fTimingParTF1LookupTable.data_address(uncheckedIndex(Voxel, OpChannel)));
249  }
const_pointer data_address(size_type pos) const
Returns a constant pointer to the specified element.
Definition: LazyVector.h:584
size_t uncheckedIndex(size_t Voxel, size_t OpChannel) const
Returns the index of visibility of specified voxel and cell.
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 175 of file larsim/larsim/PhotonPropagation/PhotonLibrary.h.

176  {
177  return Voxel * fNOpChannels + OpChannel;
178  }

Member Data Documentation

std::vector< float > phot::PhotonLibrary::EmptyChannelsList
staticprivate
art::TFileDirectory* phot::PhotonLibrary::fDir = nullptr
private

ROOT directory where to write data.

Definition at line 165 of file larsim/larsim/PhotonPropagation/PhotonLibrary.h.

bool phot::PhotonLibrary::fHasReflected = false
private

Whether the current library deals with reflected light counts.

Definition at line 141 of file larsim/larsim/PhotonPropagation/PhotonLibrary.h.

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

Whether the current library deals with reflected light timing.

Definition at line 142 of file larsim/larsim/PhotonPropagation/PhotonLibrary.h.

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

Whether the current library deals with time propagation distribution.

Definition at line 145 of file larsim/larsim/PhotonPropagation/PhotonLibrary.h.

std::vector<std::vector<float> > phot::PhotonLibrary::fLookupTable
private
util::LazyVector<float> phot::PhotonLibrary::fLookupTable
private
size_t phot::PhotonLibrary::fNOpChannels
private
size_t phot::PhotonLibrary::fNVoxels
private
util::LazyVector<float> phot::PhotonLibrary::fReflLookupTable
private
util::LazyVector<float> phot::PhotonLibrary::fReflTLookupTable
private
std::string phot::PhotonLibrary::fTimingParFormula
private
util::LazyVector<std::vector<float> > phot::PhotonLibrary::fTimingParLookupTable
private
size_t phot::PhotonLibrary::fTimingParNParameters
private
util::LazyVector<TF1> phot::PhotonLibrary::fTimingParTF1LookupTable
private
std::optional<sim::PhotonVoxelDef> phot::PhotonLibrary::fVoxelDef
private

Voxel definition loaded from library metadata.

Definition at line 162 of file larsim/larsim/PhotonPropagation/PhotonLibrary.h.

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

Name of the optical channel number in the input tree.

Definition at line 258 of file larsim/larsim/PhotonPropagation/PhotonLibrary.h.


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