00001
00002
00003
00004
00005
00006
00008 #include "TClonesArray.h"
00009
00010 #include "MCMonitorCosmic.h"
00011 #include "MessageService/MsgService.h"
00012 #include "MinosObjectMap/MomNavigator.h"
00013 #include "JobControl/JobCModuleRegistry.h"
00014 #include "HistMan/HistMan.h"
00015 #include "MCNtuple/NtpMCStdHep.h"
00016 #include "MCNtuple/NtpMCTruth.h"
00017 #include "MCNtuple/NtpMCDigiScintHit.h"
00018
00019 JOBMODULE(MCMonitorCosmic, "MCMonitorCosmic",
00020 "Produce MC plots for cosmic ray muon validation.");
00021 CVSID("$Id: MCMonitorCosmic.cxx,v 1.1 2007/10/10 03:11:22 schubert Exp $");
00022 ClassImp(MCMonitorCosmic)
00023
00024
00025 MCMonitorCosmic::MCMonitorCosmic() :
00026 fHists(new MCMonitorCosmicHistograms("MCMonCosmic")),fOutRootFileName("") {
00027
00028
00029 MSG("MCMon",Msg::kDebug) << "In MCMonitorCosmic constructor" << endl;
00030
00031 }
00032
00033 MCMonitorCosmic::~MCMonitorCosmic()
00034 {
00035
00036 MSG("MCMon",Msg::kDebug) << "In MCMonitorCosmic destructor" << endl;
00037
00038 }
00039
00040 void MCMonitorCosmic::BeginJob() {
00041
00042 MSG("MCMon",Msg::kDebug) << "In MCMonitorCosmic::BeginJob" << endl;
00043
00044 }
00045
00046 void MCMonitorCosmic::EndJob() {
00047
00048
00049 MSG("MCMon",Msg::kDebug) << "In MCMonitorCosmic::EndJob" << endl;
00050
00051 if (fNumSnarlsInCurrFile != 0) EndFile();
00052
00053 unsigned int numFiles = fNumSnarlsInFile.size();
00054 unsigned int numSnarls = 0;
00055 for ( unsigned int ifile = 0; ifile < numFiles; ifile++ ) {
00056 numSnarls += fNumSnarlsInFile[ifile];
00057 }
00058
00059 fHists->SetCanRebin();
00060 fHists->AllSumw2();
00061
00062
00063 MSG("MCMon",Msg::kInfo)
00064 << "MCMonitor::EndJob storing histograms to file "
00065 << fOutRootFileName.c_str() << endl;
00066 HistMan hm((fHists->GetName()).c_str());
00067 hm.WriteOut(fOutRootFileName.c_str());
00068
00069
00070 cout << std::string(75,'-') << endl;
00071 cout << "Processed " << numFiles << " files" << endl
00072 << "Processed " << numSnarls << " snarls" << endl
00073 << "Produced " << fHists->NumHistograms()
00074 << " histograms written to file: " << fOutRootFileName.c_str()
00075 << endl;
00076 cout << std::string(75,'-') << endl;
00077
00078 }
00079
00080 void MCMonitorCosmic::BeginFile() {
00081
00082
00083 MSG("MCMon",Msg::kDebug) << "In MCMonitorCosmic::BeginFile" << endl;
00084
00085 }
00086
00087 void MCMonitorCosmic::EndFile() {
00088
00089 MSG("MCMon",Msg::kDebug)
00090 << "In MCMonitorCosmic::EndFile \n"
00091 << "Num Snarls in Current File : "
00092 << fNumSnarlsInCurrFile << endl;
00093
00094 fNumSnarlsInFile.push_back(fNumSnarlsInCurrFile);
00095
00096 fNumSnarlsInCurrFile = 0;
00097
00098 }
00099
00100
00101 JobCResult MCMonitorCosmic::Ana(const MomNavigator* mom)
00102 {
00103
00104 MSG("MCMon",Msg::kDebug) << "In MCMonitorCosmic::Ana" << endl;
00105
00106
00107 NtpStRecord* strec =
00108 dynamic_cast<NtpStRecord*>( mom->GetFragment("NtpStRecord") );
00109
00110 NtpMCRecord* mcrec = 0;
00111 NtpSRRecord* srrec = 0;
00112 NtpTHRecord* threc = 0;
00113
00114 if (!strec) {
00115 mcrec = dynamic_cast<NtpMCRecord*>( mom->GetFragment("NtpMCRecord") );
00116 if (!mcrec) {
00117 MSG("MCMon",Msg::kWarning)
00118 << "No NtpStRecord or NtpMCRecord in Mom! Aborting . . ."
00119 << endl;
00120 return JobCResult::kFailed;
00121 }
00122 srrec = dynamic_cast<NtpSRRecord*>(mom->GetFragment("NtpSRRecord"));
00123 threc = dynamic_cast<NtpTHRecord*>(mom->GetFragment("NtpTHRecord"));
00124 }
00125
00126 fHists -> FillHistograms(strec, mcrec, srrec, threc);
00127
00128
00129 fNumSnarlsInCurrFile++;
00130
00131 MSG("MCMon",Msg::kDebug) << "\n-----> Processed " << fNumSnarlsInCurrFile
00132 << " snarls in this file." << endl;
00133
00134 return JobCResult::kPassed;
00135
00136 }
00137
00138 const Registry& MCMonitorCosmic::DefaultConfig() const
00139 {
00140
00141
00142
00143 MSG("MCMon",Msg::kDebug) << "In MCMonitorCosmic::DefaultConfig" << endl;
00144
00145 static Registry r;
00146
00147
00148 std::string name = this->GetName();
00149 name += ".config.default";
00150 r.SetName(name.c_str());
00151
00152
00153 r.UnLockValues();
00154 r.Set("OutFile","mcmonitor.root");
00155 r.LockValues();
00156
00157 return r;
00158 }
00159
00160 void MCMonitorCosmic::Config(const Registry& r)
00161 {
00162
00163
00164
00165
00166 MSG("MCMon",Msg::kDebug) << "In MCMonitorCosmic::Config" << endl;
00167
00168 fOutRootFileName = r.GetCharString("OutFile");
00169 }
00170