Jpp  16.0.3
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JShowerDirectionPrefit.hh
Go to the documentation of this file.
1 #ifndef JSHOWERDIRECTIONPREFIT_INCLUDE
2 #define JSHOWERDIRECTIONPREFIT_INCLUDE
3 
4 #include <string>
5 #include <iostream>
6 #include <set>
7 #include <vector>
8 #include <algorithm>
9 #include <memory>
10 
13 
14 #include "JTrigger/JHit.hh"
15 #include "JTrigger/JTimeslice.hh"
16 #include "JTrigger/JHitL0.hh"
17 #include "JTrigger/JHitL1.hh"
18 #include "JTrigger/JHitR1.hh"
19 #include "JTrigger/JBuildL0.hh"
20 #include "JTrigger/JBuildL2.hh"
21 #include "JTrigger/JAlgorithm.hh"
22 #include "JTrigger/JMatch3G.hh"
23 #include "JTrigger/JBind2nd.hh"
24 
26 
28 #include "JFit/JFitToolkit.hh"
29 #include "JFit/JPoint4D.hh"
30 #include "JFit/JModel.hh"
31 #include "JFit/JSimplex.hh"
32 #include "JFit/JGandalf.hh"
33 
34 #include "JAAnet/JAAnetToolkit.hh"
35 
36 #include "JReconstruction/JEvt.hh"
39 
40 #include "JDetector/JDetector.hh"
42 
43 #include "JGeometry3D/JVector3D.hh"
45 #include "JGeometry3D/JOmega3D.hh"
46 #include "JGeometry3D/JTrack3D.hh"
47 #include "JGeometry3D/JTrack3E.hh"
48 #include "JGeometry3D/JShower3E.hh"
49 
50 #include "JLang/JSharedPointer.hh"
51 
52 /**
53  * \author adomi
54  */
55 namespace JRECONSTRUCTION {}
56 namespace JPP { using namespace JRECONSTRUCTION; }
57 
58 namespace JRECONSTRUCTION {
59 
62  using JFIT::JRegressor;
63  using JFIT::JEnergy;
64  using JFIT::JShower3EZ;
65  using JFIT::JSimplex;
66  using JFIT::JGandalf;
67 
68  /**
69  * class to handle the direction fit of the shower reconstruction, mainly dedicated for ORCA
70  */
73  public JRegressor<JShower3EZ, JGandalf>
74  {
75 
77  using JRegressor_t::operator();
78 
79  public:
80 
81  /**
82  * Parameterized constructor
83  *
84  * \param parameters struct that holds default-optimized parameters for the reconstruction, available in $JPP_DATA.
85  * \param router module router, this is built via detector file.
86  * \param summary summary router
87  * \param pdfFile PDF file
88  * \param debug debug
89  */
91  const JModuleRouter& router,
92  const JSummaryRouter& summary,
93  const std::string pdfFile,
94  const int debug = 0):
96  JRegressor_t(pdfFile),
97  router(router),
98  summary(summary)
99  {
100  using namespace JPP;
101 
103  JRegressor_t::T_ns.setRange(parameters.TMin_ns, parameters.TMax_ns);
106 
107  this->parameters.resize(2);
108 
109  this->parameters[0] = JShower3EZ::pDX();
110  this->parameters[1] = JShower3EZ::pDY();
111 
112  this->estimator.reset(getMEstimator(parameters.mestimator));
113  }
114 
115  /**
116  * Declaration of the member function that actually performs the reconstruction
117  *
118  * \param event = JDAQEvent
119  * \param in = input fits
120  */
122  {
123  using namespace std;
124  using namespace JPP;
125 
126  typedef vector<JHitL0> JDataL0_t;
127  JBuildL0<JHitL0> buildL0;
128 
129  JEvt out;
130 
132 
133  JDataL0_t dataL0;
134  buildL0(JDAQTimeslice(event, true), router, back_inserter(dataL0));
135 
136  for (JEvt::const_iterator shower = in.begin(); shower != in.end(); ++shower) {
137 
138  JShower3E sh(getPosition(*shower), getDirection(*shower), shower->getT(), shower->getE());
139 
141 
142  double distance = roadWidth_m;
143  double max_angle = MaxAngle_deg_lowE;
144  double scan_angle = scanAngle_deg_lowE;
145 
146  if(sh.getE() > E_GeV) {
147  distance = DMin_m; // to speed up the code
148  max_angle = MaxAngle_deg_highE;
149  scan_angle = scanAngle_deg_highE;
150  }
151 
152  const JFIT::JModel<JPoint4D> match(JPoint4D(sh.getPosition(), sh.getT()), distance, JRegressor_t::T_ns);
153 
154  JVector3D start_dir(0,0,0);
155 
156  for (JDataL0_t::const_iterator i = dataL0.begin(); i != dataL0.end(); ++i) {
157 
158  if (match(*i)) {
159 
160  top.insert(i->getPMTIdentifier());
161 
162  start_dir.add(JDirection3D(i->getPosition() - sh.getPosition()));
163 
164  }
165  }
166 
167  sh.setDirection(JDirection3D(start_dir));
168 
169  JDetectorSubset_t subdetector(detector, sh.getPosition(), distance);
170 
171  JOmega3D scan_directions(sh.getDirection(),
172  JOmega3D::range_type(0, max_angle * PI/180.0),
173  scan_angle * PI/180.0);
174 
175  for (JOmega3D_t::const_iterator dir = scan_directions.begin(); dir != scan_directions.end(); ++dir) {
176 
177  const JDirection3D conversion(*dir);
178  const JRotation3D R(conversion);
179 
180  vector<JPMTW0> buffer;
181 
182  for (JDetectorSubset_t::iterator module = subdetector.begin();
183  module != subdetector.end(); ++module) {
184 
185  JModule dom(*module);
186  dom.rotate(R);
187 
188  for (unsigned int i = 0; i != dom.size(); ++i) {
189 
190  const JDAQPMTIdentifier id(dom.getID(), i);
191 
192  const double rate_Hz = summary.getRate(id);
193 
194  buffer.push_back(JPMTW0(dom.getPMT(i), rate_Hz, top.count(id)));
195  }
196  }
197 
198  double chi2 = (*this)(JShower3EZ(JVertex3D(JVector3D(0,0,0), sh.getT()), JVersor3Z(),
199  JEnergy(log10(sh.getE()))), buffer.begin(), buffer.end());
200 
201  double NDF = getCount(buffer.begin(), buffer.end()) - this->parameters.size();
202 
203  JShower3E sh_fit(this->value.getPosition(), this->value.getDirection(),
204  this->value.getT(), this->value.getE());
205 
206  sh_fit.rotate_back(R);
207 
208  sh_fit.add(sh.getPosition());
209 
210  out.push_back(getFit(JHistory(shower->getHistory()).add(JSHOWERDIRECTIONPREFIT), sh_fit, getQuality(chi2),
211  NDF, sh_fit.getE()));
212 
213  }
214  }
215 
216  return out;
217 
218  }
219 
222  };
223 }
224 
225 #endif
226 
Auxiliary methods to evaluate Poisson probabilities and chi2.
static int debug
debug level (default is off).
Definition: JMessage.hh:45
Template definition of a data regressor of given model.
Definition: JRegressor.hh:68
double TMax_ns
maximum time for local coincidences [ns]
static parameter_type pDX()
Definition: JShower3Z.hh:171
JEvt operator()(const KM3NETDAQ::JDAQEvent &event, const JFIT::JEvt &in)
Declaration of the member function that actually performs the reconstruction.
Data structure for direction in three dimensions.
Definition: JDirection3D.hh:33
class to handle the direction fit of the shower reconstruction, mainly dedicated for ORCA ...
Data structure for a composite optical module.
Definition: JModule.hh:68
double getQuality(const double chi2, const int NDF)
Get quality of fit.
Algorithms for hit clustering and sorting.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Template specialisation of L0 builder for JHitL0 data type.
Definition: JBuildL0.hh:102
Auxiliary class for handling PMT geometry, rate and response.
Definition: JPMTW0.hh:22
Data structure for vertex fit.
Definition: JPoint4D.hh:22
Detector data structure.
Definition: JDetector.hh:89
Router for direct addressing of module data in detector data structure.
Rotation matrix.
Definition: JRotation3D.hh:111
double getRate() const
Get default rate.
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
Direction set covering (part of) solid angle.
Definition: JOmega3D.hh:66
double MaxAngle_deg_lowE
maximum scanning angle in [deg] for low energy events
std::pair< double, double > range_type
Definition: JOmega3D.hh:32
Basic data structure for time and time over threshold information of hit.
3D track with energy.
Definition: JTrack3E.hh:30
Data structure for detector geometry and calibration.
Basic data structure for L0 hit.
double scanAngle_deg_highE
scanning angle step in [deg] for high energy events
Auxiliary class to extract a subset of optical modules from a detector.
double scanAngle_deg_lowE
scanning angle step in [deg] for low energy events
double DMin_m
radius of the hit selection for high energy events (used to speedup the code)
Data structure for fit of straight line in positive z-direction with energy.
Definition: JShower3EZ.hh:28
Detector file.
Definition: JHead.hh:224
JRegressor< JShower3EZ, JGandalf > JRegressor_t
JDirection3D getDirection(const Vec &dir)
Get direction.
Data structure for vector in three dimensions.
Definition: JVector3D.hh:34
double MaxAngle_deg_highE
maximum scanning angle in [deg] for high energy events
set_variable E_E log10(E_{fit}/E_{#mu})"
static const int JSHOWERDIRECTIONPREFIT
int getID() const
Get identifier.
Definition: JObjectID.hh:50
JShowerDirectionPrefit(const JShowerDirectionPrefitParameters_t &parameters, const JModuleRouter &router, const JSummaryRouter &summary, const std::string pdfFile, const int debug=0)
Parameterized constructor.
JPosition3D getPosition(const Vec &pos)
Get position.
Definition of hit and track types and auxiliary methods for handling Monte Carlo data.
Data time slice.
JAxis3D & rotate_back(const JRotation3D &R)
Rotate back axis.
Definition: JAxis3D.hh:240
static const double PI
Mathematical constants.
int debug
debug level
Definition: JSirene.cc:63
Router for fast addressing of summary data in KM3NETDAQ::JDAQSummaryslice data structure as a functio...
const JPMT & getPMT(const int index) const
Get PMT.
Definition: JModule.hh:173
void rotate(const JRotation3D &R)
Rotate module.
Definition: JModule.hh:315
then usage $script[distance] fi case set_variable R
Definition: JDrawLED.sh:43
Detector subset without binary search functionality.
Fit method based on the Levenberg-Marquardt method.
Definition: JGandalf.hh:52
JFit getFit(const JHistory &history, const JTrack3D &track, const double Q, const int NDF, const double energy=0.0, const int status=0)
Get fit.
Reduced data structure for L1 hit.
Regressor function object for JShower3EZ fit using JGandalf minimiser.
JFIT::JHistory JHistory
Definition: JHistory.hh:301
const JClass_t & getReference() const
Get reference to object.
Definition: JReference.hh:38
Data structure for set of track fit results.
Simple fit method based on Powell&#39;s algorithm, see reference: Numerical Recipes in C++...
Definition: JSimplex.hh:42
static parameter_type pDY()
Definition: JShower3Z.hh:172
int getCount(const T &hit)
Get hit count.
Data regression method for JFIT::JShower3EZ.
static double Vmax_npe
Maximal integral of PDF [npe].
Data structure for fit of energy.
Definition: JEnergy.hh:28
static JTimeRange T_ns
Time window with respect to Cherenkov hypothesis [ns].
static int MAXIMUM_ITERATIONS
maximal number of iterations
Definition: JGandalf.hh:280
JMEstimator * getMEstimator(const int type)
Get M-Estimator.
Definition: JMEstimator.hh:166
Template specialisation of class JModel to match hit with bright point.
Definition: JFit/JModel.hh:121
Data structure for normalised vector in positive z-direction.
Definition: JVersor3Z.hh:39
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:42
double TMin_ns
minimum time for local coincidences [ns]
JVector3D & add(const JVector3D &vector)
Add vector.
Definition: JVector3D.hh:142
Match operator for Cherenkov light from shower in any direction.
Basic data structure for L1 hit.