Jpp 21.0.0-rc.1-88-g0130508c4
the software that should make you happy
Loading...
Searching...
No Matches
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
14
16#include "JTools/JRange.hh"
17#include "JMath/JMathToolkit.hh"
18#include "JTrigger/JHitL0.hh"
22
24#include "JSupport/JSupport.hh"
25
26#include "Jeep/JParser.hh"
27#include "Jeep/JMessage.hh"
28
29namespace {
30
31 using JTRIGGER::JHitL0;
33
34 /**
35 * Get transformation.
36 *
37 * \param hit hit
38 * \param router module router
39 * \return hit
40 */
41 inline JHitL0 getHit(const Hit& hit, const JModuleRouter& router)
42 {
43 using namespace JPP;
44
45 const JPMT& pmt = router.getModule(hit.dom_id).getPMT(hit.channel_id);
46
47 return JHitL0(JDAQPMTIdentifier(hit.dom_id, hit.channel_id), pmt.getAxis(), JHit(getTime(hit.tdc, pmt.getCalibration()), getToT(hit.tot, pmt.getCalibration())));
48 }
49}
50
51
52/**
53 * \file
54 *
55 * Example program to analyse track fit results from Evt formatted data.
56 * \author mdejong
57 */
58int main(int argc, char **argv)
59{
60 using namespace std;
61 using namespace JPP;
62 using namespace KM3NETDAQ;
63
65
67 JLimit_t& numberOfEvents = inputFile.getLimit();
68 string detectorFile;
69 string outputFile;
70 JRange_t E;
71 int debug;
72
73 try {
74
75 JParser<> zap("Example program to analyse track fit results from Evt formatted data.");
76
77 zap['f'] = make_field(inputFile);
78 zap['n'] = make_field(numberOfEvents) = JLimit::max();
79 zap['a'] = make_field(detectorFile) = "";
80 zap['o'] = make_field(outputFile) = "histogram.root";
81 zap['E'] = make_field(E) = JRange_t();
82 zap['d'] = make_field(debug) = 2;
83
84 zap(argc, argv);
85 }
86 catch(const exception& error) {
87 FATAL(error.what() << endl);
88 }
89
90
92
93 if (detectorFile != "") {
94 try {
95 load(detectorFile, detector);
96 }
97 catch(const JException& error) {
98 FATAL(error);
99 }
100 }
101
102 const JModuleRouter router(detector);
103
104 TFile out(outputFile.c_str(), "recreate");
105
106 TH1D hx("hx", NULL, 100, -3.0, +2.3); // [log(deg)]
107 TH1D hd("hd", NULL, 100, 0.0, 10.0); // [m]
108 TH1D ht("ht", NULL, 100, -100.0, 100.0); // [ns]
109 TH1D he("he", NULL, 100, -5.0, +5.0); // [log10(E)]
110 TH1D h1("h1", NULL, 100, -50.0, +50.0); // [ns]
111
112
113 while (inputFile.hasNext()) {
114
115 STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
116
117 const Evt* evt = inputFile.next();
118
119 //if (has_muon(*evt) && has_reconstructed_track<JPP_RECONSTRUCTION_TYPE>(*evt, rec_stages_range(JMUONBEGIN, JMUONEND))) {
120 if (has_muon(*evt) && has_reconstructed_jppmuon(*evt)) {
121
123
124 JTrack3E ta = getTrack(get_muon(*evt));
125 //JTrack3E tb = getTrack(get_best_reconstructed_track<JPP_RECONSTRUCTION_TYPE>(*evt, rec_stages_range(JMUONBEGIN, JMUONEND)));
127
128 ta.add(getTimeSinceRTS(evt->mc_t));
129
130 ta.move(ta.getIntersection(tb), getSpeedOfLight(), gWater);
131 tb.move(tb.getIntersection(ta), getSpeedOfLight(), gWater);
132
133 if (E(ta.getE())) {
134
135 hx.Fill(log10(getAngle(ta.getDirection(), tb.getDirection())));
136 hd.Fill((ta.getPosition() - tb.getPosition()).getLength());
137 ht.Fill( ta.getT() - tb.getT());
138 he.Fill(log10(tb.getE()/ta.getE()));
139 }
140
141 for (vector<Hit>::const_iterator i = evt->hits.begin(); i != evt->hits.end(); ++i) {
142
143 if (router.hasModule(i->dom_id)) {
144
145 const JHitL0 hit = getHit(*i, router);
146
147 h1.Fill(hit.getT() - tb.getT(hit.getPosition()));
148 }
149 }
150 }
151 }
152 STATUS(endl);
153
154 out.Write();
155 out.Close();
156}
Definition of hit and track types and auxiliary methods for handling Monte Carlo data.
string outputFile
Data structure for detector geometry and calibration.
Basic data structure for L0 hit.
Binary methods for member methods.
General purpose messaging.
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define STATUS(A)
Definition JMessage.hh:63
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:74
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2140
Physics constants.
Auxiliary class to define a range between two values.
ROOT TTree parameter settings of various packages.
const JCalibration & getCalibration() const
Get calibration.
Detector data structure.
Definition JDetector.hh:96
Router for direct addressing of module data in detector data structure.
bool hasModule(const JModuleIdentifier &id) const
Has module.
const JModule & getModule(const JModuleIdentifier &id) const
Get module parameters.
const JPMT & getPMT(const int index) const
Get PMT.
Definition JModule.hh:173
Data structure for PMT geometry, calibration and status.
Definition JPMT.hh:49
double getIntersection(const JVector3D &pos) const
Get longitudinal position along axis of position of closest approach with given position.
Definition JAxis3D.hh:146
const JAxis3D & getAxis() const
Get axis.
Definition JAxis3D.hh:98
double getE() const
Get energy.
const JPosition3D & getPosition() const
Get position.
double getT(const JVector3D &pos) const
Get arrival time of Cherenkov light at given position.
Definition JTrack3D.hh:87
JTime & add(const JTime &value)
Addition operator.
JVersor3D getDirection(const JVector3D &pos) const
Get photon direction of Cherenkov light on PMT.
Definition JTrack3D.hh:108
3D track with energy.
Definition JTrack3E.hh:34
void move(const double step, const double velocity, const JGeane &geane)
Move position along this track with given velocity.
Definition JTrack3E.hh:65
General exception.
Definition JException.hh:25
Utility class to parse command line options.
Definition JParser.hh:1697
General purpose class for object reading from a list of file names.
virtual bool hasNext() override
Check availability of next element.
counter_type getCounter() const
Get counter.
virtual const pointer_type & next() override
Get next element.
Range of values.
Definition JRange.hh:42
Data structure for L0 hit.
Definition JHitL0.hh:31
double getT() const
Get calibrated time of hit.
int main()
JTrack3E getTrack(const Trk &track)
Get track.
bool has_muon(const Evt &evt)
Test whether given event has a muon.
const Trk & get_muon(const Evt &evt)
Get first muon from the event tracklist.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
double getAngle(const JQuaternion3D &first, const JQuaternion3D &second)
Get space angle between quanternions.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
const char * getTime()
Get current local time conform ISO-8601 standard.
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
double getTimeSinceRTS(const int frame_index)
Get time in ns since last RTS for a given frame index.
Definition JDAQClock.hh:263
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition Evt.hh:21
double mc_t
MC: time where the mc-event was put in the timeslice, since start of run (offset+frameidx*timeslice_d...
Definition Evt.hh:47
std::vector< Hit > hits
list of hits
Definition Evt.hh:38
Definition Hit.hh:10
int dom_id
module identifier from the data (unique in the detector).
Definition Hit.hh:14
unsigned int tdc
hit tdc (=time in ns)
Definition Hit.hh:16
unsigned int channel_id
PMT channel id {0,1, .., 30} local to moduke.
Definition Hit.hh:15
unsigned int tot
tot value as stored in raw data (int for pyroot)
Definition Hit.hh:17
Type definition of range.
Definition JHead.hh:43
Detector file.
Definition JHead.hh:227
Acoustics hit.
Auxiliary class for defining the range of iterations of objects.
Definition JLimit.hh:45
static counter_type max()
Get maximum counter value.
Definition JLimit.hh:128
std::string comment
use as you like
Definition Trk.hh:35
const Trk & get_best_reconstructed_jppmuon(const Evt &evt)
Get best reconstructed muon.
bool has_reconstructed_jppmuon(const Evt &evt)
Test whether given event has a track with muon reconstruction.