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

Anp::SelectFlux Class Reference

#include <SelectFlux.h>

Inheritance diagram for Anp::SelectFlux:

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

Public Member Functions

 SelectFlux ()
virtual ~SelectFlux ()
bool Run (Record &record)
void Config (const Registry &reg)
bool Init (const Header &header)

Private Attributes

std::string fAlgName
std::string fAlgPath
Registry fConfig
Handle< AlgAdaptfAdapt

Constructor & Destructor Documentation

Anp::SelectFlux::SelectFlux  ) 
 

Definition at line 22 of file SelectFlux.cxx.

00023    :fAlgName(""),
00024     fAlgPath(""),
00025     fConfig(false)
00026 {
00027 }

Anp::SelectFlux::~SelectFlux  )  [virtual]
 

Definition at line 30 of file SelectFlux.cxx.

00031 {
00032 }


Member Function Documentation

void Anp::SelectFlux::Config const Registry reg  )  [virtual]
 

Reimplemented from Anp::AlgSnarl.

Definition at line 79 of file SelectFlux.cxx.

References fAlgName, fAlgPath, fConfig, Registry::Get(), Registry::KeyExists(), and reg.

Referenced by Init().

00080 {
00081    //
00082    // Configure self and children algorithms
00083    //
00084    fConfig = reg;
00085 
00086    const char *value_name = 0;
00087    if(reg.Get("SelectFlux", value_name) && value_name)
00088    {
00089       fAlgName = value_name;
00090    }
00091 
00092    const char *value_path = 0;
00093    if(reg.Get("SelectFluxPath", value_path) && value_path)
00094    {
00095       fAlgPath = value_path;
00096    }
00097    
00098    if(fConfig.KeyExists("PrintConfig"))
00099    {
00100       cout << "SelectFlux::Config" << endl
00101            << "   AlgName = " << fAlgName << endl
00102            << "   AlgPath = " << fAlgPath << endl;
00103    } 
00104 }

bool Anp::SelectFlux::Init const Header header  )  [virtual]
 

Reimplemented from Anp::AlgSnarl.

Definition at line 108 of file SelectFlux.cxx.

References Config(), fAdapt, fAlgName, fAlgPath, fConfig, Lit::Print(), Anp::Read(), Anp::Handle< T >::release(), and Anp::Handle< T >::valid().

00109 {
00110    //
00111    // Configure self and save copy of Header
00112    //
00113    if(fAlgName.empty()) return true;
00114 
00115    fAdapt = Factory<AlgAdapt>::Instance().Create(fAlgName);
00116    if(!fAdapt.valid())
00117    {
00118       cerr << "SelectFlux::Init - failed to create: " << fAlgName << endl;
00119       return false;
00120    }
00121    
00122    fAdapt -> Config(fConfig);
00123    
00124    if(!fAdapt -> Init())
00125    {
00126       cerr << "SelectFlux::Init - failed to initialize: " << fAlgName << endl;
00127       fAdapt.release();
00128    }
00129    else
00130    {
00131       if(!fAlgPath.empty()) fAdapt -> Read(fAlgPath);
00132       fAdapt -> Print();
00133    }
00134    
00135    return fAdapt.valid();
00136 }

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

Implements Anp::AlgSnarl.

Definition at line 35 of file SelectFlux.cxx.

References Anp::ApplyTrueWeights(), Anp::Record::EventBegIterator(), Anp::Record::EventEndIterator(), Anp::EventIterator, fAdapt, Anp::Record::FindTruth(), Anp::Record::GetHeader(), Anp::Header::IsData(), Anp::Record::TruthBeg(), Anp::Record::TruthBegIterator(), Anp::Record::TruthEnd(), Anp::Record::TruthEndIterator(), Anp::TruthIter, Anp::TruthIterator, and Anp::Handle< T >::valid().

00036 {
00037    //
00038    // Do nothing for data
00039    //
00040    if(record.GetHeader().IsData() || record.TruthBeg() == record.TruthEnd() || !fAdapt.valid())
00041    {
00042       return true;
00043    }
00044 
00045    //
00046    // Set weights for Monte-Carlo Truths
00047    //
00048    for(TruthIterator itruth = record.TruthBegIterator(); itruth != record.TruthEndIterator(); ++itruth)
00049    {
00050       itruth -> SetWeight(itruth->Weight()*fAdapt->GetWeight(Anp::TrueNu(*itruth, record)));
00051    }
00052 
00053    //
00054    // Apply truth weights to all matching reconstructed objects
00055    //
00056    Anp::ApplyTrueWeights(record);
00057 
00058    //
00059    // Set weights, and/or change values, for reconstructed events
00060    //
00061    for(EventIterator ievent = record.EventBegIterator(); ievent != record.EventEndIterator(); ++ievent)
00062    {
00063       RecoNu rnu = ievent -> GetNu();     
00064 
00065       const TruthIter itruth = record.FindTruth(*ievent);
00066       if(itruth == record.TruthEnd())
00067       {
00068          continue;
00069       }
00070       
00071       fAdapt -> Vary(rnu, Anp::TrueNu(*itruth, record));
00072       ievent -> SetNu(rnu);
00073    }
00074 
00075    return true;
00076 }


Member Data Documentation

Handle<AlgAdapt> Anp::SelectFlux::fAdapt [private]
 

Definition at line 43 of file SelectFlux.h.

Referenced by Init(), and Run().

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

Definition at line 38 of file SelectFlux.h.

Referenced by Config(), and Init().

std::string Anp::SelectFlux::fAlgPath [private]
 

Definition at line 39 of file SelectFlux.h.

Referenced by Config(), and Init().

Registry Anp::SelectFlux::fConfig [private]
 

Definition at line 41 of file SelectFlux.h.

Referenced by Config(), and Init().


The documentation for this class was generated from the following files:
Generated on Mon Feb 15 11:10:35 2010 for loon by  doxygen 1.3.9.1