RecordSetupModule Class Reference

#include <RecordSetupModule.h>

Inheritance diagram for RecordSetupModule:
JobCModule

List of all members.

Public Member Functions

 RecordSetupModule ()
 ~RecordSetupModule ()
void BeginJob ()
void Config (const Registry &r)
const RegistryDefaultConfig () const
virtual JobCResult Get (MomNavigator *mom)
virtual JobCResult Reco (MomNavigator *mom)

Detailed Description

Definition at line 20 of file RecordSetupModule.h.


Constructor & Destructor Documentation

RecordSetupModule::RecordSetupModule (  ) 

Definition at line 42 of file RecordSetupModule.cxx.

References Msg::kVerbose, and MSG.

00043 {
00044   MSG("RecSetup", Msg::kVerbose) << "RecordSetupModule::Constructor\n";
00045 }

RecordSetupModule::~RecordSetupModule (  ) 

Definition at line 48 of file RecordSetupModule.cxx.

References Msg::kVerbose, and MSG.

00049 {
00050   MSG("RecSetup", Msg::kVerbose) << "RecordSetupModule::Destructor\n";
00051 }


Member Function Documentation

void RecordSetupModule::BeginJob ( void   )  [virtual]

Implement for notification of begin of job

Reimplemented from JobCModule.

Definition at line 54 of file RecordSetupModule.cxx.

References Msg::kVerbose, and MSG.

00055 {
00056   MSG("RecSetup", Msg::kVerbose) << "RecordSetupModule::BeginJob\n";
00057 }

void RecordSetupModule::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 60 of file RecordSetupModule.cxx.

References Msg::kDebug, and MSG.

00061 {
00062   MSG("RecSetup", Msg::kDebug) << "RecordSetupModule::Config" << endl;
00063 }

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

References JobCModule::GetName(), Msg::kDebug, Registry::LockValues(), MSG, Registry::Set(), and Registry::UnLockValues().

00067 {
00068   MSG("RecSetup", Msg::kDebug)
00069     << "RecordSetupModule::DefaultConfig" << endl;
00070 
00071   static Registry r;
00072   
00073   std::string name = this->JobCModule::GetName();
00074   name += ".config.default";
00075   r.SetName(name.c_str());
00076   
00077   r.UnLockValues();
00078   r.Set("CandRecordName",    "PrimaryCandidateRecord");
00079   r.Set("CandRecordTitle",   "Created by RecordSetupModule");
00080   r.Set("ConfigRecordName",  "AlgConfigRecord");
00081   r.Set("ConfigRecordTitle", "Created by AlgFactory");
00082   r.LockValues();
00083 
00084   return r;
00085 }

JobCResult RecordSetupModule::Get ( MomNavigator mom  )  [virtual]

Implement if your module needs to read data from some external source and fill mom

Reimplemented from JobCModule.

Definition at line 88 of file RecordSetupModule.cxx.

References MomNavigator::AdoptFragment(), RecJobHistory::Append(), RecJobHistory::CreateJobRecord(), Registry::Get(), RawDataBlock::GetBlockId(), JobCModule::GetConfig(), RawBlockId::GetEncoded(), MomNavigator::GetFragment(), RecMinos::GetJobHistory(), RawRecord::GetRawBlockIter(), RawRecord::GetRawHeader(), RawDaqHeader::GetRun(), RawDaqSnarlHeader::GetSnarl(), RecMinosHdr::GetVldContext(), RecJobHistory::kCand, Msg::kDebug, JobCResult::kPassed, Msg::kWarning, MSG, run(), JobCResult::SetFailed(), and JobCResult::SetWarning().

00089 {
00090   JobCResult result(JobCResult::kPassed);
00091 
00092   MSG("RecSetup", Msg::kDebug) << "RecordSetupModule::Get\n";
00093 
00094 // Cache JobModule Registry values for Get method
00095   const char *tmps = 0;
00096 
00097   const char *candrecordname = 0;
00098   const char *candrecordtitle = 0;
00099   const char *configrecordname = 0;
00100   const char *configrecordtitle = 0;
00101 
00102   Registry &r = GetConfig();     // Get this JobModule's Registry object
00103   if (r.Get("CandRecordName",        tmps)) candrecordname       = tmps;
00104   if (r.Get("CandRecordTitle",       tmps)) candrecordtitle      = tmps;
00105   if (r.Get("ConfigRecordName",      tmps)) configrecordname     = tmps;
00106   if (r.Get("ConfigRecordTitle",     tmps)) configrecordtitle    = tmps;
00107 
00108 // Create a VldContext
00109 // with a preference for a DaqSnarl over other RawRecords
00110   RawRecord * rawrec = 
00111     dynamic_cast<RawRecord *>(mom->GetFragment("RawRecord","","DaqSnarl"));
00112   if (!rawrec) rawrec = 
00113     dynamic_cast<RawRecord *>(mom->GetFragment("RawRecord"));
00114   if (!rawrec) {
00115     MSG("RecSetup", Msg::kWarning) << "No RawRecord in MOM." << endl;
00116     result.SetWarning().SetFailed();
00117     return result;
00118   }
00119 
00120   VldContext vldc = rawrec->GetRawHeader()->GetVldContext();
00121   Int_t run   = -1;
00122   Int_t snarl = -1;
00123 
00124   const RawDaqSnarlHeader* snarlHdr = 
00125      dynamic_cast<const RawDaqSnarlHeader*>(rawrec->GetRawHeader());
00126   if (snarlHdr) {
00127      run   = snarlHdr->GetRun();
00128      snarl = snarlHdr->GetSnarl();
00129   } else {
00130      const RawDaqHeader* daqHdr = 
00131         dynamic_cast<const RawDaqHeader*>(rawrec->GetRawHeader());
00132      if (daqHdr) {
00133         MSG("RecSetup", Msg::kWarning)
00134            << "RawRecord only had a RawDaqHeader"
00135            << " - CandHeader will have bogus Snarl #'s"
00136            << endl;
00137         run = daqHdr->GetRun();
00138      } else {
00139         MSG("RecSetup", Msg::kWarning)
00140            << "RawRecord didn't have RawDaqSnarlHeader"
00141            << " - CandHeader will have bogus Run/Snarl #'s"
00142            << endl;
00143         MSG("RecSetup", Msg::kWarning)
00144                      << "  List of RawDataBlocks in RawRecord:" << endl;
00145         TIter rbi = rawrec->GetRawBlockIter();
00146         TObject *tobj;
00147         RawDataBlock *rb;
00148         while ( (tobj = rbi()) ) {
00149            rb = dynamic_cast<RawDataBlock *>(tobj); 
00150            if (!rb) continue;
00151            MSG("RecSetup", Msg::kWarning)
00152                 << "     " << rb->ClassName() << " : " 
00153                 << rb->GetName()
00154                 << "  0x" << hex << rb->GetBlockId().GetEncoded() << dec
00155                 << endl;
00156         }
00157      }
00158   }
00159 
00160 // Check if there's a PrimaryCandidateRecord fragment in MOM.
00161   CandRecord *candrec = dynamic_cast<CandRecord *>
00162              (mom->GetFragment("CandRecord", candrecordname));
00163   if (candrec == 0) {
00164     MSG("RecSetup", Msg::kDebug)
00165     << "No " << candrecordname << " in MOM.  Create a new one." << endl;
00166 
00167 // Create a CandHeader - No event splitting so don't supply event number
00168     CandHeader *head = new CandHeader(vldc, run, snarl);
00169 
00170 // Produce a CandRecord.  Have it adopt the header
00171     candrec = new CandRecord(head);
00172 
00173 // Give the CandRecord to MOM to hold as a "fragment"
00174     candrec->SetName(candrecordname);
00175     candrec->SetTitle(candrecordtitle);
00176 
00177     RecJobHistory& jobhist 
00178               = const_cast<RecJobHistory&>(candrec->GetJobHistory());
00179     jobhist.Append(rawrec->GetJobHistory());
00180     jobhist.CreateJobRecord(RecJobHistory::kCand);
00181 
00182     mom->AdoptFragment(candrec);
00183   }
00184 
00185   return result;
00186 }

JobCResult RecordSetupModule::Reco ( MomNavigator mom  )  [virtual]

Implement this for read-write access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 189 of file RecordSetupModule.cxx.

References MomNavigator::AdoptFragment(), MomNavigator::FragmentIter(), Registry::Get(), JobCModule::GetConfig(), ConfigRecord::GetConfigIter(), MomNavigator::GetFragment(), AlgFactory::GetInstance(), AlgFactory::GetOwnedConfigRecord(), RecMinos::GetVldContext(), Msg::kDebug, JobCResult::kPassed, and MSG.

00190 {
00191   JobCResult result(JobCResult::kPassed);
00192 
00193   MSG("RecSetup", Msg::kDebug) << "RecordSetupModule::Reco\n";
00194 
00195 // Cache JobModule Registry values for Put method
00196   const char *tmps = 0;
00197 
00198   const char *candrecordname = 0;
00199   const char *candrecordtitle = 0;
00200   const char *configrecordname = 0;
00201   const char *configrecordtitle = 0;
00202 
00203   Registry &r = GetConfig();     // Get this JobModule's Registry object
00204   if (r.Get("CandRecordName",        tmps)) candrecordname       = tmps;
00205   if (r.Get("CandRecordTitle",       tmps)) candrecordtitle      = tmps;
00206   if (r.Get("ConfigRecordName",      tmps)) configrecordname     = tmps;
00207   if (r.Get("ConfigRecordTitle",     tmps)) configrecordtitle    = tmps;
00208 
00209   CandRecord* candrec =
00210               dynamic_cast<CandRecord*>(mom->GetFragment("CandRecord"));
00211   if (candrec != 0) {
00212     const VldContext* vc = candrec->GetVldContext();   
00213     AlgFactory &af = AlgFactory::GetInstance();
00214     ConfigRecord *conrec = af.GetOwnedConfigRecord(vc);
00215     if (conrec) {
00216       if (configrecordname) conrec->SetName(configrecordname);
00217       if (configrecordtitle) conrec->SetTitle(configrecordtitle);
00218       mom->AdoptFragment(conrec);
00219 
00220 // Begin diagnostic printout
00221       TIter criter = mom->FragmentIter();
00222       TObject *tob;
00223       MSG("RecSetup", Msg::kDebug) << "Mom Fragment List:" << endl;
00224       while ((tob = criter())) {
00225         MSG("RecSetup", Msg::kDebug)
00226                      << "Fragment Class = " << tob->ClassName()
00227                      << " Fragment Name = " << tob->GetName()
00228                      << " Fragment Title = " << tob->GetTitle() << endl;
00229       }
00230       TIter algiter = conrec->GetConfigIter();
00231       MSG("RecSetup", Msg::kDebug) << "AlgConfig List:" << endl;
00232       while ((tob = algiter())) {
00233         MSG("RecSetup", Msg::kDebug)
00234                        << "Config Class = "  << tob->ClassName()
00235                        << " Config Name = "  << tob->GetName() << endl;
00236       }
00237 // End diagnostic printout
00238 
00239     }
00240   }
00241   return result;
00242 }


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1