56 using namespace KM3NETDAQ;
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);
119 JManager_t H1(
new TH1D(
"H1[%]", NULL, 100, -TMax_ns, +TMax_ns));
120 JManager_t T1(
new TH1D(
"T1[%]", NULL, 100, 0.0, TMax_s[M.getLowerLimit()]));
137 STATUS(
"Processing " << *
i << endl);
143 for ( ; ps->hasNext() && counter != inputFile.getLimit(); ++counter) {
145 STATUS(
"event: " << setw(10) << counter <<
'\r');
DEBUG(endl);
149 for (JDAQTimeslice::const_iterator frame = timeslice->begin(); frame != timeslice->end(); ++frame) {
151 JSuperFrame2D_t& buffer = JSuperFrame2D_t::demultiplex(*frame, router.getModule(frame->getModuleID()));
153 for (JSuperFrame2D_t::iterator
i = buffer.begin();
i != buffer.end(); ++
i) {
157 JSuperFrame1D_t&
data = JSuperFrame1D_t::multiplex(buffer);
159 if (data.size() > 1) {
161 TH1D* h1 = H1[frame->getModuleID()];
162 TH1D* t1 = T1[frame->getModuleID()];
168 while (++q != data.end() && q->getT() - p->getT() <= TMax_ns ) {}
174 const int i = router.getIndex(frame->getModuleID());
175 const double ts =
getTimeOfRTS(frame->getFrameIndex()) + p->getT();
177 t1->Fill((ts - t0[i]) * 1.0e-9);
185 h1->Fill(JCombinatorics::getSign(__p->getPMT(),__q->getPMT()) * (__q->getT() - __p->getT()), 1.0/W);
200 const double V = (H1->GetXaxis()->GetXmax() - H1->GetXaxis()->GetXmin()) / (
double) H1->GetXaxis()->GetNbins();
203 for (JManager_t::iterator i = H1.begin(); i != H1.end(); ++
i) {
204 i->second->Scale(1.0/(V*W));
207 for (JManager_t::iterator i = T1.begin(); i != T1.end(); ++
i) {
208 i->second->Scale(1.0/i->second->GetMaximum());
212 if (summaryFile !=
"") {
214 const double V = (H1->GetXaxis()->GetXmax() - H1->GetXaxis()->GetXmin()) / (
double) H1->GetXaxis()->GetNbins();
218 const int PRECISION = (M.getLowerLimit() > 2 ? 4 : 3);
220 ofstream out(summaryFile.c_str());
222 out <<
"Multiplicity " << M << endl;
223 out <<
"-------------------------------------------------------" << endl;
224 out <<
" location | Gauss | S - B | Total | slope " << endl;
225 out <<
" | [Hz] | [Hz] | [Hz] | [Hz] " << endl;
226 out <<
"-------------------------------------------------------" << endl;
230 for (
int string = 1;
string <= number_of_strings; ++
string) {
231 for (
int floor = number_of_floors; floor >= 1; --floor) {
235 out <<
" " << setw(3) <<
string <<
' ' << setw(2) << floor <<
" ";
237 TH1D* h1 = (H1.find(
id) != H1.end() ? H1[id] : NULL);
238 TH1D* t1 = (T1.find(
id) != T1.end() ? T1[id] : NULL);
242 TF1
f1(
"f1",
"[0]*exp(-0.5*(x-[1])*(x-[1])/([2]*[2]))/(TMath::Sqrt(2*TMath::Pi())*[2]) + [3]");
244 f1.SetParameter(0, h1->GetMaximum());
245 f1.SetParameter(1, 0.0);
246 f1.SetParameter(2, h1->GetRMS() * 0.25);
247 f1.SetParameter(3, h1->GetMinimum());
249 h1->Fit(&
f1, option.c_str(),
"same");
251 out <<
" | " <<
FIXED(8,PRECISION) <<
f1.GetParameter(0);
252 out <<
" | " <<
FIXED(8,PRECISION) << (h1->GetSumOfWeights() -
f1.GetParameter(3) * h1->GetNbinsX()) * V;
253 out <<
" | " <<
FIXED(8,PRECISION) << h1->GetSumOfWeights() *
V;
255 Q[0].
put(
f1.GetParameter(0));
256 Q[1].
put((h1->GetSumOfWeights() -
f1.GetParameter(3) * h1->GetNbinsX()) * V);
257 Q[2].
put( h1->GetSumOfWeights() *
V);
262 TF1
f1(
"f1",
"[0]*exp(-[1]*x)");
264 f1.SetParameter(0, t1->GetMaximum());
265 f1.SetParameter(1, 1.0 / t1->GetRMS());
267 t1->Fit(&
f1, option.c_str(),
"same");
269 out <<
" | " <<
FIXED(8,PRECISION) <<
f1.GetParameter(1);
271 Q[3].
put(
f1.GetParameter(1));
282 out <<
"-------------------------------------------------------" << endl;
283 out << setw(10) << left <<
" average";
285 for (
int i = 0; i !=
sizeof(
Q)/
sizeof(Q[0]); ++
i) {
Utility class to parse command line options.
Q(UTCMax_s-UTCMin_s)-livetime_s
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Auxiliary class to select ROOT class based on class name.
Router for direct addressing of module data in detector data structure.
Auxiliary interface for direct access of elements in ROOT TChain.
Long64_t counter_type
Type definition for counter.
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.
V(JDAQEvent-JTriggerReprocessor)*1.0/(JDAQEvent+1.0e-10)
Template definition for direct access of elements in ROOT TChain.
long long int factorial(const long long int n)
Determine factorial.
1-dimensional frame with time calibrated data from one optical module.
const JPolynome f1(1.0, 2.0, 3.0)
Function.
Auxiliary class for defining the range of iterations of objects.
Type definition of range.
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys...
Logical location of module.
#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.
static const JStringCounter getNumberOfStrings
Function object to count unique strings.
Auxiliary class to select JTreeScanner based on ROOT class name.
Auxiliary data structure for average.
then usage $script< input file >[option[primary[working directory]]] nWhere option can be N
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
void put(const double x)
Put value.
int getCount(const T &hit)
Get hit count.
2-dimensional frame with time calibrated data from one optical module.
const JLimit & getLimit() const
Get limit.
long double getMean() const
Get mean value.
do set_variable DETECTOR_TXT $WORKDIR detector
#define DEBUG(A)
Message macros.