Jpp
 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 "JGeometry3D/JVector3D.hh"
36 #include "JGeometry3D/JShower3D.hh"
37 #include "JGeometry3D/JShower3E.hh"
38 #include "JGeometry3D/JTrack3D.hh"
39 #include "JGeometry3D/JTrack3E.hh"
41 
43 #include "JDetector/JDetector.hh"
45 
46 #include "JTools/JPermutation.hh"
47 #include "JTools/JRange.hh"
48 #include "JLang/JSharedPointer.hh"
49 
50 /**
51  * \author adomi
52  */
53 namespace JRECONSTRUCTION {}
54 namespace JPP { using namespace JRECONSTRUCTION; }
55 
56 namespace JRECONSTRUCTION {
57 
59  using JFIT::JPoint4D;
60  using JFIT::JSimplex;
61  using JFIT::JRegressor;
62 
63  /**
64  * class to handle the second position fit of the shower reconstruction, mainly dedicated for ORCA
65  */
67 
69  public JRegressor<JPoint4D, JSimplex>
70 
71  {
72 
74  using JRegressor_t::operator();
77 
78  public:
79 
80  /**
81  * Parameterized constructor
82  *
83  * \param parameters struct that holds default-optimized parameters for the reconstruction.
84  * \param router module router, this is built via detector file.
85  * \param debug debug
86  */
88  const JModuleRouter& router,
89  const int debug = 0):
91  JRegressor_t(parameters.sigma_ns),
92  router(router)
93  {
94  using namespace JPP;
95 
98 
99  this->estimator.reset(new JMEstimatorTukey(tukey_std_dev));
100  }
101 
102  /**
103  * Declaration of the member function that actually performs the reconstruction
104  *
105  * \param event which is a JDAQEvent
106  * \param in input fits
107  */
109  {
110  using namespace std;
111  using namespace JPP;
112 
113  const JBuildL0<hit_type> buildL0;
115 
116  buffer_type dataL0;
117  buffer_type dataL1;
118 
119  JEvt out;
120 
121  buildL0(JDAQTimeslice(event, true), router, back_inserter(dataL0));
122  buildL2(JDAQTimeslice(event, false), router, back_inserter(dataL1)); // false = triggered
123 
124  for (JEvt::const_iterator shower = in.begin(); shower != in.end(); ++shower) {
125 
126  JPoint4D vx(getPosition(*shower), shower->getT());
127 
128  buffer_type data;
129 
130  data.reserve(dataL0.size() + dataL1.size());
131 
133 
134  JRange<double> posGrid_m(0, 0);
135  JTimeRange timeGrid_ns(0, 0);
136 
137  /*
138  * part to help the reco of events with few hits:
139  * in this case a bigger time window in the hit selection and
140  * a grid in position and time are considered.
141  */
142  if(in.size() <= minPrefitsSize){
143 
145 
146  posGrid_m = pos_grid_m;
147  timeGrid_ns = time_grid_ns;
148  }
149 
150  for (buffer_type::const_iterator i = dataL1.begin(); i != dataL1.end(); ++i) {
151 
152  if (match(*i)) {
153  data.push_back(*i);
154  }
155  }
156 
157  buffer_type::iterator __end = data.end();
158 
159  for (buffer_type::const_iterator i = dataL0.begin(); i != dataL0.end(); ++i) {
160 
161  if (find_if(data.begin(), __end, bind2nd(equal_to<JDAQModuleIdentifier>(), i->getModuleID())) == __end) {
162 
163  if (match(*i)) {
164  data.push_back(*i);
165  }
166  }
167  }
168 
169  const int NDF = getCount(data.begin(), data.end()) - this->step.size();
170 
171  if (NDF > 0) {
172 
173  for(double x = posGrid_m.getLowerLimit(); x <= posGrid_m.getUpperLimit(); x += pos_step_m){
174  for(double y = posGrid_m.getLowerLimit(); y <= posGrid_m.getUpperLimit(); y += pos_step_m){
175  for(double z = posGrid_m.getLowerLimit(); z <= posGrid_m.getUpperLimit(); z += pos_step_m){
176  for(double t = timeGrid_ns.getLowerLimit(); t <= timeGrid_ns.getUpperLimit(); t += time_step_ns){
177 
178  JPoint4D vxs(JVector3D(vx.getX() + x, vx.getY() + y, vx.getZ() + z), vx.getT() + t);
179 
180  this->step.resize(4);
181  this->step[0] = JPoint4D(JVector3D(simplex_step_m, 0.0, 0.0), 0.0);
182  this->step[1] = JPoint4D(JVector3D(0.0, simplex_step_m, 0.0), 0.0);
183  this->step[2] = JPoint4D(JVector3D(0.0, 0.0, simplex_step_m), 0.0);
184  this->step[3] = JPoint4D(JVector3D(), simplex_step_ns);
185 
186  double chi2 = (*this)(vxs, data.begin(), data.end());
187 
188  JShower3E sh_fit(this->value.getPosition(), JDirection3D(),
189  this->value.getT(), shower->getE());
190 
191  out.push_back(getFit(JHistory(shower->getHistory()).add(JSHOWERPOINTSIMPLEX), sh_fit,
192  getQuality(chi2, NDF), NDF, sh_fit.getE()));
193 
194  }
195  }
196  }
197  }
198  }
199  }
200  return out;
201  }
203  };
204 }
205 #endif
206 
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.
T getLowerLimit() const
Get lower limit.
Definition: JRange.hh:215
Data structure for direction in three dimensions.
Definition: JDirection3D.hh:32
Algorithms for hit clustering and sorting.
Data structure for vertex fit.
Definition: JPoint4D.hh:22
Router for direct addressing of module data in detector data structure.
static const int JSHOWERPOINTSIMPLEX
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition: JSirene.sh:45
*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:29
Data structure for detector geometry and calibration.
double getQuality(const double chi2, const int N, const int NDF)
Get quality of fit.
Definition: JEvtToolkit.hh:206
JRange< double > JTimeRange
Type definition for time range.
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:33
T getUpperLimit() const
Get upper limit.
Definition: JRange.hh:226
Data time slice.
int debug
debug level
Definition: JSirene.cc:61
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.
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.
Definition: JEvtToolkit.hh:126
Reduced data structure for L1 hit.
JFIT::JHistory JHistory
Definition: JHistory.hh:283
Data structure for set of track fit results.
Definition: JEvt.hh:294
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
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
Template L0 hit builder.
Definition: JBuildL0.hh:35
Template specialisation of class JModel to match hit with bright point.
Definition: JFit/JModel.hh:121
Tukey&#39;s biweight M-estimator.
Definition: JMEstimator.hh:105
Match operator for Cherenkov light from shower in any direction.
JPosition3D getPosition(const Vec &v)
Get position.