3 #include <utl/AugerException.h>
4 #include <utl/Branch.h>
5 #include <utl/AugerUnits.h>
6 #include <utl/NormalDistribution.h>
16 using namespace USCInterTankResponseNS;
25 return pow(signal,pars[0])/(
pow(signal,pars[0]) + pars[1]);
41 string dataSilentFilePath;
44 string dataSilentSimFilePath;
47 vector<double> buffer;
49 fTriggerParameters[0][0] = buffer[0];
50 fTriggerParameters[0][1] = buffer[1];
52 vector<double>().
swap(buffer);
54 fTriggerParameters[1][0] = buffer[0];
55 fTriggerParameters[1][1] = buffer[1];
57 TFile* f = TFile::Open(dataFilePath.c_str(),
"READ");
60 msg <<
"ERROR: could not open file " << dataFilePath;
67 boost::multi_array<double,3>
data(boost::extents[NBIN][Nz][Nr]);
68 boost::multi_array<double,2> data_avg(boost::extents[Nz][Nr]);
69 boost::multi_array<double,2> data_sigma(boost::extents[Nz][Nr]);
71 for (
int nmu = 1; nmu <= Nmu; ++nmu)
73 for (
int ze = 0; ze < Nz; ++ze)
75 int theta = 60 + 2 * ze;
76 for (
int rr = 0; rr < Nr; ++rr)
79 ostringstream histoID;
81 histoID <<
"thPmt_" << theta <<
"_" << rr <<
"_0";
83 histoID <<
"thConv_" << theta <<
"_" << rr <<
"_0" <<
"_" << nmu;
85 TH1D *histResponse = 0;
86 histResponse =
static_cast<TH1D*
>(f->Get(histoID.str().c_str()));
90 msg <<
"ERROR: Histogram " << histoID.str() <<
" not found in " << dataFilePath <<
"\n";
96 data_avg[ze][rr] = histResponse->GetMean();
97 data_sigma[ze][rr] = histResponse->GetRMS();
98 fDS = histResponse->GetBinWidth(1);
101 for (
int bin = 0; bin < histResponse->GetNbinsX(); bin++)
102 data[bin][ze][rr] = histResponse->GetBinContent(bin+1);
106 fUSCTankModel[nmu-1] =
USCTankModel(GetThetaMin(),GetThetaMax(),GetLogrMin(),GetLogrMax(),data);
110 fUSCAvgTankModel =
USCAvgTankModel(GetThetaMin(),GetThetaMax(),GetLogrMin(),GetLogrMax(),data_avg);
111 fUSCSigmaTankModel =
USCSigmaTankModel(GetThetaMin(),GetThetaMax(),GetLogrMin(),GetLogrMax(),data_sigma);
121 fOutProb.open(dataSilentSimFilePath.c_str());
122 for(
int pp=0;pp<16;pp++)
123 for(
int k=0;k<30;k++)
124 fOutProb >> dummy0 >> dummy1 >> fProbNoTriggerSilent[1][pp][k];
127 fOutProb.open(dataSilentFilePath.c_str());
128 for(
int pp=0;pp<16;pp++)
129 for(
int k=0;k<30;k++)
130 fOutProb >> dummy0 >> dummy1 >> fProbNoTriggerSilent[0][pp][k];
139 if(th < GetThetaMin())
142 if(th > GetThetaMax())
145 double logr = log10(r/
meter);
147 if(logr < GetLogrMin())
150 if(logr > GetLogrMax())
153 const double a = fUSCAvgTankModel(th,logr);
162 if(th < GetThetaMin())
165 if(th > GetThetaMax())
168 double logr = log10(r/
meter);
170 if(logr < GetLogrMin())
173 if(logr > GetLogrMax())
176 const double b = fUSCSigmaTankModel(th,logr);
178 return b*
sqrt(nmuon);
186 if(th < GetThetaMin())
189 if(th > GetThetaMax())
192 double logr = log10(r/
meter);
194 if(logr < GetLogrMin())
197 if(logr > GetLogrMax())
200 if (nmuon <= GetMaxMuonNumber()) {
205 static vector<double> interpolatedTrace(NBIN);
206 fUSCTankModel[nmuon-1](interpolatedTrace, th, logr);
208 size_t i =
static_cast<size_t>(signal/fDS);
214 double prob = interpolatedTrace[i];
215 prob *=
TriggerPDF(signal, fTriggerParameters[
int(fSimulationMode)]);
216 if (prob < 0) prob = 0;
222 const double a = fUSCAvgTankModel(th,logr);
223 const double b = fUSCSigmaTankModel(th,logr);
225 const double mean = a*nmuon;
226 const double sigma = b*
sqrt(nmuon);
236 if(th < GetThetaMin())
239 if(th > GetThetaMax())
242 double logr = log10(r/
meter);
244 if(logr < GetLogrMin())
247 if(logr > GetLogrMax())
251 double theta_deg = th/
degree;
252 int c_bin = int( (theta_deg - 59.0)/2.0 );
257 double prob_silent = 1.0-fProbNoTriggerSilent[int(fSimulationMode)][c_bin][entry];
263 const double a = fUSCAvgTankModel(th,logr);
264 const double b = fUSCSigmaTankModel(th,logr);
266 double mean = a*nmuon;
267 double sigma = b*
sqrt( (
double)nmuon );
268 return NormalCDF(signalmin, mean, sigma);
virtual double StDev(const double theta, const double r, const ulong muons) const
Standard deviation of signal, given fixed number of muons.
void swap(OverCounted &oc1, OverCounted &oc2)
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
double pow(const double x, const unsigned int i)
virtual double PDF(const double signal, const double theta, const double r, const ulong muons) const
PDF of signal, given a fixed number of muons.
virtual double Mean(const double theta, const double r, const ulong muons) const
Average signal, given fixed number of muons.
double NormalPDF(const double x)
double NormalCDF(const double x)
Class representing a document branch.
utl::Spline::Interpolator2D USCSigmaTankModel
void GetData(bool &b) const
Overloads of the GetData member template function.
static TankResponse & GetInstance(const utl::Branch branch)
utl::Spline::VectorInterpolator2D USCTankModel
virtual double CDF(const double threshold, const double theta, const double r, const ulong muons) const
Probability of signal begin smaller than smax, given a fixed number of muons.
utl::Spline::Interpolator2D USCAvgTankModel