FixModule Class Reference

#include <FixModule.h>

Inheritance diagram for FixModule:
JobCModule

List of all members.

Public Member Functions

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

Private Attributes

int counter
int kept
std::string fInFile
std::string fOutFile

Detailed Description

Definition at line 25 of file FixModule.h.


Constructor & Destructor Documentation

FixModule::FixModule (  ) 

Definition at line 43 of file FixModule.cxx.

00043                     :
00044   counter(0)
00045 {}

FixModule::~FixModule (  ) 

Definition at line 49 of file FixModule.cxx.

00050 {}


Member Function Documentation

void FixModule::BeginJob ( void   )  [virtual]

Implement for notification of begin of job

Reimplemented from JobCModule.

Definition at line 53 of file FixModule.cxx.

References counter, and kept.

00054 {
00055   kept = 0;
00056 //  fCuts.Reset();
00057   if(counter%1000==0){
00058     cout<<"On entry "<<counter<<endl;
00059   }
00060 }

void FixModule::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 160 of file FixModule.cxx.

References fInFile, fOutFile, and Registry::Get().

00161 {
00162     const char* tmps;
00163     if(r.Get("InFileName",tmps)){ fInFile=tmps;}
00164     if(r.Get("FileName",tmps)){fOutFile=tmps;}
00165 }

const Registry & FixModule::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 149 of file FixModule.cxx.

References Registry::LockValues(), Registry::Set(), and Registry::UnLockValues().

00150 {
00151     static Registry r;
00152     r.UnLockValues();
00153     r.Set("InFileName","blank.root");
00154     r.Set("FileName","pottree.root");
00155     r.LockValues();
00156     
00157     return r;
00158 }

void FixModule::EndJob (  )  [virtual]

Implement for notification of end of job

Reimplemented from JobCModule.

Definition at line 119 of file FixModule.cxx.

References counter, fInFile, fOutFile, and kept.

00120 {
00121   cout<<counter<<" events processed and "<<kept<<" were output"<<endl;
00122 
00123   TChain* ch = new TChain("pottree");
00124   ch->Add(fInFile.c_str());
00125   
00126   NuePOT* pt = new NuePOT();
00127   
00128   ch->SetBranchAddress("NuePOT", &pt);
00129   ch->GetEntry(0);  
00130 
00131   TDirectory *savedir = gDirectory;
00132 
00133   cout<<"Trying to access: "<<fOutFile<<endl;
00134 
00135   TFile *fpf = dynamic_cast<TFile *>(gROOT->GetListOfFiles()->FindObject(fOutFile.c_str()));
00136   if(fpf){
00137      cout<<"Got the file and rolling"<<endl;
00138      fpf->cd();
00139      TTree *pottree = new TTree("pottree","pottree");
00140      pottree->Branch("NuePOT",&pt);
00141      pottree->Fill();
00142      pottree->Write();
00143      savedir->cd();
00144    }else{
00145     cout<<"failed!"<<endl;
00146   }
00147 }

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

Implement this for read-write access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 63 of file FixModule.cxx.

References counter, MomNavigator::FragmentIter(), JobCModule::Get(), NueHeader::GetEventNo(), RecRecordImp< T >::GetHeader(), NueHeader::GetSnarl(), Msg::kDebug, Msg::kError, JobCResult::kFailed, JobCResult::kPassed, MAXMSG, NueRecord::mri, MSG, MuonRemovalInfo::orig_event, MuonRemovalInfo::orig_roCCPID, and Anp::Handle< T >::valid().

00064 {
00065    //get all NueRecords from mom 
00066    //may have more than one per go since mom reads in a snarl's worth of data
00067    //so, this is a little more complicated than just asking for a NueRecord
00068    TObject *obj=0;
00069 //  static Float_t total_pot = 0;
00070 
00071    vector<NueRecord *> records;
00072 
00073    Anp::Handle<StorekNNData> data = Anp::Factory<StorekNNData>::Instance().Get("kNNData");
00074    if(!data.valid())
00075    {
00076       MAXMSG("NueModule", Msg::kError, 1)
00077            << "NueModule::Reco - Handle<StorekNNData> is invalid, assuming no Rustem variable to run"
00078            << endl;
00079    }
00080 
00081    bool foundOne = false;
00082    TIter objiter = mom->FragmentIter();
00083    while((obj=objiter.Next())){
00084       NueRecord *nr = dynamic_cast<NueRecord *>(obj);
00085       if(nr){
00086          foundOne = true;
00087          MSG("FixModule",Msg::kDebug)<<"Found a NueRecord in MOM"<<endl;
00088       }
00089       else{
00090          MSG("FixModule",Msg::kDebug)<<"Didn't find a NueRecord in MOM"<<endl;
00091          continue;
00092       }
00093       MSG("FixModule",Msg::kDebug)<<"Found a NueRecord in MOM"
00094                        <<" Snarl "<<nr->GetHeader().GetSnarl()
00095                        <<" Event "<<nr->GetHeader().GetEventNo()<<endl;
00096  
00097 
00098       if(nr->mri.orig_event > -10){
00099         float knn_pid;
00100 
00101         data -> SetPrefix("OldSNTP");
00102         data -> Get(nr->mri.orig_event, "knn_pid", knn_pid);
00103         nr->mri.orig_roCCPID = knn_pid; 
00104       }
00105 
00106       if(counter%1000==0){
00107          cout<<"On entry "<<counter<<endl;
00108       }
00109       counter++;
00110    }
00111 
00112    data->Clear();
00113    if(!foundOne) return JobCResult::kFailed;
00114 
00115    return JobCResult::kPassed; // kNoDecision, kFailed, etc.
00116 }


Member Data Documentation

int FixModule::counter [private]

Definition at line 41 of file FixModule.h.

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

std::string FixModule::fInFile [private]

Definition at line 43 of file FixModule.h.

Referenced by Config(), and EndJob().

std::string FixModule::fOutFile [private]

Definition at line 44 of file FixModule.h.

Referenced by Config(), and EndJob().

int FixModule::kept [private]

Definition at line 42 of file FixModule.h.

Referenced by BeginJob(), and EndJob().


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1