forgot a protection before delete
[u/mrichter/AliRoot.git] / STEER / AliQADataMakerRec.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 for Reconstruction
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>
04236e67 29
30// --- Standard library ---
31
32// --- AliRoot header files ---
33#include "AliLog.h"
34#include "AliQADataMakerRec.h"
04236e67 35#include "AliESDEvent.h"
36#include "AliRawReader.h"
37
38ClassImp(AliQADataMakerRec)
39
40//____________________________________________________________________________
41AliQADataMakerRec::AliQADataMakerRec(const char * name, const char * title) :
42 AliQADataMaker(name, title),
43 fESDsQAList(0x0),
44 fRawsQAList(0x0),
45 fRecPointsQAList(0x0)
46{
47 // ctor
48 fDetectorDirName = GetName() ;
49}
50
51//____________________________________________________________________________
52AliQADataMakerRec::AliQADataMakerRec(const AliQADataMakerRec& qadm) :
53 AliQADataMaker(qadm.GetName(), qadm.GetTitle()),
54 fESDsQAList(qadm.fESDsQAList),
55 fRawsQAList(qadm.fRawsQAList),
56 fRecPointsQAList(qadm.fRecPointsQAList)
57
58{
59 //copy ctor
60 SetName(qadm.GetName()) ;
61 SetTitle(qadm.GetTitle()) ;
62 fDetectorDirName = GetName() ;
63}
64
63c6f8ae 65//____________________________________________________________________________
66AliQADataMakerRec::~AliQADataMakerRec()
67{
68 //dtor: delete the TObjArray and thei content
7ff8385d 69 if ( fESDsQAList ) {
70 fESDsQAList->Delete() ;
71 delete fESDsQAList ;
72 }
73 if ( fRawsQAList ) {
74 fRawsQAList->Delete() ;
75 delete fRawsQAList ;
76 }
77 if ( fRecPointsQAList ) {
78 fRecPointsQAList->Delete() ;
79 delete fRecPointsQAList ;
80 }
63c6f8ae 81}
82
04236e67 83//__________________________________________________________________
84AliQADataMakerRec& AliQADataMakerRec::operator = (const AliQADataMakerRec& qadm )
85{
86 // Assignment operator.
87 this->~AliQADataMakerRec();
88 new(this) AliQADataMakerRec(qadm);
89 return *this;
90}
91
92//____________________________________________________________________________
92a357bf 93void AliQADataMakerRec::EndOfCycle(AliQA::TASKINDEX_t task)
04236e67 94{
95 // Finishes a cycle of QA data acquistion
96
97 TObjArray * list = 0x0 ;
98
99 if ( task == AliQA::kRAWS )
100 list = fRawsQAList ;
101 else if ( task == AliQA::kRECPOINTS )
102 list = fRecPointsQAList ;
103 else if ( task == AliQA::kESDS )
104 list = fESDsQAList ;
7c002d48 105
106 DefaultEndOfDetectorCycle(task) ;
0774e4a4 107 EndOfDetectorCycle(task, list) ;
7c002d48 108 TDirectory * subDir = 0x0 ;
109 if (fDetectorDir)
110 subDir = fDetectorDir->GetDirectory(AliQA::GetTaskName(task)) ;
45c5be2d 111 if ( subDir ) {
eecc22a3 112 subDir->cd() ;
7c002d48 113 if (list)
114 list->Write() ;
eecc22a3 115 }
3a1d6366 116 Finish() ;
04236e67 117}
118
119//____________________________________________________________________________
92a357bf 120void AliQADataMakerRec::Exec(AliQA::TASKINDEX_t task, TObject * data)
04236e67 121{
122 // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs)
123
124 if ( task == AliQA::kRAWS ) {
125 AliDebug(1, "Processing Raws QA") ;
126 AliRawReader * rawReader = dynamic_cast<AliRawReader *>(data) ;
127 if (rawReader)
128 MakeRaws(rawReader) ;
129 else
130 AliError("Wrong data type") ;
131 } else if ( task == AliQA::kRECPOINTS ) {
132 AliDebug(1, "Processing RecPoints QA") ;
133 TTree * tree = dynamic_cast<TTree *>(data) ;
134 if (tree) {
135 MakeRecPoints(tree) ;
136 } else {
137 AliWarning("data are not a TTree") ;
138 }
139 } else if ( task == AliQA::kESDS ) {
140 AliDebug(1, "Processing ESDs QA") ;
141 AliESDEvent * esd = dynamic_cast<AliESDEvent *>(data) ;
142 if (esd)
143 MakeESDs(esd) ;
144 else
145 AliError("Wrong type of esd container") ;
146 }
147}
148
149//____________________________________________________________________________
92a357bf 150TObjArray * AliQADataMakerRec::Init(AliQA::TASKINDEX_t task, Int_t run, Int_t cycles)
04236e67 151{
152 // general intialisation
153
154 TObjArray * rv = NULL ;
155
156 fRun = run ;
157 if (cycles > 0)
158 SetCycle(cycles) ;
159
160 if ( task == AliQA::kRAWS ) {
63c6f8ae 161 if (! fRawsQAList ) {
162 fRawsQAList = new TObjArray(100) ;
163 InitRaws() ;
164 }
04236e67 165 rv = fRawsQAList ;
166 } else if ( task == AliQA::kRECPOINTS ) {
63c6f8ae 167 if ( ! fRecPointsQAList ) {
168 fRecPointsQAList = new TObjArray(100) ;
169 InitRecPoints() ;
170 }
04236e67 171 rv = fRecPointsQAList ;
172 } else if ( task == AliQA::kESDS ) {
63c6f8ae 173 if ( ! fESDsQAList ) {
174 fESDsQAList = new TObjArray(100) ;
175 InitESDs() ;
176 }
04236e67 177 rv = fESDsQAList ;
178 }
179
180 return rv ;
181}
182
183//____________________________________________________________________________
92a357bf 184void AliQADataMakerRec::Init(AliQA::TASKINDEX_t task, TObjArray * list, Int_t run, Int_t cycles)
04236e67 185{
186 // Intialisation by passing the list of QA data booked elsewhere
187
188 fRun = run ;
189 if (cycles > 0)
190 SetCycle(cycles) ;
191
192 if ( task == AliQA::kRAWS ) {
193 fRawsQAList = list ;
194 } else if ( task == AliQA::kRECPOINTS ) {
195 fRecPointsQAList = list ;
196 } else if ( task == AliQA::kESDS ) {
197 fESDsQAList = list ;
198 }
199}
200
201//____________________________________________________________________________
92a357bf 202void AliQADataMakerRec::StartOfCycle(AliQA::TASKINDEX_t task, const Bool_t sameCycle)
04236e67 203{
204 // Finishes a cycle of QA data acquistion
04236e67 205 if ( !sameCycle || fCurrentCycle == -1) {
206 ResetCycle() ;
207 if (fOutput)
208 fOutput->Close() ;
209 fOutput = AliQA::GetQADataFile(GetName(), fRun, fCurrentCycle) ;
210 }
7c002d48 211 AliInfo(Form(" Run %d Cycle %d task %s file %s",
04236e67 212 fRun, fCurrentCycle, AliQA::GetTaskName(task).Data(), fOutput->GetName() )) ;
213
214 fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
215 if (!fDetectorDir)
216 fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
217
218 TDirectory * subDir = fDetectorDir->GetDirectory(AliQA::GetTaskName(task)) ;
219 if (!subDir)
220 subDir = fDetectorDir->mkdir(AliQA::GetTaskName(task)) ;
221 subDir->cd() ;
222
223 TObjArray * list = 0x0 ;
224
225 if ( task == AliQA::kRAWS )
226 list = fRawsQAList ;
227 else if ( task == AliQA::kRECPOINTS)
228 list = fRecPointsQAList ;
229 else if ( task == AliQA::kESDS )
230 list = fESDsQAList ;
075f5ecf 231
232// Should be the choice of detectors
233// TIter next(list) ;
234// TH1 * h ;
235// while ( (h = dynamic_cast<TH1 *>(next())) )
236// h->Reset() ;
04236e67 237
238 StartOfDetectorCycle() ;
239}