1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
21 // Produces the data needed to calculate the quality assurance.
22 // All data must be mergeable objects.
23 // Y. Schutz CERN July 2007
26 // --- ROOT system ---
31 #include <TClonesArray.h>
32 #include <TParameter.h>
44 // --- Standard library ---
46 // --- AliRoot header files ---
48 #include "AliQADataMaker.h"
49 #include "AliQAChecker.h"
50 #include "AliESDEvent.h"
51 #include "AliRawReader.h"
52 #include "AliDetectorRecoParam.h"
55 ClassImp(AliQADataMaker)
57 //____________________________________________________________________________
58 AliQADataMaker::AliQADataMaker(const char * name, const char * title) :
67 fParameterList(new TList*[AliRecoParam::kNSpecies]),
69 fEventSpecie(AliRecoParam::kDefault)
72 fDetectorDirName = GetName() ;
73 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++)
74 fParameterList[specie] = NULL ;
77 //____________________________________________________________________________
78 AliQADataMaker::AliQADataMaker(const AliQADataMaker& qadm) :
79 TNamed(qadm.GetName(), qadm.GetTitle()),
80 fOutput(qadm.fOutput),
81 fDetectorDir(qadm.fDetectorDir),
82 fDetectorDirName(qadm.fDetectorDirName),
83 fCurrentCycle(qadm.fCurrentCycle),
85 fCycleCounter(qadm.fCycleCounter),
86 fWriteExpert(qadm.fWriteExpert),
87 fParameterList(qadm.fParameterList),
89 fEventSpecie(qadm.fEventSpecie)
92 fDetectorDirName = GetName() ;
95 //____________________________________________________________________________
96 Int_t AliQADataMaker::Add2List(TH1 * hist, const Int_t index, TObjArray ** list, const Bool_t expert, const Bool_t image, const Bool_t saveForCorr)
98 // Set histograms memory resident and add to the list
99 // Maximm allowed is 10000
102 TClass * classType = hist->Class() ;
103 TString className(classType->GetName()) ;
104 if( ! className.BeginsWith("T") && ! classType->InheritsFrom("TH1") ) {
105 AliError(Form("QA data Object must be a generic ROOT object and derive fom TH1 and not %s", className.Data())) ;
106 } else if ( index > 10000 ) {
107 AliError("Max number of authorized QA objects is 10000") ;
110 hist->SetBit(AliQAv1::GetExpertBit()) ;
112 hist->SetBit(AliQAv1::GetImageBit()) ;
113 TH1 * histClone[AliRecoParam::kNSpecies] ;
114 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
115 histClone[specie] = CloneMe(hist, specie) ;
116 histClone[specie]->SetDirectory(0) ;
117 list[specie]->AddAtAndExpand(histClone[specie], index) ;
119 char * name = Form("%s_%s", list[AliRecoParam::AConvert(AliRecoParam::kDefault)]->GetName(), hist->GetName()) ;
120 TParameter<double> * p = new TParameter<double>(name, 9999.9999) ;
121 if ( fParameterList[specie] == NULL )
122 fParameterList[specie] = new TList() ;
123 fParameterList[specie]->Add(p) ;
126 rv = list[AliRecoParam::kDefault]->GetLast() ;
132 //____________________________________________________________________________
133 TH1 * AliQADataMaker::CloneMe(TH1 * hist, Int_t specie) const
135 // clones a histogram
136 char * name = Form("%s_%s", AliRecoParam::GetEventSpecieName(specie), hist->GetName()) ;
137 TH1 * hClone = dynamic_cast<TH1 *>(hist->Clone(name)) ;
138 if ( hist->TestBit(AliQAv1::GetExpertBit()) )
139 hClone->SetBit(AliQAv1::GetExpertBit()) ;
140 if ( hist->TestBit(AliQAv1::GetImageBit()) )
141 hClone->SetBit(AliQAv1::GetImageBit()) ;
145 //____________________________________________________________________________
146 void AliQADataMaker::DefaultEndOfDetectorCycle(AliQAv1::TASKINDEX_t task)
148 // this method must be oveloaded by detectors
149 // sets the QA result to Fatal
150 AliQAv1::Instance(AliQAv1::GetDetIndex(GetName())) ;
151 AliQAv1 * qa = AliQAv1::Instance(task) ;
152 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++)
153 qa->Set(AliQAv1::kFATAL, specie) ;
154 AliQAv1::GetQAResultFile()->cd() ;
155 qa->Write(AliQAv1::GetQAName(), kWriteDelete) ;
156 AliQAv1::GetQAResultFile()->Close() ;
159 //____________________________________________________________________________
160 void AliQADataMaker::Finish() const
162 // write to the output File
167 //____________________________________________________________________________
168 TObject * AliQADataMaker::GetData(TObjArray ** list, const Int_t index)
170 // Returns the QA object at index. Limit is 100.
172 AliError("Data list is NULL !!") ;
176 SetEventSpecie(fEventSpecie) ;
177 if ( GetRecoParam() ) {
178 if ( AliRecoParam::Convert(GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault) {
179 SetEventSpecie(GetRecoParam()->GetEventSpecie()) ;
181 AliError(Form("Event Specie from RecoParam of %s is = %d\n", GetName(), fEventSpecie));
184 if (list[AliRecoParam::AConvert(fEventSpecie)]) {
185 if ( index > 10000 ) {
186 AliError("Max number of authorized QA objects is 10000") ;
189 Int_t esindex = AliRecoParam::AConvert(fEventSpecie) ;
190 return list[esindex]->At(index) ;
193 AliError("Data list is NULL !!") ;