Jpp  19.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JTriggerEfficiency1D.cc File Reference

Example program to histogram trigger efficiency. More...

#include <string>
#include <iostream>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "km3net-dataformat/offline/Evt.hh"
#include "JDAQ/JDAQEventIO.hh"
#include "JAAnet/JAAnetToolkit.hh"
#include "JSupport/JTriggeredFileScanner.hh"
#include "JSupport/JMonteCarloFileSupportkit.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 trigger efficiency.

Author
mdejong

Definition in file JTriggerEfficiency1D.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 29 of file JTriggerEfficiency1D.cc.

30 {
31  using namespace std;
32  using namespace JPP;
33  using namespace KM3NETDAQ;
34 
35  JTriggeredFileScanner<> inputFile;
36  string outputFile;
37  int debug;
38 
39  try {
40 
41  JParser<> zap("Example program to histogram trigger efficiency.");
42 
43  zap['f'] = make_field(inputFile);
44  zap['o'] = make_field(outputFile) = "efficiency.root";
45  zap['d'] = make_field(debug) = 1;
46 
47  zap(argc, argv);
48  }
49  catch(const exception &error) {
50  FATAL(error.what() << endl);
51  }
52 
53 
54  // output
55 
56  TFile out(outputFile.c_str(), "recreate");
57 
58  TH1D h0("h0", NULL, 100, 0.5, 100.5);
59  TH1D h1("h1", NULL, 100, 0.5, 100.5);
60  TH1D h2("h2", NULL, 100, 0.5, 100.5);
61 
62  h2.Sumw2();
63 
64 
65  while (inputFile.hasNext()) {
66 
67  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
68 
69  JTriggeredFileScanner<>::multi_pointer_type ps = inputFile.next();
70 
71  const Evt* event = ps;
72 
73  const int n = event->mc_hits.size() - count_if(event->mc_hits.begin(), event->mc_hits.cend(), &is_noise);
74 
75  h1.Fill((Double_t) n, 1.0);
76  }
77  STATUS(endl);
78 
79 
80  for (JMultipleFileScanner<Evt> in(inputFile); in.hasNext(); ) {
81 
82  STATUS("event: " << setw(10) << in.getCounter() << '\r'); DEBUG(endl);
83 
84  const Evt* event = in.next();
85 
86  const int n = event->mc_hits.size() - count_if(event->mc_hits.begin(), event->mc_hits.cend(), &is_noise);
87 
88  h0.Fill((Double_t) n, 1.0);
89  }
90  STATUS(endl);
91 
92 
93  for (Int_t i = 1; i <= h1.GetNbinsX(); ++i) {
94 
95  const Double_t y1 = h1.GetBinContent(i);
96  const Double_t y0 = h0.GetBinContent(i);
97 
98  if (y0 != 0.0) {
99 
100  const Double_t y3 = y1 / y0;
101  const Double_t w3 = sqrt(y1 * (y0 - y1) / (y0*y0*y0));
102 
103  h2.SetBinContent(i, y3);
104  h2.SetBinError (i, w3);
105 
106  } else {
107  ERROR("Bin " << h0.GetName() << "[" << i << "] empty." << endl);
108  }
109  }
110 
111  out.Write();
112  out.Close();
113 }
Utility class to parse command line options.
Definition: JParser.hh:1711
#define STATUS(A)
Definition: JMessage.hh:63
Auxiliary class to synchronously read DAQ events and Monte Carlo events (and optionally other events)...
string outputFile
bool is_noise(const Hit &hit)
Verify hit origin.
const int n
Definition: JPolint.hh:786
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2158
#define ERROR(A)
Definition: JMessage.hh:66
#define FATAL(A)
Definition: JMessage.hh:67
General purpose class for object reading from a list of file names.
then fatal The output file must have the wildcard in the e g root fi 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:48
General purpose class for multiple pointers.
int debug
debug level
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:20
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62