]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliQADataMakerRec.cxx
Making AliDCSValue sortable (Vladimir)
[u/mrichter/AliRoot.git] / STEER / AliQADataMakerRec.cxx
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
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 */
25
26 // --- ROOT system ---
27 #include <TSystem.h> 
28 #include <TFile.h>
29 #include <TList.h> 
30 #include <TTree.h>
31 #include <TClonesArray.h>
32
33 // --- Standard library ---
34
35 // --- AliRoot header files ---
36 #include "AliLog.h"
37 #include "AliQADataMakerRec.h"
38 #include "AliQAChecker.h"
39 #include "AliESDEvent.h"
40 #include "AliRawReader.h"
41
42 ClassImp(AliQADataMakerRec)
43              
44 //____________________________________________________________________________ 
45 AliQADataMakerRec::AliQADataMakerRec(const char * name, const char * title) : 
46   AliQADataMaker(name, title), 
47   fESDsQAList(0x0), 
48   fRawsQAList(0x0), 
49   fRecPointsQAList(0x0)
50 {
51   // ctor
52         fDetectorDirName = GetName() ; 
53 }
54
55 //____________________________________________________________________________ 
56 AliQADataMakerRec::AliQADataMakerRec(const AliQADataMakerRec& qadm) :
57     AliQADataMaker(qadm.GetName(), qadm.GetTitle()), 
58     fESDsQAList(qadm.fESDsQAList),
59         fRawsQAList(qadm.fRawsQAList),
60         fRecPointsQAList(qadm.fRecPointsQAList)
61   
62 {
63   //copy ctor
64         SetName(qadm.GetName()) ; 
65         SetTitle(qadm.GetTitle()) ; 
66         fDetectorDirName = GetName() ; 
67 }
68
69 //__________________________________________________________________
70 AliQADataMakerRec& AliQADataMakerRec::operator = (const AliQADataMakerRec& qadm )
71 {
72   // Assignment operator.
73   this->~AliQADataMakerRec();
74   new(this) AliQADataMakerRec(qadm);
75   return *this;
76 }
77
78 //____________________________________________________________________________
79 void AliQADataMakerRec::EndOfCycle(AliQA::TASKINDEX task) 
80 {
81         // Finishes a cycle of QA data acquistion
82         
83         TObjArray * list = 0x0 ; 
84         
85         if ( task == AliQA::kRAWS )     
86                 list = fRawsQAList ; 
87         else if ( task == AliQA::kRECPOINTS ) 
88                 list = fRecPointsQAList ; 
89         else if ( task == AliQA::kESDS )
90                 list = fESDsQAList ; 
91         
92         EndOfDetectorCycle(task, list) ; 
93         TDirectory * subDir = fDetectorDir->GetDirectory(AliQA::GetTaskName(task)) ; 
94         if ( subDir ) {
95                 subDir->cd() ; 
96                 list->Write() ;
97         }
98 }
99  
100 //____________________________________________________________________________
101 void AliQADataMakerRec::Exec(AliQA::TASKINDEX task, TObject * data) 
102
103   // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs)
104         
105         if ( task == AliQA::kRAWS ) {
106                 AliDebug(1, "Processing Raws QA") ; 
107                 AliRawReader * rawReader = dynamic_cast<AliRawReader *>(data) ; 
108                 if (rawReader) 
109                         MakeRaws(rawReader) ;
110                 else
111                 AliError("Wrong data type") ;     
112         } else if ( task == AliQA::kRECPOINTS ) {
113                 AliDebug(1, "Processing RecPoints QA") ; 
114                 TTree * tree = dynamic_cast<TTree *>(data) ; 
115                 if (tree) {
116                         MakeRecPoints(tree) ; 
117                 } else {
118                         AliWarning("data are not a TTree") ; 
119                 }
120         } else if ( task == AliQA::kESDS ) {
121                 AliDebug(1, "Processing ESDs QA") ; 
122                 AliESDEvent * esd = dynamic_cast<AliESDEvent *>(data) ; 
123                 if (esd) 
124                         MakeESDs(esd) ;
125                 else 
126                         AliError("Wrong type of esd container") ; 
127         }  
128 }
129
130 //____________________________________________________________________________ 
131 TObjArray *  AliQADataMakerRec::Init(AliQA::TASKINDEX task, Int_t run, Int_t cycles)
132 {
133   // general intialisation
134         
135         TObjArray * rv = NULL ; 
136   
137         fRun = run ;
138         if (cycles > 0)
139                 SetCycle(cycles) ;  
140         
141         if ( task == AliQA::kRAWS ) {
142                 fRawsQAList = new TObjArray(100) ;       
143                 InitRaws() ;
144                 rv = fRawsQAList ;
145         } else if ( task == AliQA::kRECPOINTS ) {
146                 fRecPointsQAList = new TObjArray(100) ; 
147                 InitRecPoints() ;
148                 rv = fRecPointsQAList ;
149         } else if ( task == AliQA::kESDS ) {
150                 fESDsQAList = new TObjArray(100) ; 
151                 InitESDs() ;
152                 rv = fESDsQAList ;
153         }
154         
155         return rv ; 
156 }
157
158 //____________________________________________________________________________ 
159 void AliQADataMakerRec::Init(AliQA::TASKINDEX task, TObjArray * list, Int_t run, Int_t cycles)
160 {
161   // Intialisation by passing the list of QA data booked elsewhere
162   
163         fRun = run ;
164         if (cycles > 0)
165                 SetCycle(cycles) ;  
166         
167         if ( task == AliQA::kRAWS ) {
168                 fRawsQAList = list ;     
169         } else if ( task == AliQA::kRECPOINTS ) {
170                 fRecPointsQAList = list ; 
171         } else if ( task == AliQA::kESDS ) {
172                 fESDsQAList = list ; 
173         }
174 }
175
176 //____________________________________________________________________________
177 void AliQADataMakerRec::StartOfCycle(AliQA::TASKINDEX task, const Bool_t sameCycle) 
178
179   // Finishes a cycle of QA data acquistion
180  
181         if ( !sameCycle || fCurrentCycle == -1) {
182                 ResetCycle() ;
183                 if (fOutput) 
184                         fOutput->Close() ; 
185                 fOutput = AliQA::GetQADataFile(GetName(), fRun, fCurrentCycle) ;        
186         }       
187         AliInfo(Form(" Run %d Cycle %d task %s file %s", 
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 ;
207
208         TIter next(list) ;
209         TH1 * h ; 
210         while ( (h = dynamic_cast<TH1 *>(next())) )
211                 h->Reset() ;  
212
213         StartOfDetectorCycle() ; 
214 }