1#ifndef __JAANET__JAANETTOOLKIT__
2#define __JAANET__JAANETTOOLKIT__
148 for (std::vector<Hit>::const_iterator hit = event.
mc_hits.begin(); hit != event.
mc_hits.end(); ++hit) {
323 inline double getW(
const Trk& track,
const size_t index,
const double value)
325 if (index < track.
fitinf.size())
326 return track.
fitinf[index];
445 const int abstype = abs(track.
type);
447 if (abstype /
int(1e8) == 10) {
449 const int Z = (abstype / 10000) % 1000;
450 const int A = (abstype / 10) % 1000;
452 return A >= 1 && A >= Z;
468 abs(track.
type) /
int(1e8) != 10 &&
481 auto is_quark = [](
const int pdg) {
485 const int abstype = abs(track.
type);
491 const int n = abstype / int(1e6);
493 return ((n == 0 || n == 9) &&
495 is_quark((abstype / 10) % 10) &&
496 is_quark((abstype / 100) % 10) &&
497 is_quark((abstype / 1000) % 10));
530 const int absstat = abs(track.
status);
575 for (std::vector<Trk>::const_iterator i = evt.
mc_trks.cbegin(); i != evt.
mc_trks.cend(); ++i) {
598 for (std::vector<Trk>::const_iterator i = evt.
mc_trks.cbegin(); i != evt.
mc_trks.cend(); ++i) {
621 return i != evt.
mc_trks.cend();
635 if (i != evt.
mc_trks.cend()) {
return *i; }
651 for (std::vector<Trk>::const_iterator i = evt.
mc_trks.cbegin(); i != evt.
mc_trks.cend(); ++i) {
674 for (std::vector<Trk>::const_iterator i = evt.
mc_trks.cbegin(); i != evt.
mc_trks.cend(); ++i) {
679 THROW(
JIndexOutOfRange,
"JAANET::get_target_nucleus(): Target nucleus not stored for event " << evt.
id <<
".");
693 for (std::vector<Trk>::const_iterator i = evt.
mc_trks.cbegin(); i != evt.
mc_trks.cend(); ++i) {
695 const int absstat = abs(i->status);
720 for (std::vector<Trk>::const_iterator i = evt.
mc_trks.cbegin(); i != evt.
mc_trks.cend(); ++i) {
722 const int absstat = abs(i->status);
729 THROW(
JIndexOutOfRange,
"JAANET::get_target_nucleon(): Target nucleon not stored for event " << evt.
id <<
".");
741 for (std::vector<Trk>::const_iterator i = evt.
mc_trks.cbegin(); i != evt.
mc_trks.cend(); ++i) {
759 for (std::vector<Trk>::const_iterator i = evt.
mc_trks.cbegin(); i != evt.
mc_trks.cend(); ++i) {
781 for (std::vector<Trk>::const_iterator i = event.
mc_trks.cbegin(); i != event.
mc_trks.cend(); ++i) {
782 if (
is_lepton(*i) && i->mother_id == neutrino.
id) {
804 for (std::vector<Trk>::const_iterator i = event.
mc_trks.cbegin(); i != event.
mc_trks.cend(); ++i) {
805 if (
is_lepton(*i) && i->mother_id == neutrino.
id) {
810 THROW(
JIndexOutOfRange,
"JAANET::get_leading_lepton(): Event " << event.
id <<
" does not have a leading lepton.");
833 }
else if (!event.
mc_trks.empty()) {
837 if (i != event.
mc_trks.end()) {
843 }
else if (!event.
trks.empty()) {
1011 for (std::vector<Trk>::const_iterator i = event.
mc_trks.cbegin(); i != event.
mc_trks.cend(); ++i) {
1015 const Trk& tau = *i;
1017 for (std::vector<Trk>::const_iterator j = event.
mc_trks.cbegin(); j != event.
mc_trks.cend(); ++j) {
1018 if (
is_muon(*j) && j->mother_id == tau.
id) {
1037 for (std::vector<Trk>::const_iterator i = event.
mc_trks.cbegin(); i != event.
mc_trks.cend(); ++i) {
1041 const Trk& tau = *i;
1043 for (std::vector<Trk>::const_iterator j = event.
mc_trks.cbegin(); j != event.
mc_trks.cend(); ++j) {
1078 std::vector<Trk>::const_iterator i = std::find_if(event.
mc_trks.begin(), event.
mc_trks.end(),
1079 make_predicate(&
Trk::id, tauID));
1081 if (i != event.
mc_trks.end()) {
1087 const Trk& tau = *i;
1089 for (std::vector<Trk>::const_iterator i = event.
mc_trks.cbegin(); i != event.
mc_trks.cend(); ++i) {
1099 THROW(
JValueOutOfRange,
"JAANET::count_taudecay_prongs(): Track " << tauID <<
" of event " << event.
id <<
" does not correspond to a tau lepton.");
1104 THROW(
JIndexOutOfRange,
"JAANET::count_taudecay_prongs(): No track with ID " << tauID <<
" in event " << event.
id <<
".");
1124 for (std::vector<Trk>::const_iterator i = event.
mc_trks.cbegin(); i != event.
mc_trks.cend(); ++i) {
1134 THROW(
JIndexOutOfRange,
"JAANET::count_taudecay_prongs(): Event " << event.
id <<
" does not contain a tau lepton.");
1205 const double energy = trk.
E;
1234 double E0 = neutrino.
E;
1236 for (std::vector<Trk>::const_iterator track = evt.
mc_trks.cbegin(); track != evt.
mc_trks.end(); ++track) {
1282 for (std::vector<Trk>::const_iterator track = evt.
mc_trks.cbegin(); track != evt.
mc_trks.cend(); ++track) {
1293 E1 += gWater(track->E, -(track->pos - mother.
pos).len());
1324 const double E0 =
getE0(evt);
1326 return E0 - neutrino.
E;
1331 "JAANET::get_target_nucleon_mass(): Unable to compute target nucleon mass for event " << evt.
id <<
" without target nucleon or neutrino.");
1347 Vec P0 = neutrino.
E * neutrino.
dir;
1375 for (std::vector<Trk>::const_iterator track = evt.
mc_trks.cbegin(); track != evt.
mc_trks.cend(); ++track) {
1379 Vec dir = track->dir;
1380 double kineticEnergy = 0.0;
1386 double energy = 0.0;
1392 energy = gWater(track->E, -(track->pos - mother.
pos).len());
1402 P1 += kineticEnergy * dir;
1421 const double dE = (neutrino.
E - LL.
E);
1424 return -dE*dE + dp.
dot(dp);
1436 const double E0 =
getE0(event);
1439 return E0*E0 - p0.
dot(p0);
1451 const double E1 =
getE1(event);
1454 return E1*E1 -
p1.dot(
p1);
1476 const bool useScatteringType =
true,
1477 const bool useDecayType =
true)
1481 int interactionType = 0;
1482 int scatteringType = 0;
1489 if (useScatteringType) {
1506 FILL(1,
'0') << interactionType <<
1507 FILL(2,
'0') << scatteringType <<
1508 FILL(2,
'0') << decayType);
1510 return std::stoi(IDstring);
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition of GENIE neutrino interaction types.
Definition of particle types.
I/O formatting auxiliaries.
#define MAKE_STRING(A)
Make string.
Data structure for direction in three dimensions.
Data structure for position in three dimensions.
double getY() const
Get y position.
double getZ() const
Get z position.
double getX() const
Get x position.
double getDY() const
Get y direction.
double getDX() const
Get x direction.
double getDZ() const
Get z direction.
Exception for an empty collection.
Exception for accessing an index in a collection that is outside of its range.
Exception for accessing a value in a collection that is outside of its range.
Extensions to Evt data format.
const Trk & get_electron(const Evt &evt)
Get first electron from the event tracklist.
double getS1(const Evt &event)
Get final state squared invariant mass of a neutrino interaction.
JAxis3D getAxis(const Trk &track)
Get axis.
const Trk & get_tau(const Evt &evt)
Get first tau from the event tracklist.
bool is_neutron(const Trk &track)
Test whether given track is a (anti-)neutron.
bool is_charged_lepton(const Trk &track)
Test whether given track is a charged lepton.
bool is_photon(const Trk &track)
Test whether given track is a photon or neutral pion.
bool has_primary(const Evt &evt)
Auxiliary function to check if an event contains a primary track.
JDirection3D getDirection(const Vec &dir)
Get direction.
bool has_target_nucleon(const Evt &evt)
Test whether given event contains target nucleon.
int count_muons(const Evt &evt)
Count the number of muons in a given event.
bool from_tau(const Hit &hit)
Test whether given hit was produced by a tau.
bool has_target_nucleus(const Evt &evt)
Test whether given event contains target nucleus.
JTrack3E getTrack(const Trk &track)
Get track.
const Trk & get_muonbundle(const Evt &evt)
Get incoming muonbundle.
bool is_electron(const Trk &track)
Test whether given track is a (anti-)electron.
double getS0(const Evt &event)
Get initial state squared invariant mass of a neutrino interaction.
bool has_tau(const Evt &evt)
Test whether given event has a tau.
bool is_nucleus(const Trk &track)
Test whether given track is a nucleus.
bool from_muon(const Hit &hit)
Test whether given hit was produced by a muon.
void add_time_offset(Evt &evt, const double tOff)
Add time offset to mc event; according to current definition, the absolute time of the event is defin...
Vec getP0(const Evt &evt)
Get momentum vector of the initial state of a neutrino interaction.
JShower3E getShower(const Trk &shower)
Get shower.
double getKineticEnergy(const Trk &trk)
Get track kinetic energy.
bool from_hadron(const Hit &hit)
Test whether given hit was produced by a hadronic shower.
const Trk & get_target_nucleus(const Evt &evt)
Get target nucleus.
JVertex3D getVertex(const Trk &track)
Get vertex.
int count_taus(const Evt &evt)
Count the number of taus in a given event.
JTimeRange getTimeRange(const Evt &event)
Get time range (i.e. time between earliest and latest hit) of Monte Carlo event.
const Trk & get_leading_lepton(const Evt &event)
Auxiliary function to retrieve the leading lepton of a neutrino interaction.
bool is_muonbundle(const Trk &track)
Test whether given track is a (anti-)muon.
bool has_leading_lepton(const Evt &event)
Auxiliary function to check if an event contains the leading lepton of a neutrino interaction.
JTransformation3D getTransformation(const Trk &track)
Get transformation.
bool has_muon(const Evt &evt)
Test whether given event has a muon.
bool is_pion(const Trk &track)
Test whether given track is a charged pion.
const Trk & get_primary(const Evt &evt)
Auxiliary function to retrieve the primary track of an event.
static const int AASHOWER_RECONSTRUCTION_TYPE
AAnet shower fit reconstruction type.
bool has_neutrino(const Evt &evt)
Test whether given event has an incoming neutrino.
bool is_finalstate(const Trk &track)
Test whether given track corresponds to a final state particle.
bool has_electron(const Evt &evt)
Test whether given event has an electron.
bool is_neutrino(const Trk &track)
Test whether given track is a neutrino.
double getE1(const Evt &evt)
Get final state energy of a neutrino interaction.
double getTime(const Hit &hit)
Get true time of hit.
double getE0(const Evt &evt)
Get initial state energy of a neutrino interaction.
double get_target_nucleon_mass(const Evt &evt)
Get target nucleon mass.
const Trk & get_muon(const Evt &evt)
Get first muon from the event tracklist.
bool is_initialstate(const Trk &track)
Test whether given track corresponds to an initial state particle.
double getW(const Trk &track, const size_t index, const double value)
Get track information.
int count_electrons(const Evt &evt)
Count the number of electrons in a given event.
JPosition3D getPosition(const Vec &pos)
Get position.
bool is_muon(const Trk &track)
Test whether given track is a (anti-)muon.
int count_taudecay_prongs(const Evt &event, const int tauID)
Count the number of tau-lepton decay prongs for the given tau lepton.
JHitType_t
Enumeration of hit types based on km3 codes.
@ HIT_TYPE_UNKNOWN
Unknown source.
@ HIT_TYPE_NOISE
Random noise.
@ HIT_TYPE_DELTARAYS_DIRECT
Direct light from delta-rays.
@ HIT_TYPE_MUON_DIRECT
Direct light from muon.
@ HIT_TYPE_DELTARAYS_SCATTERED
Scattered light from delta-rays.
@ HIT_TYPE_MUON_SCATTERED
Scattered light from muon.
@ HIT_TYPE_SHOWER_DIRECT
Direct light from primary shower.
@ HIT_TYPE_BREMSSTRAHLUNG_SCATTERED
Scattered light from Bremsstrahlung.
@ HIT_TYPE_SHOWER_SCATTERED
Scattered light from primary shower.
@ HIT_TYPE_BREMSSTRAHLUNG_DIRECT
Direct light from Bremsstrahlung.
bool is_noise(const Hit &hit)
Verify hit origin.
bool is_lepton(const Trk &track)
Test whether given track is a lepton.
int getInteractionID(const Evt &event, const bool useScatteringType=true, const bool useDecayType=true)
Retrieve interaction identifier.
bool from_electron(const Hit &hit)
Test whether given hit was produced by an electron.
bool is_proton(const Trk &track)
Test whether given track is a (anti-)proton.
bool is_baryon(const Trk &track)
Test whether given track is a baryon.
@ GEANT4_TYPE_ANTIELECTRON
double getNPE(const Hit &hit)
Get true charge of hit.
Vec getP1(const Evt &evt)
Get momentum vector of the final state of a neutrino interaction.
double getQ2(const Evt &event)
Get negative squared momentum transfer (Q^2 = -q^2 >= 0) of a neutrino interaction.
bool is_meson(const Trk &track)
Test whether given track is a meson (is hadron and third digit of PDG code is zero)
bool has_muonbundle(const Evt &evt)
Test whether given event has an incoming muonbundle.
bool has_particleID(const Trk &track, const int type)
Test whether given track corresponds to given particle type.
bool has_leptonic_taudecay(const Evt &event)
Test whether given event contains a leptonic tau-decay.
bool has_hadronic_taudecay(const Evt &event)
Test whether given event contains a hadronic tau-decay.
const Trk & get_neutrino(const Evt &evt)
Get incoming neutrino.
const Trk & get_target_nucleon(const Evt &evt)
Get target nucleon.
bool has_muonic_taudecay(const Evt &event)
Test whether given event contains a tau-lepton decay into a muon.
bool is_hadron(const Trk &track)
Test whether given track is a hadron.
@ TRACK_TYPE_CHARGED_PION_PLUS
@ TRACK_TYPE_NEUTRAL_PION
@ TRACK_TYPE_NEUTRAL_SIGMA
bool is_tau(const Trk &track)
Test whether given track is a (anti-)tau.
int count_hadrons(const Evt &evt)
Count the number of hadrons in a given event (not including neutral pions)
JPredicate< JResult_t T::*, JComparison::eq > make_predicate(JResult_t T::*member, const JResult_t value)
Helper method to create predicate for data member.
static const double MASS_MUON
muon mass [GeV]
static const JGeaneWater gWater
Function object for energy loss of muon in sea water.
static const double MASS_NEUTRON
neutron mass [GeV]
double getKineticEnergy(const double E, const double m)
Get kinetic energy of particle with given energy and mass.
static const double MASS_PROTON
proton mass [GeV]
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
std::vector< Hit > mc_hits
MC: list of MC truth hits.
std::vector< Trk > mc_trks
MC: list of MC truth tracks.
int id
offline event identifier
static int ROOT_IO_VERSION
Streamer version as obtained from ROOT file.
std::vector< Trk > trks
list of reconstructed tracks (can be several because of prefits,showers, etc).
Auxiliary data structure for sequence of same character.
double a
hit amplitude (in p.e.)
int type
particle type or parametrisation used for hit (mc only)
double t
hit time (from tdc+calibration or MC truth)
static const JPDB & getInstance()
Get particle data book.
const JParticle & getPDG(const int pdg) const
Get particle corresponding to given PDG code.
JElectricCharge charge
electric charge of particle [|e|/3]
double mass
mass of particle [GeV]
The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower.
int status
MC or reconstruction status code, see km3net-dataformat/definitions/trkmembers.csv for values.
int type
MC: particle type in PDG encoding.
std::vector< double > fitinf
place to store additional fit info, see km3net-dataformat/definitions/fitparameters....
double E
Energy [GeV] (either MC truth or reconstructed)
double t
track time [ns] (when the particle is at pos )
int mother_id
id of the parent MC particle or of the reconstructed track at the previous stage
Vec pos
postion [m] of the track at time t
The Vec class is a straightforward 3-d vector, which also works in pyroot.
double dot(const Vec &v) const
Get dot product.
static const int PDG_MUONBUNDLE
muon bundle reached the can level (mupage)
static const int TRK_ST_FINALSTATE
for MC: the particle must be processed by detector simulation ('track_in' tag in evt files)....
static const int TRK_ST_NUCTGT
Nucleon target (gseagen)
static const int TRK_MOTHER_UNDEFINED
mother id was not defined for this track
static const int TRK_ST_MUONBUNDLE
initial state muon bundle (mupage)
static const int TRK_ST_PRIMARYCOSMIC
initial state cosmic ray ('track_primary' tag in evt files from corant).
static const int TRK_ST_PRIMARYNEUTRINO
initial state neutrino ('neutrino' tag in evt files from gseagen and genhen).
static const int TRK_ST_ININUCLEI
Initial state nuclei (gseagen)
static const int TRK_MOTHER_NONE
mother id of a particle if it has no parent
static const int W2LIST_GSEAGEN_CC
Charged current interaction flag.
static const int W2LIST_GSEAGEN_ICHAN
Interaction channel.