Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JDAQHitRouter.cc File Reference

Example program to histogram string and floor hits. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "TH2D.h"
#include "JTools/JRange.hh"
#include "JDAQ/JDAQEvent.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

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 
37  JMultipleFileScanner<JDAQEvent> inputFile;
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 
65  JDetector detector;
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 }
Utility class to parse command line options.
Definition: JParser.hh:1410
#define STATUS(A)
Definition: JMessage.hh:61
Template const_iterator.
Definition: JDAQEvent.hh:69
Structure to store the ToT mean and standard deviation of the hits produced by a nanobeacon in a sour...
double getTime(const Hit &hit)
Get true time of hit.
string outputFile
JRange< double > JTimeRange
Type definition for time range.
JLimit JLimit_t
Type definition of limit.
Definition: JLimit.hh:214
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1836
#define NOTICE(A)
Definition: JMessage.hh:62
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
int debug
debug level
Definition: JSirene.cc:59
#define FATAL(A)
Definition: JMessage.hh:65
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:72
JTriggerCounter_t next()
Increment trigger counter.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:60