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