]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliQADataMakerSim.cxx
Implementation of QA on correlated data among detectors
[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 ) {
b3cc11cb 66 if ( fDigitsQAList->IsOwner() )
67 fDigitsQAList->Delete() ;
7ff8385d 68 delete fDigitsQAList ;
69 }
70 if ( fHitsQAList ) {
b3cc11cb 71 if ( fHitsQAList->IsOwner() )
72 fHitsQAList->Delete() ;
7ff8385d 73 delete fHitsQAList ;
74 }
75 if ( fSDigitsQAList ) {
b3cc11cb 76 if ( fSDigitsQAList->IsOwner() )
77 fSDigitsQAList->Delete() ;
7ff8385d 78 delete fSDigitsQAList ;
79 }
63c6f8ae 80}
81
04236e67 82//__________________________________________________________________
83AliQADataMakerSim& AliQADataMakerSim::operator = (const AliQADataMakerSim& qadm )
84{
85 // Assignment operator.
86 this->~AliQADataMakerSim();
87 new(this) AliQADataMakerSim(qadm);
88 return *this;
89}
90
91//____________________________________________________________________________
96d67a8d 92void AliQADataMakerSim::EndOfCycle(AliQA::TASKINDEX_t task)
04236e67 93{
94 // Finishes a cycle of QA data acquistion
95 TObjArray * list = 0x0 ;
96
97 if ( task == AliQA::kHITS )
98 list = fHitsQAList ;
99 else if ( task == AliQA::kSDIGITS )
100 list = fSDigitsQAList ;
101 else if ( task == AliQA::kDIGITS )
102 list = fDigitsQAList ;
103
104 EndOfDetectorCycle(task, list) ;
105 TDirectory * subDir = fDetectorDir->GetDirectory(AliQA::GetTaskName(task)) ;
ccbf0759 106 if (subDir) {
107 subDir->cd() ;
108 list->Write() ;
109 }
04236e67 110}
111
112//____________________________________________________________________________
96d67a8d 113void AliQADataMakerSim::Exec(AliQA::TASKINDEX_t task, TObject * data)
04236e67 114{
115 // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs)
116
117 if ( task == AliQA::kHITS ) {
118 AliDebug(1, "Processing Hits QA") ;
119 TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ;
120 if (arr) {
121 MakeHits(arr) ;
122 } else {
123 TTree * tree = dynamic_cast<TTree *>(data) ;
124 if (tree) {
125 MakeHits(tree) ;
126 } else {
127 AliWarning("data are neither a TClonesArray nor a TTree") ;
128 }
129 }
130 } else if ( task == AliQA::kSDIGITS ) {
131 AliDebug(1, "Processing SDigits QA") ;
132 TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ;
133 if (arr) {
134 MakeSDigits(arr) ;
135 } else {
136 TTree * tree = dynamic_cast<TTree *>(data) ;
137 if (tree) {
138 MakeSDigits(tree) ;
139 } else {
140 AliWarning("data are neither a TClonesArray nor a TTree") ;
141 }
142 }
143 } else if ( task == AliQA::kDIGITS ) {
144 AliDebug(1, "Processing Digits QA") ;
145 TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ;
146 if (arr) {
147 MakeDigits(arr) ;
148 } else {
149 TTree * tree = dynamic_cast<TTree *>(data) ;
150 if (tree) {
151 MakeDigits(tree) ;
152 } else {
153 AliWarning("data are neither a TClonesArray nor a TTree") ;
154 }
155 }
156 }
157}
158
159//____________________________________________________________________________
96d67a8d 160TObjArray * AliQADataMakerSim::Init(AliQA::TASKINDEX_t task, Int_t run, Int_t cycles)
04236e67 161{
162 // general intialisation
163
164 fRun = run ;
165 if (cycles > 0)
166 SetCycle(cycles) ;
167 TObjArray * rv = NULL ;
168 if ( task == AliQA::kHITS ) {
63c6f8ae 169 if ( ! fHitsQAList ) {
170 fHitsQAList = new TObjArray(100) ;
a2b64fbd 171 fHitsQAList->SetName(Form("%s/%s", GetName(), AliQA::GetTaskName(task).Data())) ;
63c6f8ae 172 InitHits() ;
173 }
04236e67 174 rv = fHitsQAList ;
175 } else if ( task == AliQA::kSDIGITS ) {
63c6f8ae 176 if ( ! fSDigitsQAList ) {
177 fSDigitsQAList = new TObjArray(100) ;
a2b64fbd 178 fSDigitsQAList->SetName(Form("%s/%s", GetName(), AliQA::GetTaskName(task).Data())) ;
63c6f8ae 179 InitSDigits() ;
180 }
04236e67 181 rv = fSDigitsQAList ;
182 } else if ( task == AliQA::kDIGITS ) {
63c6f8ae 183 if ( ! fDigitsQAList ) {
184 fDigitsQAList = new TObjArray(100) ;
a2b64fbd 185 fDigitsQAList->SetName(Form("%s/%s", GetName(), AliQA::GetTaskName(task).Data())) ;
63c6f8ae 186 InitDigits() ;
187 }
04236e67 188 rv = fDigitsQAList ;
189 }
190
191 return rv ;
192}
193
194//____________________________________________________________________________
96d67a8d 195void AliQADataMakerSim::Init(AliQA::TASKINDEX_t task, TObjArray * list, Int_t run, Int_t cycles)
04236e67 196{
197 // Intialisation by passing the list of QA data booked elsewhere
198
199 fRun = run ;
200 if (cycles > 0)
201 SetCycle(cycles) ;
202
203 if ( task == AliQA::kHITS ) {
204 fHitsQAList = list ;
205 } else if ( task == AliQA::kSDIGITS) {
206 fSDigitsQAList = list ;
207 } else if ( task == AliQA::kDIGITS ) {
208 fDigitsQAList = list ;
209 }
210}
211
212//____________________________________________________________________________
96d67a8d 213void AliQADataMakerSim::StartOfCycle(AliQA::TASKINDEX_t task, const Bool_t sameCycle)
04236e67 214{
215 // Finishes a cycle of QA data acquistion
216 if ( !sameCycle || fCurrentCycle == -1) {
217 ResetCycle() ;
218 if (fOutput)
219 fOutput->Close() ;
220 fOutput = AliQA::GetQADataFile(GetName(), fRun, fCurrentCycle) ;
221 }
222
223 AliInfo(Form(" Run %d Cycle %d task %s file %s",
224 fRun, fCurrentCycle, AliQA::GetTaskName(task).Data(), fOutput->GetName() )) ;
225
226 fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
227 if (!fDetectorDir)
228 fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
229
230 TDirectory * subDir = fDetectorDir->GetDirectory(AliQA::GetTaskName(task)) ;
231 if (!subDir)
232 subDir = fDetectorDir->mkdir(AliQA::GetTaskName(task)) ;
233 subDir->cd() ;
234
235 TObjArray * list = 0x0 ;
236
237 if ( task == AliQA::kHITS )
238 list = fHitsQAList ;
239 else if ( task == AliQA::kSDIGITS )
240 list = fSDigitsQAList ;
241 else if ( task == AliQA::kDIGITS )
242 list = fDigitsQAList ;
075f5ecf 243
244// Should be the choice of detectors
245// TIter next(list) ;
246// TH1 * h ;
247// while ( (h = dynamic_cast<TH1 *>(next())) )
248// h->Reset() ;
249//
04236e67 250 StartOfDetectorCycle() ;
251}