]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RAW/AliStats.cxx
memory leak fixed
[u/mrichter/AliRoot.git] / RAW / AliStats.cxx
1 // @(#) $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 "AliStats.h"
29
30
31 ClassImp(AliStats)
32
33
34 //______________________________________________________________________________
35 AliStats::AliStats(const char *filename, Int_t compmode, Bool_t filter):
36 fEvents(0),
37 fRun(0),
38 fFirstEvent(0),
39 fLastEvent(0),
40 fBegin(),
41 fEnd(),
42 fFileName(filename),
43 fFileSize(0),
44 fCompFactor(0),
45 fCompMode(compmode),
46 fFilter(filter),
47 fRTHist(NULL),
48 fChunk(-0.5)
49 {
50    // Create statistics object.
51
52 }
53
54 //______________________________________________________________________________
55 AliStats::AliStats(const AliStats &rhs):
56 TObject(rhs),
57 fEvents(rhs.fEvents),
58 fRun(rhs.fRun),
59 fFirstEvent(rhs.fFirstEvent),
60 fLastEvent(rhs.fLastEvent),
61 fBegin(rhs.fBegin),
62 fEnd(rhs.fEnd),
63 fFileName(rhs.fFileName),
64 fFileSize(rhs.fFileSize),
65 fCompFactor(rhs.fCompFactor),
66 fCompMode(rhs.fCompMode),
67 fFilter(rhs.fFilter),
68 fRTHist(rhs.fRTHist ? (TH1F*) rhs.fRTHist->Clone() : 0),
69 fChunk(rhs.fChunk)
70 {
71   // AliStats copy constructor.
72
73 }
74
75 //______________________________________________________________________________
76 AliStats::~AliStats()
77 {
78    // Cleanup stats object.
79
80    delete fRTHist;
81 }
82
83 //______________________________________________________________________________
84 AliStats &AliStats::operator=(const AliStats &rhs)
85 {
86    // AliStats assignment operator.
87
88    if (this != &rhs) {
89       TObject::operator=(rhs);
90       fEvents     = rhs.fEvents;
91       fRun        = rhs.fRun;
92       fFirstEvent = rhs.fFirstEvent;
93       fLastEvent  = rhs.fLastEvent;
94       fBegin      = rhs.fBegin;
95       fEnd        = rhs.fEnd;
96       fFileName   = rhs.fFileName;
97       fFileSize   = rhs.fFileSize;
98       fCompFactor = rhs.fCompFactor;
99       fCompMode   = rhs.fCompMode;
100       fFilter     = rhs.fFilter;
101       fRTHist     = rhs.fRTHist ? (TH1F*) rhs.fRTHist->Clone() : 0;
102       fChunk      = rhs.fChunk;
103    }
104    return *this;
105 }
106
107 //______________________________________________________________________________
108 void AliStats::Fill(Float_t time)
109 {
110    // Fill histogram. This histogram shows the (hopefully constant) time
111    // it takes to fill the ROOT DB.
112    // Expects to be called 100 times for each file.
113
114    if (!fRTHist) {
115       fRTHist = new TH1F("rtime","Real-time to write data chunk", 100, 0, 100);
116       fRTHist->SetDirectory(0);
117    }
118
119    fRTHist->Fill(fChunk, time);
120    fChunk += 1.0;
121 }