Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Member Functions | Static Public Member Functions | Private Types | Private Attributes | List of all members
JFIT::JORCAShowerFit Class Reference

class to handle the third step of the shower reconstruction, mainly dedicated for ORCA More...

#include <JORCAShowerFit.hh>

Classes

struct  JShowerHypothesis
 Container of shower hypothesis: During the fit the algorithm creates a grid in direction and energy space, for each of these points a shower hypothesis is saved: direction, energy and LogLikelihood value. More...
 

Public Member Functions

 JORCAShowerFit ()
 Default constructor. More...
 
 JORCAShowerFit (const JLANG::JSharedPointer< const JDETECTOR::JModuleRouter > &moduleRouter, const JFIT::JShowerFitParameters_t &parameters, const std::string pdfFile)
 Parameterized constructor. More...
 
 ~JORCAShowerFit ()
 
void getJEvt (const KM3NETDAQ::JDAQTimeslice &timeSliceBuildL0, JFIT::JEvt &InPreFits, JFIT::JEvt &OutFits) const
 Declaration of the member function that actually performs the reconstruction. More...
 

Static Public Member Functions

static bool sortLogLik (JShowerHypothesis A, JShowerHypothesis B)
 Function to sort different shower hypotheses by their likelihood. More...
 

Private Types

typedef JFIT::JRegressor
< JFIT::JShower3EZ,
JFIT::JSimplex
JRegressor_t
 

Private Attributes

JRegressor_t fit_
 
JLANG::JSharedPointer< const
JDETECTOR::JModuleRouter
moduleRouter_
 
JFIT::JShowerFitParameters_t parameters_
 

Detailed Description

class to handle the third step of the shower reconstruction, mainly dedicated for ORCA

Definition at line 57 of file JORCAShowerFit.hh.

Member Typedef Documentation

Definition at line 61 of file JORCAShowerFit.hh.

Constructor & Destructor Documentation

JFIT::JORCAShowerFit::JORCAShowerFit ( )
inline

Default constructor.

Definition at line 72 of file JORCAShowerFit.hh.

73  {}
JFIT::JORCAShowerFit::JORCAShowerFit ( const JLANG::JSharedPointer< const JDETECTOR::JModuleRouter > &  moduleRouter,
const JFIT::JShowerFitParameters_t parameters,
const std::string  pdfFile 
)
inline

Parameterized constructor.

Parameters
moduleRouterJSharedPointer of JModuleRouter, this is built via detector file.
parametersstruct that holds default-optimized parameters for the reconstruction, which can be found in $JPP_DATA.
pdfFilePDF file

Definition at line 83 of file JORCAShowerFit.hh.

85  :
86  moduleRouter_(moduleRouter),
87  parameters_(parameters)
88  {
90  JRegressor_t::T_ns.setRange(-parameters.Tmax_ns,parameters.Tmax_ns);
91  JRegressor_t::Vmax_npe = 20.0;
92  JRegressor_t::MAXIMUM_ITERATIONS = 1000;
93 
94  fit_ = {pdfFile};
95  }
JLANG::JSharedPointer< const JDETECTOR::JModuleRouter > moduleRouter_
JFIT::JShowerFitParameters_t parameters_
int debug
debug level
Definition: JSirene.cc:59
JFIT::JORCAShowerFit::~JORCAShowerFit ( )
inline

Definition at line 97 of file JORCAShowerFit.hh.

97 {}

Member Function Documentation

static bool JFIT::JORCAShowerFit::sortLogLik ( JShowerHypothesis  A,
JShowerHypothesis  B 
)
inlinestatic

Function to sort different shower hypotheses by their likelihood.

Definition at line 117 of file JORCAShowerFit.hh.

118  {
119  return(A.LogLik < B.LogLik);
120  };
void JFIT::JORCAShowerFit::getJEvt ( const KM3NETDAQ::JDAQTimeslice timeSliceBuildL0,
JFIT::JEvt InPreFits,
JFIT::JEvt OutFits 
) const

Declaration of the member function that actually performs the reconstruction.

member function definition

Parameters
timeSliceBuildL0which is contructed via a JDAQEvent
InPreFitsinput fits, normally produced by JORCAShowerPositionFit
OutFitsoutput fits

Definition at line 144 of file JORCAShowerFit.hh.

147 {
148  using JFIT::JShower3EZ;
149  using JFIT::JPoint4D;
150  using JFIT::JVersor3Z;
152 
153  const double Dmax_m = parameters_.Dmax_m;
154  const double R_Hz = parameters_.R_Hz;
155  const std::size_t numberOfPrefits = parameters_.numberOfPrefits;
156 
157  if ( InPreFits.empty() ) return;
158 
159  typedef std::vector<JTRIGGER::JHitL0> JDataL0_t;
160  typedef std::vector<JFIT::JPMTW0> JPMTW0_t;
162 
163  const JDETECTOR::JDetector &detector = moduleRouter_->getReference();
164 
165  JEvt::iterator __end = InPreFits.end();
166  std::copy(InPreFits.begin(), __end, std::back_inserter(OutFits));
167 
168  if (numberOfPrefits > 0) {
169  std::advance(__end = InPreFits.begin(), std::min(numberOfPrefits, InPreFits.size()));
170  }
171 
172  std::partial_sort(InPreFits.begin(), __end, InPreFits.end(), qualitySorter);
173 
174  JDataL0_t dataL0;
175  buildL0(timeSliceBuildL0, *moduleRouter_, std::back_inserter(dataL0));
176 
177  for (JEvt::const_iterator shower = InPreFits.begin(); shower != __end; ++shower) {
178  const JVector3D pos(getPosition(*shower)); //.rotate(R));
179 
180  JFIT::JPoint4D pt(pos, shower->getT());
181  JVector3D start_dir(0,0,0);
182 
183  const JVector3D DetC(0.0, 0.0, 117);
184  const double radius = pos.getDistance(DetC);
185 
187 
188  double Nhits = 0;
189 
190  for (JDataL0_t::const_iterator i = dataL0.begin(); i != dataL0.end(); ++i) {
191 
192  const JFIT::JHitW0 hit(*i, R_Hz);
193  const JGEOMETRY3D::JPosition3D hit_pos(hit.getPosition());
194 
195  const double D = hit_pos.getDistance(pt.getPosition());
196  const double t_res = hit.getT() - pt.getT(hit_pos);
197 
198  const JGEOMETRY3D::JDirection3D photonDir(hit_pos - pt.getPosition());
199  const double cosT = photonDir.getDot(hit.getDirection());
200 
201  if(D < Dmax_m && (t_res >= -25 && t_res <= 25) && (cosT >= -1 && cosT <= 0.1)){
202  top.insert(hit.getPMTIdentifier());
203  const JVector3D d(photonDir.getDX(), photonDir.getDY(), photonDir.getDZ());
204  start_dir.add(d);
205  }
206  if(D < Dmax_m && (t_res > -30 && t_res < 20)){
207  Nhits++;
208  }
209  }
210 
211  double start_E = exp((Nhits + 26)/26);
212  if(start_E > 100) start_E = 100;
213 
214  JFIT::JORCAShowerFit::JShowerHypothesis shower_hypothesis;
216 
218  double chi2 = 0.0;
219  double max_theta = 0, max_phi = 0, scan_step = 0;
220  double Nmin = 0;
221 
222  if(start_E > 10 && radius < 100){
223  max_theta = 30;
224  max_phi = 30;
225  scan_step = 5;
226  Nmin = 10;
227  } else {
228  max_theta = 35;
229  max_phi = 35;
230  scan_step = 5;
231  Nmin = 20;
232  }
233 
234  const JGEOMETRY3D::JAngle3D start_dir_angles(start_dir.getX(), start_dir.getY(), start_dir.getZ());
235 
236  for(double E = -15; E <= 5; E += 7.5){ // scan in energy
237  for(double th = -max_theta; th <= max_theta; th += scan_step){
238  for(double ph = -max_phi; ph <= max_phi; ph += scan_step){
239 
240  buffer.clear();
241  chi2 = 0.0;
242 
243  //todo: use precise value of pi
244  const double theta = th * JTOOLS::PI / 180;
245  const double phi = ph * JTOOLS::PI / 180;
246  const double scan_E = start_E + E; // [GeV]
247 
248  const JGEOMETRY3D::JAngle3D dir_shifted_angles(start_dir_angles.getTheta() + theta,
249  start_dir_angles.getPhi() + phi);
250  const JVector3D dir_shifted(dir_shifted_angles.getDX(),
251  dir_shifted_angles.getDY(),
252  dir_shifted_angles.getDZ());
253  const JGEOMETRY3D::JDirection3D conversion(dir_shifted.getX(),
254  dir_shifted.getY(),
255  dir_shifted.getZ());
256  const JGEOMETRY3D::JRotation3D R(conversion);
257  pt.rotate(R);
258 
259  for (JDETECTOR::JDetector::const_iterator module = detector.begin();
260  module != detector.end(); ++module) {
261 
262  JGEOMETRY3D::JPosition3D pos(module->getPosition());
263  pos.rotate(R);
264 
265  if (pt.getDistance(pos) < Dmax_m) {
266  for (unsigned int i = 0; i != module->size(); ++i) {
267  const KM3NETDAQ::JDAQPMTIdentifier id(module->getID(), i);
268  JDETECTOR::JPMT pmt(module->getPMT(i));
269  pmt.rotate(R);
270  buffer.push_back(JPMTW0(pmt, R_Hz, top.count(id)));
271  }
272  }
273  }
274 
275  for(JPMTW0_t::iterator pmt = buffer.begin(); pmt != buffer.end(); ++pmt ){
276  chi2 += fit_(JShower3EZ(pt, JVersor3Z(), JEnergy(log10(scan_E))), *pmt);
277  }
278 
279  shower_hypothesis.LogLik = chi2;
280  shower_hypothesis.Energy = scan_E;
281  shower_hypothesis.Direction = dir_shifted;
282 
283  shower_hypotheses.push_back(shower_hypothesis);
284 
285  pt.rotate_back(R);
286 
287  }
288  }
289  }
290 
291  std::vector<JShowerHypothesis>::iterator __end2 = shower_hypotheses.begin() + Nmin;
292  std::partial_sort(shower_hypotheses.begin(), __end2, shower_hypotheses.end(), sortLogLik);
293 
294  for(std::vector<JShowerHypothesis>::iterator hp = shower_hypotheses.begin(); hp != __end2; ++hp){
295 
296  fit_.step.resize(3);
297  const double dir_step = 0.05;
298  fit_.step[0] = JShower3EZ(JPoint4D(JVector3D(), 0.0), JVersor3Z(dir_step, 0.0), JFIT::JEnergy());
299  fit_.step[1] = JShower3EZ(JPoint4D(JVector3D(), 0.0), JVersor3Z(0.0, dir_step), JFIT::JEnergy());
300  fit_.step[2] = JShower3EZ(JPoint4D(JVector3D(), 0.0), JVersor3Z(), 0.05);
301 
302  const double scan_E = hp->Energy;
303 
304  buffer.clear();
305 
306  const JDirection3D startVersor(hp->Direction);
307 
308  const JGEOMETRY3D::JDirection3D conversion(startVersor.getDX(), startVersor.getDY(), startVersor.getDZ());
309  JGEOMETRY3D::JRotation3D R(conversion);
310  pt.rotate(R);
311 
312  for(JDETECTOR::JDetector::const_iterator module = detector.begin();
313  module != detector.end(); ++module) {
314  JPosition3D pos(module->getPosition());
315  pos.rotate(R);
316 
317  if (pt.getDistance(pos) < Dmax_m) {
318  for (unsigned int i = 0; i != module->size(); ++i) {
319  const KM3NETDAQ::JDAQPMTIdentifier id(module->getID(), i);
320  JDETECTOR::JPMT pmt(module->getPMT(i));
321  pmt.rotate(R);
322  buffer.push_back(JPMTW0(pmt, R_Hz, top.count(id)));
323  }
324  }
325  }
326 
327  const int NDF = buffer.size() - fit_.step.size();
328 
329  chi2 = fit_(JShower3EZ(pt, JVersor3Z(), JFIT::JEnergy(log10(scan_E))), buffer.begin(), buffer.end());
330 
331  pt.rotate_back(R);
332 
333  const JVector3D resPos(fit_.value);
334  const JVersor3D resDir(fit_.value.getDX(), fit_.value.getDY(), fit_.value.getDZ());
335 
336  const JGEOMETRY3D::JTrack3D td(resPos, resDir, shower->getT());
337  const double E_reco_corrected = fit_.value.getE() - 4;
338  JGEOMETRY3D::JTrack3E tb(td, E_reco_corrected);
339  tb.rotate_back(R);
340 
341  const JFIT::JFit &outFit = JFIT::getFit(JHistory(shower->getHistory()).add(JSHOWERCOMPLETEFIT),
342  tb, -chi2, NDF,
344 
345  OutFits.push_back(outFit);
346  OutFits.rbegin()->setE(E_reco_corrected);
347  }
348  }
349  std::sort(OutFits.begin(), OutFits.end(), qualitySorter);
350 }
Data structure for angles in three dimensions.
Definition: JAngle3D.hh:30
Data structure for direction in three dimensions.
Definition: JDirection3D.hh:32
Data structure for vertex fit.
Definition: JPoint4D.hh:22
Detector data structure.
Definition: JDetector.hh:77
Rotation matrix.
Definition: JRotation3D.hh:108
static const double PI
Constants.
Definition: JConstants.hh:20
JLANG::JSharedPointer< const JDETECTOR::JModuleRouter > moduleRouter_
double getDistance(const JVector3D &pos) const
Get distance to point.
Definition: JVector3D.hh:266
3D track with energy.
Definition: JTrack3E.hh:29
double getDot(const JAngle3D &angle) const
Get dot product.
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:116
Data structure for track fit results.
Definition: JEvt.hh:32
Data structure for fit of straight line in positive z-direction with energy.
Definition: JShower3EZ.hh:25
JAxis3D & rotate(const JRotation3D &R)
Rotate axis.
Definition: JAxis3D.hh:235
Data structure for vector in three dimensions.
Definition: JVector3D.hh:32
static bool sortLogLik(JShowerHypothesis A, JShowerHypothesis B)
Function to sort different shower hypotheses by their likelihood.
Data structure for PMT geometry and calibration.
Definition: JPMT.hh:52
Auxiliary class for a hit with background rate value.
Definition: JHitW0.hh:21
JFIT::JShowerFitParameters_t parameters_
counter_type advance(counter_type &counter, const counter_type value, const counter_type limit=std::numeric_limits< counter_type >::max())
Advance counter.
Definition: JCounter.hh:35
JPosition3D getPosition(const JFit &fit)
Get position.
Definition: JEvtToolkit.hh:63
const JClass_t & getReference() const
Get reference to object.
Definition: JReference.hh:38
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:40
Data structure for fit of energy.
Definition: JEnergy.hh:24
Data structure for position in three dimensions.
Definition: JPosition3D.hh:35
bool qualitySorter(const JFit &first, const JFit &second)
Comparison of fit results.
Definition: JEvtToolkit.hh:223
Template L0 hit builder.
Definition: JBuildL0.hh:35
Data structure for normalised vector in positive z-direction.
Definition: JVersor3Z.hh:36
JPosition3D & rotate(const JRotation3D &R)
Rotate.
Definition: JPosition3D.hh:185
Container of shower hypothesis: During the fit the algorithm creates a grid in direction and energy s...

Member Data Documentation

JRegressor_t JFIT::JORCAShowerFit::fit_
mutableprivate

Definition at line 62 of file JORCAShowerFit.hh.

JLANG::JSharedPointer<const JDETECTOR::JModuleRouter> JFIT::JORCAShowerFit::moduleRouter_
private

Definition at line 64 of file JORCAShowerFit.hh.

JFIT::JShowerFitParameters_t JFIT::JORCAShowerFit::parameters_
private

Definition at line 65 of file JORCAShowerFit.hh.


The documentation for this class was generated from the following file: