EvtInfoInjectorModule Class Reference

#include <EvtInfoInjectorModule.h>

Inheritance diagram for EvtInfoInjectorModule:
JobCModule

List of all members.

Public Member Functions

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

Private Attributes

bool fInjectSnarlTimes
 private data
bool fHaveRawFiles
 has a list of .mdaq files been supplied?
bool fInjectCrateT0
 supply crate t0 times
bool fFavorRawDataTime
 user Raw times rather than User timestamp
int fVerboseFlags
 bit0=times, bit1=daqfiles
size_t fCurrentTimeIndex
 which time to use

Detailed Description

Definition at line 27 of file EvtInfoInjectorModule.h.


Constructor & Destructor Documentation

EvtInfoInjectorModule::EvtInfoInjectorModule (  ) 

Definition at line 42 of file EvtInfoInjectorModule.cxx.

00043   : fInjectSnarlTimes(false)
00044   , fHaveRawFiles(false)
00045   , fInjectCrateT0(false)
00046   , fFavorRawDataTime(true)
00047   , fCurrentTimeIndex(0)
00048 {
00049    // construct a new "EvtInfoInjectorModule" JobControl module
00050 
00051 }

EvtInfoInjectorModule::~EvtInfoInjectorModule (  ) 

Definition at line 55 of file EvtInfoInjectorModule.cxx.

References Msg::kVerbose, and MSG.

00056 {
00057   MSG("Overlay", Msg::kVerbose) << "EvtInfoInjectorModule::Destructor\n";
00058 
00059 }


Member Function Documentation

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

Implement this for read only access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 149 of file EvtInfoInjectorModule.cxx.

References VldTimeStamp::AsString(), fCurrentTimeIndex, fFavorRawDataTime, EvtOverlaySingleton::FindClosestDaqSnarl(), fInjectCrateT0, fInjectSnarlTimes, fVerboseFlags, HistMan::Get(), VldTimeStamp::GetBOT(), EvtOverlaySingleton::GetClosestCrateT0s(), EvtOverlaySingleton::GetClosestSnarlVldTimeStamp(), VldTimeStamp::GetNanoSec(), EvtOverlaySingleton::GetUserTime(), minos::GetWhiteBoardRegistry(), EvtOverlaySingleton::Instance(), EvtOverlaySingleton::IsValidSnarl(), Msg::kDebug, JobCResult::kFailed, JobCResult::kPassed, Msg::kSynopsis, Msg::kVerbose, Msg::kWarning, MSG, minos::PostOnWhiteBoard(), and Registry::Print().

00150 {
00151    // Post stuff on the whiteboard for downstream modules
00152 
00153   MSG("EvtInfo",Msg::kSynopsis)
00154     << "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
00155     << std::endl;
00156 
00157   HistMan hm("evtinfo");
00158 
00159   EvtOverlaySingleton& eos = EvtOverlaySingleton::Instance();
00160   VldTimeStamp ts(VldTimeStamp::GetBOT());
00161   VldTimeStamp tsT0(VldTimeStamp::GetBOT());
00162 
00163   if ( fInjectSnarlTimes ) {
00164 
00165     VldTimeStamp tsUser = eos.GetUserTime(fCurrentTimeIndex);
00166 
00167     minos::PostOnWhiteBoard("EvtInfo","TimeIndex",(int)fCurrentTimeIndex);
00168 
00169     ts = tsUser;
00170     if ( fFavorRawDataTime ) {
00171       // use the time of the nearest data snarl header
00172       eos.FindClosestDaqSnarl(tsUser);
00173       if ( eos.IsValidSnarl() ) {
00174         ts = eos.GetClosestSnarlVldTimeStamp();
00175       }
00176     }
00177 
00178     // drop info onto the whiteboard
00179     minos::PostOnWhiteBoard("EvtInfo","SnarlTimeStamp",ts);
00180     minos::PostOnWhiteBoard("EvtInfo","UserTimeStamp",tsUser);
00181     //minos::PostOnWhiteBoard("EvtInfo","Snarl",fSnarl);
00182     //minos::PostOnWhiteBoard("EvtInfo","RunType",runtype);
00183     //minos::PostOnWhiteBoard("EvtInfo","TrigSrc",trigsrc);  
00184 
00185     double dtuserraw = (double)(tsUser-ts);
00186     MSG("EvtInfo",Msg::kDebug) << "#rwh user-rawtime " << dtuserraw 
00187                                << " user " << tsUser.AsString("c") 
00188                                << " raw " << ts.AsString("c") << std::endl;
00189     hm.Get<TH1D>("user-rawtime")->Fill(dtuserraw);
00190 
00191     if ( fInjectCrateT0 ) {
00192 
00193       eos.FindClosestDaqSnarl(ts);
00194       if ( ! eos.IsValidSnarl() ) {
00195         MSG("EvtInfo",Msg::kSynopsis)
00196           << "EvtInfoInjectorModule index=" << fCurrentTimeIndex 
00197           << " SnarlTimeStamp " << ts.AsString("c")
00198           << " Invalid Snarl" << std::endl;
00199         return JobCResult::kFailed;
00200       }
00201       
00202       std::set<VldTimeStamp> crateT0set = eos.GetClosestCrateT0s();
00203       size_t nt0 = crateT0set.size();
00204       if ( nt0 == 0 ) {
00205         MSG("EvtInfo",Msg::kWarning) 
00206           << "HEY! EvtInfoInjectorModule got zero crate_t0 values"
00207           << std::endl;
00208       } else {
00209 
00210         tsT0 = *(crateT0set.begin());  // first one
00211         minos::PostOnWhiteBoard("EvtInfo","CrateT0",tsT0);
00212 
00213         hm.Get<TH1D>("crateT0frac")->Fill(tsT0.GetNanoSec()*1.0e-9);
00214 
00215         if ( nt0 > 1 ) {
00216           MSG("Overlay",Msg::kWarning)
00217             << "HEY! EvtInfoInjectorModule got " << nt0 
00218             << " crate_t0 values for the same RawDigitDataBlock" 
00219             << "\n  using the first!"
00220             << std::endl;
00221         }
00222       } // found one or more times
00223     }  // add crate_t0
00224   } // inject snarl times 
00225 
00226   MSG("EvtInfo",Msg::kVerbose)
00227     << "EvtInfoInjectorModule index=" << fCurrentTimeIndex 
00228     << " SnarlTimeStamp " << ts.AsString("c")
00229     << " CrateT0 " << tsT0.AsString("c") << std::endl;
00230 
00231   if (fVerboseFlags & 0x04 ) {
00232     minos::GetWhiteBoardRegistry("EvtInfo")->Print();
00233   }
00234 
00235   // move on for next time we're called
00236   ++fCurrentTimeIndex;
00237 
00238   return JobCResult::kPassed; // All Ok
00239 }

void EvtInfoInjectorModule::BeginJob ( void   )  [virtual]

Implement for notification of begin of job

Reimplemented from JobCModule.

Definition at line 63 of file EvtInfoInjectorModule.cxx.

References EvtOverlaySingleton::AddDaqFile(), HistMan::Book(), EvtOverlaySingleton::ExpandFileList(), fHaveRawFiles, files, fInjectCrateT0, fInjectSnarlTimes, Form(), fVerboseFlags, Registry::Get(), JobCModule::GetConfig(), EvtOverlaySingleton::Instance(), it, Msg::kInfo, EvtOverlaySingleton::MapDaqFiles(), MSG, EvtOverlaySingleton::NumUserTimes(), EvtOverlaySingleton::ReadSpillTimesFiles(), EvtOverlaySingleton::TokenizeString(), Registry::UnLockKeys(), and Registry::UnLockValues().

00064 {
00065 
00066   EvtOverlaySingleton& eos = EvtOverlaySingleton::Instance();
00067   Registry& r = GetConfig();
00068   r.UnLockKeys();
00069   r.UnLockValues();
00070   //r.Print();
00071 
00072   const char* tmps = 0;
00073 
00074   std::string searchpaths;
00075   if ( r.Get("SearchPaths",tmps) ) { searchpaths = tmps; }
00076 
00077   MSG("Overlay",Msg::kInfo) << "EvtInfoInjectorModule::BeginJob() searchpaths " << searchpaths << std::endl;
00078 
00079   if ( r.Get("UserTimesFile",tmps) ) {
00080     eos.ReadSpillTimesFiles(tmps,searchpaths, fVerboseFlags & 0x01 );
00081     fInjectSnarlTimes = ( eos.NumUserTimes() > 0 );
00082     MSG("Overlay",Msg::kInfo) << "EvtInfoInjectorModule::BeginJob() usertimesfile " << tmps << std::endl;
00083   }
00084 
00085   int nfilesAdded = 0;
00086   if ( r.Get("OverlayFiles",tmps) ) {
00087     std::vector<std::string> tokens = eos.TokenizeString(tmps,",:;");
00088     for (size_t it = 0; it < tokens.size() ; ++it ) {
00089       std::vector<std::string> files = 
00090         eos.ExpandFileList(tokens[it],searchpaths);
00091       for (size_t ifile=0; ifile < files.size(); ++ifile) {
00092         if ( " " == files[ifile] || "" == files[ifile] ) continue;
00093         MSG("Overlay",Msg::kInfo) << "AddDaqSnarlFile \"" << files[ifile] << "\"" << std::endl;
00094         nfilesAdded += eos.AddDaqFile(files[ifile]);
00095       }
00096     }
00097     if ( nfilesAdded == 0 ) {
00098       MSG("Overlay",Msg::kInfo) << "OverlayFiles=\"" << tmps << "\" but no files added" << endl;
00099     } else {
00100       fHaveRawFiles = true;
00101       // added all the files, spin through them
00102       TStopwatch sw;
00103       sw.Start();
00104       eos.MapDaqFiles( fVerboseFlags & 0x02 );
00105       sw.Stop();
00106       MSG("Overlay",Msg::kInfo) 
00107         << "MapDaqSnarlFiles took "
00108         << Form("Real %7.3f, CPU %7.3f sec",sw.RealTime(),sw.CpuTime())
00109         << " to load" << std::endl;
00110     }
00111   }
00112 
00113   fInjectCrateT0 = (fInjectSnarlTimes && fHaveRawFiles);
00114   // unless specifically told not to do so
00115   int tmpi = 1;
00116   if ( r.Get("InjectCrateT0",tmpi) ) {
00117     if ( 0 == tmpi ) fInjectCrateT0 = false;
00118   }
00119 
00120   // book some HistMan histograms
00121   HistMan hm("evtinfo");
00122   hm.Book<TH1D>("user-rawtime","user-rawtime; sec",100,-100.e-3,100.e-3);
00123   hm.Book<TH1D>("crateT0frac","crateT0frac; sec",100,0,100.e-6); // expect 60usec
00124 
00125   // report configuration
00126   //Report();
00127 
00128 }

void EvtInfoInjectorModule::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 280 of file EvtInfoInjectorModule.cxx.

References fFavorRawDataTime, fVerboseFlags, and Registry::Get().

00281 {
00282 //======================================================================
00283 // Configure the module given the registry r
00284 //======================================================================
00285   //const char*  tmps;
00286   //double tmpd;
00287   int    tmpi;
00288 
00289   if ( r.Get("FavorRawDataTime",tmpi) ) { fFavorRawDataTime = (tmpi!=0); }
00290   if ( r.Get("VerboseFlags",tmpi) )     { fVerboseFlags     =  tmpi;     }
00291 
00292   // other config info is used at BeginJob
00293   // don't want to process everytime Config() changes
00294 
00295 }

const Registry & EvtInfoInjectorModule::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; }

< path prefixes

< names of .mdaq.root files comma separated (wildcard okay)

< name of file(s) w/ spill times

< use rawdata time instead of actual user time

< inject crate t0 if we can (by default)

< signal that we're overlaying Minerva MC

< verbosity

< 0x01 print initial user times 0x02 print initial daq file sampling 0x04 print whiteboard info each event

Reimplemented from JobCModule.

Definition at line 243 of file EvtInfoInjectorModule.cxx.

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

00244 {
00245 //======================================================================
00246 // Create a registry which holds the default configuration and return it
00247 //======================================================================
00248   static Registry r;
00249  
00250   // Set name of config
00251   std::string name = this->GetName();
00252   name += ".config.default";
00253   r.SetName(name.c_str());
00254 
00255   // Set values of config
00256   r.UnLockValues();
00257   r.UnLockKeys();
00258 
00259   // if creating records out of whole cloth here's a starting point
00260   r.Set("SearchPaths","");     
00261   r.Set("OverlayFiles","");    
00262   r.Set("UserTimesFile","");   
00263 
00264   r.Set("FavorRawDataTime",1); 
00265   r.Set("InjectCrateT0",1);    
00266 
00267   r.Set("ProcessMinervaMC",0); 
00268   r.Set("VerboseFlags",3);     
00269 
00270 
00271 
00272 
00273   //r.LockValues();
00274 
00275   return r;
00276 }

void EvtInfoInjectorModule::EndJob (  )  [virtual]

Implement for notification of end of job

Reimplemented from JobCModule.

Definition at line 132 of file EvtInfoInjectorModule.cxx.

References Msg::kInfo, and MSG.

00133 {
00134 
00135   MSG("Overlay",Msg::kInfo)
00136     << "EvtInfoInjectorModule Added " << endl;
00137 
00138 }


Member Data Documentation

which time to use

Definition at line 70 of file EvtInfoInjectorModule.h.

Referenced by Ana().

user Raw times rather than User timestamp

Definition at line 66 of file EvtInfoInjectorModule.h.

Referenced by Ana(), and Config().

has a list of .mdaq files been supplied?

Definition at line 64 of file EvtInfoInjectorModule.h.

Referenced by BeginJob().

supply crate t0 times

Definition at line 65 of file EvtInfoInjectorModule.h.

Referenced by Ana(), and BeginJob().

private data

supply timestamps for snarl headers

Definition at line 63 of file EvtInfoInjectorModule.h.

Referenced by Ana(), and BeginJob().

bit0=times, bit1=daqfiles

Definition at line 68 of file EvtInfoInjectorModule.h.

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


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1