Changes related to the extraction of the V0 finder into a separate class (A. Dainese...
[u/mrichter/AliRoot.git] / ITS / AliITSQASSDDataMakerSim.cxx
CommitLineData
7a0e5776 1/**************************************************************************
2 * Copyright(c) 2007-2009, 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/* $Id$ */
17
18// *************************************************************
19// Checks the quality assurance
20// by comparing with reference data
21// contained in a DB
22// -------------------------------------------------------------
23// W. Ferrarese + P. Cerello Feb 2008
24// INFN Torino
25// SSD QA part: P. Christakoglou - NIKHEF/UU
26
27// --- ROOT system ---
28#include <TTree.h>
29#include <TH1.h>
30#include <TH2.h>
31#include <TMath.h>
32// --- Standard library ---
33
34// --- AliRoot header files ---
35#include "AliITS.h"
36#include "AliITSmodule.h"
37#include "AliITShit.h"
38#include "AliITSdigit.h"
39#include "AliITSpListItem.h"
40#include "AliRun.h"
41#include "AliITSQADataMakerSim.h"
42#include "AliITSQASSDDataMakerSim.h"
43#include "AliLog.h"
4e25ac79 44#include "AliQAv1.h"
7a0e5776 45#include "AliQAChecker.h"
46#include "AliRawReader.h"
47
48ClassImp(AliITSQASSDDataMakerSim)
49
50//____________________________________________________________________________
51AliITSQASSDDataMakerSim::AliITSQASSDDataMakerSim(AliITSQADataMakerSim *aliITSQADataMakerSim) :
52TObject(),
53fAliITSQADataMakerSim(aliITSQADataMakerSim),
54//fSSDhTask(0),
55fSSDhHTask(0),
56fSSDhSTask(0),
57fSSDhDTask(0),
58fGenOffsetH(0),
59fGenOffsetS(0),
60fGenOffsetD(0)
61{
62 //ctor used to discriminate OnLine-Offline analysis
63}
64
65//____________________________________________________________________________
66AliITSQASSDDataMakerSim::AliITSQASSDDataMakerSim(const AliITSQASSDDataMakerSim& qadm) :
67TObject(),
68fAliITSQADataMakerSim(qadm.fAliITSQADataMakerSim),
69//fSSDhTask(qadm.fSSDhTask),
70fSSDhHTask(qadm.fSSDhHTask),
71fSSDhSTask(qadm.fSSDhSTask),
72fSSDhDTask(qadm.fSSDhDTask),
73fGenOffsetH(qadm.fGenOffsetH),
74fGenOffsetS(qadm.fGenOffsetS),
75fGenOffsetD(qadm.fGenOffsetD)
76{
77 //copy ctor
78 fAliITSQADataMakerSim->SetName((const char*)qadm.fAliITSQADataMakerSim->GetName()) ;
79 fAliITSQADataMakerSim->SetTitle((const char*)qadm.fAliITSQADataMakerSim->GetTitle());
80 }
81
82//__________________________________________________________________
83AliITSQASSDDataMakerSim& AliITSQASSDDataMakerSim::operator = (const AliITSQASSDDataMakerSim& qac ) {
84 // Equal operator.
85 this->~AliITSQASSDDataMakerSim();
86 new(this) AliITSQASSDDataMakerSim(qac);
87 return *this;
88}
89
90//____________________________________________________________________________
91void AliITSQASSDDataMakerSim::StartOfDetectorCycle() {
92 //Detector specific actions at start of cycle
5379c4a3 93 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQADM::Start of SSD Cycle\n");
7a0e5776 94}
95
96//____________________________________________________________________________
4e25ac79 97void AliITSQASSDDataMakerSim::EndOfDetectorCycle(AliQAv1::TASKINDEX_t /*task*/, TObjArray* /*list*/) {
7a0e5776 98 // launch the QA checking
5379c4a3 99 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSDM instantiates checker with Run(AliQAv1::kITS, task, list)\n");
7a0e5776 100
4e25ac79 101// AliQAChecker::Instance()->Run( AliQAv1::kITS , task, list);
7a0e5776 102}
103
104//____________________________________________________________________________
eca4fa66 105Int_t AliITSQASSDDataMakerSim::InitDigits() {
7a0e5776 106 // Initialization for DIGIT data - SSD -
7d297381 107 const Bool_t expert = kTRUE ;
108 const Bool_t image = kTRUE ;
eca4fa66 109 Int_t rv = 0 ;
110 // fGenOffsetD = (fAliITSQADataMakerSim->fDigitsQAList[AliRecoParam::kDefault])->GetEntries();
7a0e5776 111
112 // custom code here
113 TH1F *fHistSSDModule = new TH1F("fHistSSDDigitsModule",
db72ff3b 114 "SSD Digits Module;SSD Module Number;N_{DIGITS}",
7a0e5776 115 1698,499.5,2197.5);
eca4fa66 116 rv = fAliITSQADataMakerSim->Add2DigitsList(fHistSSDModule,
7d297381 117 fGenOffsetD + 0, !expert, image);
7a0e5776 118 fSSDhDTask += 1;
119 TH2F *fHistSSDModuleStrip = new TH2F("fHistSSDDigitsModuleStrip",
db72ff3b 120 "SSD Digits Module Strip;N_{Strip};N_{Module}",
7a0e5776 121 1540,0,1540,1698,499.5,2197.5);
eca4fa66 122 rv = fAliITSQADataMakerSim->Add2DigitsList(fHistSSDModuleStrip,
7d297381 123 fGenOffsetD + 1, !expert, image);
7a0e5776 124 fSSDhDTask += 1;
125
5379c4a3 126 AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SSD Digits histograms booked\n",fSSDhDTask));
eca4fa66 127 return rv ;
7a0e5776 128}
129
130//____________________________________________________________________________
eca4fa66 131Int_t AliITSQASSDDataMakerSim::MakeDigits(TTree *digits) {
7a0e5776 132 // Fill QA for DIGIT - SSD -
eca4fa66 133 Int_t rv = 0 ;
134 // Check id histograms already created for this Event Specie
135 if ( ! fAliITSQADataMakerSim->GetDigitsData(fGenOffsetD) )
136 rv = InitDigits() ;
137
7a0e5776 138 AliITS *fITS = (AliITS*)gAlice->GetModule("ITS");
139 fITS->SetTreeAddress();
140 TClonesArray *iSSDdigits = fITS->DigitsAddress(2);
141 for(Int_t iModule = 500; iModule < 2198; iModule++) {
142 iSSDdigits->Clear();
143 digits->GetEvent(iModule);
144 Int_t ndigits = iSSDdigits->GetEntries();
145 fAliITSQADataMakerSim->GetDigitsData(fGenOffsetD + 0)->Fill(iModule,ndigits);
146 if(ndigits != 0)
5379c4a3 147 AliDebug(AliQAv1::GetQADebugLevel(),Form("Module: %d - Digits: %d",iModule,ndigits));
7a0e5776 148
149 for (Int_t iDigit = 0; iDigit < ndigits; iDigit++) {
150 AliITSdigit *dig = (AliITSdigit*)iSSDdigits->UncheckedAt(iDigit);
151 Int_t fStripNumber = (dig->GetCoord1() == 0) ? dig->GetCoord2() : dig->GetCoord2() + fgkNumberOfPSideStrips;
152 ((TH2F *)fAliITSQADataMakerSim->GetDigitsData(fGenOffsetD + 1))->Fill(fStripNumber,iModule,dig->GetSignal());
153 }//digit loop
154 }//module loop
eca4fa66 155 return rv ;
7a0e5776 156}
157
158//____________________________________________________________________________
eca4fa66 159Int_t AliITSQASSDDataMakerSim::InitSDigits() {
7a0e5776 160 // Initialization for SDIGIT data - SSD -
7d297381 161 const Bool_t expert = kTRUE ;
162 const Bool_t image = kTRUE ;
eca4fa66 163 Int_t rv = 0 ;
164 //fGenOffsetS = (fAliITSQADataMakerSim->fSDigitsQAList[AliRecoParam::kDefault])->GetEntries();
7a0e5776 165
166 // custom code here
167 TH1F *fHistSSDModule = new TH1F("fHistSSDSDigitsModule",
db72ff3b 168 "SSD SDigits Module;SSD Module Number;N_{SDIGITS}",
7a0e5776 169 1698,499.5,2197.5);
eca4fa66 170 rv = fAliITSQADataMakerSim->Add2SDigitsList(fHistSSDModule,
7d297381 171 fGenOffsetS + 0, !expert, image);
7a0e5776 172 fSSDhSTask += 1;
173
5379c4a3 174 AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SSD SDigits histograms booked\n",fSSDhSTask));
eca4fa66 175 return rv ;
7a0e5776 176}
177
178//____________________________________________________________________________
eca4fa66 179Int_t AliITSQASSDDataMakerSim::MakeSDigits(TTree *sdigits) {
7a0e5776 180 // Fill QA for SDIGIT - SSD -
eca4fa66 181 Int_t rv = 0 ;
182 // Check id histograms already created for this Event Specie
183 if ( ! fAliITSQADataMakerSim->GetSDigitsData(fGenOffsetS) )
184 rv = InitSDigits() ;
185
7a0e5776 186 static TClonesArray iSSDEmpty("AliITSpListItem",10000);
187 iSSDEmpty.Clear();
188 TClonesArray *iSSDsdigits = &iSSDEmpty;
189
5379c4a3 190 AliDebug(AliQAv1::GetQADebugLevel(), Form("Trying to access the sdigits histogram: %d\n",fGenOffsetS));
7a0e5776 191
192 TBranch *brchSDigits = sdigits->GetBranch("ITS");
193 brchSDigits->SetAddress(&iSSDsdigits);
194 for(Int_t iModule = 500; iModule < 2198; iModule++) {
195 iSSDsdigits->Clear();
196 sdigits->GetEvent(iModule);
197 Int_t ndigits = iSSDsdigits->GetEntries();
198 fAliITSQADataMakerSim->GetSDigitsData(fGenOffsetS + 0)->Fill(iModule,ndigits);
199 if(ndigits != 0)
5379c4a3 200 AliDebug(AliQAv1::GetQADebugLevel(),Form("Module: %d - Digits: %d",iModule,ndigits));
7a0e5776 201
202 for (Int_t iDigit = 0; iDigit < ndigits; iDigit++) {
203 AliITSpListItem *dig=(AliITSpListItem*)iSSDsdigits->At(iDigit);
204 dig=0;
205 }//digit loop
206 }//module loop
eca4fa66 207 return rv ;
7a0e5776 208}
209
210//____________________________________________________________________________
eca4fa66 211Int_t AliITSQASSDDataMakerSim::InitHits() {
7a0e5776 212 // Initialization for HITS data - SSD -
7d297381 213 const Bool_t expert = kTRUE ;
214 const Bool_t image = kTRUE ;
eca4fa66 215 Int_t rv = 0 ;
216
217 //fGenOffsetH = (fAliITSQADataMakerSim->fHitsQAList[fEventSpecie])->GetEntries();
7a0e5776 218
219 // custom code here
220 TH1F *fHistSSDModule = new TH1F("fHistSSDHitsModule",
db72ff3b 221 "SSD Hits Module;SDD Module Number;N_{HITS}",
7a0e5776 222 1698,499.5,2197.5);
eca4fa66 223 rv = fAliITSQADataMakerSim->Add2HitsList(fHistSSDModule,
7d297381 224 fGenOffsetH + 0, !expert, image);
7a0e5776 225 fSSDhHTask += 1;
226 TH1F *fHistSSDGlobalX = new TH1F("fHistSSDHitsGlobalX",
db72ff3b 227 "SSD Hits Global X;x [cm];Entries",
7a0e5776 228 1000,-50.,50.);
eca4fa66 229 rv = fAliITSQADataMakerSim->Add2HitsList(fHistSSDGlobalX,
7d297381 230 fGenOffsetH + 1, !expert, image);
7a0e5776 231 fSSDhHTask += 1;
232 TH1F *fHistSSDGlobalY = new TH1F("fHistSSDHitsGlobalY",
db72ff3b 233 "SSD Hits Global Y;y [cm];Entries",
7a0e5776 234 1000,-50.,50.);
eca4fa66 235 rv = fAliITSQADataMakerSim->Add2HitsList(fHistSSDGlobalY,
7d297381 236 fGenOffsetH + 2, !expert, image);
7a0e5776 237 fSSDhHTask += 1;
238 TH1F *fHistSSDGlobalZ = new TH1F("fHistSSDHitsGlobalZ",
db72ff3b 239 "SSD Hits Global Z ;z [cm];Entries",
7a0e5776 240 1000,-60.,60.);
eca4fa66 241 rv = fAliITSQADataMakerSim->Add2HitsList(fHistSSDGlobalZ,
7d297381 242 fGenOffsetH + 3, !expert, image);
7a0e5776 243 fSSDhHTask += 1;
244 TH1F *fHistSSDLocalX = new TH1F("fHistSSDHitsLocalX",
db72ff3b 245 "SSD Hits Local X;x [cm];Entries",
7a0e5776 246 1000,-4.,4.);
eca4fa66 247 rv = fAliITSQADataMakerSim->Add2HitsList(fHistSSDLocalX,
7d297381 248 fGenOffsetH + 4, !expert, image);
7a0e5776 249 fSSDhHTask += 1;
250 TH1F *fHistSSDLocalY = new TH1F("fHistSSDHitsLocalY",
db72ff3b 251 "SSD Hits Local Y;y [cm];Entries",
7a0e5776 252 1000,-0.1,0.1);
eca4fa66 253 rv = fAliITSQADataMakerSim->Add2HitsList(fHistSSDLocalY,
7d297381 254 fGenOffsetH + 5, !expert, image);
7a0e5776 255 fSSDhHTask += 1;
256 TH1F *fHistSSDLocalZ = new TH1F("fHistSSDHitsLocalZ",
db72ff3b 257 "SSD Hits Local Z;z [cm];Entries",
7a0e5776 258 1000,-4.,4.);
eca4fa66 259 rv = fAliITSQADataMakerSim->Add2HitsList(fHistSSDLocalZ,
7d297381 260 fGenOffsetH + 6, !expert, image);
7a0e5776 261 fSSDhHTask += 1;
262 TH1F *fHistSSDIonization = new TH1F("fHistSSDHitsIonization",
db72ff3b 263 "SSD Hits Ionization;log(dE/dx) [KeV];N_{Hits}",
7a0e5776 264 100,-7,-2);
eca4fa66 265 rv = fAliITSQADataMakerSim->Add2HitsList(fHistSSDIonization,
7d297381 266 fGenOffsetH + 7, !expert, image);
7a0e5776 267 fSSDhHTask += 1;
268 TH2F *fHistSSDGlobalXY = new TH2F("fHistSSDHitsGlobalXY",
db72ff3b 269 "SSD Hits Global XY;x [cm];y [cm]",
7a0e5776 270 1000,-50.,50.,
271 1000,-50.,50.);
eca4fa66 272 rv = fAliITSQADataMakerSim->Add2HitsList(fHistSSDGlobalXY,
7d297381 273 fGenOffsetH + 8, !expert, image);
7a0e5776 274 fSSDhHTask += 1;
275
5379c4a3 276 AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SSD Hits histograms booked\n",fSSDhHTask));
eca4fa66 277 return rv ;
7a0e5776 278}
279
280
281//____________________________________________________________________________
eca4fa66 282Int_t AliITSQASSDDataMakerSim::MakeHits(TTree *hits) {
7a0e5776 283 // Fill QA for HITS - SSD -
eca4fa66 284 Int_t rv = 0 ;
285 // Check id histograms already created for this Event Specie
286 if ( ! fAliITSQADataMakerSim->GetHitsData(fGenOffsetH) )
287 rv = InitHits() ;
288
7a0e5776 289 AliITS *fITS = (AliITS*)gAlice->GetModule("ITS");
290 fITS->SetTreeAddress();
291 Int_t nmodules;
292 fITS->InitModules(-1,nmodules);
293 fITS->FillModules(hits,0);
294 for(Int_t iModule = 500; iModule < 2198; iModule++) {
295 AliITSmodule *module = fITS->GetModule(iModule);
296 TObjArray *arrHits = module->GetHits();
297 Int_t nhits = arrHits->GetEntriesFast();
298 if(nhits != 0)
5379c4a3 299 AliDebug(AliQAv1::GetQADebugLevel(),Form("Module: %d - Hits: %d",iModule,nhits));
7a0e5776 300 for (Int_t iHit = 0; iHit < nhits; iHit++) {
301 AliITShit *hit = (AliITShit*) arrHits->At(iHit);
302
303 fAliITSQADataMakerSim->GetHitsData(fGenOffsetH + 0)->Fill(iModule);
304 fAliITSQADataMakerSim->GetHitsData(fGenOffsetH + 1)->Fill(hit->GetXG());
305 fAliITSQADataMakerSim->GetHitsData(fGenOffsetH + 2)->Fill(hit->GetYG());
306 fAliITSQADataMakerSim->GetHitsData(fGenOffsetH + 3)->Fill(hit->GetZG());
307 fAliITSQADataMakerSim->GetHitsData(fGenOffsetH + 4)->Fill(hit->GetXL());
308 fAliITSQADataMakerSim->GetHitsData(fGenOffsetH + 5)->Fill(hit->GetYL());
309 fAliITSQADataMakerSim->GetHitsData(fGenOffsetH + 6)->Fill(hit->GetZL());
310 if(hit->GetIonization())
311 fAliITSQADataMakerSim->GetHitsData(fGenOffsetH + 7)->Fill(TMath::Log10(hit->GetIonization()));
312 fAliITSQADataMakerSim->GetHitsData(fGenOffsetH + 8)->Fill(hit->GetXG(),hit->GetYG());
313 }//hit loop
314 }//module loop
eca4fa66 315 return rv ;
7a0e5776 316}
317
7a0e5776 318//____________________________________________________________________________
4e25ac79 319Int_t AliITSQASSDDataMakerSim::GetOffset(AliQAv1::TASKINDEX_t task){
7a0e5776 320 // Returns histogram offset according to the specified task
321 Int_t offset=0;
4e25ac79 322 if( task == AliQAv1::kHITS){
7a0e5776 323 offset=fGenOffsetH;
324 }
4e25ac79 325 else if( task == AliQAv1::kSDIGITS) {
7a0e5776 326 offset=fGenOffsetS;
327 }
4e25ac79 328 else if( task == AliQAv1::kDIGITS) {
7a0e5776 329 offset=fGenOffsetD;
330 }
331 else {
332 AliInfo("No task has been selected. TaskHisto set to zero.\n");
333 }
334
335 return offset;
336}
337
338
339//____________________________________________________________________________
eca4fa66 340void AliITSQASSDDataMakerSim::SetOffset(AliQAv1::TASKINDEX_t task, Int_t offset){
341 // Returns histogram offset according to the specified task
342 if( task == AliQAv1::kHITS){
343 fGenOffsetH = offset;
344 }
345 else if( task == AliQAv1::kSDIGITS) {
346 fGenOffsetS = offset;
347 }
348 else if( task == AliQAv1::kDIGITS) {
349 fGenOffsetD = offset;
350 }
351 else {
352 AliInfo("No task has been selected. TaskHisto set to zero.\n");
353 }
354}
355
356//____________________________________________________________________________
4e25ac79 357Int_t AliITSQASSDDataMakerSim::GetTaskHisto(AliQAv1::TASKINDEX_t task) {
7a0e5776 358 // Returns the number of booked histograms for the selected task
359 Int_t histotot=0;
4e25ac79 360 if( task == AliQAv1::kHITS) {
7a0e5776 361 histotot=fSSDhHTask ;
362 }
4e25ac79 363 else if( task == AliQAv1::kSDIGITS) {
7a0e5776 364 histotot=fSSDhSTask;
365 }
4e25ac79 366 else if( task == AliQAv1::kDIGITS) {
7a0e5776 367 histotot=fSSDhDTask ;
368 }
369 else {
370 AliInfo("No task has been selected. TaskHisto set to zero.\n");
371 }
372 return histotot;
373
374}