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 "AliRawEventHeader.h"
39 //______________________________________________________________________________
40 AliTagDB::AliTagDB(AliRawEventHeader *header, const char* fileName) :
51 if (!Create(fileName))
56 //______________________________________________________________________________
57 AliTagDB::AliTagDB(const AliTagDB& tagDB): TObject(tagDB)
61 Fatal("AliTagDB", "copy constructor not implemented");
64 //______________________________________________________________________________
65 AliTagDB& AliTagDB::operator = (const AliTagDB& /*tagDB*/)
67 // assignment operator
69 Fatal("operator =", "assignment operator not implemented");
73 //______________________________________________________________________________
74 Bool_t AliTagDB::Create(const char* fileName)
76 // Create a new tag DB.
78 const char *name = fileName;
79 if (!name) name = GetFileName();
80 fTagDB = new TFile(name, "RECREATE",
81 Form("ALICE MDC%d tag DB", AliRawDB::kMDC), 1);
82 if (fTagDB->IsZombie()) {
83 Error("Create", "error opening tag DB");
88 // Create ROOT Tree object container
89 fTree = new TTree("TAG", Form("ALICE MDC%d header data tree", AliRawDB::kMDC));
90 fTree->SetAutoSave(100000000); // autosave when 100 Mbyte written
92 Int_t bufsize = 32000;
94 fTree->Branch("header", "AliRawEventHeader", &fHeader, bufsize, split);
99 //______________________________________________________________________________
100 void AliTagDB::Close()
111 // Close DB, this also deletes the fTree
115 gSystem->Unlink(fTagDB->GetName());
121 //______________________________________________________________________________
122 Bool_t AliTagDB::NextFile(const char* fileName)
124 // Close te current file and open a new one.
125 // Returns kFALSE in case opening failed.
129 if (!Create(fileName)) return kFALSE;
133 //______________________________________________________________________________
134 void AliTagDB::SetFS(const char* fs)
136 // set the file system location
140 gSystem->ResetErrno();
141 gSystem->MakeDirectory(fs);
142 if (gSystem->GetErrno() && gSystem->GetErrno() != EEXIST) {
143 SysError("SetFS", "mkdir %s", fs);
148 //______________________________________________________________________________
149 Float_t AliTagDB::GetCompressionFactor() const
151 // Return compression factor.
153 if (fTree->GetZipBytes() == 0.)
156 return fTree->GetTotBytes()/fTree->GetZipBytes();
159 //______________________________________________________________________________
160 const char *AliTagDB::GetFileName() const
162 // Return filename based on hostname and date and time. This will make
163 // each file unique. The tags will be stored in the /data1/tags directory.
165 static char fname[64];
166 const char *fs = fFS;
168 // check that fs exists (crude check fails if fs is a file)
169 gSystem->MakeDirectory(fs);
173 strcpy(hostname, gSystem->HostName());
176 if ((s = strchr(hostname, '.')))
181 sprintf(fname, "%s/%s_%d_%d.root", fs, hostname, dt.GetDate(), dt.GetTime());