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