Fix for raw ctp decoding (Marek)
[u/mrichter/AliRoot.git] / STEER / STEER / AliCorrQADataMakerRec.cxx
CommitLineData
a64b872d 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>
57acd2d2 33#include <TMath.h>
a64b872d 34
35// --- Standard library ---
36
37// --- AliRoot header files ---
38#include "AliLog.h"
39#include "AliCorrQADataMakerRec.h"
40#include "AliQAChecker.h"
41
42ClassImp(AliCorrQADataMakerRec)
43
44//____________________________________________________________________________
45AliCorrQADataMakerRec::AliCorrQADataMakerRec(AliQADataMaker ** qadm ) :
4e25ac79 46AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kCORR), "Corr Quality Assurance Data Maker"),
a64b872d 47 fMaxRawVar(0),
097485c2 48 fqadm(qadm),
49 fVarvalue(NULL)
a64b872d 50{
51 // ctor
57acd2d2 52 fCorrNt = new TNtupleD *[AliRecoParam::kNSpecies] ;
53 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++)
54 fCorrNt[specie] = NULL ;
a64b872d 55}
56
57//____________________________________________________________________________
58AliCorrQADataMakerRec::AliCorrQADataMakerRec(const AliCorrQADataMakerRec& qadm) :
e3ee6343 59 AliQADataMakerRec(qadm),
a64b872d 60 fMaxRawVar(qadm.fMaxRawVar),
097485c2 61 fqadm(qadm.fqadm),
62 fVarvalue(NULL)
a64b872d 63{
64 //copy ctor
e3ee6343 65 if ( fMaxRawVar > 0 ) {
097485c2 66 fVarvalue = new Double_t[fMaxRawVar] ;
e3ee6343 67 memcpy(fVarvalue, qadm.fVarvalue, fMaxRawVar*sizeof(Double_t));
68 }
4bb9542a 69
e3ee6343 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
4bb9542a 73 fCorrNt = new TNtupleD *[AliRecoParam::kNSpecies] ;
74 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++)
75 fCorrNt[specie] = qadm.fCorrNt[specie] ;
76
a64b872d 77}
78
79//__________________________________________________________________
80AliCorrQADataMakerRec& AliCorrQADataMakerRec::operator = (const AliCorrQADataMakerRec& qadm )
81{
57acd2d2 82 // assign operator.
e3ee6343 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 }
d9e3787d 100 return *this;
a64b872d 101}
57acd2d2 102
103//____________________________________________________________________________
104AliCorrQADataMakerRec::~AliCorrQADataMakerRec()
105{
e3ee6343 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 ;
57acd2d2 117}
118
a64b872d 119//____________________________________________________________________________
4e25ac79 120void AliCorrQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** /*list*/)
a64b872d 121{
122 //Detector specific actions at end of cycle
123 // do the QA checking
4e25ac79 124 if (task == AliQAv1::kRAWS) {
125 AliQAChecker::Instance()->Run(AliQAv1::kCORR, task, fCorrNt) ;
930e6e3e 126 }
a64b872d 127}
128
129//____________________________________________________________________________
130void AliCorrQADataMakerRec::InitESDs()
131{
132 //Create histograms to controll ESD
133
134 AliInfo("TO BE IMPLEMENTED") ;
92664bc8 135 //
136 ClonePerTrigClass(AliQAv1::kESDS); // this should be the last line
a64b872d 137}
138
a64b872d 139
140//____________________________________________________________________________
141void AliCorrQADataMakerRec::InitRaws()
142{
143 // createa ntuple taking all the parameters declared by detectors
4bb9542a 144 if (fCorrNt && fCorrNt[AliRecoParam::AConvert(fEventSpecie)])
a64b872d 145 return ;
4bb9542a 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
3136db6f 153 if ( fRawsQAList )
154 {
155 delete[] fRawsQAList ; // not needed for the time being
156 fRawsQAList = NULL ;
157 }
a64b872d 158 TString varlist("") ;
4e25ac79 159 for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++ ) {
a64b872d 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 ;
eca4fa66 167 while ( (p = static_cast<TParameter<double>*>(next()) ) ) {
a64b872d 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 {
025edd2a 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()) ;
097485c2 180 fVarvalue = new Double_t[fMaxRawVar] ;
a64b872d 181 }
92664bc8 182 //
183 ClonePerTrigClass(AliQAv1::kRAWS); // this should be the last line
a64b872d 184}
185
f14c8c46 186//____________________________________________________________________________
187void AliCorrQADataMakerRec::InitRecPoints()
188{
189 // create Reconstructed Points histograms in RecPoints subdir
190
191 AliInfo("TO BE IMPLEMENTED") ;
92664bc8 192 ClonePerTrigClass(AliQAv1::kRECPOINTS); // this should be the last line
f14c8c46 193}
194
195//____________________________________________________________________________
196void AliCorrQADataMakerRec::InitRecoParams()
197{
198 // Get the recoparam form the OCDB for every detector involved in CORR
199
200 AliInfo("TO BE IMPLEMENTED") ;
201}
202
a64b872d 203//____________________________________________________________________________
204void AliCorrQADataMakerRec::MakeESDs(AliESDEvent * /*esd*/)
205{
206 // make QA data from ESDs
207
208 AliInfo("TO BE IMPLEMENTED") ;
92664bc8 209 IncEvCountCycleESDs();
210 IncEvCountTotalESDs();
211 //
a64b872d 212}
213
214//____________________________________________________________________________
930e6e3e 215void AliCorrQADataMakerRec::MakeRaws(AliRawReader *)
a64b872d 216{
217 //Fill prepared histograms with Raw digit properties
025edd2a 218
4bb9542a 219 if ( !fCorrNt || ! fCorrNt[AliRecoParam::AConvert(fEventSpecie)])
025edd2a 220 InitRaws() ;
221
a64b872d 222 if ( fMaxRawVar > 0 ) {
a64b872d 223 Int_t index = 0 ;
4e25ac79 224 for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++ ) {
a64b872d 225 AliQADataMaker * qadm = fqadm[detIndex] ;
226 if ( ! qadm )
227 continue ;
228 TList * list = qadm->GetParameterList() ;
4bb9542a 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 }
a64b872d 240 }
241 }
097485c2 242 static_cast<TNtupleD*>(fCorrNt[AliRecoParam::AConvert(fEventSpecie)])->Fill(fVarvalue);
a64b872d 243 }
92664bc8 244 //
245 IncEvCountCycleRaws();
246 IncEvCountTotalRaws();
247 //
a64b872d 248}
249
250//____________________________________________________________________________
251void AliCorrQADataMakerRec::MakeRecPoints(TTree * /*clustersTree*/)
252{
253 AliInfo("TO BE IMPLEMENTED") ;
92664bc8 254 IncEvCountCycleRecPoints();
255 IncEvCountTotalRecPoints();
256 //
a64b872d 257}
258
259//____________________________________________________________________________
260void AliCorrQADataMakerRec::StartOfDetectorCycle()
261{
262 //Detector specific actions at start of cycle
930e6e3e 263
a64b872d 264}