Jpp master_rocky-44-g75b7c4f75
the software that should make you happy
Loading...
Searching...
No Matches
JAANET::JEvtWeightFactorMupage Struct Referencefinal

Implementation of reweighting factor for mupage events according to a specifiable ROOT TFormula. More...

#include <JEvtWeightFactorMupage.hh>

Inheritance diagram for JAANET::JEvtWeightFactorMupage:
JLANG::JClonable< JClonable_t, JDerived_t >

Public Types

enum  variables {
  MUON_MULTIPLICITY , MEAN_ZENITH_ANGLE , TOTAL_MUON_ENERGY , LATERAL_SPREAD ,
  NUMBER_OF_VARIABLES
}
 Indices of reweighting variables for MUPAGE. More...
 
typedef JClonable< JClonable_t >::clone_type clone_type
 

Public Member Functions

 JEvtWeightFactorMupage ()
 Default constructor.
 
 JEvtWeightFactorMupage (const char *const name, const char *const formula)
 Constructor.
 
bool is_valid () const override final
 Check whether this formula is valid.
 
double getFactor (const Evt &evt) const override final
 Get weighting factor for given event.
 
virtual clone_type clone () const override
 Get clone of this object.
 

Detailed Description

Implementation of reweighting factor for mupage events according to a specifiable ROOT TFormula.

Note: The ROOT TFormula may assume any number of parameters, but should be restricted to
the physical variables listed among JEvtWeightFactorMupage::variables.
These variables may be specified within the ROOT TFormula as 'x[<index>]',
where <index> corresponds to the index of the desired physical variable within JEvtWeightFactorMupage::variables.

Definition at line 40 of file JEvtWeightFactorMupage.hh.

Member Typedef Documentation

◆ clone_type

template<class JClonable_t , class JDerived_t >
JClonable<JClonable_t>::clone_type JLANG::JClonable< JClonable_t, JDerived_t >::clone_type
inherited

Definition at line 61 of file JClonable.hh.

Member Enumeration Documentation

◆ variables

Indices of reweighting variables for MUPAGE.

Enumerator
MUON_MULTIPLICITY 

Muon multiplicity

MEAN_ZENITH_ANGLE 

Average cosine of zenith angle.

TOTAL_MUON_ENERGY 

Muon bundle total energy [GeV].

LATERAL_SPREAD 

Muon bundle lateral spread [m].

NUMBER_OF_VARIABLES 

Number of reweighting variables;
N.B. This enum value needs to be specified last!

Definition at line 46 of file JEvtWeightFactorMupage.hh.

46 {
47 MUON_MULTIPLICITY, //!< Muon multiplicity
48 MEAN_ZENITH_ANGLE, //!< Average cosine of zenith angle
49 TOTAL_MUON_ENERGY, //!< Muon bundle total energy [GeV]
50 LATERAL_SPREAD, //!< Muon bundle lateral spread [m]
51
52 NUMBER_OF_VARIABLES //!< Number of reweighting variables; \n
53 //!< N.B.\ This enum value needs to be specified last!
54 };
@ TOTAL_MUON_ENERGY
Muon bundle total energy [GeV].
@ LATERAL_SPREAD
Muon bundle lateral spread [m].
@ MEAN_ZENITH_ANGLE
Average cosine of zenith angle.
@ NUMBER_OF_VARIABLES
Number of reweighting variables; N.B. This enum value needs to be specified last!

Constructor & Destructor Documentation

◆ JEvtWeightFactorMupage() [1/2]

JAANET::JEvtWeightFactorMupage::JEvtWeightFactorMupage ( )
inline

Default constructor.

Definition at line 60 of file JEvtWeightFactorMupage.hh.

61 {}

◆ JEvtWeightFactorMupage() [2/2]

JAANET::JEvtWeightFactorMupage::JEvtWeightFactorMupage ( const char *const name,
const char *const formula )
inline

Constructor.

Parameters
namename
formulaformula

Definition at line 70 of file JEvtWeightFactorMupage.hh.

72 {
73 getFormula().SetName(name);
74
75 compile(formula);
76 }

Member Function Documentation

◆ is_valid()

bool JAANET::JEvtWeightFactorMupage::is_valid ( ) const
inlinefinaloverride

Check whether this formula is valid.

Returns
true if valid; else false

Definition at line 84 of file JEvtWeightFactorMupage.hh.

85 {
86 const int N = getFormula().GetNpar();
87
88 return N >= 0 && N <= (int) NUMBER_OF_VARIABLES;
89 }

◆ getFactor()

double JAANET::JEvtWeightFactorMupage::getFactor ( const Evt & evt) const
inlinefinaloverride

Get weighting factor for given event.

Parameters
evtevent
Returns
weighting factor

Definition at line 98 of file JEvtWeightFactorMupage.hh.

99 {
100 using namespace std;
101 using namespace JPP;
102
103 vector<JTrack3E> muons;
104
105 for (vector<Trk>::const_iterator i = evt.mc_trks.cbegin(); i != evt.mc_trks.cend(); ++i) {
106 if (is_muon(*i) && is_finalstate(*i)) {
107 muons.push_back(getTrack(*i));
108 }
109 }
110
111 if (muons.empty()) {
112 THROW(JValueOutOfRange, "JEvtWeightFactorMupage::operator(): No muon for event " << evt.id << '.' << endl);
113 }
114
115 Double_t vars[NUMBER_OF_VARIABLES] = { 0.0 };
116
117 double Etot = 0.0;
118 JVector3D dir;
119
120 for (vector<JTrack3E>::const_iterator i = muons.begin(); i != muons.end(); ++i) {
121 Etot += i->getE();
122 dir += i->getDirection();
123 }
124
125 const JDirection3D D(dir);
126 const JRotation3D R(D);
127
128 for (vector<JTrack3E>::iterator i = muons.begin(); i != muons.end(); ++i) {
129 i->rotate(R);
130 }
131
132 vector<Trk>::const_iterator iBundle = find_if(evt.mc_trks.cbegin(), evt.mc_trks.cend(),
133 make_predicate(&Trk::status, TRK_ST_MUONBUNDLE));
134
135 vars[MUON_MULTIPLICITY] = (double) muons.size();
136 vars[TOTAL_MUON_ENERGY] = (iBundle != evt.mc_trks.cend() ? iBundle->E : Etot);
137 vars[MEAN_ZENITH_ANGLE] = D.getDZ();
138
139 if (this->GetNdim() > (int) LATERAL_SPREAD) {
140
141 const JCircle2D circle = JCircle2D(muons.cbegin(), muons.cend()); // smallest enclosing circle
142
143 vars[LATERAL_SPREAD] = circle.getRadius();
144 }
145
146 return getFormula().EvalPar(&vars[0]);
147 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Data structure for circle in two dimensions.
Definition JCircle2D.hh:35
double getRadius() const
Get radius.
Definition JCircle2D.hh:144
Data structure for direction in three dimensions.
Data structure for vector in three dimensions.
Definition JVector3D.hh:36
Exception for accessing a value in a collection that is outside of its range.
JTrack3E getTrack(const Trk &track)
Get track.
bool is_finalstate(const Trk &track)
Test whether given track corresponds to a final state particle.
bool is_muon(const Trk &track)
Test whether given track is a (anti-)muon.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
std::vector< Trk > mc_trks
MC: list of MC truth tracks.
Definition Evt.hh:49
int id
offline event identifier
Definition Evt.hh:22
int status
MC status code, see km3net-dataformat/definitions/trkmembers.csv for values.
Definition Trk.hh:28
static const int TRK_ST_MUONBUNDLE
initial state muon bundle (mupage)
Definition trkmembers.hh:18

◆ clone()

template<class JClonable_t , class JDerived_t >
virtual clone_type JLANG::JClonable< JClonable_t, JDerived_t >::clone ( ) const
inlineoverridevirtualinherited

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