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 //////////////////////////////////////////////////////////////////////////
32 #include "AliRawEventHeaderBase.h"
39 //______________________________________________________________________________
40 AliTagDB::AliTagDB(AliRawEventHeaderBase *header, const char* fileName) :
51 if (!Create(fileName))
56 //______________________________________________________________________________
57 Bool_t AliTagDB::Create(const char* fileName)
59 // Create a new tag DB.
61 const char *name = fileName;
62 if (!name) name = GetFileName();
63 fTagDB = new TFile(name, "RECREATE",
64 Form("ALICE tag DB (%s)", AliRawDB::GetAliRootTag()), 1);
65 if (fTagDB->IsZombie()) {
66 Error("Create", "error opening tag DB");
70 // Put wide read-write permissions
71 if(gSystem->Chmod(name,438)) {
72 Error("Create", "can't set permissions for tag DB file");
77 // Create ROOT Tree object container
78 fTree = new TTree("TAG", Form("ALICE header data tree (%s)", AliRawDB::GetAliRootTag()));
79 fTree->SetAutoSave(100000000); // autosave when 100 Mbyte written
81 Int_t bufsize = 32000;
83 const char *headername = fHeader->GetName();
84 fTree->Branch("header", headername, &fHeader, bufsize, split);
89 //______________________________________________________________________________
90 void AliTagDB::Close()
101 // Close DB, this also deletes the fTree
105 gSystem->Unlink(fTagDB->GetName());
111 //______________________________________________________________________________
112 Bool_t AliTagDB::NextFile(const char* fileName)
114 // Close te current file and open a new one.
115 // Returns kFALSE in case opening failed.
119 if (!Create(fileName)) return kFALSE;
123 //______________________________________________________________________________
124 void AliTagDB::SetFS(const char* fs)
126 // set the file system location
130 gSystem->ResetErrno();
131 gSystem->MakeDirectory(fs);
132 if (gSystem->GetErrno() && gSystem->GetErrno() != EEXIST) {
133 SysError("SetFS", "mkdir %s", fs);
138 //______________________________________________________________________________
139 Float_t AliTagDB::GetCompressionFactor() const
141 // Return compression factor.
143 if (fTree->GetZipBytes() == 0.)
146 return fTree->GetTotBytes()/fTree->GetZipBytes();
149 //______________________________________________________________________________
150 const char *AliTagDB::GetFileName() const
152 // Return filename based on hostname and date and time. This will make
153 // each file unique. The tags will be stored in the /data1/tags directory.
155 static char fname[64];
156 const char *fs = fFS;
158 // check that fs exists (crude check fails if fs is a file)
159 gSystem->MakeDirectory(fs);
163 strcpy(hostname, gSystem->HostName());
166 if ((s = strchr(hostname, '.')))
171 sprintf(fname, "%s/%s_%d_%d.root", fs, hostname, dt.GetDate(), dt.GetTime());