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 //////////////////////////////////////////////////////////////////////////
37 //______________________________________________________________________________
38 AliTagDB::AliTagDB(AliRawEventHeader *header, const char* fileName) :
49 if (!Create(fileName))
54 //______________________________________________________________________________
55 AliTagDB::AliTagDB(const AliTagDB& tagDB): TObject(tagDB)
59 Fatal("AliTagDB", "copy constructor not implemented");
62 //______________________________________________________________________________
63 AliTagDB& AliTagDB::operator = (const AliTagDB& /*tagDB*/)
65 // assignment operator
67 Fatal("operator =", "assignment operator not implemented");
71 //______________________________________________________________________________
72 Bool_t AliTagDB::Create(const char* fileName)
74 // Create a new tag DB.
76 const char *name = fileName;
77 if (!name) name = GetFileName();
78 fTagDB = new TFile(name, "RECREATE",
79 Form("ALICE MDC%d tag DB", AliRawDB::kMDC), 1);
80 if (fTagDB->IsZombie()) {
81 Error("Create", "error opening tag DB");
86 // Create ROOT Tree object container
87 fTree = new TTree("TAG", Form("ALICE MDC%d header data tree", AliRawDB::kMDC));
88 fTree->SetAutoSave(100000000); // autosave when 100 Mbyte written
90 Int_t bufsize = 32000;
92 fTree->Branch("header", "AliRawEventHeader", &fHeader, bufsize, split);
97 //______________________________________________________________________________
98 void AliTagDB::Close()
109 // Close DB, this also deletes the fTree
113 gSystem->Unlink(fTagDB->GetName());
119 //______________________________________________________________________________
120 Bool_t AliTagDB::NextFile(const char* fileName)
122 // Close te current file and open a new one.
123 // Returns kFALSE in case opening failed.
127 if (!Create(fileName)) return kFALSE;
131 //______________________________________________________________________________
132 void AliTagDB::SetFS(const char* fs)
134 // set the file system location
138 gSystem->ResetErrno();
139 gSystem->MakeDirectory(fs);
140 if (gSystem->GetErrno() && gSystem->GetErrno() != EEXIST) {
141 SysError("SetFS", "mkdir %s", fs);
146 //______________________________________________________________________________
147 Float_t AliTagDB::GetCompressionFactor() const
149 // Return compression factor.
151 if (fTree->GetZipBytes() == 0.)
154 return fTree->GetTotBytes()/fTree->GetZipBytes();
157 //______________________________________________________________________________
158 const char *AliTagDB::GetFileName() const
160 // Return filename based on hostname and date and time. This will make
161 // each file unique. The tags will be stored in the /data1/tags directory.
163 static char fname[64];
164 const char *fs = fFS;
166 // check that fs exists (crude check fails if fs is a file)
167 gSystem->MakeDirectory(fs);
171 strcpy(hostname, gSystem->HostName());
174 if ((s = strchr(hostname, '.')))
179 sprintf(fname, "%s/%s_%d_%d.root", fs, hostname, dt.GetDate(), dt.GetTime());