55 using namespace KM3NETDAQ;
57 typedef JRange<int> JRange_t;
64 JROOTClassSelector selector;
72 JParser<> zap(
"Example program to determine N-fold coincidence rates.");
76 zap[
'n'] =
make_field(numberOfEvents) = JLimit::max();
79 zap[
'C'] =
make_field(selector) = getROOTClassSelection<JDAQTimesliceTypes_t>();
81 zap[
's'] =
make_field(summaryFile) =
"halibut.txt";
87 catch(
const exception &error) {
88 FATAL(error.what() << endl);
97 load(detectorFile, detector);
99 catch(
const JException& error) {
103 const JModuleRouter router(detector);
105 const JMatch_t match(TMax_ns);
120 JManager_t H1(
new TH1D(
"H1[%]", NULL, 100, -TMax_ns, +TMax_ns));
121 JManager_t T1(
new TH1D(
"T1[%]", NULL, 100, 0.0, TMax_s[M.getLowerLimit()]));
130 JTreeScannerInterface<JDAQTimeslice>* ps = zmap[selector];
136 for (JMultipleFileScanner<>::const_iterator i = inputFile.begin(); i != inputFile.end(); ++i) {
138 STATUS(
"Processing " << *i << endl);
144 for ( ; ps->hasNext() && counter != inputFile.getLimit(); ++counter) {
146 STATUS(
"event: " << setw(10) << counter <<
'\r');
DEBUG(endl);
150 for (JDAQTimeslice::const_iterator frame = timeslice->begin(); frame != timeslice->end(); ++frame) {
152 JSuperFrame2D_t& buffer = JSuperFrame2D_t::demultiplex(*frame, router.getModule(frame->getModuleID()));
162 if (data.size() > 1) {
164 TH1D* h1 = H1[frame->getModuleID()];
165 TH1D* t1 = T1[frame->getModuleID()];
171 while (++q != data.end() && q->getT() - p->getT() <= TMax_ns ) {}
173 const int N = distance(p,q);
177 const int i = router.getIndex(frame->getModuleID());
178 const double ts =
getTimeOfRTS(frame->getFrameIndex()) + p->getT();
180 t1->Fill((ts - t0[i]) * 1.0e-9);
188 h1->Fill(JCombinatorics::getSign(__p->getPMT(),__q->getPMT()) * (__q->getT() - __p->getT()), 1.0/W);
203 const double V = (H1->GetXaxis()->GetXmax() - H1->GetXaxis()->GetXmin()) / (
double) H1->GetXaxis()->GetNbins();
206 for (JManager_t::iterator i = H1.begin(); i != H1.end(); ++i) {
207 i->second->Scale(1.0/(V*W));
210 for (JManager_t::iterator i = T1.begin(); i != T1.end(); ++i) {
211 i->second->Scale(1.0/i->second->GetMaximum());
215 if (summaryFile !=
"") {
217 const double V = (H1->GetXaxis()->GetXmax() - H1->GetXaxis()->GetXmin()) / (
double) H1->GetXaxis()->GetNbins();
221 const int PRECISION = (M.getLowerLimit() > 2 ? 4 : 3);
223 ofstream out(summaryFile.c_str());
225 out <<
"Multiplicity " << M << endl;
226 out <<
"-------------------------------------------------------" << endl;
227 out <<
" location | Gauss | S - B | Total | slope " << endl;
228 out <<
" | [Hz] | [Hz] | [Hz] | [Hz] " << endl;
229 out <<
"-------------------------------------------------------" << endl;
233 for (
int string = 1;
string <= number_of_strings; ++string) {
234 for (
int floor = number_of_floors; floor >= 1; --floor) {
236 const int id = detector.getModule(JModuleLocation(
string,floor)).getID();
238 out <<
" " << setw(3) <<
string <<
' ' << setw(2) << floor <<
" ";
240 TH1D* h1 = (H1.find(
id) != H1.end() ? H1[id] : NULL);
241 TH1D* t1 = (T1.find(
id) != T1.end() ? T1[id] : NULL);
245 TF1 f1(
"f1",
"[0]*exp(-0.5*(x-[1])*(x-[1])/([2]*[2]))/(TMath::Sqrt(2*TMath::Pi())*[2]) + [3]");
247 f1.SetParameter(0, h1->GetMaximum());
248 f1.SetParameter(1, 0.0);
249 f1.SetParameter(2, h1->GetRMS() * 0.25);
250 f1.SetParameter(3, h1->GetMinimum());
252 h1->Fit(&f1, option.c_str(),
"same");
254 out <<
" | " <<
FIXED(8,PRECISION) << f1.GetParameter(0);
255 out <<
" | " <<
FIXED(8,PRECISION) << (h1->GetSumOfWeights() - f1.GetParameter(3) * h1->GetNbinsX()) * V;
256 out <<
" | " <<
FIXED(8,PRECISION) << h1->GetSumOfWeights() * V;
258 Q[0].put( f1.GetParameter(0));
259 Q[1].put((h1->GetSumOfWeights() - f1.GetParameter(3) * h1->GetNbinsX()) * V);
260 Q[2].put( h1->GetSumOfWeights() * V);
265 TF1 f1(
"f1",
"[0]*exp(-[1]*x)");
267 f1.SetParameter(0, t1->GetMaximum());
268 f1.SetParameter(1, 1.0 / t1->GetRMS());
270 t1->Fit(&f1, option.c_str(),
"same");
272 out <<
" | " <<
FIXED(8,PRECISION) << f1.GetParameter(1);
274 Q[3].put(f1.GetParameter(1));
285 out <<
"-------------------------------------------------------" << endl;
286 out << setw(10) << left <<
" average";
288 for (
int i = 0; i !=
sizeof(Q)/
sizeof(Q[0]); ++i) {
289 out <<
" | " <<
FIXED(8,PRECISION) << Q[i].getMean();
Utility class to parse command line options.
int getNumberOfStrings(const JDetector &detector)
Get number of strings.
double getCount(TH1D *hptr, int muon_threshold)
Auxiliary class to manage set of histograms.
Long64_t counter_type
Type definition for counter.
JSuperFrame2D< hit_type > JSuperFrame2D_t
Auxiliary class for a type holder.
Auxiliary data structure for floating point format specification.
double getTimeOfRTS(const JDAQChronometer &chronometer)
Get time of last RTS in ns since start of run for a given chronometer.
long long int factorial(const long long int n)
Determine factorial.
JLimit JLimit_t
Type definition of limit.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
double getFrameTime()
Get frame time duration.
int getNumberOfFloors(const JDetector &detector)
Get number of floors.
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
std::vector< frame_type >::iterator iterator
2-dimensional frame with time calibrated data from one optical module.
const JLimit & getLimit() const
Get limit.
#define DEBUG(A)
Message macros.
JSuperFrame1D< hit_type > JSuperFrame1D_t