1 // @(#)alimdc:$Name$:$Id$
2 // Author: Fons Rademakers 26/11/99
4 /**************************************************************************
5 * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
7 * Author: The ALICE Off-line Project. *
8 * Contributors are mentioned in the code where appropriate. *
10 * Permission to use, copy, modify and distribute this software and its *
11 * documentation strictly for non-commercial purposes is hereby granted *
12 * without fee, provided that the above copyright notice appears in all *
13 * copies and that both the copyright notice and this permission notice *
14 * appear in the supporting documentation. The authors make no claims *
15 * about the suitability of this software for any purpose. It is *
16 * provided "as is" without express or implied warranty. *
17 **************************************************************************/
19 //////////////////////////////////////////////////////////////////////////
23 //////////////////////////////////////////////////////////////////////////
35 //______________________________________________________________________________
36 AliTagDB::AliTagDB(AliRawEventHeader *header, Double_t maxsize, Bool_t create)
49 //______________________________________________________________________________
50 AliTagDB::AliTagDB(const AliTagDB& tagDB): TObject(tagDB)
54 Fatal("AliTagDB", "copy constructor not implemented");
57 //______________________________________________________________________________
58 AliTagDB& AliTagDB::operator = (const AliTagDB& /*tagDB*/)
60 // assignment operator
62 Fatal("operator =", "assignment operator not implemented");
66 //______________________________________________________________________________
67 Bool_t AliTagDB::Create()
69 // Create a new tag DB.
71 fTagDB = new TFile(GetFileName(), "RECREATE",
72 Form("ALICE MDC%d tag DB", AliMDC::kMDC), 1);
73 if (fTagDB->IsZombie()) {
74 Error("Create", "error opening tag DB");
79 // Create ROOT Tree object container
80 fTree = new TTree("TAG", Form("ALICE MDC%d header data tree", AliMDC::kMDC));
81 fTree->SetAutoSave(100000000); // autosave when 100 Mbyte written
83 Int_t bufsize = 32000;
85 fTree->Branch("header", "AliRawEventHeader", &fHeader, bufsize, split);
90 //______________________________________________________________________________
91 void AliTagDB::Close()
102 // Close DB, this also deletes the fTree
105 if (AliMDC::DeleteFiles())
106 gSystem->Unlink(fTagDB->GetName());
112 //______________________________________________________________________________
113 Bool_t AliTagDB::NextFile()
115 // Close te current file and open a new one.
116 // Returns kFALSE in case opening failed.
120 if (!Create()) return kFALSE;
124 //______________________________________________________________________________
125 Float_t AliTagDB::GetCompressionFactor() const
127 // Return compression factor.
129 if (fTree->GetZipBytes() == 0.)
132 return fTree->GetTotBytes()/fTree->GetZipBytes();
135 //______________________________________________________________________________
136 const char *AliTagDB::GetFileName() const
138 // Return filename based on hostname and date and time. This will make
139 // each file unique. The tags will be stored in the /data1/tags directory.
141 static char fname[64];
142 const char *fs = AliMDC::TagDBFS();
144 // check that fs exists (crude check fails if fs is a file)
145 gSystem->MakeDirectory(fs);
149 strcpy(hostname, gSystem->HostName());
152 if ((s = strchr(hostname, '.')))
157 sprintf(fname, "%s/%s_%d_%d.root", fs, hostname, dt.GetDate(), dt.GetTime());