MCNNMergeModule Class Reference

#include <MCNNMergeModule.h>

Inheritance diagram for MCNNMergeModule:
JobCModule

List of all members.

Public Member Functions

 MCNNMergeModule ()
 ~MCNNMergeModule ()
JobCResult Reco (MomNavigator *mom)
void EndJob ()
void BeginJob ()
const RegistryDefaultConfig () const
void Config (const Registry &r)

Private Attributes

std::string kInputMCNNFile
Bool_t kOkay
Int_t mcnn_entry
Int_t kNumBestMatches
Double_t kYCut
std::string kPDFFile
NNReader_nnreader
NueAnaReader_anareader
MCNNFiller_filler

Detailed Description

Definition at line 28 of file MCNNMergeModule.h.


Constructor & Destructor Documentation

MCNNMergeModule::MCNNMergeModule (  ) 

Definition at line 32 of file MCNNMergeModule.cxx.

00032                                 :
00033   kInputMCNNFile(""), kOkay(1), mcnn_entry(0)
00034 {}

MCNNMergeModule::~MCNNMergeModule (  ) 

Definition at line 38 of file MCNNMergeModule.cxx.

00039 {}


Member Function Documentation

void MCNNMergeModule::BeginJob ( void   )  [virtual]

Implement for notification of begin of job

Reimplemented from JobCModule.

Definition at line 42 of file MCNNMergeModule.cxx.

References _anareader, _filler, _nnreader, NNReader::Add(), count, NNReader::GetEntries(), kInputMCNNFile, kNumBestMatches, kOkay, kPDFFile, kYCut, mcnn_entry, MCNNFiller::SetBestMatchesToFill(), NueAnaReader::SetMaxNumBestMatches(), MCNNFiller::SetMCNNpidFile(), and MCNNFiller::Setycut().

00043 {
00044 
00045   kOkay = kTRUE;
00046   mcnn_entry = 0;
00047 
00048   if (kInputMCNNFile != "") {
00049 
00050     std::cout << "MCNNMergeModule: Opening MCNN file for merging" << std::endl;
00051     std::cout << "--> FILE = " << kInputMCNNFile.c_str() << std::endl;
00052     _nnreader = new NNReader("nn",true);
00053     Int_t count = _nnreader->Add(kInputMCNNFile.c_str());
00054     if (!count||!_nnreader->GetEntries()) {
00055       std::cout << "--> No valid MCNN info found in file (or file not found)!" << std::endl;
00056       kOkay = kFALSE;
00057     }
00058 
00059     // initialize Pedro's NueAnaReader object
00060     _anareader = new NueAnaReader();
00061     _anareader->SetMaxNumBestMatches(kNumBestMatches);
00062 
00063     // initialize MCNNFiller object ...
00064     // ... these should become config options
00065     _filler = new MCNNFiller();
00066     _filler->SetBestMatchesToFill(kNumBestMatches);
00067     _filler->SetMCNNpidFile(kPDFFile.c_str());
00068     _filler->Setycut(kYCut);
00069 
00070     std::cout << "MCNNMergeModule -- starting up with this configuration:" << std::endl;
00071     std::cout << "  NumBestMatches = " << kNumBestMatches << std::endl;
00072     std::cout << "  YCut           = " << kYCut << std::endl;
00073     std::cout << "  PDFFile        = " << kPDFFile.c_str() << std::endl;
00074 
00075   }
00076   else {
00077     std::cout << "MCNNMergeModule: No MCNN file specified, so no merging will be done." << std::endl;
00078   }
00079 
00080 }

void MCNNMergeModule::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 175 of file MCNNMergeModule.cxx.

References Registry::Get(), Msg::kDebug, kInputMCNNFile, kNumBestMatches, kPDFFile, kYCut, and MSG.

00176 {
00177 //======================================================================
00178 // Configure the module given the Registry r
00179 //======================================================================
00180   MSG("MCNNMergeModule",Msg::kDebug)<<"In MCNNMergeModule::Config"<<endl;
00181                                                                                  
00182   const char* tmps;
00183   Int_t tmpi;
00184   Double_t tmpd;
00185   if (r.Get("InputMCNNFile", tmps)) kInputMCNNFile = tmps;
00186   if (r.Get("PDFFile", tmps)) kPDFFile = tmps;
00187   if (r.Get("NumBestMatches", tmpi)) kNumBestMatches = tmpi;
00188   if (r.Get("YCut", tmpd)) kYCut = tmpd;
00189 
00190 }

const Registry & MCNNMergeModule::DefaultConfig ( void   )  const [virtual]

Get the default configuration registry. This should normally be overridden. One useful idiom is to implement it like:

const Registry& MyModule::DefaultConfig() const { static Registry cfg; // never is destroyed if (cfg.Size()) return cfg; // already filled it // set defaults: cfg.Set("TheAnswer",42); cfg.Set("Units","unknown"); return cfg; }

Reimplemented from JobCModule.

Definition at line 155 of file MCNNMergeModule.cxx.

References Msg::kDebug, Registry::LockValues(), MSG, Registry::Set(), and Registry::UnLockValues().

00156 {
00157 //======================================================================
00158 // Supply the default configuration for the module
00159 //======================================================================
00160    MSG("MCNNMergeModule",Msg::kDebug)<<"In MCNNMergeModule::DefaultConfig"<<endl;
00161 
00162   static Registry r;
00163  
00164   // Set values in configuration
00165   r.UnLockValues();
00166   r.Set("InputMCNNFile", "");
00167   r.Set("NumBestMatches", 50);
00168   r.Set("YCut", 0.9);
00169   r.Set("PDFFile", "${SRT_PRIVATE_CONTEXT}/MCNNAnalysis/macros/files/MCNNpdf_2D_0.5GeVbins_MCNNv2_3.0pe_3.0pelib.root");
00170   r.LockValues();
00171                                                                                 
00172   return r;
00173 }

void MCNNMergeModule::EndJob (  )  [virtual]

Implement for notification of end of job

Reimplemented from JobCModule.

Definition at line 148 of file MCNNMergeModule.cxx.

00149 {
00150   // Deleting these caused seg fault.  Whatever.  Just let the job end, and there'll be no problem.
00151   //delete _nnreader;
00152   //delete _anareader;
00153 }

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

Implement this for read-write access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 83 of file MCNNMergeModule.cxx.

References _anareader, _filler, _nnreader, NNReader::evt, MCNNFiller::FillMCNN(), MomNavigator::FragmentIter(), NNReader::GetEntry(), NueHeader::GetEventNo(), RecRecordImp< T >::GetHeader(), NueHeader::GetRun(), NueHeader::GetSnarl(), Msg::kDebug, Msg::kError, JobCResult::kFailed, kInputMCNNFile, kOkay, JobCResult::kPassed, mcnn_entry, MSG, NueConvention::NueEnergyCorrection(), NueAnaReader::nuerecord, NNReader::run, NueAnaReader::SetNueRecord(), and NNReader::snarl.

00084 {
00085   // okay?
00086   if (!kOkay) {
00087     std::cout << "MCNNMergeModule has a fatal error." << std::endl;
00088     return JobCResult::kFailed;
00089   }
00090 
00091   //get all NueRecords from mom 
00092   //may have more than one per go since mom reads in a snarl's worth of data
00093   //so, this is a little more complicated than just asking for a NueRecord
00094   TObject *obj=0;
00095   
00096   vector<NueRecord *> records;
00097 
00098   TIter objiter = mom->FragmentIter();
00099   while((obj=objiter.Next())){
00100     NueRecord *nr = dynamic_cast<NueRecord *>(obj);
00101     if(nr){
00102       MSG("MCNNMergeModule",Msg::kDebug)<<"Found a NueRecord in MOM"<<endl;
00103     }
00104     else{
00105       MSG("MCNNMergeModule",Msg::kDebug)<<"Didn't find a NueRecord in MOM"<<endl;
00106       continue;
00107     }
00108 
00109     // do it...
00110     if (kInputMCNNFile != "") {
00111 
00112       // Set the NueRecord object in _anareader object
00113       _anareader->SetNueRecord(nr);
00114       _nnreader->GetEntry(mcnn_entry++);
00115 
00116       // check that things are lined up
00117       MSG("MCNNMergeModule",Msg::kDebug) << "--------------" << std::endl;
00118       MSG("MCNNMergeModule",Msg::kDebug) << _anareader->nuerecord->GetHeader().GetRun() << " " << _nnreader->run << std::endl;
00119       MSG("MCNNMergeModule",Msg::kDebug) << _anareader->nuerecord->GetHeader().GetSnarl() << " " << _nnreader->snarl << std::endl;
00120       MSG("MCNNMergeModule",Msg::kDebug) << _anareader->nuerecord->GetHeader().GetEventNo() << " " << _nnreader->evt << std::endl;
00121 
00122       if ((_anareader->nuerecord->GetHeader().GetRun()     != _nnreader->run  )||
00123           (_anareader->nuerecord->GetHeader().GetSnarl()   != _nnreader->snarl)||
00124           (_anareader->nuerecord->GetHeader().GetEventNo() != _nnreader->evt  )) {
00125         MSG("MCNNMergeModule",Msg::kError) << "MCNNMergeModule: ERROR -- trees not in sync!" << std::endl;
00126         MSG("MCNNMergeModule",Msg::kError) << _anareader->nuerecord->GetHeader().GetRun() << " " << _nnreader->run << std::endl;
00127         MSG("MCNNMergeModule",Msg::kError) << _anareader->nuerecord->GetHeader().GetSnarl() << " " << _nnreader->snarl << std::endl;
00128         MSG("MCNNMergeModule",Msg::kError) << _anareader->nuerecord->GetHeader().GetEventNo() << " " << _nnreader->evt << std::endl;
00129         return JobCResult::kFailed;
00130       }
00131       else {
00132         // MCNN needs a calibrated energy in the NueRecord...
00133         NueConvention::NueEnergyCorrection(_anareader->nuerecord);
00134         // Fill the MCNN info!
00135         _filler->FillMCNN(_anareader,_nnreader);
00136       }
00137           
00138 
00139     }
00140     
00141   }
00142 
00143   return JobCResult::kPassed; // kNoDecision, kFailed, etc.
00144 }


Member Data Documentation

Definition at line 55 of file MCNNMergeModule.h.

Referenced by BeginJob(), and Reco().

Definition at line 56 of file MCNNMergeModule.h.

Referenced by BeginJob(), and Reco().

Definition at line 54 of file MCNNMergeModule.h.

Referenced by BeginJob(), and Reco().

std::string MCNNMergeModule::kInputMCNNFile [private]

Definition at line 45 of file MCNNMergeModule.h.

Referenced by BeginJob(), Config(), and Reco().

Definition at line 49 of file MCNNMergeModule.h.

Referenced by BeginJob(), and Config().

Bool_t MCNNMergeModule::kOkay [private]

Definition at line 46 of file MCNNMergeModule.h.

Referenced by BeginJob(), and Reco().

std::string MCNNMergeModule::kPDFFile [private]

Definition at line 51 of file MCNNMergeModule.h.

Referenced by BeginJob(), and Config().

Double_t MCNNMergeModule::kYCut [private]

Definition at line 50 of file MCNNMergeModule.h.

Referenced by BeginJob(), and Config().

Int_t MCNNMergeModule::mcnn_entry [private]

Definition at line 47 of file MCNNMergeModule.h.

Referenced by BeginJob(), 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