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

Program to histogram fit results from reconstructed data. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "TH2D.h"
#include "TMath.h"
#include "km3net-dataformat/offline/Head.hh"
#include "km3net-dataformat/offline/Evt.hh"
#include "km3net-dataformat/online/JDAQModuleIdentifier.hh"
#include "km3net-dataformat/definitions/reconstruction.hh"
#include "km3net-dataformat/definitions/fitparameters.hh"
#include "JReconstruction/JEvt.hh"
#include "JReconstruction/JEvtToolkit.hh"
#include "JAAnet/JHead.hh"
#include "JAAnet/JHeadToolkit.hh"
#include "JAAnet/JVolume.hh"
#include "JGeometry3D/JTrack3D.hh"
#include "JGeometry3D/JGeometry3DToolkit.hh"
#include "JGeometry3D/JCylinder3D.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JTriggeredFileScanner.hh"
#include "JSupport/JSupport.hh"
#include "JDAQ/JDAQEventIO.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

Program to histogram fit results from reconstructed data.

Author
bofearraigh, rgracia

Definition in file JDataPostfit.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 43 of file JDataPostfit.cc.

44 {
45  using namespace std;
46  using namespace JPP;
47 
48  using namespace KM3NETDAQ;
49 
50  typedef JTriggeredFileScanner<JEvt> JTriggeredFileScanner_t;
51  typedef JTriggeredFileScanner_t::multi_pointer_type multi_pointer_type;
52 
53  JTriggeredFileScanner<JEvt> inputFile;
54  JLimit_t& numberOfEvents = inputFile.getLimit();
55  string outputFile;
56  string option;
57  size_t numberOfPrefits; // The number of reconstructed tracks to plot per event (1 by default)
58  JQualitySorter quality_sorter; // The criterion by which to pick the "best" reconstructed track for each event.
59  int application;
60  int debug;
61 
62  try {
63 
64  JParser<> zap("Program to histogram fit results from reconstructed data.");
65 
66  zap['f'] = make_field(inputFile);
67  zap['o'] = make_field(outputFile) = "postfit.root";
68  zap['n'] = make_field(numberOfEvents) = JLimit::max();
69  zap['N'] = make_field(numberOfPrefits) = 1;
70  zap['A'] = make_field(application) = JMUONENERGY, JMUONPREFIT, JMUONSIMPLEX, JMUONGANDALF, JMUONSTART; //makes histograms after this stage of the reconstruction
72  zap['d'] = make_field(debug) = 2;
73 
74  zap(argc, argv);
75  }
76 
77  catch(const JException& error) {
78  FATAL(error);
79  }
80 
81  const double rad_to_deg = 180/M_PI;
82  const double R_m = 700.0;
83  const int MAX_OVERLAYS = 200;
84  const double zenith_min = -1.0;
85  const double zenith_max = 1.0;
86  const double MAX_TRIGGERED_HITS = 400;
87 
88  TFile out(outputFile.c_str(), "recreate");
89  TH1D job("job", NULL, 100, 0.5, 100.5);
90  TH1D hz ("hz", "; cos(#theta)" , 21 , zenith_min, zenith_max);
91  TH1D ho ("ho", "; #overlays" , MAX_OVERLAYS , -0.5, MAX_OVERLAYS-0.5);
92  TH2D hzo ("hzo", "; cos(#theta) ; #overlays" , 21, zenith_min, zenith_max, MAX_OVERLAYS , -0.5, MAX_OVERLAYS-0.5);
93  TH2D hxy ("hxy", "; x position ; y position" , 201, -R_m, R_m, 201, -R_m, R_m);
94  TH1D hn ("hn", "; # of triggered hits" , MAX_TRIGGERED_HITS, -0.5, MAX_TRIGGERED_HITS-0.5);
95  TH1D hN ("hN", "; JEnergy # of hits" , MAX_TRIGGERED_HITS, -0.5, MAX_TRIGGERED_HITS-0.5);
96  TH1D hq ("hq", "; quality parameter" , 100, -200.0, 800);
97  TH1D hb0 ("hb0", "; log(beta0)" , 60, -2, 3.5);
98  TH1D he ("he", "; log(Ereco [GeV])" , 75, -2, 4);
99  TH2D heo ("heo", "; log(Ereco [GeV]) ; #overlays" , 75, -2, 4, MAX_OVERLAYS , -0.5, MAX_OVERLAYS-0.5);
100  TH2D hzq ("hzq", "; cos(#theta); quality" , 21, zenith_min, zenith_max, 50, -10.0, 500.0);
101  TH2D hze ("hze", "; cos(#theta); log(Ereco [GeV])", 21, zenith_min, zenith_max, 75, -2, 4);
102  TH2D hzb0("hzb0", "; cos(#theta); log(beta0)" , 21, zenith_min, zenith_max, 60, -2, 3.5);
103 
104  while (inputFile.hasNext()) { // Loop over each reconstructed event
105 
106  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl); // if debug > set value, print out this line
107 
108  multi_pointer_type ps = inputFile.next();
109 
110  JDAQEvent* tev = ps;
111  JEvt* evt = ps;
112 
113  job.Fill(1.0);
114 
115  if (!evt->empty()) {
116 
117  JEvt::iterator __end = partition(evt->begin(), evt->end(), JHistory::is_event(application));
118 
119  if (evt->begin() == __end) {
120  continue;
121  }
122 
123  if (numberOfPrefits > 0) {
124 
125  JEvt::iterator __q = __end;
126 
127  advance(__end = evt->begin(), min(numberOfPrefits, (size_t) distance(evt->begin(), __q)));
128 
129  partial_sort(evt->begin(), __end, __q, quality_sorter);
130 
131  } else {
132 
133  sort(evt->begin(), __end, quality_sorter);
134  }
135 
136  if (numberOfPrefits > 0) {
137  advance(__end = evt->begin(), min(numberOfPrefits, evt->size()));
138  }
139 
140  for (JEvt::const_iterator fit = evt->begin(); fit != __end; ++fit) {
141 
142  JTrack3D track = getTrack(*fit);
143 
144  const double overlays = tev->getOverlays();
145 
146  ho .Fill(overlays);
147  hn.Fill((double) tev->size<JDAQTriggeredHit>());
148  hz .Fill(track.getDZ());
149  hzo.Fill(track.getDZ(), overlays) ;
150  hxy.Fill(track.getX(), track.getY());
151  hq .Fill(fit->getQ());
152  hzq.Fill(track.getDZ(), fit->getQ() );
153 
154  if (fit->hasW(JENERGY_NUMBER_OF_HITS)) {
155  hN .Fill( fit->getW(JENERGY_NUMBER_OF_HITS) );
156  }
157 
158  if (fit->hasW(JGANDALF_BETA0_RAD)) {
159  hb0 .Fill(log10( rad_to_deg* fit->getW(JGANDALF_BETA0_RAD) ));
160  hzb0.Fill(track.getDZ(), log10( rad_to_deg* fit->getW(JGANDALF_BETA0_RAD)) );
161  }
162  const double Efit = fit->getE();
163  he .Fill(log10(Efit));
164  hze.Fill(track.getDZ(), log10(Efit) );
165  heo.Fill(log10(Efit), overlays );
166  }
167  }
168  }
169  STATUS("Number of events input " << setw(8) << right << job.GetBinContent(1) << endl);
170  out.Write();
171  out.Close();
172 }
static const int JMUONSTART
Utility class to parse command line options.
Definition: JParser.hh:1500
General exception.
Definition: JException.hh:23
JTrack3E getTrack(const Trk &track)
Get track.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
#define STATUS(A)
Definition: JMessage.hh:63
General purpose sorter of fit results.
Auxiliary class to synchronously read DAQ events and Monte Carlo events (and optionally other events)...
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:66
string outputFile
unsigned int size() const
Get number of hits.
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
static const int JMUONPREFIT
Acoustic event fit.
static const int JENERGY_NUMBER_OF_HITS
number of hits from JEnergy.cc
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
Auxiliary class to test history.
Definition: JHistory.hh:104
static const int JMUONGANDALF
static const int JGANDALF_BETA0_RAD
KM3NeT Data Definitions v2.0.0-14-gbeccebb https://git.km3net.de/common/km3net-dataformat.
unsigned int getOverlays() const
Get number of overlays.
double getY() const
Get y position.
Definition: JVector3D.hh:104
int debug
debug level
Definition: JSirene.cc:63
Reconstruction type dependent comparison of track quality.
counter_type advance(counter_type &counter, const counter_type value, const counter_type limit=std::numeric_limits< counter_type >::max())
Advance counter.
#define FATAL(A)
Definition: JMessage.hh:67
static const int JMUONSIMPLEX
double getX() const
Get x position.
Definition: JVector3D.hh:94
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
double getDZ() const
Get z direction.
Definition: JVersor3D.hh:117
static const int JMUONENERGY
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62