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