Anp::PlotReson Class Reference

#include <PlotReson.h>

Inheritance diagram for Anp::PlotReson:
Anp::Base

List of all members.

Public Member Functions

 PlotReson (TDirectory *dir)
virtual ~PlotReson ()
void Plot (const Truth &truth, double weight=1.0)
void Plot (const Event &event, const Truth &truth)
void Config (const Registry &reg)

Private Types

typedef Handle< PlotResolPlotPtr

Private Member Functions

PlotPtr GetPlot (int ibin)
TH1 * GetTH1 (const std::string &key, const std::string &name="")
TH2 * GetTH2 (const std::string &key, const std::string &name="")

Private Attributes

bool fPlot
bool fPlot2d
bool fPlotResol
int fNMiss
double fENeuMax
TDirectory * fDir
TH1 * fhENeu
TH1 * fhENeuFid
TH1 * fhELep
TH1 * fhEHad
TH1 * fhTrueY
TH1 * fhTrueX
TH1 * fhTrueQ2
TH1 * fhTrueW2
TH1 * fhWeight
TH2 * fhEneuDiffvsTrue
TH2 * fhEneuDiffvsReco
TH2 * fhElepDiffvsTrue
TH2 * fhElepDiffvsReco
TH2 * fhEhadDiffvsTrue
TH2 * fhEhadDiffvsReco
std::map< int, PlotPtrfPlotMap

Detailed Description

Definition at line 27 of file PlotReson.h.


Member Typedef Documentation

Definition at line 42 of file PlotReson.h.


Constructor & Destructor Documentation

Anp::PlotReson::PlotReson ( TDirectory *  dir  )  [explicit]

Definition at line 26 of file PlotReson.cxx.

00027    :fPlot(false),
00028     fPlot2d(false),
00029     fPlotResol(true),
00030     fNMiss(0),
00031     fENeuMax(20.0),
00032     fDir(dir)
00033 {
00034 }

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

Definition at line 37 of file PlotReson.cxx.

00038 {
00039 }


Member Function Documentation

void Anp::PlotReson::Config ( const Registry reg  ) 

Definition at line 114 of file PlotReson.cxx.

References fDir, fENeuMax, fhEHad, fhEhadDiffvsReco, fhEhadDiffvsTrue, fhELep, fhElepDiffvsReco, fhElepDiffvsTrue, fhENeu, fhEneuDiffvsReco, fhEneuDiffvsTrue, fhENeuFid, fhTrueQ2, fhTrueW2, fhTrueX, fhTrueY, fhWeight, fNMiss, fPlot, fPlot2d, fPlotResol, Registry::Get(), GetTH1(), GetTH2(), Registry::KeyExists(), and Anp::Read().

00115 {
00116    if(!fDir)
00117    {
00118       cerr << "PlotReson::Config - invalid TDirectory pointer" << endl;
00119       return;
00120    }
00121 
00122    Anp::Read(reg, "PlotTruth2d",    fPlot2d);
00123    Anp::Read(reg, "PlotTruthResol", fPlotResol);
00124 
00125    reg.Get("PlotResonENeuMax", fENeuMax);
00126 
00127    if(reg.KeyExists("PlotResonPrintConfig"))
00128    {
00129       cout << "PlotReson::Config" << endl
00130            << "   Plot2d = " << fPlot2d << endl
00131            << "   PlotResol = " << fPlotResol << endl
00132            << "   ENeuMax = " << fENeuMax << endl;
00133    }
00134 
00135    fPlot = false;
00136 
00137    fhENeu    = PlotReson::GetTH1("true_eneu");
00138    fhENeuFid = PlotReson::GetTH1("true_eneu", "true_eneu_fid");
00139    fhELep    = PlotReson::GetTH1("true_elep");
00140    fhEHad    = PlotReson::GetTH1("true_ehad");
00141    fhTrueY   = PlotReson::GetTH1("true_y");
00142    fhTrueX   = PlotReson::GetTH1("true_x");
00143    fhTrueQ2  = PlotReson::GetTH1("true_q2");
00144    fhTrueW2  = PlotReson::GetTH1("true_w2");
00145    fhWeight  = PlotReson::GetTH1("weight");
00146 
00147    if(fPlot2d)
00148    {
00149       fhEneuDiffvsTrue = PlotReson::GetTH2("eneu_diff_vs_true");
00150       fhElepDiffvsTrue = PlotReson::GetTH2("elep_diff_vs_true");
00151       fhEhadDiffvsTrue = PlotReson::GetTH2("ehad_diff_vs_true");
00152       
00153       fhEneuDiffvsReco = PlotReson::GetTH2("enu_diff_vs_reco");
00154       fhElepDiffvsReco = PlotReson::GetTH2("elep_diff_vs_reco");
00155       fhEhadDiffvsReco = PlotReson::GetTH2("ehad_diff_vs_reco");
00156    }
00157 
00158    if(fNMiss == 0)
00159    {
00160       fPlot = true;
00161    }
00162    else
00163    {
00164       cerr << "PlotReson::Config - missed " << fNMiss << " histograms" << endl;
00165    }
00166 }

Anp::PlotReson::PlotPtr Anp::PlotReson::GetPlot ( int  ibin  )  [private]

Definition at line 169 of file PlotReson.cxx.

References fDir, fPlotMap, Anp::GetDir(), and Munits::second.

Referenced by Plot().

00170 {
00171    if(ibin < 0)
00172    {
00173       ibin = -1;
00174    }
00175 
00176    map<int, PlotPtr>::iterator pit = fPlotMap.find(ibin);
00177    if(pit == fPlotMap.end())
00178    {
00179       stringstream dname;      
00180       if(ibin >= 0)
00181       {
00182          dname << "resol_" << setfill('0') << setw(3) << ibin;
00183       }
00184       
00185       TDirectory *dir = Anp::GetDir(dname.str(), fDir);
00186       if(!dir)
00187       {
00188          cerr << "PlotReson::GetPlot - failed to create TDirectory " << dname.str() << endl;
00189       }
00190       
00191       pit = fPlotMap.insert(map<int, PlotPtr>::value_type(ibin,
00192                                                           PlotReson::PlotPtr(new PlotResol(dir)))).first;
00193    }
00194 
00195    return pit -> second;
00196 }

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

Referenced by Config().

TH2* Anp::PlotReson::GetTH2 ( const std::string &  key,
const std::string &  name = "" 
) [private]

Referenced by Config().

void Anp::PlotReson::Plot ( const Event event,
const Truth truth 
)

Definition at line 65 of file PlotReson.cxx.

References Anp::Truth::EHad(), Anp::RecoNu::EHad(), Anp::RecoNu::ELep(), Anp::Truth::ELep(), Anp::Truth::ENeu(), Anp::RecoNu::ENeu(), fDir, fENeuMax, fhEhadDiffvsReco, fhEhadDiffvsTrue, fhElepDiffvsReco, fhElepDiffvsTrue, fhEneuDiffvsReco, fhEneuDiffvsTrue, fPlot, fPlot2d, fPlotResol, GetPlot(), Plot(), Anp::Handle< T >::valid(), and Anp::RecoNu::Weight().

00066 {
00067    if(!fPlot || !fDir)
00068    {
00069       return;
00070    }
00071 
00072    const RecoNu &recon = event.GetNu();
00073 
00074    const double eneu_diff = recon.ENeu() - truth.ENeu();
00075    const double elep_diff = recon.ELep() - truth.ELep();
00076    const double ehad_diff = recon.EHad() - truth.EHad();
00077    
00078    if(fPlot2d)
00079    {
00080       fhEneuDiffvsTrue -> Fill(truth.ENeu(), eneu_diff, recon.Weight());
00081       fhEneuDiffvsReco -> Fill(recon.ENeu(), eneu_diff, recon.Weight());
00082       
00083       fhElepDiffvsTrue -> Fill(truth.ELep(), elep_diff, recon.Weight());
00084       fhElepDiffvsReco -> Fill(recon.ELep(), elep_diff, recon.Weight());
00085       
00086       fhEhadDiffvsTrue -> Fill(truth.EHad(), ehad_diff, recon.Weight());
00087       fhEhadDiffvsReco -> Fill(recon.EHad(), ehad_diff, recon.Weight());
00088    }
00089 
00090    PlotPtr plot = PlotReson::GetPlot(-1);
00091    if(plot.valid())
00092    {
00093       plot -> Plot(event, truth);
00094    }
00095 
00096    if(fPlotResol)
00097    {           
00098       int ibin = static_cast<int>(truth.ENeu());
00099 
00100       if(fENeuMax > 0.0 && fENeuMax < truth.ENeu())
00101       {
00102          ibin = static_cast<int>(fENeuMax);
00103       }
00104     
00105       PlotPtr iplot = PlotReson::GetPlot(ibin);
00106       if(iplot.valid())
00107       {
00108          iplot -> Plot(event, truth);
00109       }
00110    }
00111 }

void Anp::PlotReson::Plot ( const Truth truth,
double  weight = 1.0 
)

Definition at line 42 of file PlotReson.cxx.

References Anp::Truth::EHad(), Anp::Truth::ELep(), Anp::Truth::Energy(), fDir, fhEHad, fhELep, fhENeu, fhENeuFid, fhTrueQ2, fhTrueW2, fhTrueX, fhTrueY, fhWeight, fPlot, Anp::Truth::GetVtx(), Anp::Vertex::IsFiducial(), Anp::Truth::TrueQ2(), Anp::Truth::TrueW2(), Anp::Truth::TrueX(), and Anp::Truth::TrueY().

Referenced by Plot().

00043 { 
00044    if(!fPlot || !fDir)
00045    {
00046       return;
00047    }
00048   
00049    fhENeu   -> Fill( truth.Energy(), weight);
00050    fhELep   -> Fill( truth.ELep(),   weight);
00051    fhEHad   -> Fill( truth.EHad(),   weight);
00052    fhTrueY  -> Fill( truth.TrueY(),  weight);
00053    fhTrueX  -> Fill( truth.TrueX(),  weight);
00054    fhTrueQ2 -> Fill(-truth.TrueQ2(), weight);
00055    fhTrueW2 -> Fill( truth.TrueW2(), weight);
00056    fhWeight -> Fill( weight);
00057 
00058    if(truth.GetVtx().IsFiducial())
00059    {
00060       fhENeuFid -> Fill(truth.Energy(), weight);
00061    }
00062 }


Member Data Documentation

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

Definition at line 60 of file PlotReson.h.

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

double Anp::PlotReson::fENeuMax [private]

Definition at line 58 of file PlotReson.h.

Referenced by Config(), and Plot().

TH1* Anp::PlotReson::fhEHad [private]

Definition at line 65 of file PlotReson.h.

Referenced by Config(), and Plot().

Definition at line 80 of file PlotReson.h.

Referenced by Config(), and Plot().

Definition at line 79 of file PlotReson.h.

Referenced by Config(), and Plot().

TH1* Anp::PlotReson::fhELep [private]

Definition at line 64 of file PlotReson.h.

Referenced by Config(), and Plot().

Definition at line 77 of file PlotReson.h.

Referenced by Config(), and Plot().

Definition at line 76 of file PlotReson.h.

Referenced by Config(), and Plot().

TH1* Anp::PlotReson::fhENeu [private]

Definition at line 62 of file PlotReson.h.

Referenced by Config(), and Plot().

Definition at line 74 of file PlotReson.h.

Referenced by Config(), and Plot().

Definition at line 73 of file PlotReson.h.

Referenced by Config(), and Plot().

TH1* Anp::PlotReson::fhENeuFid [private]

Definition at line 63 of file PlotReson.h.

Referenced by Config(), and Plot().

TH1* Anp::PlotReson::fhTrueQ2 [private]

Definition at line 69 of file PlotReson.h.

Referenced by Config(), and Plot().

TH1* Anp::PlotReson::fhTrueW2 [private]

Definition at line 70 of file PlotReson.h.

Referenced by Config(), and Plot().

TH1* Anp::PlotReson::fhTrueX [private]

Definition at line 68 of file PlotReson.h.

Referenced by Config(), and Plot().

TH1* Anp::PlotReson::fhTrueY [private]

Definition at line 67 of file PlotReson.h.

Referenced by Config(), and Plot().

TH1* Anp::PlotReson::fhWeight [private]

Definition at line 71 of file PlotReson.h.

Referenced by Config(), and Plot().

int Anp::PlotReson::fNMiss [private]

Definition at line 56 of file PlotReson.h.

Referenced by Config().

bool Anp::PlotReson::fPlot [private]

Definition at line 53 of file PlotReson.h.

Referenced by Config(), and Plot().

bool Anp::PlotReson::fPlot2d [private]

Definition at line 54 of file PlotReson.h.

Referenced by Config(), and Plot().

std::map<int, PlotPtr> Anp::PlotReson::fPlotMap [private]

Definition at line 82 of file PlotReson.h.

Referenced by GetPlot().

Definition at line 55 of file PlotReson.h.

Referenced by Config(), and Plot().


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

Generated on 18 Oct 2018 for loon by  doxygen 1.6.1