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

NuModule.cxx

Go to the documentation of this file.
00001 
00002 
00003 // Coded by Jeff Hartnell Aug/2007 onwards
00004 //
00005 // Contact: j.j.hartnell@rl.ac.uk
00007 
00008 #include <cassert>
00009 
00010 #include "JobControl/JobCModuleRegistry.h"
00011 #include "JobControl/JobCommand.h"
00012 #include "MessageService/MsgService.h"
00013 #include "MinosObjectMap/MomNavigator.h"
00014 #include "BeamDataNtuple/NtpBDLiteRecord.h"
00015 #include "CandFitTrackSA/Ntp/NtpFitSARecord.h"
00016 #include "StandardNtuple/NtpStRecord.h"
00017 
00018 #include "NuMuBar/NuAnalysis.h"
00019 #include "NuMuBar/NuModule.h"
00020 
00021 JOBMODULE(NuModule,
00022           "NuModule",
00023           "A module to produce NuMuBar DST ntuples");
00024 
00025 CVSID("$Id: NuModule.cxx,v 1.3 2007/10/14 19:59:08 hartnell Exp $");
00026 
00027 ClassImp(NuModule)
00028 
00029 //......................................................................
00030 
00031 NuModule::NuModule() 
00032 {
00033   MSG("NuModule", Msg::kDebug) 
00034    <<"Running NuModule constructor..."<<endl;
00035 
00036   //initialise data members
00037   fNuAnalysis=0;
00038   fUseOldMethod=0;
00039 
00040   MSG("NuModule", Msg::kDebug) 
00041    <<"Finished constructor"<<endl;
00042 }
00043 
00044 //......................................................................
00045 
00046 NuModule::~NuModule()
00047 {
00048   MSG("NuModule", Msg::kDebug) 
00049    <<"Running destructor..."<<endl;
00050 
00051   MSG("NuModule", Msg::kDebug) 
00052    <<"Finished destructor"<<endl;
00053 }
00054 
00055 //......................................................................
00056 
00057 JobCResult NuModule::Ana(const MomNavigator *mom)
00058 {
00059   //to test number of entries
00060   //static Int_t counter=0;
00061   //counter++;
00062   //cout<<"counter="<<counter<<endl;
00063 
00064   //set default result to kPassed
00065   JobCResult result(JobCResult::kPassed);
00066   
00067   //check that mom exists.
00068   assert(mom);
00069   
00070   const NtpStRecord* pntp=dynamic_cast<NtpStRecord*>
00071     (mom->GetFragment("NtpStRecord"));
00072   if (!pntp){
00073     MSG("NuModule",Msg::kWarning) 
00074       << "No NtpStRecord in Mom" << endl;
00075   }
00076   
00077   const NtpBDLiteRecord* pntpBD=dynamic_cast<NtpBDLiteRecord*>
00078     (mom->GetFragment("NtpBDLiteRecord"));
00079   if (!pntpBD){
00080     MAXMSG("NuModule",Msg::kInfo,1)
00081       <<"No NtpBDLiteRecord in Mom (note: not present for MC)"<<endl;
00082   }
00083 
00084   //NtpFitSARecord
00085   const NtpFitSARecord* pntpSA=dynamic_cast<NtpFitSARecord*>
00086     (mom->GetFragment("NtpFitSARecord"));
00087   if (!pntpSA){
00088     MAXMSG("NuModule",Msg::kInfo,1) 
00089       <<"No NtpFitSARecord in Mom (pntpSA="<<pntpSA<<")"<<endl;
00090     //mom->Print();
00091   }
00092   else {
00093     MAXMSG("NuModule",Msg::kInfo,1)
00094       << "Found NtpFitSARecord in Mom" << endl;
00095   }
00096 
00097   //set the file name
00098   static Bool_t firstTime=true;
00099   if (firstTime) {
00100     firstTime=false;
00101     NuBase::InputFileName(this->GetCurrentFile());
00102   }
00103   
00104   //run the code to calc the meu values for events in this snarl
00105   if (fUseOldMethod==1) {
00106     fNuAnalysis->ChargeSeparationOneSnarl(pntp,pntpBD,pntpSA);
00107   }
00108   else {
00109     fNuAnalysis->MakeFullDST(pntp,pntpBD,pntpSA);
00110   }
00111   
00112   return result;
00113 }
00114 
00115 //......................................................................
00116 
00117 void NuModule::BeginJob() 
00118 {
00119   MSG("NuModule",Msg::kInfo)
00120     <<"Running NuModule::BeginJob()..."<<endl;
00121 
00122   //construct the NuAnalysis object
00123   fNuAnalysis=new NuAnalysis();
00124 
00125   MSG("NuModule",Msg::kInfo)
00126     <<"Finished running NuModule::BeginJob()"<<endl;
00127 }
00128 
00129 //......................................................................
00130 
00131 void NuModule::EndJob() 
00132 {  
00133   MSG("NuModule",Msg::kInfo)
00134     <<"Running NuModule::EndJob()..."<<endl;
00135 
00136   //finish the job
00137   fNuAnalysis->EndJob();
00138   
00139   MSG("NuModule",Msg::kInfo)
00140     <<"Finished running NuModule::EndJob()"<<endl;
00141 }
00142 
00143 //......................................................................
00144 
00145 const Registry& NuModule::DefaultConfig() const
00146 {
00148   
00149   MSG("NuModule", Msg::kDebug)
00150     << "Running NuModule::DefaultConfig..." << endl;
00151   
00152   static Registry r;
00153   
00154   string name=this->JobCModule::GetName();
00155   name+=".config.default";
00156   r.SetName(name.c_str());
00157   r.UnLockValues();
00158   
00159   r.Set("UseOldMethod",0);  
00160   //r.Set("LIRunSeqRequired",-1);
00161   //r.Set("WriteOnlyGainCurves",0);
00162 
00163   r.LockValues();
00164   
00165   return r;
00166 }
00167 
00168 //......................................................................
00169 
00170 void NuModule::Config(const Registry& r)
00171 {
00173 
00174   MSG("NuModule",Msg::kDebug)<<"NuModule::Config"<<endl;
00175 
00176   Int_t useOldMethod=0;
00177   if (r.Get("UseOldMethod",useOldMethod)) fUseOldMethod=useOldMethod;
00178   
00179   /*
00180     Int_t runSeqReq=-1;
00181     if (r.Get("LIRunSeqRequired",runSeqReq)) fLIRunSeqReq=runSeqReq;
00182   
00183     Int_t writeOnlyGainCurves=0;
00184     if (r.Get("WriteOnlyGainCurves",
00185     writeOnlyGainCurves)) fWriteOnlyGainCurves=writeOnlyGainCurves;
00186   */
00187 }
00188 
00189 //......................................................................
00190 

Generated on Mon Jun 16 14:58:08 2008 for loon by  doxygen 1.3.9.1