Jpp  18.2.1-ARCA-DF-PATCH
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Public Attributes | List of all members
Trk Struct Reference

The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower. More...

#include <Trk.hh>

Inheritance diagram for Trk:
AAObject TObject JSIRENE::JTrk_t

Public Member Functions

 Trk ()
 Default constructor. More...
 
void read (const Trk &t)
 Read track (useful in python). More...
 
void write (Trk &t) const
 Write track (useful in python). More...
 
std::string name () const
 Get the name of the MC particle type. More...
 
bool is_primary () const
 Check if this is a primary particle. More...
 
bool is_finalstate () const
 Test whether given particle is a final state inside the detector. More...
 
bool is_neutrino () const
 Check if this is a netrino. More...
 
bool is_e () const
 Check if this is an electron or positron. More...
 
bool is_muon () const
 Check if this is a muon. More...
 
bool is_tau () const
 Check if this is a tau. More...
 
bool is_lepton () const
 Check if this is a charged lepton. More...
 
bool is_orphan () const
 Check if this is an orphan (i.e. More...
 
std::vector< Trk * > get_daughters (std::vector< Trk > &mctrks)
 Get list of of pointers to tracks, all of which have their mother identifier set to identifier of this track. More...
 
void print (std::ostream &out=std::cout) const
 Print track. More...
 
int idx (const std::string &key) const
 Get index in user data of the item with given key. More...
 
bool haveusr (const std::string &key) const
 Check availability of user data of the item with given key. More...
 
int idxusr_checked (const std::string &key) const
 Get index in user data of the item with given key. More...
 
double getusr (const std::string &key) const
 Get user data item with given key. More...
 
void setusr (const std::string &key, double value)
 Set user data item with given key. More...
 
bool delusr (const std::string &key)
 Remove (first) user data item with given key. More...
 
void clearusr ()
 Clear user data. More...
 
void printusr (std::ostream &out=std::cout)
 Print user data (i.e. More...
 

Public Attributes

int id
 track identifier More...
 
Vec pos
 postion [m] of the track at time t More...
 
Vec dir
 track direction More...
 
double t
 track time [ns] (when the particle is at pos ) More...
 
double E
 Energy [GeV] (either MC truth or reconstructed) More...
 
double len
 length, if applicable [m] More...
 
double lik
 likelihood or lambda value (for aafit, lambda) More...
 
int type
 MC: particle type in PDG encoding. More...
 
int rec_type
 identifier of the fitting algorithm/chain/strategy, see km3net-dataformat/definitions/reconstruction.csv More...
 
std::vector< int > rec_stages
 list of identifyers of succesfull fitting stages resulting in this track More...
 
int status
 MC status code, see km3net-dataformat/definitions/trkmembers.csv for values. More...
 
int mother_id
 MC id of the parent particle. More...
 
int counter
 used by CORSIKA7 MC generation to store interaction counters, see CORSIKA Userguide More...
 
std::vector< double > fitinf
 place to store additional fit info, see km3net-dataformat/definitions/fitparameters.csv More...
 
std::vector< int > hit_ids
 list of associated hit-ids (corresponds to Hit::id). More...
 
std::vector< double > error_matrix
 (NxN) error covariance matrix for fit parameters (stored as linear vector) More...
 
std::string comment
 use as you like More...
 
std::vector< double > usr
 user data More...
 
std::vector< std::stringusr_names
 user keys More...
 
TObjectany
 Pointer to "any" user data. More...
 

Detailed Description

The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower.

Definition at line 14 of file Trk.hh.

Constructor & Destructor Documentation

Trk::Trk ( )
inline

Default constructor.

Definition at line 40 of file Trk.hh.

int counter
used by CORSIKA7 MC generation to store interaction counters, see CORSIKA Userguide ...
Definition: Trk.hh:30
double t
track time [ns] (when the particle is at pos )
Definition: Trk.hh:19
double E
Energy [GeV] (either MC truth or reconstructed)
Definition: Trk.hh:20
int mother_id
MC id of the parent particle.
Definition: Trk.hh:29
double len
length, if applicable [m]
Definition: Trk.hh:22
static const int TRK_ST_UNDEFINED
status was not defined for this MC track (all reco tracks have this value)
Definition: trkmembers.hh:14
static const int TRK_MOTHER_UNDEFINED
KM3NeT Data Definitions v3.2.0-2-gaaf0dd0 https://git.km3net.de/common/km3net-dataformat.
Definition: trkmembers.hh:12
int type
MC: particle type in PDG encoding.
Definition: Trk.hh:24
int id
track identifier
Definition: Trk.hh:16
int status
MC status code, see km3net-dataformat/definitions/trkmembers.csv for values.
Definition: Trk.hh:28
double lik
likelihood or lambda value (for aafit, lambda)
Definition: Trk.hh:23
int rec_type
identifier of the fitting algorithm/chain/strategy, see km3net-dataformat/definitions/reconstruction...
Definition: Trk.hh:25

Member Function Documentation

void Trk::read ( const Trk t)
inline

Read track (useful in python).

Parameters
ttrack

Definition at line 50 of file Trk.hh.

50 { *this = t;}
double t
track time [ns] (when the particle is at pos )
Definition: Trk.hh:19
void Trk::write ( Trk t) const
inline

Write track (useful in python).

Parameters
ttrack

Definition at line 57 of file Trk.hh.

57 { t = *this; }
std::string Trk::name ( ) const
inline

Get the name of the MC particle type.

Returns
name

Definition at line 65 of file Trk.hh.

66  {
67  TParticlePDG* p = TDatabasePDG::Instance()->GetParticle( type );
68  if (!p) return "unnamed state ("+ std::to_string(type)+")";
69  return p->GetName();
70  }
int type
MC: particle type in PDG encoding.
Definition: Trk.hh:24
std::string to_string(const T &value)
Convert value to string.
bool Trk::is_primary ( ) const
inline

Check if this is a primary particle.

Returns
true if primary; else false

Definition at line 77 of file Trk.hh.

78  {
80  }
static const int TRK_ST_PRIMARYNEUTRINO
initial state neutrino (&#39;neutrino&#39; tag in evt files from gseagen and genhen).
Definition: trkmembers.hh:16
static const int TRK_ST_PRIMARYCOSMIC
initial state cosmic ray (&#39;track_primary&#39; tag in evt files from corant).
Definition: trkmembers.hh:17
int status
MC status code, see km3net-dataformat/definitions/trkmembers.csv for values.
Definition: Trk.hh:28
bool Trk::is_finalstate ( ) const
inline

Test whether given particle is a final state inside the detector.

Parameters
tracktrack
Returns
true if particle is final state; else false

Definition at line 88 of file Trk.hh.

89  {
90  return status==TRK_ST_FINALSTATE;
91  }
int status
MC status code, see km3net-dataformat/definitions/trkmembers.csv for values.
Definition: Trk.hh:28
static const int TRK_ST_FINALSTATE
for MC: the particle must be processed by detector simulation (&#39;track_in&#39; tag in evt files)...
Definition: trkmembers.hh:15
bool Trk::is_neutrino ( ) const
inline

Check if this is a netrino.

Note that its is checked if the PDG type is a nu-e, nu-mu or nu-tau.

Returns
true if neutrino; else false

Definition at line 100 of file Trk.hh.

101  {
102  return type == kNuE || type == kNuEBar || type == kNuMu || type == kNuMuBar || type == kNuTau || type == kNuTauBar;
103  }
int type
MC: particle type in PDG encoding.
Definition: Trk.hh:24
bool Trk::is_e ( ) const
inline

Check if this is an electron or positron.

Returns
true if this is an electron or positron

Definition at line 110 of file Trk.hh.

111  {
112  return type == kElectron || type == kPositron;
113  }
int type
MC: particle type in PDG encoding.
Definition: Trk.hh:24
bool Trk::is_muon ( ) const
inline

Check if this is a muon.

Note that its is checked if the PDG type is a (anti-)muon.

Returns
true if muon; else false

Definition at line 122 of file Trk.hh.

123  {
124  return type == kMuonMinus || type == kMuonPlus;
125  }
int type
MC: particle type in PDG encoding.
Definition: Trk.hh:24
bool Trk::is_tau ( ) const
inline

Check if this is a tau.

Note that its is checked if the PDG type is a (anti-)tau.

Returns
true if tau; else false

Definition at line 134 of file Trk.hh.

135  {
136  return type == kTauMinus || type == kTauPlus;
137  }
int type
MC: particle type in PDG encoding.
Definition: Trk.hh:24
bool Trk::is_lepton ( ) const
inline

Check if this is a charged lepton.

Note that its is checked if the PDG type is a (anti-)electron, (anti-)muon or (anti-)tua.

Returns
true if charged lepton; else false

Definition at line 146 of file Trk.hh.

147  {
148  return is_e() || is_muon() || is_tau();
149  }
bool is_muon() const
Check if this is a muon.
Definition: Trk.hh:122
bool is_tau() const
Check if this is a tau.
Definition: Trk.hh:134
bool is_e() const
Check if this is an electron or positron.
Definition: Trk.hh:110
bool Trk::is_orphan ( ) const
inline

Check if this is an orphan (i.e.

no mother).

Returns
true if orphan; else false

Definition at line 156 of file Trk.hh.

157  {
158  return mother_id == TRK_MOTHER_NONE;
159  }
static const int TRK_MOTHER_NONE
mother id of a particle if it has no parent
Definition: trkmembers.hh:13
int mother_id
MC id of the parent particle.
Definition: Trk.hh:29
std::vector< Trk* > Trk::get_daughters ( std::vector< Trk > &  mctrks)
inline

Get list of of pointers to tracks, all of which have their mother identifier set to identifier of this track.

Parameters
mctrkslist of input tracks
Returns
list of pointers to tracks

Definition at line 167 of file Trk.hh.

168  {
170 
171  for( auto& t : mctrks )
172  {
173  if ( t.mother_id == id ) r.push_back( &t );
174  }
175  return r;
176  }
double t
track time [ns] (when the particle is at pos )
Definition: Trk.hh:19
data_type r[M+1]
Definition: JPolint.hh:868
void Trk::print ( std::ostream &  out = std::cout) const
inline

Print track.

Parameters
outoutput stream

Definition at line 183 of file Trk.hh.

184  {
185  out << "Trk: id=" << id << " pos="; pos.print(out);
186  out << " dir="; dir.print(out);
187  out << " t=" << t << " E=" << E << " pdg-type=" << type;
188  }
double t
track time [ns] (when the particle is at pos )
Definition: Trk.hh:19
Vec dir
track direction
Definition: Trk.hh:18
double E
Energy [GeV] (either MC truth or reconstructed)
Definition: Trk.hh:20
int type
MC: particle type in PDG encoding.
Definition: Trk.hh:24
Vec pos
postion [m] of the track at time t
Definition: Trk.hh:17
void print(std::ostream &out=std::cout) const
Print vector.
Definition: Vec.hh:166
int AAObject::idx ( const std::string key) const
inlineinherited

Get index in user data of the item with given key.

Parameters
keykey
Returns
index (-1 if key does not exists)

Definition at line 29 of file AAObject.hh.

30  {
31  auto i = std::find (usr_names.begin(), usr_names.end(), key );
32  if (i == usr_names.end()) return -1;
33  return i - usr_names.begin();
34  }
std::vector< std::string > usr_names
user keys
Definition: AAObject.hh:21
bool AAObject::haveusr ( const std::string key) const
inlineinherited

Check availability of user data of the item with given key.

Parameters
keykey
Returns
true if available; else false

Definition at line 42 of file AAObject.hh.

43  {
44  return idx( key ) >= 0;
45  }
int idx(const std::string &key) const
Get index in user data of the item with given key.
Definition: AAObject.hh:29
int AAObject::idxusr_checked ( const std::string key) const
inlineinherited

Get index in user data of the item with given key.


This method throws a run-time exception if no user data are available.

Parameters
keykey
Returns
index (-1 if key does not exists)

Definition at line 54 of file AAObject.hh.

55  {
56  int r = idx( key );
57  if (r < 0)
58  {
59  THROW(Exception, "No user data for key " << key << " in aanet object of type " << this -> ClassName());
60  }
61  return r;
62  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
data_type r[M+1]
Definition: JPolint.hh:868
int idx(const std::string &key) const
Get index in user data of the item with given key.
Definition: AAObject.hh:29
General exception.
Definition: Exception.hh:13
double AAObject::getusr ( const std::string key) const
inlineinherited

Get user data item with given key.


This method throws a run-time exception if no user data are available.

Parameters
keykey
Returns
value

Definition at line 72 of file AAObject.hh.

73  {
74  const int i = idx( key );
75 
76  if ( i < 0 )
77  {
78  THROW(Exception, "No user data for key " << key << " in aanet object of type " << this -> ClassName());
79  }
80 
81  if ( unsigned(i) >= usr.size() )
82  {
83  THROW(Exception, "Warning: inconsistent user data " << i << " >= " << usr.size());
84  }
85 
86  return usr[i];
87  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
int idx(const std::string &key) const
Get index in user data of the item with given key.
Definition: AAObject.hh:29
General exception.
Definition: Exception.hh:13
std::vector< double > usr
user data
Definition: AAObject.hh:20
void AAObject::setusr ( const std::string key,
double  value 
)
inlineinherited

Set user data item with given key.


Parameters
keykey
valuevalue

Definition at line 95 of file AAObject.hh.

96  {
97  int i = idx( key );
98  if (i < 0)
99  {
100  if ( usr.size() < usr_names.size() )
101  {
102  // this should not happen, but let's just add empty data
103  usr.resize( usr_names.size() );
104  }
105  else
106  {
107  // this is possible, add empty ("") names
108  usr_names.resize( usr.size() );
109  }
110 
111  usr_names.push_back( key );
112  usr.push_back( value );
113  }
114  else
115  {
116  usr[i] = value;
117  }
118  }
std::vector< std::string > usr_names
user keys
Definition: AAObject.hh:21
int idx(const std::string &key) const
Get index in user data of the item with given key.
Definition: AAObject.hh:29
std::vector< double > usr
user data
Definition: AAObject.hh:20
bool AAObject::delusr ( const std::string key)
inlineinherited

Remove (first) user data item with given key.


Parameters
keykey
Returns
true if data have been removed; else false

Definition at line 126 of file AAObject.hh.

127  {
128  int i = idx( key );
129  if ( i < 0 ) return false;
130 
131  usr.erase ( usr.begin() + i );
132  usr_names.erase( usr_names.begin() + i );
133  return true;
134  }
std::vector< std::string > usr_names
user keys
Definition: AAObject.hh:21
int idx(const std::string &key) const
Get index in user data of the item with given key.
Definition: AAObject.hh:29
std::vector< double > usr
user data
Definition: AAObject.hh:20
void AAObject::clearusr ( )
inlineinherited

Clear user data.

Definition at line 139 of file AAObject.hh.

140  {
141  usr.resize(0);
142  usr_names.resize(0);
143  }
std::vector< std::string > usr_names
user keys
Definition: AAObject.hh:21
std::vector< double > usr
user data
Definition: AAObject.hh:20
void AAObject::printusr ( std::ostream &  out = std::cout)
inlineinherited

Print user data (i.e.

list of all pairs of keys and values).

Parameters
outoutput stream

Definition at line 150 of file AAObject.hh.

151  {
152  unsigned n = std::max( usr.size(), usr_names.size() );
153 
154  for (unsigned i = 0; i < n ; i++)
155  {
156  std::string name = "(unnamed)";
157  if ( i < usr_names.size() && usr_names[i] != "" ) name = usr_names[i];
158  out << i << " \t " << name << " : \t ";
159  if ( i < usr.size() ) out << usr[i] << std::endl;
160  else out << "(none)" << std::endl;
161  }
162  }
std::vector< std::string > usr_names
user keys
Definition: AAObject.hh:21
then echo Enter input within $TIMEOUT_S seconds echo n User name
Definition: JCookie.sh:42
const int n
Definition: JPolint.hh:786
then awk string
std::vector< double > usr
user data
Definition: AAObject.hh:20

Member Data Documentation

int Trk::id

track identifier

Definition at line 16 of file Trk.hh.

Vec Trk::pos

postion [m] of the track at time t

Definition at line 17 of file Trk.hh.

Vec Trk::dir

track direction

Definition at line 18 of file Trk.hh.

double Trk::t

track time [ns] (when the particle is at pos )

Definition at line 19 of file Trk.hh.

double Trk::E

Energy [GeV] (either MC truth or reconstructed)

Definition at line 20 of file Trk.hh.

double Trk::len

length, if applicable [m]

Definition at line 22 of file Trk.hh.

double Trk::lik

likelihood or lambda value (for aafit, lambda)

Definition at line 23 of file Trk.hh.

int Trk::type

MC: particle type in PDG encoding.

Definition at line 24 of file Trk.hh.

int Trk::rec_type

identifier of the fitting algorithm/chain/strategy, see km3net-dataformat/definitions/reconstruction.csv

Definition at line 25 of file Trk.hh.

std::vector<int> Trk::rec_stages

list of identifyers of succesfull fitting stages resulting in this track

Definition at line 26 of file Trk.hh.

int Trk::status

MC status code, see km3net-dataformat/definitions/trkmembers.csv for values.

Definition at line 28 of file Trk.hh.

int Trk::mother_id

MC id of the parent particle.

Definition at line 29 of file Trk.hh.

int Trk::counter

used by CORSIKA7 MC generation to store interaction counters, see CORSIKA Userguide

Definition at line 30 of file Trk.hh.

std::vector<double> Trk::fitinf

place to store additional fit info, see km3net-dataformat/definitions/fitparameters.csv

Definition at line 32 of file Trk.hh.

std::vector<int> Trk::hit_ids

list of associated hit-ids (corresponds to Hit::id).

Definition at line 33 of file Trk.hh.

std::vector<double> Trk::error_matrix

(NxN) error covariance matrix for fit parameters (stored as linear vector)

Definition at line 34 of file Trk.hh.

std::string Trk::comment

use as you like

Definition at line 35 of file Trk.hh.

std::vector<double> AAObject::usr
inherited

user data

Definition at line 20 of file AAObject.hh.

std::vector<std::string> AAObject::usr_names
inherited

user keys

Definition at line 21 of file AAObject.hh.

TObject* AAObject::any
inherited

Pointer to "any" user data.

Definition at line 171 of file AAObject.hh.


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