7 #include "art/Framework/Services/Registry/ServiceHandle.h"
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);
68 art::ServiceHandle<geo::Geometry const> geom;
69 geom->NOpDets() ==
fRecords.size() || fatal(
"Number of opdets mismatch");
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;
112 static art::ServiceHandle<geo::Geometry const> geom;
113 const geo::OpDetGeo& opdet = geom->OpDetGeoFromOpDet(opchan);
virtual int NVoxels() const override
BEGIN_PROLOG could also be cerr
Representation of a region of space diced into voxels.
double Eval(double x) const
PhotonLibraryHybrid(const std::string &fname, const sim::PhotonVoxelDef &voxdef)
unsigned int GetNVoxels() const
Returns the total number of voxels in the volume.
virtual ~PhotonLibraryHybrid()
Definitions of voxel data structures.
virtual float GetCount(size_t Voxel, size_t OpChannel) const override
counts_as<> counts
Number of ADC counts, represented by signed short int.
Point GetCenter() const
Returns the center of the voxel (type Point).
std::vector< Exception > exceptions
const sim::PhotonVoxelDef & fVoxDef
double DistanceToPoint(geo::Point_t const &point) const
Returns the distance of the specified point from detector center [cm].
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
std::vector< OpDetRecord > fRecords
virtual const float * GetCounts(size_t Voxel) const override
Returns a pointer to NOpChannels() visibility values, one per channel.
virtual int NOpChannels() const override
art framework interface to geometry description
PhotonVoxel GetPhotonVoxel(int ID) const