coverity
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALQADataMakerSim.cxx
CommitLineData
94594e5d 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 Produces the data needed to calculate the quality assurance.
18 All data must be mergeable objects.
19
20 Based on PHOS code written by
21 Y. Schutz CERN July 2007
22*/
23
24// --- ROOT system ---
25#include <TClonesArray.h>
26#include <TFile.h>
27#include <TH1F.h>
28#include <TH1I.h>
29#include <TH2F.h>
30#include <TTree.h>
31
32// --- Standard library ---
33
34// --- AliRoot header files ---
35#include "AliESDCaloCluster.h"
36#include "AliLog.h"
37#include "AliEMCALDigit.h"
38#include "AliEMCALHit.h"
39#include "AliEMCALQADataMakerSim.h"
40#include "AliQAChecker.h"
601c73e3 41#include "AliEMCALSDigitizer.h"
94594e5d 42
43ClassImp(AliEMCALQADataMakerSim)
44
45//____________________________________________________________________________
46 AliEMCALQADataMakerSim::AliEMCALQADataMakerSim() :
4e25ac79 47 AliQADataMakerSim(AliQAv1::GetDetName(AliQAv1::kEMCAL), "EMCAL Quality Assurance Data Maker")
94594e5d 48{
49 // ctor
50}
51
52//____________________________________________________________________________
53AliEMCALQADataMakerSim::AliEMCALQADataMakerSim(const AliEMCALQADataMakerSim& qadm) :
54 AliQADataMakerSim()
55{
56 //copy ctor
57 SetName((const char*)qadm.GetName()) ;
58 SetTitle((const char*)qadm.GetTitle());
59}
60
61//__________________________________________________________________
62AliEMCALQADataMakerSim& AliEMCALQADataMakerSim::operator = (const AliEMCALQADataMakerSim& qadm )
63{
64 // Assign operator.
65 this->~AliEMCALQADataMakerSim();
66 new(this) AliEMCALQADataMakerSim(qadm);
67 return *this;
68}
69
70//____________________________________________________________________________
4e25ac79 71void AliEMCALQADataMakerSim::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
94594e5d 72{
73 //Detector specific actions at end of cycle
74 // do the QA checking
92664bc8 75 ResetEventTrigClasses(); // reset triggers list to select all histos
4e25ac79 76 AliQAChecker::Instance()->Run(AliQAv1::kEMCAL, task, list) ;
94594e5d 77}
78
79//____________________________________________________________________________
80void AliEMCALQADataMakerSim::InitHits()
81{
82 // create Hits histograms in Hits subdir
7d297381 83 const Bool_t expert = kTRUE ;
84 const Bool_t image = kTRUE ;
85
db72ff3b 86 TH1F * h0 = new TH1F("hEmcalHits", "Hits energy distribution in EMCAL;Energy [MeV];Counts", 200, 0., 2.) ; //GeV
94594e5d 87 h0->Sumw2() ;
7d297381 88 Add2HitsList(h0, 0, !expert, image) ;
db72ff3b 89 TH1I * h1 = new TH1I("hEmcalHitsMul", "Hits multiplicity distribution in EMCAL;# of Hits;Entries", 1000, 0, 10000) ;
94594e5d 90 h1->Sumw2() ;
7d297381 91 Add2HitsList(h1, 1, !expert, image) ;
92664bc8 92 //
93 ClonePerTrigClass(AliQAv1::kHITS); // this should be the last line
94594e5d 94}
95
96//____________________________________________________________________________
97void AliEMCALQADataMakerSim::InitDigits()
98{
99 // create Digits histograms in Digits subdir
7d297381 100 const Bool_t expert = kTRUE ;
101 const Bool_t image = kTRUE ;
102
db72ff3b 103 TH1I * h0 = new TH1I("hEmcalDigits", "Digits amplitude distribution in EMCAL;Amplitude [ADC counts];Counts", 500, 0, 500) ;
94594e5d 104 h0->Sumw2() ;
7d297381 105 Add2DigitsList(h0, 0, !expert, image) ;
db72ff3b 106 TH1I * h1 = new TH1I("hEmcalDigitsMul", "Digits multiplicity distribution in EMCAL;# of Digits;Entries", 200, 0, 2000) ;
94594e5d 107 h1->Sumw2() ;
7d297381 108 Add2DigitsList(h1, 1, !expert, image) ;
92664bc8 109 //
110 ClonePerTrigClass(AliQAv1::kDIGITS); // this should be the last line
94594e5d 111}
112
113//____________________________________________________________________________
114void AliEMCALQADataMakerSim::InitSDigits()
115{
116 // create SDigits histograms in SDigits subdir
7d297381 117 const Bool_t expert = kTRUE ;
118 const Bool_t image = kTRUE ;
119
db72ff3b 120 TH1F * h0 = new TH1F("hEmcalSDigits", "SDigits energy distribution in EMCAL;Energy [MeV];Counts", 200, 0., 20.) ;
94594e5d 121 h0->Sumw2() ;
7d297381 122 Add2SDigitsList(h0, 0, !expert, image) ;
db72ff3b 123 TH1I * h1 = new TH1I("hEmcalSDigitsMul", "SDigits multiplicity distribution in EMCAL;# of SDigits;Entries", 500, 0, 5000) ;
94594e5d 124 h1->Sumw2() ;
7d297381 125 Add2SDigitsList(h1, 1, !expert, image) ;
92664bc8 126 //
127 ClonePerTrigClass(AliQAv1::kSDIGITS); // this should be the last line
94594e5d 128}
129
130//____________________________________________________________________________
6252ceeb 131void AliEMCALQADataMakerSim::MakeHits()
94594e5d 132{
133 //make QA data from Hits
6252ceeb 134
92664bc8 135 FillHitsData(1,fHitsArray->GetEntriesFast()) ;
6252ceeb 136 TIter next(fHitsArray) ;
94594e5d 137 AliEMCALHit * hit ;
138 while ( (hit = dynamic_cast<AliEMCALHit *>(next())) ) {
92664bc8 139 FillHitsData(0, hit->GetEnergy()) ;
94594e5d 140 }
94594e5d 141}
142
143//____________________________________________________________________________
144void AliEMCALQADataMakerSim::MakeHits(TTree * hitTree)
145{
146 // make QA data from Hit Tree
6252ceeb 147 if (fHitsArray)
148 fHitsArray->Clear() ;
149 else
150 fHitsArray = new TClonesArray("AliEMCALHit", 1000);
94594e5d 151
152 TBranch * branch = hitTree->GetBranch("EMCAL") ;
92664bc8 153 if ( ! branch ) { AliWarning("EMCAL branch in Hit Tree not found") ; return;}
154 //
155 branch->SetAddress(&fHitsArray) ;
156 for (Int_t ientry = 0 ; ientry < branch->GetEntries() ; ientry++) {
157 branch->GetEntry(ientry) ;
158 MakeHits() ;
159 fHitsArray->Clear() ;
94594e5d 160 }
92664bc8 161 IncEvCountCycleHits();
162 IncEvCountTotalHits();
163 //
94594e5d 164}
165
166//____________________________________________________________________________
6252ceeb 167void AliEMCALQADataMakerSim::MakeDigits()
94594e5d 168{
169 // makes data from Digits
92664bc8 170
171 FillDigitsData(1,fDigitsArray->GetEntriesFast()) ;
6252ceeb 172 TIter next(fDigitsArray) ;
94594e5d 173 AliEMCALDigit * digit ;
174 while ( (digit = dynamic_cast<AliEMCALDigit *>(next())) ) {
92664bc8 175 FillDigitsData(0, digit->GetAmp()) ;
94594e5d 176 }
94594e5d 177}
178
179//____________________________________________________________________________
180void AliEMCALQADataMakerSim::MakeDigits(TTree * digitTree)
181{
182 // makes data from Digit Tree
92664bc8 183
6252ceeb 184 if (fDigitsArray)
e0dc3f7d 185 fDigitsArray->Clear("C") ;
6252ceeb 186 else
187 fDigitsArray = new TClonesArray("AliEMCALDigit", 1000) ;
94594e5d 188
189 TBranch * branch = digitTree->GetBranch("EMCAL") ;
92664bc8 190 if ( ! branch ) { AliWarning("EMCAL branch in Digit Tree not found") ; return; }
191 //
192 branch->SetAddress(&fDigitsArray) ;
193 branch->GetEntry(0) ;
194 MakeDigits() ;
195 //
196 IncEvCountCycleDigits();
197 IncEvCountTotalDigits();
94594e5d 198}
199
200//____________________________________________________________________________
6252ceeb 201void AliEMCALQADataMakerSim::MakeSDigits()
94594e5d 202{
203 // makes data from SDigits
601c73e3 204 //Need a copy of the SDigitizer to calibrate the sdigit amplitude to
205 //energy in GeV
6252ceeb 206
601c73e3 207 AliEMCALSDigitizer* sDigitizer = new AliEMCALSDigitizer();
208
92664bc8 209 FillSDigitsData(1,fSDigitsArray->GetEntriesFast()) ;
6252ceeb 210 TIter next(fSDigitsArray) ;
94594e5d 211 AliEMCALDigit * sdigit ;
212 while ( (sdigit = dynamic_cast<AliEMCALDigit *>(next())) ) {
92664bc8 213 FillSDigitsData(0, sDigitizer->Calibrate(sdigit->GetAmp())) ;
94594e5d 214 }
601c73e3 215 delete sDigitizer;
94594e5d 216}
217
218//____________________________________________________________________________
219void AliEMCALQADataMakerSim::MakeSDigits(TTree * sdigitTree)
220{
221 // makes data from SDigit Tree
6252ceeb 222 if (fSDigitsArray)
e0dc3f7d 223 fSDigitsArray->Clear("C") ;
6252ceeb 224 else
225 fSDigitsArray = new TClonesArray("AliEMCALDigit", 1000) ;
94594e5d 226
227 TBranch * branch = sdigitTree->GetBranch("EMCAL") ;
92664bc8 228 if ( ! branch ) { AliWarning("EMCAL branch in SDigit Tree not found"); return;}
229 //
230 branch->SetAddress(&fSDigitsArray);
231 branch->GetEntry(0);
232 MakeSDigits();
233 //
234 IncEvCountCycleSDigits();
235 IncEvCountTotalSDigits();
236 //
94594e5d 237}
238
239//____________________________________________________________________________
240void AliEMCALQADataMakerSim::StartOfDetectorCycle()
241{
242 //Detector specific actions at start of cycle
243
244}