Jpp  18.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
examples/JTrigger/JChecksum.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 "JROOT/JROOTClassSelector.hh"
#include "JDAQ/JDAQTimesliceIO.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JModuleRouter.hh"
#include "JDetector/JStringRouter.hh"
#include "JLang/JObjectMultiplexer.hh"
#include "JTrigger/JChecksum.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 examples/JTrigger/JChecksum.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 40 of file examples/JTrigger/JChecksum.cc.

41 {
42  using namespace std;
43  using namespace JPP;
44  using namespace KM3NETDAQ;
45 
47  JLimit_t& numberOfEvents = inputFile.getLimit();
48  string outputFile;
49  string detectorFile;
50  JROOTClassSelector selector;
51  int debug;
52 
53  try {
54 
55  JParser<> zap("Example program to histogram string and floor hits.");
56 
57  zap['f'] = make_field(inputFile);
58  zap['o'] = make_field(outputFile) = "checksum.root";
59  zap['a'] = make_field(detectorFile);
60  zap['n'] = make_field(numberOfEvents) = JLimit::max();
61  zap['C'] = make_field(selector) = getROOTClassSelection<JDAQTimesliceTypes_t>();
62  zap['d'] = make_field(debug) = 2;
63 
64  zap(argc, argv);
65  }
66  catch(const exception& error) {
67  FATAL(error.what() << endl);
68  }
69 
70 
72 
73  try {
74  load(detectorFile, detector);
75  }
76  catch(const JException& error) {
77  FATAL(error);
78  }
79 
81 
82  const JModuleRouter router(detector);
84 
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 
99 
100  for (counter_type counter = 0; in.hasNext() && counter != inputFile.getLimit(); ++counter) {
101 
102  STATUS("event: " << setw(10) << counter << '\r'); DEBUG(endl);
103 
104  const JDAQTimeslice* timeslice = in.next();
105 
106  for (JDAQTimeslice::const_iterator frame = timeslice->begin(); frame != timeslice->end(); ++frame) {
107 
108  const JModule module = router.getModule(frame->getModuleID());
109 
110  const JChecksum::result_type result = checksum.get(*frame);
111 
112  for (JChecksum::const_iterator error = result.begin(); error != result.end(); ++error) {
113  H2[error->type]->Fill((double) string.getIndex(module.getString()), (double) module.getFloor());
114  }
115  }
116  }
117  STATUS(endl);
118 
119  TFile out(outputFile.c_str(), "recreate");
120 
121  out << H2;
122 
123  out.Write();
124  out.Close();
125 }
Utility class to parse command line options.
Definition: JParser.hh:1514
General exception.
Definition: JException.hh:23
int getFloor() const
Get floor number.
Definition: JLocation.hh:145
Data structure for a composite optical module.
Definition: JModule.hh:68
#define STATUS(A)
Definition: JMessage.hh:63
Detector data structure.
Definition: JDetector.hh:89
Auxiliary class to select ROOT class based on class name.
Router for direct addressing of module data in detector data structure.
#define MAKE_CSTRING(A)
Make C-string.
Definition: JPrint.hh:136
Long64_t counter_type
Type definition for counter.
result_type::const_iterator const_iterator
Definition: JChecksum.hh:83
Auxiliary class for multiplexing object iterators.
string outputFile
floor_range getRangeOfFloors(const JDetector &detector)
Get range of floors.
static const JChecksum checksum
Function object to perform check-sum of raw data.
Definition: JChecksum.hh:176
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
Data time slice.
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.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:84
do set_variable DETECTOR_TXT $WORKDIR detector
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
const result_type & get(const JDAQSuperFrame &frame) const
Check sum.
Definition: JChecksum.hh:108