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