Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
Control_utils.hh File Reference
#include <string>
#include <iostream>
#include <sstream>
#include <iomanip>
#include "TCanvas.h"
#include "RooPlot.h"
#include "RooDerivative.h"
#include "TLine.h"
#include "TF1.h"
#include "NBRun.hh"
#include "Detector.hh"

Go to the source code of this file.

Functions

TH2D * refs_th2 (NBRun *Run)
 Produces a TH2 to be read as a table that summarizes which pmts were used as references for each module. More...
 
TH2D * good_refs_th2 (NBRun *Run)
 Produces a TH2 to be read as a table that summarizes which pmts were used as good references for each module. More...
 
TH2D * good_tgt_pmts_th2 (NBRun *Run)
 Produces a TH2 to be read as a table that summarizes which pmts were used as good references for each module. More...
 
TH2D * srcs_th2 (NBRun *Run)
 Produces a TH2 to be read as a table that summarizes which modules were used as good sources for each target module. More...
 
TH2D * tgts_th2 (NBRun *Run)
 Produces a TH2 to be interpreted as a table that summarizes which modules were targets for each source module. More...
 
TCanvas * RooCanvas (RooWorkspace w, TH1D *h)
 Produces a TCanvas with the nanobeacon peak and the fit performed with Roofit. More...
 

Function Documentation

TH2D* refs_th2 ( NBRun Run)
inline

Produces a TH2 to be read as a table that summarizes which pmts were used as references for each module.

Parameters
Runa pointer to a nanobeacon run
Returns
A TH2

Definition at line 27 of file Control_utils.hh.

27  {
28 
29  int run_number = Run->getRunNumber() ;
30 
31  double voltage = Run->getVoltage() ;
32 
33  vector <SuperModule*> SuperMods = Run->getSuperModules() ;
34 
35  char name[100] ;
36 
37  sprintf(name , "refs_Run_%d_%2.1fV", run_number , voltage) ;
38 
39  char title[100] ;
40 
41  sprintf(title , "Used reference PMTs") ;
42 
43  TH2D* refs = new TH2D(name , title , 18 , 0.5 , 18.5 , 12 , -0.5 , 11.5) ;
44 
45  for (auto & sm : SuperMods) {
46 
47  if (sm->get_ref_pmts().size()>0) {
48 
49  for (auto & ref : sm->get_ref_pmts()) {
50 
51  refs->Fill(sm->getFloor() , ref->getChannel()) ;
52 
53  }
54 
55  }
56 
57  }
58 
59  refs->GetXaxis()->SetTitle("Nanobeacon Floor") ;
60 
61  refs->GetYaxis()->SetTitle("PMT Channel (FPGA)") ;
62 
63  refs->SetOption("colz") ;
64 
65  refs->SetStats(0) ;
66 
67  return refs ;
68 
69 }
vector< SuperModule * > getSuperModules()
Get the SuperModules in the DU.
Definition: NBRun.hh:323
double getVoltage()
Get nanobeacon voltage.
Definition: NBRun.hh:439
int getRunNumber()
Get run number.
Definition: NBRun.hh:427
TH2D* good_refs_th2 ( NBRun Run)
inline

Produces a TH2 to be read as a table that summarizes which pmts were used as good references for each module.

Parameters
Runa pointer to a nanobeacon run
Returns
A TH2

Definition at line 79 of file Control_utils.hh.

79  {
80 
81  int run_number = Run->getRunNumber() ;
82 
83  double voltage = Run->getVoltage() ;
84 
85  vector <SuperModule*> SuperMods = Run->getSuperModules() ;
86 
87  char name[100] ;
88 
89  sprintf(name , "refs_Run_%d_%2.1fV", run_number , voltage) ;
90 
91  char title[100] ;
92 
93  sprintf(title , "Used reference PMTs") ;
94 
95  TH2D* refs = new TH2D(name , title , 18 , 0.5 , 18.5 , 12 , -0.5 , 11.5) ;
96 
97  for (auto & sm : SuperMods) {
98 
99  if (sm->get_ref_pmts().size()>0) {
100 
101  for (auto & ref : sm->get_ref_pmts()) {
102 
103  refs->Fill(sm->getFloor() , ref->getChannel()) ;
104 
105  if (ref->getNBPulse()->IsGood()==true){
106 
107  refs->Fill(sm->getFloor() , ref->getChannel()) ;
108 
109  }
110 
111  }
112 
113  }
114 
115  }
116 
117  refs->GetXaxis()->SetTitle("Nanobeacon Floor") ;
118 
119  refs->GetYaxis()->SetTitle("PMT Channel (FPGA)") ;
120 
121  refs->SetOption("colz") ;
122 
123  refs->SetStats(0) ;
124 
125  return refs ;
126 
127 }
vector< SuperModule * > getSuperModules()
Get the SuperModules in the DU.
Definition: NBRun.hh:323
double getVoltage()
Get nanobeacon voltage.
Definition: NBRun.hh:439
int getRunNumber()
Get run number.
Definition: NBRun.hh:427
TH2D* good_tgt_pmts_th2 ( NBRun Run)
inline

Produces a TH2 to be read as a table that summarizes which pmts were used as good references for each module.

Parameters
Runa pointer to a nanobeacon run
Returns
A TH2

Definition at line 136 of file Control_utils.hh.

136  {
137 
138  int run_number = Run->getRunNumber() ;
139 
140  double voltage = Run->getVoltage() ;
141 
142  vector <SuperModule*> SuperMods = Run->getSuperModules() ;
143 
144  char name[100] ;
145 
146  sprintf(name , "tgt_pmts_Run_%d_%2.1fV", run_number , voltage) ;
147 
148  char title[100] ;
149 
150  sprintf(title , "Target PMTs used for the closest good source.") ;
151 
152  TH2D* tgts = new TH2D(name , title , 18 , 0.5 , 18.5 , 19 , 11.5 , 30.5) ;
153 
154  for (auto & sm : SuperMods) {
155 
156  if(sm->has_good_sources()==true){
157 
158  for (auto & spm : sm->get_closest_good_source().second){
159 
160  tgts->Fill(sm->getFloor() , spm->getChannel());
161 
162  if (spm->getNBPulse()->IsGood()==true){
163 
164  tgts->Fill(sm->getFloor() , spm->getChannel());
165 
166  }
167 
168  }
169 
170  }
171 
172  }
173 
174  tgts->GetXaxis()->SetTitle("Nanobeacon Floor") ;
175 
176  tgts->GetYaxis()->SetTitle("PMT Channel (FPGA)") ;
177 
178  tgts->SetOption("colz") ;
179 
180  tgts->SetStats(0) ;
181 
182  return tgts ;
183 
184 }
vector< SuperModule * > getSuperModules()
Get the SuperModules in the DU.
Definition: NBRun.hh:323
double getVoltage()
Get nanobeacon voltage.
Definition: NBRun.hh:439
int getRunNumber()
Get run number.
Definition: NBRun.hh:427
TH2D* srcs_th2 ( NBRun Run)
inline

Produces a TH2 to be read as a table that summarizes which modules were used as good sources for each target module.

Parameters
Runa pointer to a nanobeacon run
Returns
A TH2

Definition at line 194 of file Control_utils.hh.

194  {
195 
196  int run_number = Run->getRunNumber() ;
197 
198  double voltage = Run->getVoltage() ;
199 
200  vector <SuperModule*> SuperMods = Run->getSuperModules() ;
201 
202  char name[100] ;
203 
204  sprintf(name , "srcs_Run_%d_%2.1fV", run_number , voltage) ;
205 
206  char title[100] ;
207 
208  sprintf(title , "Sources for each target module.") ;
209 
210  TH2D* srcs = new TH2D(name , title , 18 , 0.5 , 18.5 , 18 , 0.5 , 18.5);
211 
212  for(auto & sm : SuperMods){
213 
214  int thisfloor = sm->getFloor() ;
215 
216  if(sm->get_sources().size()>0){
217 
218  for (auto & src : sm->get_sources()){
219 
220  int thatfloor = src.first->getFloor();
221 
222  srcs->Fill(thisfloor , thatfloor ) ;
223 
224  }
225  }
226 
227  if(sm->get_good_sources().size()>0){
228 
229  for (auto & src : sm->get_good_sources()){
230 
231  int thatfloor = src.first->getFloor();
232 
233  srcs->Fill(thisfloor , thatfloor) ;
234  }
235 
236  int thatfloor = sm->get_closest_good_source().first->getFloor();
237 
238  srcs->Fill(thisfloor , thatfloor) ;
239  }
240 
241  }
242 
243  srcs->GetXaxis()->SetTitle("Target Floor") ;
244 
245  srcs->GetYaxis()->SetTitle("Source Floor") ;
246 
247  srcs->SetOption("colz") ;
248 
249  srcs->SetStats(0) ;
250 
251  return srcs;
252 }
vector< SuperModule * > getSuperModules()
Get the SuperModules in the DU.
Definition: NBRun.hh:323
double getVoltage()
Get nanobeacon voltage.
Definition: NBRun.hh:439
int getRunNumber()
Get run number.
Definition: NBRun.hh:427
TH2D* tgts_th2 ( NBRun Run)
inline

Produces a TH2 to be interpreted as a table that summarizes which modules were targets for each source module.

Parameters
Runa pointer to a nanobeacon run
Returns
A TH2

Definition at line 262 of file Control_utils.hh.

262  {
263 
264  int run_number = Run->getRunNumber() ;
265 
266  double voltage = Run->getVoltage() ;
267 
268  vector <SuperModule*> SuperMods = Run->getSuperModules() ;
269 
270  char name[100] ;
271 
272  sprintf(name , "tgts_Run_%d_%2.1fV", run_number , voltage) ;
273 
274  char title[100] ;
275 
276  sprintf(title , "Targets for each source module.") ;
277 
278  TH2D* tgts = new TH2D(name , title , 18 , 0.5 , 18.5 , 18 , 0.5 , 18.5) ;
279 
280  for(auto & sm : SuperMods){
281 
282  int thisfloor = sm->getFloor() ;
283 
284  if(sm->get_targets().size()>0){
285 
286  for (auto & tgt : sm->get_targets()){
287 
288  int thatfloor = tgt.first->getFloor() ;
289 
290  tgts->Fill(thisfloor , thatfloor ) ;
291 
292  }
293  }
294 
295  if(sm->get_good_targets().size()>0){
296 
297  for (auto & tgt : sm->get_good_targets()){
298 
299  int thatfloor = tgt.first->getFloor() ;
300 
301  tgts->Fill(thisfloor , thatfloor) ;
302 
303  }
304 
305  int thatfloor = sm->get_closest_good_target().first->getFloor() ;
306 
307  tgts->Fill(thisfloor , thatfloor) ;
308  }
309 
310  }
311 
312  tgts->SetOption("colz") ;
313 
314  tgts->GetXaxis()->SetTitle("Source Floor") ;
315 
316  tgts->GetYaxis()->SetTitle("Target Floor") ;
317 
318  tgts->SetOption("colz") ;
319 
320  tgts->SetStats(0) ;
321 
322  return tgts ;
323 
324 }
vector< SuperModule * > getSuperModules()
Get the SuperModules in the DU.
Definition: NBRun.hh:323
double getVoltage()
Get nanobeacon voltage.
Definition: NBRun.hh:439
int getRunNumber()
Get run number.
Definition: NBRun.hh:427
TCanvas* RooCanvas ( RooWorkspace  w,
TH1D *  h 
)
inline

Produces a TCanvas with the nanobeacon peak and the fit performed with Roofit.

Parameters
wA Rooworkspace that contains all the information relative to the fit.
hThe histogram with the nanobeacon peak.
Returns
A TCanvas

Definition at line 334 of file Control_utils.hh.

334  {
335 
336  TCanvas * c = new TCanvas( (std::string("canvas_")+h->GetName()).c_str() , (std::string("canvas_")+h->GetName()).c_str() );
337 
338  c->cd() ;
339 
340  RooPlot* frame = w.var("time")->frame() ;
341 
342  RooDataHist Data ("data" , "data" , *w.var("time") , Import(*h)) ;
343 
344  Data.plotOn(frame) ;
345 
346  w.function("Model")->plotOn(frame) ;
347 
348  w.function("L1")->plotOn(frame , LineStyle(kDashed)) ;
349 
350  w.function("G1")->plotOn(frame , LineStyle(kDashed) , LineColor(kRed)) ;
351 
352  frame->Draw() ;
353 
354  TLine* line = new TLine ( w.var("mpv")->getVal() , 1 , w.var("mpv")->getVal() , 1e5) ;
355 
356  line->SetLineColor(kBlue) ;
357 
358  TLine* line2 = new TLine ( w.var("tpeak")->getVal() , 1 , w.var("tpeak")->getVal() , 1e5) ;
359 
360  line2->SetLineColor(kBlack) ;
361 
362  line->Draw("same") ;
363 
364  line2->Draw("same") ;
365 
366  return c ;
367 }