17 bool fatal(
const std::string& msg)
19 std::cerr <<
"FATAL: PhotonLibraryHybrid: " << msg << std::endl;
31 TFile
f(fname.c_str());
32 !
f.IsZombie() || fatal(
"Could not open PhotonLibrary "+fname);
34 for(
int opdetIdx = 0;
true; ++opdetIdx){
35 const std::string dirname = TString::Format(
"opdet_%d", opdetIdx).Data();
36 TDirectory*
dir = (TDirectory*)
f.Get(dirname.c_str());
41 TVectorD* fit = (TVectorD*)dir->Get(
"fit");
42 fit || fatal(
"Didn't find "+dirname+
"/fit in "+fname);
45 TTree* tr = (TTree*)dir->Get(
"tr");
46 tr || fatal(
"Didn't find "+dirname+
"/tr in "+fname);
49 tr->SetBranchAddress(
"vox", &vox);
50 tr->SetBranchAddress(
"vis", &vis);
53 for(
int i = 0; i < tr->GetEntries(); ++i){
55 vox <
NVoxels() || fatal(
"Voxel out of range");
66 !
fRecords.empty() || fatal(
"No opdet_*/ directories in "+fname);
69 geom->
NOpDets() ==
fRecords.size() || fatal(
"Number of opdets mismatch");
91 static float* counts = 0;
100 int(vox) <
NVoxels() || fatal(
"GetCount(): Voxel out of range");
101 int(opchan) <
NOpChannels() || fatal(
"GetCount(): OpChan out of range");
105 auto it2 = std::lower_bound(rec.
exceptions.begin(),
108 if(it2->vox == vox)
return it2->vis;
116 const double xyzvox[] = {voxvec.X(), voxvec.Y(), voxvec.Z()};
OpDetGeo const & OpDetGeoFromOpDet(unsigned int OpDet) const
Number of OpDets in the whole detector.
virtual const float * GetCounts(size_t Voxel) const override
Returns a pointer to NOpChannels() visibility values, one per channel.
double Eval(double x) const
TVector3 GetCenter() const
PhotonLibraryHybrid(const std::string &fname, const sim::PhotonVoxelDef &voxdef)
virtual ~PhotonLibraryHybrid()
virtual int NVoxels() const override
std::vector< Exception > exceptions
const sim::PhotonVoxelDef & fVoxDef
virtual int NOpChannels() const override
unsigned int NOpDets() const
Number of OpDets in the whole detector.
double DistanceToPoint(geo::Point_t const &point) const
Returns the distance of the specified point from detector center [cm].
General LArSoft Utilities.
virtual float GetCount(size_t Voxel, size_t OpChannel) const override
std::vector< OpDetRecord > fRecords
art framework interface to geometry description
PhotonVoxel GetPhotonVoxel(int ID) const