RunFileModule Class Reference

#include <RunFileModule.h>

Inheritance diagram for RunFileModule:
JobCModule

List of all members.

Public Member Functions

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

Private Member Functions

void RunFileOUT ()
void BuildFileOUT ()

Private Attributes

Int_t fRunNum
Short_t fSubRunNum
std::ios_base::openmode fOutMode
Detector::Detector_t fDet
Bool_t fRunOUT
std::string fRunFileName
std::string fRunFileDir
std::string fBuildFileFull
std::string fRunFileFull

Detailed Description

Definition at line 15 of file RunFileModule.h.


Constructor & Destructor Documentation

RunFileModule::RunFileModule (  ) 

Definition at line 44 of file RunFileModule.cxx.

References fRunNum, and RSMSyn.

00044                              {
00045   RSMSyn << "RunFileModule::RunFileModule" << endl;
00046   fRunNum = 0;
00047   fSubRunNum = 0;
00048   fOutMode = ios::out | ios::app;
00049   fRunOUT = false;
00050 }

RunFileModule::~RunFileModule (  ) 

Definition at line 52 of file RunFileModule.cxx.

References RSMSyn.

00052                               {
00053   RSMSyn << "RunFileModule::~RunFileModule" << endl;
00054 }


Member Function Documentation

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

Implement this for read only access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 110 of file RunFileModule.cxx.

References BuildFileOUT(), fDet, fRunNum, fRunOUT, fSubRunNum, VldContext::GetDetector(), RawRecord::GetRawHeader(), RawDaqHeader::GetRun(), RawDaqHeader::GetSubRun(), RecMinosHdr::GetVldContext(), JobCResult::kPassed, RSMDeb, and RunFileOUT().

00110                                                      {
00111   JobCResult result(JobCResult::kPassed);// The default result
00112 
00113   RawRecord* rawrec=0;
00114 
00115   TIter momitr = const_cast<MomNavigator*>(mom)->FragmentIter();
00116   TObject* momobj=0;
00117   while ((momobj=momitr())) {
00118     if ((rawrec=dynamic_cast<RawRecord*>(momobj))) {
00119       const RawDaqHeader* dhdr =
00120         dynamic_cast<const RawDaqHeader*>(rawrec->GetRawHeader());
00121 
00122       if (fRunNum!=dhdr->GetRun() || fSubRunNum!=dhdr->GetSubRun()) {
00123         RSMDeb << "Run change: " <<
00124           fRunNum << "-" << fSubRunNum << " -> " <<
00125           dhdr->GetRun() << "-" << dhdr->GetSubRun() << endl;
00126         RunFileOUT();
00127 
00128         fRunOUT = false;
00129         fRunNum = dhdr->GetRun();
00130         fSubRunNum = dhdr->GetSubRun();
00131         fDet = dhdr->GetVldContext().GetDetector();
00132         BuildFileOUT();
00133       }
00134     }
00135   }
00136   return result;
00137 }

void RunFileModule::BeginJob ( void   )  [virtual]

Implement for notification of begin of job

Reimplemented from JobCModule.

Definition at line 139 of file RunFileModule.cxx.

References fOutMode, fRunNum, fRunOUT, fSubRunNum, and RSMSyn.

00139                              {
00140   RSMSyn << "RunFileModule::BeginJob" << endl;
00141   fRunNum = 0;
00142   fSubRunNum = 0;
00143   fOutMode = ios::out | ios::app;
00144   fRunOUT = false;
00145 }

void RunFileModule::BuildFileOUT (  )  [private]

Definition at line 89 of file RunFileModule.cxx.

References det, fBuildFileFull, fDet, fOutMode, fRunNum, fSubRunNum, Detector::kFar, Detector::kNear, and RSMDeb.

Referenced by Ana().

00089                                  {
00090   RSMDeb << "RunFileModule::BuildFileOUT" << endl;
00091 
00092   if (fRunNum==0 && fSubRunNum==0) {
00093     RSMDeb << "Output attempt for: " <<
00094       fRunNum << "-" << fSubRunNum << endl;
00095     return;
00096   }
00097 
00098   ofstream fout(fBuildFileFull.c_str(),fOutMode);
00099 
00100   char det = 'F';
00101   if(fDet==Detector::kFar) det = 'F';
00102   if(fDet==Detector::kNear) det = 'N';
00103   char file_out[25];
00104   sprintf(file_out,"%c%08d_%04d.mdaq.root",det,fRunNum,fSubRunNum);
00105   fout << file_out << endl;
00106   fout.close();
00107   return;
00108 }

void RunFileModule::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 172 of file RunFileModule.cxx.

References UtilRSM::CheckDir(), exit(), fBuildFileFull, fRunFileDir, fRunFileFull, fRunFileName, Registry::Get(), and RSMSyn.

00172                                             {
00173   RSMSyn << "RunFileModule::Config" << endl;
00174   const char* tmps = 0;
00175 
00176   if(r.Get("RunFileName",tmps)) fRunFileName=tmps;
00177   if(r.Get("RunFileDir",tmps)) fRunFileDir=tmps;
00178 
00179   if(!UtilRSM::CheckDir(fRunFileDir.c_str())) exit(0);
00180 
00181   fRunFileFull = fRunFileDir + "/" + fRunFileName;
00182   fBuildFileFull = fRunFileDir + "/.building_" + fRunFileName;
00183 }

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

References JobCModule::GetName(), Registry::LockValues(), RSMSyn, Registry::Set(), and Registry::UnLockValues().

00155                                                    {
00156   RSMSyn << "RunFileModule::DefaultConfig" << endl;
00157 
00158   static Registry r;
00159 
00160   string name = this->JobCModule::GetName();
00161   r.SetName((name+".config.default").c_str());
00162   r.UnLockValues();
00163 
00164   r.Set("RunFileName","GenericMode.run");
00165   r.Set("RunFileDir","./");
00166 
00167   r.LockValues();
00168 
00169   return r;
00170 }

void RunFileModule::EndJob (  )  [virtual]

Implement for notification of end of job

Reimplemented from JobCModule.

Definition at line 147 of file RunFileModule.cxx.

References fRunNum, fSubRunNum, RSMDeb, RSMSyn, and RunFileOUT().

00147                            {
00148   RSMSyn << "RunFileModule::EndJob" << endl;
00149 
00150   RSMDeb << "Final output in EndJob: " <<
00151     fRunNum << "-" << fSubRunNum << endl;
00152   RunFileOUT();
00153 }

void RunFileModule::RunFileOUT (  )  [private]

Definition at line 56 of file RunFileModule.cxx.

References det, fBuildFileFull, fDet, fOutMode, fRunFileFull, fRunNum, fRunOUT, fSubRunNum, gSystem(), Detector::kFar, Detector::kNear, RSMDeb, and RSMErr.

Referenced by Ana(), and EndJob().

00056                                {
00057   RSMDeb << "RunFileModule::RunFileOUT" << endl;
00058 
00059   if (fRunOUT) {
00060     RSMErr << "Multiple output attempt for: " <<
00061       fRunNum << "-" << fSubRunNum << endl;
00062     return;
00063   }
00064 
00065   if (fRunNum==0 && fSubRunNum==0) {
00066     RSMDeb << "Output attempt for: " <<
00067       fRunNum << "-" << fSubRunNum << endl;
00068     return;
00069   }
00070 
00071   ofstream fout(fRunFileFull.c_str(),fOutMode);
00072 
00073   char det = 'F';
00074   if(fDet==Detector::kFar) det = 'F';
00075   if(fDet==Detector::kNear) det = 'N';
00076   char file_out[25];
00077   sprintf(file_out,"%c%08d_%04d.mdaq.root",det,fRunNum,fSubRunNum);
00078   fout << file_out << endl;
00079   fout.close();
00080 
00081   fRunOUT = true;
00082 
00083   //remove the .building_[] file
00084   gSystem->Unlink(fBuildFileFull.c_str());
00085 
00086   return;
00087 }


Member Data Documentation

std::string RunFileModule::fBuildFileFull [private]

Definition at line 43 of file RunFileModule.h.

Referenced by BuildFileOUT(), Config(), and RunFileOUT().

Definition at line 36 of file RunFileModule.h.

Referenced by Ana(), BuildFileOUT(), and RunFileOUT().

std::ios_base::openmode RunFileModule::fOutMode [private]

Definition at line 34 of file RunFileModule.h.

Referenced by BeginJob(), BuildFileOUT(), and RunFileOUT().

std::string RunFileModule::fRunFileDir [private]

Definition at line 42 of file RunFileModule.h.

Referenced by Config().

std::string RunFileModule::fRunFileFull [private]

Definition at line 44 of file RunFileModule.h.

Referenced by Config(), and RunFileOUT().

std::string RunFileModule::fRunFileName [private]

Definition at line 41 of file RunFileModule.h.

Referenced by Config().

Int_t RunFileModule::fRunNum [private]

Definition at line 31 of file RunFileModule.h.

Referenced by Ana(), BeginJob(), BuildFileOUT(), EndJob(), and RunFileOUT().

Bool_t RunFileModule::fRunOUT [private]

Definition at line 38 of file RunFileModule.h.

Referenced by Ana(), BeginJob(), and RunFileOUT().

Short_t RunFileModule::fSubRunNum [private]

Definition at line 32 of file RunFileModule.h.

Referenced by Ana(), BeginJob(), BuildFileOUT(), EndJob(), and RunFileOUT().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1