forgot a protection before delete
[u/mrichter/AliRoot.git] / STEER / AliQADataMakerSim.cxx
CommitLineData
04236e67 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16
17/* $Id$ */
18
202374b1 19//
20// Base Class
21// Produces the data needed to calculate the quality assurance.
22// All data must be mergeable objects.
23// Y. Schutz CERN July 2007
24//
04236e67 25
26// --- ROOT system ---
04236e67 27#include <TFile.h>
04236e67 28#include <TTree.h>
29#include <TClonesArray.h>
30
31// --- Standard library ---
32
33// --- AliRoot header files ---
34#include "AliLog.h"
35#include "AliQADataMakerSim.h"
04236e67 36
37ClassImp(AliQADataMakerSim)
38
39//____________________________________________________________________________
40AliQADataMakerSim::AliQADataMakerSim(const char * name, const char * title) :
41 AliQADataMaker(name, title),
42 fDigitsQAList(0x0),
43 fHitsQAList(0x0),
44 fSDigitsQAList(0x0)
45{
46 // ctor
47 fDetectorDirName = GetName() ;
48}
49
50//____________________________________________________________________________
51AliQADataMakerSim::AliQADataMakerSim(const AliQADataMakerSim& qadm) :
52 AliQADataMaker(qadm.GetName(), qadm.GetTitle()),
53 fDigitsQAList(qadm.fDigitsQAList),
54 fHitsQAList(qadm.fHitsQAList),
55 fSDigitsQAList(qadm.fSDigitsQAList)
56{
57 //copy ctor
58 fDetectorDirName = GetName() ;
59}
60
63c6f8ae 61//____________________________________________________________________________
62AliQADataMakerSim::~AliQADataMakerSim()
63{
64 //dtor: delete the TObjArray and thei content
7ff8385d 65 if ( fDigitsQAList ) {
66 fDigitsQAList->Delete() ;
67 delete fDigitsQAList ;
68 }
69 if ( fHitsQAList ) {
70 fHitsQAList->Delete() ;
71 delete fHitsQAList ;
72 }
73 if ( fSDigitsQAList ) {
74 fSDigitsQAList->Delete() ;
75 delete fSDigitsQAList ;
76 }
63c6f8ae 77}
78
04236e67 79//__________________________________________________________________
80AliQADataMakerSim& AliQADataMakerSim::operator = (const AliQADataMakerSim& qadm )
81{
82 // Assignment operator.
83 this->~AliQADataMakerSim();
84 new(this) AliQADataMakerSim(qadm);
85 return *this;
86}
87
88//____________________________________________________________________________
96d67a8d 89void AliQADataMakerSim::EndOfCycle(AliQA::TASKINDEX_t task)
04236e67 90{
91 // Finishes a cycle of QA data acquistion
92 TObjArray * list = 0x0 ;
93
94 if ( task == AliQA::kHITS )
95 list = fHitsQAList ;
96 else if ( task == AliQA::kSDIGITS )
97 list = fSDigitsQAList ;
98 else if ( task == AliQA::kDIGITS )
99 list = fDigitsQAList ;
100
101 EndOfDetectorCycle(task, list) ;
102 TDirectory * subDir = fDetectorDir->GetDirectory(AliQA::GetTaskName(task)) ;
ccbf0759 103 if (subDir) {
104 subDir->cd() ;
105 list->Write() ;
106 }
04236e67 107}
108
109//____________________________________________________________________________
96d67a8d 110void AliQADataMakerSim::Exec(AliQA::TASKINDEX_t task, TObject * data)
04236e67 111{
112 // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs)
113
114 if ( task == AliQA::kHITS ) {
115 AliDebug(1, "Processing Hits QA") ;
116 TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ;
117 if (arr) {
118 MakeHits(arr) ;
119 } else {
120 TTree * tree = dynamic_cast<TTree *>(data) ;
121 if (tree) {
122 MakeHits(tree) ;
123 } else {
124 AliWarning("data are neither a TClonesArray nor a TTree") ;
125 }
126 }
127 } else if ( task == AliQA::kSDIGITS ) {
128 AliDebug(1, "Processing SDigits QA") ;
129 TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ;
130 if (arr) {
131 MakeSDigits(arr) ;
132 } else {
133 TTree * tree = dynamic_cast<TTree *>(data) ;
134 if (tree) {
135 MakeSDigits(tree) ;
136 } else {
137 AliWarning("data are neither a TClonesArray nor a TTree") ;
138 }
139 }
140 } else if ( task == AliQA::kDIGITS ) {
141 AliDebug(1, "Processing Digits QA") ;
142 TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ;
143 if (arr) {
144 MakeDigits(arr) ;
145 } else {
146 TTree * tree = dynamic_cast<TTree *>(data) ;
147 if (tree) {
148 MakeDigits(tree) ;
149 } else {
150 AliWarning("data are neither a TClonesArray nor a TTree") ;
151 }
152 }
153 }
154}
155
156//____________________________________________________________________________
96d67a8d 157TObjArray * AliQADataMakerSim::Init(AliQA::TASKINDEX_t task, Int_t run, Int_t cycles)
04236e67 158{
159 // general intialisation
160
161 fRun = run ;
162 if (cycles > 0)
163 SetCycle(cycles) ;
164 TObjArray * rv = NULL ;
165 if ( task == AliQA::kHITS ) {
63c6f8ae 166 if ( ! fHitsQAList ) {
167 fHitsQAList = new TObjArray(100) ;
168 InitHits() ;
169 }
04236e67 170 rv = fHitsQAList ;
171 } else if ( task == AliQA::kSDIGITS ) {
63c6f8ae 172 if ( ! fSDigitsQAList ) {
173 fSDigitsQAList = new TObjArray(100) ;
174 InitSDigits() ;
175 }
04236e67 176 rv = fSDigitsQAList ;
177 } else if ( task == AliQA::kDIGITS ) {
63c6f8ae 178 if ( ! fDigitsQAList ) {
179 fDigitsQAList = new TObjArray(100) ;
180 InitDigits() ;
181 }
04236e67 182 rv = fDigitsQAList ;
183 }
184
185 return rv ;
186}
187
188//____________________________________________________________________________
96d67a8d 189void AliQADataMakerSim::Init(AliQA::TASKINDEX_t task, TObjArray * list, Int_t run, Int_t cycles)
04236e67 190{
191 // Intialisation by passing the list of QA data booked elsewhere
192
193 fRun = run ;
194 if (cycles > 0)
195 SetCycle(cycles) ;
196
197 if ( task == AliQA::kHITS ) {
198 fHitsQAList = list ;
199 } else if ( task == AliQA::kSDIGITS) {
200 fSDigitsQAList = list ;
201 } else if ( task == AliQA::kDIGITS ) {
202 fDigitsQAList = list ;
203 }
204}
205
206//____________________________________________________________________________
96d67a8d 207void AliQADataMakerSim::StartOfCycle(AliQA::TASKINDEX_t task, const Bool_t sameCycle)
04236e67 208{
209 // Finishes a cycle of QA data acquistion
210 if ( !sameCycle || fCurrentCycle == -1) {
211 ResetCycle() ;
212 if (fOutput)
213 fOutput->Close() ;
214 fOutput = AliQA::GetQADataFile(GetName(), fRun, fCurrentCycle) ;
215 }
216
217 AliInfo(Form(" Run %d Cycle %d task %s file %s",
218 fRun, fCurrentCycle, AliQA::GetTaskName(task).Data(), fOutput->GetName() )) ;
219
220 fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
221 if (!fDetectorDir)
222 fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
223
224 TDirectory * subDir = fDetectorDir->GetDirectory(AliQA::GetTaskName(task)) ;
225 if (!subDir)
226 subDir = fDetectorDir->mkdir(AliQA::GetTaskName(task)) ;
227 subDir->cd() ;
228
229 TObjArray * list = 0x0 ;
230
231 if ( task == AliQA::kHITS )
232 list = fHitsQAList ;
233 else if ( task == AliQA::kSDIGITS )
234 list = fSDigitsQAList ;
235 else if ( task == AliQA::kDIGITS )
236 list = fDigitsQAList ;
075f5ecf 237
238// Should be the choice of detectors
239// TIter next(list) ;
240// TH1 * h ;
241// while ( (h = dynamic_cast<TH1 *>(next())) )
242// h->Reset() ;
243//
04236e67 244 StartOfDetectorCycle() ;
245}