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

TODO doc. More...

#include "PhotonLibraryHybrid.h"

Inheritance diagram for phot::PhotonLibraryHybrid:
phot::IPhotonLibrary

Classes

struct  Exception
 
struct  FitFunc
 
struct  OpDetRecord
 

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

 PhotonLibraryHybrid (const std::string &fname, const sim::PhotonVoxelDef &voxdef)
 
virtual ~PhotonLibraryHybrid ()
 
virtual float GetCount (size_t Voxel, size_t OpChannel) const override
 
virtual const float * GetCounts (size_t Voxel) const override
 Returns a pointer to NOpChannels() visibility values, one per channel. More...
 
virtual bool hasReflected () const override
 Don't implement reflected light. More...
 
virtual const float * GetReflCounts (size_t Voxel) const override
 
virtual float GetReflCount (size_t Voxel, size_t OpChannel) const override
 
virtual bool hasReflectedT0 () const override
 Don't implement reflected light timing. More...
 
virtual const float * GetReflT0s (size_t Voxel) const override
 
virtual float GetReflT0 (size_t Voxel, size_t OpChannel) const override
 
virtual int NOpChannels () const override
 
virtual int NVoxels () const override
 
virtual bool isVoxelValid (size_t Voxel) const
 
size_t LibrarySize () const
 Returns the number of elements in the library. More...
 

Protected Attributes

const sim::PhotonVoxelDeffVoxDef
 
std::vector< OpDetRecordfRecords
 

Detailed Description

TODO doc.

Definition at line 19 of file PhotonLibraryHybrid.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::PhotonLibraryHybrid::PhotonLibraryHybrid ( const std::string &  fname,
const sim::PhotonVoxelDef voxdef 
)

Definition at line 25 of file PhotonLibraryHybrid.cxx.

References dir, phot::PhotonLibraryHybrid::OpDetRecord::exceptions, f, phot::PhotonLibraryHybrid::OpDetRecord::fit, fRecords, geo::GeometryCore::NOpDets(), NVoxels(), and vox.

27  : fVoxDef(voxdef)
28  {
29  TFile f(fname.c_str());
30  !f.IsZombie() || fatal("Could not open PhotonLibrary " + fname);
31 
32  for (int opdetIdx = 0; true; ++opdetIdx) {
33  const std::string dirname = TString::Format("opdet_%d", opdetIdx).Data();
34  TDirectory* dir = (TDirectory*)f.Get(dirname.c_str());
35  if (!dir) break; // Ran out of opdets
36 
37  OpDetRecord rec;
38 
39  TVectorD* fit = (TVectorD*)dir->Get("fit");
40  fit || fatal("Didn't find " + dirname + "/fit in " + fname);
41  rec.fit = FitFunc((*fit)[0], (*fit)[1]);
42 
43  TTree* tr = (TTree*)dir->Get("tr");
44  tr || fatal("Didn't find " + dirname + "/tr in " + fname);
45  int vox;
46  float vis;
47  tr->SetBranchAddress("vox", &vox);
48  tr->SetBranchAddress("vis", &vis);
49 
50  rec.exceptions.reserve(tr->GetEntries());
51  for (int i = 0; i < tr->GetEntries(); ++i) {
52  tr->GetEntry(i);
53  vox < NVoxels() || fatal("Voxel out of range");
54  rec.exceptions.emplace_back(vox, vis);
55  }
56  rec.exceptions.shrink_to_fit(); // In case we don't trust reserve()
57 
58  // In case they weren't sorted in the file
59  std::sort(rec.exceptions.begin(), rec.exceptions.end());
60 
61  fRecords.push_back(rec);
62  } // end for opdetIdx
63 
64  !fRecords.empty() || fatal("No opdet_*/ directories in " + fname);
65 
67  geom->NOpDets() == fRecords.size() || fatal("Number of opdets mismatch");
68 
69  fRecords.shrink_to_fit(); // save memory
70  }
Float_t vox
Definition: plot.C:38
TFile f
Definition: plotHisto.C:6
virtual int NVoxels() const override
const sim::PhotonVoxelDef & fVoxDef
unsigned int NOpDets() const
Number of OpDets in the whole detector.
TDirectory * dir
Definition: macro.C:5
std::vector< OpDetRecord > fRecords
phot::PhotonLibraryHybrid::~PhotonLibraryHybrid ( )
virtual

Definition at line 73 of file PhotonLibraryHybrid.cxx.

73 {}

Member Function Documentation

float phot::PhotonLibraryHybrid::GetCount ( size_t  Voxel,
size_t  OpChannel 
) const
overridevirtual

Implements phot::IPhotonLibrary.

Definition at line 95 of file PhotonLibraryHybrid.cxx.

References larg4::dist(), geo::OpDetGeo::DistanceToPoint(), phot::PhotonLibraryHybrid::FitFunc::Eval(), phot::PhotonLibraryHybrid::OpDetRecord::exceptions, phot::PhotonLibraryHybrid::OpDetRecord::fit, fRecords, fVoxDef, sim::PhotonVoxel::GetCenter(), sim::PhotonVoxelDef::GetPhotonVoxel(), NOpChannels(), NVoxels(), geo::GeometryCore::OpDetGeoFromOpDet(), and vox.

Referenced by GetCounts().

96  {
97  int(vox) < NVoxels() || fatal("GetCount(): Voxel out of range");
98  int(opchan) < NOpChannels() || fatal("GetCount(): OpChan out of range");
99 
100  const OpDetRecord& rec = fRecords[opchan];
101 
102  auto it2 = std::lower_bound(rec.exceptions.begin(), rec.exceptions.end(), vox);
103  if (it2->vox == vox) return it2->vis;
104 
105  // Otherwise, we use the interpolation, which requires a distance
106 
108  const geo::OpDetGeo& opdet = geom->OpDetGeoFromOpDet(opchan);
109 
110  const auto voxvec = fVoxDef.GetPhotonVoxel(vox).GetCenter();
111 
112  const double dist = opdet.DistanceToPoint(voxvec);
113 
114  return rec.fit.Eval(dist);
115  }
OpDetGeo const & OpDetGeoFromOpDet(unsigned int OpDet) const
Returns the geo::OpDetGeo object for the given detector number.
Float_t vox
Definition: plot.C:38
virtual int NVoxels() const override
const sim::PhotonVoxelDef & fVoxDef
virtual int NOpChannels() const override
double DistanceToPoint(geo::Point_t const &point) const
Returns the distance of the specified point from detector center [cm].
Definition: OpDetGeo.cxx:98
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
Point GetCenter() const
Returns the center of the voxel (type Point).
Definition: PhotonVoxels.h:186
std::vector< OpDetRecord > fRecords
PhotonVoxel GetPhotonVoxel(int ID) const
const float * phot::PhotonLibraryHybrid::GetCounts ( size_t  Voxel) const
overridevirtual

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

Implements phot::IPhotonLibrary.

Definition at line 82 of file PhotonLibraryHybrid.cxx.

References GetCount(), and NOpChannels().

83  {
84  // The concept of GetCounts() conflicts fairly badly with how this library
85  // works. This is probably the best we can do.
86 
87  static float* counts = 0;
88  if (!counts) counts = new float[NOpChannels()];
89  for (int od = 0; od < NOpChannels(); ++od)
90  counts[od] = GetCount(vox, od);
91  return counts;
92  }
Float_t vox
Definition: plot.C:38
counts_as<> counts
Number of ADC counts, represented by signed short int.
Definition: electronics.h:112
virtual int NOpChannels() const override
virtual float GetCount(size_t Voxel, size_t OpChannel) const override
virtual float phot::PhotonLibraryHybrid::GetReflCount ( size_t  Voxel,
size_t  OpChannel 
) const
inlineoverridevirtual

Implements phot::IPhotonLibrary.

Definition at line 32 of file PhotonLibraryHybrid.h.

32 { return 0; }
virtual const float* phot::PhotonLibraryHybrid::GetReflCounts ( size_t  Voxel) const
inlineoverridevirtual

Implements phot::IPhotonLibrary.

Definition at line 31 of file PhotonLibraryHybrid.h.

31 { return 0; }
virtual float phot::PhotonLibraryHybrid::GetReflT0 ( size_t  Voxel,
size_t  OpChannel 
) const
inlineoverridevirtual

Implements phot::IPhotonLibrary.

Definition at line 37 of file PhotonLibraryHybrid.h.

37 { return 0; }
virtual const float* phot::PhotonLibraryHybrid::GetReflT0s ( size_t  Voxel) const
inlineoverridevirtual

Implements phot::IPhotonLibrary.

Definition at line 36 of file PhotonLibraryHybrid.h.

36 { return 0; }
virtual bool phot::PhotonLibraryHybrid::hasReflected ( ) const
inlineoverridevirtual

Don't implement reflected light.

Implements phot::IPhotonLibrary.

Definition at line 30 of file PhotonLibraryHybrid.h.

30 { return false; }
virtual bool phot::PhotonLibraryHybrid::hasReflectedT0 ( ) const
inlineoverridevirtual

Don't implement reflected light timing.

Implements phot::IPhotonLibrary.

Definition at line 35 of file PhotonLibraryHybrid.h.

35 { return false; }
virtual bool phot::IPhotonLibrary::isVoxelValid ( size_t  Voxel) const
inlinevirtualinherited

Reimplemented in phot::PhotonLibrary.

Definition at line 50 of file IPhotonLibrary.h.

References phot::IPhotonLibrary::NVoxels().

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

50 { return Voxel < (std::size_t)NVoxels(); }
virtual int NVoxels() const =0
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 phot::PhotonLibrary::CreateEmptyLibrary(), and phot::PhotonLibrary::LoadLibraryFromFile().

53 { return NVoxels() * NOpChannels(); }
virtual int NOpChannels() const =0
virtual int NVoxels() const =0
virtual int phot::PhotonLibraryHybrid::NOpChannels ( ) const
inlineoverridevirtual

Implements phot::IPhotonLibrary.

Definition at line 39 of file PhotonLibraryHybrid.h.

Referenced by GetCount(), and GetCounts().

39 { return fRecords.size(); }
std::vector< OpDetRecord > fRecords
int phot::PhotonLibraryHybrid::NVoxels ( ) const
overridevirtual

Implements phot::IPhotonLibrary.

Definition at line 76 of file PhotonLibraryHybrid.cxx.

References fVoxDef, and sim::PhotonVoxelDef::GetNVoxels().

Referenced by GetCount(), and PhotonLibraryHybrid().

77  {
78  return fVoxDef.GetNVoxels();
79  }
const sim::PhotonVoxelDef & fVoxDef
unsigned int GetNVoxels() const
Returns the total number of voxels in the volume.

Member Data Documentation

std::vector<OpDetRecord> phot::PhotonLibraryHybrid::fRecords
protected

Definition at line 70 of file PhotonLibraryHybrid.h.

Referenced by GetCount(), and PhotonLibraryHybrid().

const sim::PhotonVoxelDef& phot::PhotonLibraryHybrid::fVoxDef
protected

Definition at line 43 of file PhotonLibraryHybrid.h.

Referenced by GetCount(), and NVoxels().


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