Anp::PlotPur Class Reference

#include <PlotPur.h>

Inheritance diagram for Anp::PlotPur:
Anp::AlgSnarl Anp::AlgEvent Anp::Base Anp::Base

List of all members.

Public Member Functions

 PlotPur ()
virtual ~PlotPur ()
bool Run (Record &record)
bool Run (Event &event, const Record &record, bool pass)
void Config (const Registry &reg)
void Set (TDirectory *dir)
void End (const DataBlock &)

Private Types

typedef std::vector< Handle
< CountHist > > 
PurVec

Private Member Functions

bool Add (PurVec &pvec, int action, int reson, Particle::Particle_t particle, const std::string &opt)
TH1 * GetTH1 (TDirectory *dir, const std::string &key, const std::string &name, const std::string &xtitle, const std::string &ytitle)
bool IsMatch (Handle< CountHist > &hist, const Truth &truth) const

Private Attributes

TDirectory * fDir
std::string fDirName
std::string fTH1Name
double fNMerge
PurVec fReco
PurVec fTrue

Detailed Description

Definition at line 29 of file PlotPur.h.


Member Typedef Documentation

typedef std::vector<Handle<CountHist> > Anp::PlotPur::PurVec [private]

Definition at line 48 of file PlotPur.h.


Constructor & Destructor Documentation

Anp::PlotPur::PlotPur (  ) 

Definition at line 26 of file PlotPur.cxx.

00027    :fDir(0),
00028     fDirName("pur"),
00029     fTH1Name("energy"),
00030     fNMerge(100.0)
00031 {
00032 }

Anp::PlotPur::~PlotPur (  )  [virtual]

Definition at line 35 of file PlotPur.cxx.

00036 {
00037 }


Member Function Documentation

bool Anp::PlotPur::Add ( PurVec pvec,
int  action,
int  reson,
Particle::Particle_t  particle,
const std::string &  opt 
) [private]

Referenced by Set().

void Anp::PlotPur::Config ( const Registry reg  )  [virtual]

Reimplemented from Anp::AlgEvent.

Definition at line 116 of file PlotPur.cxx.

References fDirName, fNMerge, fTH1Name, Registry::Get(), and Registry::KeyExists().

00117 {
00118    const char *value_char = 0;
00119    if(reg.Get("PlotPurDirName", value_char) && value_char)
00120    {
00121       fDirName = value_char;
00122    }
00123 
00124    value_char = 0;
00125    if(reg.Get("PlotPurTH1Name", value_char) && value_char)
00126    {
00127       fTH1Name = value_char;
00128    }
00129 
00130    double value_double = 0;
00131    if(reg.Get("PlotPurNMerge", value_double))
00132    {
00133       fNMerge = value_double;
00134    }
00135 
00136    if(reg.KeyExists("PrintConfig"))
00137    {
00138       cout << "PlotPur::Config" << endl
00139            << "   DirName = " << fDirName << endl
00140            << "   TH1Name = " << fTH1Name << endl
00141            << "   NMerge = " << fNMerge << endl;
00142    }
00143 }

void Anp::PlotPur::End ( const DataBlock  )  [virtual]

Reimplemented from Anp::AlgEvent.

Definition at line 175 of file PlotPur.cxx.

References fNMerge, fReco, fTrue, it, and Anp::Handle< T >::valid().

00176 {
00177    for(PurVec::iterator it = fTrue.begin(); it != fTrue.end(); ++it)
00178    {
00179       Handle<CountHist> &hist = *it;
00180       
00181       if(!hist.valid() || !hist -> Valid())
00182       {
00183          continue;
00184       }
00185 
00186       if(fNMerge > 0.0)
00187       {
00188          hist -> ComputeRatio("merge");
00189       }
00190       else
00191       {
00192          hist -> ComputeRatio();
00193       }
00194    }
00195 
00196    for(PurVec::iterator it = fReco.begin(); it != fReco.end(); ++it)
00197    {
00198       Handle<CountHist> &hist = *it;
00199       
00200       if(!hist.valid() || !hist -> Valid())
00201       {
00202          continue;
00203       }
00204 
00205       if(fNMerge > 0.0)
00206       {
00207          hist -> ComputeRatio("merge");
00208       }
00209       else
00210       {
00211          hist -> ComputeRatio();
00212       }
00213    }
00214 }

TH1* Anp::PlotPur::GetTH1 ( TDirectory *  dir,
const std::string &  key,
const std::string &  name,
const std::string &  xtitle,
const std::string &  ytitle 
) [private]
bool Anp::PlotPur::IsMatch ( Handle< CountHist > &  hist,
const Truth truth 
) const [private]

Definition at line 311 of file PlotPur.cxx.

References OscFit::GetInteraction(), Anp::Truth::Interaction(), Particle::Overlap(), Anp::Truth::Particle(), Anp::Truth::Resonance(), and Anp::Handle< T >::valid().

Referenced by Run().

00312 {
00313    if(!hist.valid() || !(hist -> Valid()))
00314    {
00315       return false;
00316    }
00317    
00318    if(hist -> GetReson() > 0 &&
00319       hist -> GetReson() != truth.Resonance())
00320    {
00321       return false;
00322    }
00323 
00324    if(hist -> GetInteraction() >= 0 && 
00325       hist -> GetInteraction() != truth.Interaction())
00326    {
00327       return false;
00328    }
00329    
00330    if(!Particle::Overlap(hist -> GetParticle(), truth.Particle()))
00331    {
00332       return false;
00333    }
00334    
00335    return true;
00336 }

bool Anp::PlotPur::Run ( Event event,
const Record record,
bool  pass 
) [virtual]

Implements Anp::AlgEvent.

Definition at line 56 of file PlotPur.cxx.

References Anp::RecoNu::ENeu(), fDir, Anp::Record::FindTruth(), fReco, fTrue, Anp::Record::GetHeader(), Anp::Event::GetNu(), Anp::Header::IsData(), IsMatch(), it, Anp::Record::TruthBeg(), Anp::Record::TruthEnd(), and Anp::Handle< T >::valid().

00057 {
00058    if(!fDir || record.GetHeader().IsData() || record.TruthBeg() == record.TruthEnd())
00059    {
00060       return true;
00061    }  
00062 
00063    if(!pass)
00064    {
00065       return true;
00066    }  
00067 
00068    const TruthIter itruth = record.FindTruth(event);
00069    if(itruth == record.TruthEnd())
00070    {
00071       return true;
00072    }
00073 
00074    for(PurVec::iterator it = fTrue.begin(); it != fTrue.end(); ++it)
00075    {
00076       Handle<CountHist> &hist = *it;
00077       
00078       if(!hist.valid() || !hist -> Valid())
00079       {
00080          continue;
00081       }
00082       
00083       if(PlotPur::IsMatch(hist, *itruth))
00084       {
00085          hist -> Fill(itruth -> ENeu(), itruth -> Weight(), itruth -> Weight());
00086       }
00087       else
00088       {
00089          hist -> Fill(itruth -> ENeu(), itruth -> Weight(), 0.0);
00090       }
00091    }
00092 
00093    for(PurVec::iterator it = fReco.begin(); it != fReco.end(); ++it)
00094    {
00095       Handle<CountHist> &hist = *it;
00096       
00097       if(!hist.valid() || !hist -> Valid())
00098       {
00099          continue;
00100       }
00101 
00102       if(PlotPur::IsMatch(hist, *itruth))
00103       {
00104          hist -> Fill(event.GetNu().ENeu(), event.Weight(), event.Weight());
00105       }
00106       else
00107       {
00108          hist -> Fill(event.GetNu().ENeu(), event.Weight(), 0.0);
00109       }
00110    }
00111 
00112    return true;
00113 }

bool Anp::PlotPur::Run ( Record record  )  [virtual]

Implements Anp::AlgSnarl.

Definition at line 40 of file PlotPur.cxx.

References Anp::Record::EventBegIterator(), Anp::Record::EventEndIterator(), fDir, Anp::Record::GetHeader(), Anp::Header::IsData(), Anp::Record::TruthBeg(), and Anp::Record::TruthEnd().

00041 {
00042    if(!fDir || record.GetHeader().IsData() || record.TruthBeg() == record.TruthEnd())
00043    {
00044       return true;
00045    }
00046    
00047    for(EventIterator ievent = record.EventBegIterator(); ievent != record.EventEndIterator(); ++ievent)
00048    {
00049       PlotPur::Run(*ievent, record, true);
00050    }
00051       
00052    return true;
00053 }

void Anp::PlotPur::Set ( TDirectory *  dir  )  [virtual]

Reimplemented from Anp::AlgEvent.

Definition at line 146 of file PlotPur.cxx.

References Add(), fDir, fDirName, fReco, fTrue, Anp::GetDir(), Particle::kAll, Particle::kNuM, Particle::kNuMAny, and Particle::kNuMBar.

00147 {
00148    if(!dir)
00149    {
00150       return;
00151    }
00152 
00153    fDir = Anp::GetDir(fDirName, dir);
00154 
00155    Add(fReco, 1, 0, Particle::kNuM,    "reco");
00156    Add(fReco, 1, 0, Particle::kNuMBar, "reco");
00157    Add(fReco, 1, 0, Particle::kNuMAny, "reco");
00158    Add(fReco, 0, 0, Particle::kAll,    "reco");
00159 
00160    Add(fReco, 1, 1001, Particle::kNuM, "reco");
00161    Add(fReco, 1, 1002, Particle::kNuM, "reco");
00162    Add(fReco, 1, 1003, Particle::kNuM, "reco");
00163 
00164    Add(fTrue, 1, 0, Particle::kNuM,    "true");
00165    Add(fTrue, 1, 0, Particle::kNuMBar, "true");
00166    Add(fTrue, 1, 0, Particle::kNuMAny, "true");
00167    Add(fTrue, 0, 0, Particle::kAll,    "true");
00168 
00169    Add(fTrue, 1, 1001, Particle::kNuM, "true");
00170    Add(fTrue, 1, 1002, Particle::kNuM, "true");
00171    Add(fTrue, 1, 1003, Particle::kNuM, "true");
00172 }


Member Data Documentation

TDirectory* Anp::PlotPur::fDir [private]

Definition at line 61 of file PlotPur.h.

Referenced by Run(), and Set().

std::string Anp::PlotPur::fDirName [private]

Definition at line 63 of file PlotPur.h.

Referenced by Config(), and Set().

double Anp::PlotPur::fNMerge [private]

Definition at line 66 of file PlotPur.h.

Referenced by Config(), and End().

Definition at line 68 of file PlotPur.h.

Referenced by End(), Run(), and Set().

std::string Anp::PlotPur::fTH1Name [private]

Definition at line 64 of file PlotPur.h.

Referenced by Config().

Definition at line 69 of file PlotPur.h.

Referenced by End(), Run(), and Set().


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

Generated on 15 Jul 2018 for loon by  doxygen 1.6.1