Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JAAnet.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 #include <cmath>
6 
7 #include "TROOT.h"
8 #include "TFile.h"
9 #include "TH1D.h"
10 
13 
14 #include "JTools/JRange.hh"
15 #include "JTools/JConstants.hh"
17 #include "JAAnet/JAAnetToolkit.hh"
18 #include "JMath/JMathToolkit.hh"
19 #include "JDetector/JDetector.hh"
21 
23 #include "JSupport/JSupport.hh"
24 
25 #include "Jeep/JParser.hh"
26 #include "Jeep/JMessage.hh"
27 
28 
29 /**
30  * \file
31  *
32  * Example program to analyse track fit results from AAnet formatted data.
33  * \author mdejong
34  */
35 int main(int argc, char **argv)
36 {
37  using namespace std;
38  using namespace JPP;
39  using namespace KM3NETDAQ;
40 
42 
43  JMultipleFileScanner<Evt> inputFile;
44  JLimit_t& numberOfEvents = inputFile.getLimit();
45  string detectorFile;
46  string outputFile;
47  JRange_t E;
48  int debug;
49 
50  try {
51 
52  JParser<> zap("Example program to analyse track fit results from AAnet formatted data.");
53 
54  zap['f'] = make_field(inputFile);
55  zap['n'] = make_field(numberOfEvents) = JLimit::max();
56  zap['a'] = make_field(detectorFile) = "";
57  zap['o'] = make_field(outputFile) = "histogram.root";
58  zap['E'] = make_field(E) = JRange_t();
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 
69 
70  if (detectorFile != "") {
71  try {
72  load(detectorFile, detector);
73  }
74  catch(const JException& error) {
75  FATAL(error);
76  }
77  }
78 
79  const JModuleRouter router(detector);
80 
81  TFile out(outputFile.c_str(), "recreate");
82 
83  TH1D hx("hx", NULL, 100, -3.0, +2.3); // [log(deg)]
84  TH1D hd("hd", NULL, 100, 0.0, 10.0); // [m]
85  TH1D ht("ht", NULL, 100, -100.0, 100.0); // [ns]
86  TH1D he("he", NULL, 100, -5.0, +5.0); // [log10(E)]
87  TH1D h1("h1", NULL, 100, -50.0, +50.0); // [ns]
88 
89 
90  while (inputFile.hasNext()) {
91 
92  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
93 
94  const Evt* evt = inputFile.next();
95 
96  //if (has_muon(*evt) && has_reconstructed_track<JPP_RECONSTRUCTION_TYPE>(*evt, rec_stages_range(JMUONBEGIN, JMUONEND))) {
97  if (has_muon(*evt) && has_reconstructed_jppmuon(*evt)) {
98 
100 
101  JTrack3E ta = getTrack(get_muon(*evt));
102  //JTrack3E tb = getTrack(get_best_reconstructed_track<JPP_RECONSTRUCTION_TYPE>(*evt, rec_stages_range(JMUONBEGIN, JMUONEND)));
104 
105  ta.add(getTimeSinceRTS(evt->mc_t));
106 
109 
110  if (E(ta.getE())) {
111 
112  hx.Fill(log10(getAngle(ta.getDirection(), tb.getDirection())));
113  hd.Fill((ta.getPosition() - tb.getPosition()).getLength());
114  ht.Fill( ta.getT() - tb.getT());
115  he.Fill(log10(tb.getE()/ta.getE()));
116  }
117 
118  for (vector<Hit>::const_iterator i = evt->hits.begin(); i != evt->hits.end(); ++i) {
119 
120  if (router.hasModule(i->dom_id)) {
121 
122  const JHitL0 hit = getHit(*i, router);
123 
124  h1.Fill(hit.getT() - tb.getT(hit.getPosition()));
125  }
126  }
127  }
128  }
129  STATUS(endl);
130 
131  out.Write();
132  out.Close();
133 }
double getT() const
Get calibrated time of hit.
Utility class to parse command line options.
Definition: JParser.hh:1493
General exception.
Definition: JException.hh:23
ROOT TTree parameter settings.
Auxiliary methods for geometrical methods.
const Trk & get_muon(const Evt &evt)
Get first muon from the event tracklist.
double getAngle(const JFirst_t &first, const JSecond_t &second)
Get space angle between objects.
JTrack3E getTrack(const Trk &track)
Get track.
const double getSpeedOfLight()
Number of bytes in a gigabyte.
Definition: JConstants.hh:89
#define STATUS(A)
Definition: JMessage.hh:63
Detector data structure.
Definition: JDetector.hh:80
double getIntersection(const JVector3D &pos) const
Get longitudinal position along axis of position of closest approach with given position.
Definition: JAxis3D.hh:157
Router for direct addressing of module data in detector data structure.
std::string comment
use as you like
Definition: Trk.hh:32
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:69
static const JGeaneWater gWater
Function object for energy loss of muon in sea water.
Definition: JGeane.hh:328
string outputFile
bool has_reconstructed_jppmuon(const Evt &evt)
Test whether given event has a track with muon reconstruction.
3D track with energy.
Definition: JTrack3E.hh:29
Data structure for detector geometry and calibration.
void move(const double step, const double velocity, const JGeane &geane)
Move vertex along this track with given velocity.
Definition: JTrack3E.hh:105
JVersor3D getDirection(const JVector3D &pos) const
Get photon direction of Cherenkov light on PMT.
Definition: JTrack3D.hh:147
JTime & add(const JTime &value)
Addition operator.
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
Constants.
Detector file.
Definition: JHead.hh:130
double getE() const
Get energy.
Definition: JTrack3E.hh:92
const Trk & get_best_reconstructed_jppmuon(const Evt &evt)
Get best reconstructed muon.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
Definition of hit and track types and auxiliary methods for handling Monte Carlo data.
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
int debug
debug level
Definition: JSirene.cc:61
const JPosition3D & getPosition() const
Get position.
Definition: JPosition3D.hh:129
double mc_t
MC: time of the mc event.
Definition: Evt.hh:43
double getT(const JVector3D &pos) const
Get arrival time of Cherenkov light at given position.
Definition: JTrack3D.hh:126
General purpose messaging.
double getTimeSinceRTS(const int frame_index)
Get time in ns since last RTS for a given frame index.
Definition: JDAQClock.hh:263
#define FATAL(A)
Definition: JMessage.hh:67
Scanning of objects from multiple files according a format that follows from the extension of each fi...
JRange< Double_t > JRange_t
Definition: JFitToT.hh:34
Auxiliary class to define a range between two values.
bool has_muon(const Evt &evt)
Test whether given event has a muon.
General purpose class for object reading from a list of file names.
Utility class to parse command line options.
Data structure for L0 hit.
Definition: JHitL0.hh:27
bool hasModule(const JObjectID &id) const
Has module.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
std::vector< Hit > hits
list of hits
Definition: Evt.hh:35
JHitL0 getHit(const Hit &hit)
Get transformation.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:19
then usage $script[input file[working directory[option]]] nWhere option can be E
Definition: JMuonPostfit.sh:37
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
int main(int argc, char *argv[])
Definition: Main.cpp:15