Jpp  18.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Functions
tools/reconstruction.hh File Reference

Auxiliary methods for selection of reconstructed tracks. More...

#include <limits>
#include <algorithm>
#include "km3net-dataformat/offline/Hit.hh"
#include "km3net-dataformat/offline/Vec.hh"
#include "km3net-dataformat/offline/Trk.hh"
#include "km3net-dataformat/offline/Evt.hh"
#include "km3net-dataformat/offline/Exception.hh"
#include "km3net-dataformat/definitions/reconstruction.hh"

Go to the source code of this file.

Classes

struct  rec_stages_range
 Range of reconstruction stages. More...
 
struct  quality_sorter< reconstruction_type >
 Reconstruction type dependent comparison of track quality. More...
 
struct  has_history
 Auxiliary class to test whether given track has specified history. More...
 

Functions

bool has_jppmuon_prefit (const Trk &track)
 Test whether given track has muon prefit in history. More...
 
bool has_jppmuon_simplex (const Trk &track)
 Test whether given track has muon simplex fit in history. More...
 
bool has_jppmuon_gandalf (const Trk &track)
 Test whether given track has muon gandalf fit in history. More...
 
bool has_jppmuon_energy (const Trk &track)
 Test whether given track has muon energy fit in history. More...
 
bool has_jppmuon_start (const Trk &track)
 Test whether given track has muon start fit in history. More...
 
bool has_jppmuon_fit (const Trk &track)
 Test whether given track has default muon fit in history. More...
 
bool has_shower_prefit (const Trk &track)
 Test whether given track has shower prefit in history. More...
 
bool has_shower_positionfit (const Trk &track)
 Test whether given track has shower position fit in history. More...
 
bool has_shower_completefit (const Trk &track)
 Test whether given track has shower complete fit in history. More...
 
bool has_shower_fit (const Trk &track)
 Test whether given track has default shower fit in history. More...
 
bool has_aashower_fit (const Trk &track)
 Test whether given track has default shower fit in history. More...
 
template<class JTrackSelector_t >
bool has_reconstructed_track (const Evt &evt, JTrackSelector_t selector)
 Test whether given event has a track according selection. More...
 
template<int reconstruction_type>
bool has_reconstructed_track (const Evt &evt, const rec_stages_range range=rec_stages_range())
 Test whether given event has a track according selection. More...
 
bool has_reconstructed_jppmuon (const Evt &evt)
 Test whether given event has a track with muon reconstruction. More...
 
bool has_reconstructed_jppshower (const Evt &evt)
 Test whether given event has a track with shower reconstruction. More...
 
bool has_reconstructed_aashower (const Evt &evt)
 Test whether given event has a track with aashower reconstruction. More...
 
template<class JTrackSelector_t , class JQualitySorter_t >
const Trkget_best_reconstructed_track (const Evt &evt, JTrackSelector_t selector, JQualitySorter_t comparator)
 Get best reconstructed track. More...
 
template<int reconstruction_type>
const Trkget_best_reconstructed_track (const Evt &evt, const rec_stages_range range=rec_stages_range())
 Get best reconstructed track. More...
 
const Trkget_best_reconstructed_jppmuon (const Evt &evt)
 Get best reconstructed muon. More...
 
const Trkget_best_reconstructed_jppshower (const Evt &evt)
 Get best reconstructed shower. More...
 
const Trkget_best_reconstructed_aashower (const Evt &evt)
 Get best reconstructed aashower. More...
 

Detailed Description

Auxiliary methods for selection of reconstructed tracks.

Author
mdejong

Definition in file tools/reconstruction.hh.

Function Documentation

bool has_jppmuon_prefit ( const Trk track)
inline

Test whether given track has muon prefit in history.

Parameters
tracktrack
Returns
true if muon prefit in history; else false

Definition at line 144 of file tools/reconstruction.hh.

145 {
147 }
bool has_history(const JFit &fit, const int type)
Test whether given fit has specified history.
static const int JMUONPREFIT
static const int JPP_RECONSTRUCTION_TYPE
KM3NeT Data Definitions v3.0.0-5-gcddadc1 https://git.km3net.de/common/km3net-dataformat.
bool has_jppmuon_simplex ( const Trk track)
inline

Test whether given track has muon simplex fit in history.

Parameters
tracktrack
Returns
true if muon simplex fit in history; else false

Definition at line 156 of file tools/reconstruction.hh.

157 {
159 }
bool has_history(const JFit &fit, const int type)
Test whether given fit has specified history.
static const int JMUONSIMPLEX
static const int JPP_RECONSTRUCTION_TYPE
KM3NeT Data Definitions v3.0.0-5-gcddadc1 https://git.km3net.de/common/km3net-dataformat.
bool has_jppmuon_gandalf ( const Trk track)
inline

Test whether given track has muon gandalf fit in history.

Parameters
tracktrack
Returns
true if muon gandalf fit in history; else false

Definition at line 168 of file tools/reconstruction.hh.

169 {
171 }
bool has_history(const JFit &fit, const int type)
Test whether given fit has specified history.
static const int JMUONGANDALF
static const int JPP_RECONSTRUCTION_TYPE
KM3NeT Data Definitions v3.0.0-5-gcddadc1 https://git.km3net.de/common/km3net-dataformat.
bool has_jppmuon_energy ( const Trk track)
inline

Test whether given track has muon energy fit in history.

Parameters
tracktrack
Returns
true if muon energy fit in history; else false

Definition at line 180 of file tools/reconstruction.hh.

181 {
183 }
bool has_history(const JFit &fit, const int type)
Test whether given fit has specified history.
static const int JPP_RECONSTRUCTION_TYPE
KM3NeT Data Definitions v3.0.0-5-gcddadc1 https://git.km3net.de/common/km3net-dataformat.
static const int JMUONENERGY
bool has_jppmuon_start ( const Trk track)
inline

Test whether given track has muon start fit in history.

Parameters
tracktrack
Returns
true if muon start fit in history; else false

Definition at line 192 of file tools/reconstruction.hh.

193 {
195 }
static const int JMUONSTART
bool has_history(const JFit &fit, const int type)
Test whether given fit has specified history.
static const int JPP_RECONSTRUCTION_TYPE
KM3NeT Data Definitions v3.0.0-5-gcddadc1 https://git.km3net.de/common/km3net-dataformat.
bool has_jppmuon_fit ( const Trk track)
inline

Test whether given track has default muon fit in history.

Parameters
tracktrack
Returns
true if muon fit in history; else false

Definition at line 204 of file tools/reconstruction.hh.

205 {
207 }
bool has_history(const JFit &fit, const int type)
Test whether given fit has specified history.
static const int JMUONBEGIN
begin range of reconstruction stages
Range of reconstruction stages.
static const int JPP_RECONSTRUCTION_TYPE
KM3NeT Data Definitions v3.0.0-5-gcddadc1 https://git.km3net.de/common/km3net-dataformat.
static const int JMUONEND
end range of reconstruction stages
bool has_shower_prefit ( const Trk track)
inline

Test whether given track has shower prefit in history.

Parameters
tracktrack
Returns
true if shower prefit in history; else false

Definition at line 216 of file tools/reconstruction.hh.

217 {
219 }
bool has_history(const JFit &fit, const int type)
Test whether given fit has specified history.
static const int JSHOWERPREFIT
static const int JPP_RECONSTRUCTION_TYPE
KM3NeT Data Definitions v3.0.0-5-gcddadc1 https://git.km3net.de/common/km3net-dataformat.
bool has_shower_positionfit ( const Trk track)
inline

Test whether given track has shower position fit in history.

Parameters
tracktrack
Returns
true if shower position fit in history; else false

Definition at line 228 of file tools/reconstruction.hh.

229 {
231 }
bool has_history(const JFit &fit, const int type)
Test whether given fit has specified history.
static const int JSHOWERPOSITIONFIT
static const int JPP_RECONSTRUCTION_TYPE
KM3NeT Data Definitions v3.0.0-5-gcddadc1 https://git.km3net.de/common/km3net-dataformat.
bool has_shower_completefit ( const Trk track)
inline

Test whether given track has shower complete fit in history.

Parameters
tracktrack
Returns
true if shower complete fit in history; else false

Definition at line 240 of file tools/reconstruction.hh.

241 {
243 }
bool has_history(const JFit &fit, const int type)
Test whether given fit has specified history.
static const int JSHOWERCOMPLETEFIT
static const int JPP_RECONSTRUCTION_TYPE
KM3NeT Data Definitions v3.0.0-5-gcddadc1 https://git.km3net.de/common/km3net-dataformat.
bool has_shower_fit ( const Trk track)
inline

Test whether given track has default shower fit in history.

Parameters
tracktrack
Returns
true if shower fit in history; else false

Definition at line 252 of file tools/reconstruction.hh.

253 {
255 }
static const int JSHOWEREND
end range of reconstruction stages
bool has_history(const JFit &fit, const int type)
Test whether given fit has specified history.
Range of reconstruction stages.
static const int JSHOWERBEGIN
begin range of reconstruction stages
static const int JPP_RECONSTRUCTION_TYPE
KM3NeT Data Definitions v3.0.0-5-gcddadc1 https://git.km3net.de/common/km3net-dataformat.
bool has_aashower_fit ( const Trk track)
inline

Test whether given track has default shower fit in history.

Parameters
tracktrack
Returns
true if shower fit in history; else false

Definition at line 264 of file tools/reconstruction.hh.

265 {
267 }
static const int AANET_RECONSTRUCTION_TYPE
aanet reconstruction type
bool has_history(const JFit &fit, const int type)
Test whether given fit has specified history.
Range of reconstruction stages.
template<class JTrackSelector_t >
bool has_reconstructed_track ( const Evt evt,
JTrackSelector_t  selector 
)
inline

Test whether given event has a track according selection.


The track selector corresponds to the function operator bool selector(const Trk&);.

Parameters
evtevent
selectortrack selector
Returns
true if at least one corresponding track; else false

Definition at line 279 of file tools/reconstruction.hh.

280 {
281  return std::find_if(evt.trks.begin(), evt.trks.end(), selector) != evt.trks.end();
282 }
std::vector< Trk > trks
list of reconstructed tracks (can be several because of prefits,showers, etc).
Definition: Evt.hh:39
template<int reconstruction_type>
bool has_reconstructed_track ( const Evt evt,
const rec_stages_range  range = rec_stages_range() 
)
inline

Test whether given event has a track according selection.

Parameters
evtevent
rangerange of application types
Returns
true if at least one corresponding track; else false

Definition at line 293 of file tools/reconstruction.hh.

294 {
295  return has_reconstructed_track(evt, has_history(reconstruction_type, range));
296 }
bool has_history(const JFit &fit, const int type)
Test whether given fit has specified history.
bool has_reconstructed_track(const JEvt &evt, JTrackSelector_t selector)
Test whether given event has a track according selection.
bool has_reconstructed_jppmuon ( const Evt evt)
inline

Test whether given event has a track with muon reconstruction.

Parameters
evtevent
Returns
true if at least one reconstructed muon; else false

Definition at line 305 of file tools/reconstruction.hh.

306 {
308 }
bool has_reconstructed_track(const JEvt &evt, JTrackSelector_t selector)
Test whether given event has a track according selection.
bool has_jppmuon_fit(const Trk &track)
Test whether given track has default muon fit in history.
bool has_reconstructed_jppshower ( const Evt evt)
inline

Test whether given event has a track with shower reconstruction.

Parameters
evtevent
Returns
true if at least one reconstructed shower; else false

Definition at line 317 of file tools/reconstruction.hh.

318 {
320 }
bool has_shower_fit(const Trk &track)
Test whether given track has default shower fit in history.
bool has_reconstructed_track(const JEvt &evt, JTrackSelector_t selector)
Test whether given event has a track according selection.
bool has_reconstructed_aashower ( const Evt evt)
inline

Test whether given event has a track with aashower reconstruction.

Parameters
evtevent
Returns
true if at least one reconstructed shower; else false

Definition at line 329 of file tools/reconstruction.hh.

330 {
332 }
bool has_aashower_fit(const Trk &track)
Test whether given track has default shower fit in history.
bool has_reconstructed_track(const JEvt &evt, JTrackSelector_t selector)
Test whether given event has a track according selection.
template<class JTrackSelector_t , class JQualitySorter_t >
const Trk& get_best_reconstructed_track ( const Evt evt,
JTrackSelector_t  selector,
JQualitySorter_t  comparator 
)
inline

Get best reconstructed track.


The track selector corresponds to the function operator bool selector(const Trk&); and the track comparator to bool comparator(const Trk&, const Trk&);.
This method throws an exception in case no track is present.
The method has_reconstructed_track can be used to avoid this exception.

Parameters
evtevent
selectortrack selector
comparatortrack comparator
Returns
track

Definition at line 348 of file tools/reconstruction.hh.

351 {
352  std::vector<Trk>::const_iterator p = std::find_if(evt.trks.begin(), evt.trks.end(), selector);
353 
354  for (std::vector<Trk>::const_iterator i = p; i != evt.trks.end(); ++i) {
355  if (selector(*i) && comparator(*i, *p)) {
356  p = i;
357  }
358  }
359 
360  if (p != evt.trks.end())
361  return *p;
362  else
363  THROW(Exception, "This event has no reconstructed track with given selector.");
364 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
std::vector< Trk > trks
list of reconstructed tracks (can be several because of prefits,showers, etc).
Definition: Evt.hh:39
General exception.
Definition: Exception.hh:13
template<int reconstruction_type>
const Trk& get_best_reconstructed_track ( const Evt evt,
const rec_stages_range  range = rec_stages_range() 
)
inline

Get best reconstructed track.

Parameters
evtevent
rangerange of application types
Returns
track

Definition at line 375 of file tools/reconstruction.hh.

376 {
377  return get_best_reconstructed_track(evt, has_history(reconstruction_type, range), quality_sorter<reconstruction_type>());
378 }
bool has_history(const JFit &fit, const int type)
Test whether given fit has specified history.
Reconstruction type dependent comparison of track quality.
const JFit & get_best_reconstructed_track(const JEvt &evt, JTrackSelector_t selector, JQualitySorter_t comparator)
Get best reconstructed track.
const Trk& get_best_reconstructed_jppmuon ( const Evt evt)
inline

Get best reconstructed muon.

Parameters
evtevent
Returns
track

Definition at line 387 of file tools/reconstruction.hh.

388 {
390 }
Reconstruction type dependent comparison of track quality.
const JFit & get_best_reconstructed_track(const JEvt &evt, JTrackSelector_t selector, JQualitySorter_t comparator)
Get best reconstructed track.
bool has_jppmuon_fit(const Trk &track)
Test whether given track has default muon fit in history.
const Trk& get_best_reconstructed_jppshower ( const Evt evt)
inline

Get best reconstructed shower.

Parameters
evtevent
Returns
track

Definition at line 399 of file tools/reconstruction.hh.

400 {
402 }
Reconstruction type dependent comparison of track quality.
bool has_shower_fit(const Trk &track)
Test whether given track has default shower fit in history.
const JFit & get_best_reconstructed_track(const JEvt &evt, JTrackSelector_t selector, JQualitySorter_t comparator)
Get best reconstructed track.
const Trk& get_best_reconstructed_aashower ( const Evt evt)
inline

Get best reconstructed aashower.

Parameters
evtevent
Returns
track

Definition at line 411 of file tools/reconstruction.hh.

412 {
414 }
Reconstruction type dependent comparison of track quality.
bool has_aashower_fit(const Trk &track)
Test whether given track has default shower fit in history.
const JFit & get_best_reconstructed_track(const JEvt &evt, JTrackSelector_t selector, JQualitySorter_t comparator)
Get best reconstructed track.