108 using namespace MONITORL1DT;
114 Double_t Timewindow_ns;
117 unsigned int multiplicity;
123 JParser<> zap(
"Program to create L1 hit time difference histograms from raw data.");
125 zap[
'f'] =
make_field(inputFile,
"input file");
127 zap[
'a'] =
make_field(detectorFile,
"detector file");
128 zap[
't'] =
make_field(TmaxL1_ns,
"max time between L1 hits [ns]") = 1000.0;
129 zap[
'T'] =
make_field(Timewindow_ns,
"time window around t=0 [ns]") = 2400.0;
130 zap[
'C'] =
make_field(selector,
"datastream selector") = getROOTClassSelection<JDAQTimesliceTypes_t>();
131 zap[
'm'] =
make_field(multiplicity,
"minimal multiplicity of the L1 hits") = 2;
132 zap[
'L'] =
make_field(livetime_s,
"livetime of the data, set to positive value") = -1.0;
135 if (zap.read(argc, argv) != 0)
138 catch(
const exception &error) {
139 FATAL(error.what() << endl);
154 FATAL(
"Empty detector." << endl);
161 const double ctMin = -1;
167 const double xmin = -0.5;
168 const double xmax = nx - 0.5;
170 const double ymin = -floor(Timewindow_ns) + 0.5;
171 const double ymax = +floor(Timewindow_ns) + 0.5;
172 const int ny = (int) ((ymax - ymin) / 1.0);
174 NOTICE(
"Running JMonitorL1dt: Monitoring L1 time differences MonitorL1dt creating histograms.");
175 for (JDetector::iterator module =
detector.begin(); module !=
detector.end(); ++module) {
177 const JModuleAddress& address = router.getAddress(module->getID());
179 STATUS(
"Booking histograms for module " << module->getID() << endl);
181 const JString title(module->getID());
184 titleString1D = title +
".1L";
185 titleString2D = title +
".2S";
187 zmap[address.
first] =
JHistogram(
new TH2D((titleString2D).c_str(), NULL, nx, xmin, xmax, ny, ymin, ymax),
188 new TH1D((titleString1D).c_str(), NULL, nx, xmin, xmax));
190 for (JDetector::iterator mod =
detector.begin(); mod !=
detector.end(); ++mod) {
191 zmap[address.
first].h2s->GetXaxis()->SetBinLabel(
distance(
detector.begin(), mod)+1, Form(
"%i", mod->getID()));
192 zmap[address.
first].h1l->GetXaxis()->SetBinLabel(
distance(
detector.begin(), mod)+1, Form(
"%i", mod->getID()));
203 for ( ;
in.hasNext() && counter != inputFile.getLimit(); ++counter) {
205 STATUS(
"event: " << setw(10) << counter <<
'\r');
DEBUG(endl);
213 for (JDAQTimeslice::const_iterator super_frame = timeslice->begin(); super_frame != timeslice->end(); ++super_frame) {
214 if (router.hasModule(super_frame->getModuleID()) && !super_frame->empty()) {
216 const JModuleAddress& address = router.getAddress(super_frame->getModuleID());
221 buildL2(*super_frame, module, back_inserter(frameL1));
223 for (JFrameL1_t::iterator L1hit = frameL1.begin(); L1hit != frameL1.end(); ++L1hit) {
224 buffer.push_back(
JElement(address.
first, L1hit->begin()->getT()));
233 for (
unsigned int i = 0; i <
detector.size(); ++i) {
239 sort(buffer.begin(), buffer.end());
244 while (++q != buffer.end() && q->t - p->t <= Timewindow_ns ) {
247 zmap[p->id].h2s->Fill(q->id, q->t - p->t);
248 zmap[q->id].h2s->Fill(p->id, p->t - q->t);
257 if (livetime_s > 0.0) {
260 for (
int ibin = 1; ibin <= hl->GetNbinsX(); ++ibin) {
261 hl->SetBinContent(ibin, livetime_s);
262 hl->SetBinError(ibin, 0.0000001);
Utility class to parse command line options.
Wrapper class around STL string class.
Data structure for a composite optical module.
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.
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
then for HISTOGRAM in h0 h1
Auxiliary class for multiplexing object iterators.
int first
index of module in detector data structure
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Data structure for hit time and DOM identifier.
double getFrameTime()
Get frame time duration.
Address of module in detector data structure.
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
Data structure for L2 parameters.
General purpose class for object reading from a list of file names.
#define DEBUG(A)
Message macros.