For Pythia with tune don't switch off MI in ConfigHeavyFlavor
[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{
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//____________________________________________________________________________
4e25ac79 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//____________________________________________________________________________
eca4fa66 140Int_t AliITSQASSDDataMakerSim::MakeDigits(TTree *digits) {
7a0e5776 141 // Fill QA for DIGIT - SSD -
eca4fa66 142 Int_t rv = 0 ;
6252ceeb 143
7a0e5776 144 AliITS *fITS = (AliITS*)gAlice->GetModule("ITS");
145 fITS->SetTreeAddress();
146 TClonesArray *iSSDdigits = fITS->DigitsAddress(2);
147 for(Int_t iModule = 500; iModule < 2198; iModule++) {
148 iSSDdigits->Clear();
149 digits->GetEvent(iModule);
150 Int_t ndigits = iSSDdigits->GetEntries();
4a903927 151 fAliITSQADataMakerSim->GetDigitsData(fGenOffsetD[fAliITSQADataMakerSim->GetEventSpecie()] + 0)->Fill(iModule,ndigits);
7a0e5776 152 if(ndigits != 0)
5379c4a3 153 AliDebug(AliQAv1::GetQADebugLevel(),Form("Module: %d - Digits: %d",iModule,ndigits));
7a0e5776 154
155 for (Int_t iDigit = 0; iDigit < ndigits; iDigit++) {
156 AliITSdigit *dig = (AliITSdigit*)iSSDdigits->UncheckedAt(iDigit);
157 Int_t fStripNumber = (dig->GetCoord1() == 0) ? dig->GetCoord2() : dig->GetCoord2() + fgkNumberOfPSideStrips;
4a903927 158 ((TH2F *)fAliITSQADataMakerSim->GetDigitsData(fGenOffsetD[fAliITSQADataMakerSim->GetEventSpecie()] + 1))->Fill(fStripNumber,iModule,dig->GetSignal());
7a0e5776 159 }//digit loop
160 }//module loop
eca4fa66 161 return rv ;
7a0e5776 162}
163
164//____________________________________________________________________________
eca4fa66 165Int_t AliITSQASSDDataMakerSim::InitSDigits() {
7a0e5776 166 // Initialization for SDIGIT data - SSD -
7d297381 167 const Bool_t expert = kTRUE ;
168 const Bool_t image = kTRUE ;
eca4fa66 169 Int_t rv = 0 ;
170 //fGenOffsetS = (fAliITSQADataMakerSim->fSDigitsQAList[AliRecoParam::kDefault])->GetEntries();
7a0e5776 171
172 // custom code here
173 TH1F *fHistSSDModule = new TH1F("fHistSSDSDigitsModule",
db72ff3b 174 "SSD SDigits Module;SSD Module Number;N_{SDIGITS}",
7a0e5776 175 1698,499.5,2197.5);
eca4fa66 176 rv = fAliITSQADataMakerSim->Add2SDigitsList(fHistSSDModule,
4a903927 177 fGenOffsetS[fAliITSQADataMakerSim->GetEventSpecie()] + 0, !expert, image);
7a0e5776 178 fSSDhSTask += 1;
179
5379c4a3 180 AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SSD SDigits histograms booked\n",fSSDhSTask));
eca4fa66 181 return rv ;
7a0e5776 182}
183
184//____________________________________________________________________________
eca4fa66 185Int_t AliITSQASSDDataMakerSim::MakeSDigits(TTree *sdigits) {
7a0e5776 186 // Fill QA for SDIGIT - SSD -
eca4fa66 187 Int_t rv = 0 ;
eca4fa66 188
7a0e5776 189 static TClonesArray iSSDEmpty("AliITSpListItem",10000);
190 iSSDEmpty.Clear();
191 TClonesArray *iSSDsdigits = &iSSDEmpty;
192
5379c4a3 193 AliDebug(AliQAv1::GetQADebugLevel(), Form("Trying to access the sdigits histogram: %d\n",fGenOffsetS));
7a0e5776 194
195 TBranch *brchSDigits = sdigits->GetBranch("ITS");
196 brchSDigits->SetAddress(&iSSDsdigits);
197 for(Int_t iModule = 500; iModule < 2198; iModule++) {
198 iSSDsdigits->Clear();
199 sdigits->GetEvent(iModule);
200 Int_t ndigits = iSSDsdigits->GetEntries();
4a903927 201 fAliITSQADataMakerSim->GetSDigitsData(fGenOffsetS[fAliITSQADataMakerSim->GetEventSpecie()] + 0)->Fill(iModule,ndigits);
7a0e5776 202 if(ndigits != 0)
5379c4a3 203 AliDebug(AliQAv1::GetQADebugLevel(),Form("Module: %d - Digits: %d",iModule,ndigits));
7a0e5776 204
205 for (Int_t iDigit = 0; iDigit < ndigits; iDigit++) {
206 AliITSpListItem *dig=(AliITSpListItem*)iSSDsdigits->At(iDigit);
207 dig=0;
208 }//digit loop
209 }//module loop
eca4fa66 210 return rv ;
7a0e5776 211}
212
213//____________________________________________________________________________
eca4fa66 214Int_t AliITSQASSDDataMakerSim::InitHits() {
7a0e5776 215 // Initialization for HITS data - SSD -
7d297381 216 const Bool_t expert = kTRUE ;
217 const Bool_t image = kTRUE ;
eca4fa66 218 Int_t rv = 0 ;
219
220 //fGenOffsetH = (fAliITSQADataMakerSim->fHitsQAList[fEventSpecie])->GetEntries();
7a0e5776 221
222 // custom code here
223 TH1F *fHistSSDModule = new TH1F("fHistSSDHitsModule",
ba3bf74e 224 "SSD Hits Module;SSD Module Number;N_{HITS}",
7a0e5776 225 1698,499.5,2197.5);
eca4fa66 226 rv = fAliITSQADataMakerSim->Add2HitsList(fHistSSDModule,
4a903927 227 fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()] + 0, !expert, image);
7a0e5776 228 fSSDhHTask += 1;
229 TH1F *fHistSSDGlobalX = new TH1F("fHistSSDHitsGlobalX",
db72ff3b 230 "SSD Hits Global X;x [cm];Entries",
7a0e5776 231 1000,-50.,50.);
eca4fa66 232 rv = fAliITSQADataMakerSim->Add2HitsList(fHistSSDGlobalX,
4a903927 233 fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()] + 1, !expert, image);
7a0e5776 234 fSSDhHTask += 1;
235 TH1F *fHistSSDGlobalY = new TH1F("fHistSSDHitsGlobalY",
db72ff3b 236 "SSD Hits Global Y;y [cm];Entries",
7a0e5776 237 1000,-50.,50.);
eca4fa66 238 rv = fAliITSQADataMakerSim->Add2HitsList(fHistSSDGlobalY,
4a903927 239 fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()] + 2, !expert, image);
7a0e5776 240 fSSDhHTask += 1;
241 TH1F *fHistSSDGlobalZ = new TH1F("fHistSSDHitsGlobalZ",
db72ff3b 242 "SSD Hits Global Z ;z [cm];Entries",
7a0e5776 243 1000,-60.,60.);
eca4fa66 244 rv = fAliITSQADataMakerSim->Add2HitsList(fHistSSDGlobalZ,
4a903927 245 fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()] + 3, !expert, image);
7a0e5776 246 fSSDhHTask += 1;
247 TH1F *fHistSSDLocalX = new TH1F("fHistSSDHitsLocalX",
db72ff3b 248 "SSD Hits Local X;x [cm];Entries",
7a0e5776 249 1000,-4.,4.);
eca4fa66 250 rv = fAliITSQADataMakerSim->Add2HitsList(fHistSSDLocalX,
4a903927 251 fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()] + 4, !expert, image);
7a0e5776 252 fSSDhHTask += 1;
253 TH1F *fHistSSDLocalY = new TH1F("fHistSSDHitsLocalY",
db72ff3b 254 "SSD Hits Local Y;y [cm];Entries",
7a0e5776 255 1000,-0.1,0.1);
eca4fa66 256 rv = fAliITSQADataMakerSim->Add2HitsList(fHistSSDLocalY,
4a903927 257 fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()] + 5, !expert, image);
7a0e5776 258 fSSDhHTask += 1;
259 TH1F *fHistSSDLocalZ = new TH1F("fHistSSDHitsLocalZ",
db72ff3b 260 "SSD Hits Local Z;z [cm];Entries",
7a0e5776 261 1000,-4.,4.);
eca4fa66 262 rv = fAliITSQADataMakerSim->Add2HitsList(fHistSSDLocalZ,
4a903927 263 fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()] + 6, !expert, image);
7a0e5776 264 fSSDhHTask += 1;
265 TH1F *fHistSSDIonization = new TH1F("fHistSSDHitsIonization",
db72ff3b 266 "SSD Hits Ionization;log(dE/dx) [KeV];N_{Hits}",
7a0e5776 267 100,-7,-2);
eca4fa66 268 rv = fAliITSQADataMakerSim->Add2HitsList(fHistSSDIonization,
4a903927 269 fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()] + 7, !expert, image);
7a0e5776 270 fSSDhHTask += 1;
271 TH2F *fHistSSDGlobalXY = new TH2F("fHistSSDHitsGlobalXY",
db72ff3b 272 "SSD Hits Global XY;x [cm];y [cm]",
7a0e5776 273 1000,-50.,50.,
274 1000,-50.,50.);
eca4fa66 275 rv = fAliITSQADataMakerSim->Add2HitsList(fHistSSDGlobalXY,
4a903927 276 fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()] + 8, !expert, image);
7a0e5776 277 fSSDhHTask += 1;
278
5379c4a3 279 AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SSD Hits histograms booked\n",fSSDhHTask));
eca4fa66 280 return rv ;
7a0e5776 281}
282
283
284//____________________________________________________________________________
eca4fa66 285Int_t AliITSQASSDDataMakerSim::MakeHits(TTree *hits) {
7a0e5776 286 // Fill QA for HITS - SSD -
eca4fa66 287 Int_t rv = 0 ;
eca4fa66 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
4a903927 303 fAliITSQADataMakerSim->GetHitsData(fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()] + 0)->Fill(iModule);
304 fAliITSQADataMakerSim->GetHitsData(fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()] + 1)->Fill(hit->GetXG());
305 fAliITSQADataMakerSim->GetHitsData(fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()] + 2)->Fill(hit->GetYG());
306 fAliITSQADataMakerSim->GetHitsData(fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()] + 3)->Fill(hit->GetZG());
307 fAliITSQADataMakerSim->GetHitsData(fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()] + 4)->Fill(hit->GetXL());
308 fAliITSQADataMakerSim->GetHitsData(fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()] + 5)->Fill(hit->GetYL());
309 fAliITSQADataMakerSim->GetHitsData(fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()] + 6)->Fill(hit->GetZL());
7a0e5776 310 if(hit->GetIonization())
4a903927 311 fAliITSQADataMakerSim->GetHitsData(fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()] + 7)->Fill(TMath::Log10(hit->GetIonization()));
312 fAliITSQADataMakerSim->GetHitsData(fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()] + 8)->Fill(hit->GetXG(),hit->GetYG());
7a0e5776 313 }//hit loop
314 }//module loop
eca4fa66 315 return rv ;
7a0e5776 316}
317
7a0e5776 318//____________________________________________________________________________
80b9610c 319Int_t AliITSQASSDDataMakerSim::GetOffset(AliQAv1::TASKINDEX_t task,Int_t specie){
7a0e5776 320 // Returns histogram offset according to the specified task
321 Int_t offset=0;
4e25ac79 322 if( task == AliQAv1::kHITS){
80b9610c 323 offset=fGenOffsetH[specie];
7a0e5776 324 }
4e25ac79 325 else if( task == AliQAv1::kSDIGITS) {
80b9610c 326 offset=fGenOffsetS[specie];
7a0e5776 327 }
4e25ac79 328 else if( task == AliQAv1::kDIGITS) {
80b9610c 329 offset=fGenOffsetD[specie];
7a0e5776 330 }
331 else {
332 AliInfo("No task has been selected. TaskHisto set to zero.\n");
333 }
334
335 return offset;
336}
337
338
339//____________________________________________________________________________
4a903927 340void AliITSQASSDDataMakerSim::SetOffset(AliQAv1::TASKINDEX_t task, Int_t offset,Int_t specie ){
eca4fa66 341 // Returns histogram offset according to the specified task
342 if( task == AliQAv1::kHITS){
4a903927 343 fGenOffsetH[specie] = offset;
eca4fa66 344 }
345 else if( task == AliQAv1::kSDIGITS) {
4a903927 346 fGenOffsetS[specie] = offset;
eca4fa66 347 }
348 else if( task == AliQAv1::kDIGITS) {
4a903927 349 fGenOffsetD[specie] = offset;
eca4fa66 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}