Jpp  18.1.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JMermaid.cc File Reference

Example program to monitor event duration. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "JTools/JRange.hh"
#include "JROOT/JRootToolkit.hh"
#include "JDAQ/JDAQEventIO.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JDAQHitRouter.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JSupport.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program to monitor event duration.

Author
mdejong

Definition in file JMermaid.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 32 of file JMermaid.cc.

33 {
34  using namespace std;
35  using namespace JPP;
36  using namespace KM3NETDAQ;
37 
39  JLimit_t& numberOfEvents = inputFile.getLimit();
40  string outputFile;
41  string detectorFile;
42  double T_ns;
43  int qaqc;
44  int debug;
45 
46  try {
47 
48  JParser<> zap("Example program to monitor event duration.");
49 
50  zap['f'] = make_field(inputFile);
51  zap['o'] = make_field(outputFile) = "mermaid.root";
52  zap['a'] = make_field(detectorFile);
53  zap['n'] = make_field(numberOfEvents) = JLimit::max();
54  zap['T'] = make_field(T_ns, "Time limit for event duration [ns]") = 10.0e3;
55  zap['Q'] = make_field(qaqc) = 0;
56  zap['d'] = make_field(debug) = 2;
57 
58  zap(argc, argv);
59  }
60  catch(const exception& error) {
61  FATAL(error.what() << endl);
62  }
63 
64 
66 
67  try {
68  load(detectorFile, detector);
69  }
70  catch(const JException& error) {
71  FATAL(error);
72  }
73 
74  const JDAQHitRouter router(detector);
75 
76  TH1D h1("h1", NULL, 100, 0.0, 10.0e3);
77 
78  size_t N = 0;
79 
80  while (inputFile.hasNext()) {
81 
82  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
83 
84  JDAQEvent* event = inputFile.next();
85 
86  JTimeRange tx = JTimeRange::DEFAULT_RANGE();
87 
88  for (JDAQEvent::const_iterator<JDAQTriggeredHit> hit = event->begin<JDAQTriggeredHit>(); hit != event->end<JDAQTriggeredHit>(); ++hit) {
89  tx.include(getTime(*hit, router.getPMT(*hit)));
90  }
91 
92  h1.Fill(tx.getLength());
93 
94  if (tx.getLength() >= T_ns) {
95  N += 1;
96  }
97  }
98  STATUS(endl);
99 
100  TFile out(outputFile.c_str(), "recreate");
101 
102  out << h1;
103 
104  out.Write();
105  out.Close();
106 
107  NOTICE("Number of event with duration beyond " << FIXED(9,0) << T_ns << " [ns] " << N << endl);
108 
109  QAQC(N << endl);
110 
111  return 0;
112 }
Utility class to parse command line options.
Definition: JParser.hh:1514
General exception.
Definition: JException.hh:24
range_type & include(argument_type x)
Include given value to range.
Definition: JRange.hh:397
#define STATUS(A)
Definition: JMessage.hh:63
Detector data structure.
Definition: JDetector.hh:89
Template const_iterator.
Definition: JDAQEvent.hh:68
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
double getTime(const Hit &hit)
Get true time of hit.
string outputFile
Simple wrapper around JModuleRouter class for direct addressing of PMT data in detector data structur...
T getLength() const
Get length (difference between upper and lower limit).
Definition: JRange.hh:289
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
Detector file.
Definition: JHead.hh:226
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
#define NOTICE(A)
Definition: JMessage.hh:64
#define FATAL(A)
Definition: JMessage.hh:67
then usage $script< input file >[option[primary[working directory]]] nWhere option can be N
Definition: JMuonPostfit.sh:40
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.
#define QAQC(A)
QA/QC output macro.
Definition: JMessage.hh:100
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:84
do set_variable DETECTOR_TXT $WORKDIR detector
int qaqc
QA/QC file descriptor.
int debug
debug level
JTriggerCounter_t next()
Increment trigger counter.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62