Coverity fix.
[u/mrichter/AliRoot.git] / PHOS / AliPHOSQADataMakerSim.cxx
CommitLineData
04236e67 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
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 <TTree.h>
32
33// --- Standard library ---
34
35// --- AliRoot header files ---
36#include "AliESDCaloCluster.h"
37#include "AliLog.h"
38#include "AliPHOSDigit.h"
39#include "AliPHOSHit.h"
40#include "AliPHOSQADataMakerSim.h"
41#include "AliQAChecker.h"
42
43ClassImp(AliPHOSQADataMakerSim)
44
45//____________________________________________________________________________
8d8258f6 46AliPHOSQADataMakerSim::AliPHOSQADataMakerSim() :
6252ceeb 47 AliQADataMakerSim(AliQAv1::GetDetName(AliQAv1::kPHOS), "PHOS Quality Assurance Data Maker")
04236e67 48{
49 // ctor
50}
51
52//____________________________________________________________________________
53AliPHOSQADataMakerSim::AliPHOSQADataMakerSim(const AliPHOSQADataMakerSim& qadm) :
6252ceeb 54 AliQADataMakerSim()
04236e67 55{
56 //copy ctor
57 SetName((const char*)qadm.GetName()) ;
58 SetTitle((const char*)qadm.GetTitle());
59}
60
61//__________________________________________________________________
62AliPHOSQADataMakerSim& AliPHOSQADataMakerSim::operator = (const AliPHOSQADataMakerSim& qadm )
63{
64 // Assign operator.
65 this->~AliPHOSQADataMakerSim();
66 new(this) AliPHOSQADataMakerSim(qadm);
67 return *this;
68}
69
70//____________________________________________________________________________
4e25ac79 71void AliPHOSQADataMakerSim::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
04236e67 72{
73 //Detector specific actions at end of cycle
74 // do the QA checking
4e25ac79 75 AliQAChecker::Instance()->Run(AliQAv1::kPHOS, task, list) ;
04236e67 76}
77
78//____________________________________________________________________________
79void AliPHOSQADataMakerSim::InitHits()
80{
81 // create Hits histograms in Hits subdir
7d297381 82 const Bool_t expert = kTRUE ;
83 const Bool_t image = kTRUE ;
db72ff3b 84 TH1F * h0 = new TH1F("hPhosHits", "Hits energy distribution in PHOS;Energy [MeV];Counts", 100, 0., 100.) ;
04236e67 85 h0->Sumw2() ;
7d297381 86 Add2HitsList(h0, kHits, !expert, image) ;
db72ff3b 87 TH1I * h1 = new TH1I("hPhosHitsMul", "Hits multiplicity distribution in PHOS;# of Hits;Entries", 500, 0., 10000) ;
04236e67 88 h1->Sumw2() ;
7d297381 89 Add2HitsList(h1, kHitsMul, !expert, image) ;
92664bc8 90 //
91 ClonePerTrigClass(AliQAv1::kHITS); // this should be the last line
04236e67 92}
93
94//____________________________________________________________________________
95void AliPHOSQADataMakerSim::InitDigits()
96{
97 // create Digits histograms in Digits subdir
7d297381 98 const Bool_t expert = kTRUE ;
99 const Bool_t image = kTRUE ;
db72ff3b 100 TH1I * h0 = new TH1I("hPhosDigits", "Digits amplitude distribution in PHOS;Amplitude [ADC counts];Counts", 500, 0, 1000) ;
04236e67 101 h0->Sumw2() ;
7d297381 102 Add2DigitsList(h0, kDigits, !expert, image) ;
db72ff3b 103 TH1I * h1 = new TH1I("hPhosDigitsMul", "Digits multiplicity distribution in PHOS;# of Digits;Entries", 2000, 0, 10000) ;
04236e67 104 h1->Sumw2() ;
7d297381 105 Add2DigitsList(h1, kDigitsMul, !expert, image) ;
92664bc8 106 //
107 ClonePerTrigClass(AliQAv1::kDIGITS); // this should be the last line
04236e67 108}
109
110//____________________________________________________________________________
111void AliPHOSQADataMakerSim::InitSDigits()
112{
113 // create SDigits histograms in SDigits subdir
7d297381 114 const Bool_t expert = kTRUE ;
115 const Bool_t image = kTRUE ;
db72ff3b 116 TH1F * h0 = new TH1F("hPhosSDigits", "SDigits energy distribution in PHOS; Energy [MeV];Counts", 500, 0., 1000.) ;
04236e67 117 h0->Sumw2() ;
7d297381 118 Add2SDigitsList(h0, kSDigits, !expert, image) ;
db72ff3b 119 TH1I * h1 = new TH1I("hPhosSDigitsMul", "SDigits multiplicity distribution in PHOS;# of SDigits;Entries", 500, 0, 1000) ;
04236e67 120 h1->Sumw2() ;
7d297381 121 Add2SDigitsList(h1, kSDigitsMul, !expert, image) ;
92664bc8 122 //
123 ClonePerTrigClass(AliQAv1::kSDIGITS); // this should be the last line
04236e67 124}
125
126//____________________________________________________________________________
8d8258f6 127void AliPHOSQADataMakerSim::MakeHits()
04236e67 128{
8d8258f6 129 //make QA data from Hits
130
6252ceeb 131 TIter next(fHitsArray) ;
8d8258f6 132 AliPHOSHit * hit ;
133 while ( (hit = dynamic_cast<AliPHOSHit *>(next())) ) {
92664bc8 134 FillHitsData(kHits, hit->GetEnergy()) ;
8d8258f6 135 }
04236e67 136}
137
138//____________________________________________________________________________
139void AliPHOSQADataMakerSim::MakeHits(TTree * hitTree)
140{
8d8258f6 141 // make QA data from Hit Tree
142
6252ceeb 143 if (fHitsArray)
144 fHitsArray->Clear() ;
145 else
146 fHitsArray = new TClonesArray("AliPHOSHit", 1000);
147
8d8258f6 148 TBranch * branch = hitTree->GetBranch("PHOS") ;
92664bc8 149 if ( ! branch ) { AliWarning("PHOS branch in Hit Tree not found"); return;}
150 //
151 Int_t nHits = 0;
152 branch->SetAddress(&fHitsArray) ;
153 for (Int_t ientry = 0 ; ientry < branch->GetEntries() ; ientry++) {
154 branch->GetEntry(ientry) ;
155 nHits += fHitsArray->GetEntriesFast();
156 MakeHits() ;
157 fHitsArray->Clear();
158 }
159 FillHitsData(1,nHits) ;
160 //
161 IncEvCountCycleHits();
162 IncEvCountTotalHits();
163 //
04236e67 164}
165
166//____________________________________________________________________________
6252ceeb 167void AliPHOSQADataMakerSim::MakeDigits()
04236e67 168{
169 // makes data from Digits
6252ceeb 170
92664bc8 171 FillDigitsData(1,fDigitsArray->GetEntriesFast()) ;
6252ceeb 172 TIter next(fDigitsArray) ;
173 AliPHOSDigit * digit ;
174 while ( (digit = dynamic_cast<AliPHOSDigit *>(next())) ) {
92664bc8 175 FillDigitsData(kDigits, digit->GetEnergy()) ;
6252ceeb 176 }
04236e67 177}
178
179//____________________________________________________________________________
180void AliPHOSQADataMakerSim::MakeDigits(TTree * digitTree)
181{
92664bc8 182 // makes data from Digit Tree
183 if (fDigitsArray)
6252ceeb 184 fDigitsArray->Clear() ;
185 else
186 fDigitsArray = new TClonesArray("AliPHOSDigit", 1000) ;
92664bc8 187
188 TBranch * branch = digitTree->GetBranch("PHOS") ;
189 if ( ! branch ) {AliWarning("PHOS branch in Digit Tree not found"); return;}
190 branch->SetAddress(&fDigitsArray) ;
191 branch->GetEntry(0) ;
192 MakeDigits() ;
193 //
194 IncEvCountCycleDigits();
195 IncEvCountTotalDigits();
196 //
04236e67 197}
198
199//____________________________________________________________________________
6252ceeb 200void AliPHOSQADataMakerSim::MakeSDigits()
04236e67 201{
202 // makes data from SDigits
eca4fa66 203
92664bc8 204 FillSDigitsData(1,fSDigitsArray->GetEntriesFast()) ;
6252ceeb 205 TIter next(fSDigitsArray) ;
eca4fa66 206 AliPHOSDigit * sdigit ;
207 while ( (sdigit = dynamic_cast<AliPHOSDigit *>(next())) ) {
92664bc8 208 FillSDigitsData(kSDigits, sdigit->GetEnergy()) ;
eca4fa66 209 }
04236e67 210}
211
212//____________________________________________________________________________
213void AliPHOSQADataMakerSim::MakeSDigits(TTree * sdigitTree)
214{
215 // makes data from SDigit Tree
92664bc8 216 if (fSDigitsArray)
6252ceeb 217 fSDigitsArray->Clear() ;
218 else
219 fSDigitsArray = new TClonesArray("AliPHOSDigit", 1000) ;
220
92664bc8 221 TBranch * branch = sdigitTree->GetBranch("PHOS") ;
222 if ( ! branch ) {AliWarning("PHOS branch in SDigit Tree not found"); return;}
223 branch->SetAddress(&fSDigitsArray) ;
224 branch->GetEntry(0) ;
225 MakeSDigits() ;
226 //
227 IncEvCountCycleSDigits();
228 IncEvCountTotalSDigits();
229 //
04236e67 230}
231
232//____________________________________________________________________________
233void AliPHOSQADataMakerSim::StartOfDetectorCycle()
234{
235 //Detector specific actions at start of cycle
236
237}