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.4 2009/09/05 17:38:03 jyuko 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     std::cout<<" use charge separtion one snarl"<<endl;
00107     fNuAnalysis->ChargeSeparationOneSnarl(pntp,pntpBD,pntpSA);
00108   }
00109   else {
00110     fNuAnalysis->MakeFullDST(pntp,pntpBD,pntpSA);
00111   }
00112   
00113   return result;
00114 }
00115 
00116 //......................................................................
00117 
00118 void NuModule::BeginJob() 
00119 {
00120   MSG("NuModule",Msg::kInfo)
00121     <<"Running NuModule::BeginJob()..."<<endl;
00122 
00123   //construct the NuAnalysis object
00124   fNuAnalysis=new NuAnalysis();
00125 
00126   MSG("NuModule",Msg::kInfo)
00127     <<"Finished running NuModule::BeginJob()"<<endl;
00128 }
00129 
00130 //......................................................................
00131 
00132 void NuModule::EndJob() 
00133 {  
00134   MSG("NuModule",Msg::kInfo)
00135     <<"Running NuModule::EndJob()..."<<endl;
00136 
00137   //finish the job
00138   fNuAnalysis->EndJob();
00139   
00140   MSG("NuModule",Msg::kInfo)
00141     <<"Finished running NuModule::EndJob()"<<endl;
00142 }
00143 
00144 //......................................................................
00145 
00146 const Registry& NuModule::DefaultConfig() const
00147 {
00149   
00150   MSG("NuModule", Msg::kDebug)
00151     << "Running NuModule::DefaultConfig..." << endl;
00152   
00153   static Registry r;
00154   
00155   string name=this->JobCModule::GetName();
00156   name+=".config.default";
00157   r.SetName(name.c_str());
00158   r.UnLockValues();
00159   
00160   r.Set("UseOldMethod",0);  
00161   //r.Set("LIRunSeqRequired",-1);
00162   //r.Set("WriteOnlyGainCurves",0);
00163 
00164   r.LockValues();
00165   
00166   return r;
00167 }
00168 
00169 //......................................................................
00170 
00171 void NuModule::Config(const Registry& r)
00172 {
00174 
00175   MSG("NuModule",Msg::kDebug)<<"NuModule::Config"<<endl;
00176 
00177   Int_t useOldMethod=0;
00178   if (r.Get("UseOldMethod",useOldMethod)) fUseOldMethod=useOldMethod;
00179   
00180   /*
00181     Int_t runSeqReq=-1;
00182     if (r.Get("LIRunSeqRequired",runSeqReq)) fLIRunSeqReq=runSeqReq;
00183   
00184     Int_t writeOnlyGainCurves=0;
00185     if (r.Get("WriteOnlyGainCurves",
00186     writeOnlyGainCurves)) fWriteOnlyGainCurves=writeOnlyGainCurves;
00187   */
00188 }
00189 
00190 //......................................................................
00191 

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