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

Anp::StudyFiducial Class Reference

#include <StudyFiducial.h>

Inheritance diagram for Anp::StudyFiducial:

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

Public Member Functions

 StudyFiducial ()
virtual ~StudyFiducial ()
bool Run (Record &record)
void Config (const Registry &)
void Set (TDirectory *dir)
void End (const DataBlock &)

Private Types

typedef std::pair< double,
double > 
PassFail
typedef std::map< std::string,
PassFail
CountMap

Private Member Functions

void Print (std::ostream &os=std::cout) const
void Count (const std::string &key, bool pass, double weight)

Private Attributes

int fFiducialKey
int fNeutrinoKey
std::map< std::string, PassFailfCountMap

Member Typedef Documentation

typedef std::map<std::string, PassFail> Anp::StudyFiducial::CountMap [private]
 

Definition at line 38 of file StudyFiducial.h.

typedef std::pair<double,double> Anp::StudyFiducial::PassFail [private]
 

Definition at line 37 of file StudyFiducial.h.

Referenced by Count().


Constructor & Destructor Documentation

Anp::StudyFiducial::StudyFiducial  ) 
 

Definition at line 23 of file StudyFiducial.cxx.

00024    :fFiducialKey(100),
00025     fNeutrinoKey(2100)
00026 {
00027 }

Anp::StudyFiducial::~StudyFiducial  )  [virtual]
 

Definition at line 30 of file StudyFiducial.cxx.

00031 {
00032 }


Member Function Documentation

void Anp::StudyFiducial::Config const Registry  )  [virtual]
 

Reimplemented from Anp::AlgSnarl.

Definition at line 125 of file StudyFiducial.cxx.

References fFiducialKey, fNeutrinoKey, Registry::Get(), and reg.

00126 {
00127    int value_int = 0;
00128    if(reg.Get("StudyFiducialKey", value_int) && value_int != 0)
00129    {
00130       fFiducialKey = value_int;
00131    }
00132 
00133    value_int = 0;
00134    if(reg.Get("StudyFiducialNeu", value_int) && value_int != 0)
00135    {
00136       fNeutrinoKey = value_int;
00137    }
00138 
00139    const char *value_char = 0;
00140    if(reg.Get("PrintConfig", value_char) && value_char && strcmp(value_char, "yes") == 0)
00141    {
00142       cout << "StudyFiducial::Config" << endl
00143            << "   FiducialKey = " << fFiducialKey << endl
00144            << "   NeutrinoKey = " << fNeutrinoKey << endl;
00145    }
00146 }

void Anp::StudyFiducial::Count const std::string &  key,
bool  pass,
double  weight
[private]
 

Definition at line 227 of file StudyFiducial.cxx.

References fCountMap, and PassFail.

Referenced by Run().

00228 {
00229    map<string, PassFail>::iterator cit = fCountMap.find(key);
00230    if(cit == fCountMap.end())
00231    {
00232       cit = fCountMap.insert(map<string, PassFail>::value_type(key, PassFail(0.0, 0.0))).first;
00233    }
00234 
00235    PassFail &p = cit -> second;
00236    if(pass)
00237    {
00238       p.first += weight;
00239    }
00240    else
00241    {
00242       p.second += weight;
00243    }
00244 }

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

Reimplemented from Anp::AlgSnarl.

Definition at line 119 of file StudyFiducial.cxx.

References Print().

00120 {
00121    Print();
00122 }

void Anp::StudyFiducial::Print std::ostream &  os = std::cout  )  const [private]
 

Definition at line 154 of file StudyFiducial.cxx.

References fCountMap.

Referenced by End().

00155 {
00156    //
00157    // Print count for all used keys
00158    //
00159 
00160    //
00161    // Compute widths of three fields: string size and two integers
00162    //
00163    unsigned widthS = 0, widthN1 = 0, widthN2 = 0;
00164 
00165    for(map<string, PassFail>::const_iterator cit = fCountMap.begin(); cit != fCountMap.end(); ++cit)
00166    {
00167       const double d1 = (cit -> second).first;
00168       const double d2 = (cit -> second).second;
00169     
00170       unsigned w1 = 1;
00171       unsigned w2 = 1;
00172 
00173       if(d1 > 1.0)
00174       {
00175          w1 += static_cast<unsigned int>(std::log10(d1));
00176       }
00177       if(d2 > 1.0)
00178       {
00179          w2 += static_cast<unsigned int>(std::log10(d2));
00180       }
00181       
00182       if(cit == fCountMap.begin())
00183       {
00184          widthS  = (cit -> first).size();
00185          widthN1 = w1;
00186          widthN2 = w2;
00187       }
00188       else
00189       {
00190          widthS  = std::max<unsigned int>(widthS, (cit -> first).size());
00191          widthN1 = std::max<unsigned int>(widthN1, w1);
00192          widthN2 = std::max<unsigned int>(widthN2, w2);
00193       }
00194    }
00195 
00196    if(widthS < 1)
00197    {
00198       return;
00199    }
00200 
00201    //
00202    // Actually print keys and values
00203    //
00204    for(map<string, PassFail>::const_iterator cit = fCountMap.begin(); cit != fCountMap.end(); ++cit)
00205    {
00206       const double d1 = (cit -> second).first;
00207       const double d2 = (cit -> second).second;
00208 
00209       const unsigned int n1 = static_cast<unsigned int>(d1);
00210       const unsigned int n2 = static_cast<unsigned int>(d2);
00211       
00212       os << "   " << setw(widthS) << left << cit -> first << " pass, fail, pass/all = "
00213          << setw(widthN1) << std::right << n1 << ", "
00214          << setw(widthN2) << std::right << n2 << ", ";
00215       
00216       double ratio = 0.0;
00217       if(d1+d2 > 0.0)
00218       {
00219          ratio = d1/(d1+d2);
00220       }
00221 
00222       os << setw(6) << setprecision(4) << ratio << endl;
00223    }
00224 }

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

Implements Anp::AlgSnarl.

Definition at line 35 of file StudyFiducial.cxx.

References Count(), Anp::Record::EventBeg(), Anp::Record::EventEnd(), Anp::EventIter, fFiducialKey, fNeutrinoKey, Anp::Record::TruthBeg(), Anp::Record::TruthEnd(), and Anp::TruthIter.

00036 {
00037    //
00038    // Count and study fiducial and non-fiducial events
00039    //
00040 
00041    for(TruthIter itrue = record.TruthBeg(); itrue != record.TruthEnd(); ++itrue)
00042    {
00043       bool fid_true = false;
00044       bool fid_reco = false;
00045       bool pid_pass = false;
00046 
00047       unsigned int rcount = 0;
00048 
00049       string fidR = "FidReco=0";
00050       string fidT = "FidTrue=0";
00051       string skey = "Select=0";
00052       
00053       //
00054       // Find reco event information
00055       //
00056       for(EventIter ievent = record.EventBeg(); ievent != record.EventEnd(); ++ievent)
00057       {
00058          if(!(itrue -> Match(*ievent)))
00059          {
00060             continue;
00061          }
00062 
00063          ++rcount;
00064          
00065          if(ievent -> KeyExists(fFiducialKey))
00066          {
00067             fid_reco = true;
00068             fidR = "FidReco=1";
00069          }
00070 
00071          if(ievent -> KeyExists(fNeutrinoKey))
00072          {
00073             pid_pass = true;
00074             skey = "Select=1";
00075          }
00076       }
00077 
00078       //
00079       // Check if true interaction vertex is within fiducial volume
00080       //
00081       if(itrue -> KeyExists(fFiducialKey))
00082       {
00083          fid_true = true;
00084          fidT = "FidTrue=1";
00085       }
00086       
00087       string ikey;
00088       if(itrue -> Interaction() == 0)
00089       {
00090          ikey = "NC";
00091       }
00092       else if(itrue -> Interaction() == 1)
00093       {
00094          ikey = "CC";
00095       }
00096 
00097       Count(ikey + " & FidTrue=?", fid_true, 1.0);
00098       Count(ikey + " & RecoEvent=?", rcount > 0, 1.0);
00099       Count(ikey + " & " + fidT + " & RecoEvent=?", rcount > 0, 1.0);
00100 
00101       if(rcount > 0)
00102       {
00103          Count(ikey + " & " + fidT + " & SplitEvent=?", rcount > 1, 1.0);
00104          Count(ikey + " & " + fidR + " & SplitEvent=?", rcount > 1, 1.0);
00105 
00106          Count(ikey + " & " + fidT + " & FidReco=?", fid_reco, 1.0);
00107 
00108          Count(ikey + " & " + skey + " & FidTrue=?", fid_true, 1.0);
00109          Count(ikey + " & " + skey + " & FidReco=?", fid_reco, 1.0);
00110 
00111          Count(ikey + " & " + skey + " & " + fidT + " & FidReco=?", fid_reco, 1.0);
00112       }
00113    }
00114 
00115    return true;
00116 }

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

Reimplemented from Anp::AlgSnarl.

Definition at line 149 of file StudyFiducial.cxx.

00150 {
00151 }


Member Data Documentation

std::map<std::string, PassFail> Anp::StudyFiducial::fCountMap [private]
 

Definition at line 50 of file StudyFiducial.h.

Referenced by Count(), and Print().

int Anp::StudyFiducial::fFiducialKey [private]
 

Definition at line 47 of file StudyFiducial.h.

Referenced by Config(), and Run().

int Anp::StudyFiducial::fNeutrinoKey [private]
 

Definition at line 48 of file StudyFiducial.h.

Referenced by Config(), and Run().


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