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

Anp::PlotTruth Class Reference

#include <PlotTruth.h>

Inheritance diagram for Anp::PlotTruth:

Anp::AlgSnarl Anp::AlgEvent Anp::Base Anp::Base List of all members.

Public Member Functions

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

Private Types

typedef std::map< int, Handle<
PlotReson > > 
PlotMap

Private Member Functions

void Plot (const Truth &truth, double weight=1.0)
int CreateHist ()
TH1 * GetTH1 (const std::string &key, const std::string &name="")
Handle< PlotResonGetPlot (int ireson)

Private Attributes

TDirectory * fDir
std::string fDirName
bool fPlot
bool fPlotResn
int fNMiss
Registry fConfig
PlotMap fPlotMap
TH1 * fhAction
TH1 * fhFlags
TH1 * fhReson
TH1 * fhTgtE
TH1 * fhTgtP
TH1 * fhNRecoEvent
TH1 * fhNRecoTrack
TH1 * fhEventPur
TH1 * fhEventCom
TH1 * fhTrackPur
TH1 * fhTrackCom

Member Typedef Documentation

typedef std::map<int, Handle<PlotReson> > Anp::PlotTruth::PlotMap [private]
 

Definition at line 44 of file PlotTruth.h.


Constructor & Destructor Documentation

Anp::PlotTruth::PlotTruth  ) 
 

Definition at line 29 of file PlotTruth.cxx.

00030    :fDir(0),
00031     fDirName("truth"),
00032     fPlot(false),
00033     fPlotResn(true),
00034     fNMiss(0)
00035 {
00036 }

Anp::PlotTruth::~PlotTruth  )  [virtual]
 

Definition at line 39 of file PlotTruth.cxx.

00040 {
00041 }


Member Function Documentation

void Anp::PlotTruth::Config const Registry reg  )  [virtual]
 

Reimplemented from Anp::AlgEvent.

Definition at line 153 of file PlotTruth.cxx.

References fConfig, fDirName, fPlotResn, Registry::Get(), Registry::KeyExists(), Anp::Read(), and reg.

Referenced by GetPlot().

00154 {
00155    fConfig = reg;
00156 
00157    const char *value_char = 0;
00158    if(reg.Get("PlotTruthDirName", value_char) && value_char)
00159    {
00160       fDirName = value_char;
00161    }
00162 
00163    Anp::Read(reg, "PlotTruthResn", fPlotResn);
00164 
00165    if(reg.KeyExists("PrintConfig"))
00166    {
00167       cout << "PlotTruth::Config" << endl
00168            << "   DirName = " << fDirName << endl
00169            << "   PlotResn = " << fPlotResn << endl;
00170    }
00171 }

int Anp::PlotTruth::CreateHist  )  [private]
 

void Anp::PlotTruth::End const DataBlock  )  [virtual]
 

Reimplemented from Anp::AlgEvent.

Definition at line 174 of file PlotTruth.cxx.

00175 {
00176 }

Anp::Handle< Anp::PlotReson > Anp::PlotTruth::GetPlot int  ireson  )  [private]
 

Definition at line 259 of file PlotTruth.cxx.

References Config(), fConfig, fDir, fPlotMap, and Anp::GetDir().

00260 {
00261    if(!fDir)
00262    {
00263       return Handle<PlotReson>(0);
00264    }
00265 
00266    PlotMap::iterator pit = fPlotMap.find(ireson);
00267    if(pit == fPlotMap.end())
00268    {
00269       stringstream rname;
00270       if     (ireson == 0) rname << "nc";
00271       else if(ireson == 1) rname << "cc_numu";
00272       else if(ireson == 2) rname << "cc_numubar";
00273       else if(ireson  > 0) rname << "reson_"  << ireson;
00274             
00275       TDirectory *dir = Anp::GetDir(rname.str(), fDir);
00276       
00277       Handle<PlotReson> plot(new PlotReson(dir));
00278       plot -> Config(fConfig);
00279       
00280       pit = fPlotMap.insert(PlotMap::value_type(ireson, plot)).first;
00281    }
00282 
00283    return pit -> second;
00284 }

TH1 * Anp::PlotTruth::GetTH1 const std::string &  key,
const std::string &  name = ""
[private]
 

Definition at line 243 of file PlotTruth.cxx.

References fDir, fNMiss, and Anp::SetDir().

00244 {
00245    TH1 *h = HistMan::Instance().CreateTH1(key, "truth");
00246    if(h)
00247    {
00248       Anp::SetDir(h, fDir, name);
00249    }
00250    else
00251    {
00252       ++fNMiss;
00253    }
00254 
00255    return h;
00256 }

void Anp::PlotTruth::Plot const Truth truth,
double  weight = 1.0
[private]
 

Definition at line 179 of file PlotTruth.cxx.

References fDir, fhAction, fhEventCom, fhEventPur, fhFlags, fhNRecoEvent, fhNRecoTrack, fhReson, fhTgtE, fhTgtP, fhTrackCom, fhTrackPur, Anp::Truth::Flags(), fPlot, fPlotResn, Anp::Truth::Interaction(), Anp::Truth::RecoBeg(), Anp::Truth::RecoEnd(), Anp::Truth::Resonance(), Anp::Truth::TgtE(), Anp::Truth::TgtP(), Anp::TruthRecoIter, and Anp::Handle< T >::valid().

Referenced by Run().

00180 { 
00181    if(!fDir || !fPlot)
00182    {
00183       return;
00184    }
00185 
00186    fhAction -> Fill(truth.Interaction() + 0.5, weight);
00187    fhFlags  -> Fill(truth.Flags() + 0.5, weight);
00188    fhReson  -> Fill(truth.Resonance() + 0.5, weight);
00189    fhTgtE   -> Fill(truth.TgtE(), weight);
00190    fhTgtP   -> Fill(truth.TgtP(), weight);
00191 
00192    unsigned int nevent = 0, ntrack = 0;
00193 
00194    for(TruthRecoIter ireco = truth.RecoBeg(); ireco != truth.RecoEnd(); ++ireco)
00195    {
00196       if(ireco -> IsEvent())
00197       {
00198          ++nevent;
00199          
00200          fhEventPur -> Fill(ireco -> Purity(), weight);
00201          fhEventCom -> Fill(ireco -> ComplAll(), weight);
00202       }
00203       else if(ireco -> IsTrack())
00204       {
00205          ++ntrack;
00206 
00207          fhTrackPur -> Fill(ireco -> Purity(), weight);
00208          fhTrackCom -> Fill(ireco -> ComplAll(), weight);
00209       }
00210       else if(!ireco -> IsShower())
00211       {
00212          cerr << "PlotTruth::Plot - unknown reco type" << endl;
00213       }
00214    }
00215 
00216    fhNRecoEvent -> Fill(nevent + 0.5, weight);
00217    fhNRecoTrack -> Fill(ntrack + 0.5, weight);
00218 
00219    if(truth.Resonance() < 0)
00220    {
00221       cerr << "PlotTruth::Plot - unexpected resonance code: " << truth.Resonance() << endl;
00222    }
00223    else
00224    {
00225       Handle<PlotReson> plot = PlotTruth::GetPlot(-1);
00226       if(plot.valid())
00227       {
00228          plot -> Plot(truth, weight);
00229       }
00230    }
00231 
00232    if(fPlotResn)
00233    {
00234       Handle<PlotReson> plot = PlotTruth::GetPlot(truth.Resonance());
00235       if(plot.valid())
00236       {
00237          plot -> Plot(truth, weight);
00238       }
00239    }
00240 }

bool Anp::PlotTruth::Run Event event,
const Record record,
bool  pass
[virtual]
 

Implements Anp::AlgEvent.

Definition at line 74 of file PlotTruth.cxx.

References Anp::Record::FindTruth(), fPlot, fPlotResn, Anp::Record::GetHeader(), Anp::Header::IsData(), Plot(), Anp::Record::TruthEnd(), Anp::TruthIter, Anp::Handle< T >::valid(), and Anp::Event::Weight().

00075 { 
00076    //
00077    // Plot truth records that match reconstructed events
00078    //
00079 
00080    if(!pass || !fPlot || record.GetHeader().IsData())
00081    {
00082       return true;
00083    }
00084 
00085    const TruthIter truth = record.FindTruth(event);
00086    if(truth == record.TruthEnd())
00087    {
00088       return true;
00089    }
00090 
00091    PlotTruth::Plot(*truth, event.Weight());
00092 
00093    if(truth -> Resonance() < 1)
00094    {
00095       cerr << "PlotTruth::Plot - unexpected resonance code: " << truth -> Resonance() << endl;
00096       return false;
00097    }
00098    else
00099    {
00100       Handle<PlotReson> plot = PlotTruth::GetPlot(-1);
00101       if(plot.valid())
00102       {
00103          plot -> Plot(event, *truth);
00104       }
00105    }
00106    
00107    if(fPlotResn)
00108    {
00109       Handle<PlotReson> plot = PlotTruth::GetPlot(truth -> Resonance());
00110       if(plot.valid())
00111       {
00112          plot -> Plot(event, *truth);
00113       }
00114    }
00115 
00116    return true;
00117 }

bool Anp::PlotTruth::Run Record record  )  [virtual]
 

Implements Anp::AlgSnarl.

Definition at line 44 of file PlotTruth.cxx.

References Anp::Record::EventBegIterator(), Anp::Record::EventEndIterator(), Anp::EventIterator, Plot(), Anp::Record::TruthBegIterator(), Anp::Record::TruthEndIterator(), Anp::TruthIterator, and Anp::Handle< T >::valid().

00045 {
00046    for(EventIterator ievent = record.EventBegIterator(); ievent != record.EventEndIterator(); ++ievent)
00047    {
00048       PlotTruth::Run(*ievent, record, true);
00049    }
00050 
00051    for(TruthIterator itruth = record.TruthBegIterator(); itruth != record.TruthEndIterator(); ++itruth)
00052    {      
00053       short ikey = 10;
00054 
00055       if     (itruth -> IsNC())                          ikey = 0;
00056       else if(itruth -> Particle() == Particle::kNuM)    ikey = 1;
00057       else if(itruth -> Particle() == Particle::kNuMBar) ikey = 2;
00058       else
00059       {
00060          continue;
00061       }
00062 
00063       Handle<PlotReson> plot = PlotTruth::GetPlot(ikey);
00064       if(plot.valid())
00065       {
00066          plot -> Plot(*itruth, itruth -> Weight());
00067       }
00068    }
00069 
00070    return true;
00071 }

void Anp::PlotTruth::Set TDirectory *  dir  )  [virtual]
 

Reimplemented from Anp::AlgEvent.

Definition at line 120 of file PlotTruth.cxx.

References fDir, fDirName, fhAction, fhEventCom, fhEventPur, fhFlags, fhNRecoEvent, fhNRecoTrack, fhReson, fhTgtE, fhTgtP, fhTrackCom, fhTrackPur, fNMiss, fPlot, and Anp::GetDir().

00121 {
00122    if(!dir)
00123    {
00124       return;
00125    }
00126    
00127    fDir = Anp::GetDir(fDirName, dir);
00128    fPlot = false;
00129 
00130    fhAction     = PlotTruth::GetTH1("action");
00131    fhFlags      = PlotTruth::GetTH1("flags");
00132    fhReson      = PlotTruth::GetTH1("reson");
00133    fhTgtE       = PlotTruth::GetTH1("tgte");
00134    fhTgtP       = PlotTruth::GetTH1("tgtp");
00135    fhNRecoEvent = PlotTruth::GetTH1("reco_nevent");
00136    fhNRecoTrack = PlotTruth::GetTH1("reco_ntrack");
00137    fhEventPur   = PlotTruth::GetTH1("event_pur");
00138    fhEventCom   = PlotTruth::GetTH1("event_com");
00139    fhTrackPur   = PlotTruth::GetTH1("track_pur");
00140    fhTrackCom   = PlotTruth::GetTH1("track_com");   
00141 
00142    if(fNMiss == 0)
00143    {
00144       fPlot = true;
00145    }
00146    else
00147    {
00148       cerr << "PlotTruth::Set - missed " << fNMiss << " histograms" << endl;
00149    }
00150 }


Member Data Documentation

Registry Anp::PlotTruth::fConfig [private]
 

Definition at line 66 of file PlotTruth.h.

Referenced by Config(), and GetPlot().

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

Definition at line 58 of file PlotTruth.h.

Referenced by GetPlot(), GetTH1(), Plot(), and Set().

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

Definition at line 60 of file PlotTruth.h.

Referenced by Config(), and Set().

TH1* Anp::PlotTruth::fhAction [private]
 

Definition at line 70 of file PlotTruth.h.

Referenced by Plot(), and Set().

TH1* Anp::PlotTruth::fhEventCom [private]
 

Definition at line 80 of file PlotTruth.h.

Referenced by Plot(), and Set().

TH1* Anp::PlotTruth::fhEventPur [private]
 

Definition at line 79 of file PlotTruth.h.

Referenced by Plot(), and Set().

TH1* Anp::PlotTruth::fhFlags [private]
 

Definition at line 71 of file PlotTruth.h.

Referenced by Plot(), and Set().

TH1* Anp::PlotTruth::fhNRecoEvent [private]
 

Definition at line 76 of file PlotTruth.h.

Referenced by Plot(), and Set().

TH1* Anp::PlotTruth::fhNRecoTrack [private]
 

Definition at line 77 of file PlotTruth.h.

Referenced by Plot(), and Set().

TH1* Anp::PlotTruth::fhReson [private]
 

Definition at line 72 of file PlotTruth.h.

Referenced by Plot(), and Set().

TH1* Anp::PlotTruth::fhTgtE [private]
 

Definition at line 73 of file PlotTruth.h.

Referenced by Plot(), and Set().

TH1* Anp::PlotTruth::fhTgtP [private]
 

Definition at line 74 of file PlotTruth.h.

Referenced by Plot(), and Set().

TH1* Anp::PlotTruth::fhTrackCom [private]
 

Definition at line 83 of file PlotTruth.h.

Referenced by Plot(), and Set().

TH1* Anp::PlotTruth::fhTrackPur [private]
 

Definition at line 82 of file PlotTruth.h.

Referenced by Plot(), and Set().

int Anp::PlotTruth::fNMiss [private]
 

Definition at line 64 of file PlotTruth.h.

Referenced by GetTH1(), and Set().

bool Anp::PlotTruth::fPlot [private]
 

Definition at line 62 of file PlotTruth.h.

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

PlotMap Anp::PlotTruth::fPlotMap [private]
 

Definition at line 68 of file PlotTruth.h.

Referenced by GetPlot().

bool Anp::PlotTruth::fPlotResn [private]
 

Definition at line 63 of file PlotTruth.h.

Referenced by Config(), Plot(), and Run().


The documentation for this class was generated from the following files:
Generated on Sat Feb 7 22:52:52 2009 for loon by doxygen 1.3.5