Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JAAnet.cc File Reference

Example program to analyse track fit results from AAnet formatted data. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <cmath>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "evt/Head.hh"
#include "evt/Evt.hh"
#include "JTools/JRange.hh"
#include "JTools/JConstants.hh"
#include "JDAQ/JDAQClock.hh"
#include "JAAnet/JAAnetToolkit.hh"
#include "JMath/JMathToolkit.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.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 analyse track fit results from AAnet formatted data.

Author
mdejong

Definition in file JAAnet.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 35 of file JAAnet.cc.

36 {
37  using namespace std;
38  using namespace JPP;
39  using namespace KM3NETDAQ;
40 
41  typedef JTOOLS::JRange<double> JRange_t;
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 
68  JDetector detector;
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_muon(*evt)) {
97  if (has_muon(*evt) && has_reconstructed_track<JPP_RECONSTRUCTION_TYPE>(*evt, JRange<int>(JFIT::JMUONBEGIN, JFIT::JMUONEND))) {
98 
99  JTrack3E ta = getTrack(get_muon(*evt));
100  //JTrack3E tb = getTrack(get_best_reconstructed_muon(*evt));
101  JTrack3E tb = getTrack(get_best_reconstructed_track<JPP_RECONSTRUCTION_TYPE>(*evt, JRange<int>(JFIT::JMUONBEGIN, JFIT::JMUONEND)));
102 
103  ta.add(getTimeSinceRTS(evt->mc_t));
104 
105  ta.move(ta.getIntersection(tb), getSpeedOfLight(), gWater);
106  tb.move(tb.getIntersection(ta), getSpeedOfLight(), gWater);
107 
108  if (E(ta.getE())) {
109 
110  hx.Fill(log10(getAngle(ta.getDirection(), tb.getDirection())));
111  hd.Fill((ta.getPosition() - tb.getPosition()).getLength());
112  ht.Fill( ta.getT() - tb.getT());
113  he.Fill(log10(tb.getE()/ta.getE()));
114  }
115 
116  for (vector<Hit>::const_iterator i = evt->hits.begin(); i != evt->hits.end(); ++i) {
117 
118  if (router.hasModule(i->dom_id)) {
119 
120  const JHitL0 hit = getHit(*i, router);
121 
122  h1.Fill(hit.getT() - tb.getT(hit.getPosition()));
123  }
124  }
125  }
126  }
127  STATUS(endl);
128 
129  out.Write();
130  out.Close();
131 }
Utility class to parse command line options.
Definition: JParser.hh:1410
static const JGeane gWater(2.67e-1 *JTOOLS::DENSITY_SEA_WATER, 3.4e-4 *JTOOLS::DENSITY_SEA_WATER)
Function object for Energy loss of muon in sea water.
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:61
string outputFile
JLimit JLimit_t
Type definition of limit.
Definition: JLimit.hh:214
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1836
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
int debug
debug level
Definition: JSirene.cc:59
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:65
End of muon fit applications.
bool has_muon(const Evt &evt)
Test whether given event has a muon.
Start of muon fit applications.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:72
JHitL0 getHit(const Hit &hit)
Get transformation.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:60