Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

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

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]
 

Definition at line 217 of file PlotPur.cxx.

References fDir, find(), fTH1Name, Anp::GetDir(), and Particle::Name().

Referenced by Set().

00219 {
00220    Handle<CountHist> hist(new CountHist(action, reson, particle));
00221   
00222    if(std::find(pvec.begin(), pvec.end(), hist) != pvec.end())
00223    {
00224       cerr << "PlotPur::Create - key already exists" << endl;
00225       return false;
00226    }
00227 
00228    string name, title;
00229    
00230    if     (action == 1) name = "cc";
00231    else if(action == 0) name = "nc";
00232    else if(action  < 0) name = "all";
00233    else
00234    {
00235       return false;
00236    }
00237 
00238    if(true)
00239    {
00240       Anp::Lock<Mutex> lock(Anp::GetMainMutex());
00241       name = name + "_" + Particle::Name(particle);
00242    }
00243 
00244    if     (reson == 1001) name = name + "_qes";
00245    else if(reson == 1002) name = name + "_res";
00246    else if(reson == 1003) name = name + "_dis";
00247 
00248    TDirectory *dir = 0;
00249    
00250    if(opt.find("reco") != string::npos)
00251    {
00252       title = "reco E_{#nu} (GeV)";
00253       dir = Anp::GetDir("reco", fDir);
00254    }
00255    else if(opt.find("true") != string::npos)
00256    {
00257       title = "true E_{#nu} (GeV)";
00258       dir = Anp::GetDir("true", fDir);
00259    }
00260    else
00261    {
00262       return false;
00263    }      
00264    
00265    const string name1 = "all_" + name;
00266    const string name2 = "sel_" + name;
00267    const string name3 = "pur_" + name;
00268 
00269    hist -> nmin = fNMerge;
00270    hist -> hall = PlotPur::GetTH1(dir, fTH1Name, name1, title, "all events");
00271    hist -> hsel = PlotPur::GetTH1(dir, fTH1Name, name2, title, "selected events");
00272    hist -> hrat = PlotPur::GetTH1(dir, fTH1Name, name3, title, "purity");
00273 
00274    if(hist -> Valid())
00275    {
00276       pvec.push_back(hist);
00277    }
00278    else
00279    {
00280       return false;
00281    }
00282 
00283    return true;
00284 }

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(), Registry::KeyExists(), and reg.

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, 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]
 

Definition at line 287 of file PlotPur.cxx.

References Anp::SetDir().

00291 {
00292    if(!dir)
00293    {
00294       return 0;
00295    }
00296 
00297    TH1 *h = HistMan::Instance().CreateTH1(key, "pur");
00298    if(h)
00299    {
00300       h -> GetXaxis() -> SetTitle(xtitle.c_str());
00301       h -> GetYaxis() -> SetTitle(ytitle.c_str());
00302       h -> GetXaxis() -> CenterTitle();
00303       h -> GetYaxis() -> CenterTitle();
00304       Anp::SetDir(h, dir, name);
00305    }
00306 
00307    return h;
00308 }

bool Anp::PlotPur::IsMatch Handle< CountHist > &  hist,
const Truth truth
const [private]
 

Definition at line 311 of file PlotPur.cxx.

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

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(), Anp::Record::TruthBeg(), Anp::Record::TruthEnd(), Anp::TruthIter, Anp::Handle< T >::valid(), and Anp::Event::Weight().

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(), Anp::EventIterator, 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, and Anp::GetDir().

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 Add(), 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().

PurVec Anp::PlotPur::fReco [private]
 

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 Add(), and Config().

PurVec Anp::PlotPur::fTrue [private]
 

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 Mon Feb 15 11:10:33 2010 for loon by  doxygen 1.3.9.1