Anp::PlotShortSelect Class Reference

#include <PlotShortSelect.h>

Inheritance diagram for Anp::PlotShortSelect:
Anp::AlgSnarl Anp::Base

List of all members.

Public Member Functions

 PlotShortSelect ()
virtual ~PlotShortSelect ()
bool Run (Record &record)
void Set (TDirectory *dir)
void Config (const Registry &reg)

Private Types

typedef std::map< std::string,
TH1 * > 
MapTH1
typedef std::map< std::string,
TH2 * > 
MapTH2

Private Member Functions

bool Plot (const TruthIter truth, const Record &record)
TH1 * GetTH1 (const std::string &key, const std::string &name="", TDirectory *dir=0)
TH2 * GetTH2 (const std::string &key, const std::string &name="", TDirectory *dir=0, const std::string &plottype="unknown")
Particle::Particle_t Particle (const Track &track, const Record &record) const

Private Attributes

std::string fDirName
TDirectory * fDir
int fPid
int fLowPid
int fSelector
double fPidCut
double fLowCut
double fSelCut
double fMinCom
bool fErase
bool fPlot
bool fTrueFid
int fNMiss
std::vector< int > fKeys
std::map< std::string, TH1 * > fMapTH1
std::map< std::string, TH2 * > fMapTH2

Detailed Description

Definition at line 23 of file PlotShortSelect.h.


Member Typedef Documentation

typedef std::map<std::string, TH1 *> Anp::PlotShortSelect::MapTH1 [private]

Definition at line 50 of file PlotShortSelect.h.

typedef std::map<std::string, TH2 *> Anp::PlotShortSelect::MapTH2 [private]

Definition at line 51 of file PlotShortSelect.h.


Constructor & Destructor Documentation

Anp::PlotShortSelect::PlotShortSelect (  ) 

Definition at line 27 of file PlotShortSelect.cxx.

00028   :fDirName("shorteff"),
00029    fDir(0),
00030    fPid(4280),
00031    fLowPid(2695),
00032    fSelector(19480),
00033    fPidCut(0.4),
00034    fLowCut(0.3),
00035    fSelCut(0.8),
00036    fMinCom(0.9),
00037    fErase(false),
00038    fPlot(true),
00039    fTrueFid(true),
00040    fNMiss(0)
00041 {
00042 }

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

Definition at line 45 of file PlotShortSelect.cxx.

00046 {
00047 }


Member Function Documentation

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

Reimplemented from Anp::AlgSnarl.

Definition at line 85 of file PlotShortSelect.cxx.

References fDirName, fLowCut, fLowPid, fPid, fPidCut, fSelCut, fSelector, fTrueFid, Registry::Get(), Registry::KeyExists(), and Anp::Read().

00086 {
00087    //
00088    // Read string configurations
00089    //
00090   Anp::Read(reg,"PlotShortSelectDirName", fDirName);
00091   reg.Get("PlotShortSelectPid",fPid);
00092   reg.Get("PlotShortSelectLowPid",fLowPid);
00093   reg.Get("PlotShortSelectSelector", fSelector);
00094   reg.Get("PlotShortSelectPidCut",fPidCut);
00095   reg.Get("PlotShortSelectLowPidCut",fLowCut);
00096   reg.Get("PlotShortSelectSelCut", fSelCut);
00097   Anp::Read(reg, "PlotShortSelectFiducial", fTrueFid) ;
00098    if(reg.KeyExists("PrintConfig"))
00099    {
00100       cout << "PlotShortSelect::Config" << endl
00101            << "   DirName = " << fDirName << endl
00102            << "   Pid = "<<fPid<<endl
00103            << "   LowPid = "<<fLowPid<<endl
00104            << "   Selector = "<<fSelector<<endl
00105            << "   PidCut ="<< fPidCut<< endl
00106            << "   LowPidCut="<<fLowCut<< endl
00107            << "   SelectorCut="<<fSelCut<<endl
00108            << "   TrueFiducial = " <<fTrueFid<<endl;
00109    }
00110 }

TH1* Anp::PlotShortSelect::GetTH1 ( const std::string &  key,
const std::string &  name = "",
TDirectory *  dir = 0 
) [private]

Referenced by Plot().

TH2* Anp::PlotShortSelect::GetTH2 ( const std::string &  key,
const std::string &  name = "",
TDirectory *  dir = 0,
const std::string &  plottype = "unknown" 
) [private]
Particle::Particle_t Anp::PlotShortSelect::Particle ( const Track track,
const Record record 
) const [private]

Definition at line 295 of file PlotShortSelect.cxx.

References Anp::Record::FindStdHep(), Anp::Record::GetHeader(), Anp::Header::IsData(), Particle::kMuon, Particle::kMuonNeg, Particle::kMuonPos, Particle::kNotMuon, Particle::kUnknown, Anp::Record::StdHepBeg(), and Anp::Record::StdHepEnd().

Referenced by Plot().

00296 {
00297   if(record.GetHeader().IsData())
00298     {
00299       return Particle::kUnknown;
00300     }
00301 
00302   if(record.StdHepBeg() != record.StdHepEnd())
00303     {
00304       const StdHepIter stdhep = record.FindStdHep(track);
00305       if(stdhep == record.StdHepEnd())
00306         {
00307           return Particle::kUnknown;
00308         }
00309 
00310       if(stdhep -> Particle() == Particle::kMuonPos ||
00311          stdhep -> Particle() == Particle::kMuonNeg)
00312         {
00313           return Particle::kMuon;
00314         }
00315       else
00316         {
00317 
00318           return Particle::kNotMuon;
00319         }
00320     }
00321 
00322   return Particle::kUnknown;
00323 }

bool Anp::PlotShortSelect::Plot ( const TruthIter  truth,
const Record record 
) [private]

Definition at line 114 of file PlotShortSelect.cxx.

References Anp::Event::DataAt(), Anp::Record::EventBeg(), Anp::Record::EventEnd(), fDir, find(), Anp::Record::FindEvent(), fLowCut, fLowPid, fMinCom, fPid, fPidCut, fPlot, fSelCut, fSelector, fTrueFid, Anp::GetDir(), Anp::Event::GetRecoNu(), GetTH1(), it, Anp::Event::KeyExists(), Particle::kMuonNeg, Particle::kMuonPos, Anp::LongestTrack(), Munits::m, Particle(), Anp::Record::TrackEnd(), and Anp::RecoNu::Y().

Referenced by Run().

00115 { 
00116   double weight_all = 1.0;
00117 
00118   if(fTrueFid && truth->GetVtx().IsFiducial())
00119   {
00120     weight_all = truth->Weight();   
00121   }
00122   if(!fDir || !fPlot)
00123   {
00124     return false;
00125   }
00126   EventIter event = record.EventEnd(); 
00127   std::map<std::string, double>  hist_map;
00128   bool withtrack =false;
00129   bool pid1pass=false;
00130   bool pid2pass=false;
00131   bool pid3pass=false;
00132   double weight_sel= 0.0;
00133   double weight_evt = 0.0;
00134   for(TruthRecoIter ireco = truth->RecoBeg(); ireco  !=truth->RecoEnd(); ++ireco)
00135   {
00136     if(!(ireco -> IsEvent()) || ireco -> ComplAll() < fMinCom)
00137     {
00138       continue;
00139     }
00140             
00141     if(std::find(record.EventBeg(), record.EventEnd(), ireco->RecoIndex()) != record.EventEnd())
00142     {
00143       weight_sel += truth->Weight();
00144     
00145       event = record.FindEvent(ireco->RecoIndex());
00146       weight_evt += event->Weight();
00147     }
00148   }       
00149          
00150   const TrackIter track = Anp::LongestTrack((*event),record);
00151   string eventdir = "unknown";
00152   if(truth->IsCC()){
00153     eventdir = "cc";
00154     hist_map["iaction"] =1;
00155   }
00156   else if(truth->IsNC()){
00157     eventdir = "nc";
00158     hist_map["iaction"]=0;
00159   }
00160   else{
00161     eventdir="other";
00162     hist_map["iaction"]=2;
00163   }
00164 
00165   TDirectory* evtdir = Anp::GetDir(eventdir,fDir); // cc or nc (or other)    
00166 
00167   TH1* recoE =(TH1*) PlotShortSelect::GetTH1("reco_enu_base","reco_enu_base", evtdir);
00168   if(recoE && event!=record.EventEnd())recoE->Fill(event->Gev(), weight_all);
00169 
00170   TH1* trueE =(TH1*) PlotShortSelect::GetTH1("true_enu_base","true_enu_base", evtdir);
00171   if(trueE) trueE->Fill(truth->Energy(), weight_all);
00172 
00173   TH1* recoY =(TH1*) PlotShortSelect::GetTH1("reco_y_base","reco_y_base", evtdir);
00174   Event evt = *event;
00175   RecoNu &rnu = (evt).GetRecoNu();
00176   if(recoY) recoY->Fill(rnu.Y(), weight_all);
00177 
00178   //
00179   // Get Event base quantities
00180   //
00181 
00182   hist_map["reco_enu"] = event->Gev();
00183   hist_map["true_enu"] = truth->Energy();
00184   hist_map["reco_y"] = (evt.GetRecoNu()).Y();
00185   
00186 
00187   if(track==(record.TrackEnd()))
00188   {
00189     if(evt.KeyExists(fSelector) && evt.DataAt(fSelector) > fSelCut) pid3pass=true; 
00190   }
00191   else
00192   {
00193     //
00194     // event has a track, see if it passes rustem's or  lowE kNN
00195     //
00196     withtrack=true;
00197     const Particle::Particle_t particle = PlotShortSelect::Particle(*track, record);
00198     if(!track->KeyExists(fPid) && !track->KeyExists(fLowPid)) return false;
00199    
00200     if(track->KeyExists(fPid) && track->DataAt(fPid) > fPidCut) pid1pass =true;
00201     if(track->KeyExists(fLowPid) && track->DataAt(fLowPid) >fLowCut)pid2pass =true;
00202     if(!pid1pass && !pid2pass) return false;
00203 
00204     if(particle == Particle::kMuonPos  || particle== Particle::kMuonNeg)hist_map["track_id"] = 1;
00205     else hist_map["track_id"] =0;
00206   }
00207 
00208   //
00209   // Fill Histograms
00210   //
00211 
00212   string passdir = "unknown";
00213   if(track==record.TrackEnd()) passdir = "no-track";
00214   else    passdir = "track";
00215 
00216   //
00217   //
00218   //
00219                                                                       
00220   TDirectory* pasdir  =Anp::GetDir(passdir,evtdir); // track or no-track event
00221   TDirectory* pid1dir =Anp::GetDir("firstpass",evtdir); // passed pid1  
00222   TDirectory* pid2dir =Anp::GetDir("secondpass",evtdir); // passed pid2 but not pid1        
00223   TDirectory* pid3dir =Anp::GetDir("thirdpass",evtdir); // passed pid3 but not pid2 or pid1  
00224   for( std::map<std::string, double>::iterator it = hist_map.begin(); it!=hist_map.end(); it++)
00225   {
00226     TH1* h =(TH1*) PlotShortSelect::GetTH1(it->first,it->first, evtdir);
00227     if(h)h->Fill(it->second, weight_sel);
00228     
00229     TH1* j =(TH1*) PlotShortSelect::GetTH1(it->first,it->first, pasdir);
00230     if(j)j->Fill(it->second, weight_sel);
00231 
00232     if(pid1pass) {
00233       TH1* k =(TH1*) PlotShortSelect::GetTH1(it->first,it->first, pid1dir);
00234       if(k)k->Fill(it->second, weight_sel);
00235     }
00236     else if(pid2pass) {
00237       TH1* l =(TH1*) PlotShortSelect::GetTH1(it->first,it->first, pid2dir);
00238       if(l)l->Fill(it->second, weight_sel);
00239     }
00240     else if(pid3pass) {
00241       TH1* m =(TH1*) PlotShortSelect::GetTH1(it->first,it->first, pid3dir);
00242       if(m)m->Fill(it->second, weight_sel);
00243     }
00244 
00245   }
00246 
00247   return true;
00248 }

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

Implements Anp::AlgSnarl.

Definition at line 50 of file PlotShortSelect.cxx.

References fErase, Anp::Record::GetHeader(), Anp::Header::IsData(), Plot(), Anp::Record::TruthBeg(), and Anp::Record::TruthEnd().

00051 {
00052   if( record.GetHeader().IsData() || record.TruthBeg() == record.TruthEnd()) return true;
00053   for(TruthIter itruth = record.TruthBeg(); itruth != record.TruthEnd(); ++itruth)
00054   {     
00055     if(!PlotShortSelect::Plot(itruth, record) && fErase)
00056     {
00057       //      ievent= record.Erase(ievent);
00058     }
00059   }
00060    return true;
00061 }

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

Reimplemented from Anp::AlgSnarl.

Definition at line 64 of file PlotShortSelect.cxx.

References fDir, fDirName, fNMiss, fPlot, and Anp::GetDir().

00065 {
00066 
00067    if(!dir)
00068    {
00069       return;
00070    }
00071    
00072    fDir = Anp::GetDir(fDirName, dir);
00073 
00074    if(fNMiss == 0)
00075    {
00076       fPlot = true;
00077    }
00078    else
00079    {
00080       cerr << "PlotShortSelect::Set - missed " << fNMiss << " histograms" << endl;
00081    }
00082 }


Member Data Documentation

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

Definition at line 56 of file PlotShortSelect.h.

Referenced by Plot(), and Set().

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

Definition at line 55 of file PlotShortSelect.h.

Referenced by Config(), and Set().

Definition at line 65 of file PlotShortSelect.h.

Referenced by Run().

std::vector<int> Anp::PlotShortSelect::fKeys [private]

Definition at line 70 of file PlotShortSelect.h.

Definition at line 62 of file PlotShortSelect.h.

Referenced by Config(), and Plot().

Definition at line 59 of file PlotShortSelect.h.

Referenced by Config(), and Plot().

std::map<std::string, TH1 *> Anp::PlotShortSelect::fMapTH1 [private]

Definition at line 72 of file PlotShortSelect.h.

std::map<std::string, TH2 *> Anp::PlotShortSelect::fMapTH2 [private]

Definition at line 73 of file PlotShortSelect.h.

Definition at line 64 of file PlotShortSelect.h.

Referenced by Plot().

Definition at line 68 of file PlotShortSelect.h.

Referenced by Set().

Definition at line 58 of file PlotShortSelect.h.

Referenced by Config(), and Plot().

Definition at line 61 of file PlotShortSelect.h.

Referenced by Config(), and Plot().

Definition at line 66 of file PlotShortSelect.h.

Referenced by Plot(), and Set().

Definition at line 63 of file PlotShortSelect.h.

Referenced by Config(), and Plot().

Definition at line 60 of file PlotShortSelect.h.

Referenced by Config(), and Plot().

Definition at line 67 of file PlotShortSelect.h.

Referenced by Config(), and Plot().


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

Generated on 11 Jan 2018 for loon by  doxygen 1.6.1