]>
Commit | Line | Data |
---|---|---|
d04aea32 | 1 | // @(#) $Id$ |
a197a4ce | 2 | // Author: Fons Rademakers 26/11/99 |
3 | ||
4 | /************************************************************************** | |
5 | * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. * | |
6 | * * | |
7 | * Author: The ALICE Off-line Project. * | |
8 | * Contributors are mentioned in the code where appropriate. * | |
9 | * * | |
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 | **************************************************************************/ | |
18 | ||
19 | ////////////////////////////////////////////////////////////////////////// | |
20 | // // | |
21 | // AliRawRootdDB // | |
22 | // // | |
23 | ////////////////////////////////////////////////////////////////////////// | |
24 | ||
25 | #include <TSystem.h> | |
26 | ||
a197a4ce | 27 | #include "AliRawRootdDB.h" |
28 | ||
29 | ||
30 | ClassImp(AliRawRootdDB) | |
31 | ||
32 | ||
33 | //______________________________________________________________________________ | |
33314186 | 34 | AliRawRootdDB::AliRawRootdDB(AliRawEventV2 *event, |
af885e0f | 35 | AliESDEvent *esd, |
e10815f1 | 36 | Int_t compress, |
8ec37122 | 37 | const char* fileName,Int_t basketsize) |
38 | : AliRawDB(event, esd, compress, fileName, basketsize) | |
a197a4ce | 39 | { |
40 | // Create a new raw DB that will be accessed via rootd daemon. | |
41 | ||
e10815f1 | 42 | if (fRawDB) fRawDB->UseCache(50, 0x200000); //0x100000 = 1MB) |
a197a4ce | 43 | } |
44 | ||
45 | //______________________________________________________________________________ | |
46 | const char *AliRawRootdDB::GetFileName() const | |
47 | { | |
48 | // Return filename based on hostname and date and time. This will make | |
49 | // each file unique. Also the directory will be made unique for each | |
50 | // day by adding the date to the fs. Assumes there is always enough | |
51 | // space on the device. | |
52 | ||
53 | static TString fname; | |
54 | ||
e10815f1 | 55 | TString fs = fFS1; |
a197a4ce | 56 | TDatime dt; |
57 | ||
58 | #if 0 | |
59 | // make a new subdirectory for each day | |
60 | fs += "/adc-"; | |
61 | fs += dt.GetDate(); | |
62 | ||
63 | Long_t id, size, flags, time; | |
64 | if (gSystem->GetPathInfo(fs, &id, &size, &flags, &time) == 1) { | |
65 | // directory does not exist, create it | |
66 | if (gSystem->mkdir(fs, kTRUE) == -1) { | |
67 | Error("GetFileName", "cannot create dir %s, using %s", fs.Data(), | |
e10815f1 | 68 | fFS1.Data()); |
69 | fs = fFS1; | |
a197a4ce | 70 | } |
71 | } | |
72 | // FIXME: should check if fs is a directory | |
73 | #endif | |
74 | ||
75 | TString hostname = gSystem->HostName(); | |
76 | Int_t pos; | |
77 | if ((pos = hostname.Index(".")) != kNPOS) | |
78 | hostname.Remove(pos); | |
79 | ||
80 | fname = fs + "/" + hostname + "_"; | |
81 | fname += dt.GetDate(); | |
82 | fname += "_"; | |
83 | fname += dt.GetTime(); | |
84 | fname += ".root"; | |
85 | ||
86 | return fname; | |
87 | } | |
88 | ||
89 | //______________________________________________________________________________ | |
d2450633 | 90 | Long64_t AliRawRootdDB::Close() |
a197a4ce | 91 | { |
92 | // Close raw rootd DB. | |
93 | ||
f07ec911 | 94 | if (!fRawDB) return 0; |
95 | ||
96 | if (!fRawDB->IsOpen()) return 0; | |
a197a4ce | 97 | |
98 | fRawDB->cd(); | |
99 | ||
100 | // Write the tree. | |
f07ec911 | 101 | Bool_t error = kFALSE; |
33314186 | 102 | if (fTree) |
103 | if (fTree->Write() == 0) | |
104 | error = kTRUE; | |
f07ec911 | 105 | if (fESDTree) |
106 | if (fESDTree->Write() == 0) | |
107 | error = kTRUE; | |
a197a4ce | 108 | |
109 | // Close DB, this also deletes the fTree | |
110 | fRawDB->Close(); | |
111 | ||
33314186 | 112 | fTree = NULL; |
113 | ||
d2450633 | 114 | Long64_t filesize = fRawDB->GetEND(); |
f07ec911 | 115 | |
a197a4ce | 116 | #if 0 |
117 | // can use services of TFTP | |
e10815f1 | 118 | if (fDeleteFiles) |
a197a4ce | 119 | gSystem->Exec(Form("rfrm %s", fRawDB->GetName())); |
120 | #endif | |
121 | ||
122 | delete fRawDB; | |
123 | fRawDB = 0; | |
f07ec911 | 124 | if(!error) |
125 | return filesize; | |
126 | else | |
127 | return -1; | |
a197a4ce | 128 | } |