Jpp  17.2.1-pre0
the software that should make you happy
 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 "JROOT/JManager.hh"
#include "JROOT/JRootToolkit.hh"
#include "JDAQ/JDAQEventIO.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JDAQHitRouter.hh"
#include "JDetector/JStringRouter.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 35 of file JDAQHitRouter.cc.

36 {
37  using namespace std;
38  using namespace JPP;
39  using namespace KM3NETDAQ;
40 
42  JLimit_t& numberOfEvents = inputFile.getLimit();
43  string outputFile;
44  string detectorFile;
45  int debug;
46 
47  try {
48 
49  JParser<> zap("Example program to histogram string and floor hits.");
50 
51  zap['f'] = make_field(inputFile);
52  zap['o'] = make_field(outputFile) = "router.root";
53  zap['a'] = make_field(detectorFile);
54  zap['n'] = make_field(numberOfEvents) = JLimit::max();
55  zap['d'] = make_field(debug) = 2;
56 
57  zap(argc, argv);
58  }
59  catch(const exception& error) {
60  FATAL(error.what() << endl);
61  }
62 
63 
64 
65 
66  cout.tie(&cerr);
67 
68 
70 
71  try {
72  load(detectorFile, detector);
73  }
74  catch(const JException& error) {
75  FATAL(error);
76  }
77 
79 
80  const JDAQHitRouter router(detector);
82 
83 
84  TH1D h1("h1", NULL, 100, 0.0, 1.0e1);
85 
86  JManager<int, TH2D> H2(new TH2D("h2[%]", NULL,
88  range.getUpperLimit(), 1 - 0.5, range.getUpperLimit() + 0.5));
89 
90  for (Int_t i = 1; i <= H2->GetXaxis()->GetNbins(); ++i) {
91  H2->GetXaxis()->SetBinLabel(i, MAKE_CSTRING(string.at(i-1)));
92  }
93  for (Int_t i = 1; i <= H2->GetYaxis()->GetNbins(); ++i) {
94  H2->GetYaxis()->SetBinLabel(i, MAKE_CSTRING(i));
95  }
96 
97  TH2D* h3 = (TH2D*) H2->Clone("h3");
98 
99  while (inputFile.hasNext()) {
100 
101  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
102 
103  JDAQEvent* event = inputFile.next();
104 
105  JTimeRange tx = JTimeRange::DEFAULT_RANGE;
106 
107  {
108  typedef JDAQTriggeredHit JHit_t;
109 
110  for (JDAQEvent::const_iterator<JHit_t> hit = event->begin<JHit_t>(); hit != event->end<JHit_t>(); ++hit) {
111 
112  const JPMTChannel& channel = router.getPMTChannel(*hit);
113 
114  H2->Fill((double) string.getIndex(channel.getString()), (double) channel.getFloor());
115 
116  for (int i = 0; i != NUMBER_OF_TRIGGER_BITS; ++i) {
117  if (hit->hasTriggerBit(i)) {
118  H2[i]->Fill((double) string.getIndex(channel.getString()), (double) channel.getFloor());
119  }
120  }
121 
122  tx.include(getTime(*hit, router.getPMT(*hit)));
123  }
124  }
125 
126  h1.Fill(tx.getLength() * 1.0e-3);
127 
128  {
129  typedef JDAQSnapshotHit JHit_t;
130 
131  for (JDAQEvent::const_iterator<JHit_t> hit = event->begin<JHit_t>(); hit != event->end<JHit_t>(); ++hit) {
132 
133  const JPMTChannel& channel = router.getPMTChannel(*hit);
134 
135  h3->Fill((double) string.getIndex(channel.getString()), (double) channel.getFloor());
136  }
137  }
138  }
139  STATUS(endl);
140 
141  TFile out(outputFile.c_str(), "recreate");
142 
143  out << h1;
144  out << *H2;
145  out << H2;
146  out << *h3;
147 
148  out.Write();
149  out.Close();
150 }
Utility class to parse command line options.
Definition: JParser.hh:1517
General exception.
Definition: JException.hh:23
DAQ key hit.
Definition: JDAQKeyHit.hh:19
Auxiliary class to uniquely identify PMT readout channel.
Definition: JPMTChannel.hh:30
static const unsigned int NUMBER_OF_TRIGGER_BITS
Number of trigger bits.
int getFloor() const
Get floor number.
Definition: JLocation.hh:145
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
#define MAKE_CSTRING(A)
Make C-string.
Definition: JPrint.hh:136
double getTime(const Hit &hit)
Get true time of hit.
string outputFile
floor_range getRangeOfFloors(const JDetector &detector)
Get range of floors.
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
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys...
Definition: JManager.hh:43
Detector file.
Definition: JHead.hh:226
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1993
then awk string
int getIndex()
Get index for user I/O manipulation.
Definition: JManip.hh:26
static const JStringCounter getNumberOfStrings
Function object to count unique strings.
#define FATAL(A)
Definition: JMessage.hh:67
z range($ZMAX-$ZMIN)< $MINIMAL_DZ." fi fi typeset -Z 4 STRING typeset -Z 2 FLOOR JPlot1D -f $
int getString() const
Get string number.
Definition: JLocation.hh:134
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
Router for mapping of string identifier to index.
General purpose class for object reading from a list of file names.
Auxiliary class to set-up Hit.
Definition: JSirene.hh:55
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
do set_variable DETECTOR_TXT $WORKDIR detector
int debug
debug level
JTriggerCounter_t next()
Increment trigger counter.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62