|
//____________________________________________________________________ // // // //____________________________________________________________________ // // $Id: BrPassInfo.cxx,v 1.2 2001/11/16 16:49:12 cholm Exp $ // $Author: cholm $ // $Date: 2001/11/16 16:49:12 $ // $Copyright: (C) 2001 BRAHMS Collaboration <brahmlib@rhic.bnl.gov> // #ifndef BRAT_BrPassInfo #include "BrPassInfo.h" #endif #ifndef BRAT_BrException #include "BrException.h" #endif #ifndef __IOSTREAM__ #include <iostream> #endif #ifndef __IOMANIP__ #include <iomanip> #endif //____________________________________________________________________ ClassImp(BrPassInfo); //____________________________________________________________________ BrPassInfo::BrPassInfo() { // Default constructor fAccessMode = kWrite; fPass = 0; fInputFiles = new TObjArray; fOutputFiles = new TObjArray; fPassDb = BrPassDb::Instance(); } //____________________________________________________________________ BrPassInfo::~BrPassInfo() { // Remove old entries fInputFiles->Delete(); fOutputFiles->Delete(); delete fInputFiles; delete fOutputFiles; delete fPass; } //____________________________________________________________________ void BrPassInfo::Init() { // Nothing fInitialized = kTRUE; Start(); } //____________________________________________________________________ void BrPassInfo::SetDatabase(BrPassDb* db) { if(fInitialized) throw new BrWarning("SetDatabase","Not allowed after Init()"); fPassDb = db; } //____________________________________________________________________ void BrPassInfo::AddInputFile(const Char_t* filename, Int_t runno) { if (fAccessMode == kRead) { Error("AddInputFile", "not allowed in read mode"); return; } fInputFiles->Add(new BrDbInputFile(filename, runno, -1)); } //____________________________________________________________________ void BrPassInfo::AddOutputFile(const Char_t* filename, Int_t runno) { if (fAccessMode == kRead) { Error("AddOutputFile", "not allowed in read mode"); return; } fOutputFiles->Add(new BrDbOutputFile(filename, runno, -1)); } //____________________________________________________________________ void BrPassInfo::Print(Option_t* option) const { // Print information on this pass; // B Basic information // I Input files // O Output files if (!fPass) return; TString opt(option); opt.ToLower(); cout << "Pass information for pass "" << fPass->GetName() << """ << endl << "-------------------------------------" << endl; if (opt.Contains("b")) { cout << " Run #: " << fPass->GetRunNo() << endl << " Revision: " << fPass->GetRevisionId() << endl; TDatime s, e; #if ROOT_VERSION_CODE >= ROOT_VERSION(3,01,0) s.Set(fPass->GetStartTime()); e.Set(fPass->GetEndTime()); #endif cout << " Start: " << s.AsString() << endl << " End: " << s.AsString() << endl; } if (opt.Contains("i")) { cout << " Input files: " << endl << " ------------------------------------" << endl; TIter next(fInputFiles); BrDbInputFile* i = 0; Int_t no = 0; while ((i = (BrDbInputFile*)next())) cout << setw(4) << no++ << " " << i->GetFileName() << endl; } if (opt.Contains("o")) { cout << " Output files: " << endl << " ------------------------------------" << endl; TIter next(fOutputFiles); BrDbInputFile* o = 0; Int_t no = 0; while ((o = (BrDbInputFile*)next())) cout << setw(4) << no++ << " " << o->GetFileName() << endl; } } //____________________________________________________________________ void BrPassInfo::Update(const Char_t* name, Int_t runNo) { // Update structure for run given by run number if (fAccessMode == kWrite) { Error("Update", "not allowed in write mode"); return; } if(!fInitialized) { Warning("Update","Not allowed before Init()"); throw new BrWarning("Update","Not allowed before Init()"); } // Remove old entries delete fPass; fInputFiles->Delete(); fOutputFiles->Delete(); // Get the new pass. fPass = fPassDb->GetPass(name, runNo); fInputFiles = fPassDb->GetXInputFile(fPass->GetDBID()); fOutputFiles = fPassDb->GetXOutputFile(fPass->GetDBID()); } //____________________________________________________________________ void BrPassInfo::Commit(const Char_t* name, Int_t runNo) { // if (fAccessMode == kRead) { Error("Commit", "not allowed in read mode"); return; } delete fPass; fPass = new BrDbPass(name, runNo); fPass->SetStartTime(fStart.Convert()); TDatime n; fPass->SetEndTime(n.Convert()); fPassDb->AddPass(fPass); // Commit the input files to the database TIter nextI(fInputFiles); BrDbInputFile* i = 0; while ((i = (BrDbInputFile*)nextI())) { // Get the reference ID i->SetPassId(fPass->GetDBID()); // Make sure the runnumber is set if (i->GetRunNo() < 0) i->SetRunNo(fPass->GetRunNo()); fPassDb->AddInputFile(i); } // Commit the output files to the database TIter nextO(fOutputFiles); BrDbOutputFile* o = 0; while ((o = (BrDbOutputFile*)nextO())) { // Get the reference ID o->SetPassId(fPass->GetDBID()); // Make sure the runnumber is set if (o->GetRunNo() < 0) o->SetRunNo(fPass->GetRunNo()); fPassDb->AddOutputFile(o); } // Remove old entries fInputFiles->Delete(); fOutputFiles->Delete(); } //____________________________________________________________________ // // EOF // |
||||||
This page automatically generated by script docBrat by Christian Holm |
Copyright ; 2002 BRAHMS Collaboration
<brahmlib@rcf.rhic.bnl.gov>
|