34{
37
38 string inputFile;
43 string option;
46
47
48 try {
49
50 JParser<> zap(
"Auxiliary program to fit singles rate distributions.");
51
60
62 }
63 catch(const exception &error) {
65 }
66
67
69
71
72 try {
74 }
77 }
78
79 TFile* in = TFile::Open(inputFile.c_str(),
"exist");
80
81 if (in ==
NULL || !in->IsOpen()) {
82 FATAL(
"File: " << inputFile <<
" not opened." <<
endl);
83 }
84
86
88
91
92 TH2D* h2s = (
TH2D*) in->Get((title+
".2S").c_str());
93
95
97
98 continue;
99 }
100
101 const double factor = 1.0/1000 ;
102
103 TH1D mean((title+
".1mean").c_str(),
NULL, NUMBER_OF_PMTS, -0.5, NUMBER_OF_PMTS-0.5) ;
104 TH1D sigma((title+
".1sigma").c_str(),
NULL, NUMBER_OF_PMTS, -0.5, NUMBER_OF_PMTS-0.5) ;
105
106 for (
int i = 1; i <= h2s->GetXaxis()->
GetNbins(); ++i) {
107
109
110 slice.Sumw2() ;
111
112 for (
int j = 1 ;
j <= h2s->GetNbinsY() ; ++
j) {
113
114 slice.SetBinContent(
j, h2s->GetBinContent(i,
j)) ;
115 slice.SetBinError (
j, sqrt(h2s->GetBinContent(i,
j))) ;
116
117 }
118
119 if (slice.Integral() <= 0.0) {
120
121 WARNING(
"No data in PMT " << i-1 <<
" of module " << title <<
", skipping fit" <<
endl) ;
122
124 }
125
126 slice.Scale(1.0/slice.Integral()) ;
127
128
129 int binmax = slice.GetMaximumBin() ;
131
136
138
139 TF1 f1("f1", "[0]*exp(-0.5*(x-[1])*(x-[1])/([2]*[2]))/(sqrt(2*pi)*[2])");
140
141
142 f1.SetParameter(0, 0.2) ;
143 f1.SetParameter(1, 6.0) ;
144 f1.SetParameter(2, 0.3) ;
145
147 f1.SetParLimits(0, 0.0, 10.0);
148 f1.SetParLimits(1, 0.0, 20.0);
149 f1.SetParLimits(2, 0.0, 1.0);
150 }
151
153 option += " Q";
154 }
155
156 DEBUG(
"Fit histogram " << slice.GetName() <<
" in range " <<
fitrange <<
" kHz " <<
endl ) ;
157
158 slice.Fit(&f1, option.c_str(),
"same", max(0.0,
fitrange.first),
fitrange.second) ;
159
160 DEBUG( f1.GetParameter(0)<<
" "<<f1.GetParameter(1)<<
" "<<f1.GetParameter(2)<<
endl ) ;
161
162 mean.SetBinContent(i, f1.GetParameter(1)) ;
163 sigma.SetBinContent(i, f1.GetParameter(2)) ;
164
166 slice.Write() ;
167 }
168
169 }
170
171 mean.Write() ;
172 sigma.Write() ;
173
174 }
175
176 out.Close() ;
177
178}
#define DEBUG(A)
Message macros.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Wrapper class around STL string class.
Template definition of a multi-dimensional oscillation probability interpolation table.
static const double * getData(const double factor=1.0)
Get abscissa values.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
KM3NeT DAQ data structures and auxiliaries.