1.The QA data created on demand according to the event species at filling time. 2...
[u/mrichter/AliRoot.git] / ITS / AliITSQASPDDataMakerSim.cxx
CommitLineData
379510c2 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// Checks the quality assurance
19// by comparing with reference data
20// contained in a DB
21// -------------------------------------------------------------
22// W. Ferrarese + P. Cerello INFN Torino Feb 2008
23// M. Nicassio D. Elia INFN Bari April 2008
24// maria.nicassio@ba.infn.it
25
26// --- ROOT system ---
27#include <TTree.h>
28#include <TH2.h>
29#include <TH1.h>
30// --- Standard library ---
31
32// --- AliRoot header files ---
33#include "AliRun.h"
34#include "AliITSQADataMakerSim.h"
35#include "AliITSQASPDDataMakerSim.h"
4e25ac79 36#include "AliQAv1.h"
379510c2 37#include "AliQAChecker.h"
38#include "AliITSdigit.h"
39#include "AliITSdigitSPD.h"
40#include "AliITS.h"
41#include "AliITSmodule.h"
42#include "AliITShit.h"
43#include "AliITSLoader.h"
44#include "AliRunLoader.h"
45
46ClassImp(AliITSQASPDDataMakerSim)
47
48//____________________________________________________________________________
49AliITSQASPDDataMakerSim::AliITSQASPDDataMakerSim(AliITSQADataMakerSim *aliITSQADataMakerSim) :
50TObject(),
51fAliITSQADataMakerSim(aliITSQADataMakerSim),
7a0e5776 52fSPDhHTask(0),
53fSPDhSTask(0),
54fSPDhDTask(0),
3f905799 55fGenOffsetH(0),
56fGenOffsetS(0),
57fGenOffsetD(0)
379510c2 58{
59 //ctor used to discriminate OnLine-Offline analysis
60}
61
62//____________________________________________________________________________
63AliITSQASPDDataMakerSim::AliITSQASPDDataMakerSim(const AliITSQASPDDataMakerSim& qadm) :
64TObject(),
65fAliITSQADataMakerSim(qadm.fAliITSQADataMakerSim),
7a0e5776 66fSPDhHTask(qadm.fSPDhHTask),
67fSPDhSTask(qadm.fSPDhSTask),
68fSPDhDTask(qadm.fSPDhDTask),
3f905799 69fGenOffsetH(qadm.fGenOffsetH),
70fGenOffsetS(qadm.fGenOffsetS),
71fGenOffsetD(qadm.fGenOffsetD)
379510c2 72{
73 //copy ctor
74 fAliITSQADataMakerSim->SetName((const char*)qadm.fAliITSQADataMakerSim->GetName()) ;
75 fAliITSQADataMakerSim->SetTitle((const char*)qadm.fAliITSQADataMakerSim->GetTitle());
76 }
77
78//__________________________________________________________________
79AliITSQASPDDataMakerSim& AliITSQASPDDataMakerSim::operator = (const AliITSQASPDDataMakerSim& qac )
80{
81 // Equal operator.
82 this->~AliITSQASPDDataMakerSim();
83 new(this) AliITSQASPDDataMakerSim(qac);
84 return *this;
85}
86
87//____________________________________________________________________________
88void AliITSQASPDDataMakerSim::StartOfDetectorCycle()
89{
90 //Detector specific actions at start of cycle
5379c4a3 91 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQADM::Start of SPD Cycle\n");
379510c2 92}
93
94//____________________________________________________________________________
4e25ac79 95void AliITSQASPDDataMakerSim::EndOfDetectorCycle(AliQAv1::TASKINDEX_t /*task*/, TObjArray* /*list*/)
379510c2 96{
97 // launch the QA checking
5379c4a3 98 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSDM instantiates checker with Run(AliQAv1::kITS, task, list)\n");
379510c2 99
4e25ac79 100 //AliQAChecker::Instance()->Run( AliQAv1::kITS , task, list);
379510c2 101}
102
103//____________________________________________________________________________
eca4fa66 104Int_t AliITSQASPDDataMakerSim::InitDigits()
379510c2 105{
106 // Initialization for DIGIT data - SPD -
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 //fSPDhDTask must be incremented by one unit every time a histogram is ADDED to the QA List
379510c2 112
113 Char_t name[50];
114 Char_t title[50];
115
26ee9565 116 TH1F *hlayer = new TH1F("SPDLayPattern_SPD","Layer map - SPD",6,0.,6.);
379510c2 117 hlayer->GetXaxis()->SetTitle("Layer number");
118 hlayer->GetYaxis()->SetTitle("Entries");
eca4fa66 119 rv = fAliITSQADataMakerSim->Add2DigitsList(hlayer,fGenOffsetD, expert, !image);
7a0e5776 120 fSPDhDTask++;
379510c2 121
122 TH1F **hmod = new TH1F*[2];
123 for (Int_t iLay=0; iLay<2; iLay++) {
26ee9565 124 sprintf(name,"SPDModPattern_SPD%d",iLay+1);
379510c2 125 sprintf(title,"Module map - SPD Layer %d",iLay+1);
126 hmod[iLay]=new TH1F(name,title,240,0,240);
127 hmod[iLay]->GetXaxis()->SetTitle("Module number");
128 hmod[iLay]->GetYaxis()->SetTitle("Entries");
eca4fa66 129 rv = fAliITSQADataMakerSim->Add2DigitsList(hmod[iLay],1+iLay+fGenOffsetD, !expert, image);
7a0e5776 130 fSPDhDTask++;
379510c2 131 }
132
26ee9565 133 TH1F *hcolumns = new TH1F("SPDColumns_SPD","Columns - SPD",160,0.,160.);
379510c2 134 hcolumns->GetXaxis()->SetTitle("Column number");
135 hcolumns->GetYaxis()->SetTitle("Entries");
7d297381 136 fAliITSQADataMakerSim->Add2DigitsList(hcolumns,3+fGenOffsetD, expert, !image);
7a0e5776 137 fSPDhDTask++;
379510c2 138
26ee9565 139 TH1F *hrows = new TH1F("SPDRows_SPD","Rows - SPD",256,0.,256.);
379510c2 140 hrows->GetXaxis()->SetTitle("Row number");
141 hrows->GetYaxis()->SetTitle("Entries");
eca4fa66 142 rv = fAliITSQADataMakerSim->Add2DigitsList(hrows,4+fGenOffsetD, expert, !image);
7a0e5776 143 fSPDhDTask++;
379510c2 144
145 TH1F** hMultSPDdigits = new TH1F*[2];
146 for (Int_t iLay=0; iLay<2; ++iLay) {
26ee9565 147 sprintf(name,"SPDDigitMultiplicity_SPD%d",iLay+1);
379510c2 148 sprintf(title,"Digit multiplicity - SPD Layer %d",iLay+1);
149 hMultSPDdigits[iLay]=new TH1F(name,title,200,0.,200.);
150 hMultSPDdigits[iLay]->GetXaxis()->SetTitle("Digit multiplicity");
151 hMultSPDdigits[iLay]->GetYaxis()->SetTitle("Entries");
eca4fa66 152 rv = fAliITSQADataMakerSim->Add2DigitsList(hMultSPDdigits[iLay], 5+iLay+fGenOffsetD, !expert, image);
7a0e5776 153 fSPDhDTask++;
379510c2 154 }
155
954ef57a 156 TH2F *hMultSPDdig2MultSPDdig1
26ee9565 157 = new TH2F("SPDDigitMultCorrelation_SPD","Digit multiplicity correlation - SPD",200,0.,200.,200,0.,200.);
379510c2 158 hMultSPDdig2MultSPDdig1->GetXaxis()->SetTitle("Digit multiplicity (Layer 1)");
159 hMultSPDdig2MultSPDdig1->GetYaxis()->SetTitle("Digit multiplicity (Layer 2)");
eca4fa66 160 rv = fAliITSQADataMakerSim->Add2DigitsList(hMultSPDdig2MultSPDdig1,7+fGenOffsetD, !expert, image);
7a0e5776 161 fSPDhDTask++;
379510c2 162
5379c4a3 163 AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SPD Digits histograms booked\n",fSPDhDTask));
eca4fa66 164 return rv ;
379510c2 165}
166
167//____________________________________________________________________________
eca4fa66 168Int_t AliITSQASPDDataMakerSim::MakeDigits(TTree *digits)
379510c2 169{
170 // Fill QA for DIGIT - SPD -
eca4fa66 171 Int_t rv = 0 ;
172 // Check id histograms already created for this Event Specie
173 if ( ! fAliITSQADataMakerSim->GetDigitsData(fGenOffsetD) )
174 rv = InitDigits() ;
175
379510c2 176 AliITS *fITS = (AliITS*)gAlice->GetModule("ITS");
177 fITS->SetTreeAddress();
178 TClonesArray *iITSdigits = fITS->DigitsAddress(0); // 0->SPD
179
180 Int_t nDigitsL1=0;
181 Int_t nDigitsL2=0;
182
183 for (Int_t imod=0; imod<240; ++imod){
184 digits->GetEvent(imod);
185 Int_t ndigits = iITSdigits->GetEntries();
186 if (imod<80) {
3f905799 187 fAliITSQADataMakerSim->GetDigitsData(0+fGenOffsetD)->Fill(0.5,ndigits);
188 fAliITSQADataMakerSim->GetDigitsData(1+fGenOffsetD)->Fill(imod,ndigits);
379510c2 189 nDigitsL1+=ndigits;
190 }
191 else {
3f905799 192 fAliITSQADataMakerSim->GetDigitsData(0+fGenOffsetD)->Fill(1,ndigits);
193 fAliITSQADataMakerSim->GetDigitsData(2+fGenOffsetD)->Fill(imod,ndigits);
379510c2 194 nDigitsL2+=ndigits;
195 }
196 for (Int_t idig=0; idig<ndigits; ++idig) {
197 AliITSdigit *dig=(AliITSdigit*)iITSdigits->UncheckedAt(idig);
198 Int_t col=dig->GetCoord1(); // cell number z
199 Int_t row=dig->GetCoord2(); // cell number x
3f905799 200 fAliITSQADataMakerSim->GetDigitsData(3+fGenOffsetD)->Fill(col);
201 fAliITSQADataMakerSim->GetDigitsData(4+fGenOffsetD)->Fill(row);
379510c2 202 }
203 }
3f905799 204 fAliITSQADataMakerSim->GetDigitsData(5+fGenOffsetD)->Fill(nDigitsL1);
205 fAliITSQADataMakerSim->GetDigitsData(6+fGenOffsetD)->Fill(nDigitsL2);
206 fAliITSQADataMakerSim->GetDigitsData(7+fGenOffsetD)->Fill(nDigitsL1,nDigitsL2);
eca4fa66 207 return rv ;
379510c2 208}
209
210//____________________________________________________________________________
eca4fa66 211Int_t AliITSQASPDDataMakerSim::InitSDigits()
379510c2 212{
213 // Initialization for SDIGIT data - SPD -
7d297381 214 const Bool_t expert = kTRUE ;
215 const Bool_t image = kTRUE ;
eca4fa66 216 Int_t rv = 0 ;
217 //fGenOffsetS = (fAliITSQADataMakerSim->fSDigitsQAList[AliRecoParam::kDefault])->GetEntries();
c71529b0 218 //printf("--W-- AliITSQASPDDataMakerSim::InitSDigits() fGenOffset= %d \n",fGenOffset);
7a0e5776 219 //fSPDhSTask must be incremented by one unit every time a histogram is ADDED to the QA List
c71529b0 220
379510c2 221 Char_t name[50];
222 Char_t title[50];
223
26ee9565 224 TH1F *hlayer = new TH1F("SPDLayPattern_SPD","Layer map - SPD",6,0.,6.);
379510c2 225 hlayer->GetXaxis()->SetTitle("Layer number");
226 hlayer->GetYaxis()->SetTitle("Entries");
eca4fa66 227 rv = fAliITSQADataMakerSim->Add2SDigitsList(hlayer,fGenOffsetS, expert, !image);
7a0e5776 228 fSPDhSTask++;
379510c2 229
230 TH1F **hmod = new TH1F*[2];
231 for (Int_t iLay=0; iLay<2; ++iLay) {
26ee9565 232 sprintf(name,"SPDModPattern_SPD%d",iLay+1);
379510c2 233 sprintf(title,"Module map - SPD Layer %d",iLay+1);
234 hmod[iLay]=new TH1F(name,title,240,0,240);
235 hmod[iLay]->GetXaxis()->SetTitle("Module number");
236 hmod[iLay]->GetYaxis()->SetTitle("Entries");
eca4fa66 237 rv = fAliITSQADataMakerSim->Add2SDigitsList(hmod[iLay],1+iLay+fGenOffsetS, !expert, image);
7a0e5776 238 fSPDhSTask++;
379510c2 239 }
379510c2 240
5379c4a3 241 AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SPD SDigits histograms booked\n",fSPDhSTask));
eca4fa66 242 return rv ;
379510c2 243}
244
245//____________________________________________________________________________
eca4fa66 246Int_t AliITSQASPDDataMakerSim::MakeSDigits(TTree *sdigits)
379510c2 247{
248 // Fill QA for SDIGIT - SPD -
eca4fa66 249 Int_t rv = 0 ;
250 // Check id histograms already created for this Event Specie
251 if ( ! fAliITSQADataMakerSim->GetSDigitsData(fGenOffsetS) )
252 rv = InitSDigits() ;
253
379510c2 254 TBranch *brchSDigits = sdigits->GetBranch("ITS");
255 for (Int_t imod=0; imod<240; ++imod){
256 TClonesArray * sdig = new TClonesArray( "AliITSpListItem",1000 );
257 brchSDigits->SetAddress( &sdig );
258 brchSDigits->GetEvent(imod);
259 Int_t nsdig=sdig->GetEntries();
260 if (imod<80) {
3f905799 261 fAliITSQADataMakerSim->GetSDigitsData(0+fGenOffsetS)->Fill(0.5,nsdig);
262 fAliITSQADataMakerSim->GetSDigitsData(1+fGenOffsetS)->Fill(imod,nsdig);
379510c2 263 }
264 else {
3f905799 265 fAliITSQADataMakerSim->GetSDigitsData(0+fGenOffsetS)->Fill(1,nsdig);
266 fAliITSQADataMakerSim->GetSDigitsData(2+fGenOffsetS)->Fill(imod,nsdig);
379510c2 267 }
268 delete sdig;
269 }
eca4fa66 270 return rv ;
379510c2 271}
272
273//____________________________________________________________________________
eca4fa66 274Int_t AliITSQASPDDataMakerSim::InitHits()
379510c2 275{
276 // Initialization for HITS data - SPD -
7d297381 277 const Bool_t expert = kTRUE ;
278 const Bool_t image = kTRUE ;
eca4fa66 279 Int_t rv = 0 ;
7d297381 280
eca4fa66 281 //fGenOffsetH = (fAliITSQADataMakerSim->fHitsQAList[AliRecoParam::kDefault])->GetEntries();
c71529b0 282 //printf("--W-- AliITSQASPDDataMakerSim::InitHits() fGenOffset= %d \n",fGenOffset);
7a0e5776 283 //fSPDhHTask must be incremented by one unit every time a histogram is ADDED to the QA List
379510c2 284 Char_t name[50];
285 Char_t title[50];
286
26ee9565 287 TH1F *hlayer = new TH1F("SPDLayPattern_SPD","Layer map - SPD",6,0.,6.);
379510c2 288 hlayer->GetXaxis()->SetTitle("Layer number");
289 hlayer->GetYaxis()->SetTitle("Entries");
eca4fa66 290 rv = fAliITSQADataMakerSim->Add2HitsList(hlayer,fGenOffsetH, expert, !image);
7a0e5776 291 fSPDhHTask++;
379510c2 292
293 TH1F **hmod = new TH1F*[2];
294 for (Int_t iLay=0; iLay<2; ++iLay) {
26ee9565 295 sprintf(name,"SPDModPattern_SPD%d",iLay+1);
379510c2 296 sprintf(title,"Module map - SPD Layer %d",iLay+1);
297 hmod[iLay]=new TH1F(name,title,240,0,240);
298 hmod[iLay]->GetXaxis()->SetTitle("Module number");
299 hmod[iLay]->GetYaxis()->SetTitle("Entries");
eca4fa66 300 rv = fAliITSQADataMakerSim->Add2HitsList(hmod[iLay],1+iLay+fGenOffsetH, !expert, image);
7a0e5776 301 fSPDhHTask++;
379510c2 302 }
303
db72ff3b 304 TH1F *hhitlenght = new TH1F("SPDLenght_SPD","SPD Hit lenght along y_{loc} coord",210,0.,210.);
379510c2 305 hhitlenght->GetXaxis()->SetTitle("Hit lenght [#mum]");
306 hhitlenght->GetYaxis()->SetTitle("# hits");
eca4fa66 307 rv = fAliITSQADataMakerSim->Add2HitsList(hhitlenght,3+fGenOffsetH, !expert, image);
7a0e5776 308 fSPDhHTask++;
379510c2 309
db72ff3b 310 TH1F *hEdepos = new TH1F("SPDEnergyDeposit_SPD","SPD Deposited energy distribution (y_{loc}>180 #mum)",150,0.,300.);
379510c2 311 hEdepos->GetXaxis()->SetTitle("Deposited energy [keV]");
312 hEdepos->GetYaxis()->SetTitle("# hits");
eca4fa66 313 rv = fAliITSQADataMakerSim->Add2HitsList(hEdepos,4+fGenOffsetH, !expert, image);
7a0e5776 314 fSPDhHTask++;
379510c2 315
5379c4a3 316 AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SPD Hits histograms booked\n",fSPDhHTask));
eca4fa66 317 return rv ;
379510c2 318}
319
320//____________________________________________________________________________
eca4fa66 321Int_t AliITSQASPDDataMakerSim::MakeHits(TTree *hits)
379510c2 322{
323 // Fill QA for HITS - SPD -
eca4fa66 324 Int_t rv = 0 ;
325 // Check id histograms already created for this Event Specie
326 if ( ! fAliITSQADataMakerSim->GetHitsData(fGenOffsetH) )
327 rv = InitHits() ;
328
379510c2 329 AliITS *fITS = (AliITS*)gAlice->GetModule("ITS");
330 fITS->SetTreeAddress();
331 Int_t nmodules;
332 fITS->InitModules(-1,nmodules); //-1->number of modules taken from AliITSgeom class kept in fITSgeom
333 //nmodules is set
334
335 fITS->FillModules(hits,0);
336
337 for (Int_t imod=0; imod<240; ++imod){
338 AliITSmodule *module = fITS->GetModule(imod);
339 TObjArray *arrHits = module->GetHits();
340 Int_t nhits = arrHits->GetEntriesFast();
341 if (imod<80) {
3f905799 342 fAliITSQADataMakerSim->GetHitsData(fGenOffsetH)->Fill(0.5,nhits);
343 fAliITSQADataMakerSim->GetHitsData(1+fGenOffsetH)->Fill(imod,nhits);
379510c2 344 } else {
3f905799 345 fAliITSQADataMakerSim->GetHitsData(fGenOffsetH)->Fill(1,nhits);
346 fAliITSQADataMakerSim->GetHitsData(2+fGenOffsetH)->Fill(imod,nhits);
379510c2 347 }
379510c2 348 for (Int_t iHit=0; iHit<nhits; ++iHit) {
349 AliITShit *hit = (AliITShit*) arrHits->At(iHit);
350 Double_t xl,yl,zl,xl0,yl0,zl0;
351 Double_t tof,tof0;
352 hit->GetPositionL(xl,yl,zl,tof);
353 hit->GetPositionL0(xl0,yl0,zl0,tof0);
354 Float_t dyloc=TMath::Abs(yl-yl0)*10000.;
3f905799 355 fAliITSQADataMakerSim->GetHitsData(3+fGenOffsetH)->Fill(dyloc);
379510c2 356 Float_t edep=hit->GetIonization()*1000000;
357 if(dyloc>180.){
3f905799 358 fAliITSQADataMakerSim->GetHitsData(4+fGenOffsetH)->Fill(edep);
379510c2 359 }
360 }
361 }
eca4fa66 362 return rv ;
379510c2 363}
7a0e5776 364
365
366//_______________________________________________________________
367
4e25ac79 368Int_t AliITSQASPDDataMakerSim::GetOffset(AliQAv1::TASKINDEX_t task){
7a0e5776 369 // Returns histogram offset according to the specified task
370 Int_t offset=0;
4e25ac79 371 if( task == AliQAv1::kHITS){
7a0e5776 372 offset=fGenOffsetH;
373 }
4e25ac79 374 else if( task == AliQAv1::kSDIGITS) {
7a0e5776 375 offset=fGenOffsetS;
376 }
4e25ac79 377 else if( task == AliQAv1::kDIGITS) {
7a0e5776 378 offset=fGenOffsetD;
379 }
380 else {
381 AliInfo("No task has been selected. TaskHisto set to zero.\n");
382 }
383
384 return offset;
385}
386
eca4fa66 387//____________________________________________________________________________
388void AliITSQASPDDataMakerSim::SetOffset(AliQAv1::TASKINDEX_t task, Int_t offset){
389 // Returns histogram offset according to the specified task
390 if( task == AliQAv1::kHITS){
391 fGenOffsetH = offset;
392 }
393 else if( task == AliQAv1::kSDIGITS) {
394 fGenOffsetS = offset;
395 }
396 else if( task == AliQAv1::kDIGITS) {
397 fGenOffsetD = offset;
398 }
399 else {
400 AliInfo("No task has been selected. TaskHisto set to zero.\n");
401 }
402}
7a0e5776 403
404//_______________________________________________________________
405
4e25ac79 406Int_t AliITSQASPDDataMakerSim::GetTaskHisto(AliQAv1::TASKINDEX_t task) {
7a0e5776 407 // Returns the number of booked histograms for the selected task
408 Int_t histotot=0;
4e25ac79 409 if( task == AliQAv1::kHITS) {
7a0e5776 410 histotot=fSPDhHTask ;
411 }
4e25ac79 412 else if( task == AliQAv1::kSDIGITS) {
7a0e5776 413 histotot=fSPDhSTask;
414 }
4e25ac79 415 else if( task == AliQAv1::kDIGITS) {
7a0e5776 416 histotot=fSPDhDTask ;
417 }
418 else {
419 AliInfo("No task has been selected. TaskHisto set to zero.\n");
420 }
421 return histotot;
422
423}