Anp::SelectCount Class Reference

#include <SelectCount.h>

Inheritance diagram for Anp::SelectCount:
Anp::AlgEvent Anp::Base

List of all members.

Public Types

typedef std::map< std::pair
< int, int >, Select::Count
KeyMap
typedef std::map< unsigned int,
KeyMap
CountMap

Public Member Functions

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

Private Member Functions

Select::CountGetCount (int iaction, Particle::Particle_t particle, int select, const std::string &opt="")
void Print (int iaction, const std::string &opt, std::ostream &out) const

Private Attributes

TDirectory * fDir
std::string fDirName
std::string fAlgName
Registry fConfig
bool fPrint
bool fWeight
bool fTotalOnlyNC
bool fTotalOnlyNue
int fRun
int fSnarl
int fIndex
unsigned int fCount
unsigned int fNameWidth
unsigned int fNumbWidth
CountMap fMap

Detailed Description

Definition at line 42 of file SelectCount.h.


Member Typedef Documentation

typedef std::map<unsigned int, KeyMap> Anp::SelectCount::CountMap

Definition at line 60 of file SelectCount.h.

typedef std::map<std::pair<int, int>, Select::Count> Anp::SelectCount::KeyMap

Definition at line 59 of file SelectCount.h.


Constructor & Destructor Documentation

Anp::SelectCount::SelectCount (  ) 

Definition at line 51 of file SelectCount.cxx.

References fConfig, and Registry::Set().

00052    :fDir(0),
00053     fDirName(""),
00054     fAlgName(),
00055     fConfig(false),
00056     fPrint(true),
00057     fWeight(true),
00058     fTotalOnlyNC(true),
00059     fTotalOnlyNue(true),
00060     fRun(-1),
00061     fSnarl(-1),
00062     fIndex(-1),
00063     fCount(0),
00064     fNameWidth(0),
00065     fNumbWidth(0),
00066     fMap()
00067 {
00068    fConfig.Set("RunAlgEventPrint", "no");
00069 }

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

Definition at line 72 of file SelectCount.cxx.

00073 {
00074 }


Member Function Documentation

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

Reimplemented from Anp::AlgEvent.

Definition at line 127 of file SelectCount.cxx.

References fAlgName, fConfig, fDirName, fPrint, fTotalOnlyNC, fTotalOnlyNue, fWeight, Anp::GetString(), Registry::KeyExists(), Registry::Merge(), and Anp::Read().

00128 {
00129    fConfig.Merge(reg);
00130 
00131    pair<string, bool> result;
00132 
00133    result = Anp::GetString("SelectCount", "DirName", reg);
00134    if(result.second)
00135    {
00136       fDirName = result.first;
00137    }
00138 
00139    result = Anp::GetString("SelectCount", "AlgName", reg);
00140    if(result.second)
00141    {
00142       fAlgName = result.first;
00143    }   
00144 
00145    Anp::Read(reg, "SelectCountPrint",  fPrint);
00146    Anp::Read(reg, "SelectCountWeight", fWeight);
00147 
00148    if(reg.KeyExists("PrintConfig"))
00149    {
00150       cout << "SelectCount::Config" << endl
00151            << "   DirName = " << fDirName << endl
00152            << "   AlgName = " << fAlgName << endl
00153            << "   Print = " << fPrint << endl
00154            << "   Weight = " << fWeight << endl
00155            << "   TotalOnlyNC = " << fTotalOnlyNC << endl
00156            << "   TotalOnlyNue = " << fTotalOnlyNue << endl;
00157    }
00158 }

void Anp::SelectCount::End ( const DataBlock block  )  [virtual]

Reimplemented from Anp::AlgEvent.

Definition at line 161 of file SelectCount.cxx.

References Anp::AlgCaddy< T >::alg, count, Anp::Select::Count::fail, fMap, fNameWidth, fNumbWidth, fPrint, Anp::NameWidth(), Anp::NumbWidth(), Anp::Select::Count::pass, Print(), Munits::second, and Anp::Handle< T >::valid().

00162 {
00163    vector<AlgCaddy<AlgEvent> > avec;
00164 
00165    for(CountMap::iterator cit = fMap.begin(); cit != fMap.end(); ++cit)
00166    {
00167       KeyMap &kmap = cit -> second;
00168 
00169       for(KeyMap::iterator kit = kmap.begin(); kit != kmap.end(); ++kit)
00170       {
00171          Select::Count &count = kit -> second;
00172          
00173          if(count.pass.alg.valid())
00174          {
00175             count.pass.alg -> End(block);
00176          }
00177          if(count.fail.alg.valid())
00178          {
00179             count.fail.alg -> End(block);
00180          }
00181 
00182          avec.push_back(count.pass);
00183          avec.push_back(count.fail);
00184       }
00185    }
00186 
00187    fNameWidth = Anp::NameWidth(avec);
00188    fNumbWidth = Anp::NumbWidth(avec);
00189    
00190    avec.clear();
00191 
00192    stringstream out;
00193 
00194    out << "Printing number of passed events" << endl;
00195    
00196    Print(-1, "pass", out); // all interactions types
00197    Print( 0, "pass", out); // NC interactions
00198    Print(+1, "pass", out); // CC interactions
00199 
00200    out << "Printing number of failed events" << endl;
00201    
00202    Print(-1, "fail", out); // all interactions types
00203    Print( 0, "fail", out); // NC interactions
00204    Print(+1, "fail", out); // CC interactions
00205 
00206    if(fPrint)
00207    {
00208       cout << out.str();
00209    }
00210 }

Select::Count& Anp::SelectCount::GetCount ( int  iaction,
Particle::Particle_t  particle,
int  select,
const std::string &  opt = "" 
) [private]

Referenced by Run().

void Anp::SelectCount::Print ( int  iaction,
const std::string &  opt,
std::ostream &  out 
) const [private]

Referenced by End().

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

Implements Anp::AlgEvent.

Definition at line 77 of file SelectCount.cxx.

References Anp::Event::EventIndex(), fCount, Anp::Select::Count::Fill(), fIndex, Anp::Record::FindTruth(), fRun, fSnarl, GetCount(), Anp::Record::GetHeader(), Particle::kAll, Anp::Header::Run(), Anp::Header::Snarl(), Anp::Record::TruthBeg(), and Anp::Record::TruthEnd().

00078 {
00079    if(fRun != record.GetHeader().Run() || fSnarl != record.GetHeader().Snarl())
00080    {
00081       fRun   = record.GetHeader().Run();
00082       fSnarl = record.GetHeader().Snarl();      
00083       fIndex = event.EventIndex();
00084       fCount = 0;
00085    }
00086    else if(fIndex != event.EventIndex())
00087    {
00088       fIndex = event.EventIndex();
00089       fCount = 0;
00090    }
00091    else
00092    {
00093       ++fCount;
00094    }
00095    
00096    GetCount(-1, Particle::kAll, fCount, "alg").Fill(event, record, pass);
00097   
00098    if(record.TruthBeg() == record.TruthEnd())
00099    {
00100       return true;
00101    }
00102 
00103    const TruthIter itruth = record.FindTruth(event);
00104    if(itruth == record.TruthEnd())
00105    {
00106       return false;
00107    }
00108 
00109    GetCount(itruth -> Interaction(), Particle::kAll, fCount).Fill(event, record, pass);
00110    GetCount(itruth -> Interaction(), itruth -> Particle(), fCount).Fill(event, record, pass);
00111 
00112    return true;
00113 }

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

Reimplemented from Anp::AlgEvent.

Definition at line 116 of file SelectCount.cxx.

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

00117 {
00118    if(!dir)
00119    {
00120       return;
00121    }
00122 
00123    fDir = Anp::GetDir(fDirName, dir);
00124 }


Member Data Documentation

std::string Anp::SelectCount::fAlgName [private]

Definition at line 74 of file SelectCount.h.

Referenced by Config().

Definition at line 76 of file SelectCount.h.

Referenced by Config(), and SelectCount().

unsigned int Anp::SelectCount::fCount [private]

Reimplemented from Anp::Base.

Definition at line 87 of file SelectCount.h.

Referenced by Run().

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

Definition at line 71 of file SelectCount.h.

Referenced by Set().

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

Definition at line 73 of file SelectCount.h.

Referenced by Config(), and Set().

int Anp::SelectCount::fIndex [private]

Definition at line 85 of file SelectCount.h.

Referenced by Run().

Definition at line 92 of file SelectCount.h.

Referenced by End().

unsigned int Anp::SelectCount::fNameWidth [private]

Definition at line 89 of file SelectCount.h.

Referenced by End().

unsigned int Anp::SelectCount::fNumbWidth [private]

Definition at line 90 of file SelectCount.h.

Referenced by End().

bool Anp::SelectCount::fPrint [private]

Definition at line 78 of file SelectCount.h.

Referenced by Config(), and End().

int Anp::SelectCount::fRun [private]

Definition at line 83 of file SelectCount.h.

Referenced by Run().

int Anp::SelectCount::fSnarl [private]

Definition at line 84 of file SelectCount.h.

Referenced by Run().

Definition at line 80 of file SelectCount.h.

Referenced by Config().

Definition at line 81 of file SelectCount.h.

Referenced by Config().

bool Anp::SelectCount::fWeight [private]

Definition at line 79 of file SelectCount.h.

Referenced by Config().


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

Generated on 19 Jan 2018 for loon by  doxygen 1.6.1