SpillTimeCreateKeyFile.h File Reference

#include "SpillTimeFinder.h"

Go to the source code of this file.

Functions

int SpillTimeCreateKeyFile (const char *filename="SpillTimeKeys.root", int task=SpillTimeND::kTask_TimeGoblin, VldTimeStamp start=VldTimeStamp(1971, 01, 01, 0, 0, 0, 0), VldTimeStamp stop=VldTimeStamp(2010, 12, 12, 0, 0, 0, 0))

Function Documentation

int SpillTimeCreateKeyFile ( const char *  filename = "SpillTimeKeys.root",
int  task = SpillTimeND::kTask_TimeGoblin,
VldTimeStamp  start = VldTimeStamp(1971, 01, 01, 0, 0, 0, 0),
VldTimeStamp  stop = VldTimeStamp(2010, 12, 12, 0, 0, 0, 0) 
)

Function to create a Loon file that contains only some very bare-bones records. These can then be used with the Input Per::kWindow method to read in events around these spills.

Definition at line 12 of file SpillTimeCreateKeyFile.cxx.

References MomNavigator::AdoptFragment(), VldTimeStamp::AsString(), VldContext::AsString(), MomNavigator::Clear(), PerStreamManager::CloseFile(), PerStreamManager::CloseStream(), done(), SpillTimeFinder::GetLastQueryRangeEnd(), VldTimeStamp::GetSec(), SpillTimeFinder::GetTimeOfNextSpill(), VldContext::GetTimeStamp(), header, SimFlag::kData, Msg::kDebug, Msg::kError, Detector::kFar, Msg::kInfo, Per::kRecreate, Per::kRecSplit, MSG, PerOutputStreamManager::OpenStream(), PerOutputStreamManager::Put(), CfgPromptConfigurable::Set(), PerStreamManager::SetFile(), and PerOutputStreamManager::Write().

00018 {
00019   
00020  
00021   PerOutputStreamManager perOutputStreamManager;
00022 
00023   PerOutputStream* outstream =    
00024     perOutputStreamManager.OpenStream("BeamMon","BeamMon",
00025                                       "SpillTimeRecord","","",Per::kRecSplit);
00026   if(!outstream) {
00027     MSG("SpillTime",Msg::kError) << "OpenStream failed!" << endl;
00028     return 1;
00029   }
00030 
00031   bool open_ok = perOutputStreamManager.SetFile("BeamMon",filename,Per::kRecreate);
00032   if(!open_ok) {
00033     MSG("SpillTime",Msg::kError) << "SetFile failed!" << endl;
00034     return 1;
00035   }
00036   
00037   // Start with the first one in VTM table:
00038   SpillTimeFinder stf;
00039   stf.Set("Task",task);
00040   VldTimeStamp ts1 = start;
00041   VldContext context(Detector::kFar,SimFlag::kData,ts1);
00042   MomNavigator mom;
00043  
00044   bool done = false;
00045   do {
00046     // Get the next spill time.
00047     ts1 = stf.GetTimeOfNextSpill(context);
00048 
00049     while(ts1.GetSec()==0) { // Invalid query.
00050       VldTimeStamp jumptime = stf.GetLastQueryRangeEnd();
00051       if(jumptime == context.GetTimeStamp()) {
00052         // That's it.. we're done.
00053         done = true;
00054         break;
00055       }
00056       if(jumptime > stop){
00057         done=true;
00058         break;
00059       }
00060       context = VldContext(Detector::kFar,SimFlag::kData,jumptime);
00061       MSG("SpillTime",Msg::kInfo) << "Found no spills.. skipping to " << context.AsString() << endl;
00062       ts1 = stf.GetTimeOfNextSpill(context);      
00063     }
00064 
00065     if(ts1>stop) done= true;
00066 
00067     if(!done) {
00068 
00069       MSG("SpillTime",Msg::kDebug) << ts1.AsString() << endl;
00070       // Rebuild the context for this.
00071       context = VldContext(Detector::kFar,SimFlag::kData,ts1);
00072       
00073       // Create the record.
00074       mom.Clear();
00075       RecHeader* header = new RecHeader(context);
00076       SpillTimeRecord* record = new SpillTimeRecord(*header);
00077       mom.AdoptFragment(record);
00078       perOutputStreamManager.Put(&mom);
00079 
00080     }
00081   } while(!done); //(ts1 > VldTimeStamp(1990,1,1,0,0,0,0,0)) && (ts1<stop));
00082  
00083   perOutputStreamManager.Write(); // write the trees on all streams to file
00084   perOutputStreamManager.CloseFile(); // close files on all streams
00085   perOutputStreamManager.CloseStream();
00086 
00087   
00088 
00089   return 0;
00090 }


Generated on 22 Nov 2017 for loon by  doxygen 1.6.1