Anp::SelectTrue Class Reference

#include <SelectTrue.h>

Inheritance diagram for Anp::SelectTrue:
Anp::AlgSnarl Anp::Base

List of all members.

Public Member Functions

 SelectTrue ()
virtual ~SelectTrue ()
bool Run (Record &record)
void Config (const Registry &reg)
void Set (TDirectory *dir)
bool Init (const Header &header)
void End (const DataBlock &block)

Private Types

enum  Selection {
  kAll = -1, kNC = 0, kCC = 1, kCCPos = 2,
  kCCNeg = 3, kBad = 5, kQES = 1001, kRES = 1002,
  kDIS = 1003
}

Private Member Functions

AlgSnarlPtr GetAlg (const std::string &key)
bool Select (Event &event, const Record &record, const std::string &option) const
Selection GetSelection (const std::string &key) const
void AddData (Event &event, const Record &record, const Selection select) const

Private Attributes

TDirectory * fDir
std::string fAlgList
std::string fAlgName
std::string fDirName
Registry fConfig
Header fHeader
Record fRecord
int fNeuKey
int fDISKey
int fQESKey
double fDISCut
double fQESCut
double fEHCut
double fW2Cut
std::vector< std::string > fKeys
std::map< std::string,
AlgSnarlPtr
fAlgMap

Detailed Description

Definition at line 20 of file SelectTrue.h.


Member Enumeration Documentation

Enumerator:
kAll 
kNC 
kCC 
kCCPos 
kCCNeg 
kBad 
kQES 
kRES 
kDIS 

Definition at line 39 of file SelectTrue.h.

00040       {
00041          kAll=-1, kNC=0, kCC=1, kCCPos=2, kCCNeg=3, kBad=5, kQES=1001, kRES=1002, kDIS=1003
00042       };


Constructor & Destructor Documentation

Anp::SelectTrue::SelectTrue (  ) 

Definition at line 31 of file SelectTrue.cxx.

00032    :fDir(0),
00033     fAlgList(""),
00034     fAlgName(""),
00035     fDirName(""),
00036     fConfig(false),
00037     fHeader(),
00038     fRecord(),
00039     fNeuKey(1),
00040     fDISKey(1523),
00041     fQESKey(1521),
00042     fDISCut(0.25),
00043     fQESCut(0.75),
00044     fEHCut(0.15),
00045     fW2Cut(4.0)
00046 {
00047 }

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

Definition at line 50 of file SelectTrue.cxx.

00051 {
00052 }


Member Function Documentation

void Anp::SelectTrue::AddData ( Event event,
const Record record,
const Selection  select 
) const [private]
void Anp::SelectTrue::Config ( const Registry reg  )  [virtual]

Reimplemented from Anp::AlgSnarl.

Definition at line 109 of file SelectTrue.cxx.

References fAlgList, fAlgName, fConfig, fDirName, fKeys, Registry::Get(), GetSelection(), it, kBad, Registry::KeyExists(), Registry::Merge(), Registry::Set(), and UtilString::StringTok().

00110 {
00111    const char *value_char = 0;
00112    if(reg.Get("SelectTrueAlgName", value_char) && value_char)
00113    {
00114       fAlgName = value_char;
00115    }
00116 
00117    value_char = 0;
00118    if(reg.Get("SelectTrueDirName", value_char) && value_char)
00119    {
00120       fDirName = value_char;
00121    }
00122 
00123    //
00124    // Merge main registry and reset some keys used by RunAlgSnarl
00125    //
00126    fConfig.Merge(reg);
00127    fConfig.Set("AlgEventList", "");
00128    fConfig.Set("AlgSnarlList", "");
00129    fConfig.Set("AlgSnarlDirName", "");
00130    fConfig.Set("AlgSnarlDoThread", "no");
00131    fConfig.Set("AlgSnarlMakeCopy", "no");
00132    fConfig.Set("AlgSnarlPrintEnd", "no");
00133 
00134    // read list of algorithms from SelectTrueList key and set
00135    // AlgSnarlList key with this list. If SelectTrueList key 
00136    // does not exist then erase AlgSnarlList key.
00137    const char *value_list = 0;
00138    if(reg.Get("SelectTrueList", value_list) && value_list)
00139    {
00140       const string alist = value_list;
00141       if(alist.find("SelectTrue") == string::npos)
00142       {
00143          fAlgList = alist;
00144          if     (fAlgName.find("Event") != string::npos) fConfig.Set("AlgEventList", alist.c_str());
00145          else if(fAlgName.find("Snarl") != string::npos) fConfig.Set("AlgSnarlList", alist.c_str());
00146       }
00147       else
00148       {
00149          cerr << "SelectTrue::Config - algorithm list should not include self" << endl; 
00150       }
00151    }
00152 
00153    const char *value_true = 0;
00154    if(reg.Get("SelectTrue", value_true) && value_true)
00155    {
00156       vector<string> svec;
00157 
00158       UtilString::StringTok(svec, string(value_true), ", ");
00159       
00160       for(vector<string>::const_iterator sit = svec.begin(); sit != svec.end(); ++sit)
00161       {
00162          const string &key = *sit;
00163 
00164          const Selection select = SelectTrue::GetSelection(key);
00165          if(select != kBad)
00166          {
00167             fKeys.push_back(key);
00168             continue;       
00169          }
00170          
00171          cerr << "SelectTrue::Config - ignoring unknown key: " << key << endl;
00172       }
00173       
00174       std::sort(fKeys.begin(), fKeys.end());
00175    }
00176 
00177    if(fConfig.KeyExists("PrintConfig") || fConfig.KeyExists("PrintKinem"))
00178    {
00179       cout << "SelectTrue::Config" << endl
00180            << "   AlgList = " << fAlgList << endl
00181            << "   AlgName = " << fAlgName << endl
00182            << "   DirName = " << fDirName << endl
00183            << "   Added " << fKeys.size() << " keys" << endl;
00184       
00185       for(vector<string>::const_iterator it = fKeys.begin(); it != fKeys.end(); ++it)
00186       {
00187          if(it == fKeys.begin())
00188          {
00189             cout << "   " << *it;
00190          }
00191          else if(it + 1 == fKeys.end())
00192          {
00193             cout << " " << *it << endl;
00194          }
00195          else
00196          {
00197             cout << " " << *it;
00198          }
00199       }
00200    }
00201 }

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

Reimplemented from Anp::AlgSnarl.

Definition at line 229 of file SelectTrue.cxx.

References fAlgMap, Munits::second, and Anp::Handle< T >::valid().

00230 {
00231    for(map<string, AlgSnarlPtr>::iterator ialg = fAlgMap.begin(); ialg != fAlgMap.end(); ++ialg)
00232    {
00233       AlgSnarlPtr alg = ialg -> second;
00234 
00235       if(alg.valid())
00236       {
00237          alg -> End(block);
00238       }
00239    }
00240    
00241    fAlgMap.clear();
00242 }

AlgSnarlPtr Anp::SelectTrue::GetAlg ( const std::string &  key  )  [private]

Referenced by Run().

Selection Anp::SelectTrue::GetSelection ( const std::string &  key  )  const [private]

Referenced by Config().

bool Anp::SelectTrue::Init ( const Header header  )  [virtual]

Reimplemented from Anp::AlgSnarl.

Definition at line 215 of file SelectTrue.cxx.

References fHeader, and Anp::Header::IsValid().

00216 {
00217    //
00218    // Configure self and save copy of Header
00219    //
00220 
00221    assert(!fHeader.IsValid() && "SelectTrue already has valid header - logic errror");
00222 
00223    fHeader = header;
00224 
00225    return fHeader.IsValid();
00226 }

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

Implements Anp::AlgSnarl.

Definition at line 55 of file SelectTrue.cxx.

References Anp::CleanRecord(), Anp::Record::Erase(), Anp::Record::EventBeg(), Anp::Record::EventBegIterator(), Anp::Record::EventEnd(), Anp::Record::EventEndIterator(), fKeys, fRecord, GetAlg(), Anp::Record::GetHeader(), Anp::Header::IsData(), Select(), Anp::Record::TruthBeg(), Anp::Record::TruthEnd(), and Anp::Handle< T >::valid().

00056 {    
00057    //
00058    // Create empty Record class, code runs faster when this is outside loop.   
00059    //
00060 
00061    for(vector<string>::const_iterator kit = fKeys.begin(); kit != fKeys.end(); ++kit)
00062    {
00063       const string &key = *kit;
00064 
00065       AlgSnarlPtr alg = GetAlg(key);
00066       if(!alg.valid())
00067       {
00068          continue;
00069       }
00070       
00071       if(key != "all" && (record.GetHeader().IsData() || record.TruthBeg() == record.TruthEnd()))
00072       {
00073          return true;
00074       }
00075 
00076       //
00077       // Fill copy with Record content
00078       //
00079       fRecord = record;
00080 
00081       //
00082       // Remove events that do not pass current selection
00083       //
00084       EventIterator ievent = fRecord.EventBegIterator();
00085       while(ievent != fRecord.EventEndIterator())
00086       {
00087          if(SelectTrue::Select(*ievent, fRecord, key))
00088          {
00089             ++ievent;
00090          }
00091          else
00092          {
00093             ievent = fRecord.Erase(ievent);
00094          }
00095       }
00096       
00097       //
00098       // Remove tracks and showers that do not match selected events
00099       //
00100       Anp::CleanRecord(fRecord.EventBeg(), fRecord.EventEnd(), fRecord);
00101       
00102       alg -> Run(fRecord);      
00103    }
00104 
00105    return true;
00106 }

bool Anp::SelectTrue::Select ( Event event,
const Record record,
const std::string &  option 
) const [private]

Referenced by Run().

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

Reimplemented from Anp::AlgSnarl.

Definition at line 204 of file SelectTrue.cxx.

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

00205 {
00206    if(!dir)
00207    {
00208       return;
00209    }
00210    
00211    fDir = Anp::GetDir(fDirName, dir);
00212 }


Member Data Documentation

std::string Anp::SelectTrue::fAlgList [private]

Definition at line 58 of file SelectTrue.h.

Referenced by Config().

std::map<std::string, AlgSnarlPtr> Anp::SelectTrue::fAlgMap [private]

Definition at line 76 of file SelectTrue.h.

Referenced by End().

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

Definition at line 59 of file SelectTrue.h.

Referenced by Config().

Definition at line 62 of file SelectTrue.h.

Referenced by Config().

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

Definition at line 56 of file SelectTrue.h.

Referenced by Set().

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

Definition at line 60 of file SelectTrue.h.

Referenced by Config(), and Set().

double Anp::SelectTrue::fDISCut [private]

Definition at line 69 of file SelectTrue.h.

int Anp::SelectTrue::fDISKey [private]

Definition at line 67 of file SelectTrue.h.

double Anp::SelectTrue::fEHCut [private]

Definition at line 71 of file SelectTrue.h.

Definition at line 63 of file SelectTrue.h.

Referenced by Init().

std::vector<std::string> Anp::SelectTrue::fKeys [private]

Definition at line 74 of file SelectTrue.h.

Referenced by Config(), and Run().

int Anp::SelectTrue::fNeuKey [private]

Definition at line 66 of file SelectTrue.h.

double Anp::SelectTrue::fQESCut [private]

Definition at line 70 of file SelectTrue.h.

int Anp::SelectTrue::fQESKey [private]

Definition at line 68 of file SelectTrue.h.

Definition at line 64 of file SelectTrue.h.

Referenced by Run().

double Anp::SelectTrue::fW2Cut [private]

Definition at line 72 of file SelectTrue.h.


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

Generated on 24 Jul 2018 for loon by  doxygen 1.6.1