Jpp  18.0.0-rc.2
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 
65 
66  try {
67  load(detectorFile, detector);
68  }
69  catch(const JException& error) {
70  FATAL(error);
71  }
72 
74 
75  const JDAQHitRouter router(detector);
77 
78 
79  TH1D h1("h1", NULL, 100, 0.0, 1.0e1);
80 
81  JManager<int, TH2D> H2(new TH2D("h2[%]", NULL,
83  range.getUpperLimit(), 1 - 0.5, range.getUpperLimit() + 0.5));
84 
85  for (Int_t i = 1; i <= H2->GetXaxis()->GetNbins(); ++i) {
86  H2->GetXaxis()->SetBinLabel(i, MAKE_CSTRING(string.at(i-1)));
87  }
88  for (Int_t i = 1; i <= H2->GetYaxis()->GetNbins(); ++i) {
89  H2->GetYaxis()->SetBinLabel(i, MAKE_CSTRING(i));
90  }
91 
92  TH2D* h3 = (TH2D*) H2->Clone("h3");
93 
94  while (inputFile.hasNext()) {
95 
96  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
97 
98  JDAQEvent* event = inputFile.next();
99 
100  JTimeRange tx = JTimeRange::DEFAULT_RANGE();
101 
102  {
103  typedef JDAQTriggeredHit JHit_t;
104 
105  for (JDAQEvent::const_iterator<JHit_t> hit = event->begin<JHit_t>(); hit != event->end<JHit_t>(); ++hit) {
106 
107  const JPMTChannel& channel = router.getPMTChannel(*hit);
108 
109  H2->Fill((double) string.getIndex(channel.getString()), (double) channel.getFloor());
110 
111  for (int i = 0; i != NUMBER_OF_TRIGGER_BITS; ++i) {
112  if (hit->hasTriggerBit(i)) {
113  H2[i]->Fill((double) string.getIndex(channel.getString()), (double) channel.getFloor());
114  }
115  }
116 
117  tx.include(getTime(*hit, router.getPMT(*hit)));
118  }
119  }
120 
121  h1.Fill(tx.getLength() * 1.0e-3);
122 
123  {
124  typedef JDAQSnapshotHit JHit_t;
125 
126  for (JDAQEvent::const_iterator<JHit_t> hit = event->begin<JHit_t>(); hit != event->end<JHit_t>(); ++hit) {
127 
128  const JPMTChannel& channel = router.getPMTChannel(*hit);
129 
130  h3->Fill((double) string.getIndex(channel.getString()), (double) channel.getFloor());
131  }
132  }
133  }
134  STATUS(endl);
135 
136  TFile out(outputFile.c_str(), "recreate");
137 
138  out << h1;
139  out << *H2;
140  out << H2;
141  out << *h3;
142 
143  out.Write();
144  out.Close();
145 }
Utility class to parse command line options.
Definition: JParser.hh:1514
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:1989
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:57
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:84
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