]>
Commit | Line | Data |
---|---|---|
a197a4ce | 1 | // @(#)alimdc:$Name$:$Id$ |
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 | ||
27 | #include "AliMDC.h" | |
28 | ||
29 | #include "AliRawRootdDB.h" | |
30 | ||
31 | ||
32 | ClassImp(AliRawRootdDB) | |
33 | ||
34 | ||
35 | //______________________________________________________________________________ | |
a109e73e | 36 | AliRawRootdDB::AliRawRootdDB(AliRawEvent *event, |
37 | #ifdef USE_HLT | |
38 | AliESD *esd, | |
39 | #endif | |
40 | Double_t maxsize, Int_t compress) | |
41 | : AliRawDB(event, | |
42 | #ifdef USE_HLT | |
43 | esd, | |
44 | #endif | |
45 | maxsize, compress, kFALSE) | |
a197a4ce | 46 | { |
47 | // Create a new raw DB that will be accessed via rootd daemon. | |
48 | ||
49 | if (!Create()) | |
50 | MakeZombie(); | |
51 | else | |
52 | fRawDB->UseCache(50, 0x200000); //0x100000 = 1MB) | |
53 | } | |
54 | ||
55 | //______________________________________________________________________________ | |
56 | const char *AliRawRootdDB::GetFileName() const | |
57 | { | |
58 | // Return filename based on hostname and date and time. This will make | |
59 | // each file unique. Also the directory will be made unique for each | |
60 | // day by adding the date to the fs. Assumes there is always enough | |
61 | // space on the device. | |
62 | ||
63 | static TString fname; | |
64 | ||
65 | TString fs = AliMDC::RootdFS(); | |
66 | TDatime dt; | |
67 | ||
68 | #if 0 | |
69 | // make a new subdirectory for each day | |
70 | fs += "/adc-"; | |
71 | fs += dt.GetDate(); | |
72 | ||
73 | Long_t id, size, flags, time; | |
74 | if (gSystem->GetPathInfo(fs, &id, &size, &flags, &time) == 1) { | |
75 | // directory does not exist, create it | |
76 | if (gSystem->mkdir(fs, kTRUE) == -1) { | |
77 | Error("GetFileName", "cannot create dir %s, using %s", fs.Data(), | |
78 | AliMDC::RootdFS()); | |
79 | fs = AliMDC::RootdFS(); | |
80 | } | |
81 | } | |
82 | // FIXME: should check if fs is a directory | |
83 | #endif | |
84 | ||
85 | TString hostname = gSystem->HostName(); | |
86 | Int_t pos; | |
87 | if ((pos = hostname.Index(".")) != kNPOS) | |
88 | hostname.Remove(pos); | |
89 | ||
90 | fname = fs + "/" + hostname + "_"; | |
91 | fname += dt.GetDate(); | |
92 | fname += "_"; | |
93 | fname += dt.GetTime(); | |
94 | fname += ".root"; | |
95 | ||
96 | return fname; | |
97 | } | |
98 | ||
99 | //______________________________________________________________________________ | |
100 | void AliRawRootdDB::Close() | |
101 | { | |
102 | // Close raw rootd DB. | |
103 | ||
104 | if (!fRawDB) return; | |
105 | ||
106 | fRawDB->cd(); | |
107 | ||
108 | // Write the tree. | |
109 | fTree->Write(); | |
110 | ||
111 | // Close DB, this also deletes the fTree | |
112 | fRawDB->Close(); | |
113 | ||
114 | #if 0 | |
115 | // can use services of TFTP | |
116 | if (AliMDC::DeleteFiles()) | |
117 | gSystem->Exec(Form("rfrm %s", fRawDB->GetName())); | |
118 | #endif | |
119 | ||
120 | delete fRawDB; | |
121 | fRawDB = 0; | |
122 | } |