MCMonitorBeam Class Reference

#include <MCMonitorBeam.h>

Inheritance diagram for MCMonitorBeam:
JobCModule

List of all members.

Public Member Functions

 MCMonitorBeam ()
 ~MCMonitorBeam ()
void BeginJob ()
void EndJob ()
void BeginFile ()
void EndFile ()
JobCResult Ana (const MomNavigator *mom)
const RegistryDefaultConfig () const
void Config (const Registry &r)

Private Member Functions

void FillTrueHistograms (NtpStRecord *strec, NtpMCRecord *mcrec)

Private Attributes

MCMonitorBeamHistogramsfHists
std::string fOutRootFileName
int fNumSnarlsInCurrFile
std::vector< int > fNumSnarlsInFile

Detailed Description

Definition at line 17 of file MCMonitorBeam.h.


Constructor & Destructor Documentation

MCMonitorBeam::MCMonitorBeam (  ) 

Definition at line 24 of file MCMonitorBeam.cxx.

References Msg::kDebug, and MSG.

00024                              : 
00025   fHists(new MCMonitorBeamHistograms("MCMonBeam")),fOutRootFileName("") {
00026   // Default constructor
00027 
00028   MSG("MCMon",Msg::kDebug) << "In MCMonitorBeam constructor" << endl;
00029 
00030 }

MCMonitorBeam::~MCMonitorBeam (  ) 

Definition at line 32 of file MCMonitorBeam.cxx.

References Msg::kDebug, and MSG.

00033 {
00034   // Destructor
00035   MSG("MCMon",Msg::kDebug) << "In MCMonitorBeam destructor" << endl;
00036 
00037 }


Member Function Documentation

JobCResult MCMonitorBeam::Ana ( const MomNavigator mom  )  [virtual]

Implement this for read only access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 100 of file MCMonitorBeam.cxx.

References fHists, fNumSnarlsInCurrFile, MomNavigator::GetFragment(), Msg::kDebug, JobCResult::kFailed, JobCResult::kPassed, Msg::kWarning, and MSG.

00101 {
00102 
00103   MSG("MCMon",Msg::kDebug) << "In MCMonitorBeam::Ana" << endl;
00104 
00105   // get NtpSt from the file
00106   NtpStRecord* strec =
00107     dynamic_cast<NtpStRecord*>( mom->GetFragment("NtpStRecord") );
00108   // (just in case strec isn't present . . .)
00109   NtpMCRecord* mcrec = 0;
00110   
00111   if (!strec) {
00112     mcrec = dynamic_cast<NtpMCRecord*>( mom->GetFragment("NtpMCRecord") );
00113     if (!mcrec) {
00114       MSG("MCMon",Msg::kWarning)
00115         << "No NtpStRecord or NtpMCRecord in Mom! Aborting . . ."
00116         << endl;
00117       return JobCResult::kFailed;
00118     }
00119   } 
00120 
00121   fHists -> FillHistograms(strec, mcrec);
00122 
00123   // Increment #snarls/file
00124   fNumSnarlsInCurrFile++;
00125 
00126   MSG("MCMon",Msg::kDebug) << "\n-----> Processed " << fNumSnarlsInCurrFile 
00127                            << " snarls in this file." << endl;
00128 
00129   return JobCResult::kPassed; 
00130 
00131 }

void MCMonitorBeam::BeginFile (  )  [virtual]

Implement for notification of begin of file. See GetCurrentFile().

Reimplemented from JobCModule.

Definition at line 79 of file MCMonitorBeam.cxx.

References Msg::kDebug, and MSG.

00079                               {
00080   //
00081 
00082   MSG("MCMon",Msg::kDebug) << "In MCMonitorBeam::BeginFile" << endl;
00083 
00084 }

void MCMonitorBeam::BeginJob ( void   )  [virtual]

Implement for notification of begin of job

Reimplemented from JobCModule.

Definition at line 39 of file MCMonitorBeam.cxx.

References Msg::kDebug, and MSG.

00039                              {
00040   
00041   MSG("MCMon",Msg::kDebug) << "In MCMonitorBeam::BeginJob" << endl;
00042 
00043 }

void MCMonitorBeam::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 155 of file MCMonitorBeam.cxx.

References fOutRootFileName, Registry::GetCharString(), Msg::kDebug, and MSG.

00156 {
00157   //
00158   // Configure the module given the Registry r
00159   //
00160 
00161   MSG("MCMon",Msg::kDebug) << "In MCMonitorBeam::Config" << endl;
00162 
00163   fOutRootFileName   = r.GetCharString("OutFile");
00164 }

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

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

00134 {
00135   //
00136   // Supply the default configuration for the module
00137   //
00138   MSG("MCMon",Msg::kDebug) << "In MCMonitorBeam::DefaultConfig" << endl;
00139 
00140   static Registry r; // Default configuration for module
00141 
00142   // Set name of config
00143   std::string name = this->GetName();
00144   name += ".config.default";
00145   r.SetName(name.c_str());
00146 
00147   // Set values in configuration
00148   r.UnLockValues();
00149   r.Set("OutFile","mcmonitor.root");    // Output root file for histograms
00150   r.LockValues();
00151 
00152   return r;
00153 }

void MCMonitorBeam::EndFile (  )  [virtual]

Implement for notification of end of file. See GetLastFile().

Reimplemented from JobCModule.

Definition at line 86 of file MCMonitorBeam.cxx.

References fNumSnarlsInCurrFile, fNumSnarlsInFile, Msg::kDebug, and MSG.

Referenced by EndJob().

00086                             {
00087 
00088   MSG("MCMon",Msg::kDebug)
00089     << "In MCMonitorBeam::EndFile \n" 
00090     << "Num Snarls in Current File           : "
00091     << fNumSnarlsInCurrFile << endl;
00092   // Send 'number of X per file' info to vectors; increment fFileNum
00093   fNumSnarlsInFile.push_back(fNumSnarlsInCurrFile);
00094 
00095   fNumSnarlsInCurrFile = 0;
00096 
00097 }

void MCMonitorBeam::EndJob (  )  [virtual]

Implement for notification of end of job

Reimplemented from JobCModule.

Definition at line 45 of file MCMonitorBeam.cxx.

References MCMonitorBeamHistograms::AllSumw2(), EndFile(), fHists, fNumSnarlsInCurrFile, fNumSnarlsInFile, fOutRootFileName, MCMonitorBeamHistograms::GetName(), Msg::kDebug, Msg::kInfo, MSG, MCMonitorBeamHistograms::NumHistograms(), and MCMonitorBeamHistograms::SetCanRebin().

00045                            {
00046   //
00047   //
00048   MSG("MCMon",Msg::kDebug) << "In MCMonitorBeam::EndJob" << endl;
00049 
00050   if (fNumSnarlsInCurrFile !=  0) EndFile();
00051 
00052   unsigned int numFiles = fNumSnarlsInFile.size();
00053   unsigned int numSnarls = 0;
00054   for ( unsigned int ifile = 0; ifile < numFiles; ifile++ ) {
00055     numSnarls += fNumSnarlsInFile[ifile];
00056   }
00057   
00058   fHists->SetCanRebin();
00059   fHists->AllSumw2();
00060   
00061   // Send all of the histograms to output root file
00062   MSG("MCMon",Msg::kInfo)
00063      << "MCMonitor::EndJob storing histograms to file "
00064      << fOutRootFileName.c_str() << endl;
00065   HistMan hm((fHists->GetName()).c_str());
00066   hm.WriteOut(fOutRootFileName.c_str());
00067 
00068   // Print a summary of the module
00069   cout << std::string(75,'-') << endl;
00070   cout << "Processed " << numFiles << " files" << endl
00071        << "Processed " << numSnarls << " snarls" << endl
00072        << "Produced  " << fHists->NumHistograms()
00073        << " histograms written to file: " << fOutRootFileName.c_str()
00074        << endl;
00075   cout << std::string(75,'-') << endl;
00076 
00077 }

void MCMonitorBeam::FillTrueHistograms ( NtpStRecord strec,
NtpMCRecord mcrec 
) [private]

Member Data Documentation

Definition at line 42 of file MCMonitorBeam.h.

Referenced by Ana(), and EndJob().

Definition at line 48 of file MCMonitorBeam.h.

Referenced by Ana(), EndFile(), and EndJob().

std::vector<int> MCMonitorBeam::fNumSnarlsInFile [private]

Definition at line 49 of file MCMonitorBeam.h.

Referenced by EndFile(), and EndJob().

std::string MCMonitorBeam::fOutRootFileName [private]

Definition at line 45 of file MCMonitorBeam.h.

Referenced by Config(), and EndJob().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1