Jpp
Functions
JDAQHitRouter.cc File Reference
#include <string>
#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "TH2D.h"
#include "JTools/JRange.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 histogram string and floor hits.

Author
mdejong

Definition in file JDAQHitRouter.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 31 of file JDAQHitRouter.cc.

32 {
33  using namespace std;
34  using namespace JPP;
35  using namespace KM3NETDAQ;
36 
38  JLimit_t& numberOfEvents = inputFile.getLimit();
39  string outputFile;
40  string detectorFile;
41  int debug;
42 
43  try {
44 
45  JParser<> zap("Example program to histogram string and floor hits.");
46 
47  zap['f'] = make_field(inputFile);
48  zap['o'] = make_field(outputFile) = "router.root";
49  zap['a'] = make_field(detectorFile);
50  zap['n'] = make_field(numberOfEvents) = JLimit::max();
51  zap['d'] = make_field(debug) = 2;
52 
53  zap(argc, argv);
54  }
55  catch(const exception& error) {
56  FATAL(error.what() << endl);
57  }
58 
59 
60 
61 
62  cout.tie(&cerr);
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 
77  typedef JTOOLS::JRange<int> JRange_t;
78 
79  const JRange_t string(detector.begin(), detector.end(), &JModule::getString);
80  const JRange_t floor (detector.begin(), detector.end(), &JModule::getFloor);
81 
82  NOTICE("String " << string.getLowerLimit() << " - " << string.getUpperLimit() << endl);
83  NOTICE("Floor " << floor .getLowerLimit() << " - " << floor .getUpperLimit() << endl);
84 
85 
86  TFile out(outputFile.c_str(), "recreate");
87 
88  TH1D h1("h1", NULL, 100, 0.0, 1.0e1);
89  TH2D h2("h2", NULL,
90  string.getLength() + 1,
91  string.getLowerLimit() - 0.5,
92  string.getUpperLimit() + 0.5,
93  floor.getLength() + 1,
94  floor.getLowerLimit() - 0.5,
95  floor.getUpperLimit() + 0.5);
96 
97 
98  while (inputFile.hasNext()) {
99 
100  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
101 
102  JDAQEvent* event = inputFile.next();
103 
104  JTimeRange tx = JTimeRange::DEFAULT_RANGE;
105 
106  typedef JDAQTriggeredHit JHit_t;
107 
108  for (JDAQEvent::const_iterator<JHit_t> hit = event->begin<JHit_t>(); hit != event->end<JHit_t>(); ++hit) {
109 
110  const JPMTChannel& channel = router.getPMTChannel(*hit);
111 
112  h2.Fill((double) channel.getString(), (double) channel.getFloor());
113 
114  tx.include(getTime(*hit, router.getPMT(*hit)));
115  }
116 
117  h1.Fill(tx.getLength() * 1.0e-3);
118  }
119  STATUS(endl);
120 
121  out.Write();
122  out.Close();
123 }
JDETECTOR::JPMTChannel
Auxiliary class to uniquely identify PMT readout channel.
Definition: JPMTChannel.hh:28
KM3NETDAQ::JDAQEvent
DAQ Event.
Definition: JDAQEvent.hh:30
JAANET::JHit_t
Auxiliary class to set-up Hit.
Definition: JHit_t.hh:25
JTOOLS::JRange::include
range_type include(argument_type x)
Include given value to range.
Definition: JRange.hh:388
JSUPPORT::JLimit
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
JDETECTOR::load
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
Definition: JDetectorToolkit.hh:476
JTOOLS::JRange::getLength
T getLength() const
Get length (difference between upper and lower limit).
Definition: JRange.hh:302
JTOOLS::JRange< int >
JPARSER::JParser
Utility class to parse command line options.
Definition: JParser.hh:1493
NOTICE
#define NOTICE(A)
Definition: JMessage.hh:64
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
KM3NETDAQ::JDAQTriggeredHit
DAQ triggered hit.
Definition: JDAQTriggeredHit.hh:20
JSUPPORT::JMultipleFileScanner::getCounter
counter_type getCounter() const
Get counter.
Definition: JMultipleFileScanner.hh:323
debug
int debug
debug level
Definition: JSirene.cc:59
JSUPPORT::JMultipleFileScanner::next
virtual const pointer_type & next()
Get next element.
Definition: JMultipleFileScanner.hh:398
KM3NETDAQ::JDAQEvent::const_iterator
Template const_iterator.
Definition: JDAQEvent.hh:68
JAANET::getTime
double getTime(const Hit &hit)
Get true time of hit.
Definition: JAAnetToolkit.hh:87
STATUS
#define STATUS(A)
Definition: JMessage.hh:63
JSUPPORT::JMultipleFileScanner::hasNext
virtual bool hasNext()
Check availability of next element.
Definition: JMultipleFileScanner.hh:350
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
JSUPPORT::JMultipleFileScanner
General purpose class for object reading from a list of file names.
Definition: JMultipleFileScanner.hh:167
JDETECTOR::JDetector
Detector data structure.
Definition: JDetector.hh:80
JAANET::detector
Detector file.
Definition: JHead.hh:130
DEBUG
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
std
Definition: jaanetDictionary.h:36
KM3NETDAQ
KM3NeT DAQ data structures and auxiliaries.
Definition: DataQueue.cc:39
JDETECTOR::JModuleLocation::getFloor
int getFloor() const
Get floor number.
Definition: JModuleLocation.hh:144
FATAL
#define FATAL(A)
Definition: JMessage.hh:67
outputFile
string outputFile
Definition: JDAQTimesliceSelector.cc:37
JLANG::JException
General exception.
Definition: JException.hh:23
JDETECTOR::JModuleLocation::getString
int getString() const
Get string number.
Definition: JModuleLocation.hh:133
JDETECTOR::JDAQHitRouter
Simple wrapper around JModuleRouter class for direct addressing of PMT data in detector data structur...
Definition: JDAQHitRouter.hh:24