Updated SSD raw data QA code and first implementation of the SSD rec points QA code...
[u/mrichter/AliRoot.git] / ITS / AliITSQASSDDataMakerRec.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 /* $Id:$    */
16 //  *************************************************************
17 //  Checks the quality assurance 
18 //  by comparing with reference data
19 //  contained in a DB
20 //  -------------------------------------------------------------
21 //  W. Ferrarese + P. Cerello Feb 2008
22 //  INFN Torino
23
24 // --- ROOT system ---
25 #include <TH2D.h>
26 #include <TTree.h>
27 #include <TMath.h>
28 #include <TString.h>
29
30 // --- Standard library ---
31
32 // --- AliRoot header files ---
33 #include "AliITSQASSDDataMakerRec.h"
34 #include "AliQADataMakerRec.h"
35 #include "AliLog.h"
36 #include "AliQA.h"
37 #include "AliQAChecker.h"
38 #include "AliRawReader.h"
39 #include "AliRawReaderRoot.h"
40 #include "AliITSRawStreamSSD.h"
41 #include "AliITSgeomTGeo.h"
42 #include "AliRawEventHeaderBase.h"
43 #include "AliITSRecPoint.h"
44
45 ClassImp(AliITSQASSDDataMakerRec)
46
47 AliITSQASSDDataMakerRec::AliITSQASSDDataMakerRec(AliITSQADataMakerRec *aliITSQADataMakerRec, Bool_t kMode, Int_t ldc) :
48 TObject(),
49 fAliITSQADataMakerRec(aliITSQADataMakerRec),
50 fSSDEvent(0),
51 fkOnline(kMode),
52 fLDC(ldc),
53 fSSDRawsOffset(0),
54 fSSDhRaws(0),
55 fSSDhRecs(0),
56 fRawsOffset(0),
57 fRecsOffset(0) {
58   // Default constructor   
59   //initilize the raw signal vs strip number histograms
60   Int_t fLayer = 0,fLadder = 0, fModule = 0;
61   TString fTitle; Int_t fHistCounter = 0;
62   if(fkOnline) {
63     for(Int_t i = 500; i < fgkSSDMODULES + 500; i++) {
64       AliITSgeomTGeo::GetModuleId(i,fLayer,fLadder,fModule);
65       fTitle = "SSD_RawSignal_Layer"; fTitle += fLayer;
66       fTitle += "_Ladder"; fTitle += fLadder;
67       fTitle += "_Module"; fTitle += fModule; 
68       fHistSSDRawSignalModule[fHistCounter] = new TH1D(fTitle.Data(),fTitle.Data(),1540,0,1540);
69       fHistCounter += 1;
70     }
71   }//online flag
72   else {
73     for(Int_t i = 0; i < fgkSSDMODULES; i++) {
74       fHistSSDRawSignalModule[i]=NULL;
75     }
76   }
77 }
78
79 //____________________________________________________________________________ 
80 AliITSQASSDDataMakerRec::AliITSQASSDDataMakerRec(const AliITSQASSDDataMakerRec& qadm) :
81 TObject(),
82 fAliITSQADataMakerRec(qadm.fAliITSQADataMakerRec),
83 fSSDEvent(qadm.fSSDEvent),
84 fkOnline(qadm.fkOnline),
85 fLDC(qadm.fLDC),
86 fSSDRawsOffset(qadm.fSSDRawsOffset),
87 fSSDhRaws(qadm.fSSDhRaws),
88 fSSDhRecs(qadm.fSSDhRecs),
89 fRawsOffset(qadm.fRawsOffset),
90 fRecsOffset(qadm.fRecsOffset) {
91   //copy ctor 
92   fAliITSQADataMakerRec->SetName((const char*)qadm.fAliITSQADataMakerRec->GetName()) ; 
93   fAliITSQADataMakerRec->SetTitle((const char*)qadm.fAliITSQADataMakerRec->GetTitle());
94 }
95
96 //__________________________________________________________________
97 AliITSQASSDDataMakerRec& AliITSQASSDDataMakerRec::operator = (const AliITSQASSDDataMakerRec& qac )
98 {
99   // Equal operator.
100   this->~AliITSQASSDDataMakerRec();
101   new(this) AliITSQASSDDataMakerRec(qac);
102   return *this;
103 }
104
105 //__________________________________________________________________
106 AliITSQASSDDataMakerRec::~AliITSQASSDDataMakerRec() {
107   // destructor
108   for(Int_t i = 0; i < fgkSSDMODULES; i++) 
109     if(fHistSSDRawSignalModule[i]) delete fHistSSDRawSignalModule[i];
110 }
111
112 //____________________________________________________________________________ 
113 void AliITSQASSDDataMakerRec::StartOfDetectorCycle()
114 {
115   //Detector specific actions at start of cycle
116   AliDebug(1,"AliITSQADM::Start of SSD Cycle\n");
117 }
118
119 //____________________________________________________________________________ 
120 void AliITSQASSDDataMakerRec::EndOfDetectorCycle(AliQA::TASKINDEX_t /*task*/, TObjArray* /*list*/)
121 {
122   // launch the QA checking
123   AliDebug(1,"AliITSDM instantiates checker with Run(AliQA::kITS, task, list)\n"); 
124   
125   //scaling SSD occupancy plots
126   if(fkOnline) {
127     if(fSSDEvent != 0) {
128       ((TH2F *)fAliITSQADataMakerRec->GetRawsData(fRawsOffset+28))->Scale(1./fSSDEvent);
129       ((TH2F *)fAliITSQADataMakerRec->GetRawsData(fRawsOffset+29))->Scale(1./fSSDEvent);
130     }
131     Int_t fLayer = 0, fLadder = 0;
132     Int_t fOccPosition = 0; 
133     for(Int_t iLayer = 5; iLayer < 7; iLayer++) {
134       for(Int_t iLadder = 1; iLadder < AliITSgeomTGeo::GetNLadders(iLayer) + 1; iLadder++) {
135         fOccPosition  = (fLayer == 5) ? fLadder : fLadder + fgkSSDLADDERSLAYER5;
136         if(fSSDEvent != 0) {
137           //P-SIDE OCCUPANCY - scaling
138           fAliITSQADataMakerRec->GetRawsData(fRawsOffset + fSSDRawsOffset - 1 + 2*fOccPosition - 1)->Scale(1./fSSDEvent);
139           //N-SIDE OCCUPANCY - scaling
140           fAliITSQADataMakerRec->GetRawsData(fRawsOffset + fSSDRawsOffset - 1 + 2*fOccPosition)->Scale(1./fSSDEvent);
141         }//ssd events != 0
142       }//ladder loop
143     }//layer loop
144   }//online flag for SSD
145   //AliQAChecker::Instance()->Run( AliQA::kITS , task, list);
146 }
147
148 //____________________________________________________________________________ 
149 void AliITSQASSDDataMakerRec::InitRaws() {  
150
151   // Initialization for RAW data - SSD -
152   fRawsOffset = (fAliITSQADataMakerRec->fRawsQAList)->GetEntries();
153
154   if(fkOnline) {
155     AliInfo("Book Online Histograms for SSD\n");
156   }
157   else {
158     AliInfo("Book Offline Histograms for SSD\n ");
159   }
160   AliInfo(Form("Number of histograms (SPD+SDD): %d\n",fRawsOffset));
161   TString fTitle = 0;
162   //book online QA histos
163   if(fkOnline) {
164     TH1F *fHistSSDEventType = new TH1F("fHistSSDEventType",
165                                        ";Event type;Events",
166                                        31,-1,30);
167     fAliITSQADataMakerRec->Add2RawsList(fHistSSDEventType, 
168                                         fRawsOffset+fSSDRawsOffset);
169     fSSDRawsOffset += 1;
170     TH1F *fHistSSDDataSize = new TH1F("fHistSSDDataSize",
171                                       ";log(SSD data size) [Bytes];Events",
172                                       100,3,8);
173     fAliITSQADataMakerRec->Add2RawsList(fHistSSDDataSize, 
174                                         fRawsOffset+fSSDRawsOffset);
175     fSSDRawsOffset += 1;
176     TH1F *fHistSSDDataSizePercentage = new TH1F("fHistSSDDataSizePercentage",
177                                                 ";SSD data size [%];Events",
178                                                 100,0,100);
179     fAliITSQADataMakerRec->Add2RawsList(fHistSSDDataSizePercentage, 
180                                         fRawsOffset+fSSDRawsOffset);
181     fSSDRawsOffset += 1;
182     TH1F *fHistSSDDDLId = new TH1F("fHistSSDDDLId",
183                                    ";DDL id;Events",20,510.5,530.5);
184     fAliITSQADataMakerRec->Add2RawsList(fHistSSDDDLId, 
185                                         fRawsOffset+fSSDRawsOffset);
186     fSSDRawsOffset += 1;
187     TH1F *fHistSSDDataSizePerDDL = new TH1F("fHistSSDDataSizePerDDL",
188                                             ";DDL id;<SSD data size> [MB]",
189                                             20,510.5,530.5);
190     fAliITSQADataMakerRec->Add2RawsList(fHistSSDDataSizePerDDL, 
191                                         fRawsOffset+fSSDRawsOffset);
192     fSSDRawsOffset += 1;
193     TH1F *fHistSSDDataSizeDDL[fgkNumOfDDLs];
194     for(Int_t i = 1; i < fgkNumOfDDLs+1; i++) {
195       fTitle = "fHistSSDDataSizeDDL"; fTitle += i+511;
196       fHistSSDDataSizeDDL[i-1] = new TH1F(fTitle.Data(),
197                                           ";log(SSD data size) [Bytes];Events",
198                                           100,1,8);
199       fAliITSQADataMakerRec->Add2RawsList(fHistSSDDataSizeDDL[i-1], 
200                                           fRawsOffset+fSSDRawsOffset);
201       fSSDRawsOffset += 1;
202     }
203     
204     TH1F *fHistSSDLDCId = new TH1F("fHistSSDLDCId",";LDC id;Events",10,0.5,10.5);
205     fAliITSQADataMakerRec->Add2RawsList(fHistSSDLDCId, 
206                                         fRawsOffset+fSSDRawsOffset);
207     fSSDRawsOffset += 1;
208     TH1F *fHistSSDDataSizePerLDC = new TH1F("fHistSSDDataSizePerLDC",
209                                             ";LDC id;<SSD data size> [MB]",
210                                             100,0,20);
211     fAliITSQADataMakerRec->Add2RawsList(fHistSSDDataSizePerLDC, 
212                                         fRawsOffset+fSSDRawsOffset);
213     fSSDRawsOffset += 1;
214     TH1F *fHistSSDDataSizeLDC[fgkNumOfLDCs];
215     for(Int_t i = 1; i < fgkNumOfLDCs+1; i++) {
216       fTitle = "fHistSSDDataSizeLDC"; fTitle += i;
217       fHistSSDDataSizeLDC[i-1] = new TH1F(fTitle.Data(),
218                                           ";log(SSD data size) [Bytes];Events",
219                                           100,1,8);
220       fAliITSQADataMakerRec->Add2RawsList(fHistSSDDataSizeLDC[i-1], 
221                                           fRawsOffset+fSSDRawsOffset);
222       fSSDRawsOffset += 1;
223     }
224
225     //top level occupancy plots
226     TH2D *fHistSSDOccupancyLayer5 = new TH2D("fHistSSDOccupancyLayer5",
227                                              ";N_{modules};N_{Ladders}",
228                                              fgkSSDMODULESPERLADDERLAYER5,
229                                              0,fgkSSDMODULESPERLADDERLAYER5,
230                                              3*fgkSSDLADDERSLAYER5,
231                                              0,fgkSSDLADDERSLAYER5);  
232     Char_t fLabel[3];
233     for(Int_t iBin = 1; iBin < fgkSSDMODULESPERLADDERLAYER5 + 1; iBin++){
234       sprintf(fLabel,"%d",iBin);
235       fHistSSDOccupancyLayer5->GetXaxis()->SetBinLabel(iBin,fLabel);
236     }
237     fAliITSQADataMakerRec->Add2RawsList(fHistSSDOccupancyLayer5, fRawsOffset+fSSDRawsOffset);
238     fSSDRawsOffset += 1;
239     TH2D *fHistSSDOccupancyLayer6 = new TH2D("fHistSSDOccupancyLayer6",
240                                              ";N_{modules};N_{Ladders}",
241                                              fgkSSDMODULESPERLADDERLAYER6,
242                                              0,fgkSSDMODULESPERLADDERLAYER6,
243                                              3*fgkSSDLADDERSLAYER6,
244                                              0,fgkSSDLADDERSLAYER6);
245     for(Int_t iBin = 1; iBin < fgkSSDMODULESPERLADDERLAYER6 + 1; iBin++){
246       sprintf(fLabel,"%d",iBin);
247       fHistSSDOccupancyLayer6->GetXaxis()->SetBinLabel(iBin,fLabel);
248     }
249     fAliITSQADataMakerRec->Add2RawsList(fHistSSDOccupancyLayer6, fRawsOffset+fSSDRawsOffset);
250     fSSDRawsOffset += 1;
251
252     //Occupancy per ladder
253     fSSDhRaws = fSSDRawsOffset;
254     TH1D *fHistOccupancyLadder[2*(fgkSSDLADDERSLAYER5 + fgkSSDLADDERSLAYER6)];
255     for(Int_t iLayer = 5; iLayer < 7; iLayer++) {
256       for(Int_t iLadder = 1; iLadder < AliITSgeomTGeo::GetNLadders(iLayer) + 1; iLadder++) {
257         //P-side occupancy plots
258         fTitle = "fHistSSD_Occupancy_Layer"; fTitle += iLayer;
259         fTitle += "_Ladder"; fTitle += iLadder; fTitle += "_PSide";
260         fHistOccupancyLadder[fSSDhRaws] = 
261           new TH1D(fTitle.Data(),
262                    fTitle.Data(),
263                    AliITSgeomTGeo::GetNDetectors(iLayer),
264                    0.5,AliITSgeomTGeo::GetNDetectors(iLayer)+0.5);
265         fHistOccupancyLadder[fSSDhRaws]->GetXaxis()->SetTitleColor(1);
266         fHistOccupancyLadder[fSSDhRaws]->GetXaxis()->SetTitle("Module number");
267         fHistOccupancyLadder[fSSDhRaws]->GetYaxis()->SetTitle("Occupancy [%]");
268         fAliITSQADataMakerRec->Add2RawsList(fHistOccupancyLadder[fSSDhRaws], 
269                                             fRawsOffset+fSSDhRaws);     
270         fSSDhRaws++;
271         //N-side occupancy plots
272         fTitle = "fHistSSD_Occupancy_Layer"; fTitle += iLayer;
273         fTitle += "_Ladder"; fTitle += iLadder; fTitle += "_NSide";
274         fHistOccupancyLadder[fSSDhRaws] = 
275           new TH1D(fTitle.Data(),
276                    fTitle.Data(),
277                    AliITSgeomTGeo::GetNDetectors(iLayer),
278                    0.5,AliITSgeomTGeo::GetNDetectors(iLayer)+0.5);
279         fHistOccupancyLadder[fSSDhRaws]->GetXaxis()->SetTitleColor(1);
280         fHistOccupancyLadder[fSSDhRaws]->GetXaxis()->SetTitle("Module number");
281         fHistOccupancyLadder[fSSDhRaws]->GetYaxis()->SetTitle("Occupancy [%]");
282         fAliITSQADataMakerRec->Add2RawsList(fHistOccupancyLadder[fSSDhRaws], 
283                                             fRawsOffset+fSSDhRaws);     
284         fSSDhRaws++;
285       }//ladder loop
286     }//layer loop
287   }//online flag
288   AliDebug(1,Form("%d SSD Raws histograms booked\n",fSSDhRaws));
289   AliInfo(Form("Number of histograms (SPD+SDD+SSD): %d\n",fRawsOffset+fSSDhRaws));  
290 }
291
292 //____________________________________________________________________________
293 void AliITSQASSDDataMakerRec::MakeRaws(AliRawReader* rawReader) { 
294   // Fill QA for RAW - SSD -
295   Int_t fStripNumber;
296   Int_t fHistPosition;
297   Int_t fLayer = 0,fLadder = 0, fModule = 0;
298   
299   Double_t fSizePerDDL[fgkNumOfDDLs] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
300   Double_t fSizePerLDC[fgkNumOfLDCs] = {0.,0.,0.};
301   Double_t sumSSDDataSize = 0.0;
302   Double_t eventSize = -1.0;
303
304   if(fkOnline) {
305     //reset the signal vs strip number histograms
306     for(Int_t i = 0; i < fgkSSDMODULES; i++) 
307       fHistSSDRawSignalModule[i]->Reset();
308   
309     rawReader->Select("ITSSSD",-1,-1);  
310     rawReader->Reset(); //rawReader->NextEvent();   
311     (fAliITSQADataMakerRec->GetRawsData(fRawsOffset))->Fill(rawReader->GetType());
312     if(rawReader->GetType() == 7)
313       fSSDEvent += 1;
314
315     AliITSRawStreamSSD fSSDStream(rawReader);    
316     AliRawReaderRoot *rootReader = (AliRawReaderRoot *)rawReader;
317     if(rootReader) {
318       const AliRawEventHeaderBase *header = rootReader->GetEventHeader();
319       if(header)
320         eventSize = header->GetEventSize();
321     }
322     while (fSSDStream.Next()) {
323       if(fSSDStream.GetModuleID() < 0) continue;
324       fSizePerDDL[rawReader->GetDDLID()] = rawReader->GetDataSize();
325       fSizePerLDC[rawReader->GetLDCId()-6] = rawReader->GetDataSize();
326       AliITSgeomTGeo::GetModuleId(fSSDStream.GetModuleID(),fLayer,fLadder,fModule);
327       fStripNumber = (fSSDStream.GetSideFlag() == 0) ? fSSDStream.GetStrip() : fSSDStream.GetStrip() + fgkNumberOfPSideStrips;
328       fHistPosition = (fLayer == 5) ? ((fLadder - 1)*fgkSSDMODULESPERLADDERLAYER5 + fModule - 1) : ((fLadder - 1)*fgkSSDMODULESPERLADDERLAYER6 + fModule + fgkSSDMODULESLAYER5 - 1);
329       //AliInfo(Form("ModulePosition: %d - Layer: %d - Ladder: %d - Module: %d\n",fHistPosition,fLayer,fLadder,fModule));
330       fHistSSDRawSignalModule[fHistPosition]->Fill(fStripNumber,fSSDStream.GetSignal());
331     }//streamer loop   
332
333     
334     for(Int_t i = 0; i < fgkNumOfDDLs; i++) {
335       sumSSDDataSize += fSizePerDDL[i];
336       if(fSizePerDDL[i] > 0) {
337         (fAliITSQADataMakerRec->GetRawsData(fRawsOffset+3))->Fill(i+512);
338         (fAliITSQADataMakerRec->GetRawsData(fRawsOffset+5+i))->Fill(TMath::Log10(fSizePerDDL[i]));
339       }
340       (fAliITSQADataMakerRec->GetRawsData(fRawsOffset+4))->Fill(i+512,fSizePerDDL[i]/1e+06);
341     }
342     for(Int_t i = 0; i < fgkNumOfLDCs; i++) {
343       if(fSizePerLDC[i] > 0) {
344         (fAliITSQADataMakerRec->GetRawsData(fRawsOffset+21))->Fill(i+6);
345         (fAliITSQADataMakerRec->GetRawsData(fRawsOffset+23+i))->Fill(TMath::Log10(fSizePerLDC[0]));
346       }
347       (fAliITSQADataMakerRec->GetRawsData(fRawsOffset+22))->Fill(i+6,fSizePerLDC[i]/1e+06);
348     }
349     if(sumSSDDataSize) 
350       (fAliITSQADataMakerRec->GetRawsData(fRawsOffset+1))->Fill(TMath::Log10(sumSSDDataSize));
351     if(eventSize)
352       (fAliITSQADataMakerRec->GetRawsData(fRawsOffset+2))->Fill(100.*sumSSDDataSize/eventSize);
353  
354     //AliInfo(Form("EVENT: %d\n",fSSDEvent));
355     Double_t occupancy = 0.0;
356     Int_t lLadderLocationY = 0;    
357     Int_t fOccPosition = 0;
358     for(Int_t i = 0; i < fgkSSDMODULES; i++) {
359       AliITSgeomTGeo::GetModuleId(i+500,fLayer,fLadder,fModule); 
360       fOccPosition  = (fLayer == 5) ? fLadder : fLadder + fgkSSDLADDERSLAYER5;
361       //P-SIDE OCCUPANCY
362       occupancy = GetSSDOccupancyRaws(fHistSSDRawSignalModule[i],0);
363       fAliITSQADataMakerRec->GetRawsData(fRawsOffset + fSSDRawsOffset - 1 + 2*fOccPosition - 1)->Fill(fModule,occupancy);
364       lLadderLocationY = 3*fLadder; // sideP=1 sideN=0
365       if(fLayer == 5)
366         ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fRawsOffset+28))->SetBinContent(fModule,lLadderLocationY,occupancy);
367       else if(fLayer == 6)
368         ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fRawsOffset+29))->SetBinContent(fModule,lLadderLocationY,occupancy);
369       //N-SIDE OCCUPANCY
370       occupancy = GetSSDOccupancyRaws(fHistSSDRawSignalModule[i],1);
371       fAliITSQADataMakerRec->GetRawsData(fRawsOffset + fSSDRawsOffset - 1 + 2*fOccPosition)->Fill(fModule,occupancy);
372       if(fLayer == 5)
373         ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fRawsOffset+28))->SetBinContent(fModule,lLadderLocationY-1,occupancy);
374       else if(fLayer == 6)
375         ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fRawsOffset+29))->SetBinContent(fModule,lLadderLocationY-1,occupancy);
376     }
377   }//online flag for SSD
378 }
379
380 //____________________________________________________________________________ 
381 Double_t AliITSQASSDDataMakerRec::GetSSDOccupancyRaws(TH1 *lHisto, Int_t stripside) { 
382   // bo: TDC >0 or # of sigmas wrt noise ?
383   //stripside == 0 --> P-side
384   //stripside == 1 --> N-side
385   Int_t lNumFiredBins = 0;
386   for(Int_t iBin = 1 + stripside*fgkNumberOfPSideStrips; iBin < fgkNumberOfPSideStrips*(1 + stripside); iBin++){
387     if (lHisto->GetBinContent(iBin) > 0)
388       lNumFiredBins++; 
389   }
390   
391   Double_t lOccupancy = (100.*lNumFiredBins)/fgkNumberOfPSideStrips; // percentage
392   //AliInfo(Form("Fired strips: %d - Total strips: %d - Occupancy :%lf\n",lNumFiredBins,lHisto->GetNbinsX(),lOccupancy));
393   
394   return lOccupancy;
395 }
396
397
398 //____________________________________________________________________________ 
399 void AliITSQASSDDataMakerRec::InitRecPoints()
400 {
401   // Initialization for RECPOINTS - SSD -
402   fRecsOffset = (fAliITSQADataMakerRec->fRecPointsQAList)->GetEntries();
403   Int_t nModuleOffset = 500;
404   Int_t nITSTotalModules = AliITSgeomTGeo::GetNModules();
405
406   TH1F *fHistModuleIdLayer5 = new TH1F("fHistModuleIdLayer5",
407                                        "Module Id - Layer 5;Module Id;Entries",
408                                        fgkSSDMODULESLAYER5,
409                                        nModuleOffset - 0.5,
410                                        nITSTotalModules-fgkSSDMODULESLAYER6+0.5);
411   fAliITSQADataMakerRec->Add2RecPointsList(fHistModuleIdLayer5, 
412                                            fRecsOffset + fSSDhRecs);
413   fSSDhRecs += 1;
414   TH1F *fHistModuleIdLayer6 = new TH1F("fHistModuleIdLayer6",
415                                        "Module Id - Layer 6;Module Id;Entries",
416                                        fgkSSDMODULESLAYER6,
417                                        nModuleOffset+fgkSSDMODULESLAYER5 - 0.5,
418                                        nITSTotalModules + 0.5);
419   fAliITSQADataMakerRec->Add2RecPointsList(fHistModuleIdLayer6, 
420                                            fRecsOffset + fSSDhRecs);
421   fSSDhRecs += 1;
422   TH1F *fHistLocalXLayer5 = new TH1F("fHistLocalXLayer5",
423                                      "Local x coord.- Layer 5;x [cm];Entries;",
424                                      100,-4.,4.);
425   fAliITSQADataMakerRec->Add2RecPointsList(fHistLocalXLayer5,
426                                            fRecsOffset + fSSDhRecs);
427   fSSDhRecs += 1;
428   TH1F *fHistLocalXLayer6 = new TH1F("fHistLocalXLayer6",
429                                      "Local x coord.- Layer 6;x [cm];Entries;",
430                                      100,-4.,4.);
431   fAliITSQADataMakerRec->Add2RecPointsList(fHistLocalXLayer6, 
432                                            fRecsOffset + fSSDhRecs);
433   fSSDhRecs += 1;
434   TH1F *fHistLocalZLayer5 = new TH1F("fHistLocalZLayer5",
435                                      "Local z coord.- Layer 5;z [cm];Entries;",
436                                      100,-4.,4.);
437   fAliITSQADataMakerRec->Add2RecPointsList(fHistLocalZLayer5, 
438                                            fRecsOffset + fSSDhRecs);
439   fSSDhRecs += 1;
440   TH1F *fHistLocalZLayer6 = new TH1F("fHistLocalZLayer6",
441                                      "Local z coord.- Layer 6;z [cm];Entries;",
442                                      100,-4.,4.);
443   fAliITSQADataMakerRec->Add2RecPointsList(fHistLocalZLayer6, 
444                                            fRecsOffset + fSSDhRecs);
445   fSSDhRecs += 1;
446   TH1F *fHistGlobalXLayer5 = new TH1F("fHistGlobalXLayer5",
447                                       "Global x - Layer 5;x [cm];Entries;",
448                                       100,-40.,40.);
449   fAliITSQADataMakerRec->Add2RecPointsList(fHistGlobalXLayer5, 
450                                            fRecsOffset + fSSDhRecs);
451   fSSDhRecs += 1;
452   TH1F *fHistGlobalXLayer6 = new TH1F("fHistGlobalXLayer6",
453                                       "Global x - Layer 6;x [cm];Entries;",
454                                       100,-45.,45.);
455   fAliITSQADataMakerRec->Add2RecPointsList(fHistGlobalXLayer6, 
456                                            fRecsOffset + fSSDhRecs);
457   fSSDhRecs += 1;
458   TH1F *fHistGlobalYLayer5 = new TH1F("fHistGlobalYLayer5",
459                                       "Global y - Layer 5;y [cm];Entries;",
460                                       100,-40.,40);
461   fAliITSQADataMakerRec->Add2RecPointsList(fHistGlobalYLayer5, 
462                                            fRecsOffset + fSSDhRecs);
463   fSSDhRecs += 1;
464   TH1F *fHistGlobalYLayer6 = new TH1F("fHistGlobalYLayer6",
465                                       "Global y - Layer 6;y [cm];Entries;",
466                                       100,-45.,45.);
467   fAliITSQADataMakerRec->Add2RecPointsList(fHistGlobalYLayer6, 
468                                            fRecsOffset + fSSDhRecs);
469   fSSDhRecs += 1;
470   TH1F *fHistGlobalZLayer5 = new TH1F("fHistGlobalZLayer5",
471                                       "Global z - Layer 5;z [cm];Entries;",
472                                       100,-45.,45);
473   fAliITSQADataMakerRec->Add2RecPointsList(fHistGlobalZLayer5, 
474                                            fRecsOffset + fSSDhRecs);
475   fSSDhRecs += 1;
476   TH1F *fHistGlobalZLayer6 = new TH1F("fHistGlobalZLayer6",
477                                       "Global z - Layer 6;z [cm];Entries;",
478                                       100,-55.,55.);
479   fAliITSQADataMakerRec->Add2RecPointsList(fHistGlobalZLayer6, 
480                                            fRecsOffset + fSSDhRecs);
481   fSSDhRecs += 1;
482   TH1F *fHistPhiLayer5 = new TH1F("fHistPhiLayer5",
483                                   "#phi - Layer 5;#phi [rad];Entries;",
484                                   100,-TMath::Pi(),TMath::Pi());
485   fAliITSQADataMakerRec->Add2RecPointsList(fHistPhiLayer5, 
486                                            fRecsOffset + fSSDhRecs);
487   fSSDhRecs += 1;
488   TH1F *fHistPhiLayer6 = new TH1F("fHistPhiLayer6",
489                                   "#phi - Layer 6;#phi [rad];Entries;",
490                                   100,-TMath::Pi(),TMath::Pi());
491   fAliITSQADataMakerRec->Add2RecPointsList(fHistPhiLayer6, 
492                                            fRecsOffset + fSSDhRecs);
493   fSSDhRecs += 1;
494   TH1F *fHistThetaLayer5 = new TH1F("fHistThetaLayer5",
495                                     "#theta - Layer 5;#theta [rad];Entries;",
496                                     100,-TMath::Pi(),TMath::Pi());
497   fAliITSQADataMakerRec->Add2RecPointsList(fHistThetaLayer5, 
498                                            fRecsOffset + fSSDhRecs);
499   fSSDhRecs += 1;
500   TH1F *fHistThetaLayer6 = new TH1F("fHistThetaLayer6",
501                                     "#theta - Layer 6;#theta [rad];Entries;",
502                                     100,-TMath::Pi(),TMath::Pi());
503   fAliITSQADataMakerRec->Add2RecPointsList(fHistThetaLayer6, 
504                                            fRecsOffset + fSSDhRecs);
505   fSSDhRecs += 1;
506   TH1F *fHistRadiusLayer5 = new TH1F("fHistRadiusLayer5",
507                                      "r - Layer 5;r [cm];Entries;",
508                                      100,35.,50.);
509   fAliITSQADataMakerRec->Add2RecPointsList(fHistRadiusLayer5, 
510                                            fRecsOffset + fSSDhRecs);
511   fSSDhRecs += 1;
512   TH1F *fHistRadiusLayer6 = new TH1F("fHistRadiusLayer6",
513                                      "r - Layer 6;r [cm];Entries;",
514                                      100,35.,50.);
515   fAliITSQADataMakerRec->Add2RecPointsList(fHistRadiusLayer6, 
516                                            fRecsOffset + fSSDhRecs);
517   fSSDhRecs += 1;
518   TH1F *fHistClusterTypeLayer5 = new TH1F("fHistClusterTypeLayer5",
519                                           "CL type - Layer 5;Cluster type;Entries;",
520                                           150,0,150);
521   fAliITSQADataMakerRec->Add2RecPointsList(fHistClusterTypeLayer5, 
522                                            fRecsOffset + fSSDhRecs);
523   fSSDhRecs += 1;
524   TH1F *fHistClusterTypeLayer6 = new TH1F("fHistClusterTypeLayer6",
525                                           "CL type - Layer 6;Cluster type;Entries;",
526                                           150,0,150);
527   fAliITSQADataMakerRec->Add2RecPointsList(fHistClusterTypeLayer6, 
528                                            fRecsOffset + fSSDhRecs);
529   fSSDhRecs += 1;
530   TH1F *fHistChargeRatioLayer5 = new TH1F("fHistChargeRatioLayer5",
531                                           "Charge ratio - Layer 5;q_{ratio};Entries;",
532                                           100,-2.0,2.0);
533   fAliITSQADataMakerRec->Add2RecPointsList(fHistChargeRatioLayer5, 
534                                            fRecsOffset + fSSDhRecs);
535   fSSDhRecs += 1;
536   TH1F *fHistChargeRatioLayer6 = new TH1F("fHistChargeRatioLayer6",
537                                           "Charge ratio - Layer 6;q_{ratio};Entries;",
538                                           100,-2.0,2.0);
539   fAliITSQADataMakerRec->Add2RecPointsList(fHistChargeRatioLayer6, 
540                                            fRecsOffset + fSSDhRecs);
541   fSSDhRecs += 1;
542   TH1F *fHistChargekeVLayer5 = new TH1F("fHistChargekeVLayer5",
543                                         "Charge - Layer 5;q [keV];Entries;",
544                                         100,0.,300.);
545   fAliITSQADataMakerRec->Add2RecPointsList(fHistChargekeVLayer5, 
546                                            fRecsOffset + fSSDhRecs);
547   fSSDhRecs += 1;
548   TH1F *fHistChargekeVLayer6 = new TH1F("fHistChargekeVLayer6",
549                                         "Charge - Layer 6;q [keV];Entries;",
550                                         100,0.,300.);
551   fAliITSQADataMakerRec->Add2RecPointsList(fHistChargekeVLayer6, 
552                                            fRecsOffset + fSSDhRecs);
553   fSSDhRecs += 1;
554   TH1F *fHistChargeADCLayer5 = new TH1F("fHistChargeADCLayer5",
555                                         "Charge - Layer 5;q [ADC];Entries;",
556                                         100,0.,300.);
557   fAliITSQADataMakerRec->Add2RecPointsList(fHistChargeADCLayer5, 
558                                            fRecsOffset + fSSDhRecs);
559   fSSDhRecs += 1;
560   TH1F *fHistChargeADCLayer6 = new TH1F("fHistChargeADCLayer6",
561                                         "Charge - Layer 6;q [ADC];Entries;",
562                                         100,0.,300.);
563   fAliITSQADataMakerRec->Add2RecPointsList(fHistChargeADCLayer6, 
564                                            fRecsOffset + fSSDhRecs);
565   fSSDhRecs += 1;
566   TH2F *fHistChargeMapLayer5 = new TH2F("fHistChargeMapLayer5",
567                                         "Charge map;N_{modules};N_{Ladders}",
568                                         fgkSSDMODULESPERLADDERLAYER5,
569                                         -0.5,fgkSSDMODULESPERLADDERLAYER5+0.5,
570                                         3*fgkSSDLADDERSLAYER5,
571                                         -0.5,fgkSSDLADDERSLAYER5+0.5);
572   fAliITSQADataMakerRec->Add2RecPointsList(fHistChargeMapLayer5, 
573                                            fRecsOffset + fSSDhRecs);
574   fSSDhRecs += 1;
575   TH2F *fHistChargeMapLayer6 = new TH2F("fHistChargeMapLayer6",
576                                         "Charge map;N_{modules};N_{Ladders}",
577                                         fgkSSDMODULESPERLADDERLAYER6,
578                                         -0.5,fgkSSDMODULESPERLADDERLAYER6+0.5,
579                                         3*fgkSSDLADDERSLAYER6,
580                                         -0.5,fgkSSDLADDERSLAYER6+0.5);
581   fAliITSQADataMakerRec->Add2RecPointsList(fHistChargeMapLayer6, 
582                                            fRecsOffset + fSSDhRecs);
583   fSSDhRecs += 1;
584
585 // custom code here
586 //fSSDhRecs must be incremented by one unit every time a histogram is ADDED to the QA List
587
588   AliDebug(1,Form("%d SSD Recs histograms booked\n",fSSDhRecs));
589 }
590
591 //____________________________________________________________________________ 
592 void AliITSQASSDDataMakerRec::MakeRecPoints(TTree *clustersTree)
593 {
594   // Fill QA for recpoints - SSD -
595   Int_t fLayer = 0, fLadder = 0, fModule = 0;
596   Int_t lLadderLocationY = 0;
597   TBranch *branchRecP = clustersTree->GetBranch("ITSRecPoints");
598   if (!branchRecP) { 
599     AliError("can't get the branch with the ITS clusters !");
600     return;
601   }
602   TClonesArray * recpoints = new TClonesArray("AliITSRecPoint") ;
603   branchRecP->SetAddress(&recpoints);
604   Int_t npoints = 0;      
605   Float_t cluglo[3]={0.,0.,0.}; 
606   for(Int_t module = 0; module < clustersTree->GetEntries(); module++){
607     branchRecP->GetEvent(module);
608     npoints += recpoints->GetEntries();
609     AliITSgeomTGeo::GetModuleId(module,fLayer,fLadder,fModule);
610     lLadderLocationY = 3*fLadder;
611
612     for(Int_t j = 0;j < recpoints->GetEntries(); j++){
613       AliITSRecPoint *recp = (AliITSRecPoint*)recpoints->At(j);    
614       Int_t layer = recp->GetLayer();
615       recp->GetGlobalXYZ(cluglo);
616       Float_t radius = TMath::Sqrt(cluglo[0]*cluglo[0]+cluglo[1]*cluglo[1]); 
617       Float_t phi = TMath::ATan2(cluglo[1],cluglo[0]);
618       Float_t theta = TMath::ATan2(radius,cluglo[2]);
619       if(layer == 4) {
620         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 0)->Fill(module);
621         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 2)->Fill(recp->GetDetLocalX());
622         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 4)->Fill(recp->GetDetLocalZ());
623         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 6)->Fill(cluglo[0]);
624         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 8)->Fill(cluglo[1]);
625         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 10)->Fill(cluglo[2]);
626         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 12)->Fill(phi);
627         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 14)->Fill(theta);
628         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 16)->Fill(radius);
629         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 18)->Fill(recp->GetType());
630         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 20)->Fill(recp->GetChargeRatio());
631         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 22)->Fill(recp->GetQ());
632         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 26)->SetBinContent(fModule,lLadderLocationY,recp->GetQ());
633       }//layer 5 histograms
634       if(layer == 5) {
635         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 1)->Fill(module);
636         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 3)->Fill(recp->GetDetLocalX());
637         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 5)->Fill(recp->GetDetLocalZ());
638         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 7)->Fill(cluglo[0]);
639         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 9)->Fill(cluglo[1]);
640         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 11)->Fill(cluglo[2]);
641         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 13)->Fill(phi);
642         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 15)->Fill(theta);
643         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 17)->Fill(radius);
644         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 19)->Fill(recp->GetType());
645         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 21)->Fill(recp->GetChargeRatio());
646         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 23)->Fill(recp->GetQ());
647         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 27)->SetBinContent(fModule,lLadderLocationY,recp->GetQ());
648       }//layer 6 histograms
649     }//rec. points loop
650   }//module loop
651
652   recpoints->Delete();
653   delete recpoints;
654 }