Introducing event specie in QA (Yves)
[u/mrichter/AliRoot.git] / ITS / AliITSQASDDDataMakerSim.cxx
CommitLineData
8dc34e37 1/**************************************************************************\r
2 * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *\r
3 * *\r
4 * Author: The ALICE Off-line Project. *\r
5 * Contributors are mentioned in the code where appropriate. *\r
6 * *\r
7 * Permission to use, copy, modify and distribute this software and its *\r
8 * documentation strictly for non-commercial purposes is hereby granted *\r
9 * without fee, provided that the above copyright notice appears in all *\r
10 * copies and that both the copyright notice and this permission notice *\r
11 * appear in the supporting documentation. The authors make no claims *\r
12 * about the suitability of this software for any purpose. It is *\r
13 * provided "as is" without express or implied warranty. *\r
14 **************************************************************************/\r
15\r
6f5308d9 16/* $Id$ */\r
17\r
8dc34e37 18// *************************************************************\r
19// Checks the quality assurance \r
20// by comparing with reference data\r
21// contained in a DB\r
22// -------------------------------------------------------------\r
23// W. Ferrarese + P. Cerello Feb 2008\r
24// INFN Torino\r
25\r
26// --- ROOT system ---\r
27#include <TTree.h>\r
28// --- Standard library ---\r
29\r
30// --- AliRoot header files ---\r
31#include "AliITSQASDDDataMakerSim.h"\r
32#include "AliLog.h"\r
33#include "AliQA.h"\r
34#include "AliQAChecker.h"\r
35#include "AliQADataMakerSim.h"\r
36#include "AliITSQADataMakerSim.h"\r
37#include "AliRawReader.h"\r
38#include "AliITSdigit.h"\r
39#include "AliITS.h"\r
40#include "AliITSmodule.h"\r
41#include "AliITShit.h"\r
42#include "AliITSLoader.h"\r
43#include "AliRunLoader.h"\r
44#include "AliRun.h"\r
45#include "AliITSsegmentationSDD.h"\r
46#include "AliITSpList.h"\r
47\r
48ClassImp(AliITSQASDDDataMakerSim)\r
49\r
50//____________________________________________________________________________ \r
51AliITSQASDDDataMakerSim::AliITSQASDDDataMakerSim(AliITSQADataMakerSim *aliITSQADataMakerSim) :\r
52TObject(),\r
53fAliITSQADataMakerSim(aliITSQADataMakerSim),\r
ad300de9 54fSDDhHTask(0),\r
55fSDDhSTask(0),\r
56fSDDhDTask(0),\r
3f905799 57fGenOffsetH(0),\r
58fGenOffsetS(0),\r
59fGenOffsetD(0)\r
8dc34e37 60{\r
61 //ctor used to discriminate OnLine-Offline analysis \r
62}\r
63\r
64//____________________________________________________________________________ \r
65AliITSQASDDDataMakerSim::AliITSQASDDDataMakerSim(const AliITSQASDDDataMakerSim& qadm) :\r
66TObject(),\r
67fAliITSQADataMakerSim(qadm.fAliITSQADataMakerSim),\r
ad300de9 68fSDDhHTask(qadm.fSDDhHTask),\r
69fSDDhSTask(qadm.fSDDhSTask),\r
70fSDDhDTask(qadm.fSDDhDTask),\r
3f905799 71fGenOffsetH(qadm.fGenOffsetH),\r
72fGenOffsetS(qadm.fGenOffsetS),\r
73fGenOffsetD(qadm.fGenOffsetD)\r
8dc34e37 74{\r
75 //copy ctor \r
76 fAliITSQADataMakerSim->SetName((const char*)qadm.fAliITSQADataMakerSim->GetName()) ; \r
77 fAliITSQADataMakerSim->SetTitle((const char*)qadm.fAliITSQADataMakerSim->GetTitle());\r
78 }\r
79\r
80//__________________________________________________________________\r
81AliITSQASDDDataMakerSim& AliITSQASDDDataMakerSim::operator = (const AliITSQASDDDataMakerSim& qac )\r
82{\r
83 // Equal operator.\r
84 this->~AliITSQASDDDataMakerSim();\r
85 new(this) AliITSQASDDDataMakerSim(qac);\r
86 return *this;\r
87}\r
88\r
89//____________________________________________________________________________ \r
90void AliITSQASDDDataMakerSim::StartOfDetectorCycle()\r
91{\r
92 //Detector specific actions at start of cycle\r
93 AliDebug(1,"AliITSQADM::Start of SDD Cycle\n");\r
94}\r
95\r
96//____________________________________________________________________________ \r
97void AliITSQASDDDataMakerSim::EndOfDetectorCycle(AliQA::TASKINDEX_t /*task*/, TObjArray* /*list*/)\r
98{\r
99 // launch the QA checking\r
100 AliDebug(1,"AliITSDM instantiates checker with Run(AliQA::kITS, task, list)\n"); \r
101 //AliQAChecker::Instance()->Run( AliQA::kITS , task, list);\r
102}\r
103\r
104//____________________________________________________________________________ \r
105void AliITSQASDDDataMakerSim::InitDigits()\r
106{ \r
c71529b0 107 // Initialization for DIGIT data - SDD - \r
57acd2d2 108 fGenOffsetD = (fAliITSQADataMakerSim->fDigitsQAList[AliRecoParam::kDefault])->GetEntries();\r
3647765c 109 //fSDDhTask must be incremented by one unit every time a histogram is ADDED to the QA List\r
8dc34e37 110 TH1F* h0=new TH1F("SDD DIGITS Module Pattern","SDD DIGITS Module Pattern",260,239.5,499.5); //hmod\r
111 h0->GetXaxis()->SetTitle("SDD Module Number");\r
112 h0->GetYaxis()->SetTitle("# DIGITS");\r
3f905799 113 fAliITSQADataMakerSim->Add2DigitsList(h0,fGenOffsetD);\r
ad300de9 114 fSDDhDTask ++;\r
8dc34e37 115 TH1F* h1=new TH1F("SDD Anode Distribution","DIGITS Anode Distribution",512,-0.5,511.5); //hanocc\r
116 h1->GetXaxis()->SetTitle("Anode Number");\r
117 h1->GetYaxis()->SetTitle("# DIGITS");\r
3f905799 118 fAliITSQADataMakerSim->Add2DigitsList(h1,1+fGenOffsetD);\r
ad300de9 119 fSDDhDTask ++;\r
8dc34e37 120 TH1F* h2=new TH1F("SDD Tbin Distribution","DIGITS Tbin Distribution",256,-0.5,255.5); //htbocc\r
121 h2->GetXaxis()->SetTitle("Tbin Number");\r
122 h2->GetYaxis()->SetTitle("# DIGITS");\r
3f905799 123 fAliITSQADataMakerSim->Add2DigitsList(h2,2+fGenOffsetD);\r
ad300de9 124 fSDDhDTask ++;\r
8dc34e37 125 TH1F* h3=new TH1F("SDD ADC Counts Distribution","DIGITS ADC Counts Distribution",200,0.,1024.); //hsig\r
126 h3->GetXaxis()->SetTitle("ADC Value");\r
127 h3->GetYaxis()->SetTitle("# DIGITS");\r
3f905799 128 fAliITSQADataMakerSim->Add2DigitsList(h3,3+fGenOffsetD);\r
ad300de9 129 fSDDhDTask ++;\r
130 AliDebug(1,Form("%d SDD Digits histograms booked\n",fSDDhDTask));\r
8dc34e37 131}\r
132\r
133//____________________________________________________________________________\r
134void AliITSQASDDDataMakerSim::MakeDigits(TTree * digits)\r
135{ \r
ad300de9 136\r
8dc34e37 137 // Fill QA for DIGIT - SDD -\r
8dc34e37 138 AliITS *fITS = (AliITS*)gAlice->GetModule("ITS");\r
139 fITS->SetTreeAddress();\r
140 TClonesArray *iITSdigits = fITS->DigitsAddress(1);\r
141 for(Int_t i=0; i<260; i++){\r
142 Int_t nmod=i+240;\r
143 digits->GetEvent(nmod);\r
144 Int_t ndigits = iITSdigits->GetEntries();\r
3f905799 145 fAliITSQADataMakerSim->GetDigitsData(fGenOffsetD)->Fill(nmod,ndigits);\r
8dc34e37 146 for (Int_t idig=0; idig<ndigits; idig++) {\r
147 AliITSdigit *dig=(AliITSdigit*)iITSdigits->UncheckedAt(idig);\r
148 Int_t iz=dig->GetCoord1(); // cell number z\r
149 Int_t ix=dig->GetCoord2(); // cell number x\r
150 Int_t sig=dig->GetSignal();\r
3f905799 151 fAliITSQADataMakerSim->GetDigitsData(1+fGenOffsetD)->Fill(iz);\r
152 fAliITSQADataMakerSim->GetDigitsData(2+fGenOffsetD)->Fill(ix);\r
153 fAliITSQADataMakerSim->GetDigitsData(3+fGenOffsetD)->Fill(sig);\r
8dc34e37 154 }\r
155 }\r
156}\r
157\r
158//____________________________________________________________________________ \r
159void AliITSQASDDDataMakerSim::InitSDigits()\r
160{ \r
161 // Initialization for SDIGIT data - SDD -\r
57acd2d2 162 fGenOffsetS = (fAliITSQADataMakerSim->fSDigitsQAList[AliRecoParam::kDefault])->GetEntries();\r
3647765c 163 //fSDDhTask must be incremented by one unit every time a histogram is ADDED to the QA List\r
8dc34e37 164 TH1F* h0=new TH1F("SDD SDIGITS Module Pattern","SDIGITS SDD Module Pattern",260,239.5,499.5); //hmod\r
165 h0->GetXaxis()->SetTitle("SDD Module Number");\r
166 h0->GetYaxis()->SetTitle("# SDIGITS");\r
3f905799 167 fAliITSQADataMakerSim->Add2SDigitsList(h0,fGenOffsetS);\r
ad300de9 168 fSDDhSTask ++;\r
8dc34e37 169 TH1F* h1=new TH1F("SDD Anode Distribution","SDIGITS Anode Distribution",512,-0.5,511.5); //hanocc\r
170 h1->GetXaxis()->SetTitle("Anode Number");\r
171 h1->GetYaxis()->SetTitle("# SDIGITS");\r
3f905799 172 fAliITSQADataMakerSim->Add2SDigitsList(h1,1+fGenOffsetS);\r
ad300de9 173 fSDDhSTask ++;\r
8dc34e37 174 TH1F* h2=new TH1F("SDD Tbin Distribution","SDIGITS Tbin Distribution",256,-0.5,255.5); //htbocc\r
175 h2->GetXaxis()->SetTitle("Tbin Number");\r
176 h2->GetYaxis()->SetTitle("# SDIGITS");\r
3f905799 177 fAliITSQADataMakerSim->Add2SDigitsList(h2,2+fGenOffsetS);\r
ad300de9 178 fSDDhSTask ++;\r
8dc34e37 179 TH1F* h3=new TH1F("SDD ADC Counts Distribution","SDIGITS ADC Counts Distribution",200,0.,1024.); //hsig\r
180 h3->GetXaxis()->SetTitle("ADC Value");\r
181 h3->GetYaxis()->SetTitle("# SDIGITS");\r
3f905799 182 fAliITSQADataMakerSim->Add2SDigitsList(h3,3+fGenOffsetS);\r
ad300de9 183 fSDDhSTask ++;\r
8dc34e37 184\r
ad300de9 185 AliDebug(1,Form("%d SDD SDigits histograms booked\n",fSDDhSTask));\r
8dc34e37 186}\r
187\r
188//____________________________________________________________________________\r
189void AliITSQASDDDataMakerSim::MakeSDigits(TTree * sdigits)\r
190{ \r
191 // Fill QA for SDIGIT - SDD -\r
ad300de9 192\r
8dc34e37 193 AliITSsegmentationSDD* seg = new AliITSsegmentationSDD();\r
194 Int_t nan=seg->Npz();\r
195 Int_t ntb=seg->Npx();\r
196 Int_t scaleSize=4;\r
197 AliITSpList* list=new AliITSpList(nan,ntb*scaleSize);\r
198\r
199 //AliITS *fITS = (AliITS*)gAlice->GetModule("ITS");\r
200 //fITS->SetTreeAddress();\r
201 //TClonesArray *ITSdigits = fITS->DigitsAddress(1);\r
202 //TFile *sper = new TFile("sper.root","CREATE"); //agginto a mano x prova\r
203 //digits->Write();\r
204 //sper->Close();\r
205\r
206\r
207 TBranch *brchSDigits = sdigits->GetBranch("ITS");\r
208 for(Int_t id=0; id<260; id++){\r
209 Int_t nmod=id+240;\r
210 TClonesArray * sdig = new TClonesArray( "AliITSpListItem",1000 );\r
211 brchSDigits->SetAddress( &sdig );\r
212 brchSDigits->GetEvent(nmod);\r
213 Int_t nsdig=sdig->GetEntries();\r
3f905799 214 fAliITSQADataMakerSim->GetSDigitsData(fGenOffsetS)->Fill(nmod,nsdig);\r
8dc34e37 215 for(Int_t i=0;i<nsdig;i++){\r
216 AliITSpListItem *cell=(AliITSpListItem*)sdig->At(i);\r
217 Float_t sig=cell->GetSignal();\r
218 Int_t idx=cell->GetIndex();\r
219 Int_t ia,it;\r
220 list->GetCell(idx,ia,it);\r
3f905799 221 fAliITSQADataMakerSim->GetSDigitsData(1+fGenOffsetS)->Fill(ia);\r
222 fAliITSQADataMakerSim->GetSDigitsData(2+fGenOffsetS)->Fill(it);\r
223 fAliITSQADataMakerSim->GetSDigitsData(3+fGenOffsetS)->Fill(sig);\r
8dc34e37 224 }\r
225 delete sdig;\r
226 }\r
227}\r
228\r
229//____________________________________________________________________________ \r
230void AliITSQASDDDataMakerSim::InitHits()\r
231{ \r
ad300de9 232\r
8dc34e37 233 // Initialization for HITS data - SDD -\r
57acd2d2 234 fGenOffsetH = (fAliITSQADataMakerSim->fHitsQAList[AliRecoParam::kDefault])->GetEntries();\r
3647765c 235 //fSDDhTask must be incremented by one unit every time a histogram is ADDED to the QA List\r
8dc34e37 236 //printf("AliITSQASDDDataMakerSim::InitHits called \n");\r
237 TH1F *h0=new TH1F("SDD HITS Module Pattern","SDD HITS Module Pattern",260,239.5,499.5); \r
238 h0->GetXaxis()->SetTitle("SDD Module Number");\r
239 h0->GetYaxis()->SetTitle("# HITS");\r
3f905799 240 fAliITSQADataMakerSim->Add2HitsList(h0,fGenOffsetH);\r
ad300de9 241 fSDDhHTask ++;\r
8dc34e37 242 TH1F *h1=new TH1F("SDD HIT lenght along local Y Coord","HIT lenght along local Y Coord",200,0.,350.);\r
243 h1->GetXaxis()->SetTitle("HIT lenght (um)");\r
244 h1->GetYaxis()->SetTitle("# HITS");\r
3f905799 245 fAliITSQADataMakerSim->Add2HitsList(h1,1+fGenOffsetH);\r
ad300de9 246 fSDDhHTask ++;\r
8dc34e37 247 TH1F *h2=new TH1F("SDD HIT lenght along local Y Coord - Zoom","SDD HIT lenght along local Y Coord - Zoom",200,250.,350.);\r
248 h2->GetXaxis()->SetTitle("HIT lenght (um)");\r
249 h2->GetYaxis()->SetTitle("# HITS");\r
3f905799 250 fAliITSQADataMakerSim->Add2HitsList(h2,2+fGenOffsetH);\r
ad300de9 251 fSDDhHTask ++;\r
8dc34e37 252 TH1F *h3=new TH1F("SDD Deposited Energy Distribution (loc Y > 200um)","SDD HITS Deposited Energy Distribution (loc Y > 200um)",200,0.,350.);\r
ad300de9 253 h3->GetXaxis()->SetTitle("ADC counts ");\r
8dc34e37 254 h3->GetYaxis()->SetTitle("# HITS");\r
3f905799 255 fAliITSQADataMakerSim->Add2HitsList(h3,3+fGenOffsetH);\r
ad300de9 256 fSDDhHTask ++;\r
257 AliDebug(1,Form("%d SDD Hits histograms booked\n",fSDDhHTask));\r
8dc34e37 258}\r
259\r
260//____________________________________________________________________________\r
261void AliITSQASDDDataMakerSim::MakeHits(TTree * hits)\r
262{ \r
263 // Fill QA for HITS - SDD -\r
ad300de9 264\r
8dc34e37 265 AliITS *fITS = (AliITS*)gAlice->GetModule("ITS");\r
266 fITS->SetTreeAddress();\r
267 Int_t nmodules;\r
6f5308d9 268 if(!(fITS->InitModules(-1,nmodules))){\r
269 AliError("ITS geometry not available - nothing done");\r
270 return;\r
271 }\r
8dc34e37 272 \r
273 fITS->FillModules(hits,0);\r
274\r
275 for(Int_t i=0; i<260; i++){\r
276 Int_t nmod=i+240;\r
277 AliITSmodule *modu = fITS->GetModule(nmod);\r
278 TObjArray *arrHits = modu->GetHits();\r
279 Int_t nhits = arrHits->GetEntriesFast();\r
ad300de9 280 ////printf("--w--AliITSQASDDDataMakerSim::MakeHits nhits = %d\n",nhits);\r
8dc34e37 281 for (Int_t iHit=0;iHit<nhits;iHit++) {\r
282 AliITShit *hit = (AliITShit*) arrHits->At(iHit);\r
3f905799 283 fAliITSQADataMakerSim->GetHitsData(fGenOffsetH)->Fill(nmod);\r
8dc34e37 284 Double_t xl,yl,zl,xl0,yl0,zl0;\r
285 Double_t tof,tof0;\r
286 hit->GetPositionL(xl,yl,zl,tof);\r
287 hit->GetPositionL0(xl0,yl0,zl0,tof0);\r
288 Float_t dyloc=TMath::Abs(yl-yl0)*10000.;\r
3f905799 289 fAliITSQADataMakerSim->GetHitsData(1+fGenOffsetH)->Fill(dyloc);\r
8dc34e37 290 Float_t edep=hit->GetIonization()*1000000;\r
291 if(dyloc>200.){ \r
3f905799 292 fAliITSQADataMakerSim->GetHitsData(2+fGenOffsetH)->Fill(edep);\r
293 fAliITSQADataMakerSim->GetHitsData(3+fGenOffsetH)->Fill(dyloc);\r
8dc34e37 294 }\r
295 }\r
296 }\r
297}\r
ad300de9 298\r
299//_______________________________________________________________\r
300\r
301Int_t AliITSQASDDDataMakerSim::GetOffset(AliQA::TASKINDEX_t task){\r
302 // Returns histogram offset according to the specified task\r
303 Int_t offset=0;\r
304 if( task == AliQA::kHITS){\r
305 offset=fGenOffsetH; \r
306 }\r
307 else if( task == AliQA::kSDIGITS) {\r
308 offset=fGenOffsetS; \r
309 }\r
310 else if( task == AliQA::kDIGITS) {\r
311 offset=fGenOffsetD; \r
312 }\r
313 else {\r
314 AliInfo("No task has been selected. TaskHisto set to zero.\n");\r
315 }\r
316\r
317 return offset;\r
318}\r
319\r
320\r
321//_______________________________________________________________\r
322\r
323Int_t AliITSQASDDDataMakerSim::GetTaskHisto(AliQA::TASKINDEX_t task) {\r
324 // Returns the number of booked histograms for the selected task\r
325 Int_t histotot=0;\r
326 if( task == AliQA::kHITS) {\r
327 histotot=fSDDhHTask ; \r
328 }\r
329 else if( task == AliQA::kSDIGITS) {\r
330 histotot=fSDDhSTask; \r
331 }\r
332 else if( task == AliQA::kDIGITS) {\r
333 histotot=fSDDhDTask ; \r
334 }\r
335 else {\r
336 AliInfo("No task has been selected. TaskHisto set to zero.\n");\r
337 }\r
338 return histotot;\r
339\r
340}\r