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

DDSPaceModule.cxx

Go to the documentation of this file.
00001 
00002 //
00003 // DDSPaceModule.cxx
00004 //
00005 // A JobControl Module for filling an DDSPaceRecord from data stored
00006 // in the SimSnarlRecord.
00007 //
00009 #include <iostream>
00010 #include <cassert>
00011 using namespace std;
00012 
00013 #include "TSystem.h"
00014 
00015 #include "MessageService/MsgService.h"
00016 #include "Record/RecMinos.h"
00017 #include "JobControl/JobCModuleRegistry.h"
00018 #include "JobControl/JobCommand.h"
00019 #include "MinosObjectMap/MomNavigator.h"
00020 #include "Validity/VldContext.h"
00021 #include "Dispatcher/test/DDSPaceModule.h"
00022 
00023 
00024 ClassImp(DDSPaceModule)
00025 
00026 //   Definition of static data members
00027 //   *********************************
00028 
00029 CVSID("$Id: DDSPaceModule.cxx,v 1.2 2005/02/01 18:42:18 tagg Exp $");
00030 JOBMODULE(DDSPaceModule, "DDSPaceModule",
00031          "A pace maker module for record sets.");
00032 
00033 
00034 // Definition of methods (alphabetical order)
00035 // ***************************************************
00036 
00037 
00038 //......................................................................
00039 
00040 DDSPaceModule::DDSPaceModule() : fVldStartTime(0,0) {
00041   // Default constructor
00042 
00043   fStopwatch.Reset();
00044   fStopwatch.Stop();
00045   
00046 }
00047 
00048   
00049 const Registry& DDSPaceModule::DefaultConfig() const {
00050   //
00051   // Purpose: Method to return default configuration.
00052   // 
00053   // Arguments: none.
00054   //
00055   // Return: Registry containing default configuration
00056   //
00057 
00058   MSG("DDSPace",Msg::kDebug) << 
00059     "DDSPaceModule::DefaultConfig" << endl;
00060 
00061   static Registry r; 
00062   std::string name = this->JobCModule::GetName();
00063   name += ".config.default";
00064   r.SetName(name.c_str());
00065 
00066   r.UnLockValues();
00067   r.LockValues();
00068 
00069   return r;
00070 }
00071 
00072 //......................................................................
00073 
00074 void DDSPaceModule::Config(const Registry& /* r */) {
00075   //
00076   // Purpose: Configure the module given a registry.
00077   //
00078   // Arguments: Registry to use to configure the module.
00079   //
00080   // Return: none.
00081   //
00082 
00083   MSG("DDSPace",Msg::kDebug) << "DDSPaceModule::Config" << endl;
00084   
00085   //Int_t tmpi;
00086   //  Double_t tmpd;
00087   //  const Char_t* tmps;
00088 
00089 }
00090 
00091 //......................................................................
00092 
00093 JobCResult DDSPaceModule::Ana(const MomNavigator *mom) {
00094   //
00095   //  Purpose:  Create and fill ntuple record.
00096   //
00097   //  Arguments: mom.
00098   //  
00099   //  Return: status.
00100   // 
00101 
00102   JobCResult result(JobCResult::kPassed);  
00103   MSG("DDSPace",Msg::kDebug) << "DDSPaceModule::Ana" << endl;
00104 
00105   // Check that mom exists.
00106   assert(mom);
00107 
00108   // Blindly look at first record, this module is very simple
00109   // Assumption is that its only of interest to RawRecords with RecMinos base
00110   TIter fiter = mom->FragmentIter();
00111   RecMinos* record = dynamic_cast<RecMinos*>(fiter());
00112   if ( !record ) {
00113     MSG("DDS",Msg::kWarning) << "First record not RecMinos record" << endl;
00114     result.SetWarning().SetFailed();
00115     return result;
00116   }
00117   VldTimeStamp vldCurrentTime = record->GetVldContext()->GetTimeStamp();
00118   
00119   if ( fVldStartTime.GetSec() == 0 ) {
00120     // first call
00121     fVldStartTime = vldCurrentTime;
00122     fStopwatch.Start();  // start timer
00123   }
00124   
00125   Double_t vldtimediff = vldCurrentTime-fVldStartTime;  // seconds
00126   Double_t realtime = fStopwatch.RealTime();  // seconds
00127   // RealTime will stop it, need to restart w/o resetting
00128   fStopwatch.Start(false); 
00129 
00130   Double_t timediff = vldtimediff - realtime;
00131   MSG("DDS",Msg::kDebug) << "Delta VldTime " << vldtimediff 
00132                          << " RealTime " << realtime << " => sleep for " 
00133                          << timediff << " seconds." << endl;
00134 
00135   if ( timediff > 0 ) {
00136     // Sleep for specified length of time in msec
00137     gSystem->Sleep((Int_t)(timediff*1000));
00138   }
00139   
00140   
00141   return result;
00142 
00143 }
00144 

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