Jpp
Functions
JPlotData.cc File Reference
#include <string>
#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "TH2D.h"
#include "JFit/JEvt.hh"
#include "JFit/JEvtToolkit.hh"
#include "JFit/JFitParameters.hh"
#include "JFit/JFitApplications.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JGeometry3D/JTrack3D.hh"
#include "JGeometry3D/JGeometry3DToolkit.hh"
#include "JGeometry3D/JCylinder3D.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JSupport.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program to produce some standard plots of reconstructed data

Author
lquinn

Definition in file JPlotData.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 34 of file JPlotData.cc.

35 {
36  using namespace std;
37  using namespace JPP;
38 
39  JMultipleFileScanner<JEvt> inputFile; // Class to scan for reconstructed information only
40  JLimit_t& numberOfEvents = inputFile.getLimit();
41  string outputFile;
42  string detectorFile;
43  size_t numberOfPrefits; // The number of reconstructed tracks to plot per event (1 by default)
44  JQualitySorter quality_sorter; // The criterion by which to pick the "best" reconstructed track for each event.
45  int application;
46  int debug;
47 
48  try {
49 
50  JParser<> zap("Example program to histogram fit results.");
51 
52  zap['f'] = make_field(inputFile);
53  zap['o'] = make_field(outputFile) = "postfit.root";
54  zap['a'] = make_field(detectorFile);
55  zap['n'] = make_field(numberOfEvents) = JLimit::max();
56  zap['N'] = make_field(numberOfPrefits) = 1;
59  zap['d'] = make_field(debug) = 2;
60 
61  zap(argc, argv);
62  }
63  catch(const exception& error) {
64  FATAL(error.what() << endl);
65  }
66 
67 
68 
70 
71  try {
72  load(detectorFile, detector);
73  }
74  catch(const JException& error) {
75  FATAL(error);
76  }
77 
78  JCylinder3D cylinder(detector.begin(), detector.end()); // Get detector geometry
79 
80  const double R_m = 2.0 * cylinder.getRadius();
81  const double zmin = -2.0 * cylinder.getZmin();
82  const double zmax = 2.0 * cylinder.getZmax();
83 
84  TFile out(outputFile.c_str(), "recreate");
85  TH1D job("job", "", 2, -0.5, 1.5);
86  TH1D hz ("hz ", "", 21 , -1.0, 1.0); // Zenith angle
87  TH2D hxy("hxy", "", 201, -R_m, R_m, 201, -200.0, 200.0); // X and Y position distribution
88  TH2D hzR("hzR", "", 201, 0.0, R_m, 201, zmin, zmax); // Z and R position distribution
89  TH1D hq1("hq1", "", 200, -50.0, 150); // Reconstruction quality (JPrefit and JSimplex)
90  TH1D hq2("hq2", "", 200, -5.0, 5.0); // Reconstruction quality (JGandalf)
91  TH1D hmu("hmu", "", 100, -50, 50); // Atmospheric muon rejection parameter
92  TH2D hmz("hmz", "", 100, -50, 50, 21, -1.0, 1.0); // Zenith angle vs atmospheric muon rejection parameter
93  TH2D hqz("hqz", "", 200, -5, 5, 21, -1.0, 1.0); // Zenith angle vs reconstruction quality (JGandalf)
94 
95  JAtmosphericMuon isAtmosphericMuon;
96 
97  while (inputFile.hasNext()) { // Loop over each reconstructed event
98 
99  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
100 
101  JEvt* evt = inputFile.next();
102 
103  if (!evt->empty()) {
104 
105  job.Fill(1.0);
106 
107  JEvt::iterator __end = partition(evt->begin(), evt->end(), JHistory::is_event(application));
108 
109  if (evt->begin() == __end) {
110  continue;
111  }
112 
113  if (numberOfPrefits > 0) {
114 
115  JEvt::iterator __q = __end;
116 
117  advance(__end = evt->begin(), min(numberOfPrefits, (size_t) distance(evt->begin(), __q)));
118 
119  partial_sort(evt->begin(), __end, __q, quality_sorter);
120 
121  } else {
122 
123  sort(evt->begin(), __end, quality_sorter);
124  }
125 
126  const double muon_probability = isAtmosphericMuon(evt->begin(), __end);
127 
128  hmu.Fill(muon_probability);
129 
130  if (numberOfPrefits > 0) {
131  advance(__end = evt->begin(), min(numberOfPrefits, evt->size()));
132  }
133 
134  for (JEvt::const_iterator fit = evt->begin(); fit != __end; ++fit) {
135 
136  JTrack3D track = getTrack(*fit);
137  track.sub(cylinder.getCenter());// Move the coordinate system so that (0,0,0) is the centre of the detector
138 
139  hz.Fill(track.getDZ());
140  hxy.Fill(track.getX(), track.getY());
141  hzR.Fill(sqrt(track.getX()*track.getX() + track.getY()*track.getY()), track.getZ());
142  hq1.Fill(fit->getQ());
143  hmz.Fill(muon_probability, track.getDZ());
144 
145  if (fit->hasW(JGANDALF_CHI2) && fit->hasW(JGANDALF_NUMBER_OF_HITS)) {
146 
147  const double lambda = fit->getW(JGANDALF_CHI2)/fit->getW(JGANDALF_NUMBER_OF_HITS);
148 
149  hq2.Fill(lambda);
150  hqz.Fill(lambda, track.getDZ());
151  }
152  }
153  }
154  else {
155  job.Fill(0.0);
156  }
157  }
158 
159  NOTICE("Number of events input " << setw(8) << right << job.GetBinContent(1) << endl);
160  NOTICE("Number of events with direction fit" << setw(8) << right << job.GetBinContent(2) << endl);
161 
162  out.Write();
163  out.Close();
164 }
JMUONENERGY
static const int JMUONENERGY
Definition: reconstruction.hh:17
JGEOMETRY3D::JVersor3D::getDZ
double getDZ() const
Get z direction.
Definition: JVersor3D.hh:114
JGEOMETRY3D::JTrack3D::sub
JTime & sub(const JTime &value)
Subtraction operator.
Definition: JGeometry3D/JTime.hh:80
JMUONSTART
static const int JMUONSTART
Definition: reconstruction.hh:18
JMUONPREFIT
static const int JMUONPREFIT
Definition: reconstruction.hh:14
JSUPPORT::JLimit
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
JROOT::advance
counter_type advance(counter_type &counter, const counter_type value, const counter_type limit=std::numeric_limits< counter_type >::max())
Advance counter.
Definition: JCounter.hh:35
JGANDALF_CHI2
static const int JGANDALF_CHI2
chi2 from JGandalf.cc
Definition: fitparameters.hh:14
JGEOMETRY3D::JVector3D::getZ
double getZ() const
Get z position.
Definition: JVector3D.hh:114
JPARSER::initialised
Empty structure for specification of parser element that is initialised (i.e.
Definition: JParser.hh:63
JDETECTOR::load
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
Definition: JDetectorToolkit.hh:476
JAANET::getTrack
JTrack3E getTrack(const Trk &track)
Get track.
Definition: JAAnetToolkit.hh:256
JPARSER::JParser
Utility class to parse command line options.
Definition: JParser.hh:1493
distance
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Definition: PhysicsEvent.hh:434
JGEOMETRY2D::JCircle2D::getRadius
double getRadius() const
Get radius.
Definition: JCircle2D.hh:121
NOTICE
#define NOTICE(A)
Definition: JMessage.hh:64
JFIT::JEvt
Data structure for set of track fit results.
Definition: JEvt.hh:293
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JGEOMETRY3D::JCylinder3D
Cylinder object.
Definition: JCylinder3D.hh:37
JSUPPORT::JMultipleFileScanner::getCounter
counter_type getCounter() const
Get counter.
Definition: JMultipleFileScanner.hh:323
JFIT::JQualitySorter
General purpose sorter of fit results.
Definition: JEvtToolkit.hh:239
debug
int debug
debug level
Definition: JSirene.cc:59
JSUPPORT::JMultipleFileScanner::next
virtual const pointer_type & next()
Get next element.
Definition: JMultipleFileScanner.hh:398
JMUONSIMPLEX
static const int JMUONSIMPLEX
Definition: reconstruction.hh:15
JMUONGANDALF
static const int JMUONGANDALF
Definition: reconstruction.hh:16
JFIT::JHistory::is_event
Auxiliary class to test history.
Definition: JHistory.hh:101
JMUONPATH
static const int JMUONPATH
Definition: reconstruction.hh:40
STATUS
#define STATUS(A)
Definition: JMessage.hh:63
JSUPPORT::JMultipleFileScanner::hasNext
virtual bool hasNext()
Check availability of next element.
Definition: JMultipleFileScanner.hh:350
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
JSUPPORT::JMultipleFileScanner
General purpose class for object reading from a list of file names.
Definition: JMultipleFileScanner.hh:167
JDETECTOR::JDetector
Detector data structure.
Definition: JDetector.hh:80
JAANET::detector
Detector file.
Definition: JHead.hh:130
DEBUG
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
std
Definition: jaanetDictionary.h:36
JGEOMETRY3D::JVector3D::getY
double getY() const
Get y position.
Definition: JVector3D.hh:103
JGEOMETRY3D::JTrack3D
3D track.
Definition: JTrack3D.hh:30
JGEOMETRY3D::JVector3D::getX
double getX() const
Get x position.
Definition: JVector3D.hh:93
FATAL
#define FATAL(A)
Definition: JMessage.hh:67
outputFile
string outputFile
Definition: JDAQTimesliceSelector.cc:37
JGANDALF_NUMBER_OF_HITS
static const int JGANDALF_NUMBER_OF_HITS
number of hits from JGandalf.cc
Definition: fitparameters.hh:15
JFIT::JAtmosphericMuon
Auxiliary class to evaluate atmospheric muon hypothesis.
Definition: JEvtToolkit.hh:624
JLANG::JException
General exception.
Definition: JException.hh:23
JAANET::quality_sorter
Reconstruction type dependent comparison of track quality.
Definition: JAAnetToolkit.hh:670