TestDataModule Class Reference

#include <TestDataModule.h>

Inheritance diagram for TestDataModule:
JobCModule

List of all members.

Public Member Functions

 TestDataModule ()
virtual ~TestDataModule ()
JobCResult Reco (MomNavigator *mom)
void Config (const Registry &reg)
void BeginJob ()

Private Member Functions

void Analyze (TObject *object, bool print=false)

Private Attributes

Anp::InterfacefInterface
unsigned int fNPass
unsigned int fNFail
bool fPrintEvent
bool fPrintTrack
bool fStrip
Registry fConfig

Detailed Description

Definition at line 39 of file TestDataModule.h.


Constructor & Destructor Documentation

TestDataModule::TestDataModule (  ) 

Definition at line 62 of file TestDataModule.cxx.

00063    :fInterface(new Anp::Interface()),
00064     fNPass(0),
00065     fNFail(0),
00066     fPrintEvent(false),
00067     fPrintTrack(false),
00068     fStrip(false),
00069     fConfig(false)
00070 {
00071    Anp::Factory<Anp::StorekNNData>::
00072       Instance().Hold("kNNData", Anp::Handle<Anp::StorekNNData>(new Anp::StorekNNData));
00073 }

TestDataModule::~TestDataModule (  )  [virtual]

Definition at line 76 of file TestDataModule.cxx.

References fInterface, fNFail, fNPass, Msg::kDebug, and MSG.

00077 {
00078    //
00079    // Delete interface object
00080    //
00081    delete fInterface;
00082    fInterface = 0;
00083 
00084    //
00085    // Destroy StorekNNData if it exists
00086    //
00087    Anp::Factory<Anp::StorekNNData>::Instance().Remove("kNNData");
00088 
00089    MSG("TestData", Msg::kDebug) 
00090       << endl
00091       << "**************************************************" << std::endl
00092       << "    TestDataModule" << std::endl
00093       << "      Number of passed records " << fNPass << std::endl
00094       << "      Number of failed records " << fNFail << std::endl
00095       << "**************************************************" << std::endl;
00096 }


Member Function Documentation

void TestDataModule::Analyze ( TObject *  object,
bool  print = false 
) [private]

Definition at line 210 of file TestDataModule.cxx.

References fInterface, JobCModule::Get(), and Anp::Handle< T >::valid().

Referenced by Reco().

00211 {
00212    //
00213    // Extract variables from PhysicsNtuple interface
00214    //
00215    const float numubar = fInterface -> GetVar("numubar", object);
00216    const float rel_ang = fInterface -> GetVar("rel_ang", object);
00217    const float knn_pid = fInterface -> GetVar("knn_pid", object);
00218    const float knn_01  = fInterface -> GetVar("knn_01",  object);
00219    const float knn_10  = fInterface -> GetVar("knn_10",  object);
00220    const float knn_20  = fInterface -> GetVar("knn_20",  object);
00221    const float knn_40  = fInterface -> GetVar("knn_40",  object);
00222 
00223    if(print)
00224    {
00225       cout << "   anti neutrino selection = " << numubar << endl
00226            << "   relative angle = " << rel_ang << endl
00227            << "   knn muon pid = " << knn_pid << endl
00228            << "   number of scintillator planes = " << knn_01 << endl
00229            << "   mean track signal = " << knn_10 << endl
00230            << "   low mean signal over high mean signal = " << knn_20 << endl
00231            << "   track mean signal over track window mean signal = " << knn_40 << endl;
00232    }
00233    
00234    Anp::Handle<Anp::StorekNNData> data = Anp::Factory<Anp::StorekNNData>::Instance().Get("kNNData");
00235 
00236    if(!data.valid())
00237    {
00238       cerr << " TestDataModule::Analyze - Handle<StorekNNData> is invalid" << endl;
00239       return;
00240    }
00241 
00242    data -> Add("numubar", numubar);
00243    data -> Add("rel_ang", rel_ang);
00244 
00245    float numubar_ = -1.0e6, rel_ang_ = -1.0e6;
00246 
00247    data -> Get("numubar", numubar_);
00248    data -> Get("rel_ang", rel_ang_);
00249 }

void TestDataModule::BeginJob ( void   )  [virtual]

Implement for notification of begin of job

Reimplemented from JobCModule.

Definition at line 199 of file TestDataModule.cxx.

References Config(), fConfig, fInterface, Msg::kVerbose, and MSG.

00200 {
00201    MSG("TestData", Msg::kVerbose) << "TestDataModule::BeginJob()..." << std::endl;
00202 
00203    //
00204    // Configure interface object at the beginning of analysis job
00205    //
00206    fInterface -> Config(fConfig);
00207 }

void TestDataModule::Config ( const Registry r  )  [virtual]

Return the actual configuration. If your module directly pulls its configuration from the fConfig Registry, you don't need to override this. Override if you have local config variables.

Reimplemented from JobCModule.

Definition at line 182 of file TestDataModule.cxx.

References fConfig, fPrintEvent, fPrintTrack, fStrip, Msg::kVerbose, Registry::LockValues(), Registry::Merge(), MSG, Anp::Read(), and Registry::UnLockValues().

Referenced by BeginJob().

00183 {
00184    MSG("TestData", Msg::kVerbose) << "TestDataModule::Config()..." << std::endl;
00185 
00186    //
00187    // Store Registry copy
00188    //
00189    fConfig.UnLockValues();
00190    fConfig.Merge(reg);
00191    fConfig.LockValues();
00192 
00193    Anp::Read(reg, "TestDataModulePrintEvent", fPrintEvent);
00194    Anp::Read(reg, "TestDataModulePrintTrack", fPrintTrack);
00195    Anp::Read(reg, "TestDataModuleStrip", fStrip);
00196 }

JobCResult TestDataModule::Reco ( MomNavigator mom  )  [virtual]

Implement this for read-write access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 99 of file TestDataModule.cxx.

References Analyze(), fInterface, fNFail, fNPass, fPrintEvent, fPrintTrack, fStrip, JobCResult::kAOK, Msg::kError, Msg::kWarning, MSG, Lit::Print(), and Anp::PrintStrips().

00100 {   
00101    NtpStRecord *ntprec = dynamic_cast<NtpStRecord *>(mom -> GetFragment("NtpStRecord")); 
00102    if(!ntprec)
00103    {
00104       MSG("TestData", Msg::kError) << "Failed to get NtpStRecord pointer" << endl;
00105       return JobCResult::kAOK;
00106    }
00107 
00108    //
00109    // Fill interface with data for a new snarl
00110    //
00111    if(fInterface -> FillSnarl(ntprec))
00112    {
00113       ++fNPass;
00114    }
00115    else
00116    {
00117       ++fNFail;
00118       return JobCResult::kAOK; 
00119    } 
00120 
00121    TClonesArray *event_array = ntprec -> evt;
00122    TClonesArray *track_array = ntprec -> trk;
00123    if(!event_array || !track_array)
00124    {           
00125       MSG("TestData", Msg::kWarning) << "Invalid TClonesArray object(s)" << endl;
00126       return JobCResult::kAOK;
00127    }
00128 
00129    //
00130    // Iterate over all events and access analysis variables
00131    //
00132    for(int ievent = 0; ievent < event_array -> GetEntries(); ++ievent)
00133    {
00134       NtpSREvent *event = dynamic_cast<NtpSREvent *>(event_array -> At(ievent));
00135       if(!event)
00136       {
00137          MSG("TestData", Msg::kError) << "NtpSREvent dynamic_cast failed" << endl;
00138          continue;
00139       }
00140 
00141       if(fPrintEvent)
00142       {
00143          cout << "NtpSREvent - index "<< event -> index << endl << "   ";
00144          (event -> plane).Print(cout);
00145       }
00146       
00147       TestDataModule::Analyze(event, fPrintEvent);
00148       assert(event -> index == ievent && "mismatched index");
00149    }
00150 
00151    //
00152    // Iterate over all tracks and access analysis variables
00153    //
00154    for(int itrack = 0; itrack < track_array -> GetEntries(); ++itrack)
00155    {
00156       NtpSRTrack *track = dynamic_cast<NtpSRTrack *>(track_array -> At(itrack));
00157       if(!track)
00158       {
00159          MSG("TestData", Msg::kError) << "NtpSRTrack dynamic_cast failed" << endl;
00160          continue;
00161       }
00162       
00163       if(fPrintTrack)
00164       {
00165          cout << "NtpSRTrack - index "<< track -> index << endl << "   ";
00166          (track -> plane).Print(cout);
00167       }
00168       
00169       TestDataModule::Analyze(track, fPrintTrack);
00170       assert(track -> index == itrack && "mismatched index");
00171       
00172       if(fPrintTrack && fStrip)
00173       {
00174             Anp::PrintStrips(*ntprec, track -> stp, track -> nstrip);
00175       }
00176    }
00177 
00178    return JobCResult::kAOK;
00179 }


Member Data Documentation

Reimplemented from JobCModule.

Definition at line 67 of file TestDataModule.h.

Referenced by BeginJob(), and Config().

Definition at line 58 of file TestDataModule.h.

Referenced by Analyze(), BeginJob(), Reco(), and ~TestDataModule().

unsigned int TestDataModule::fNFail [private]

Definition at line 61 of file TestDataModule.h.

Referenced by Reco(), and ~TestDataModule().

unsigned int TestDataModule::fNPass [private]

Definition at line 60 of file TestDataModule.h.

Referenced by Reco(), and ~TestDataModule().

Definition at line 63 of file TestDataModule.h.

Referenced by Config(), and Reco().

Definition at line 64 of file TestDataModule.h.

Referenced by Config(), and Reco().

bool TestDataModule::fStrip [private]

Definition at line 65 of file TestDataModule.h.

Referenced by Config(), and Reco().


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1