Jpp
Functions
pulse_classification.cc 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"
#include "pulse_classification_IO.hh"
#include "Control_utils.hh"

Go to the source code of this file.

Functions

void write_output (string filename, NBRun &run)
 Writes a .root file with some objects that can be used to check the calibration. More...
 
int main (int argc, char **argv)
 

Function Documentation

◆ write_output()

void write_output ( string  filename,
NBRun run 
)
inline

Writes a .root file with some objects that can be used to check the calibration.

Parameters
filenamepath to the name of the .root
runThe nanobeacon calibration run

Definition at line 29 of file pulse_classification.cc.

29  {
30 
31  if (filename.length()==0){
32 
33  cout << "Omitting calibration checks..." << endl ;
34 
35  return ;
36 
37  }else{
38 
39  cout << "Writing pulses to file: " << endl ;
40 
41  cout << filename << endl ;
42 
43  cout << "------------------------------------" << endl << endl ;
44 
45  TFile outfile(filename.c_str() , "recreate") ;
46 
47  outfile.cd() ;
48 
49  outfile.mkdir("REF/Good") ;
50  outfile.mkdir("REF/Weak") ;
51  outfile.mkdir("REF/Saturated") ;
52 
53  outfile.mkdir("TGT/Good") ;
54  outfile.mkdir("TGT/Weak") ;
55  outfile.mkdir("TGT/Saturated") ;
56 
57  vector <SuperModule*> SuperMods = run.getSuperModules() ;
58 
59 
60  for (auto & sm : SuperMods){
61 
62  for (auto & spm : sm->get_ref_pmts()){
63 
64  if (spm->getNBPulse()->IsGood()==true) outfile.cd("REF/Good") ;
65 
66  if (spm->getNBPulse()->IsSaturatedHit()==true) outfile.cd("REF/Saturated") ;
67 
68  if (spm->getNBPulse()->IsWeak()==true) outfile.cd("REF/Weak") ;
69 
70  spm->getNBPulse()->getHtime_full()->Write() ;
71 
72  if (spm->getNBPulse()->IsFitted()==true){
73 
74  RooWorkspace w = spm->getNBPulse()->getWorkspace() ;
75 
76  TH1D* h = spm->getNBPulse()->getHtime_full() ;
77 
78  TCanvas* c1 = RooCanvas(w , h) ;
79 
80  c1->Write() ;
81 
82  w.Write() ;
83 
84  }
85 
86  outfile.cd() ;
87 
88  }
89 
90  for (auto & sms : sm->get_sources()){
91 
92  for (auto & spm : sms.second){
93 
94  if (spm->getNBPulse()->IsGood()==true) outfile.cd("TGT/Good") ;
95 
96  if (spm->getNBPulse()->IsSaturatedHit()==true) outfile.cd("TGT/Saturated") ;
97 
98  if (spm->getNBPulse()->IsWeak()==true) outfile.cd("TGT/Weak") ;
99 
100  spm->getNBPulse()->getHtime_full()->Write() ;
101 
102  if (spm->getNBPulse()->IsFitted()==true){
103 
104  RooWorkspace w = spm->getNBPulse()->getWorkspace() ;
105 
106  TH1D* h = spm->getNBPulse()->getHtime_full() ;
107 
108  TCanvas* c1 = RooCanvas(w , h) ;
109 
110  c1->Write() ;
111 
112  w.Write() ;
113 
114  }
115 
116  outfile.cd() ;
117 
118  }
119 
120  }
121 
122  }
123 
124  outfile.Close() ;
125 
126  }
127 
128 }

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 131 of file pulse_classification.cc.

131  {
132 
133  IO options ;
134 
135  read_user_options(options, argc , argv);
136 
137  JDetector detector = loadDetector(options.detector_file) ;
138 
139  NBRun run (options.ifname , detector , options.string_number , options.up_pmts , options.down_pmts , options.number_neighbors) ;
140 
141  run.analyze(options.analysis_level) ;
142 
143  write_output(options.ofname , run) ;
144 
145 }
IO::analysis_level
int analysis_level
Definition: JInterDomCal_IO.hh:63
JTOOLS::w
data_type w[N+1][M+1]
Definition: JPolint.hh:708
IO::down_pmts
int down_pmts
Definition: JInterDomCal_IO.hh:59
read_user_options
int read_user_options(IO &options, int argc, char **argv)
Parses the command line options and fills an IO structure with them.
Definition: JRunAnalyzer.cc:59
NBRun
Class dedicated to the nanobeacon analyses, where the Modules in the detector are not regarded as sin...
Definition: NBRun.hh:24
c1
TCanvas * c1
Global variables to handle mouse events.
Definition: JDrawModule3D.cc:34
std::vector< SuperModule * >
IO
Structure to store the different command line arguments for JRunAnalyzer.
Definition: JRunAnalyzer.cc:40
write_output
void write_output(string filename, NBRun &run)
Writes a .root file with some objects that can be used to check the calibration.
Definition: pulse_classification.cc:29
IO::ofname
string ofname
Definition: JRunAnalyzer.cc:44
IO::ifname
string ifname
Definition: JRunAnalyzer.cc:42
RooCanvas
TCanvas * RooCanvas(RooWorkspace w, TH1D *h)
Produces a TCanvas with the nanobeacon peak and the fit performed with Roofit.
Definition: Control_utils.hh:334
IO::up_pmts
int up_pmts
Definition: JInterDomCal_IO.hh:57
IO::string_number
int string_number
Definition: JInterDomCal_IO.hh:55
JDETECTOR::JDetector
Detector data structure.
Definition: JDetector.hh:80
IO::detector_file
string detector_file
Definition: JRunAnalyzer.cc:46
loadDetector
JDetector loadDetector(string detectorFile)
Loads the content of a detector file in a JDetector object.
Definition: Detector.hh:28
IO::number_neighbors
int number_neighbors
Definition: JInterDomCal_IO.hh:61
NBRun::getSuperModules
vector< SuperModule * > getSuperModules()
Get the SuperModules in the DU.
Definition: NBRun.hh:323