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