Jpp  pmt_effective_area_update_2
the software that should make you happy
 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 
14 
15 #include "JAAnet/JAAnetToolkit.hh"
16 #include "JTools/JRange.hh"
17 #include "JMath/JMathToolkit.hh"
18 #include "JTrigger/JHitL0.hh"
19 #include "JPhysics/JConstants.hh"
20 #include "JDetector/JDetector.hh"
22 
24 #include "JSupport/JSupport.hh"
25 
26 #include "Jeep/JParser.hh"
27 #include "Jeep/JMessage.hh"
28 
29 namespace {
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  */
58 int main(int argc, char **argv)
59 {
60  using namespace std;
61  using namespace JPP;
62  using namespace KM3NETDAQ;
63 
64  typedef JTOOLS::JRange<double> JRange_t;
65 
66  JMultipleFileScanner<Evt> inputFile;
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 
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 }
double getT() const
Get calibrated time of hit.
Utility class to parse command line options.
Definition: JParser.hh:1500
double getAngle(const JQuaternion3D &first, const JQuaternion3D &second)
Get space angle between quanternions.
General exception.
Definition: JException.hh:23
int main(int argc, char *argv[])
Definition: Main.cc:15
ROOT TTree parameter settings of various packages.
Auxiliary methods for geometrical methods.
const Trk & get_muon(const Evt &evt)
Get first muon from the event tracklist.
const JModule & getModule(const JObjectID &id) const
Get module parameters.
JTrack3E getTrack(const Trk &track)
Get track.
#define STATUS(A)
Definition: JMessage.hh:63
Detector data structure.
Definition: JDetector.hh:81
double getIntersection(const JVector3D &pos) const
Get longitudinal position along axis of position of closest approach with given position.
Definition: JAxis3D.hh:146
Router for direct addressing of module data in detector data structure.
std::string comment
use as you like
Definition: Trk.hh:33
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:71
static const JGeaneWater gWater
Function object for energy loss of muon in sea water.
Definition: JGeane.hh:323
unsigned int tdc
hit tdc (=time in ns)
Definition: Hit.hh:16
double getTime(const Hit &hit)
Get true time of hit.
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:30
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:117
Acoustics hit.
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.
Basic data structure for L0 hit.
double getToT(const T &tot, const JCalibration &cal)
Get calibrated time-over-threshold of hit.
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
Detector file.
Definition: JHead.hh:196
double getE() const
Get energy.
Definition: JTrack3E.hh:93
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:1961
Data structure for PMT geometry, calibration and status.
Definition: JPMT.hh:42
Definition of hit and track types and auxiliary methods for handling Monte Carlo data.
Physics constants.
int debug
debug level
Definition: JSirene.cc:63
const JPosition3D & getPosition() const
Get position.
Definition: JPosition3D.hh:130
const JPMT & getPMT(const int index) const
Get PMT.
Definition: JModule.hh:163
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:44
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...
Definition: Hit.hh:8
const double getSpeedOfLight()
Get speed of light.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
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
int dom_id
module identifier from the data (unique in the detector).
Definition: Hit.hh:14
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
unsigned int tot
tot value as stored in raw data (int for pyroot)
Definition: Hit.hh:17
bool hasModule(const JObjectID &id) const
Has module.
unsigned int channel_id
PMT channel id {0,1, .., 31} local to moduke.
Definition: Hit.hh:15
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
std::vector< Hit > hits
list of hits
Definition: Evt.hh:35
do set_variable DETECTOR_TXT $WORKDIR detector
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:36