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 //////////////////////////////////////////////////////////////////////////
28 #include "AliRawRFIODB.h"
31 ClassImp(AliRawRFIODB)
34 //______________________________________________________________________________
35 AliRawRFIODB::AliRawRFIODB(AliRawEvent *event,
39 : AliRawDB(event, esd, compress, fileName)
41 // Create a new raw DB that will be accessed via RFIO.
44 // Set STAGE_POOL environment variable to current host
46 // THESE ENVIRONMENT SYMBOLS ARE NOW DEFINED BY THE ALICE DATE SETUP
47 // THEREFORE WE SHALL NOT USE ANY HARDCODED VALUES BUT RATHER USE
48 // WHATEVER HAS BEEN SET IN THE DATE SITE
49 //gSystem->Setenv("STAGE_POOL", "lcg00");
50 //gSystem->Setenv("STAGE_HOST", "stage013");
52 // however for sanity we check if they are really set
53 if (!gSystem->Getenv("STAGE_POOL"))
54 Error("AliRawRFIODB", "STAGE_POOL not set");
55 if (!gSystem->Getenv("STAGE_HOST"))
56 Error("AliRawRFIODB", "STAGE_HOST not set");
60 if (fRawDB) fRawDB->UseCache(50, 0x200000); //0x100000 = 1MB)
63 //______________________________________________________________________________
64 const char *AliRawRFIODB::GetFileName() const
66 // Return filename based on hostname and date and time. This will make
67 // each file unique. Also the directory will be made unique for each
68 // day by adding the date to the fs. Assumes there is always enough
69 // space on the device.
76 // make a new subdirectory for each day
80 Long_t id, size, flags, time;
81 if (gSystem->GetPathInfo(fs, &id, &size, &flags, &time) == 1) {
82 // directory does not exist, create it
83 if (gSystem->mkdir(fs, kTRUE) == -1) {
84 Error("GetFileName", "cannot create dir %s, using %s", fs.Data(),
89 // FIXME: should check if fs is a directory
91 TString hostname = gSystem->HostName();
93 if ((pos = hostname.Index(".")) != kNPOS)
96 fname = fs + "/" + hostname + "_";
97 fname += dt.GetDate();
99 fname += dt.GetTime();
105 //______________________________________________________________________________
106 Long64_t AliRawRFIODB::Close()
108 // Close raw RFIO DB.
110 if (!fRawDB) return 0;
112 if (!fRawDB->IsOpen()) return 0;
117 Bool_t error = kFALSE;
118 if (fTree->Write() == 0)
121 if (fESDTree->Write() == 0)
124 // Close DB, this also deletes the fTree
127 Long64_t filesize = fRawDB->GetEND();
130 TUrl u(fRawDB->GetName());
131 gSystem->Exec(Form("rfrm %s", u.GetFile()));