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

SpillTimeCreateKeyFile.cxx

Go to the documentation of this file.
00001 #include "SpillTimeCreateKeyFile.h"
00002 #include "SpillTimeRecord.h"
00003 #include "MessageService/MsgService.h"
00004 #include "Persistency/Per.h"
00005 #include "Persistency/PerOutputStreamManager.h"
00006 #include "Persistency/PerOutputStream.h"
00007 #include "MinosObjectMap/MomNavigator.h"
00008 #include "Conventions/Munits.h"
00009 
00010 CVSID(" $Id: SpillTimeCreateKeyFile.cxx,v 1.1 2005/05/20 17:46:32 tagg Exp $ ");
00011 
00012 int SpillTimeCreateKeyFile(
00013                                    const char* filename,
00014                                    int task,
00015                                    VldTimeStamp start,
00016                                    VldTimeStamp stop  
00017                                    )
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 Mon Feb 15 11:07:38 2010 for loon by  doxygen 1.3.9.1