22 #include "TGraphErrors.h" 30 #include "TMultiGraph.h" 60 TFile* fout_full =
new TFile(
"full.root",
"RECREATE");
61 TFile* fout_fit =
new TFile(
"fit.root",
"RECREATE");
63 std::cout << voxdef.
GetNVoxels() <<
" voxels for each of " << geom->
NOpDets() <<
" OpDets" << std::endl;
64 std::cout << std::endl;
67 long totExceptions = 0;
70 for(
unsigned int opdetIdx =0; opdetIdx < geom->
NOpDets(); ++opdetIdx){
71 std::cout << opdetIdx <<
" / " << geom->
NOpDets() << std::endl;
73 TDirectory* d_full = fout_full->mkdir(TString::Format(
"opdet_%d", opdetIdx).Data());
74 TDirectory* d_fit = fout_fit->mkdir(TString::Format(
"opdet_%d", opdetIdx).Data());
77 TTree* tr_full =
new TTree(
"tr",
"tr");
79 float dist, vis, psi, theta, xpos;
80 tr_full->Branch(
"vox", &vox);
81 tr_full->Branch(
"dist", &dist);
82 tr_full->Branch(
"vis", &vis);
83 tr_full->Branch(
"taken", &taken);
84 tr_full->Branch(
"psi", &psi);
85 tr_full->Branch(
"theta", &theta);
86 tr_full->Branch(
"xpos", &xpos);
92 const TVector3 opdetvec(xyzopdet);
95 Visibility(
int vx,
int t,
float d,
float v,
float p,
float th,
float xp) :
vox(vx), taken(t), dist(d), vis(v), psi(p), theta(th), xpos(xp) {}
104 TCanvas *
c1=
new TCanvas(
"c1",
"c1");
106 c1->SetWindowSize(600, 600);
111 std::vector<Visibility> viss;
114 for(
int voxIdx = 0; voxIdx < voxdef.
GetNVoxels(); ++voxIdx){
117 const double xyzvox[] = {voxvec.X(), voxvec.Y(), voxvec.Z()};
118 const double fc_y = 600;
119 const double fc_z = 1394;
120 const double fc_x = 350;
131 if((xyzvox[0] - xyzopdet[0])<0){
132 psi = atan((xyzvox[1] - xyzopdet[1])/(-xyzvox[0] +xyzopdet[0]));
135 if(xyzvox[0]<fc_x && xyzvox[0]>-fc_x && xyzvox[1]<fc_y && xyzvox[1]>-fc_y && xyzvox[2]> -9 && xyzvox[2]<fc_z){
136 g.SetPoint(g.GetN(), dist, vis*dist*dist);
138 psi = atan((xyzvox[1] - xyzopdet[1])/(xyzvox[0] - xyzopdet[0]))* 180.0/
PI ;
139 theta = acos((xyzvox[2] - xyzopdet[2])/dist) * 180.0/
PI;
141 if((xyzvox[0] - xyzopdet[0])<0){
142 psi = atan((xyzvox[1] - xyzopdet[1])/(-xyzvox[0] +xyzopdet[0]));
147 viss.emplace_back(voxIdx, taken, dist, vis, psi, theta, xpos);
157 g.GetXaxis()->SetTitle(
"Distance (cm)");
158 g.GetYaxis()->SetTitle(
"Visibility #times r^{2}");
160 TF1* fit = g.GetFunction(
"expo");
164 fitres[0] = fit->GetParameter(0);
165 fitres[1] = fit->GetParameter(1);
170 TH1F h(
"",
"", 200, 0, 20);
173 TTree* tr_fit =
new TTree(
"tr",
"tr");
174 tr_fit->Branch(
"vox", &vox);
175 tr_fit->Branch(
"dist", &dist);
176 tr_fit->Branch(
"vis", &vis);
177 tr_fit->Branch(
"taken", &taken);
178 tr_fit->Branch(
"psi", &psi);
179 tr_fit->Branch(
"theta", &theta);
180 tr_fit->Branch(
"xpos", &xpos);
183 for(
const Visibility& v: viss){
187 const double obs = v.vis / 2
e-5;
188 const double pred = fit->Eval(v.dist) / (v.dist*v.dist) / 2
e-5;
198 double chisq = 2*(pred-obs);
199 if(obs) chisq += 2*obs*log(obs/pred);
216 g2.SetPoint(g2.GetN(), v.dist, v.vis*v.dist*v.dist);
229 g2.SetMarkerStyle(7);
230 g2.SetMarkerColor(kRed);
231 gStyle->SetLabelSize(.04,
"XY");
232 gStyle->SetTitleSize(.04,
"XY");
235 c1->SaveAs(TString::Format(
"plots/Chris_vis_vs_dist_%d.png", opdetIdx).Data());
238 h.GetXaxis()->SetTitle(
"#chi^{2}");
239 h.GetYaxis()->SetTitle(
"Counts");
240 gStyle->SetLabelSize(.04,
"XY");
241 gStyle->SetTitleSize(.04,
"XY");
243 std::cout <<
"Integral(90,-1)/Integral(all) = "<< h.Integral(90, -1) / h.Integral(0, -1) << std::endl;
244 std::cout <<
"*****************************" << std::endl;
245 totExceptions += h.Integral(90, -1);
246 totPts += h.Integral(0, -1);
247 gPad->Print(TString::Format(
"plots/chisq_opdet_%d.eps", opdetIdx).Data());
252 std::cout << totExceptions <<
" exceptions from " << totPts <<
" points = " << (100.*totExceptions)/totPts <<
"%" << std::endl;
CreateHybridLibrary(const fhicl::ParameterSet &p)
OpDetGeo const & OpDetGeoFromOpDet(unsigned int OpDet) const
Number of OpDets in the whole detector.
Encapsulate the construction of a single cyostat.
void analyze(const art::Event &e) override
void GetCenter(double *xyz, double localz=0.0) const
TVector3 GetCenter() const
#define DEFINE_ART_MODULE(klass)
EDAnalyzer(Table< Config > const &config)
unsigned int NOpDets() const
Number of OpDets in the whole detector.
Encapsulate the geometry of an optical detector.
const sim::PhotonVoxelDef & GetVoxelDef() const
double DistanceToPoint(geo::Point_t const &point) const
Returns the distance of the specified point from detector center [cm].
General LArSoft Utilities.
CreateHybridLibrary & operator=(const CreateHybridLibrary &)=delete
art framework interface to geometry description
float GetVisibility(double const *xyz, unsigned int OpChannel, bool wantReflected=false) const
PhotonVoxel GetPhotonVoxel(int ID) const