Introducing event specie in QA (Yves)
[u/mrichter/AliRoot.git] / TPC / AliTPCQADataMakerSim.cxx
CommitLineData
44f32dd2 1/**************************************************************************
2 * Copyright(c) 1998-2007, 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 Based on AliPHOSQADataMaker
21 Produces the data needed to calculate the quality assurance.
22 All data must be mergeable objects.
23 P. Christiansen, Lund, January 2008
24*/
25
26/*
27 Implementation:
28
29 We have chosen to have the histograms as non-persistent meber to
30 allow better debugging. In the copy constructor we then have to
31 assign the pointers to the existing histograms in the copied
32 list. This have been implemented but not tested.
33*/
34
35#include "AliTPCQADataMakerSim.h"
36
37// --- ROOT system ---
38
39// --- Standard library ---
40
41// --- AliRoot header files ---
42#include "AliQAChecker.h"
44f32dd2 43#include "AliTPC.h"
44#include "AliTPCv2.h"
45#include "AliSimDigits.h"
46
47ClassImp(AliTPCQADataMakerSim)
48
49//____________________________________________________________________________
50AliTPCQADataMakerSim::AliTPCQADataMakerSim() :
51 AliQADataMakerSim(AliQA::GetDetName(AliQA::kTPC),
57acd2d2 52 "TPC Sim Quality Assurance Data Maker")
44f32dd2 53{
54 // ctor
55}
56
57//____________________________________________________________________________
58AliTPCQADataMakerSim::AliTPCQADataMakerSim(const AliTPCQADataMakerSim& qadm) :
57acd2d2 59 AliQADataMakerSim()
44f32dd2 60{
61 //copy ctor
62 SetName((const char*)qadm.GetName()) ;
63 SetTitle((const char*)qadm.GetTitle());
64
65 //
66 // Associate class histogram objects to the copies in the list
67 // Could also be done with the indexes
68 //
57acd2d2 69 }
44f32dd2 70
71//__________________________________________________________________
72AliTPCQADataMakerSim& AliTPCQADataMakerSim::operator = (const AliTPCQADataMakerSim& qadm )
73{
74 // Equal operator.
75 this->~AliTPCQADataMakerSim();
76 new(this) AliTPCQADataMakerSim(qadm);
77 return *this;
78}
79
80//____________________________________________________________________________
57acd2d2 81void AliTPCQADataMakerSim::EndOfDetectorCycle(AliQA::TASKINDEX_t task, TObjArray ** list)
44f32dd2 82{
83 //Detector specific actions at end of cycle
84 // do the QA checking
85 AliQAChecker::Instance()->Run(AliQA::kTPC, task, list) ;
86}
87
88//____________________________________________________________________________
89void AliTPCQADataMakerSim::InitDigits()
90{
57acd2d2 91 TH1F * histDigitsADC =
44f32dd2 92 new TH1F("hDigitsADC", "Digit ADC distribution; ADC; Counts",
93 1000, 0, 1000);
57acd2d2 94 histDigitsADC->Sumw2();
95 Add2DigitsList(histDigitsADC, kDigitsADC);
44f32dd2 96}
97
98//____________________________________________________________________________
99void AliTPCQADataMakerSim::InitHits()
100{
57acd2d2 101 TH1F * histHitsNhits =
44f32dd2 102 new TH1F("hHitsNhits", "Interactions per primary track in the TPC volume; Number of primary interactions; Counts",
103 100, 0, 10000);
57acd2d2 104 histHitsNhits->Sumw2();
105 Add2HitsList(histHitsNhits, kNhits);
44f32dd2 106
57acd2d2 107 TH1F * histHitsElectrons =
44f32dd2 108 new TH1F("hHitsElectrons", "Electrons per interaction (primaries); Electrons; Counts",
109 300, 0, 300);
57acd2d2 110 histHitsElectrons->Sumw2();
111 Add2HitsList(histHitsElectrons, kElectrons);
44f32dd2 112
57acd2d2 113 TH1F * histHitsRadius =
44f32dd2 114 new TH1F("hHitsRadius", "Position of interaction (Primary tracks only); Radius; Counts",
115 300, 0., 300.);
57acd2d2 116 histHitsRadius->Sumw2();
117 Add2HitsList(histHitsRadius, kRadius);
44f32dd2 118
57acd2d2 119 TH1F * histHitsPrimPerCm =
44f32dd2 120 new TH1F("hHitsPrimPerCm", "Primaries per cm (Primary tracks only); Primaries; Counts",
121 100, 0., 100.);
57acd2d2 122 histHitsPrimPerCm->Sumw2();
123 Add2HitsList(histHitsPrimPerCm, kPrimPerCm);
44f32dd2 124
57acd2d2 125 TH1F * histHitsElectronsPerCm =
44f32dd2 126 new TH1F("hHitsElectronsPerCm", "Electrons per cm (Primary tracks only); Electrons; Counts",
127 300, 0., 300.);
57acd2d2 128 histHitsElectronsPerCm->Sumw2();
129 Add2HitsList(histHitsElectronsPerCm, kElectronsPerCm);
44f32dd2 130}
131
132//____________________________________________________________________________
133void AliTPCQADataMakerSim::MakeDigits(TTree* digitTree)
134{
135 TBranch* branch = digitTree->GetBranch("Segment");
136 AliSimDigits* digArray = 0;
137 branch->SetAddress(&digArray);
138
139 Int_t nEntries = Int_t(digitTree->GetEntries());
140
141 for (Int_t n = 0; n < nEntries; n++) {
142
143 digitTree->GetEvent(n);
144
145 if (digArray->First())
146 do {
57acd2d2 147 Float_t dig = digArray->CurrentDigit();
44f32dd2 148
57acd2d2 149 GetDigitsData(kDigitsADC)->Fill(dig);
44f32dd2 150 } while (digArray->Next());
151 }
152}
153
154//____________________________________________________________________________
155void AliTPCQADataMakerSim::MakeHits(TTree * hitTree)
156{
157 // make QA data from Hit Tree
158 const Int_t nTracks = hitTree->GetEntries();
0ae34bb1 159 TBranch* branch = hitTree->GetBranch("TPC");
44f32dd2 160 AliTPCv2* tpc = (AliTPCv2*)gAlice->GetDetector("TPC");
1546352e 161
44f32dd2 162 //
163 // loop over tracks
164 //
165 for(Int_t n = 0; n < nTracks; n++){
44f32dd2 166 Int_t nHits = 0;
167 branch->GetEntry(n);
44f32dd2 168
1546352e 169 AliTPChit* tpcHit = (AliTPChit*)tpc->FirstHit(-1);
44f32dd2 170
1546352e 171 if (tpcHit) {
172 Float_t dist = 0.;
173 Int_t nprim = 0;
174 Float_t xold = tpcHit->X();
175 Float_t yold = tpcHit->Y();
176 Float_t zold = tpcHit->Z();
177 Float_t radiusOld = TMath::Sqrt(xold*xold + yold*yold);
178 Float_t q = 0.;
179 while(tpcHit) {
57acd2d2 180 Float_t x = tpcHit->X();
181 Float_t y = tpcHit->Y();
182 Float_t z = tpcHit->Z();
183 Float_t radius = TMath::Sqrt(x*x + y*y);
44f32dd2 184
57acd2d2 185 if(radius>50) { // Skip hits at interaction point
44f32dd2 186
57acd2d2 187 nHits++;
44f32dd2 188
57acd2d2 189 Int_t trackNo = tpcHit->GetTrack();
1546352e 190
57acd2d2 191 if(trackNo==n) { // primary track
44f32dd2 192
57acd2d2 193 GetDigitsData(kElectrons)->Fill(tpcHit->fQ);
194 GetDigitsData(kRadius)->Fill(radius);
44f32dd2 195
57acd2d2 196 // find the new distance
197 dist += TMath::Sqrt((x-xold)*(x-xold) + (y-yold)*(y-yold) +
198 (z-zold)*(z-zold));
199 if(dist<1.){
200 // add data to this 1 cm step
201 nprim++;
202 q += tpcHit->fQ;
1546352e 203
57acd2d2 204 } else{
205 // Fill the histograms normalized to per cm
1546352e 206
57acd2d2 207 if(nprim==1)
208 cout << radius << ", " << radiusOld << ", " << dist << endl;
1546352e 209
57acd2d2 210 GetDigitsData(kPrimPerCm)->Fill((Float_t)nprim);
211 GetDigitsData(kElectronsPerCm)->Fill(q);
1546352e 212
57acd2d2 213 dist = 0;
214 q = 0;
215 nprim = 0;
216 }
217 }
218 }
1546352e 219
57acd2d2 220 radiusOld = radius;
221 xold = x;
222 yold = y;
223 zold = z;
1546352e 224
57acd2d2 225 tpcHit = (AliTPChit*) tpc->NextHit();
226 }
44f32dd2 227 }
57acd2d2 228 GetDigitsData(kNhits)->Fill(nHits);
44f32dd2 229 }
44f32dd2 230 }
44f32dd2 231