minor fix
[u/mrichter/AliRoot.git] / ITS / AliITSQASDDDataMakerSim.cxx
CommitLineData
a65a7e70 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
26// --- ROOT system ---
27#include <TTree.h>
28// --- Standard library ---
29
30// --- AliRoot header files ---
31#include "AliITSQASDDDataMakerSim.h"
32#include "AliLog.h"
33#include "AliQAv1.h"
34#include "AliQAChecker.h"
35#include "AliQADataMakerSim.h"
36#include "AliITSQADataMakerSim.h"
37#include "AliRawReader.h"
38#include "AliITSdigit.h"
39#include "AliITS.h"
40#include "AliITSmodule.h"
41#include "AliITShit.h"
42#include "AliITSLoader.h"
43#include "AliRunLoader.h"
44#include "AliRun.h"
45#include "AliITSsegmentationSDD.h"
46#include "AliITSpList.h"
47
48ClassImp(AliITSQASDDDataMakerSim)
49
50//____________________________________________________________________________
51AliITSQASDDDataMakerSim::AliITSQASDDDataMakerSim(AliITSQADataMakerSim *aliITSQADataMakerSim) :
52TObject(),
53fAliITSQADataMakerSim(aliITSQADataMakerSim),
54fSDDhHTask(0),
55fSDDhSTask(0),
56fSDDhDTask(0),
57fGenOffsetH(0),
58fGenOffsetS(0),
59fGenOffsetD(0)
60{
61 //ctor used to discriminate OnLine-Offline analysis
62 fGenOffsetH= new Int_t[AliRecoParam::kNSpecies];
63 fGenOffsetS= new Int_t[AliRecoParam::kNSpecies];
64 fGenOffsetD= new Int_t[AliRecoParam::kNSpecies];
65 for(Int_t i=0; i<AliRecoParam::kNSpecies; i++)
66 {
67 fGenOffsetH[i]= 0;
68 fGenOffsetS[i]= 0;
69 fGenOffsetD[i]= 0;
70 }
71}
72
73//____________________________________________________________________________
74AliITSQASDDDataMakerSim::AliITSQASDDDataMakerSim(const AliITSQASDDDataMakerSim& qadm) :
75TObject(),
76fAliITSQADataMakerSim(qadm.fAliITSQADataMakerSim),
77fSDDhHTask(qadm.fSDDhHTask),
78fSDDhSTask(qadm.fSDDhSTask),
79fSDDhDTask(qadm.fSDDhDTask),
80fGenOffsetH(qadm.fGenOffsetH),
81fGenOffsetS(qadm.fGenOffsetS),
82fGenOffsetD(qadm.fGenOffsetD)
83{
84 //copy ctor
85 fAliITSQADataMakerSim->SetName((const char*)qadm.fAliITSQADataMakerSim->GetName()) ;
86 fAliITSQADataMakerSim->SetTitle((const char*)qadm.fAliITSQADataMakerSim->GetTitle());
87
88}
89
90//__________________________________________________________________
91AliITSQASDDDataMakerSim& AliITSQASDDDataMakerSim::operator = (const AliITSQASDDDataMakerSim& qac )
92{
93 // Equal operator.
94 this->~AliITSQASDDDataMakerSim();
95 new(this) AliITSQASDDDataMakerSim(qac);
96 return *this;
97}
98
99//____________________________________________________________________________
100void AliITSQASDDDataMakerSim::StartOfDetectorCycle()
101{
102 //Detector specific actions at start of cycle
103 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQADM::Start of SDD Cycle\n");
104}
105
106//____________________________________________________________________________
107void AliITSQASDDDataMakerSim::EndOfDetectorCycle(AliQAv1::TASKINDEX_t /*task*/, TObjArray** /*list*/)
108{
109 // launch the QA checking
110 //
111 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSDM instantiates checker with Run(AliQAv1::kITS, task, list)\n");
112 //AliQAChecker::Instance()->Run( AliQAv1::kITS , task, list);
113}
114
115//____________________________________________________________________________
116Int_t AliITSQASDDDataMakerSim::InitDigits()
117{
118 // Initialization for DIGIT data - SDD -
119 const Bool_t expert = kTRUE ;
120 const Bool_t image = kTRUE ;
121 Int_t rv = 0 ;
122 //fGenOffsetD = (fAliITSQADataMakerSim->fDigitsQAList[AliRecoParam::kDefault])->GetEntries();
123 //fSDDhTask must be incremented by one unit every time a histogram is ADDED to the QA List
124 TH1F* h0=new TH1F("SDD DIGITS Module Pattern","SDD DIGITS Module Pattern",260,239.5,499.5); //hmod
125 h0->GetXaxis()->SetTitle("SDD Module Number");
126 h0->GetYaxis()->SetTitle("# DIGITS");
127 rv = fAliITSQADataMakerSim->Add2DigitsList(h0,fGenOffsetD[fAliITSQADataMakerSim->GetEventSpecie()], !expert, image);
128 fSDDhDTask ++;
129 TH1F* h1=new TH1F("SDD Anode Distribution","SDD DIGITS Anode Distribution",512,-0.5,511.5); //hanocc
130 h1->GetXaxis()->SetTitle("Anode Number");
131 h1->GetYaxis()->SetTitle("# DIGITS");
132 rv = fAliITSQADataMakerSim->Add2DigitsList(h1,1+fGenOffsetD[fAliITSQADataMakerSim->GetEventSpecie()], !expert, image);
133 fSDDhDTask ++;
134 TH1F* h2=new TH1F("SDD Tbin Distribution","SDD DIGITS Tbin Distribution",256,-0.5,255.5); //htbocc
135 h2->GetXaxis()->SetTitle("Tbin Number");
136 h2->GetYaxis()->SetTitle("# DIGITS");
137 rv = fAliITSQADataMakerSim->Add2DigitsList(h2,2+fGenOffsetD[fAliITSQADataMakerSim->GetEventSpecie()], !expert, image);
138 fSDDhDTask ++;
139 TH1F* h3=new TH1F("SDD ADC Counts Distribution","SDD DIGITS ADC Counts Distribution",200,0.,1024.); //hsig
140 h3->GetXaxis()->SetTitle("ADC Value");
141 h3->GetYaxis()->SetTitle("# DIGITS");
142 rv = fAliITSQADataMakerSim->Add2DigitsList(h3,3+fGenOffsetD[fAliITSQADataMakerSim->GetEventSpecie()], !expert, image);
143 fSDDhDTask ++;
144 AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SDD Digits histograms booked\n",fSDDhDTask));
145 return rv ;
146}
147
148//____________________________________________________________________________
149Int_t AliITSQASDDDataMakerSim::MakeDigits(TTree * digits)
150{
151
152 // Fill QA for DIGIT - SDD -
153 Int_t rv = 0 ;
154
155 AliITS *fITS = (AliITS*)gAlice->GetModule("ITS");
156 fITS->SetTreeAddress();
157 TClonesArray *iITSdigits = fITS->DigitsAddress(1);
158 for(Int_t i=0; i<260; i++){
159 Int_t nmod=i+240;
160 digits->GetEvent(nmod);
161 Int_t ndigits = iITSdigits->GetEntries();
162 fAliITSQADataMakerSim->FillDigitsData(fGenOffsetD[fAliITSQADataMakerSim->GetEventSpecie()],nmod,ndigits);
163 for (Int_t idig=0; idig<ndigits; idig++) {
164 AliITSdigit *dig=(AliITSdigit*)iITSdigits->UncheckedAt(idig);
165 Int_t iz=dig->GetCoord1(); // cell number z
166 Int_t ix=dig->GetCoord2(); // cell number x
167 Int_t sig=dig->GetSignal();
168 fAliITSQADataMakerSim->FillDigitsData(1+fGenOffsetD[fAliITSQADataMakerSim->GetEventSpecie()],iz);
169 fAliITSQADataMakerSim->FillDigitsData(2+fGenOffsetD[fAliITSQADataMakerSim->GetEventSpecie()],ix);
170 fAliITSQADataMakerSim->FillDigitsData(3+fGenOffsetD[fAliITSQADataMakerSim->GetEventSpecie()],sig);
171 }
172 }
173 //
174 return rv ;
175}
176
177//____________________________________________________________________________
178Int_t AliITSQASDDDataMakerSim::InitSDigits()
179{
180 // Initialization for SDIGIT data - SDD -
181 const Bool_t expert = kTRUE ;
182 const Bool_t image = kTRUE ;
183 Int_t rv = 0 ;
184 //fGenOffsetS = (fAliITSQADataMakerSim->fSDigitsQAList[AliRecoParam::kDefault])->GetEntries();
185 //fSDDhTask must be incremented by one unit every time a histogram is ADDED to the QA List
186 TH1F* h0=new TH1F("SDD SDIGITS Module Pattern","SDIGITS SDD Module Pattern",260,239.5,499.5); //hmod
187 h0->GetXaxis()->SetTitle("SDD Module Number");
188 h0->GetYaxis()->SetTitle("# SDIGITS");
189 rv = fAliITSQADataMakerSim->Add2SDigitsList(h0,fGenOffsetS[fAliITSQADataMakerSim->GetEventSpecie()], !expert, image);
190 fSDDhSTask ++;
191 TH1F* h1=new TH1F("SDD Anode Distribution","SDIGITS SDD Anode Distribution",512,-0.5,511.5); //hanocc
192 h1->GetXaxis()->SetTitle("Anode Number");
193 h1->GetYaxis()->SetTitle("# SDIGITS");
194 rv = fAliITSQADataMakerSim->Add2SDigitsList(h1,1+fGenOffsetS[fAliITSQADataMakerSim->GetEventSpecie()], !expert, image);
195 fSDDhSTask ++;
196 TH1F* h2=new TH1F("SDD Tbin Distribution","SDIGITS SDD Tbin Distribution",256,-0.5,255.5); //htbocc
197 h2->GetXaxis()->SetTitle("Tbin Number");
198 h2->GetYaxis()->SetTitle("# SDIGITS");
199 rv = fAliITSQADataMakerSim->Add2SDigitsList(h2,2+fGenOffsetS[fAliITSQADataMakerSim->GetEventSpecie()]);
200 fSDDhSTask ++;
201 TH1F* h3=new TH1F("SDD ADC Counts Distribution","SDIGITS SDD ADC Counts Distribution",200,0.,1024.); //hsig
202 h3->GetXaxis()->SetTitle("ADC Value");
203 h3->GetYaxis()->SetTitle("# SDIGITS");
204 rv = fAliITSQADataMakerSim->Add2SDigitsList(h3,3+fGenOffsetS[fAliITSQADataMakerSim->GetEventSpecie()], !expert, image);
205 fSDDhSTask ++;
206
207 AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SDD SDigits histograms booked\n",fSDDhSTask));
208 return rv ;
209}
210
211//____________________________________________________________________________
212Int_t AliITSQASDDDataMakerSim::MakeSDigits(TTree * sdigits)
213{
214 // Fill QA for SDIGIT - SDD -
215 Int_t rv = 0 ;
216
217 AliITSsegmentationSDD* seg = new AliITSsegmentationSDD();
218 Int_t nan=seg->Npz();
219 Int_t ntb=seg->Npx();
220 Int_t scaleSize=4;
221 AliITSpList* list=new AliITSpList(nan,ntb*scaleSize);
222
223 //AliITS *fITS = (AliITS*)gAlice->GetModule("ITS");
224 //fITS->SetTreeAddress();
225 //TClonesArray *ITSdigits = fITS->DigitsAddress(1);
226 //TFile *sper = new TFile("sper.root","CREATE"); //agginto a mano x prova
227 //digits->Write();
228 //sper->Close();
229
230
231 TBranch *brchSDigits = sdigits->GetBranch("ITS");
232 static TClonesArray * sdig ;
233 if (! sdig )
234 sdig = new TClonesArray( "AliITSpListItem",1000 );
235 for(Int_t id=0; id<260; id++){
236 Int_t nmod=id+240;
237 brchSDigits->SetAddress( &sdig );
238 brchSDigits->GetEvent(nmod);
239 Int_t nsdig=sdig->GetEntries();
240 fAliITSQADataMakerSim->FillSDigitsData(fGenOffsetS[fAliITSQADataMakerSim->GetEventSpecie()],nmod,nsdig);
241 for(Int_t i=0;i<nsdig;i++){
242 AliITSpListItem *cell=(AliITSpListItem*)sdig->At(i);
243 Float_t sig=cell->GetSignal();
244 Int_t idx=cell->GetIndex();
245 Int_t ia,it;
246 list->GetCell(idx,ia,it);
247 fAliITSQADataMakerSim->FillSDigitsData(1+fGenOffsetS[fAliITSQADataMakerSim->GetEventSpecie()],ia);
248 fAliITSQADataMakerSim->FillSDigitsData(2+fGenOffsetS[fAliITSQADataMakerSim->GetEventSpecie()],it);
249 fAliITSQADataMakerSim->FillSDigitsData(3+fGenOffsetS[fAliITSQADataMakerSim->GetEventSpecie()],sig);
250 }
251 sdig->Clear();
252 }
253 //
254 return rv ;
255}
256
257//____________________________________________________________________________
258Int_t AliITSQASDDDataMakerSim::InitHits()
259{
260
261 // Initialization for HITS data - SDD -
262 const Bool_t expert = kTRUE ;
263 const Bool_t image = kTRUE ;
264 Int_t rv = 0 ;
265
266 //fGenOffsetH = (fAliITSQADataMakerSim->fHitsQAList[AliRecoParam::kDefault])->GetEntries();
267 //fSDDhTask must be incremented by one unit every time a histogram is ADDED to the QA List
268 //printf("AliITSQASDDDataMakerSim::InitHits called \n");
269 TH1F *h0=new TH1F("SDD HITS Module Pattern","SDD HITS Module Pattern",260,239.5,499.5);
270 h0->GetXaxis()->SetTitle("SDD Module Number");
271 h0->GetYaxis()->SetTitle("# HITS");
272 rv = fAliITSQADataMakerSim->Add2HitsList(h0,fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()], !expert, image);
273 fSDDhHTask ++;
274 TH1F *h1=new TH1F("SDD HIT lenght along local Y Coord","SDD HIT lenght along local Y Coord",200,0.,350.);
275 h1->GetXaxis()->SetTitle("HIT lenght (um)");
276 h1->GetYaxis()->SetTitle("# HITS");
277 rv = fAliITSQADataMakerSim->Add2HitsList(h1,1+fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()], !expert, image);
278 fSDDhHTask ++;
279 TH1F *h2=new TH1F("SDD HIT lenght along local Y Coord - Zoom","SDD HIT lenght along local Y Coord - Zoom",200,250.,350.);
280 h2->GetXaxis()->SetTitle("HIT lenght (um)");
281 h2->GetYaxis()->SetTitle("# HITS");
282 rv = fAliITSQADataMakerSim->Add2HitsList(h2,2+fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()], !expert, image);
283 fSDDhHTask ++;
284 TH1F *h3=new TH1F("SDD Deposited Energy Distribution (loc Y > 200um)","SDD HITS Deposited Energy Distribution (loc Y > 200um)",200,0.,350.);
285 h3->GetXaxis()->SetTitle("ADC counts ");
286 h3->GetYaxis()->SetTitle("# HITS");
287 rv = fAliITSQADataMakerSim->Add2HitsList(h3,3+fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()], !expert, image);
288 fSDDhHTask ++;
289 AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SDD Hits histograms booked\n",fSDDhHTask));
290 return rv ;
291}
292
293//____________________________________________________________________________
294Int_t AliITSQASDDDataMakerSim::MakeHits(TTree * hits)
295{
296 // Fill QA for HITS - SDD -
297 Int_t rv = 0 ;
298
299 AliITS *fITS = (AliITS*)gAlice->GetModule("ITS");
300 fITS->SetTreeAddress();
301 Int_t nmodules;
302 if(!(fITS->InitModules(-1,nmodules))){
303 AliError("ITS geometry not available - nothing done");
304 return rv;
305 }
306
307 fITS->FillModules(hits,0);
308
309 for(Int_t i=0; i<260; i++){
310 Int_t nmod=i+240;
311 AliITSmodule *modu = fITS->GetModule(nmod);
312 TObjArray *arrHits = modu->GetHits();
313 Int_t nhits = arrHits->GetEntriesFast();
314 ////printf("--w--AliITSQASDDDataMakerSim::MakeHits nhits = %d\n",nhits);
315 for (Int_t iHit=0;iHit<nhits;iHit++) {
316 AliITShit *hit = (AliITShit*) arrHits->At(iHit);
317 fAliITSQADataMakerSim->FillHitsData(fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()],nmod);
318 Double_t xl,yl,zl,xl0,yl0,zl0;
319 Double_t tof,tof0;
320 hit->GetPositionL(xl,yl,zl,tof);
321 hit->GetPositionL0(xl0,yl0,zl0,tof0);
322 Float_t dyloc=TMath::Abs(yl-yl0)*10000.;
323 fAliITSQADataMakerSim->FillHitsData(1+fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()],dyloc);
324 Float_t edep=hit->GetIonization()*1000000;
325 if(dyloc>200.){
326 fAliITSQADataMakerSim->FillHitsData(2+fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()],edep);
327 fAliITSQADataMakerSim->FillHitsData(3+fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()],dyloc);
328 }
329 }
330 }
331 //
332 return rv ;
333}
334
335//_______________________________________________________________
336
337Int_t AliITSQASDDDataMakerSim::GetOffset(AliQAv1::TASKINDEX_t task, Int_t specie){
338 // Returns histogram offset according to the specified task
339 Int_t offset=0;
340 if( task == AliQAv1::kHITS){
341 offset=fGenOffsetH[specie];
342 }
343 else if( task == AliQAv1::kSDIGITS) {
344 offset=fGenOffsetS[specie];
345 }
346 else if( task == AliQAv1::kDIGITS) {
347 offset=fGenOffsetD[specie];
348 }
349 else {
350 AliInfo("No task has been selected. TaskHisto set to zero.\n");
351 }
352
353 return offset;
354}
355
356//____________________________________________________________________________
357void AliITSQASDDDataMakerSim::SetOffset(AliQAv1::TASKINDEX_t task, Int_t offset,Int_t specie ){
358 // Returns histogram offset according to the specified task
359 if( task == AliQAv1::kHITS){
360 fGenOffsetH[specie] = offset;
361 }
362 else if( task == AliQAv1::kSDIGITS) {
363 fGenOffsetS[specie] = offset;
364 }
365 else if( task == AliQAv1::kDIGITS) {
366 fGenOffsetD[specie] = offset;
367 }
368 else {
369 AliInfo("No task has been selected. TaskHisto set to zero.\n");
370 }
371}
372
373//_______________________________________________________________
374
375Int_t AliITSQASDDDataMakerSim::GetTaskHisto(AliQAv1::TASKINDEX_t task) {
376 // Returns the number of booked histograms for the selected task
377 Int_t histotot=0;
378 if( task == AliQAv1::kHITS) {
379 histotot=fSDDhHTask ;
380 }
381 else if( task == AliQAv1::kSDIGITS) {
382 histotot=fSDDhSTask;
383 }
384 else if( task == AliQAv1::kDIGITS) {
385 histotot=fSDDhDTask ;
386 }
387 else {
388 AliInfo("No task has been selected. TaskHisto set to zero.\n");
389 }
390 return histotot;
391
392}