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

MCMonitorBeam.cxx

Go to the documentation of this file.
00001 
00002 //
00003 // MCMonitorBeam
00004 //    Modified version of Kregg Arm's MCMonitor class to generate
00005 //    histograms specific to comparison of ptsim to gminos beam 
00006 //    events
00008 #include "TClonesArray.h"
00009 
00010 #include "MCMonitorBeam.h"
00011 #include "MessageService/MsgService.h"
00012 #include "MinosObjectMap/MomNavigator.h"
00013 #include "JobControl/JobCModuleRegistry.h" // For JOBMODULE macro
00014 #include "HistMan/HistMan.h"
00015 #include "MCNtuple/NtpMCStdHep.h"
00016 #include "MCNtuple/NtpMCTruth.h"
00017 
00018 JOBMODULE(MCMonitorBeam, "MCMonitorBeam",
00019           "Produce MC plots for beam ray validation.");
00020 CVSID("$Id: MCMonitorBeam.cxx,v 1.1 2008/02/05 20:30:05 schubert Exp $");
00021 ClassImp(MCMonitorBeam)
00022 
00023 //___________________________________________________________________________
00024 MCMonitorBeam::MCMonitorBeam() : 
00025   fHists(new MCMonitorBeamHistograms("MCMonBeam")),fOutRootFileName("") {
00026   // Default constructor
00027 
00028   MSG("MCMon",Msg::kDebug) << "In MCMonitorBeam constructor" << endl;
00029 
00030 }
00031 //___________________________________________________________________________
00032 MCMonitorBeam::~MCMonitorBeam()
00033 {
00034   // Destructor
00035   MSG("MCMon",Msg::kDebug) << "In MCMonitorBeam destructor" << endl;
00036 
00037 }
00038 //___________________________________________________________________________
00039 void MCMonitorBeam::BeginJob() {
00040   
00041   MSG("MCMon",Msg::kDebug) << "In MCMonitorBeam::BeginJob" << endl;
00042 
00043 }
00044 //___________________________________________________________________________
00045 void MCMonitorBeam::EndJob() {
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 }
00078 //___________________________________________________________________________
00079 void MCMonitorBeam::BeginFile() {
00080   //
00081 
00082   MSG("MCMon",Msg::kDebug) << "In MCMonitorBeam::BeginFile" << endl;
00083 
00084 }
00085 //___________________________________________________________________________
00086 void MCMonitorBeam::EndFile() {
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 }
00098 
00099 //___________________________________________________________________________
00100 JobCResult MCMonitorBeam::Ana(const MomNavigator* mom)
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 }
00132 //___________________________________________________________________________
00133 const Registry& MCMonitorBeam::DefaultConfig() const
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 }
00154 //___________________________________________________________________________
00155 void MCMonitorBeam::Config(const Registry& r)
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 }
00165 //___________________________________________________________________________

Generated on Mon Feb 15 11:06:58 2010 for loon by  doxygen 1.3.9.1