Jpp  18.1.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JShowerPointSimplex.hh
Go to the documentation of this file.
1 #ifndef JSHOWERPOINTSIMPLEX_INCLUDE
2 #define JSHOWERPOINTSIMPLEX_INCLUDE
3 
4 #include <string>
5 #include <iostream>
6 #include <set>
7 #include <vector>
8 #include <algorithm>
9 #include <memory>
10 #include <math.h>
11 
14 
15 #include "JTrigger/JHit.hh"
16 #include "JTrigger/JTimeslice.hh"
17 #include "JTrigger/JHitR1.hh"
18 #include "JTrigger/JBuildL0.hh"
19 #include "JTrigger/JBuildL2.hh"
20 #include "JTrigger/JAlgorithm.hh"
21 #include "JTrigger/JMatch3G.hh"
22 #include "JTrigger/JBind2nd.hh"
23 
24 #include "JFit/JFitToolkit.hh"
25 #include "JFit/JEstimator.hh"
26 #include "JFit/JPoint4D.hh"
27 #include "JFit/JModel.hh"
28 #include "JFit/JSimplex.hh"
30 
31 #include "JReconstruction/JEvt.hh"
34 
35 #include "JLang/JPredicate.hh"
36 
37 #include "JGeometry3D/JVector3D.hh"
38 #include "JGeometry3D/JShower3D.hh"
39 #include "JGeometry3D/JShower3E.hh"
40 #include "JGeometry3D/JTrack3D.hh"
41 #include "JGeometry3D/JTrack3E.hh"
43 
45 #include "JDetector/JDetector.hh"
47 
48 #include "JTools/JPermutation.hh"
49 #include "JTools/JRange.hh"
50 
51 /**
52  * \author adomi
53  */
54 namespace JRECONSTRUCTION {}
55 namespace JPP { using namespace JRECONSTRUCTION; }
56 
57 namespace JRECONSTRUCTION {
58 
60  using JFIT::JPoint4D;
61  using JFIT::JSimplex;
62  using JFIT::JRegressor;
63 
64  /**
65  * class to handle the second position fit of the shower reconstruction, mainly dedicated for ORCA
66  */
68 
70  public JRegressor<JPoint4D, JSimplex>
71 
72  {
73 
75  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.
85  * \param router module router, this is built via detector file.
86  * \param debug debug
87  */
89  const JModuleRouter& router,
90  const int debug = 0):
92  JRegressor_t(parameters.sigma_ns),
93  router(router)
94  {
95  using namespace JPP;
96 
99 
100  this->estimator.reset(new JMEstimatorTukey(tukey_std_dev));
101  }
102 
103  /**
104  * Declaration of the member function that actually performs the reconstruction
105  *
106  * \param event which is a JDAQEvent
107  * \param in input fits
108  */
110  {
111  using namespace std;
112  using namespace JPP;
113 
114  const JBuildL0<hit_type> buildL0;
116 
117  buffer_type dataL0;
118  buffer_type dataL1;
119 
120  JEvt out;
121 
122  buildL0(JDAQTimeslice(event, true), router, back_inserter(dataL0));
123  buildL2(JDAQTimeslice(event, false), router, back_inserter(dataL1)); // false = triggered
124 
125  for (JEvt::const_iterator shower = in.begin(); shower != in.end(); ++shower) {
126 
127  JPoint4D vx(getPosition(*shower), shower->getT());
128 
130 
131  data.reserve(dataL0.size() + dataL1.size());
132 
134 
135  JRange<double> posGrid_m(0, 0);
136  JTimeRange timeGrid_ns(0, 0);
137 
138  /*
139  * part to help the reco of events with few hits:
140  * in this case a bigger time window in the hit selection and
141  * a grid in position and time are considered.
142  */
143  if(in.size() <= minPrefitsSize){
144 
146 
147  posGrid_m = pos_grid_m;
148  timeGrid_ns = time_grid_ns;
149  }
150 
151  for (buffer_type::const_iterator i = dataL1.begin(); i != dataL1.end(); ++i) {
152 
153  if (match(*i)) {
154  data.push_back(*i);
155  }
156  }
157 
158  buffer_type::iterator __end = data.end();
159 
160  for (buffer_type::const_iterator i = dataL0.begin(); i != dataL0.end(); ++i) {
161  if (find_if(data.begin(), __end, make_predicate(&hit_type::getModuleID, i->getModuleID())) == __end) {
162  if (match(*i)) {
163  data.push_back(*i);
164  }
165  }
166  }
167 
168  const int NDF = getCount(data.begin(), data.end()) - this->step.size();
169 
170  if (NDF > 0) {
171 
172  for(double x = posGrid_m.getLowerLimit(); x <= posGrid_m.getUpperLimit(); x += pos_step_m){
173  for(double y = posGrid_m.getLowerLimit(); y <= posGrid_m.getUpperLimit(); y += pos_step_m){
174  for(double z = posGrid_m.getLowerLimit(); z <= posGrid_m.getUpperLimit(); z += pos_step_m){
175  for(double t = timeGrid_ns.getLowerLimit(); t <= timeGrid_ns.getUpperLimit(); t += time_step_ns){
176 
177  JPoint4D vxs(JVector3D(vx.getX() + x, vx.getY() + y, vx.getZ() + z), vx.getT() + t);
178 
179  this->step.resize(4);
180  this->step[0] = JPoint4D(JVector3D(simplex_step_m, 0.0, 0.0), 0.0);
181  this->step[1] = JPoint4D(JVector3D(0.0, simplex_step_m, 0.0), 0.0);
182  this->step[2] = JPoint4D(JVector3D(0.0, 0.0, simplex_step_m), 0.0);
183  this->step[3] = JPoint4D(JVector3D(), simplex_step_ns);
184 
185  double chi2 = (*this)(vxs, data.begin(), data.end());
186 
187  JShower3E sh_fit(this->value.getPosition(), JDirection3D(),
188  this->value.getT(), shower->getE());
189 
190  out.push_back(getFit(JHistory(shower->getHistory()).add(JSHOWERPOINTSIMPLEX), sh_fit,
191  getQuality(chi2, NDF), NDF, sh_fit.getE()));
192 
193  }
194  }
195  }
196  }
197  }
198  }
199  return out;
200  }
202  };
203 }
204 #endif
205 
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
class to handle the second position fit of the shower reconstruction, mainly dedicated for ORCA ...
Linear fit methods.
JPredicate< JResult_t T::*, JComparison::eq > make_predicate(JResult_t T::*member, const JResult_t value)
Helper method to create predicate for data member.
Definition: JPredicate.hh:128
T getLowerLimit() const
Get lower limit.
Definition: JRange.hh:202
int getModuleID() const
Get module identifier.
Data structure for direction in three dimensions.
Definition: JDirection3D.hh:33
double getQuality(const double chi2, const int NDF)
Get quality of fit.
Algorithms for hit clustering and sorting.
Data structure for vertex fit.
Definition: JPoint4D.hh:22
JRange_t pos_grid_m
edges in [m] of the position grid
Router for direct addressing of module data in detector data structure.
static const int JSHOWERPOINTSIMPLEX
*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
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.
JRange_t TWindow_ns
time window for local coincidences [ns] for events with few prefits
JRegressor< JPoint4D, JSimplex > JRegressor_t
Auxiliary class to extract a subset of optical modules from a detector.
JEvt operator()(const KM3NETDAQ::JDAQEvent &event, const JFIT::JEvt &in)
Declaration of the member function that actually performs the reconstruction.
Template L2 builder.
Definition: JBuildL2.hh:45
Regressor function object for JPoint4D fit using JSimplex minimiser.
Data structure for vector in three dimensions.
Definition: JVector3D.hh:34
double TMaxLocal_ns
time window for local coincidences [ns]
JPosition3D getPosition(const Vec &pos)
Get position.
T getUpperLimit() const
Get upper limit.
Definition: JRange.hh:213
Data time slice.
double simplex_step_ns
step in [ns] of JSimplex minimiser
JShowerPointSimplex(const JShowerPointSimplexParameters_t &parameters, const JModuleRouter &router, const int debug=0)
Parameterized constructor.
Direct access to module in detector data structure.
Data structure for L2 parameters.
Reduced data structure for L1 hit.
JFIT::JHistory JHistory
Definition: JHistory.hh:354
double TMax_ns
maximum time for local coincidences [ns]
Data structure for set of track fit results.
JFit getFit(const int id, const JMODEL::JString &string)
Get fit parameters of string.
Auxiliary class to define a range between two values.
Simple fit method based on Powell&#39;s algorithm, see reference: Numerical Recipes in C++...
Definition: JSimplex.hh:42
size_t minPrefitsSize
number of prefits under which an event is treated as a very low energy one
then if[[!-f $DETECTOR]] then JDetector sh $DETECTOR fi cat $WORKDIR trigger_parameters txt<< EOFtrigger3DMuon.enabled=1;trigger3DMuon.numberOfHits=5;trigger3DMuon.gridAngle_deg=1;ctMin=0.0;TMaxLocal_ns=15.0;EOF set_variable TRIGGEREFFICIENCY_TRIGGERED_EVENTS_ONLY INPUT_FILES=() for((i=1;$i<=$NUMBER_OF_RUNS;++i));do JSirene.sh $DETECTOR $JPP_DATA/genhen.km3net_wpd_V2_0.evt.gz $WORKDIR/sirene_ ${i}.root JTriggerEfficiency.sh $DETECTOR $DETECTOR $WORKDIR/sirene_ ${i}.root $WORKDIR/trigger_efficiency_ ${i}.root $WORKDIR/trigger_parameters.txt $JPP_DATA/PMT_parameters.txt INPUT_FILES+=($WORKDIR/trigger_efficiency_ ${i}.root) done for ANGLE_DEG in $ANGLES_DEG[*];do set_variable SIGMA_NS 3.0 set_variable OUTLIERS 3 set_variable OUTPUT_FILE $WORKDIR/matrix\[${ANGLE_DEG}\deg\].root $JPP_DIR/examples/JReconstruction-f"$INPUT_FILES[*]"-o $OUTPUT_FILE-S ${SIGMA_NS}-A ${ANGLE_DEG}-O ${OUTLIERS}-d ${DEBUG}--!fiif[[$OPTION=="plot"]];then if((0));then for H1 in h0 h1;do JPlot1D-f"$WORKDIR/matrix["${^ANGLES_DEG}" deg].root:${H1}"-y"1 2e3"-Y-L TR-T""-\^"number of events [a.u.]"-> o chi2
Definition: JMatrixNZ.sh:106
int getCount(const T &hit)
Get hit count.
Reduced data structure for L1 hit.
Definition: JHitR1.hh:31
static int MAXIMUM_ITERATIONS
maximal number of iterations
Definition: JSimplex.hh:237
double TMin_ns
minimum time for local coincidences [ns]
Template L0 hit builder.
Definition: JBuildL0.hh:35
double tukey_std_dev
standard deviation of Tukey estimator
double ctMin
minimal cosine space angle between PMT axes
Template specialisation of class JModel to match hit with bright point.
Definition: JFit/JModel.hh:121
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 JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46
Tukey&#39;s biweight M-estimator.
Definition: JMEstimator.hh:105
Match operator for Cherenkov light from shower in any direction.
int debug
debug level
JTOOLS::JRange< double > JTimeRange
Type definition for time range (unit [s]).