]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/STEER/AliCorrQADataMakerRec.cxx
Fixing Coverity 18329
[u/mrichter/AliRoot.git] / STEER / STEER / AliCorrQADataMakerRec.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: AliCorrQADataMakerRec.cxx 27570 2008-07-24 21:49:27Z cvetan $ */
18
19 /*
20   Produces the data needed to calculate the quality assurance. 
21   All data must be mergeable objects.
22   Y. Schutz CERN July 2007
23 */
24
25 // --- ROOT system ---
26 #include <TClonesArray.h>
27 #include <TFile.h> 
28 #include <TH1F.h> 
29 #include <TH1I.h> 
30 #include <TH2F.h> 
31 #include <TNtupleD.h>
32 #include <TParameter.h>
33 #include <TMath.h> 
34
35 // --- Standard library ---
36
37 // --- AliRoot header files ---
38 #include "AliLog.h"
39 #include "AliCorrQADataMakerRec.h"
40 #include "AliQAChecker.h"
41
42 ClassImp(AliCorrQADataMakerRec)
43            
44 //____________________________________________________________________________ 
45 AliCorrQADataMakerRec::AliCorrQADataMakerRec(AliQADataMaker ** qadm ) : 
46 AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kCORR), "Corr Quality Assurance Data Maker"),
47   fMaxRawVar(0),  
48   fqadm(qadm),
49   fVarvalue(NULL)
50 {
51   // ctor
52   fCorrNt = new TNtupleD *[AliRecoParam::kNSpecies] ; 
53   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) 
54     fCorrNt[specie] = NULL ; 
55 }
56
57 //____________________________________________________________________________ 
58 AliCorrQADataMakerRec::AliCorrQADataMakerRec(const AliCorrQADataMakerRec& qadm) :
59   AliQADataMakerRec(qadm),
60   fMaxRawVar(qadm.fMaxRawVar), 
61   fqadm(qadm.fqadm),
62   fVarvalue(NULL)
63 {
64   //copy ctor 
65   if ( fMaxRawVar > 0 ) {
66     fVarvalue = new Double_t[fMaxRawVar] ;
67     memcpy(fVarvalue, qadm.fVarvalue, fMaxRawVar*sizeof(Double_t));
68   }
69
70   // Replace shallow copy done by AliQADataMakerRec by a semi-deep
71   // copy where the pointer container is recreated but the Ntuples pointed 
72   // to are simply copied
73   fCorrNt = new TNtupleD *[AliRecoParam::kNSpecies] ; 
74   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) 
75     fCorrNt[specie] = qadm.fCorrNt[specie] ; 
76
77 }
78
79 //__________________________________________________________________
80 AliCorrQADataMakerRec& AliCorrQADataMakerRec::operator = (const AliCorrQADataMakerRec& qadm )
81 {
82   // assign operator.
83   if(this != &qadm) {
84     AliQADataMakerRec::operator=(qadm);
85     fMaxRawVar = qadm.fMaxRawVar;
86     fqadm = qadm.fqadm;
87     delete [] fVarvalue;
88     if ( fMaxRawVar > 0 ) {
89       fVarvalue = new Double_t[fMaxRawVar] ;
90       memcpy(fVarvalue, qadm.fVarvalue, fMaxRawVar*sizeof(Double_t));
91     } else fVarvalue = 0;
92
93     // Replace shallow copy done by AliQADataMakerRec by a semi-deep
94     // copy where the pointer container is recreated but the Ntuples pointed 
95     // to are simply copied
96     fCorrNt = new TNtupleD *[AliRecoParam::kNSpecies] ; 
97     for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) 
98       fCorrNt[specie] = qadm.fCorrNt[specie] ; 
99   }
100 }
101    
102 //____________________________________________________________________________ 
103 AliCorrQADataMakerRec::~AliCorrQADataMakerRec()  
104 {
105   //
106   // dtor only destroy the ntuple otherwise it would violate ownership...
107   // however when the last AliCorrQADataMakerRec is deleted there is
108   // a leak
109   //
110   //  if ( fCorrNt ) 
111   //    for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; ++specie) 
112   //        delete fCorrNt[specie] ; 
113   //  
114   delete [] fCorrNt ; 
115   delete [] fVarvalue ;
116 }
117   
118 //____________________________________________________________________________ 
119 void AliCorrQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** /*list*/)
120 {
121   //Detector specific actions at end of cycle
122   // do the QA checking
123   if (task == AliQAv1::kRAWS) {
124      AliQAChecker::Instance()->Run(AliQAv1::kCORR, task, fCorrNt) ; 
125   }
126 }
127
128 //____________________________________________________________________________ 
129 void AliCorrQADataMakerRec::InitESDs()
130 {
131   //Create histograms to controll ESD
132
133   AliInfo("TO BE IMPLEMENTED") ; 
134   //
135   ClonePerTrigClass(AliQAv1::kESDS); // this should be the last line
136 }
137
138
139 //____________________________________________________________________________ 
140 void AliCorrQADataMakerRec::InitRaws()
141 {
142   // createa ntuple taking all the parameters declared by detectors
143   if (fCorrNt && fCorrNt[AliRecoParam::AConvert(fEventSpecie)]) 
144     return ; 
145
146   if (!fCorrNt) {
147     fCorrNt = new TNtupleD *[AliRecoParam::kNSpecies] ; ;
148     for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) 
149       fCorrNt[specie] = NULL ;
150   } 
151
152   if ( fRawsQAList ) 
153   {
154     delete[] fRawsQAList ; // not needed for the time being 
155     fRawsQAList = NULL ; 
156   }
157   TString varlist("") ;
158   for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++ ) {
159     AliQADataMaker * qadm = fqadm[detIndex] ; 
160     if ( ! qadm ) 
161       continue ;
162     TList * list = qadm->GetParameterList() ; 
163     if (list) {
164       TIter next(list) ; 
165       TParameter<double> * p ; 
166       while ( (p = static_cast<TParameter<double>*>(next()) ) ) {
167         varlist.Append(p->GetName()) ; 
168         varlist.Append(":") ; 
169         fMaxRawVar++ ; 
170       }
171     }
172   }
173   varlist = varlist.Strip(TString::kTrailing, ':') ; 
174   if (fMaxRawVar == 0) { 
175     AliWarning("NTUPLE not created") ; 
176   } else {
177     char * name = Form("%s_%s", AliQAv1::GetQACorrName(), AliRecoParam::GetEventSpecieName(fEventSpecie)) ; 
178     fCorrNt[AliRecoParam::AConvert(fEventSpecie)] = new TNtupleD(name, "Raws data correlation among detectors", varlist.Data()) ;  
179     fVarvalue = new Double_t[fMaxRawVar] ;
180   }  
181   //
182   ClonePerTrigClass(AliQAv1::kRAWS); // this should be the last line
183 }
184
185 //____________________________________________________________________________ 
186 void AliCorrQADataMakerRec::InitRecPoints()
187 {
188     // create Reconstructed Points histograms in RecPoints subdir
189   
190   AliInfo("TO BE IMPLEMENTED") ; 
191   ClonePerTrigClass(AliQAv1::kRECPOINTS); // this should be the last line
192 }
193
194 //____________________________________________________________________________ 
195 void AliCorrQADataMakerRec::InitRecoParams()
196 {
197     // Get the recoparam form the OCDB for every detector involved in CORR
198   
199   AliInfo("TO BE IMPLEMENTED") ; 
200 }
201
202 //____________________________________________________________________________
203 void AliCorrQADataMakerRec::MakeESDs(AliESDEvent * /*esd*/)
204 {
205   // make QA data from ESDs
206
207   AliInfo("TO BE IMPLEMENTED") ; 
208   IncEvCountCycleESDs();
209   IncEvCountTotalESDs();
210   //
211 }
212
213 //____________________________________________________________________________
214 void AliCorrQADataMakerRec::MakeRaws(AliRawReader *)
215 {
216   //Fill prepared histograms with Raw digit properties
217   
218   if ( !fCorrNt || ! fCorrNt[AliRecoParam::AConvert(fEventSpecie)])
219       InitRaws() ; 
220   
221   if ( fMaxRawVar > 0 ) {
222     Int_t index = 0 ;
223     for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++ ) {
224       AliQADataMaker * qadm = fqadm[detIndex] ; 
225       if ( ! qadm ) 
226         continue ;
227       TList * list = qadm->GetParameterList() ; 
228       if (list) {
229         TIter next(list) ; 
230         TParameter<double> * p ; 
231         while ( (p = static_cast<TParameter<double>*>(next()) ) ) {
232           if (index >= fMaxRawVar) {
233             AliError(Form("Variables list size exceeded (%d) !",index));
234             break;
235           }
236           fVarvalue[index] = p->GetVal() ; 
237           index++ ; 
238         }
239       }
240     }
241     static_cast<TNtupleD*>(fCorrNt[AliRecoParam::AConvert(fEventSpecie)])->Fill(fVarvalue);
242   }
243   //
244   IncEvCountCycleRaws();
245   IncEvCountTotalRaws();
246   //
247 }
248
249 //____________________________________________________________________________
250 void AliCorrQADataMakerRec::MakeRecPoints(TTree * /*clustersTree*/)
251 {
252   AliInfo("TO BE IMPLEMENTED") ; 
253   IncEvCountCycleRecPoints();
254   IncEvCountTotalRecPoints();
255   //
256 }
257
258 //____________________________________________________________________________ 
259 void AliCorrQADataMakerRec::StartOfDetectorCycle()
260 {
261   //Detector specific actions at start of cycle  
262
263 }