Jpp
Functions
JORCAShowerPositionPDF.cc File Reference
#include <iostream>
#include <cmath>
#include "km3net-dataformat/offline/Evt.hh"
#include "JDAQ/JDAQEventIO.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
#include "JFit/JPoint4D.hh"
#include "JLang/JTypeList.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JTriggeredFileScanner.hh"
#include "JSupport/JTreeScanner.hh"
#include "JTrigger/JTimeConverter.hh"
#include "JTrigger/JHitL0.hh"
#include "JTrigger/JHitL1.hh"
#include "JTrigger/JBuildL0.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JPMTRouter.hh"
#include "JDetector/JModuleRouter.hh"
#include "JGeometry3D/JPosition3D.hh"
#include "JGeometry3D/JDirection3D.hh"
#include <TFile.h>
#include <TH2D.h>

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 34 of file JORCAShowerPositionPDF.cc.

35 {
36  using namespace std;
37  using namespace JPP;
38 
39  typedef JTriggeredFileScanner<> JTriggeredFileScanner_t;
40  typedef JTriggeredFileScanner_t::multi_pointer_type multi_pointer_type;
41 
42  JTriggeredFileScanner_t inputFile;
43  string outputFile;
44  string detectorFile;
45  JRange<double> t_res_ns;
46  JRange<double> D_m;
47  JRange<double> cosT;
48  bool PMTweight; // weight PDF to take into account PMT growing number
49  // with respect to vertex
50  int debug;
51 
52  try{
53  JParser<> zap;
54 
55  zap['f'] = make_field(inputFile);
56  zap['o'] = make_field(outputFile) = "JORCAShowerPositionFit_PDF.root";
57  zap['a'] = make_field(detectorFile);
58  zap['T'] = make_field(t_res_ns) = JRange<double>(-100, 100); // [ns]
59  zap['D'] = make_field(D_m) = JRange<double>(0, 100); // [m]
60  zap['C'] = make_field(cosT) = JRange<double>(-1, 1);
61  zap['d'] = make_field(debug) = 2;
62  zap['P'] = make_field(PMTweight);
63 
64  if (zap.read(argc, argv) != 0) return 1;
65  }
66  catch(const exception& error){
67  FATAL(error.what() << endl);
68  }
69 
70  cout.tie(&cerr);
71 
73 
74  try{
75  load(detectorFile, detector);
76  }
77  catch(const JException& error){
78  FATAL(error);
79  }
80 
81  const JPMTRouter pmtRouter(detector);
82  const JModuleRouter moduleRouter(detector);
83 
84  typedef vector<JHitL0> JDataL0_t;
85  const JBuildL0<JHitL0> buildL0;
86 
87  TFile *out = new TFile(outputFile.c_str(), "RECREATE");
88  if ( !out->IsOpen() ) printf("Can't open outputfile\n");
89 
90  TH2D hPDF2Dist("hPDF2Dist", "PDF for ORCA Shower Position Fit; #delta t [ns]; D [m]",
91  2000, t_res_ns.getLowerLimit(), t_res_ns.getUpperLimit(),
92  700, D_m.getLowerLimit(), D_m.getUpperLimit());
93 
94  while(inputFile.hasNext()){
95 
96  multi_pointer_type ps = inputFile.next();
97 
98  JDAQEvent* tev = ps;
99  Evt* event = ps;
100  JTimeConverter converter(*event, *tev);
101 
102  // Get MC truth neutrino and shower
103  Trk cascade;
104  cascade.pos = event->mc_trks[1].pos;
105  cascade.pos -= Vec(0.0, 0.0, -117.164);
106 
107  for (unsigned int i = 1; i < event->mc_trks.size(); i++) {
108  cascade.E += event->mc_trks[i].E;
109  cascade.dir += event->mc_trks[i].dir * event->mc_trks[i].E;
110  }
111  cascade.dir.normalize();
112 
113  JPosition3D vx = getPosition(cascade.pos);
114  double t_vx = converter.putTime(event->mc_trks[1].t);
115  JDirection3D dir = getDirection(cascade.dir);
116 
117  JDataL0_t dataL0;
118  buildL0(JDAQTimeslice(*tev, true), moduleRouter, back_inserter(dataL0));
119 
120  //**************** PDF with real interaction vertex ***************
121  const JRotation3D R(dir);
122  vx.rotate(R);
123 
124  for (vector<JHitL0>::const_iterator i = dataL0.begin(); i != dataL0.end(); ++i) {
125 
126  JHitL0 hit(*i);
127  hit.transform(R, vx);
128 
129  const double D = hit.getLength();
130  const double t_expected = t_vx + D * getInverseSpeedOfLight() * getIndexOfRefraction();
131  const double dt = hit.getT() - t_expected;
132  const JDirection3D photonDir(hit.getPosition());
133  const double ct = photonDir.getDot(hit.getDirection());
134 
135  if((D >= D_m.getLowerLimit() && D <= D_m.getUpperLimit()) &&
136  (dt >= t_res_ns.getLowerLimit() && dt <= t_res_ns.getUpperLimit()) &&
137  (ct >= cosT.getLowerLimit() && ct <= cosT.getUpperLimit())){
138 
139  double w = 1;
140 
141  if(PMTweight){
142  w = 1 / (D*D);
143  }
144 
145  hPDF2Dist.Fill(dt, D, w);
146  }
147  }
148  }
149  STATUS(endl);
150 
151  out->cd();
152  hPDF2Dist.Write();
153  out->Close();
154 
155 }
JTOOLS::JRange::getLowerLimit
T getLowerLimit() const
Get lower limit.
Definition: JRange.hh:215
KM3NETDAQ::JDAQEvent
DAQ Event.
Definition: JDAQEvent.hh:30
JTOOLS::JRange::getUpperLimit
T getUpperLimit() const
Get upper limit.
Definition: JRange.hh:226
JTOOLS::w
data_type w[N+1][M+1]
Definition: JPolint.hh:708
JDETECTOR::load
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
Definition: JDetectorToolkit.hh:476
JGEOMETRY3D::JDirection3D::getDot
double getDot(const JAngle3D &angle) const
Get dot product.
Definition: JDirection3D.hh:333
Trk::E
double E
Energy (either MC truth or reconstructed)
Definition: Trk.hh:18
std::vector< JHitL0 >
Trk
The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower.
Definition: Trk.hh:12
JTOOLS::JRange< double >
JGEOMETRY3D::JDirection3D
Data structure for direction in three dimensions.
Definition: JDirection3D.hh:32
Evt
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:19
JTRIGGER::JTimeConverter
Auxiliary class to convert DAQ/trigger hit time to/from Monte Carlo hit time.
Definition: JTimeConverter.hh:36
KM3NETDAQ::JDAQTimeslice
Data time slice.
Definition: JDAQTimeslice.hh:30
JPARSER::JParser
Utility class to parse command line options.
Definition: JParser.hh:1493
JDETECTOR::JPMTRouter
Router for direct addressing of PMT data in detector data structure.
Definition: JPMTRouter.hh:33
JGEOMETRY3D::JPosition3D::rotate
JPosition3D & rotate(const JRotation3D &R)
Rotate.
Definition: JPosition3D.hh:185
Trk::dir
Vec dir
track direction
Definition: Trk.hh:16
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JTOOLS::getInverseSpeedOfLight
const double getInverseSpeedOfLight()
Get inverse speed of light.
Definition: JConstants.hh:100
debug
int debug
debug level
Definition: JSirene.cc:59
JGEOMETRY3D::JPosition3D
Data structure for position in three dimensions.
Definition: JPosition3D.hh:35
JTOOLS::getIndexOfRefraction
double getIndexOfRefraction()
Get average index of refraction of water.
Definition: JConstants.hh:111
STATUS
#define STATUS(A)
Definition: JMessage.hh:63
Trk::pos
Vec pos
postion of the track at time t
Definition: Trk.hh:15
JDETECTOR::JModuleRouter
Router for direct addressing of module data in detector data structure.
Definition: JModuleRouter.hh:34
JAANET::getDirection
JDirection3D getDirection(const Vec &v)
Get direction.
Definition: JAAnetToolkit.hh:221
JSUPPORT::JTriggeredFileScanner
Auxiliary class to synchronously read DAQ events and Monte Carlo events (and optionally other events)...
Definition: JTriggeredFileScanner.hh:39
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
JDETECTOR::JDetector
Detector data structure.
Definition: JDetector.hh:80
JAANET::getPosition
JPosition3D getPosition(const Vec &v)
Get position.
Definition: JAAnetToolkit.hh:197
JTRIGGER::JHitL0
Data structure for L0 hit.
Definition: JHitL0.hh:27
JAANET::detector
Detector file.
Definition: JHead.hh:130
std
Definition: jaanetDictionary.h:36
Vec
The Vec class is a straightforward 3-d vector, which also works in pyroot.
Definition: Vec.hh:12
Vec::normalize
Vec & normalize()
Normalise this vector.
Definition: Vec.hh:159
JTRIGGER::JBuildL0< JHitL0 >
Template specialisation of L0 builder for JHitL0 data type.
Definition: JBuildL0.hh:101
FATAL
#define FATAL(A)
Definition: JMessage.hh:67
outputFile
string outputFile
Definition: JDAQTimesliceSelector.cc:37
JLANG::JException
General exception.
Definition: JException.hh:23
JGEOMETRY3D::JRotation3D
Rotation matrix.
Definition: JRotation3D.hh:111
JPARSER::JParser::read
int read(const int argc, const char *const argv[])
Parse the program's command line options.
Definition: JParser.hh:1791