]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliQADataMakerSim.cxx
The total mult in V0 became float number.
[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 <TFile.h>
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"
36
37 ClassImp(AliQADataMakerSim)
38              
39 //____________________________________________________________________________ 
40 AliQADataMakerSim::AliQADataMakerSim(const char * name, const char * title) : 
41   AliQADataMaker(name, title), 
42   fDigitsQAList(NULL), 
43   fHitsQAList(NULL),
44   fSDigitsQAList(NULL),  
45   fHitsArray(NULL),
46   fSDigitsArray(NULL)
47 {
48         // ctor
49         fDetectorDirName = GetName() ; 
50 }
51
52 //____________________________________________________________________________ 
53 AliQADataMakerSim::AliQADataMakerSim(const AliQADataMakerSim& qadm) :
54   AliQADataMaker(qadm.GetName(), qadm.GetTitle()), 
55   fDigitsQAList(qadm.fDigitsQAList),
56   fHitsQAList(qadm.fHitsQAList),
57   fSDigitsQAList(qadm.fSDigitsQAList),  
58   fHitsArray(NULL),
59   fSDigitsArray(NULL)
60 {
61   //copy ctor
62   fDetectorDirName = GetName() ; 
63 }
64
65 //____________________________________________________________________________ 
66 AliQADataMakerSim::~AliQADataMakerSim()
67 {
68         //dtor: delete the TObjArray and thei content
69         if ( fDigitsQAList ) { 
70     for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
71       if ( fDigitsQAList[specie]->IsOwner() )
72                         fDigitsQAList[specie]->Delete() ;
73     }
74                 delete[] fDigitsQAList ;
75   }
76         if ( fHitsQAList ) {
77     for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
78       if ( fHitsQAList[specie]->IsOwner() ) 
79                         fHitsQAList[specie]->Delete() ;
80     }
81         delete[] fHitsQAList ;
82   }
83         if ( fSDigitsQAList ) { 
84     for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
85       if ( fSDigitsQAList[specie]->IsOwner() ) 
86                         fSDigitsQAList[specie]->Delete() ; 
87     }
88                 delete[] fSDigitsQAList ;
89   }
90   if (fHitsArray) {
91     fHitsArray->Clear() ; 
92     delete fHitsArray ;
93   }
94   if (fSDigitsArray) {
95     fSDigitsArray->Clear() ; 
96     delete fSDigitsArray ;
97   }  
98 }
99
100 //__________________________________________________________________
101 AliQADataMakerSim& AliQADataMakerSim::operator = (const AliQADataMakerSim& qadm )
102 {
103   // Assignment operator.
104   this->~AliQADataMakerSim();
105   new(this) AliQADataMakerSim(qadm);
106   return *this;
107 }
108
109 //____________________________________________________________________________
110 void AliQADataMakerSim::EndOfCycle() 
111
112   // Finishes a cycle of QA for all tasks
113   EndOfCycle(AliQAv1::kHITS) ; 
114   EndOfCycle(AliQAv1::kSDIGITS) ; 
115   EndOfCycle(AliQAv1::kDIGITS) ;
116   ResetCycle() ; 
117 }
118
119 //____________________________________________________________________________
120 void AliQADataMakerSim::EndOfCycle(AliQAv1::TASKINDEX_t task) 
121
122   // Finishes a cycle of QA data acquistion
123         TObjArray ** list = NULL ; 
124         
125         if ( task == AliQAv1::kHITS ) 
126                 list = fHitsQAList ; 
127         else if ( task == AliQAv1::kSDIGITS )
128                 list = fSDigitsQAList ; 
129         else if ( task == AliQAv1::kDIGITS ) 
130                 list = fDigitsQAList ; 
131   
132   if ( ! list ) 
133     return ; 
134         EndOfDetectorCycle(task, list) ; 
135   fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
136         if (!fDetectorDir) 
137     fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ; 
138   TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ; 
139   if (!subDir)
140     subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ;  
141   subDir->cd() ; 
142   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
143     if (! AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(specie)) ) 
144       continue ;
145     TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ;
146     if (!eventSpecieDir) 
147       eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(specie)) ; 
148     eventSpecieDir->cd() ; 
149     TIter next(list[specie]) ; 
150     TObject * obj ; 
151     while ( (obj = next()) )  {
152       if (!obj->TestBit(AliQAv1::GetExpertBit()))
153         obj->Write() ;
154     }
155     if (WriteExpert()) {
156       TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ; 
157       if (!expertDir) 
158         expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ; 
159       expertDir->cd() ;
160       next.Reset() ; 
161       while ( (obj = next()) ) {
162         if (!obj->TestBit(AliQAv1::GetExpertBit()))
163           continue ; 
164         obj->Write() ;
165       }      
166     }
167     fOutput->Save() ; 
168   }
169 }
170
171 //____________________________________________________________________________
172 void AliQADataMakerSim::Exec(AliQAv1::TASKINDEX_t task, TObject * data) 
173
174   // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs)
175   
176         if ( task == AliQAv1::kHITS ) {  
177                 AliDebug(AliQAv1::GetQADebugLevel(), "Processing Hits QA") ; 
178                 if (strcmp(data->ClassName(), "TClonesArray") == 0) { 
179       fHitsArray = static_cast<TClonesArray *>(data) ; 
180                         MakeHits() ;
181                 } else if (strcmp(data->ClassName(), "TTree") == 0) {
182                         TTree * tree = static_cast<TTree *>(data) ; 
183       MakeHits(tree) ; 
184     } else {
185       AliWarning("data are neither a TClonesArray nor a TTree") ; 
186     }
187         } else if ( task == AliQAv1::kSDIGITS ) {
188                 AliDebug(AliQAv1::GetQADebugLevel(), "Processing SDigits QA") ; 
189                 if (strcmp(data->ClassName(), "TClonesArray") == 0) { 
190       fSDigitsArray = static_cast<TClonesArray *>(data) ; 
191                         MakeSDigits() ;
192                 } else if (strcmp(data->ClassName(), "TTree") == 0) {
193                         TTree * tree = static_cast<TTree *>(data) ; 
194       MakeSDigits(tree) ; 
195     } else {
196       AliWarning("data are neither a TClonesArray nor a TTree") ; 
197     }
198         } else if ( task == AliQAv1::kDIGITS ) {
199                 AliDebug(AliQAv1::GetQADebugLevel(), "Processing Digits QA") ; 
200                 if (strcmp(data->ClassName(), "TClonesArray") == 0) { 
201       fDigitsArray = static_cast<TClonesArray *>(data) ; 
202                         MakeDigits() ;
203                 } else if (strcmp(data->ClassName(), "TTree") == 0)  {
204                         TTree * tree = static_cast<TTree *>(data) ; 
205       MakeDigits(tree) ; 
206     } else {
207       AliWarning("data are neither a TClonesArray nor a TTree") ; 
208     }
209   }
210 }
211
212 //____________________________________________________________________________ 
213 TObjArray **  AliQADataMakerSim::Init(AliQAv1::TASKINDEX_t task, Int_t cycles)
214 {
215   // general intialisation
216         
217         if (cycles > 0)
218                 SetCycle(cycles) ;  
219         TObjArray ** rv = NULL ; 
220         if ( task == AliQAv1::kHITS ) {
221                 if ( ! fHitsQAList ) {
222       fHitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ; 
223       for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
224         fHitsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;    
225         fHitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
226       }
227                 }
228                 rv = fHitsQAList ;
229         } else if ( task == AliQAv1::kSDIGITS ) {
230                 if ( ! fSDigitsQAList ) {
231       fSDigitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ; 
232       for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
233         fSDigitsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ; 
234         fSDigitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ; 
235       }
236                 }
237                 rv = fSDigitsQAList ;
238    } else if ( task == AliQAv1::kDIGITS ) {
239            if ( ! fDigitsQAList ) {
240        fDigitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ; 
241        for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {    
242          fDigitsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
243          fDigitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
244        }
245            }
246            rv =  fDigitsQAList ;
247    }
248   
249         return rv ; 
250
251
252 //____________________________________________________________________________ 
253 void AliQADataMakerSim::Init(AliQAv1::TASKINDEX_t task, TObjArray ** list, Int_t run, Int_t cycles)
254 {
255   // Intialisation by passing the list of QA data booked elsewhere
256   
257         fRun = run ;
258         if (cycles > 0)
259                 SetCycle(cycles) ;  
260         
261         if ( task == AliQAv1::kHITS ) {
262                 fHitsQAList = list ;     
263         } else if ( task == AliQAv1::kSDIGITS) {
264                 fSDigitsQAList = list ; 
265         } else if ( task == AliQAv1::kDIGITS ) {
266                 fDigitsQAList = list ; 
267         } 
268 }
269
270 //____________________________________________________________________________
271 void AliQADataMakerSim::StartOfCycle(Int_t run) 
272
273   // Finishes a cycle of QA for all tasks
274   Bool_t samecycle = kFALSE ; 
275   StartOfCycle(AliQAv1::kHITS,    run, samecycle) ;
276   samecycle = kTRUE ; 
277   StartOfCycle(AliQAv1::kSDIGITS, run, samecycle) ;
278   StartOfCycle(AliQAv1::kDIGITS,  run, samecycle) ;
279 }
280
281 //____________________________________________________________________________
282 void AliQADataMakerSim::StartOfCycle(AliQAv1::TASKINDEX_t task, Int_t run, const Bool_t sameCycle) 
283
284   // Finishes a cycle of QA data acquistion
285   if ( run > 0 ) 
286     fRun = run ; 
287         if ( !sameCycle || fCurrentCycle == -1) {
288                 ResetCycle() ;
289         if (fOutput) 
290                 fOutput->Close() ; 
291         fOutput = AliQAv1::GetQADataFile(GetName(), fRun) ;     
292         }       
293
294         AliDebug(AliQAv1::GetQADebugLevel(), Form(" Run %d Cycle %d task %s file %s", 
295                                  fRun, fCurrentCycle, AliQAv1::GetTaskName(task).Data(), fOutput->GetName() )) ;
296
297         //fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ; 
298 //      if (!fDetectorDir)
299 //              fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ; 
300 //
301 //      TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ; 
302 //      if (!subDir)
303 //              subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ;  
304 //  
305 //  for ( Int_t index = AliRecoParam::kDefault ; index < AliRecoParam::kNSpecies ; index++ ) {
306 //    TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(index)) ; 
307 //    if (!eventSpecieDir) 
308 //      eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(index)) ; 
309 //    TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ; 
310 //    if (!expertDir) 
311 //      expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ; 
312 //   }   
313         StartOfDetectorCycle() ; 
314 }