58 typedef JRange<int> JRange_t;
61 JLimit_t& numberOfEvents = inputFile.getLimit();
65 JROOTClassSelector selector;
73 JParser<> zap(
"Example program to determine N-fold coincidence rates.");
77 zap[
'n'] =
make_field(numberOfEvents) = JLimit::max();
80 zap[
'C'] =
make_field(selector) = getROOTClassSelection<JDAQTimesliceTypes_t>();
82 zap[
's'] =
make_field(summaryFile) =
"halibut.txt";
88 catch(
const exception &error) {
89 FATAL(error.what() << endl);
98 load(detectorFile, detector);
100 catch(
const JException& error) {
104 const JModuleRouter router(detector);
114 typedef JSuperFrame2D<JHitR0> JSuperFrame2D_t;
115 typedef JSuperFrame1D<JHitR0> JSuperFrame1D_t;
117 const JMatchL0<JHitR0> match(TMax_ns);
121 JManager_t H1(
new TH1D(
"H1[%]", NULL, 100, -TMax_ns, +TMax_ns));
122 JManager_t T1(
new TH1D(
"T1[%]", NULL, 100, 0.0, TMax_s[M.getLowerLimit()]));
131 JTreeScannerInterface<JDAQTimeslice>* ps = zmap[selector];
137 for (JMultipleFileScanner<>::const_iterator i = inputFile.begin(); i != inputFile.end(); ++i) {
139 STATUS(
"Processing " << *i << endl);
145 for ( ; ps->hasNext() && counter != inputFile.getLimit(); ++counter) {
147 STATUS(
"event: " << setw(10) << counter <<
'\r');
DEBUG(endl);
151 for (JDAQTimeslice::const_iterator frame = timeslice->begin(); frame != timeslice->end(); ++frame) {
153 JSuperFrame2D_t& buffer = JSuperFrame2D_t::demultiplex(*frame, router.getModule(frame->getModuleID()));
155 for (JSuperFrame2D_t::iterator i = buffer.begin(); i != buffer.end(); ++i) {
159 JSuperFrame1D_t& data = JSuperFrame1D_t::multiplex(buffer);
163 if (data.size() > 1) {
165 TH1D* h1 = H1[frame->getModuleID()];
166 TH1D* t1 = T1[frame->getModuleID()];
172 while (++q != data.end() && q->getT() - p->getT() <= TMax_ns ) {}
178 const int i = router.getIndex(frame->getModuleID());
179 const double ts =
getTimeOfRTS(frame->getFrameIndex()) + p->getT();
181 t1->Fill((ts - t0[i]) * 1.0e-9);
189 h1->Fill(JCombinatorics::getSign(__p->getPMT(),__q->getPMT()) * (__q->getT() - __p->getT()), 1.0/W);
204 const double V = (H1->GetXaxis()->GetXmax() - H1->GetXaxis()->GetXmin()) / (
double) H1->GetXaxis()->GetNbins();
207 for (JManager_t::iterator i = H1.begin(); i != H1.end(); ++i) {
208 i->second->Scale(1.0/(V*W));
211 for (JManager_t::iterator i = T1.begin(); i != T1.end(); ++i) {
212 i->second->Scale(1.0/i->second->GetMaximum());
216 if (summaryFile !=
"") {
218 const double V = (H1->GetXaxis()->GetXmax() - H1->GetXaxis()->GetXmin()) / (
double) H1->GetXaxis()->GetNbins();
222 const int PRECISION = (M.getLowerLimit() > 2 ? 4 : 3);
224 ofstream out(summaryFile.c_str());
226 out <<
"Multiplicity " << M << endl;
227 out <<
"-------------------------------------------------------" << endl;
228 out <<
" location | Gauss | S - B | Total | slope " << endl;
229 out <<
" | [Hz] | [Hz] | [Hz] | [Hz] " << endl;
230 out <<
"-------------------------------------------------------" << endl;
234 for (
int string = 1;
string <= number_of_strings; ++string) {
235 for (
int floor = number_of_floors; floor >= 1; --floor) {
237 const int id = detector.getModule(JModuleLocation(
string,floor)).getID();
239 out <<
" " << setw(3) <<
string <<
' ' << setw(2) << floor <<
" ";
241 TH1D* h1 = (H1.find(
id) != H1.end() ? H1[id] : NULL);
242 TH1D* t1 = (T1.find(
id) != T1.end() ? T1[id] : NULL);
246 TF1 f1(
"f1",
"[0]*exp(-0.5*(x-[1])*(x-[1])/([2]*[2]))/(TMath::Sqrt(2*TMath::Pi())*[2]) + [3]");
248 f1.SetParameter(0, h1->GetMaximum());
249 f1.SetParameter(1, 0.0);
250 f1.SetParameter(2, h1->GetRMS() * 0.25);
251 f1.SetParameter(3, h1->GetMinimum());
253 h1->Fit(&f1, option.c_str(),
"same");
255 out <<
" | " <<
FIXED(8,PRECISION) << f1.GetParameter(0);
256 out <<
" | " <<
FIXED(8,PRECISION) << (h1->GetSumOfWeights() - f1.GetParameter(3) * h1->GetNbinsX()) * V;
257 out <<
" | " <<
FIXED(8,PRECISION) << h1->GetSumOfWeights() * V;
259 Q[0].put( f1.GetParameter(0));
260 Q[1].put((h1->GetSumOfWeights() - f1.GetParameter(3) * h1->GetNbinsX()) * V);
261 Q[2].put( h1->GetSumOfWeights() * V);
266 TF1 f1(
"f1",
"[0]*exp(-[1]*x)");
268 f1.SetParameter(0, t1->GetMaximum());
269 f1.SetParameter(1, 1.0 / t1->GetRMS());
271 t1->Fit(&f1, option.c_str(),
"same");
273 out <<
" | " <<
FIXED(8,PRECISION) << f1.GetParameter(1);
275 Q[3].put(f1.GetParameter(1));
286 out <<
"-------------------------------------------------------" << endl;
287 out << setw(10) << left <<
" average";
289 for (
int i = 0; i !=
sizeof(Q)/
sizeof(Q[0]); ++i) {
290 out <<
" | " <<
FIXED(8,PRECISION) << Q[i].getMean();