]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/STEER/AliCorrQADataMakerRec.cxx
Merge branch 'TPCdev' of https://git.cern.ch/reps/AliRoot into TPCdev
[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   return *this;
101 }
102    
103 //____________________________________________________________________________ 
104 AliCorrQADataMakerRec::~AliCorrQADataMakerRec()  
105 {
106   //
107   // dtor only destroy the ntuple otherwise it would violate ownership...
108   // however when the last AliCorrQADataMakerRec is deleted there is
109   // a leak
110   //
111   //  if ( fCorrNt ) 
112   //    for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; ++specie) 
113   //        delete fCorrNt[specie] ; 
114   //  
115   delete [] fCorrNt ; 
116   delete [] fVarvalue ;
117 }
118   
119 //____________________________________________________________________________ 
120 void AliCorrQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** /*list*/)
121 {
122   //Detector specific actions at end of cycle
123   // do the QA checking
124   if (task == AliQAv1::kRAWS) {
125      AliQAChecker::Instance()->Run(AliQAv1::kCORR, task, fCorrNt) ; 
126   }
127 }
128
129 //____________________________________________________________________________ 
130 void AliCorrQADataMakerRec::InitESDs()
131 {
132   //Create histograms to controll ESD
133
134   AliInfo("TO BE IMPLEMENTED") ; 
135   //
136   ClonePerTrigClass(AliQAv1::kESDS); // this should be the last line
137 }
138
139
140 //____________________________________________________________________________ 
141 void AliCorrQADataMakerRec::InitRaws()
142 {
143   // createa ntuple taking all the parameters declared by detectors
144   if (fCorrNt && fCorrNt[AliRecoParam::AConvert(fEventSpecie)]) 
145     return ; 
146
147   if (!fCorrNt) {
148     fCorrNt = new TNtupleD *[AliRecoParam::kNSpecies] ; ;
149     for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) 
150       fCorrNt[specie] = NULL ;
151   } 
152
153   if ( fRawsQAList ) 
154   {
155     delete[] fRawsQAList ; // not needed for the time being 
156     fRawsQAList = NULL ; 
157   }
158   TString varlist("") ;
159   for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++ ) {
160     AliQADataMaker * qadm = fqadm[detIndex] ; 
161     if ( ! qadm ) 
162       continue ;
163     TList * list = qadm->GetParameterList() ; 
164     if (list) {
165       TIter next(list) ; 
166       TParameter<double> * p ; 
167       while ( (p = static_cast<TParameter<double>*>(next()) ) ) {
168         varlist.Append(p->GetName()) ; 
169         varlist.Append(":") ; 
170         fMaxRawVar++ ; 
171       }
172     }
173   }
174   varlist = varlist.Strip(TString::kTrailing, ':') ; 
175   if (fMaxRawVar == 0) { 
176     AliWarning("NTUPLE not created") ; 
177   } else {
178     char * name = Form("%s_%s", AliQAv1::GetQACorrName(), AliRecoParam::GetEventSpecieName(fEventSpecie)) ; 
179     fCorrNt[AliRecoParam::AConvert(fEventSpecie)] = new TNtupleD(name, "Raws data correlation among detectors", varlist.Data()) ;  
180     fVarvalue = new Double_t[fMaxRawVar] ;
181   }  
182   //
183   ClonePerTrigClass(AliQAv1::kRAWS); // this should be the last line
184 }
185
186 //____________________________________________________________________________ 
187 void AliCorrQADataMakerRec::InitRecPoints()
188 {
189     // create Reconstructed Points histograms in RecPoints subdir
190   
191   AliInfo("TO BE IMPLEMENTED") ; 
192   ClonePerTrigClass(AliQAv1::kRECPOINTS); // this should be the last line
193 }
194
195 //____________________________________________________________________________ 
196 void AliCorrQADataMakerRec::InitRecoParams()
197 {
198     // Get the recoparam form the OCDB for every detector involved in CORR
199   
200   AliInfo("TO BE IMPLEMENTED") ; 
201 }
202
203 //____________________________________________________________________________
204 void AliCorrQADataMakerRec::MakeESDs(AliESDEvent * /*esd*/)
205 {
206   // make QA data from ESDs
207
208   AliInfo("TO BE IMPLEMENTED") ; 
209   IncEvCountCycleESDs();
210   IncEvCountTotalESDs();
211   //
212 }
213
214 //____________________________________________________________________________
215 void AliCorrQADataMakerRec::MakeRaws(AliRawReader *)
216 {
217   //Fill prepared histograms with Raw digit properties
218   
219   if ( !fCorrNt || ! fCorrNt[AliRecoParam::AConvert(fEventSpecie)])
220       InitRaws() ; 
221   
222   if ( fMaxRawVar > 0 ) {
223     Int_t index = 0 ;
224     for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++ ) {
225       AliQADataMaker * qadm = fqadm[detIndex] ; 
226       if ( ! qadm ) 
227         continue ;
228       TList * list = qadm->GetParameterList() ; 
229       if (list) {
230         TIter next(list) ; 
231         TParameter<double> * p ; 
232         while ( (p = static_cast<TParameter<double>*>(next()) ) ) {
233           if (index >= fMaxRawVar) {
234             AliError(Form("Variables list size exceeded (%d) !",index));
235             break;
236           }
237           fVarvalue[index] = p->GetVal() ; 
238           index++ ; 
239         }
240       }
241     }
242     static_cast<TNtupleD*>(fCorrNt[AliRecoParam::AConvert(fEventSpecie)])->Fill(fVarvalue);
243   }
244   //
245   IncEvCountCycleRaws();
246   IncEvCountTotalRaws();
247   //
248 }
249
250 //____________________________________________________________________________
251 void AliCorrQADataMakerRec::MakeRecPoints(TTree * /*clustersTree*/)
252 {
253   AliInfo("TO BE IMPLEMENTED") ; 
254   IncEvCountCycleRecPoints();
255   IncEvCountTotalRecPoints();
256   //
257 }
258
259 //____________________________________________________________________________ 
260 void AliCorrQADataMakerRec::StartOfDetectorCycle()
261 {
262   //Detector specific actions at start of cycle  
263
264 }