119 using namespace MONITORL1DT;
125 double Timewindow_ns;
129 unsigned int multiplicity;
136 JParser<> zap(
"Program to create L1 hit time difference histograms from raw data.");
138 zap[
'f'] =
make_field(inputFile,
"input file");
140 zap[
'a'] =
make_field(detectorFile,
"detector file");
141 zap[
't'] =
make_field(TmaxL1_ns,
"max time between L1 hits [ns]") = 1000.0;
142 zap[
'T'] =
make_field(Timewindow_ns,
"time window around t=0 [ns]") = 2400.0;
143 zap[
'w'] =
make_field(binwidth,
"binwidth [ns]") = 1;
144 zap[
'C'] =
make_field(selector,
"datastream selector") = getROOTClassSelection<JDAQTimesliceTypes_t>();
145 zap[
'm'] =
make_field(multiplicity,
"minimal multiplicity of the L1 hits") = 2;
146 zap[
'c'] =
make_field(correct_time,
"subtract expected arrival time from delta-t");
147 zap[
'L'] =
make_field(livetime_s,
"livetime of the data, set to positive value") = -1.0;
150 if (zap.read(argc, argv) != 0)
153 catch(
const exception &error) {
154 FATAL(error.what() << endl);
169 FATAL(
"Empty detector." << endl);
176 const double ctMin = -1;
183 const double xmin = -0.5;
184 const double xmax = nx - 0.5;
186 const double ymin = -floor(Timewindow_ns) + 0.5;
187 const double ymax = +floor(Timewindow_ns) + 0.5;
188 const int ny = (int) ((ymax - ymin) / binwidth);
193 Int_t npairs = c.getNumberOfPairs();
197 manager =
new JManager <int, TH2D>(
new TH2D(
"h%",
"", npairs, 0.5, npairs+0.5, ny, ymin, ymax));
199 NOTICE(
"Running JMonitorL1dt: Monitoring L1 time differences and creating histograms." << endl);
200 for (JDetector::iterator module =
detector.begin(); module !=
detector.end(); ++module) {
202 const JModuleAddress& address = router.getAddress(module->getID());
204 STATUS(
"Booking histograms for module " << module->getID() << endl);
206 const JString title(module->getID());
209 titleString1D = title +
".1L";
210 titleString2D = title +
".2S";
212 zmap[address.
first] =
JHistogram(
new TH2D((titleString2D).c_str(), NULL, nx, xmin, xmax, ny, ymin, ymax),
213 new TH1D((titleString1D).c_str(), NULL, nx, xmin, xmax));
215 for (JDetector::iterator mod =
detector.begin(); mod !=
detector.end(); ++mod) {
216 zmap[address.
first].h2s->GetXaxis()->SetBinLabel(
distance(
detector.begin(), mod)+1, Form(
"%i", mod->getID()));
217 zmap[address.
first].h1l->GetXaxis()->SetBinLabel(
distance(
detector.begin(), mod)+1, Form(
"%i", mod->getID()));
228 for ( ;
in.hasNext() && counter != inputFile.getLimit(); ++counter) {
230 STATUS(
"event: " << setw(10) << counter <<
'\r');
DEBUG(endl);
238 for (JDAQTimeslice::const_iterator super_frame = timeslice->begin(); super_frame != timeslice->end(); ++super_frame) {
239 if (router.hasModule(super_frame->getModuleID()) && !super_frame->empty()) {
241 const JModuleAddress& address = router.getAddress(super_frame->getModuleID());
246 buildL2(*super_frame, module, back_inserter(frameL1));
248 for (JFrameL1_t::iterator L1hit = frameL1.begin(); L1hit != frameL1.end(); ++L1hit) {
249 buffer.push_back(
JElement(address.
first, L1hit->begin()->getT()));
258 for (
unsigned int i = 0; i <
detector.size(); ++i) {
264 sort(buffer.begin(), buffer.end());
271 while (++q != buffer.end() && q->t - p->t <= Timewindow_ns ) {
277 double time_correction = (correct_time ? (dom_distance /
getSpeedOfLight()) : 0);
279 zmap[p->id].h2s->Fill(q->id, q->t - p->t - time_correction);
280 zmap[q->id].h2s->Fill(p->id, p->t - q->t + time_correction);
284 int xbin = c.getIndex(module_p.
getFloor() - 1, module_q.
getFloor() - 1) + 1;
285 (*manager)[module_p.
getString()]->Fill(xbin, q->t - p->t - time_correction);
295 if (livetime_s > 0.0) {
298 for (
int ibin = 1; ibin <= hl->GetNbinsX(); ++ibin) {
299 hl->SetBinContent(ibin, livetime_s);
300 hl->SetBinError(ibin, 0.0000001);
Utility class to parse command line options.
Wrapper class around STL string class.
int getFloor() const
Get floor number.
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.
then for HISTOGRAM in h0 h1
Auxiliary class for multiplexing object iterators.
double getDistance(const JFirst_t &first, const JSecond_t &second)
Get distance between objects.
int first
index of module in detector data structure
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys...
#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.
int getNumberOfFloors(const JDetector &detector)
Get number of floors.
Address of module in detector data structure.
const JPosition3D & getPosition() const
Get position.
Data structure for L2 parameters.
int getString() const
Get string number.
const double getSpeedOfLight()
Get speed of light.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
General purpose class for object reading from a list of file names.
bool comparepair(const pair_type &A, const pair_type &B)
do set_variable DETECTOR_TXT $WORKDIR detector
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
#define DEBUG(A)
Message macros.