Anp::TrueNu Class Reference

#include <TrueNu.h>

List of all members.

Public Member Functions

 TrueNu ()
 TrueNu (const Truth &truth, const Record &record)
 ~TrueNu ()
void SetEScale (float value)
int Index () const
int INu () const
int Resonance () const
int IAction () const
int Flags () const
int InitState () const
int Nucleus () const
int HadFS () const
int TPtype () const
float ENeu () const
float ELep () const
float EHad () const
float LepE () const
float LepCos () const
float TrueY () const
float TrueX () const
float TrueQ2 () const
float TrueW2 () const
float TPt () const
float TPz () const
float EScale () const
double Weight () const
bool IsCC () const
bool IsNC () const
bool IsDIS () const
bool IsRES () const
bool IsQES () const
bool IsNuMu () const
bool IsNuMuBar () const
bool Match (const RecoNu &rnu) const
bool Add (short key, float data)
bool Erase (short key)
bool KeyExists (short key) const
float operator[] (short key) const
float DataAt (short key) const
void Print (std::ostream &o=std::cout) const

Private Attributes

Short_t index
Short_t inu
Short_t iresonance
Short_t iaction
Short_t iflags
Short_t init_state
Short_t nucleus
Short_t had_fstate
Short_t tptype
Float_t neu_e
Float_t lep_e
Float_t lep_cos
Float_t y
Float_t x
Float_t q2
Float_t w2
Float_t tpt
Float_t tpz
Float_t escale
Double_t weight
std::vector< Short_t > fReco
DataVec fData

Detailed Description

Definition at line 23 of file TrueNu.h.


Constructor & Destructor Documentation

Anp::TrueNu::TrueNu (  ) 

Definition at line 18 of file TrueNu.cxx.

00019    :index(-1),
00020     inu(0),
00021     iresonance(0),
00022     iaction(-1),
00023     iflags(-1),
00024     init_state(-1),
00025     nucleus(-1),
00026     had_fstate(-1),
00027     tptype(-1),
00028     neu_e(0.0),
00029     lep_e(0.0),
00030     lep_cos(-1.0),
00031     y(-1.0),
00032     x(0.0),
00033     q2(0.0),
00034     w2(0.0),
00035     tpt(0.0),
00036     tpz(0.0),
00037     escale(1.0),
00038     weight(1.0)
00039 {
00040 }

Anp::TrueNu::TrueNu ( const Truth truth,
const Record record 
)

Definition at line 43 of file TrueNu.cxx.

References Anp::Truth::ChildBeg(), Anp::Truth::ChildEnd(), Anp::Truth::Flags(), Anp::Truth::Flux(), fReco, Anp::StdHep::GetIstHEP(), Anp::Record::GetStdHep(), Anp::Truth::HadFS(), Anp::Truth::InitState(), Anp::Truth::Interaction(), Anp::Truth::INu(), Anp::StdHep::IsLepton(), it, lep_cos, Anp::Truth::Nucleus(), Anp::StdHep::ParentBeg(), Anp::StdHep::ParentEnd(), Anp::Truth::Print(), Anp::StdHep::Print(), Anp::StdHep::Px(), Anp::Truth::Px(), Anp::StdHep::Py(), Anp::Truth::Py(), Anp::Truth::Pz(), Anp::StdHep::Pz(), Anp::Truth::RecoBeg(), Anp::Truth::RecoEnd(), Anp::Truth::Resonance(), Anp::Record::StdHepBeg(), Anp::Record::StdHepEnd(), Anp::StdHep::StdHepIndex(), Anp::FluxInfo::tptype, Anp::StdHep::TruthIndex(), and Anp::Truth::TruthIndex().

00044    :index(tnu.TruthIndex()),
00045     inu(tnu.INu()),
00046     iresonance(tnu.Resonance()),
00047     iaction(tnu.Interaction()),
00048     iflags(tnu.Flags()),
00049     init_state(tnu.InitState()),
00050     nucleus(tnu.Nucleus()),
00051     had_fstate(tnu.HadFS()),
00052     tptype(tnu.Flux().tptype),
00053     neu_e(tnu.ENeu()),
00054     lep_e(0.0),
00055     lep_cos(0.0),
00056     y(tnu.TrueY()),
00057     x(tnu.TrueX()),
00058     q2(tnu.TrueQ2()),
00059     w2(tnu.TrueW2()),
00060     tpt(std::sqrt(tnu.Flux().tpy*tnu.Flux().tpy + tnu.Flux().tpx*tnu.Flux().tpx)),
00061     tpz(tnu.Flux().tpz),
00062     escale(1.0),
00063     weight(tnu.Weight())
00064 {
00065    //
00066    // Collect indexes of matching reconstructed events
00067    //
00068    for(TruthRecoIter it = tnu.RecoBeg(); it != tnu.RecoEnd(); ++it)
00069    {
00070       if(it -> IsEvent())
00071       {
00072          fReco.push_back(it -> RecoIndex());
00073       }
00074    }
00075 
00076    if(record.StdHepBeg() != record.StdHepEnd())
00077    {      
00078       const int ibeg = tnu.ChildBeg();
00079       const int iend = tnu.ChildEnd();
00080       
00081       if(ibeg < 0 || iend < 0 || iend < ibeg)
00082       {
00083          cerr << "TrueNu ctor - StdHep range is invalid: " << endl;
00084          tnu.Print();
00085       }
00086       else
00087       {
00088          const vector<StdHep> &svec = record.GetStdHep();
00089          bool ifound = false;
00090 
00091          for(unsigned int ihep = 0; ihep < svec.size(); ++ihep)
00092          {                  
00093             const StdHep &hep = svec[ihep];
00094 
00095             if(hep.TruthIndex() != tnu.TruthIndex())
00096             {
00097                continue;
00098             }
00099 
00100             if(hep.StdHepIndex() < ibeg || hep.StdHepIndex() > iend)
00101             {
00102                cerr << "TrueNu ctor - StdHep range is invalid: " << svec.size() << endl;
00103                tnu.Print();
00104                hep.Print();
00105                continue;
00106             }
00107 
00108             if(hep.IsLepton() &&
00109                hep.GetIstHEP() == 1 &&
00110                hep.ParentBeg() >= 0 &&
00111                hep.ParentEnd() >= 0)
00112             {
00113                const double plep_ = std::sqrt(hep.Px()*hep.Px()+hep.Py()*hep.Py()+hep.Pz()*hep.Pz());
00114                const double pneu_ = std::sqrt(tnu.Px()*tnu.Px()+tnu.Py()*tnu.Py()+tnu.Pz()*tnu.Pz());
00115                if(plep_ > 0.0 && pneu_ > 0.0)
00116                {
00117                   lep_cos = (hep.Px()*tnu.Px()+hep.Py()*tnu.Py()+hep.Pz()*tnu.Pz())/(plep_*pneu_);
00118                   ifound = true;
00119                   break;
00120                }
00121             }
00122          }
00123          
00124          if(!ifound)
00125          {
00126             cerr << "TrueNu ctor - failed to find lepton StdHep" << endl;           
00127          }
00128       }
00129    }
00130 
00131    //
00132    // Stupid way to make sure that int values are within allowed short range
00133    //
00134    assert(std::abs(tnu.INu())         < SHRT_MAX && "inu is out of range");
00135    assert(std::abs(tnu.Resonance())   < SHRT_MAX && "iresonance is out of range");
00136    assert(std::abs(tnu.Interaction()) < SHRT_MAX && "iaction is out of range");
00137    assert(std::abs(tnu.Flags())       < SHRT_MAX && "iflags is out of range");
00138    assert(std::abs(tnu.InitState())   < SHRT_MAX && "init_state is out of range");
00139    assert(std::abs(tnu.Nucleus())     < SHRT_MAX && "nucleus is out of range");
00140    assert(std::abs(tnu.HadFS())       < SHRT_MAX && "had_fstate is out of range");
00141    assert(std::abs(tnu.Flux().tptype) < SHRT_MAX && "tptype is out of range");
00142 }

Anp::TrueNu::~TrueNu (  ) 

Definition at line 145 of file TrueNu.cxx.

00146 {
00147 }


Member Function Documentation

bool Anp::TrueNu::Add ( short  key,
float  data 
)

Definition at line 150 of file TrueNu.cxx.

References fData, and KeyExists().

00151 { 
00152    if(KeyExists(key))
00153    {
00154       cerr << "TrueNu::Add - key " << key << " already exists " << endl;
00155       assert(!KeyExists(key) && "key already exists");
00156       return false;
00157    }
00158    
00159    fData.push_back(Anp::Data(key, value));
00160    return true;
00161 }

float Anp::TrueNu::DataAt ( short  key  )  const

Definition at line 190 of file TrueNu.cxx.

References fData, find(), and it.

Referenced by operator[]().

00191 {
00192    DataIter it = find(fData.begin(), fData.end(), key);
00193    if(it == fData.end())
00194    {
00195       cerr << "TrueNu: key " << key << " does not exist" << endl;
00196       return 0.0;
00197    }
00198    
00199    return it -> Data();
00200 }

float Anp::TrueNu::EHad (  )  const [inline]

Definition at line 131 of file TrueNu.h.

References ENeu(), and TrueY().

00131 { return TrueY()*ENeu(); }

float Anp::TrueNu::ELep (  )  const [inline]

Definition at line 130 of file TrueNu.h.

References ENeu(), and TrueY().

00130 { return (1.0 - TrueY())*ENeu(); }

float Anp::TrueNu::ENeu (  )  const [inline]

Definition at line 129 of file TrueNu.h.

References neu_e.

Referenced by EHad(), and ELep().

00129 { return neu_e; }

bool Anp::TrueNu::Erase ( short  key  ) 

Definition at line 164 of file TrueNu.cxx.

References fData, find(), and it.

00165 {
00166    DataVec::iterator it = std::find(fData.begin(), fData.end(), key);
00167    if(it == fData.end())
00168    {
00169       cerr << "TrueNu::Erase - key " << key << " does not exist" << endl;
00170       return false;      
00171    }
00172 
00173    fData.erase(it);
00174    return true;
00175 }

float Anp::TrueNu::EScale (  )  const [inline]

Definition at line 142 of file TrueNu.h.

References escale.

00142 { return escale; }

int Anp::TrueNu::Flags (  )  const [inline]

Definition at line 123 of file TrueNu.h.

References iflags.

00123 { return iflags; }

int Anp::TrueNu::HadFS (  )  const [inline]

Definition at line 126 of file TrueNu.h.

References had_fstate.

00126 { return had_fstate; }

int Anp::TrueNu::IAction (  )  const [inline]

Definition at line 122 of file TrueNu.h.

References iaction.

00122 { return iaction; }

int Anp::TrueNu::Index (  )  const [inline]

Definition at line 119 of file TrueNu.h.

References index.

Referenced by Anp::operator==().

00119 { return index;  }

int Anp::TrueNu::InitState (  )  const [inline]

Definition at line 124 of file TrueNu.h.

00124 { return init_state; }

int Anp::TrueNu::INu (  )  const [inline]

Definition at line 120 of file TrueNu.h.

References inu.

00120 { return inu; }

bool Anp::TrueNu::IsCC (  )  const [inline]

Definition at line 145 of file TrueNu.h.

References iaction.

00145 { return (iaction == 1); }

bool Anp::TrueNu::IsDIS (  )  const [inline]

Definition at line 148 of file TrueNu.h.

References iresonance.

00148 { return (iresonance == 1003); }

bool Anp::TrueNu::IsNC (  )  const [inline]

Definition at line 146 of file TrueNu.h.

References iaction.

00146 { return (iaction == 0); }

bool Anp::TrueNu::IsNuMu (  )  const [inline]

Definition at line 152 of file TrueNu.h.

References inu.

00152 { return (inu == +14); }

bool Anp::TrueNu::IsNuMuBar (  )  const [inline]

Definition at line 153 of file TrueNu.h.

References inu.

00153 { return (inu == -14); }

bool Anp::TrueNu::IsQES (  )  const [inline]

Definition at line 150 of file TrueNu.h.

References iresonance.

00150 { return (iresonance == 1001); }

bool Anp::TrueNu::IsRES (  )  const [inline]

Definition at line 149 of file TrueNu.h.

References iresonance.

00149 { return (iresonance == 1002); }

bool Anp::TrueNu::KeyExists ( short  key  )  const

Definition at line 178 of file TrueNu.cxx.

References fData, and find().

Referenced by Add().

00179 {
00180    return (std::find(fData.begin(), fData.end(), key) != fData.end());
00181 }

float Anp::TrueNu::LepCos (  )  const [inline]

Definition at line 133 of file TrueNu.h.

References lep_cos.

00133 { return lep_cos; }

float Anp::TrueNu::LepE (  )  const [inline]

Definition at line 132 of file TrueNu.h.

References lep_e.

00132 { return lep_e; }

bool Anp::TrueNu::Match ( const RecoNu rnu  )  const [inline]

Definition at line 155 of file TrueNu.h.

References find(), and fReco.

Referenced by Anp::operator==().

00156    {
00157       return (std::find(fReco.begin(), fReco.end(), rnu) != fReco.end());
00158    }

int Anp::TrueNu::Nucleus (  )  const [inline]

Definition at line 125 of file TrueNu.h.

00125 { return nucleus; }

float Anp::TrueNu::operator[] ( short  key  )  const

Definition at line 184 of file TrueNu.cxx.

References DataAt().

00185 {
00186    return DataAt(key);
00187 }

void Anp::TrueNu::Print ( std::ostream &  o = std::cout  )  const
int Anp::TrueNu::Resonance (  )  const [inline]

Definition at line 121 of file TrueNu.h.

References iresonance.

00121 { return iresonance; }

void Anp::TrueNu::SetEScale ( float  value  )  [inline]

Definition at line 117 of file TrueNu.h.

References escale.

00117 { escale = value; }

float Anp::TrueNu::TPt (  )  const [inline]

Definition at line 139 of file TrueNu.h.

References tpt.

00139 { return tpt; }

int Anp::TrueNu::TPtype (  )  const [inline]

Definition at line 127 of file TrueNu.h.

References tptype.

00127 { return tptype; }

float Anp::TrueNu::TPz (  )  const [inline]

Definition at line 140 of file TrueNu.h.

References tpz.

00140 { return tpz; }

float Anp::TrueNu::TrueQ2 (  )  const [inline]

Definition at line 136 of file TrueNu.h.

References q2.

00136 { return q2; }

float Anp::TrueNu::TrueW2 (  )  const [inline]

Definition at line 137 of file TrueNu.h.

References w2.

00137 { return w2; }

float Anp::TrueNu::TrueX (  )  const [inline]

Definition at line 135 of file TrueNu.h.

References x.

00135 { return x; }

float Anp::TrueNu::TrueY (  )  const [inline]

Definition at line 134 of file TrueNu.h.

References y.

Referenced by EHad(), and ELep().

00134 { return y; }

double Anp::TrueNu::Weight (  )  const [inline]

Definition at line 143 of file TrueNu.h.

References weight.

00143 { return weight; }


Member Data Documentation

Float_t Anp::TrueNu::escale [private]

Definition at line 99 of file TrueNu.h.

Referenced by EScale(), and SetEScale().

Definition at line 104 of file TrueNu.h.

Referenced by Add(), DataAt(), Erase(), and KeyExists().

std::vector<Short_t> Anp::TrueNu::fReco [private]

Definition at line 102 of file TrueNu.h.

Referenced by Match(), and TrueNu().

Short_t Anp::TrueNu::had_fstate [private]

Definition at line 88 of file TrueNu.h.

Referenced by HadFS().

Short_t Anp::TrueNu::iaction [private]

Definition at line 84 of file TrueNu.h.

Referenced by IAction(), IsCC(), and IsNC().

Short_t Anp::TrueNu::iflags [private]

Definition at line 85 of file TrueNu.h.

Referenced by Flags().

Short_t Anp::TrueNu::index [private]

Definition at line 81 of file TrueNu.h.

Referenced by Index().

Short_t Anp::TrueNu::init_state [private]

Definition at line 86 of file TrueNu.h.

Short_t Anp::TrueNu::inu [private]

Definition at line 82 of file TrueNu.h.

Referenced by INu(), IsNuMu(), and IsNuMuBar().

Short_t Anp::TrueNu::iresonance [private]

Definition at line 83 of file TrueNu.h.

Referenced by IsDIS(), IsQES(), IsRES(), and Resonance().

Float_t Anp::TrueNu::lep_cos [private]

Definition at line 92 of file TrueNu.h.

Referenced by LepCos(), and TrueNu().

Float_t Anp::TrueNu::lep_e [private]

Definition at line 91 of file TrueNu.h.

Referenced by LepE().

Float_t Anp::TrueNu::neu_e [private]

Definition at line 90 of file TrueNu.h.

Referenced by ENeu().

Short_t Anp::TrueNu::nucleus [private]

Definition at line 87 of file TrueNu.h.

Float_t Anp::TrueNu::q2 [private]

Definition at line 95 of file TrueNu.h.

Referenced by TrueQ2().

Float_t Anp::TrueNu::tpt [private]

Definition at line 97 of file TrueNu.h.

Referenced by TPt().

Short_t Anp::TrueNu::tptype [private]

Definition at line 89 of file TrueNu.h.

Referenced by TPtype().

Float_t Anp::TrueNu::tpz [private]

Definition at line 98 of file TrueNu.h.

Referenced by TPz().

Float_t Anp::TrueNu::w2 [private]

Definition at line 96 of file TrueNu.h.

Referenced by TrueW2().

Double_t Anp::TrueNu::weight [private]

Definition at line 100 of file TrueNu.h.

Referenced by Weight().

Float_t Anp::TrueNu::x [private]

Definition at line 94 of file TrueNu.h.

Referenced by TrueX().

Float_t Anp::TrueNu::y [private]

Definition at line 93 of file TrueNu.h.

Referenced by TrueY().


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

Generated on 3 Oct 2018 for loon by  doxygen 1.6.1