Anp::PlotEff Class Reference

#include <PlotEff.h>

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

List of all members.

Public Member Functions

 PlotEff ()
virtual ~PlotEff ()
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 > > 
EffVec

Private Member Functions

bool Add (EffVec &evec, 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
bool fInit
bool fTrueFid
bool fVerbose
double fMinCom
double fNMerge
EffVec fTrueEff
EffVec fRecoEff
double fTruthAll
double fTruthFid
double fTruthRec

Detailed Description

Definition at line 28 of file PlotEff.h.


Member Typedef Documentation

typedef std::vector<Handle<CountHist> > Anp::PlotEff::EffVec [private]

Definition at line 47 of file PlotEff.h.


Constructor & Destructor Documentation

Anp::PlotEff::PlotEff (  ) 

Definition at line 27 of file PlotEff.cxx.

00028    :fDir(0),
00029     fDirName("eff"),
00030     fTH1Name("energy"),
00031     fInit(false),
00032     fTrueFid(true),
00033     fVerbose(false),
00034     fMinCom(0.0),
00035     fNMerge(100.0),
00036     fTruthAll(0.0),
00037     fTruthFid(0.0),
00038     fTruthRec(0.0)
00039 {
00040 }

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

Definition at line 43 of file PlotEff.cxx.

00044 {
00045 }


Member Function Documentation

bool Anp::PlotEff::Add ( EffVec evec,
int  action,
int  reson,
Particle::Particle_t  particle,
const std::string &  opt 
) [private]

Referenced by Set().

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

Reimplemented from Anp::AlgEvent.

Definition at line 167 of file PlotEff.cxx.

References fDirName, fMinCom, fNMerge, fTH1Name, fTrueFid, fVerbose, Registry::Get(), Registry::KeyExists(), and Anp::Read().

00168 {
00169    const char *value_char = 0;
00170    if(reg.Get("PlotEffDirName", value_char) && value_char)
00171    {
00172       fDirName = value_char;
00173    }
00174 
00175    value_char = 0;
00176    if(reg.Get("PlotEffTH1Name", value_char) && value_char)
00177    {
00178       fTH1Name = value_char;
00179    }
00180 
00181    Anp::Read(reg, "PlotEffTrueFid", fTrueFid);
00182    Anp::Read(reg, "PlotEffVerbose", fVerbose);
00183 
00184    reg.Get("PlotPurNMerge", fNMerge);
00185    reg.Get("PlotPurMinCom", fMinCom);
00186 
00187    if(reg.KeyExists("PrintConfig"))
00188    {
00189       cout << "PlotEff::Config" << endl
00190            << "   DirName = " << fDirName << endl
00191            << "   TH1Name = " << fTH1Name << endl
00192            << "   MinCom = " << fMinCom << endl
00193            << "   NMerge = " << fNMerge << endl
00194            << "   TrueFid = " << fTrueFid << endl
00195            << "   Verbose = " << fVerbose << endl;
00196    } 
00197 }

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

Reimplemented from Anp::AlgEvent.

Definition at line 232 of file PlotEff.cxx.

References fNMerge, fRecoEff, fTrueEff, fTruthAll, fTruthFid, fTruthRec, fVerbose, it, and Anp::Handle< T >::valid().

00233 {
00234    for(EffVec::iterator it = fTrueEff.begin(); it != fTrueEff.end(); ++it)
00235    {
00236       Handle<CountHist> &hist = *it;
00237       
00238       if(!hist.valid() || !hist -> Valid())
00239       {
00240          continue;
00241       }
00242 
00243       if(fNMerge > 0.0)
00244       {
00245          hist -> ComputeRatio("merge");
00246       }
00247       else
00248       {
00249          hist -> ComputeRatio();
00250       }
00251    }
00252    for(EffVec::iterator it = fRecoEff.begin(); it != fRecoEff.end(); ++it)
00253    {
00254       Handle<CountHist> &hist = *it;
00255       
00256       if(!hist.valid() || !hist -> Valid())
00257       {
00258          continue;
00259       }
00260 
00261       if(fNMerge > 0.0)
00262       {
00263          hist -> ComputeRatio("merge");
00264       }
00265       else
00266       {
00267          hist -> ComputeRatio();
00268       }
00269    }
00270 
00271    fTrueEff.clear();
00272    fRecoEff.clear();
00273 
00274    if(fVerbose)
00275    {
00276       cout << "PlotEff::End " << endl
00277            << "   TruthAll = " << fTruthAll << endl
00278            << "   TruthFid = " << fTruthFid << endl
00279            << "   TruthRec = " << fTruthRec << endl;
00280    }
00281 }

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

Definition at line 384 of file PlotEff.cxx.

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

Referenced by Run().

00385 {
00386    if(!hist.valid() || !(hist -> Valid()))
00387    {
00388       return false;
00389    }
00390    
00391    if(hist -> GetReson() > 0 && 
00392       hist -> GetReson() != truth.Resonance())
00393    {
00394       return false;
00395    }
00396 
00397    if(hist -> GetInteraction() >= 0 &&
00398       hist -> GetInteraction() != truth.Interaction())
00399    {
00400       return false;
00401    }
00402    
00403    if(!Particle::Overlap(hist -> GetParticle(), truth.Particle()))
00404    {
00405       return false;
00406    }
00407    
00408    return true;
00409 }

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

Implements Anp::AlgEvent.

Definition at line 111 of file PlotEff.cxx.

References Anp::RecoNu::ENeu(), fDir, Anp::Record::FindTruth(), fRecoEff, fTrueEff, Anp::Record::GetHeader(), Anp::Event::GetNu(), Anp::Header::IsData(), IsMatch(), it, Anp::Record::TruthBeg(), and Anp::Record::TruthEnd().

00112 {
00113    if(!fDir || record.GetHeader().IsData() || record.TruthBeg() == record.TruthEnd())
00114    {
00115       return true;
00116    }
00117    
00118    const TruthIter itruth = record.FindTruth(event);
00119    if(itruth == record.TruthEnd())
00120    {
00121       return true;
00122    }
00123 
00124    for(EffVec::iterator it = fRecoEff.begin(); it != fRecoEff.end(); ++it)
00125    {
00126       Handle<CountHist> &hist = *it;
00127       
00128       if(!PlotEff::IsMatch(hist, *itruth))
00129       {
00130          continue;
00131       }
00132     
00133       if(pass)
00134       {
00135          hist -> Fill(event.GetNu().ENeu(), event.Weight(), event.Weight());
00136       }
00137       else
00138       {
00139          hist -> Fill(event.GetNu().ENeu(), event.Weight(), 0.0);
00140       }
00141    }
00142 
00143    for(EffVec::iterator it = fTrueEff.begin(); it != fTrueEff.end(); ++it)
00144    {
00145       Handle<CountHist> &hist = *it;
00146 
00147       if(!PlotEff::IsMatch(hist, *itruth))
00148       {
00149          continue;
00150       }
00151 
00152       if(pass)
00153       {
00154          hist -> Fill(itruth -> ENeu(), itruth -> Weight(), itruth -> Weight());
00155       }
00156       else
00157       {
00158          hist -> Fill(itruth -> ENeu(), itruth -> Weight(), 0.0);
00159       }
00160    }
00161 
00162    
00163    return true;
00164 }

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

Implements Anp::AlgSnarl.

Definition at line 48 of file PlotEff.cxx.

References Anp::Record::EventBeg(), Anp::Record::EventEnd(), fDir, find(), fMinCom, fTrueEff, fTrueFid, fTruthAll, fTruthFid, fTruthRec, Anp::Record::GetHeader(), Anp::Header::IsData(), IsMatch(), it, Anp::Record::TruthBeg(), and Anp::Record::TruthEnd().

00049 {
00050    if(!fDir || record.GetHeader().IsData() || record.TruthBeg() == record.TruthEnd())
00051    {
00052       return true;
00053    }
00054    
00055    for(TruthIter itruth = record.TruthBeg(); itruth != record.TruthEnd(); ++itruth)
00056    {
00057       //
00058       // True fiducial vertex?
00059       //
00060       double weight_all = 0.0;
00061       if(fTrueFid && itruth -> GetVtx().IsFiducial())
00062       {
00063          weight_all = itruth -> Weight();
00064       
00065 }
00066       fTruthAll += itruth -> Weight();
00067       fTruthFid += weight_all;
00068 
00069       for(EffVec::iterator it = fTrueEff.begin(); it != fTrueEff.end(); ++it)
00070       {
00071          Handle<CountHist> &hist = *it;
00072 
00073          if(!PlotEff::IsMatch(hist, *itruth))
00074          {
00075             continue;
00076          }
00077 
00078          double weight_sel = 0.0;
00079 
00080          for(TruthRecoIter ireco = itruth -> RecoBeg(); ireco != itruth -> RecoEnd(); ++ireco)
00081          {
00082             if(!(ireco -> IsEvent()) || ireco -> ComplAll() < fMinCom)
00083             {
00084                continue;
00085             }
00086             
00087             if(std::find(record.EventBeg(), record.EventEnd(), ireco->RecoIndex()) != record.EventEnd())
00088             {
00089                weight_sel += itruth -> Weight();
00090             }
00091          }       
00092          
00093          hist -> Fill(itruth -> ENeu(), weight_all, weight_sel);
00094       }
00095       
00096       for(TruthRecoIter ireco = itruth -> RecoBeg(); ireco != itruth -> RecoEnd(); ++ireco)
00097       {
00098          if(!(ireco -> IsEvent()) || ireco -> ComplAll() < fMinCom)
00099          {
00100             continue;
00101          }
00102                  
00103          fTruthRec += itruth -> Weight();
00104       }
00105    }
00106    
00107    return true;
00108 }

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

Reimplemented from Anp::AlgEvent.

Definition at line 200 of file PlotEff.cxx.

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

00201 {
00202    if(!dir)
00203    {
00204       return;
00205    }
00206 
00207    fDir = Anp::GetDir(fDirName, dir);
00208 
00209    //
00210    // Create histograms
00211    //
00212    Add(fTrueEff, 1, 0, Particle::kNuM,    "true");
00213    Add(fTrueEff, 1, 0, Particle::kNuMBar, "true");
00214    Add(fTrueEff, 1, 0, Particle::kNuMAny, "true");
00215    Add(fTrueEff, 0, 0, Particle::kAll,    "true");
00216    
00217    Add(fTrueEff, 1, 1001, Particle::kNuM, "true");
00218    Add(fTrueEff, 1, 1002, Particle::kNuM, "true");
00219    Add(fTrueEff, 1, 1003, Particle::kNuM, "true");
00220 
00221    Add(fRecoEff, 1, 0, Particle::kNuM,    "reco");
00222    Add(fRecoEff, 1, 0, Particle::kNuMBar, "reco");
00223    Add(fRecoEff, 1, 0, Particle::kNuMAny, "reco");
00224    Add(fRecoEff, 0, 0, Particle::kAll,    "reco");
00225    
00226    Add(fRecoEff, 1, 1001, Particle::kNuM, "reco");
00227    Add(fRecoEff, 1, 1002, Particle::kNuM, "reco");
00228    Add(fRecoEff, 1, 1003, Particle::kNuM, "reco");
00229 }


Member Data Documentation

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

Definition at line 60 of file PlotEff.h.

Referenced by Run(), and Set().

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

Definition at line 62 of file PlotEff.h.

Referenced by Config(), and Set().

bool Anp::PlotEff::fInit [private]

Definition at line 65 of file PlotEff.h.

double Anp::PlotEff::fMinCom [private]

Definition at line 69 of file PlotEff.h.

Referenced by Config(), and Run().

double Anp::PlotEff::fNMerge [private]

Definition at line 70 of file PlotEff.h.

Referenced by Config(), and End().

Definition at line 73 of file PlotEff.h.

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

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

Definition at line 63 of file PlotEff.h.

Referenced by Config().

Definition at line 72 of file PlotEff.h.

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

bool Anp::PlotEff::fTrueFid [private]

Definition at line 66 of file PlotEff.h.

Referenced by Config(), and Run().

double Anp::PlotEff::fTruthAll [private]

Definition at line 75 of file PlotEff.h.

Referenced by End(), and Run().

double Anp::PlotEff::fTruthFid [private]

Definition at line 76 of file PlotEff.h.

Referenced by End(), and Run().

double Anp::PlotEff::fTruthRec [private]

Definition at line 77 of file PlotEff.h.

Referenced by End(), and Run().

bool Anp::PlotEff::fVerbose [private]

Definition at line 67 of file PlotEff.h.

Referenced by Config(), and End().


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

Generated on 16 Jan 2018 for loon by  doxygen 1.6.1