LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
FlashHypothesisComparison.cxx
Go to the documentation of this file.
1 
12 
16 
17 #include "TH1F.h"
18 #include "TTree.h"
19 
20 #include <iostream>
21 
23  TH1F* h_h_p,
24  TH1F* h_s_p,
25  TH1F* h_c_p,
26  TH1F* h_h_l,
27  TH1F* h_s_l,
28  TH1F* h_c_l,
29  TH1F* h_h_t,
30  TH1F* h_s_t,
31  TH1F* h_c_t,
32  const unsigned int n_opdet,
33  bool fill)
34 {
35  fTree = tree;
36  fFillTree = fill;
37  fTree->SetName("ctree");
38 
39  fTree->Branch("run", &fRun, "run/i");
40  fTree->Branch("event", &fEvent, "event/i");
41 
42  fHypHist_p = h_h_p;
43  fSimHist_p = h_s_p;
44  fCompareHist_p = h_c_p;
45 
46  fHypHist_p->SetBins(n_opdet, -0.5, (float)n_opdet - 0.5);
47  fSimHist_p->SetBins(n_opdet, -0.5, (float)n_opdet - 0.5);
48  fCompareHist_p->SetBins(n_opdet, -0.5, (float)n_opdet - 0.5);
49 
50  fHypHist_p->SetNameTitle("hHypHist_p", "Hypothesis (Prompt);Opdet;PEs");
51  fSimHist_p->SetNameTitle("hSimHist_p", "SimPhoton (Prompt);Opdet;PEs");
52  fCompareHist_p->SetNameTitle("hCompareHist_p", "Comparison (Hyp - Sim) (Prompt);Opdet;PEs");
53 
54  fTree->Branch("hyp_PEs_p", &fHypPEs_p, "hyp_PEs_p/F");
55  fTree->Branch("hyp_PEsError_p", &fHypPEsError_p, "hyp_PEsError_p/F");
56  fTree->Branch("sim_PEs_p", &fSimPEs_p, "sim_PEs_p/F");
57 
58  fTree->Branch("hyp_Y_p", &fHypY_p, "hyp_Y_p/F");
59  fTree->Branch("sim_Y_p", &fSimY_p, "sim_Y_p/F");
60 
61  fTree->Branch("hyp_RMSY_p", &fHypRMSY_p, "hyp_RMSY_p/F");
62  fTree->Branch("sim_RMSY_p", &fSimRMSY_p, "sim_RMSY_p/F");
63 
64  fTree->Branch("hyp_Z_p", &fHypZ_p, "hyp_Z_p/F");
65  fTree->Branch("sim_Z_p", &fSimZ_p, "sim_Z_p/F");
66 
67  fTree->Branch("hyp_RMSZ_p", &fHypRMSZ_p, "hyp_RMSZ_p/F");
68  fTree->Branch("sim_RMSZ_p", &fSimRMSZ_p, "sim_RMSZ_p/F");
69 
70  fTree->Branch("comp_total_p", &fCompare_p, "comp_total_p/F");
71 
72  fTree->Branch("hHypHist_p", &fHypHist_p);
73  fTree->Branch("hSimHist_p", &fSimHist_p);
74  fTree->Branch("hCompareHist_p", &fCompareHist_p);
75 
76  fHypHist_l = h_h_l;
77  fSimHist_l = h_s_l;
78  fCompareHist_l = h_c_l;
79 
80  fHypHist_l->SetBins(n_opdet, -0.5, (float)n_opdet - 0.5);
81  fSimHist_l->SetBins(n_opdet, -0.5, (float)n_opdet - 0.5);
82  fCompareHist_l->SetBins(n_opdet, -0.5, (float)n_opdet - 0.5);
83 
84  fHypHist_l->SetNameTitle("hHypHist_l", "Hypothesis (Late);Opdet;PEs");
85  fSimHist_l->SetNameTitle("hSimHist_l", "SimPhoton (Late);Opdet;PEs");
86  fCompareHist_l->SetNameTitle("hCompareHist_l", "Comparison (Hyp - Sim) (Late);Opdet;PEs");
87 
88  fTree->Branch("hyp_PEs_l", &fHypPEs_l, "hyp_PEs_l/F");
89  fTree->Branch("hyp_PEsError_l", &fHypPEsError_l, "hyp_PEsError_l/F");
90  fTree->Branch("sim_PEs_l", &fSimPEs_l, "sim_PEs_l/F");
91 
92  fTree->Branch("hyp_Y_l", &fHypY_l, "hyp_Y_l/F");
93  fTree->Branch("sim_Y_l", &fSimY_l, "sim_Y_l/F");
94 
95  fTree->Branch("hyp_RMSY_l", &fHypRMSY_l, "hyp_RMSY_l/F");
96  fTree->Branch("sim_RMSY_l", &fSimRMSY_l, "sim_RMSY_l/F");
97 
98  fTree->Branch("hyp_Z_l", &fHypZ_l, "hyp_Z_l/F");
99  fTree->Branch("sim_Z_l", &fSimZ_l, "sim_Z_l/F");
100 
101  fTree->Branch("hyp_RMSZ_l", &fHypRMSZ_l, "hyp_RMSZ_l/F");
102  fTree->Branch("sim_RMSZ_l", &fSimRMSZ_l, "sim_RMSZ_l/F");
103 
104  fTree->Branch("comp_total_l", &fCompare_l, "comp_total_l/F");
105 
106  fTree->Branch("hHypHist_l", &fHypHist_l);
107  fTree->Branch("hSimHist_l", &fSimHist_l);
108  fTree->Branch("hCompareHist_l", &fCompareHist_l);
109 
110  fHypHist_t = h_h_t;
111  fSimHist_t = h_s_t;
112  fCompareHist_t = h_c_t;
113 
114  fHypHist_t->SetBins(n_opdet, -0.5, (float)n_opdet - 0.5);
115  fSimHist_t->SetBins(n_opdet, -0.5, (float)n_opdet - 0.5);
116  fCompareHist_t->SetBins(n_opdet, -0.5, (float)n_opdet - 0.5);
117 
118  fHypHist_t->SetNameTitle("hHypHist_t", "Hypothesis (Total);Opdet;PEs");
119  fSimHist_t->SetNameTitle("hSimHist_t", "SimPhoton (Total);Opdet;PEs");
120  fCompareHist_t->SetNameTitle("hCompareHist_t", "Comparison (Hyp - Sim) (Total);Opdet;PEs");
121 
122  fTree->Branch("hyp_PEs_t", &fHypPEs_t, "hyp_PEs_t/F");
123  fTree->Branch("hyp_PEsError_t", &fHypPEsError_t, "hyp_PEsError_t/F");
124  fTree->Branch("sim_PEs_t", &fSimPEs_t, "sim_PEs_t/F");
125 
126  fTree->Branch("hyp_Y_t", &fHypY_t, "hyp_Y_t/F");
127  fTree->Branch("sim_Y_t", &fSimY_t, "sim_Y_t/F");
128 
129  fTree->Branch("hyp_RMSY_t", &fHypRMSY_t, "hyp_RMSY_t/F");
130  fTree->Branch("sim_RMSY_t", &fSimRMSY_t, "sim_RMSY_t/F");
131 
132  fTree->Branch("hyp_Z_t", &fHypZ_t, "hyp_Z_t/F");
133  fTree->Branch("sim_Z_t", &fSimZ_t, "sim_Z_t/F");
134 
135  fTree->Branch("hyp_RMSZ_t", &fHypRMSZ_t, "hyp_RMSZ_t/F");
136  fTree->Branch("sim_RMSZ_t", &fSimRMSZ_t, "sim_RMSZ_t/F");
137 
138  fTree->Branch("comp_total_t", &fCompare_t, "comp_total_t/F");
139 
140  fTree->Branch("hHypHist_t", &fHypHist_t);
141  fTree->Branch("hSimHist_t", &fSimHist_t);
142  fTree->Branch("hCompareHist_t", &fCompareHist_t);
143 }
144 
146  const unsigned int event,
147  const FlashHypothesisCollection& fhc,
148  const SimPhotonCounter& spc,
149  const std::vector<float>& posY,
150  const std::vector<float>& posZ)
151 {
152  if (fhc.GetVectorSize() != (unsigned int)fHypHist_p->GetNbinsX() ||
153  fhc.GetVectorSize() != spc.PromptPhotonVector().size() ||
154  fhc.GetVectorSize() != posY.size() || fhc.GetVectorSize() != posZ.size()) {
155  std::cout << (unsigned int)fHypHist_p->GetNbinsX() << " " << spc.PromptPhotonVector().size()
156  << " " << posY.size() << " " << posZ.size() << std::endl;
157  throw std::runtime_error("ERROR in FlashHypothesisComparison: Mismatch in vector sizes.");
158  }
159  fRun = run;
160  fEvent = event;
161 
162  FillFlashHypothesisInfo(fhc, posY, posZ);
163  FillSimPhotonCounterInfo(spc, posY, posZ);
164  FillComparisonInfo(fhc, spc);
165 
166  if (fFillTree) fTree->Fill();
167 }
168 
170  const std::vector<float>& posY,
171  const std::vector<float>& posZ)
172 {
177 
178  for (size_t i = 0; i < fhc.GetVectorSize(); i++)
179  fHypHist_p->SetBinContent(i + 1, fhc.GetPromptHypothesis().GetHypothesis(i));
180 
185 
186  for (size_t i = 0; i < fhc.GetVectorSize(); i++)
187  fHypHist_l->SetBinContent(i + 1, fhc.GetLateHypothesis().GetHypothesis(i));
188 
193 
194  for (size_t i = 0; i < fhc.GetVectorSize(); i++)
195  fHypHist_t->SetBinContent(i + 1, fhc.GetLateHypothesis().GetHypothesis(i));
196 }
197 
199  const std::vector<float>& posY,
200  const std::vector<float>& posZ)
201 {
205 
206  for (size_t i = 0; i < spc.PromptPhotonVector().size(); i++)
207  fSimHist_p->SetBinContent(i + 1, spc.PromptPhotonVector()[i]);
208 
209  fSimPEs_l = spc.LatePhotonTotal();
212 
213  for (size_t i = 0; i < spc.LatePhotonVector().size(); i++)
214  fSimHist_l->SetBinContent(i + 1, spc.LatePhotonVector()[i]);
215 
219 
220  for (size_t i = 0; i < spc.GetVectorSize(); i++)
221  fSimHist_t->SetBinContent(i + 1, spc.TotalPhotonVector(i));
222 }
223 
225  const SimPhotonCounter& spc)
226 {
227  std::vector<float> result_p, result_l, result_t;
231 
232  for (size_t i = 0; i < result_p.size(); i++) {
233  fCompareHist_p->SetBinContent(i + 1, result_p[i]);
234  fCompareHist_l->SetBinContent(i + 1, result_l[i]);
235  fCompareHist_t->SetBinContent(i + 1, result_t[i]);
236  }
237 }
Float_t posZ
Definition: plotDend.C:20
void FillSimPhotonCounterInfo(const SimPhotonCounter &, const std::vector< float > &, const std::vector< float > &)
float GetTotalPEsError() const
Float_t posY
Definition: plotDend.C:20
const FlashHypothesis & GetLateHypothesis() const
const std::vector< float > & PromptPhotonVector() const
void FillComparisonInfo(const FlashHypothesisCollection &, const SimPhotonCounter &)
float GetTotalPEs() const
std::vector< float > TotalPhotonVector() const
void GetPosition(const std::vector< float > &, const std::vector< float > &, float &, float &)
void fill(const art::PtrVector< recob::Hit > &hits, int only_plane)
const FlashHypothesis & GetPromptHypothesis() const
void SetOutputObjects(TTree *, TH1F *, TH1F *, TH1F *, TH1F *, TH1F *, TH1F *, TH1F *, TH1F *, TH1F *, const unsigned int, bool fill=true)
float CompareByError(const FlashHypothesis &, const std::vector< float > &, std::vector< float > &)
const std::vector< float > & LatePhotonVector() const
float const & GetHypothesis(size_t i_opdet) const
float PromptPhotonTotal() const
void RunComparison(const unsigned int, const unsigned int, const FlashHypothesisCollection &, const SimPhotonCounter &, const std::vector< float > &, const std::vector< float > &)
const FlashHypothesis & GetTotalHypothesis() const
void FillFlashHypothesisInfo(const FlashHypothesisCollection &, const std::vector< float > &, const std::vector< float > &)
size_t GetVectorSize() const
std::vector< float > const & GetHypothesisVector() const
float LatePhotonTotal() const
Event finding and building.