Fixes for bug #49914: Compilation breaks in trunk, and bug #48629: Trunk cannot read...
[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
91 AliDebug(1,"AliITSQADM::Start of SPD Cycle\n");
92}
93
94//____________________________________________________________________________
4e25ac79 95void AliITSQASPDDataMakerSim::EndOfDetectorCycle(AliQAv1::TASKINDEX_t /*task*/, TObjArray* /*list*/)
379510c2 96{
97 // launch the QA checking
4e25ac79 98 AliDebug(1,"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//____________________________________________________________________________
104void AliITSQASPDDataMakerSim::InitDigits()
105{
106 // Initialization for DIGIT data - SPD -
57acd2d2 107 fGenOffsetD = (fAliITSQADataMakerSim->fDigitsQAList[AliRecoParam::kDefault])->GetEntries();
7a0e5776 108 //fSPDhDTask must be incremented by one unit every time a histogram is ADDED to the QA List
379510c2 109
110 Char_t name[50];
111 Char_t title[50];
112
26ee9565 113 TH1F *hlayer = new TH1F("SPDLayPattern_SPD","Layer map - SPD",6,0.,6.);
379510c2 114 hlayer->GetXaxis()->SetTitle("Layer number");
115 hlayer->GetYaxis()->SetTitle("Entries");
954ef57a 116 fAliITSQADataMakerSim->Add2DigitsList(hlayer,fGenOffsetD,kTRUE);
7a0e5776 117 fSPDhDTask++;
379510c2 118
119 TH1F **hmod = new TH1F*[2];
120 for (Int_t iLay=0; iLay<2; iLay++) {
26ee9565 121 sprintf(name,"SPDModPattern_SPD%d",iLay+1);
379510c2 122 sprintf(title,"Module map - SPD Layer %d",iLay+1);
123 hmod[iLay]=new TH1F(name,title,240,0,240);
124 hmod[iLay]->GetXaxis()->SetTitle("Module number");
125 hmod[iLay]->GetYaxis()->SetTitle("Entries");
3f905799 126 fAliITSQADataMakerSim->Add2DigitsList(hmod[iLay],1+iLay+fGenOffsetD);
7a0e5776 127 fSPDhDTask++;
379510c2 128 }
129
26ee9565 130 TH1F *hcolumns = new TH1F("SPDColumns_SPD","Columns - SPD",160,0.,160.);
379510c2 131 hcolumns->GetXaxis()->SetTitle("Column number");
132 hcolumns->GetYaxis()->SetTitle("Entries");
954ef57a 133 fAliITSQADataMakerSim->Add2DigitsList(hcolumns,3+fGenOffsetD,kTRUE);
7a0e5776 134 fSPDhDTask++;
379510c2 135
26ee9565 136 TH1F *hrows = new TH1F("SPDRows_SPD","Rows - SPD",256,0.,256.);
379510c2 137 hrows->GetXaxis()->SetTitle("Row number");
138 hrows->GetYaxis()->SetTitle("Entries");
954ef57a 139 fAliITSQADataMakerSim->Add2DigitsList(hrows,4+fGenOffsetD,kTRUE);
7a0e5776 140 fSPDhDTask++;
379510c2 141
142 TH1F** hMultSPDdigits = new TH1F*[2];
143 for (Int_t iLay=0; iLay<2; ++iLay) {
26ee9565 144 sprintf(name,"SPDDigitMultiplicity_SPD%d",iLay+1);
379510c2 145 sprintf(title,"Digit multiplicity - SPD Layer %d",iLay+1);
146 hMultSPDdigits[iLay]=new TH1F(name,title,200,0.,200.);
147 hMultSPDdigits[iLay]->GetXaxis()->SetTitle("Digit multiplicity");
148 hMultSPDdigits[iLay]->GetYaxis()->SetTitle("Entries");
3f905799 149 fAliITSQADataMakerSim->Add2DigitsList(hMultSPDdigits[iLay], 5+iLay+fGenOffsetD);
7a0e5776 150 fSPDhDTask++;
379510c2 151 }
152
954ef57a 153 TH2F *hMultSPDdig2MultSPDdig1
26ee9565 154 = new TH2F("SPDDigitMultCorrelation_SPD","Digit multiplicity correlation - SPD",200,0.,200.,200,0.,200.);
379510c2 155 hMultSPDdig2MultSPDdig1->GetXaxis()->SetTitle("Digit multiplicity (Layer 1)");
156 hMultSPDdig2MultSPDdig1->GetYaxis()->SetTitle("Digit multiplicity (Layer 2)");
3f905799 157 fAliITSQADataMakerSim->Add2DigitsList(hMultSPDdig2MultSPDdig1,7+fGenOffsetD);
7a0e5776 158 fSPDhDTask++;
379510c2 159
7a0e5776 160 AliDebug(1,Form("%d SPD Digits histograms booked\n",fSPDhDTask));
379510c2 161
162}
163
164//____________________________________________________________________________
165void AliITSQASPDDataMakerSim::MakeDigits(TTree *digits)
166{
167 // Fill QA for DIGIT - SPD -
168 AliITS *fITS = (AliITS*)gAlice->GetModule("ITS");
169 fITS->SetTreeAddress();
170 TClonesArray *iITSdigits = fITS->DigitsAddress(0); // 0->SPD
171
172 Int_t nDigitsL1=0;
173 Int_t nDigitsL2=0;
174
175 for (Int_t imod=0; imod<240; ++imod){
176 digits->GetEvent(imod);
177 Int_t ndigits = iITSdigits->GetEntries();
178 if (imod<80) {
3f905799 179 fAliITSQADataMakerSim->GetDigitsData(0+fGenOffsetD)->Fill(0.5,ndigits);
180 fAliITSQADataMakerSim->GetDigitsData(1+fGenOffsetD)->Fill(imod,ndigits);
379510c2 181 nDigitsL1+=ndigits;
182 }
183 else {
3f905799 184 fAliITSQADataMakerSim->GetDigitsData(0+fGenOffsetD)->Fill(1,ndigits);
185 fAliITSQADataMakerSim->GetDigitsData(2+fGenOffsetD)->Fill(imod,ndigits);
379510c2 186 nDigitsL2+=ndigits;
187 }
188 for (Int_t idig=0; idig<ndigits; ++idig) {
189 AliITSdigit *dig=(AliITSdigit*)iITSdigits->UncheckedAt(idig);
190 Int_t col=dig->GetCoord1(); // cell number z
191 Int_t row=dig->GetCoord2(); // cell number x
3f905799 192 fAliITSQADataMakerSim->GetDigitsData(3+fGenOffsetD)->Fill(col);
193 fAliITSQADataMakerSim->GetDigitsData(4+fGenOffsetD)->Fill(row);
379510c2 194 }
195 }
3f905799 196 fAliITSQADataMakerSim->GetDigitsData(5+fGenOffsetD)->Fill(nDigitsL1);
197 fAliITSQADataMakerSim->GetDigitsData(6+fGenOffsetD)->Fill(nDigitsL2);
198 fAliITSQADataMakerSim->GetDigitsData(7+fGenOffsetD)->Fill(nDigitsL1,nDigitsL2);
379510c2 199}
200
201//____________________________________________________________________________
202void AliITSQASPDDataMakerSim::InitSDigits()
203{
204 // Initialization for SDIGIT data - SPD -
57acd2d2 205 fGenOffsetS = (fAliITSQADataMakerSim->fSDigitsQAList[AliRecoParam::kDefault])->GetEntries();
c71529b0 206 //printf("--W-- AliITSQASPDDataMakerSim::InitSDigits() fGenOffset= %d \n",fGenOffset);
7a0e5776 207 //fSPDhSTask must be incremented by one unit every time a histogram is ADDED to the QA List
c71529b0 208
379510c2 209 Char_t name[50];
210 Char_t title[50];
211
26ee9565 212 TH1F *hlayer = new TH1F("SPDLayPattern_SPD","Layer map - SPD",6,0.,6.);
379510c2 213 hlayer->GetXaxis()->SetTitle("Layer number");
214 hlayer->GetYaxis()->SetTitle("Entries");
954ef57a 215 fAliITSQADataMakerSim->Add2SDigitsList(hlayer,fGenOffsetS,kTRUE);
7a0e5776 216 fSPDhSTask++;
379510c2 217
218 TH1F **hmod = new TH1F*[2];
219 for (Int_t iLay=0; iLay<2; ++iLay) {
26ee9565 220 sprintf(name,"SPDModPattern_SPD%d",iLay+1);
379510c2 221 sprintf(title,"Module map - SPD Layer %d",iLay+1);
222 hmod[iLay]=new TH1F(name,title,240,0,240);
223 hmod[iLay]->GetXaxis()->SetTitle("Module number");
224 hmod[iLay]->GetYaxis()->SetTitle("Entries");
3f905799 225 fAliITSQADataMakerSim->Add2SDigitsList(hmod[iLay],1+iLay+fGenOffsetS);
7a0e5776 226 fSPDhSTask++;
379510c2 227 }
379510c2 228
7a0e5776 229 AliDebug(1,Form("%d SPD SDigits histograms booked\n",fSPDhSTask));
379510c2 230
231}
232
233//____________________________________________________________________________
234void AliITSQASPDDataMakerSim::MakeSDigits(TTree *sdigits)
235{
236 // Fill QA for SDIGIT - SPD -
237 TBranch *brchSDigits = sdigits->GetBranch("ITS");
238 for (Int_t imod=0; imod<240; ++imod){
239 TClonesArray * sdig = new TClonesArray( "AliITSpListItem",1000 );
240 brchSDigits->SetAddress( &sdig );
241 brchSDigits->GetEvent(imod);
242 Int_t nsdig=sdig->GetEntries();
243 if (imod<80) {
3f905799 244 fAliITSQADataMakerSim->GetSDigitsData(0+fGenOffsetS)->Fill(0.5,nsdig);
245 fAliITSQADataMakerSim->GetSDigitsData(1+fGenOffsetS)->Fill(imod,nsdig);
379510c2 246 }
247 else {
3f905799 248 fAliITSQADataMakerSim->GetSDigitsData(0+fGenOffsetS)->Fill(1,nsdig);
249 fAliITSQADataMakerSim->GetSDigitsData(2+fGenOffsetS)->Fill(imod,nsdig);
379510c2 250 }
251 delete sdig;
252 }
253
254}
255
256//____________________________________________________________________________
257void AliITSQASPDDataMakerSim::InitHits()
258{
259 // Initialization for HITS data - SPD -
57acd2d2 260 fGenOffsetH = (fAliITSQADataMakerSim->fHitsQAList[AliRecoParam::kDefault])->GetEntries();
c71529b0 261 //printf("--W-- AliITSQASPDDataMakerSim::InitHits() fGenOffset= %d \n",fGenOffset);
7a0e5776 262 //fSPDhHTask must be incremented by one unit every time a histogram is ADDED to the QA List
379510c2 263 Char_t name[50];
264 Char_t title[50];
265
26ee9565 266 TH1F *hlayer = new TH1F("SPDLayPattern_SPD","Layer map - SPD",6,0.,6.);
379510c2 267 hlayer->GetXaxis()->SetTitle("Layer number");
268 hlayer->GetYaxis()->SetTitle("Entries");
954ef57a 269 fAliITSQADataMakerSim->Add2HitsList(hlayer,fGenOffsetH,kTRUE);
7a0e5776 270 fSPDhHTask++;
379510c2 271
272 TH1F **hmod = new TH1F*[2];
273 for (Int_t iLay=0; iLay<2; ++iLay) {
26ee9565 274 sprintf(name,"SPDModPattern_SPD%d",iLay+1);
379510c2 275 sprintf(title,"Module map - SPD Layer %d",iLay+1);
276 hmod[iLay]=new TH1F(name,title,240,0,240);
277 hmod[iLay]->GetXaxis()->SetTitle("Module number");
278 hmod[iLay]->GetYaxis()->SetTitle("Entries");
3f905799 279 fAliITSQADataMakerSim->Add2HitsList(hmod[iLay],1+iLay+fGenOffsetH);
7a0e5776 280 fSPDhHTask++;
379510c2 281 }
282
26ee9565 283 TH1F *hhitlenght = new TH1F("SPDLenght_SPD","Hit lenght along y_{loc} coord",210,0.,210.);
379510c2 284 hhitlenght->GetXaxis()->SetTitle("Hit lenght [#mum]");
285 hhitlenght->GetYaxis()->SetTitle("# hits");
3f905799 286 fAliITSQADataMakerSim->Add2HitsList(hhitlenght,3+fGenOffsetH);
7a0e5776 287 fSPDhHTask++;
379510c2 288
26ee9565 289 TH1F *hEdepos = new TH1F("SPDEnergyDeposit_SPD","Deposited energy distribution (y_{loc}>180 #mum)",150,0.,300.);
379510c2 290 hEdepos->GetXaxis()->SetTitle("Deposited energy [keV]");
291 hEdepos->GetYaxis()->SetTitle("# hits");
3f905799 292 fAliITSQADataMakerSim->Add2HitsList(hEdepos,4+fGenOffsetH);
7a0e5776 293 fSPDhHTask++;
379510c2 294
7a0e5776 295 AliDebug(1,Form("%d SPD Hits histograms booked\n",fSPDhHTask));
379510c2 296
297}
298
299//____________________________________________________________________________
300void AliITSQASPDDataMakerSim::MakeHits(TTree *hits)
301{
302 // Fill QA for HITS - SPD -
303 AliITS *fITS = (AliITS*)gAlice->GetModule("ITS");
304 fITS->SetTreeAddress();
305 Int_t nmodules;
306 fITS->InitModules(-1,nmodules); //-1->number of modules taken from AliITSgeom class kept in fITSgeom
307 //nmodules is set
308
309 fITS->FillModules(hits,0);
310
311 for (Int_t imod=0; imod<240; ++imod){
312 AliITSmodule *module = fITS->GetModule(imod);
313 TObjArray *arrHits = module->GetHits();
314 Int_t nhits = arrHits->GetEntriesFast();
315 if (imod<80) {
3f905799 316 fAliITSQADataMakerSim->GetHitsData(fGenOffsetH)->Fill(0.5,nhits);
317 fAliITSQADataMakerSim->GetHitsData(1+fGenOffsetH)->Fill(imod,nhits);
379510c2 318 } else {
3f905799 319 fAliITSQADataMakerSim->GetHitsData(fGenOffsetH)->Fill(1,nhits);
320 fAliITSQADataMakerSim->GetHitsData(2+fGenOffsetH)->Fill(imod,nhits);
379510c2 321 }
379510c2 322 for (Int_t iHit=0; iHit<nhits; ++iHit) {
323 AliITShit *hit = (AliITShit*) arrHits->At(iHit);
324 Double_t xl,yl,zl,xl0,yl0,zl0;
325 Double_t tof,tof0;
326 hit->GetPositionL(xl,yl,zl,tof);
327 hit->GetPositionL0(xl0,yl0,zl0,tof0);
328 Float_t dyloc=TMath::Abs(yl-yl0)*10000.;
3f905799 329 fAliITSQADataMakerSim->GetHitsData(3+fGenOffsetH)->Fill(dyloc);
379510c2 330 Float_t edep=hit->GetIonization()*1000000;
331 if(dyloc>180.){
3f905799 332 fAliITSQADataMakerSim->GetHitsData(4+fGenOffsetH)->Fill(edep);
379510c2 333 }
334 }
335 }
336}
7a0e5776 337
338
339//_______________________________________________________________
340
4e25ac79 341Int_t AliITSQASPDDataMakerSim::GetOffset(AliQAv1::TASKINDEX_t task){
7a0e5776 342 // Returns histogram offset according to the specified task
343 Int_t offset=0;
4e25ac79 344 if( task == AliQAv1::kHITS){
7a0e5776 345 offset=fGenOffsetH;
346 }
4e25ac79 347 else if( task == AliQAv1::kSDIGITS) {
7a0e5776 348 offset=fGenOffsetS;
349 }
4e25ac79 350 else if( task == AliQAv1::kDIGITS) {
7a0e5776 351 offset=fGenOffsetD;
352 }
353 else {
354 AliInfo("No task has been selected. TaskHisto set to zero.\n");
355 }
356
357 return offset;
358}
359
360
361//_______________________________________________________________
362
4e25ac79 363Int_t AliITSQASPDDataMakerSim::GetTaskHisto(AliQAv1::TASKINDEX_t task) {
7a0e5776 364 // Returns the number of booked histograms for the selected task
365 Int_t histotot=0;
4e25ac79 366 if( task == AliQAv1::kHITS) {
7a0e5776 367 histotot=fSPDhHTask ;
368 }
4e25ac79 369 else if( task == AliQAv1::kSDIGITS) {
7a0e5776 370 histotot=fSPDhSTask;
371 }
4e25ac79 372 else if( task == AliQAv1::kDIGITS) {
7a0e5776 373 histotot=fSPDhDTask ;
374 }
375 else {
376 AliInfo("No task has been selected. TaskHisto set to zero.\n");
377 }
378 return histotot;
379
380}