]>
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 | // AliStats // | |
22 | // // | |
23 | ////////////////////////////////////////////////////////////////////////// | |
24 | ||
25 | #include <TH1.h> | |
26 | #include <TFile.h> | |
27 | ||
28 | #include "AliRawEvent.h" | |
29 | #include "AliRawEventHeader.h" | |
30 | #include "AliRawDB.h" | |
31 | #include "AliRunDB.h" | |
32 | ||
33 | #include "AliStats.h" | |
34 | ||
35 | ||
36 | ClassImp(AliStats) | |
37 | ||
38 | ||
39 | //______________________________________________________________________________ | |
40 | AliStats::AliStats(const char *filename, Int_t compmode, Bool_t filter) | |
41 | { | |
42 | // Create statistics object. | |
43 | ||
44 | fEvents = 0; | |
45 | fFirstRun = 0; | |
46 | fFirstEvent = 0; | |
47 | fLastRun = 0; | |
48 | fLastEvent = 0; | |
49 | fChunk = -0.5; | |
50 | fFileName = filename; | |
51 | fCompMode = compmode; | |
52 | fFilter = filter; | |
53 | fRTHist = 0; | |
54 | } | |
55 | ||
56 | //______________________________________________________________________________ | |
57 | AliStats::AliStats(const AliStats &rhs): TObject(rhs) | |
58 | { | |
59 | // AliStats copy constructor. | |
60 | ||
61 | operator=(rhs); | |
62 | } | |
63 | ||
64 | //______________________________________________________________________________ | |
65 | AliStats::~AliStats() | |
66 | { | |
67 | // Cleanup stats object. | |
68 | ||
69 | delete fRTHist; | |
70 | } | |
71 | ||
72 | //______________________________________________________________________________ | |
73 | AliStats &AliStats::operator=(const AliStats &rhs) | |
74 | { | |
75 | // AliStats assignment operator. | |
76 | ||
77 | if (this != &rhs) { | |
78 | TObject::operator=(rhs); | |
79 | fEvents = rhs.fEvents; | |
80 | fFirstRun = rhs.fFirstRun; | |
81 | fFirstEvent = rhs.fFirstEvent; | |
82 | fLastRun = rhs.fLastRun; | |
83 | fLastEvent = rhs.fLastEvent; | |
84 | fBegin = rhs.fBegin; | |
85 | fEnd = rhs.fEnd; | |
86 | fFileName = rhs.fFileName; | |
87 | fFileSize = rhs.fFileSize; | |
88 | fCompFactor = rhs.fCompFactor; | |
89 | fCompMode = rhs.fCompMode; | |
90 | fFilter = rhs.fFilter; | |
91 | fRTHist = rhs.fRTHist ? (TH1F*) rhs.fRTHist->Clone() : 0; | |
92 | fChunk = rhs.fChunk; | |
93 | } | |
94 | return *this; | |
95 | } | |
96 | ||
97 | //______________________________________________________________________________ | |
98 | void AliStats::Fill(Float_t time) | |
99 | { | |
100 | // Fill histogram. This histogram shows the (hopefully constant) time | |
101 | // it takes to fill the ROOT DB. | |
102 | // Expects to be called 100 times for each file. | |
103 | ||
104 | if (!fRTHist) { | |
105 | fRTHist = new TH1F("rtime","Real-time to write data chunk", 100, 0, 100); | |
106 | fRTHist->SetDirectory(0); | |
107 | } | |
108 | ||
109 | fRTHist->Fill(fChunk, time); | |
110 | fChunk += 1.0; | |
111 | } | |
112 | ||
113 | //______________________________________________________________________________ | |
114 | void AliStats::WriteToDB(AliRawDB *rawdb) | |
115 | { | |
116 | // Write stats to raw DB, local run DB and global MySQL DB. | |
117 | ||
118 | AliRawEventHeader &header = *rawdb->GetEvent()->GetHeader(); | |
119 | ||
120 | // Write stats into RawDB | |
121 | TDirectory *ds = gDirectory; | |
122 | rawdb->GetDB()->cd(); | |
123 | SetEvents(rawdb->GetEvents()); | |
124 | SetLastId(header.GetRunNumber(), header.GetEventInRun()); | |
125 | SetFileSize(rawdb->GetBytesWritten()); | |
126 | SetCompressionFactor(rawdb->GetCompressionFactor()); | |
127 | SetEndTime(); | |
128 | Write("stats"); | |
129 | ds->cd(); | |
130 | ||
131 | // Write stats also in the bookkeeping RunDB | |
132 | AliRunDB *rundb = new AliRunDB(kTRUE); | |
133 | rundb->Update(this); | |
134 | rundb->UpdateRDBMS(this); | |
135 | rundb->UpdateAliEn(this); | |
136 | delete rundb; | |
137 | } |