]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliQADataMaker.cxx
set the bits correctly
[u/mrichter/AliRoot.git] / STEER / AliQADataMaker.cxx
CommitLineData
421ab0fb 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
202374b1 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//
421ab0fb 25
26// --- ROOT system ---
27#include <TSystem.h>
28#include <TFile.h>
6c18591a 29#include <TList.h>
d76c31f4 30#include <TTree.h>
d5cf81bd 31#include <TClonesArray.h>
a2b64fbd 32#include <TParameter.h>
57acd2d2 33#include <TH1K.h>
34#include <TH2C.h>
35#include <TH2D.h>
36#include <TH2F.h>
37#include <TH2I.h>
38#include <TH3C.h>
39#include <TH3D.h>
40#include <TH3F.h>
41#include <TH3I.h>
42#include <TH3S.h>
421ab0fb 43
44// --- Standard library ---
45
46// --- AliRoot header files ---
47#include "AliLog.h"
2e42b4d4 48#include "AliQADataMaker.h"
49#include "AliQAChecker.h"
d76c31f4 50#include "AliESDEvent.h"
d5cf81bd 51#include "AliRawReader.h"
421ab0fb 52
2e42b4d4 53ClassImp(AliQADataMaker)
312e6f8d 54
421ab0fb 55//____________________________________________________________________________
2e42b4d4 56AliQADataMaker::AliQADataMaker(const char * name, const char * title) :
421ab0fb 57 TNamed(name, title),
58 fOutput(0x0),
6c18591a 59 fDetectorDir(0x0),
312e6f8d 60 fDetectorDirName(""),
930e6e3e 61 fCurrentCycle(0),
5b188f2f 62 fCycle(9999999),
63 fCycleCounter(0),
b1af1125 64 fWriteExpert(kFALSE),
57acd2d2 65 fParameterList(new TList*[AliRecoParam::kNSpecies]),
66 fRun(0),
67 fEventSpecie(AliRecoParam::kDefault)
421ab0fb 68{
69 // ctor
421ab0fb 70 fDetectorDirName = GetName() ;
57acd2d2 71 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++)
72 fParameterList[specie] = NULL ;
421ab0fb 73}
74
75//____________________________________________________________________________
2e42b4d4 76AliQADataMaker::AliQADataMaker(const AliQADataMaker& qadm) :
421ab0fb 77 TNamed(qadm.GetName(), qadm.GetTitle()),
78 fOutput(qadm.fOutput),
6c18591a 79 fDetectorDir(qadm.fDetectorDir),
312e6f8d 80 fDetectorDirName(qadm.fDetectorDirName),
5b188f2f 81 fCurrentCycle(qadm.fCurrentCycle),
82 fCycle(qadm.fCycle),
83 fCycleCounter(qadm.fCycleCounter),
b1af1125 84 fWriteExpert(qadm.fWriteExpert),
a2b64fbd 85 fParameterList(qadm.fParameterList),
57acd2d2 86 fRun(qadm.fRun),
87 fEventSpecie(qadm.fEventSpecie)
421ab0fb 88{
89 //copy ctor
90 fDetectorDirName = GetName() ;
91}
92
ba7aca7d 93//____________________________________________________________________________
7d297381 94Int_t AliQADataMaker::Add2List(TH1 * hist, const Int_t index, TObjArray ** list, const Bool_t expert, const Bool_t image, const Bool_t saveForCorr)
ba7aca7d 95{
04236e67 96 // Set histograms memory resident and add to the list
ab4351aa 97 // Maximm allowed is 10000
57acd2d2 98
99 Int_t rv = -1 ;
100 TClass * classType = hist->Class() ;
101 TString className(classType->GetName()) ;
102 if( ! className.BeginsWith("T") && ! classType->InheritsFrom("TH1") ) {
103 AliError(Form("QA data Object must be a generic ROOT object and derive fom TH1 and not %s", className.Data())) ;
104 } else if ( index > 10000 ) {
ab4351aa 105 AliError("Max number of authorized QA objects is 10000") ;
57acd2d2 106 } else {
750730d8 107 if (expert)
7d297381 108 hist->SetBit(AliQAv1::GetExpertBit()) ;
109 if (image)
110 hist->SetBit(AliQAv1::GetImageBit()) ;
111 TH1 * histClone[AliRecoParam::kNSpecies] ;
57acd2d2 112 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
113 histClone[specie] = CloneMe(hist, specie) ;
114 histClone[specie]->SetDirectory(0) ;
115 list[specie]->AddAtAndExpand(histClone[specie], index) ;
116 if(saveForCorr) {
117 char * name = Form("%s_%s", list[AliRecoParam::kDefault]->GetName(), hist->GetName()) ;
118 TParameter<double> * p = new TParameter<double>(name, 9999.9999) ;
119 if ( fParameterList[specie] == NULL )
120 fParameterList[specie] = new TList() ;
121 fParameterList[specie]->Add(p) ;
122 }
a2b64fbd 123 }
57acd2d2 124 rv = list[AliRecoParam::kDefault]->GetLast() ;
a2b64fbd 125 }
57acd2d2 126 delete hist ;
127 return rv ;
128}
129
130//____________________________________________________________________________
131TH1 * AliQADataMaker::CloneMe(TH1 * hist, Int_t specie) const
132{
133 // clones a histogram
134 char * name = Form("%s_%s", AliRecoParam::GetEventSpecieName(specie), hist->GetName()) ;
75373542 135 TH1 * hClone = dynamic_cast<TH1 *>(hist->Clone(name)) ;
4e25ac79 136 if ( hist->TestBit(AliQAv1::GetExpertBit()) )
b2db43c5 137 hClone->SetBit(AliQAv1::GetExpertBit()) ;
138 if ( hist->TestBit(AliQAv1::GetImageBit()) )
139 hClone->SetBit(AliQAv1::GetImageBit()) ;
75373542 140 return hClone ;
421ab0fb 141}
142
96d67a8d 143//____________________________________________________________________________
4e25ac79 144void AliQADataMaker::DefaultEndOfDetectorCycle(AliQAv1::TASKINDEX_t task)
96d67a8d 145{
146 // this method must be oveloaded by detectors
147 // sets the QA result to Fatal
4e25ac79 148 AliQAv1::Instance(AliQAv1::GetDetIndex(GetName())) ;
149 AliQAv1 * qa = AliQAv1::Instance(task) ;
57acd2d2 150 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++)
4e25ac79 151 qa->Set(AliQAv1::kFATAL, specie) ;
152 AliQAv1::GetQAResultFile()->cd() ;
153 qa->Write(AliQAv1::GetQAName(), kWriteDelete) ;
154 AliQAv1::GetQAResultFile()->Close() ;
96d67a8d 155}
156
421ab0fb 157//____________________________________________________________________________
c65c502a 158void AliQADataMaker::Finish() const
421ab0fb 159{
96d67a8d 160 // write to the output File
d9cbd8fd 161 if (fOutput)
162 fOutput->Close() ;
421ab0fb 163}
164
165//____________________________________________________________________________
57acd2d2 166TObject * AliQADataMaker::GetData(TObjArray ** list, const Int_t index)
04236e67 167{
168 // Returns the QA object at index. Limit is 100.
76c42cb4 169 if ( ! list ) {
170 AliError("Data list is NULL !!") ;
171 return NULL ;
172 }
57acd2d2 173 if (list[AliRecoParam::AConvert(fEventSpecie)]) {
27773260 174 if ( index > 10000 ) {
175 AliError("Max number of authorized QA objects is 10000") ;
176 return NULL ;
177 } else {
57acd2d2 178 Int_t esindex = AliRecoParam::AConvert(fEventSpecie) ;
179 return list[esindex]->At(index) ;
27773260 180 }
57acd2d2 181 } else {
27773260 182 AliError("Data list is NULL !!") ;
183 return NULL ;
04236e67 184 }
27773260 185}
7d297381 186