//*-- Author :    Damir Buskulic   30/04/02

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// Frame file direct info data base                                     //
//                                                                      //
// File Info database for simple files                                  //
// Uses the standard Framelib                                           //
// the TOC of a set of frame files is considered as an info database    //
// This allows to treat the same way a small set of frame files         //
// and a set of frame files managed by a metadb or a BKDB               //
//                                                                      //
//////////////////////////////////////////////////////////////////////////


#include <iostream.h>
#include "VFileDirectDB.h"

ClassImp(VFileDirectDB)

//______________________________________________________________________________
VFileDirectDB::VFileDirectDB() : VVirtualFrameInfoDB()
{
//
// direct frame file info data base constructor
//
   mFrameFileName = "";
   mFrameFile = 0;
   mIsOpened = kFALSE;
   mPathToDB = "";
}

//______________________________________________________________________________
VFileDirectDB::VFileDirectDB(char* filenames, Option_t* mode,char* frfilenames, Option_t* option)
           : VVirtualFrameInfoDB()
{
// Local frame data base constructor
// filenames are the names of frame files separated by blanks.
// The mode is irrelevant for this type of frame info db
//

   mFrameFileName = "";
   mFrameFile = 0;
   mIsOpened = kFALSE;
   mPathToDB = "";

   Open(filenames, mode);
}

//______________________________________________________________________________
VFileDirectDB::~VFileDirectDB()
{
//
// Local frame data base destructor
//

   Close();
}

//______________________________________________________________________________
 Bool_t VFileDirectDB::Open(char* filenames, Option_t* openopt)
{
// Open the frame files "filenames" considered as an info database
   
   mFrameFile = FrFileINew(filenames);
   if (!mFrameFile) return 0;
   mIsOpened = kTRUE;
   mFrameFileName = filenames;
   mPathToDB = "";
   return 1;
}

//______________________________________________________________________________
 void VFileDirectDB::Close()
{
// Closes this metadb
   FrFileIEnd(mFrameFile);
   mIsOpened = kFALSE;
}

//______________________________________________________________________________
 Double_t VFileDirectDB::GetStart()
{
// Returns the start time of the first frame in the files
   return FrFileITStart(mFrameFile);
}

//______________________________________________________________________________
 Double_t VFileDirectDB::GetEnd()
{
// Returns the end time of the last frame in the metadatabase
   return FrFileITEnd(mFrameFile);
}

//______________________________________________________________________________
 void VFileDirectDB::Print(Option_t* opt)
{
// Prints information about the files

   FrFileIDump(mFrameFile,stdout,3,"");
}

//______________________________________________________________________________
 void VFileDirectDB::GetMetaData(VMetaData* meta, Double_t gpstime)
{
// Retrieve the meta data corresponding to time
   
   int index;
   
   if (!mIsOpened) {
      Warning("GetMetaData","Data base not opened");
      meta->Clear();
      return;
   }
      
   if (gpstime<GetStart()) gpstime = GetStart();
   index = FrTOCFrameFindT(mFrameFile, gpstime);
   if (index<0) {
      meta->Clear();
      return;
   }
   FrTOC* filetoc = mFrameFile->toc;

// ---- Get the metadata and transfer it to VMetaData object ----
   
   meta->SetRun(filetoc->runs[index]);
   meta->SetFrame(filetoc->frame[index]);
   VGPSTime gpsti(filetoc->GTimeS[index],filetoc->GTimeN[index]);
   meta->SetStartTime(gpsti);
   meta->SetLocalStartTime(0);
   meta->SetLength(filetoc->dt[index]);
   meta->SetQuality(1);
   meta->SetTrigger(1);
   meta->SetFileName(mFrameFile->current->fileName);
   meta->SetDetector("");
   meta->SetState("L");
   
   return;
}

//______________________________________________________________________________
 void VFileDirectDB::NextMetaData(VMetaData* meta)
{
// Retrieve the next meta data

   if (!mIsOpened) {
      Warning("NextMetaData","Data base not opened");
      meta->Clear();
      return;
   }
      
   NextMetaData(meta,meta->GetEndTime()+1e-4);
   return;
}

//______________________________________________________________________________
 void VFileDirectDB::PreviousMetaData(VMetaData* meta)
{
// Retrieve the previous meta data

   if (!mIsOpened) {
      Warning("PreviousMetaData","Data base not opened");
      meta->Clear();
      return;
   }
// A CORRIGER !
   NextMetaData(meta,meta->GetStartTime().GetTimeD()-1e-4);
   return;
}

//______________________________________________________________________________
 void VFileDirectDB::NextMetaData(VMetaData* meta, VConditionSet* condset0)
{
// Retrieve the next meta data with condition set

   NextMetaData(meta);
   return;
}

//______________________________________________________________________________
 void VFileDirectDB::NextMetaData(VMetaData* meta, Double_t time, VConditionSet* condset0)
{
// Retrieve the next meta data after time "time" with condition set condset

   NextMetaData(meta,time);
   return;
}

//______________________________________________________________________________
 void VFileDirectDB::NextMetaData(VMetaData* meta, Double_t gpstime, VConditionFormula* condf)
{
// Retrieve the next meta data with time greater or equal to "time"
// selection condition is not taken into account in direct frame access
   
   
   int index;
   
   if (!mIsOpened) {
      Warning("GetNextMetaData","Data base not opened");
      meta->Clear();
      return;
   }
   
   if (gpstime<GetStart()) gpstime = GetStart();
   index = FrTOCFrameFindT(mFrameFile, gpstime);
   if (index<0) {
      meta->Clear();
      return;
   }
   FrTOC* filetoc = mFrameFile->toc;

// ---- Get the metadata and transfer it to VMetaData object ----
   
   meta->SetRun(filetoc->runs[index]);
   meta->SetFrame(filetoc->frame[index]);
   VGPSTime gpsti(filetoc->GTimeS[index],filetoc->GTimeN[index]);
   meta->SetStartTime(gpsti);
   meta->SetLocalStartTime(0);
   meta->SetLength(filetoc->dt[index]);
   meta->SetQuality(1);
   meta->SetTrigger(1);
   meta->SetFileName(mFrameFile->current->fileName);
   meta->SetDetector("");
   meta->SetState("L");

   return;
}

//______________________________________________________________________________
 void VFileDirectDB::NextMetaData(VMetaData* meta, Double_t gpstime, const char* selection)
{
// Retrieve the next meta data with time greater or equal to "time"
// and selection condition
   VConditionFormula* condf;
   
   if (!selection) {
      NextMetaData(meta, gpstime, (VConditionFormula*)0);
      return;
   }
   
   condf = new VConditionFormula("condf",selection,this);
   NextMetaData(meta,gpstime,condf);
   delete condf;
   return;
}


- ROOT page - VEGA page - Class index - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to , or contact with any questions or problems regarding ROOT or VEGA.