]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliQADataMakerSim.cxx
Corrected the methods used to create and assign the TRD L0 and L1 trigger inputs.
[u/mrichter/AliRoot.git] / STEER / AliQADataMakerSim.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. 
22 //  All data must be mergeable objects.
23 //  Y. Schutz CERN July 2007
24 //
25
26 // --- ROOT system ---
27 #include <TCanvas.h>
28 #include <TFile.h>
29 #include <TTree.h>
30 #include <TClonesArray.h>
31
32 // --- Standard library ---
33
34 // --- AliRoot header files ---
35 #include "AliLog.h"
36 #include "AliQADataMakerSim.h"
37
38 ClassImp(AliQADataMakerSim)
39              
40 //____________________________________________________________________________ 
41 AliQADataMakerSim::AliQADataMakerSim(const char * name, const char * title) : 
42   AliQADataMaker(name, title), 
43   fDigitsQAList(0x0), 
44   fHitsQAList(0x0),
45   fSDigitsQAList(0x0)
46 {
47         // ctor
48         fDetectorDirName = GetName() ; 
49 }
50
51 //____________________________________________________________________________ 
52 AliQADataMakerSim::AliQADataMakerSim(const AliQADataMakerSim& qadm) :
53   AliQADataMaker(qadm.GetName(), qadm.GetTitle()), 
54   fDigitsQAList(qadm.fDigitsQAList),
55   fHitsQAList(qadm.fHitsQAList),
56   fSDigitsQAList(qadm.fSDigitsQAList) 
57 {
58   //copy ctor
59   fDetectorDirName = GetName() ; 
60 }
61
62 //____________________________________________________________________________ 
63 AliQADataMakerSim::~AliQADataMakerSim()
64 {
65         //dtor: delete the TObjArray and thei content
66         if ( fDigitsQAList ) { 
67     for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
68       if ( fDigitsQAList[specie]->IsOwner() )
69                         fDigitsQAList[specie]->Delete() ;
70     }
71                 delete[] fDigitsQAList ;     
72         }
73         if ( fHitsQAList ) {
74     for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
75       if ( fHitsQAList[specie]->IsOwner() ) 
76                         fHitsQAList[specie]->Delete() ;
77     }
78                 delete[] fHitsQAList ;
79         }
80         if ( fSDigitsQAList ) { 
81     for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
82       if ( fSDigitsQAList[specie]->IsOwner() ) 
83                         fSDigitsQAList[specie]->Delete() ; 
84     }
85                 delete[] fSDigitsQAList ; 
86         }
87 }
88
89 //__________________________________________________________________
90 AliQADataMakerSim& AliQADataMakerSim::operator = (const AliQADataMakerSim& qadm )
91 {
92   // Assignment operator.
93   this->~AliQADataMakerSim();
94   new(this) AliQADataMakerSim(qadm);
95   return *this;
96 }
97
98 //____________________________________________________________________________
99 void AliQADataMakerSim::EndOfCycle() 
100
101   // Finishes a cycle of QA for all tasks
102   EndOfCycle(AliQAv1::kHITS) ; 
103   EndOfCycle(AliQAv1::kSDIGITS) ; 
104   EndOfCycle(AliQAv1::kDIGITS) ;
105   ResetCycle() ; 
106 }
107
108 //____________________________________________________________________________
109 void AliQADataMakerSim::EndOfCycle(AliQAv1::TASKINDEX_t task) 
110
111   // Finishes a cycle of QA data acquistion
112         TObjArray ** list = NULL ; 
113         
114         if ( task == AliQAv1::kHITS ) 
115                 list = fHitsQAList ; 
116         else if ( task == AliQAv1::kSDIGITS )
117                 list = fSDigitsQAList ; 
118         else if ( task == AliQAv1::kDIGITS ) 
119                 list = fDigitsQAList ; 
120   
121   if ( ! list ) 
122     return ; 
123         EndOfDetectorCycle(task, list) ; 
124   TDirectory * subDir = NULL ;
125         if (fDetectorDir) 
126     subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ; 
127         if (subDir) { 
128                 subDir->cd() ; 
129     for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
130       TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ;
131       if (eventSpecieDir) {
132         eventSpecieDir->cd() ; 
133         TIter next(list[specie]) ; 
134         TObject * obj ; 
135         while ( (obj = next()) )  {
136           if (!obj->TestBit(AliQAv1::GetExpertBit()))
137             obj->Write() ;
138         }
139         if (WriteExpert()) {
140           TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ; 
141           if ( expertDir ) {
142             expertDir->cd() ;
143             next.Reset() ; 
144             while ( (obj = next()) ) {
145               if (!obj->TestBit(AliQAv1::GetExpertBit()))
146                 continue ; 
147             obj->Write() ;
148             }      
149           }
150         }
151       }
152     }
153     fOutput->Save() ; 
154   }
155   if (fPrintImage) 
156     MakeImage(task) ; 
157 }
158  
159 //____________________________________________________________________________
160 void AliQADataMakerSim::Exec(AliQAv1::TASKINDEX_t task, TObject * data) 
161
162   // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs)
163     
164         if ( task == AliQAv1::kHITS ) {  
165                 AliDebug(AliQAv1::GetQADebugLevel(), "Processing Hits QA") ; 
166                 TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ; 
167                 if (arr) { 
168                         MakeHits(arr) ;
169                 } else {
170                         TTree * tree = dynamic_cast<TTree *>(data) ; 
171                         if (tree) {
172                                 MakeHits(tree) ; 
173                         } else {
174                                 AliWarning("data are neither a TClonesArray nor a TTree") ; 
175                         }
176                 }
177         } else if ( task == AliQAv1::kSDIGITS ) {
178                 AliDebug(AliQAv1::GetQADebugLevel(), "Processing SDigits QA") ; 
179                 TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ; 
180                 if (arr) { 
181                         MakeSDigits(arr) ;
182                 } else {
183                         TTree * tree = dynamic_cast<TTree *>(data) ; 
184                         if (tree) {
185                                 MakeSDigits(tree) ; 
186                         } else {
187                                 AliWarning("data are neither a TClonesArray nor a TTree") ; 
188                         }
189                 }
190         } else if ( task == AliQAv1::kDIGITS ) {
191                 AliDebug(AliQAv1::GetQADebugLevel(), "Processing Digits QA") ; 
192                 TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ; 
193                 if (arr) { 
194                         MakeDigits(arr) ;
195                 } else {
196                         TTree * tree = dynamic_cast<TTree *>(data) ; 
197                         if (tree) {
198                                 MakeDigits(tree) ; 
199                         } else {
200                                 AliWarning("data are neither a TClonesArray nor a TTree") ; 
201                         }
202                 }
203         }
204 }
205
206 //____________________________________________________________________________ 
207 void AliQADataMakerSim::MakeImage(AliQAv1::TASKINDEX_t task)
208 {
209   // create a drawing of detetor defined histograms
210   TObjArray ** list = NULL ;  
211   switch (task) {
212     case AliQAv1::kRAWS:
213       break;
214     case AliQAv1::kHITS:
215       list = fHitsQAList ;
216       break;
217     case AliQAv1::kSDIGITS:
218       list = fSDigitsQAList ;
219       break;  
220     case AliQAv1::kDIGITS:
221       list = fDigitsQAList ;
222       break;  
223     case AliQAv1::kDIGITSR:
224       break;
225     case AliQAv1::kRECPOINTS:
226       break;
227     case AliQAv1::kTRACKSEGMENTS:
228       break;
229     case AliQAv1::kRECPARTICLES:
230       break;
231     case AliQAv1::kESDS:
232       break;
233     case AliQAv1::kNTASKINDEX:
234       break;
235     default:
236     break;
237   }
238   if ( !list) {
239     AliFatal("data not initialized, call AliQADataMaker::Init"); 
240   return ; 
241   }
242   MakeTheImage(list, task, "Sim") ; 
243 }
244
245 //____________________________________________________________________________ 
246 TObjArray **  AliQADataMakerSim::Init(AliQAv1::TASKINDEX_t task, Int_t cycles)
247 {
248   // general intialisation
249         
250         if (cycles > 0)
251                 SetCycle(cycles) ;  
252         TObjArray ** rv = NULL ; 
253         if ( task == AliQAv1::kHITS ) {
254                 if ( ! fHitsQAList ) {
255       fHitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ; 
256       for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
257         fHitsQAList[specie] = new TObjArray(100) ;       
258         fHitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
259       }
260                         InitHits() ;
261                 }
262                 rv = fHitsQAList ;
263         } else if ( task == AliQAv1::kSDIGITS ) {
264                 if ( ! fSDigitsQAList ) {
265       fSDigitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ; 
266       for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
267         fSDigitsQAList[specie] = new TObjArray(100) ; 
268         fSDigitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ; 
269       }
270       InitSDigits() ;
271                 }
272                 rv = fSDigitsQAList ;
273    } else if ( task == AliQAv1::kDIGITS ) {
274            if ( ! fDigitsQAList ) {
275        fDigitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ; 
276        for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {    
277          fDigitsQAList[specie] = new TObjArray(100) ;
278          fDigitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
279        }
280                    InitDigits() ;
281            }
282            rv =  fDigitsQAList ;
283    }
284   
285         return rv ; 
286 }
287
288 //____________________________________________________________________________ 
289 void AliQADataMakerSim::Init(AliQAv1::TASKINDEX_t task, TObjArray ** list, Int_t run, Int_t cycles)
290 {
291   // Intialisation by passing the list of QA data booked elsewhere
292   
293         fRun = run ;
294         if (cycles > 0)
295                 SetCycle(cycles) ;  
296         
297         if ( task == AliQAv1::kHITS ) {
298                 fHitsQAList = list ;     
299         } else if ( task == AliQAv1::kSDIGITS) {
300                 fSDigitsQAList = list ; 
301         } else if ( task == AliQAv1::kDIGITS ) {
302                 fDigitsQAList = list ; 
303         } 
304 }
305
306 //____________________________________________________________________________
307 void AliQADataMakerSim::StartOfCycle(Int_t run) 
308
309   // Finishes a cycle of QA for all tasks
310   Bool_t samecycle = kFALSE ; 
311   StartOfCycle(AliQAv1::kHITS,    run, samecycle) ;
312   samecycle = kTRUE ; 
313   StartOfCycle(AliQAv1::kSDIGITS, run, samecycle) ;
314   StartOfCycle(AliQAv1::kDIGITS,  run, samecycle) ;
315 }
316
317 //____________________________________________________________________________
318 void AliQADataMakerSim::StartOfCycle(AliQAv1::TASKINDEX_t task, Int_t run, const Bool_t sameCycle) 
319
320   // Finishes a cycle of QA data acquistion
321   if ( run > 0 ) 
322     fRun = run ; 
323         if ( !sameCycle || fCurrentCycle == -1) {
324                 ResetCycle() ;
325         if (fOutput) 
326                 fOutput->Close() ; 
327         fOutput = AliQAv1::GetQADataFile(GetName(), fRun) ;     
328         }       
329
330         AliDebug(AliQAv1::GetQADebugLevel(), Form(" Run %d Cycle %d task %s file %s", 
331                                  fRun, fCurrentCycle, AliQAv1::GetTaskName(task).Data(), fOutput->GetName() )) ;
332
333         fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ; 
334         if (!fDetectorDir)
335                 fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ; 
336
337         TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ; 
338         if (!subDir)
339                 subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ;  
340   
341   for ( Int_t index = AliRecoParam::kDefault ; index < AliRecoParam::kNSpecies ; index++ ) {
342     TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(index)) ; 
343     if (!eventSpecieDir) 
344       eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(index)) ; 
345     TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ; 
346     if (!expertDir) 
347       expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ; 
348    }   
349         StartOfDetectorCycle() ; 
350 }