Added method SetTaskOffset in ITS checkers. Updated data members containing the numbe...
[u/mrichter/AliRoot.git] / ITS / AliITSQASPDDataMakerSim.cxx
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"
36 #include "AliQA.h"
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
46 ClassImp(AliITSQASPDDataMakerSim)
47
48 //____________________________________________________________________________ 
49 AliITSQASPDDataMakerSim::AliITSQASPDDataMakerSim(AliITSQADataMakerSim *aliITSQADataMakerSim) :
50 TObject(),
51 fAliITSQADataMakerSim(aliITSQADataMakerSim),
52 fSPDhTask(0),
53 fGenOffset(0)
54 {
55   //ctor used to discriminate OnLine-Offline analysis   
56 }
57
58 //____________________________________________________________________________ 
59 AliITSQASPDDataMakerSim::AliITSQASPDDataMakerSim(const AliITSQASPDDataMakerSim& qadm) :
60 TObject(),
61 fAliITSQADataMakerSim(qadm.fAliITSQADataMakerSim),
62 fSPDhTask(qadm.fSPDhTask),
63 fGenOffset(qadm.fGenOffset)
64 {
65   //copy ctor 
66   fAliITSQADataMakerSim->SetName((const char*)qadm.fAliITSQADataMakerSim->GetName()) ; 
67   fAliITSQADataMakerSim->SetTitle((const char*)qadm.fAliITSQADataMakerSim->GetTitle());
68   }
69
70 //__________________________________________________________________
71 AliITSQASPDDataMakerSim& AliITSQASPDDataMakerSim::operator = (const AliITSQASPDDataMakerSim& qac )
72 {
73   // Equal operator.
74   this->~AliITSQASPDDataMakerSim();
75   new(this) AliITSQASPDDataMakerSim(qac);
76   return *this;
77 }
78
79 //____________________________________________________________________________ 
80 void AliITSQASPDDataMakerSim::StartOfDetectorCycle()
81 {
82   //Detector specific actions at start of cycle
83   AliDebug(1,"AliITSQADM::Start of SPD Cycle\n");
84 }
85
86 //____________________________________________________________________________ 
87 void AliITSQASPDDataMakerSim::EndOfDetectorCycle(AliQA::TASKINDEX_t /*task*/, TObjArray* /*list*/)
88 {
89   // launch the QA checking
90   AliDebug(1,"AliITSDM instantiates checker with Run(AliQA::kITS, task, list)\n"); 
91   
92   //AliQAChecker::Instance()->Run( AliQA::kITS , task, list);
93 }
94
95 //____________________________________________________________________________ 
96 void AliITSQASPDDataMakerSim::InitDigits()
97
98   // Initialization for DIGIT data - SPD -
99   fGenOffset = (fAliITSQADataMakerSim->fDigitsQAList)->GetEntries();
100   //fSPDhTask must be incremented by one unit every time a histogram is ADDED to the QA List
101
102   Char_t name[50];
103   Char_t title[50];
104
105   TH1F *hlayer = new TH1F("LayPattern_SPD","Layer map - SPD",6,0.,6.);
106   hlayer->GetXaxis()->SetTitle("Layer number");
107   hlayer->GetYaxis()->SetTitle("Entries");
108   fAliITSQADataMakerSim->Add2DigitsList(hlayer,fGenOffset);
109   fSPDhTask++;
110   
111   TH1F **hmod = new TH1F*[2];
112   for (Int_t iLay=0; iLay<2; iLay++) {
113     sprintf(name,"ModPattern_SPD%d",iLay+1);
114     sprintf(title,"Module map - SPD Layer %d",iLay+1);
115     hmod[iLay]=new TH1F(name,title,240,0,240);
116     hmod[iLay]->GetXaxis()->SetTitle("Module number");
117     hmod[iLay]->GetYaxis()->SetTitle("Entries");
118     fAliITSQADataMakerSim->Add2DigitsList(hmod[iLay],1+iLay+fGenOffset);
119     fSPDhTask++;
120   }
121   
122   TH1F *hcolumns = new TH1F("Columns_SPD","Columns - SPD",160,0.,160.);
123   hcolumns->GetXaxis()->SetTitle("Column number");
124   hcolumns->GetYaxis()->SetTitle("Entries");
125   fAliITSQADataMakerSim->Add2DigitsList(hcolumns,3+fGenOffset);
126   fSPDhTask++;
127
128   TH1F *hrows = new TH1F("Rows_SPD","Rows - SPD",256,0.,256.);
129   hrows->GetXaxis()->SetTitle("Row number");
130   hrows->GetYaxis()->SetTitle("Entries");
131   fAliITSQADataMakerSim->Add2DigitsList(hrows,4+fGenOffset);
132   fSPDhTask++;
133
134   TH1F** hMultSPDdigits = new TH1F*[2];
135   for (Int_t iLay=0; iLay<2; ++iLay) {
136     sprintf(name,"DigitMultiplicity_SPD%d",iLay+1);
137     sprintf(title,"Digit multiplicity - SPD Layer %d",iLay+1);
138     hMultSPDdigits[iLay]=new TH1F(name,title,200,0.,200.);
139     hMultSPDdigits[iLay]->GetXaxis()->SetTitle("Digit multiplicity");
140     hMultSPDdigits[iLay]->GetYaxis()->SetTitle("Entries");
141     fAliITSQADataMakerSim->Add2DigitsList(hMultSPDdigits[iLay], 5+iLay+fGenOffset);
142     fSPDhTask++;
143   }
144
145   TH2F *hMultSPDdig2MultSPDdig1 = new TH2F("DigitMultCorrelation_SPD","Digit multiplicity correlation - SPD",200,0.,200.,200,0.,200.);
146   hMultSPDdig2MultSPDdig1->GetXaxis()->SetTitle("Digit multiplicity (Layer 1)");
147   hMultSPDdig2MultSPDdig1->GetYaxis()->SetTitle("Digit multiplicity (Layer 2)");
148   fAliITSQADataMakerSim->Add2DigitsList(hMultSPDdig2MultSPDdig1,7+fGenOffset);
149   fSPDhTask++;
150
151   AliDebug(1,Form("%d SPD Digits histograms booked\n",fSPDhTask));
152
153 }
154
155 //____________________________________________________________________________
156 void AliITSQASPDDataMakerSim::MakeDigits(TTree *digits)
157
158   // Fill QA for DIGIT - SPD -
159   AliITS *fITS  = (AliITS*)gAlice->GetModule("ITS");
160   fITS->SetTreeAddress();
161   TClonesArray *iITSdigits  = fITS->DigitsAddress(0);  // 0->SPD
162
163   Int_t nDigitsL1=0;
164   Int_t nDigitsL2=0;
165
166   for (Int_t imod=0; imod<240; ++imod){
167     digits->GetEvent(imod);
168     Int_t ndigits = iITSdigits->GetEntries();
169     if (imod<80) {
170       fAliITSQADataMakerSim->GetDigitsData(0+fGenOffset)->Fill(0.5,ndigits);
171       fAliITSQADataMakerSim->GetDigitsData(1+fGenOffset)->Fill(imod,ndigits);
172       nDigitsL1+=ndigits;
173     }
174     else {
175       fAliITSQADataMakerSim->GetDigitsData(0+fGenOffset)->Fill(1,ndigits);
176       fAliITSQADataMakerSim->GetDigitsData(2+fGenOffset)->Fill(imod,ndigits);
177       nDigitsL2+=ndigits;
178     }
179     for (Int_t idig=0; idig<ndigits; ++idig) {
180       AliITSdigit *dig=(AliITSdigit*)iITSdigits->UncheckedAt(idig);
181       Int_t col=dig->GetCoord1();  // cell number z
182       Int_t row=dig->GetCoord2();  // cell number x
183       fAliITSQADataMakerSim->GetDigitsData(3+fGenOffset)->Fill(col);
184       fAliITSQADataMakerSim->GetDigitsData(4+fGenOffset)->Fill(row);
185     }
186   }
187   fAliITSQADataMakerSim->GetDigitsData(5+fGenOffset)->Fill(nDigitsL1);
188   fAliITSQADataMakerSim->GetDigitsData(6+fGenOffset)->Fill(nDigitsL2);
189   fAliITSQADataMakerSim->GetDigitsData(7+fGenOffset)->Fill(nDigitsL1,nDigitsL2);
190 }
191
192 //____________________________________________________________________________ 
193 void AliITSQASPDDataMakerSim::InitSDigits()
194
195   // Initialization for SDIGIT data - SPD -
196   fGenOffset = (fAliITSQADataMakerSim->fSDigitsQAList)->GetEntries();
197   //printf("--W-- AliITSQASPDDataMakerSim::InitSDigits()  fGenOffset= %d \n",fGenOffset);
198   //fSPDhTask must be incremented by one unit every time a histogram is ADDED to the QA List
199   
200   Char_t name[50];
201   Char_t title[50];
202
203   TH1F *hlayer = new TH1F("LayPattern_SPD","Layer map - SPD",6,0.,6.);
204   hlayer->GetXaxis()->SetTitle("Layer number");
205   hlayer->GetYaxis()->SetTitle("Entries");
206   fAliITSQADataMakerSim->Add2SDigitsList(hlayer,fGenOffset);
207   fSPDhTask++;
208
209   TH1F **hmod = new TH1F*[2];
210   for (Int_t iLay=0; iLay<2; ++iLay) {
211     sprintf(name,"ModPattern_SPD%d",iLay+1);
212     sprintf(title,"Module map - SPD Layer %d",iLay+1);
213     hmod[iLay]=new TH1F(name,title,240,0,240);
214     hmod[iLay]->GetXaxis()->SetTitle("Module number");
215     hmod[iLay]->GetYaxis()->SetTitle("Entries");
216     fAliITSQADataMakerSim->Add2SDigitsList(hmod[iLay],1+iLay+fGenOffset);
217     fSPDhTask++;
218   }
219   
220
221   AliDebug(1,Form("%d SPD SDigits histograms booked\n",fSPDhTask));
222
223 }
224
225 //____________________________________________________________________________
226 void AliITSQASPDDataMakerSim::MakeSDigits(TTree *sdigits)
227
228   // Fill QA for SDIGIT - SPD -
229   TBranch *brchSDigits = sdigits->GetBranch("ITS");
230   for (Int_t imod=0; imod<240; ++imod){
231     TClonesArray * sdig = new TClonesArray( "AliITSpListItem",1000 );
232     brchSDigits->SetAddress( &sdig );
233     brchSDigits->GetEvent(imod);
234     Int_t nsdig=sdig->GetEntries();
235     if (imod<80) {
236       fAliITSQADataMakerSim->GetSDigitsData(0+fGenOffset)->Fill(0.5,nsdig);
237       fAliITSQADataMakerSim->GetSDigitsData(1+fGenOffset)->Fill(imod,nsdig);
238     }
239     else {
240       fAliITSQADataMakerSim->GetSDigitsData(0+fGenOffset)->Fill(1,nsdig);
241       fAliITSQADataMakerSim->GetSDigitsData(2+fGenOffset)->Fill(imod,nsdig);
242     }
243     delete sdig;
244   }
245
246 }
247
248 //____________________________________________________________________________ 
249 void AliITSQASPDDataMakerSim::InitHits()
250
251   // Initialization for HITS data - SPD -
252   fGenOffset = (fAliITSQADataMakerSim->fHitsQAList)->GetEntries();
253   //printf("--W-- AliITSQASPDDataMakerSim::InitHits()  fGenOffset= %d \n",fGenOffset);
254   //fSPDhTask must be incremented by one unit every time a histogram is ADDED to the QA List
255   Char_t name[50];
256   Char_t title[50];
257
258   TH1F *hlayer = new TH1F("LayPattern_SPD","Layer map - SPD",6,0.,6.);
259   hlayer->GetXaxis()->SetTitle("Layer number");
260   hlayer->GetYaxis()->SetTitle("Entries");
261   fAliITSQADataMakerSim->Add2HitsList(hlayer,fGenOffset);
262   fSPDhTask++;
263
264   TH1F **hmod = new TH1F*[2];
265   for (Int_t iLay=0; iLay<2; ++iLay) {
266     sprintf(name,"ModPattern_SPD%d",iLay+1);
267     sprintf(title,"Module map - SPD Layer %d",iLay+1);
268     hmod[iLay]=new TH1F(name,title,240,0,240);
269     hmod[iLay]->GetXaxis()->SetTitle("Module number");
270     hmod[iLay]->GetYaxis()->SetTitle("Entries");
271     fAliITSQADataMakerSim->Add2HitsList(hmod[iLay],1+iLay+fGenOffset);
272     fSPDhTask++;
273   }
274
275   TH1F *hhitlenght = new TH1F("Lenght_SPD","Hit lenght along y_{loc} coord",210,0.,210.);
276   hhitlenght->GetXaxis()->SetTitle("Hit lenght [#mum]");
277   hhitlenght->GetYaxis()->SetTitle("# hits");
278   fAliITSQADataMakerSim->Add2HitsList(hhitlenght,3+fGenOffset);
279   fSPDhTask++;
280
281   TH1F *hEdepos = new TH1F("EnergyDeposit_SPD","Deposited energy distribution (y_{loc}>180 #mum)",150,0.,300.); 
282   hEdepos->GetXaxis()->SetTitle("Deposited energy [keV]"); 
283   hEdepos->GetYaxis()->SetTitle("# hits");
284   fAliITSQADataMakerSim->Add2HitsList(hEdepos,4+fGenOffset);
285   fSPDhTask++;
286
287   AliDebug(1,Form("%d SPD Hits histograms booked\n",fSPDhTask));
288
289 }
290
291 //____________________________________________________________________________
292 void AliITSQASPDDataMakerSim::MakeHits(TTree *hits)
293
294   // Fill QA for HITS - SPD -
295   AliITS *fITS  = (AliITS*)gAlice->GetModule("ITS");
296   fITS->SetTreeAddress();
297   Int_t nmodules;
298   fITS->InitModules(-1,nmodules); //-1->number of modules taken from AliITSgeom class kept in fITSgeom
299                                   //nmodules is set
300
301   fITS->FillModules(hits,0);
302
303   for (Int_t imod=0; imod<240; ++imod){
304     AliITSmodule *module = fITS->GetModule(imod);
305     TObjArray *arrHits = module->GetHits();
306     Int_t nhits = arrHits->GetEntriesFast();
307     if (imod<80) {
308       fAliITSQADataMakerSim->GetHitsData(fGenOffset)->Fill(0.5,nhits);
309       fAliITSQADataMakerSim->GetHitsData(1+fGenOffset)->Fill(imod,nhits);
310     } else {
311       fAliITSQADataMakerSim->GetHitsData(fGenOffset)->Fill(1,nhits);
312       fAliITSQADataMakerSim->GetHitsData(2+fGenOffset)->Fill(imod,nhits);
313     }
314     for (Int_t iHit=0; iHit<nhits; ++iHit) {
315       AliITShit *hit = (AliITShit*) arrHits->At(iHit);
316       Double_t xl,yl,zl,xl0,yl0,zl0;
317       Double_t tof,tof0;
318       hit->GetPositionL(xl,yl,zl,tof);
319       hit->GetPositionL0(xl0,yl0,zl0,tof0);
320       Float_t dyloc=TMath::Abs(yl-yl0)*10000.;
321       fAliITSQADataMakerSim->GetHitsData(3+fGenOffset)->Fill(dyloc);
322       Float_t edep=hit->GetIonization()*1000000;
323       if(dyloc>180.){
324         fAliITSQADataMakerSim->GetHitsData(4+fGenOffset)->Fill(edep);
325       }
326     }
327   }
328 }