Jpp - 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 "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 32 of file JDAQHitRouter.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  int debug;
43 
44  try {
45 
46  JParser<> zap("Example program to histogram string and floor hits.");
47 
48  zap['f'] = make_field(inputFile);
49  zap['o'] = make_field(outputFile) = "router.root";
50  zap['a'] = make_field(detectorFile);
51  zap['n'] = make_field(numberOfEvents) = JLimit::max();
52  zap['d'] = make_field(debug) = 2;
53 
54  zap(argc, argv);
55  }
56  catch(const exception& error) {
57  FATAL(error.what() << endl);
58  }
59 
60 
61 
62 
63  cout.tie(&cerr);
64 
65 
67 
68  try {
69  load(detectorFile, detector);
70  }
71  catch(const JException& error) {
72  FATAL(error);
73  }
74 
75  const JDAQHitRouter router(detector);
76  const JStringRouter string(detector);
77 
78 
79  TFile out(outputFile.c_str(), "recreate");
80 
81  TH1D h1("h1", NULL, 100, 0.0, 1.0e1);
82  TH2D h2("h2", NULL,
85 
86  for (Int_t i = 1; i <= h2.GetXaxis()->GetNbins(); ++i) {
87  h2.GetXaxis()->SetBinLabel(i, MAKE_CSTRING(string.at(i-1)));
88  }
89  for (Int_t i = 1; i <= h2.GetYaxis()->GetNbins(); ++i) {
90  h2.GetYaxis()->SetBinLabel(i, MAKE_CSTRING(i));
91  }
92 
93  TH2D* h3 = (TH2D*) h2.Clone("h3");
94 
95  while (inputFile.hasNext()) {
96 
97  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
98 
99  JDAQEvent* event = inputFile.next();
100 
101  JTimeRange tx = JTimeRange::DEFAULT_RANGE;
102 
103  {
104  typedef JDAQTriggeredHit JHit_t;
105 
106  for (JDAQEvent::const_iterator<JHit_t> hit = event->begin<JHit_t>(); hit != event->end<JHit_t>(); ++hit) {
107 
108  const JPMTChannel& channel = router.getPMTChannel(*hit);
109 
110  h2.Fill((double) string.getIndex(channel.getString()), (double) channel.getFloor());
111 
112  tx.include(getTime(*hit, router.getPMT(*hit)));
113  }
114  }
115 
116  h1.Fill(tx.getLength() * 1.0e-3);
117 
118  {
119  typedef JDAQSnapshotHit JHit_t;
120 
121  for (JDAQEvent::const_iterator<JHit_t> hit = event->begin<JHit_t>(); hit != event->end<JHit_t>(); ++hit) {
122 
123  const JPMTChannel& channel = router.getPMTChannel(*hit);
124 
125  h3->Fill((double) string.getIndex(channel.getString()), (double) channel.getFloor());
126  }
127  }
128  }
129  STATUS(endl);
130 
131  out.Write();
132  out.Close();
133 }
Auxiliary class to set-up Hit.
Definition: JHit_t.hh:25
Utility class to parse command line options.
Definition: JParser.hh:1500
General exception.
Definition: JException.hh:23
DAQ key hit.
Definition: JDAQKeyHit.hh:19
Auxiliary class to uniquely identify PMT readout channel.
Definition: JPMTChannel.hh:28
range_type include(argument_type x)
Include given value to range.
Definition: JRange.hh:398
int getFloor() const
Get floor number.
Definition: JLocation.hh:145
#define STATUS(A)
Definition: JMessage.hh:63
Detector data structure.
Definition: JDetector.hh:80
Template const_iterator.
Definition: JDAQEvent.hh:68
#define MAKE_CSTRING(A)
Make C-string.
Definition: JPrint.hh:151
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:69
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:196
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
int getNumberOfFloors(const JDetector &detector)
Get number of floors.
int getIndex()
Get index for user I/O manipulation.
Definition: JManip.hh:26
int debug
debug level
Definition: JSirene.cc:63
static const JStringCounter getNumberOfStrings
Function object to count unique strings.
#define FATAL(A)
Definition: JMessage.hh:67
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.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
do set_variable DETECTOR_TXT $WORKDIR detector
JTriggerCounter_t next()
Increment trigger counter.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62