Restoring backward compatibility of the SSD calibration objects + output of the SSD...
[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 #include <TSystem.h>
30
31 // --- Standard library ---
32
33 // --- AliRoot header files ---
34 #include "AliITSQASSDDataMakerRec.h"
35 #include "AliQADataMakerRec.h"
36 #include "AliLog.h"
37 #include "AliQA.h"
38 #include "AliQAChecker.h"
39 #include "AliRawReader.h"
40 #include "AliRawReaderRoot.h"
41 #include "AliITSRawStreamSSD.h"
42 #include "AliITSgeomTGeo.h"
43 #include "AliRawEventHeaderBase.h"
44 #include "AliITSRecPoint.h"
45 #include "AliITSBadChannelsSSDv2.h"
46
47 #include "AliCDBManager.h"
48 #include "AliCDBEntry.h"
49
50 ClassImp(AliITSQASSDDataMakerRec)
51
52 AliITSQASSDDataMakerRec::AliITSQASSDDataMakerRec(AliITSQADataMakerRec *aliITSQADataMakerRec, Bool_t kMode, Int_t ldc) :
53 TObject(),
54 fAliITSQADataMakerRec(aliITSQADataMakerRec),
55 fSSDEvent(0),
56 fSSDEventPerCycle(0),
57 fkOnline(kMode),
58 fLDC(ldc),
59 fSSDRawsOffset(0), fSSDRawsDAOffset(0),
60 fSSDRawsCommonLevelOffset(0),
61 fSSDhTask(0),
62 fGenOffset(0),
63 fCDBManager(0) {
64   // Default constructor   
65   //initilize the raw signal vs strip number histograms
66   if(fkOnline) {
67     fCDBManager = AliCDBManager::Instance();
68     //fCDBManager->SetDefaultStorage("local://$ALICE_ROOT");
69     fCDBManager->SetDefaultStorage(gSystem->Getenv("AMORE_CDB_URI"));
70     Int_t runNumber = atoi(gSystem->Getenv("DATE_RUN_NUMBER"));
71     if(!runNumber) 
72       AliInfo("DATE_RUN_NUMBER not defined!!!\n");
73     
74     fCDBManager->SetRun(runNumber);
75     AliCDBEntry *geomGRP = fCDBManager->Get("GRP/Geometry/Data");
76     if(!geomGRP) AliInfo("GRP geometry not found!!!\n");
77     
78     Int_t gLayer = 0,gLadder = 0, gModule = 0;
79     Int_t gHistCounter = 0;
80     TString gTitle; 
81
82     for(Int_t iModule = 500; iModule < fgkSSDMODULES + 500; iModule++) {
83       AliITSgeomTGeo::GetModuleId(iModule,gLayer,gLadder,gModule);
84       gTitle = "SSD_RawSignal_Layer"; gTitle += gLayer;
85       gTitle += "_Ladder"; gTitle += gLadder;
86       gTitle += "_Module"; gTitle += gModule;
87       fHistSSDRawSignalModule[gHistCounter] = new TH1D(gTitle.Data(),gTitle.Data(),
88                                                        2*fgkNumberOfPSideStrips,0,2*fgkNumberOfPSideStrips);
89       gHistCounter += 1;
90       
91       for(Int_t iStrip = 0; iStrip < 2*fgkNumberOfPSideStrips; iStrip++)
92         fOccupancyMatrix[iModule][iStrip] = 0; 
93     }//module loop
94   }//online flag
95   else {
96     for(Int_t iModule = 0; iModule < fgkSSDMODULES; iModule++) 
97       fHistSSDRawSignalModule[iModule]=NULL;
98     fCDBManager = NULL;
99   }
100 }
101
102 //____________________________________________________________________________ 
103 AliITSQASSDDataMakerRec::AliITSQASSDDataMakerRec(const AliITSQASSDDataMakerRec& qadm) :
104 TObject(),
105 fAliITSQADataMakerRec(qadm.fAliITSQADataMakerRec),
106 fSSDEvent(qadm.fSSDEvent),
107 fSSDEventPerCycle(qadm.fSSDEventPerCycle),
108 fkOnline(qadm.fkOnline),
109 fLDC(qadm.fLDC),
110 fSSDRawsOffset(qadm.fSSDRawsOffset), fSSDRawsDAOffset(qadm.fSSDRawsDAOffset),
111 fSSDRawsCommonLevelOffset(qadm.fSSDRawsCommonLevelOffset),
112 fSSDhTask(qadm.fSSDhTask),
113 fGenOffset(qadm.fGenOffset),
114 fCDBManager(qadm.fCDBManager) {
115   //copy ctor 
116   fAliITSQADataMakerRec->SetName((const char*)qadm.fAliITSQADataMakerRec->GetName()) ; 
117   fAliITSQADataMakerRec->SetTitle((const char*)qadm.fAliITSQADataMakerRec->GetTitle());
118 }
119
120 //__________________________________________________________________
121 AliITSQASSDDataMakerRec& AliITSQASSDDataMakerRec::operator = (const AliITSQASSDDataMakerRec& qac )
122 {
123   // Equal operator.
124   this->~AliITSQASSDDataMakerRec();
125   new(this) AliITSQASSDDataMakerRec(qac);
126   return *this;
127 }
128
129 //__________________________________________________________________
130 AliITSQASSDDataMakerRec::~AliITSQASSDDataMakerRec() {
131   // destructor
132   for(Int_t iModule = 0; iModule < fgkSSDMODULES; iModule++)
133     if(fHistSSDRawSignalModule[iModule]) delete fHistSSDRawSignalModule[iModule];
134   if(fCDBManager) delete fCDBManager;
135 }
136
137 //____________________________________________________________________________ 
138 void AliITSQASSDDataMakerRec::StartOfDetectorCycle()
139 {
140   //Detector specific actions at start of cycle
141   AliDebug(1,"AliITSQADM::Start of SSD Cycle\n");
142 }
143
144 //____________________________________________________________________________ 
145 void AliITSQASSDDataMakerRec::EndOfDetectorCycle(AliQA::TASKINDEX_t task, TObjArray* list)
146 {
147   // launch the QA checking
148   AliDebug(1,"AliITSDM instantiates checker with Run(AliQA::kITS, task, list)\n"); 
149   
150   //online part
151   if(fkOnline) {
152     //Output of the DA
153     MonitorOCDBObjects();
154
155     Int_t gHistPositionOccupancyPerModule = 0;
156     Int_t gLayer = 0, gLadder = 0, gModule = 0;
157     //occupancy per module
158     for(Int_t iModule = 0; iModule < fgkSSDMODULES; iModule++) {
159       AliITSgeomTGeo::GetModuleId(iModule+500,gLayer,gLadder,gModule);
160
161       gHistPositionOccupancyPerModule = (gLayer == 5) ? ((gLadder - 1)*fgkSSDMODULESPERLADDERLAYER5 + gModule - 1) : ((gLadder - 1)*fgkSSDMODULESPERLADDERLAYER6 + gModule + fgkSSDMODULESLAYER5 - 1);
162       for(Int_t iBins = 1; iBins < fHistSSDRawSignalModule[iModule]->GetXaxis()->GetNbins(); iBins++)
163         fAliITSQADataMakerRec->GetRawsData(fGenOffset+fSSDRawsCommonLevelOffset+gHistPositionOccupancyPerModule)->SetBinContent(iBins,fOccupancyMatrix[iModule][iBins-1]);
164       
165       if(fSSDEventPerCycle != 0)
166         ((TH1D *)(fAliITSQADataMakerRec->GetRawsData(fGenOffset+fSSDRawsCommonLevelOffset+gHistPositionOccupancyPerModule)))->Scale(100./fSSDEventPerCycle);
167     }//module loop
168
169     //occupancy per ladder
170     Int_t gHistPositionOccupancyPerLadder = 0;
171     Int_t lLadderLocationY = 0;
172     Double_t occupancy = 0.0;
173     for(Int_t iModule = 0; iModule < fgkSSDMODULES; iModule++) {
174       AliITSgeomTGeo::GetModuleId(iModule+500,gLayer,gLadder,gModule);
175       
176       gHistPositionOccupancyPerModule = (gLayer == 5) ? ((gLadder - 1)*fgkSSDMODULESPERLADDERLAYER5 + gModule - 1) : ((gLadder - 1)*fgkSSDMODULESPERLADDERLAYER6 + gModule + fgkSSDMODULESLAYER5 - 1);
177       gHistPositionOccupancyPerLadder = (gLayer == 5) ? 2*(gLadder - 1) : 2*(gLadder - 1 + fgkSSDLADDERSLAYER5);
178       
179       //P-SIDE OCCUPANCY                                                                     
180       occupancy = GetOccupancyModule((TH1 *)fAliITSQADataMakerRec->GetRawsData(fGenOffset+fSSDRawsCommonLevelOffset+fgkSSDMODULES+gHistPositionOccupancyPerModule),0);
181       fAliITSQADataMakerRec->GetRawsData(fGenOffset+fSSDRawsCommonLevelOffset+fgkSSDMODULES+fgkSSDMODULES+gHistPositionOccupancyPerLadder)->Fill(gModule,occupancy);
182       lLadderLocationY = 3*gLadder; // sideP=1 sideN=0 
183       if(gLayer == 5)                                                               
184         ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenOffset+fSSDRawsCommonLevelOffset+fgkSSDMODULES+2*fgkSSDLADDERSLAYER5+2*fgkSSDLADDERSLAYER6))->SetBinContent(gModule,lLadderLocationY,occupancy);
185       else if(gLayer == 6)
186         ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenOffset+fSSDRawsCommonLevelOffset+fgkSSDMODULES+2*fgkSSDLADDERSLAYER5+2*fgkSSDLADDERSLAYER6+1))->SetBinContent(gModule,lLadderLocationY,occupancy);
187
188       //N-SIDE OCCUPANCY                                                                           
189       occupancy = GetOccupancyModule((TH1 *)fAliITSQADataMakerRec->GetRawsData(fGenOffset+fSSDRawsCommonLevelOffset+fgkSSDMODULES+gHistPositionOccupancyPerModule),1);   
190       fAliITSQADataMakerRec->GetRawsData(fGenOffset+fSSDRawsCommonLevelOffset+fgkSSDMODULES+fgkSSDMODULES+gHistPositionOccupancyPerLadder+1)->Fill(gModule,occupancy);
191       if(gLayer == 5)                                                               
192         ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenOffset+fSSDRawsCommonLevelOffset+fgkSSDMODULES+2*fgkSSDLADDERSLAYER5+2*fgkSSDLADDERSLAYER6))->SetBinContent(gModule,lLadderLocationY-1,occupancy);
193       else if(gLayer == 6)
194         ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenOffset+fSSDRawsCommonLevelOffset+fgkSSDMODULES+2*fgkSSDLADDERSLAYER5+2*fgkSSDLADDERSLAYER6+1))->SetBinContent(gModule,lLadderLocationY-1,occupancy);
195     }//module loop
196   }//online flag for SSD
197
198   fSSDEventPerCycle = 0;
199   
200   AliQAChecker::Instance()->Run( AliQA::kITS , task, list);
201 }
202
203 //____________________________________________________________________________ 
204 void AliITSQASSDDataMakerRec::InitRaws() {  
205   // Initialization for RAW data - SSD -
206     fGenOffset = (fAliITSQADataMakerRec->fRawsQAList)->GetEntries();
207
208   if(fkOnline) {
209     AliInfo("Book Online Histograms for SSD\n");
210   }
211   else {
212     AliInfo("Book Offline Histograms for SSD\n ");
213   }
214   AliInfo(Form("Number of histograms (SPD+SDD): %d\n",fGenOffset));
215   TString gTitle = 0;
216   //book online-offline QA histos
217   TH1F *fHistSSDEventType = new TH1F("fHistSSDEventType",
218                                      ";Event type;Events",
219                                      31,-1,30);
220   fAliITSQADataMakerRec->Add2RawsList(fHistSSDEventType, 
221                                       fGenOffset+fSSDRawsOffset);
222   fSSDRawsOffset += 1;
223   TH1F *fHistSSDDataSize = new TH1F("fHistSSDDataSize",
224                                     ";log(SSD data size) [Bytes];Events",
225                                     100,3,8);
226   fAliITSQADataMakerRec->Add2RawsList(fHistSSDDataSize, 
227                                       fGenOffset+fSSDRawsOffset);
228   fSSDRawsOffset += 1;
229   TH1F *fHistSSDDataSizePercentage = new TH1F("fHistSSDDataSizePercentage",
230                                               ";SSD data size [%];Events",
231                                               100,0,100);
232   fAliITSQADataMakerRec->Add2RawsList(fHistSSDDataSizePercentage, 
233                                       fGenOffset+fSSDRawsOffset);
234   fSSDRawsOffset += 1;
235   TH1F *fHistSSDDDLId = new TH1F("fHistSSDDDLId",
236                                  ";DDL id;Events",20,510.5,530.5);
237   fAliITSQADataMakerRec->Add2RawsList(fHistSSDDDLId, 
238                                       fGenOffset+fSSDRawsOffset);
239   fSSDRawsOffset += 1;
240   TH1F *fHistSSDDataSizePerDDL = new TH1F("fHistSSDDataSizePerDDL",
241                                           ";DDL id;<SSD data size> [MB]",
242                                           20,510.5,530.5);
243   fAliITSQADataMakerRec->Add2RawsList(fHistSSDDataSizePerDDL, 
244                                       fGenOffset+fSSDRawsOffset);
245   fSSDRawsOffset += 1;
246   TH1F *fHistSSDDataSizeDDL[fgkNumOfDDLs];
247   for(Int_t i = 1; i < fgkNumOfDDLs+1; i++) {
248     gTitle = "fHistSSDDataSizeDDL"; gTitle += i+511;
249     fHistSSDDataSizeDDL[i-1] = new TH1F(gTitle.Data(),
250                                         ";log(SSD data size) [Bytes];Events",
251                                         100,1,8);
252     fAliITSQADataMakerRec->Add2RawsList(fHistSSDDataSizeDDL[i-1], 
253                                         fGenOffset+fSSDRawsOffset);
254     fSSDRawsOffset += 1;
255   }
256   
257   TH1F *fHistSSDLDCId = new TH1F("fHistSSDLDCId",";LDC id;Events",10,0.5,10.5);
258   fAliITSQADataMakerRec->Add2RawsList(fHistSSDLDCId, 
259                                       fGenOffset+fSSDRawsOffset);
260   fSSDRawsOffset += 1;
261   TH1F *fHistSSDDataSizePerLDC = new TH1F("fHistSSDDataSizePerLDC",
262                                           ";LDC id;<SSD data size> [MB]",
263                                           100,0,20);
264   fAliITSQADataMakerRec->Add2RawsList(fHistSSDDataSizePerLDC, 
265                                       fGenOffset+fSSDRawsOffset);
266   fSSDRawsOffset += 1;
267   TH1F *fHistSSDDataSizeLDC[fgkNumOfLDCs];
268   for(Int_t i = 1; i < fgkNumOfLDCs+1; i++) {
269     gTitle = "fHistSSDDataSizeLDC"; gTitle += i;
270     fHistSSDDataSizeLDC[i-1] = new TH1F(gTitle.Data(),
271                                         ";log(SSD data size) [Bytes];Events",
272                                         100,1,8);
273     fAliITSQADataMakerRec->Add2RawsList(fHistSSDDataSizeLDC[i-1], 
274                                         fGenOffset+fSSDRawsOffset);
275     fSSDRawsOffset += 1;
276   }
277   fSSDRawsCommonLevelOffset = fSSDRawsOffset;
278
279   if(fkOnline) {
280     Int_t gLayer = 0, gLadder = 0, gModule = 0;
281     //occupancy per SSD module
282     TH1D *fHistSSDOccupancyModule[fgkSSDMODULES]; 
283     for(Int_t i = 500; i < fgkSSDMODULES + 500; i++) {
284       AliITSgeomTGeo::GetModuleId(i,gLayer,gLadder,gModule);
285       gTitle = "fHistSSD_Occupancy_Layer"; gTitle += gLayer;
286       gTitle += "_Ladder"; 
287       if(gLayer == 5)
288         gTitle += 499+gLadder;
289       if(gLayer == 6)
290         gTitle += 599+gLadder;
291       gTitle += "_Module"; gTitle += gModule; 
292       fHistSSDOccupancyModule[i-500] = new TH1D(gTitle.Data(),gTitle.Data(),
293                                                 2*fgkNumberOfPSideStrips,0,2*fgkNumberOfPSideStrips);
294       fHistSSDOccupancyModule[i-500]->GetXaxis()->SetTitleColor(1);
295       fHistSSDOccupancyModule[i-500]->GetXaxis()->SetTitle("N_{strip}");
296       fHistSSDOccupancyModule[i-500]->GetYaxis()->SetTitle("Occupancy [%]");
297       fAliITSQADataMakerRec->Add2RawsList(fHistSSDOccupancyModule[i-500], fGenOffset+fSSDRawsOffset);
298       fSSDRawsOffset += 1;
299     }
300
301     //Occupancy per SSD ladder
302     Int_t occupancyCounter = 0;
303     TH1D *fHistSSDOccupancyLadder[2*(fgkSSDLADDERSLAYER5 + fgkSSDLADDERSLAYER6)];
304     for(Int_t iLayer = 5; iLayer < 7; iLayer++) {
305       for(Int_t iLadder = 1; iLadder < AliITSgeomTGeo::GetNLadders(iLayer) + 1; iLadder++) {
306         //P-side occupancy plots
307         gTitle = "fHistSSD_Occupancy_Layer"; gTitle += iLayer;
308         gTitle += "_Ladder"; 
309         if(iLayer == 5)
310           gTitle += 499+iLadder;
311         if(iLayer == 6)
312           gTitle += 599+iLadder;
313         gTitle += "_PSide";
314         fHistSSDOccupancyLadder[occupancyCounter] = new TH1D(gTitle.Data(),
315                                                              gTitle.Data(),
316                                                              AliITSgeomTGeo::GetNDetectors(iLayer),
317                                                              0.5,AliITSgeomTGeo::GetNDetectors(iLayer)+0.5);
318         fHistSSDOccupancyLadder[occupancyCounter]->GetXaxis()->SetTitleColor(1);
319         fHistSSDOccupancyLadder[occupancyCounter]->GetXaxis()->SetTitle("Module number");
320         fHistSSDOccupancyLadder[occupancyCounter]->GetYaxis()->SetTitle("Occupancy [%]");
321         fAliITSQADataMakerRec->Add2RawsList(fHistSSDOccupancyLadder[occupancyCounter], 
322                                             fGenOffset+fSSDRawsOffset);
323         occupancyCounter += 1; fSSDRawsOffset += 1;
324         //N-side occupancy plots
325         gTitle = "fHistSSD_Occupancy_Layer"; gTitle += iLayer;
326         gTitle += "_Ladder"; 
327         if(iLayer == 5)
328           gTitle += 499+iLadder;
329         if(iLayer == 6)
330           gTitle += 599+iLadder;
331         gTitle += "_NSide";
332         fHistSSDOccupancyLadder[occupancyCounter] = new TH1D(gTitle.Data(),
333                                                              gTitle.Data(),
334                                                              AliITSgeomTGeo::GetNDetectors(iLayer),
335                                                              0.5,AliITSgeomTGeo::GetNDetectors(iLayer)+0.5);
336         fHistSSDOccupancyLadder[occupancyCounter]->GetXaxis()->SetTitleColor(1);
337         fHistSSDOccupancyLadder[occupancyCounter]->GetXaxis()->SetTitle("Module number");
338         fHistSSDOccupancyLadder[occupancyCounter]->GetYaxis()->SetTitle("Occupancy [%]");
339         fAliITSQADataMakerRec->Add2RawsList(fHistSSDOccupancyLadder[occupancyCounter], 
340                                             fGenOffset+fSSDRawsOffset);
341         occupancyCounter += 1; fSSDRawsOffset += 1;
342       }//ladder loop
343     }//layer loop
344
345     //top level occupancy plots
346     TH2D *fHistSSDOccupancyLayer5 = new TH2D("fHistSSDOccupancyLayer5",
347                                              ";N_{modules};N_{Ladders}",
348                                              fgkSSDMODULESPERLADDERLAYER5,
349                                              0,fgkSSDMODULESPERLADDERLAYER5,
350                                              3*fgkSSDLADDERSLAYER5,
351                                              0,fgkSSDLADDERSLAYER5);  
352     Char_t fLabel[3];
353     for(Int_t iBin = 1; iBin < fgkSSDMODULESPERLADDERLAYER5 + 1; iBin++){
354       sprintf(fLabel,"%d",iBin);
355       fHistSSDOccupancyLayer5->GetXaxis()->SetBinLabel(iBin,fLabel);
356     }
357     fAliITSQADataMakerRec->Add2RawsList(fHistSSDOccupancyLayer5, fGenOffset+fSSDRawsOffset);
358     fSSDRawsOffset += 1;
359     TH2D *fHistSSDOccupancyLayer6 = new TH2D("fHistSSDOccupancyLayer6",
360                                              ";N_{modules};N_{Ladders}",
361                                              fgkSSDMODULESPERLADDERLAYER6,
362                                              0,fgkSSDMODULESPERLADDERLAYER6,
363                                              3*fgkSSDLADDERSLAYER6,
364                                              0,fgkSSDLADDERSLAYER6);
365     for(Int_t iBin = 1; iBin < fgkSSDMODULESPERLADDERLAYER6 + 1; iBin++){
366       sprintf(fLabel,"%d",iBin);
367       fHistSSDOccupancyLayer6->GetXaxis()->SetBinLabel(iBin,fLabel);
368     }
369     fAliITSQADataMakerRec->Add2RawsList(fHistSSDOccupancyLayer6, fGenOffset+fSSDRawsOffset);
370     fSSDRawsOffset += 1;
371
372     //Output of the DA
373     TH2D *fHistPSideBadChannelMapLayer5 = new TH2D("fHistPSideBadChannelMapLayer5",
374                                                    "Layer 5;N_{module};N_{ladder}",
375                                                    22,1,23,
376                                                    34,500,534);
377     fHistPSideBadChannelMapLayer5->GetXaxis()->SetTitleColor(1);
378     fHistPSideBadChannelMapLayer5->SetStats(kFALSE);
379     fHistPSideBadChannelMapLayer5->GetYaxis()->SetTitleOffset(1.8);
380     fHistPSideBadChannelMapLayer5->GetXaxis()->SetNdivisions(22);
381     fHistPSideBadChannelMapLayer5->GetYaxis()->SetNdivisions(34);
382     fHistPSideBadChannelMapLayer5->GetXaxis()->SetLabelSize(0.03);
383     fHistPSideBadChannelMapLayer5->GetYaxis()->SetLabelSize(0.03);
384     fHistPSideBadChannelMapLayer5->GetZaxis()->SetTitleOffset(1.6);
385     fHistPSideBadChannelMapLayer5->GetZaxis()->SetTitle("Bad channels (p-side)[%]");
386     fAliITSQADataMakerRec->Add2RawsList(fHistPSideBadChannelMapLayer5, fGenOffset+fSSDRawsOffset);
387     fSSDRawsOffset += 1; fSSDRawsDAOffset += 1;
388
389     TH2D *fHistNSideBadChannelMapLayer5 = new TH2D("fHistNSideBadChannelMapLayer5",
390                                                    "Layer 5;N_{module};N_{ladder}",
391                                                    22,1,23,
392                                                    34,500,534);
393     fHistNSideBadChannelMapLayer5->GetXaxis()->SetTitleColor(1);
394     fHistNSideBadChannelMapLayer5->SetStats(kFALSE);
395     fHistNSideBadChannelMapLayer5->GetYaxis()->SetTitleOffset(1.8);
396     fHistNSideBadChannelMapLayer5->GetXaxis()->SetNdivisions(22);
397     fHistNSideBadChannelMapLayer5->GetYaxis()->SetNdivisions(34);
398     fHistNSideBadChannelMapLayer5->GetXaxis()->SetLabelSize(0.03);
399     fHistNSideBadChannelMapLayer5->GetYaxis()->SetLabelSize(0.03);
400     fHistNSideBadChannelMapLayer5->GetZaxis()->SetTitleOffset(1.6);
401     fHistNSideBadChannelMapLayer5->GetZaxis()->SetTitle("Bad channels (n-side)[%]");
402     fAliITSQADataMakerRec->Add2RawsList(fHistNSideBadChannelMapLayer5, fGenOffset+fSSDRawsOffset);
403     fSSDRawsOffset += 1; fSSDRawsDAOffset += 1;
404
405     TH2D *fHistPSideBadChannelMapLayer6 = new TH2D("fHistPSideBadChannelMapLayer6",
406                                                    "Layer 6;N_{module};N_{ladder}",
407                                                    25,1,26,
408                                                    38,600,638);
409     fHistPSideBadChannelMapLayer6->GetXaxis()->SetTitleColor(1);
410     fHistPSideBadChannelMapLayer6->SetStats(kFALSE);
411     fHistPSideBadChannelMapLayer6->GetYaxis()->SetTitleOffset(1.8);
412     fHistPSideBadChannelMapLayer6->GetXaxis()->SetNdivisions(25);
413     fHistPSideBadChannelMapLayer6->GetYaxis()->SetNdivisions(38);
414     fHistPSideBadChannelMapLayer6->GetXaxis()->SetLabelSize(0.03);
415     fHistPSideBadChannelMapLayer6->GetYaxis()->SetLabelSize(0.03);
416     fHistPSideBadChannelMapLayer6->GetZaxis()->SetTitleOffset(1.6);
417     fHistPSideBadChannelMapLayer6->GetZaxis()->SetTitle("Bad channels (p-side)[%]");
418     fAliITSQADataMakerRec->Add2RawsList(fHistPSideBadChannelMapLayer6, fGenOffset+fSSDRawsOffset);
419     fSSDRawsOffset += 1; fSSDRawsDAOffset += 1;
420
421     TH2D *fHistNSideBadChannelMapLayer6 = new TH2D("fHistNSideBadChannelMapLayer6",
422                                                    "Layer 6;N_{module};N_{ladder}",
423                                                    25,1,26,
424                                                    38,600,638);
425     fHistNSideBadChannelMapLayer6->GetXaxis()->SetTitleColor(1);
426     fHistNSideBadChannelMapLayer6->SetStats(kFALSE);
427     fHistNSideBadChannelMapLayer6->GetYaxis()->SetTitleOffset(1.8);
428     fHistNSideBadChannelMapLayer6->GetXaxis()->SetNdivisions(25);
429     fHistNSideBadChannelMapLayer6->GetYaxis()->SetNdivisions(38);
430     fHistNSideBadChannelMapLayer6->GetXaxis()->SetLabelSize(0.03);
431     fHistNSideBadChannelMapLayer6->GetYaxis()->SetLabelSize(0.03);
432     fHistNSideBadChannelMapLayer6->GetZaxis()->SetTitleOffset(1.6);
433     fHistNSideBadChannelMapLayer6->GetZaxis()->SetTitle("Bad channels (n-side)[%]");
434     fAliITSQADataMakerRec->Add2RawsList(fHistNSideBadChannelMapLayer6, fGenOffset+fSSDRawsOffset);
435     fSSDRawsOffset += 1; fSSDRawsDAOffset += 1;
436   }//online flag
437   fSSDhTask = fSSDRawsOffset;
438   AliDebug(1,Form("%d SSD Raws histograms booked\n",fSSDhTask));
439   AliInfo(Form("Number of histograms (SPD+SDD+SSD): %d\n",fGenOffset+fSSDhTask));  
440   AliDebug(1,Form("Number of histograms (SPD+SDD+SSD): %d\n",fGenOffset+fSSDRawsOffset));
441 }
442
443 //____________________________________________________________________________
444 void AliITSQASSDDataMakerRec::MakeRaws(AliRawReader* rawReader) { 
445   // Fill QA for RAW - SSD -
446   Int_t gStripNumber;
447   Int_t gHistPosition;
448   Int_t gLayer = 0,gLadder = 0, gModule = 0;
449   
450   Double_t gSizePerDDL[fgkNumOfDDLs] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
451   Double_t gSizePerLDC[fgkNumOfLDCs] = {0.,0.,0.};
452   Double_t sumSSDDataSize = 0.0;
453   Double_t eventSize = -1.0;
454
455   if(fkOnline) {
456     //reset the signal vs strip number histograms
457     for(Int_t iModule = 0; iModule < fgkSSDMODULES; iModule++)
458       fHistSSDRawSignalModule[iModule]->Reset();
459   }//online flag
460
461   rawReader->Select("ITSSSD",-1,-1);  
462   rawReader->Reset(); //rawReader->NextEvent();   
463   (fAliITSQADataMakerRec->GetRawsData(fGenOffset))->Fill(rawReader->GetType());
464   if(rawReader->GetType() == 7) {
465     fSSDEvent += 1;
466     fSSDEventPerCycle += 1;
467   }
468
469   AliITSRawStreamSSD gSSDStream(rawReader);    
470   AliRawReaderRoot *rootReader = (AliRawReaderRoot *)rawReader;
471   if(rootReader) {
472     const AliRawEventHeaderBase *header = rootReader->GetEventHeader();
473     if(header)
474       eventSize = header->GetEventSize();
475   }
476   while (gSSDStream.Next()) {
477     if(gSSDStream.GetModuleID() < 0) continue;
478     gSizePerDDL[rawReader->GetDDLID()] = rawReader->GetDataSize();
479     gSizePerLDC[rawReader->GetLDCId()-6] = rawReader->GetDataSize();
480     AliITSgeomTGeo::GetModuleId(gSSDStream.GetModuleID(),gLayer,gLadder,gModule);
481     gStripNumber = (gSSDStream.GetSideFlag() == 0) ? gSSDStream.GetStrip() : gSSDStream.GetStrip() + fgkNumberOfPSideStrips;
482     gHistPosition = (gLayer == 5) ? ((gLadder - 1)*fgkSSDMODULESPERLADDERLAYER5 + gModule - 1) : ((gLadder - 1)*fgkSSDMODULESPERLADDERLAYER6 + gModule + fgkSSDMODULESLAYER5 - 1);
483     //AliInfo(Form("ModulePosition: %d - Layer: %d - Ladder: %d - Module: %d\n",gHistPosition,gLayer,gLadder,gModule));
484     if(fkOnline)
485       fHistSSDRawSignalModule[gHistPosition]->Fill(gStripNumber,gSSDStream.GetSignal());
486     //fAliITSQADataMakerRec->GetRawsData(fGenOffset+gHistPosition+fSSDRawsCommonLevelOffset)->Fill(gStripNumber,gSSDStream.GetSignal());
487   }//streamer loop   
488   
489   //event size calculation and filling info
490   for(Int_t i = 0; i < fgkNumOfDDLs; i++) {
491     sumSSDDataSize += gSizePerDDL[i];
492     if(gSizePerDDL[i] > 0) {
493       (fAliITSQADataMakerRec->GetRawsData(fGenOffset+3))->Fill(i+512);
494       (fAliITSQADataMakerRec->GetRawsData(fGenOffset+5+i))->Fill(TMath::Log10(gSizePerDDL[i]));
495     }
496     (fAliITSQADataMakerRec->GetRawsData(fGenOffset+4))->Fill(i+512,gSizePerDDL[i]/1e+06);
497   }
498   for(Int_t i = 0; i < fgkNumOfLDCs; i++) {
499     if(gSizePerLDC[i] > 0) {
500       (fAliITSQADataMakerRec->GetRawsData(fGenOffset+21))->Fill(i+6);
501       (fAliITSQADataMakerRec->GetRawsData(fGenOffset+23+i))->Fill(TMath::Log10(gSizePerLDC[i]));
502     }
503     (fAliITSQADataMakerRec->GetRawsData(fGenOffset+22))->Fill(i+6,gSizePerLDC[i]/1e+06);
504   }
505   if(sumSSDDataSize) 
506     (fAliITSQADataMakerRec->GetRawsData(fGenOffset+1))->Fill(TMath::Log10(sumSSDDataSize));
507   if(eventSize)
508     (fAliITSQADataMakerRec->GetRawsData(fGenOffset+2))->Fill(100.*sumSSDDataSize/eventSize);
509
510   //Occupancy calculation
511   if(fkOnline) {
512     for(Int_t iModule = 0; iModule < fgkSSDMODULES; iModule++)
513       GetOccupancyStrip(fHistSSDRawSignalModule[iModule],fOccupancyMatrix[iModule]);
514   }//online flag for SSD
515 }
516
517 //____________________________________________________________________________ //
518 void AliITSQASSDDataMakerRec::GetOccupancyStrip(TH1 *lHisto, Int_t *occupancyMatrix) { 
519   //Increments the entries in the occupancy matrix based 
520   //on whether the signal for each strip is larger than the cutoff
521   //Currently the cutoff is at 0 which means that if ZS
522   //works, whatever comes from the FEROM is considered as "signal"
523   Double_t cutoff = 0.0;
524   for(Int_t iBin = 1; iBin < lHisto->GetXaxis()->GetNbins(); iBin++) {
525     Double_t y = lHisto->GetBinContent(iBin);
526     if(y > cutoff) {
527       occupancyMatrix[iBin-1] += 1;
528       //cout<<"Event: "<<iEvent<<" - Strip: "<<i<<" - Signal: "<<fRawSignal->GetBinContent(i)<<                              
529       //" - Occupancy: "<<fOccupancy[i-1]<<endl;                                                                  
530     }
531   }
532 }
533
534 //____________________________________________________________________________ 
535 Double_t AliITSQASSDDataMakerRec::GetOccupancyModule(TH1 *lHisto, Int_t stripside) { 
536   // bo: TDC >0 or # of sigmas wrt noise ?
537   //stripside == 0 --> P-side
538   //stripside == 1 --> N-side
539   Int_t lNumFiredBins = 0;
540   for(Int_t iBin = 1 + stripside*fgkNumberOfPSideStrips; iBin < fgkNumberOfPSideStrips*(1 + stripside); iBin++){
541     if (lHisto->GetBinContent(iBin) > 0)
542       lNumFiredBins++; 
543   }
544   
545   Double_t lOccupancy = (100.*lNumFiredBins)/fgkNumberOfPSideStrips; // percentage
546   //AliInfo(Form("Fired strips: %d - Total strips: %d - Occupancy :%lf\n",lNumFiredBins,lHisto->GetNbinsX(),lOccupancy));
547   
548   return lOccupancy;
549 }
550
551 //____________________________________________________________________________
552 void AliITSQASSDDataMakerRec::MonitorOCDBObjects() { 
553   //Monitor in AMORE the output of the DA
554   //Currently only the bad channel list is monitored
555   //Todo: Noise - Pedestal
556   AliCDBEntry *entryBadChannelsSSD = fCDBManager->Get("ITS/Calib/BadChannelsSSD");
557   if(!entryBadChannelsSSD) 
558     AliError("OCDB entry for the bad channel list is not valid!"); 
559   AliITSBadChannelsSSDv2 *badchannelsSSD = (AliITSBadChannelsSSDv2 *)entryBadChannelsSSD->GetObject();
560   if(!badchannelsSSD)
561     AliError("Bad channel list object is not a valid AliITSBadChannelsSSD object!");
562
563   //_____________________________________________________________________________//                       
564   Int_t nBadPSideChannels = 0, nBadNSideChannels = 0;
565   Int_t layer = 0, ladder = 0, module = 0;
566   Int_t nPSideChannelsLayer5 = 0, nNSideChannelsLayer5 = 0;
567   Int_t nPSideChannelsLayer6 = 0, nNSideChannelsLayer6 = 0;
568   //_____________________________________________________________________________//                      
569
570   for(Int_t i = 0; i < fgkSSDMODULES; i++) {
571     AliITSgeomTGeo::GetModuleId(i+500,layer,ladder,module);
572     nBadPSideChannels = 0, nBadNSideChannels = 0;
573     nPSideChannelsLayer5 = 0, nNSideChannelsLayer5 = 0;
574     nPSideChannelsLayer6 = 0, nNSideChannelsLayer6 = 0;
575
576     Int_t badChannel = 0;
577     for(Int_t j = 0; j < fgkNumberOfPSideStrips; j++) {
578       badChannel = (Int_t)(badchannelsSSD->GetBadChannelP(i,j));
579       if(badChannel != 0) {
580         if(layer == 5)
581           nPSideChannelsLayer5 += 1;
582         if(layer == 6)
583           nPSideChannelsLayer6 += 1;
584         nBadPSideChannels += 1;
585       }//badchannel flag != 0
586       badChannel = (Int_t)(badchannelsSSD->GetBadChannelN(i,j));
587       if(badChannel != 0) {
588         if(layer == 5)
589           nNSideChannelsLayer5 += 1;
590         if(layer == 6)
591           nNSideChannelsLayer6 += 1;
592         nBadNSideChannels += 1;
593       }//badchannel flag != 0
594     }//loop over strips
595     if(layer == 5) {
596       if(nPSideChannelsLayer5 > 0)
597         ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenOffset+fSSDRawsOffset-fSSDRawsDAOffset))->Fill(module,499+ladder,
598                                                                             100.*nPSideChannelsLayer5/fgkNumberOfPSideStrips);
599       else ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenOffset+fSSDRawsOffset-fSSDRawsDAOffset))->Fill(module,499+ladder,0.0001);
600       if(nNSideChannelsLayer5 > 0)
601         ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenOffset+fSSDRawsOffset-fSSDRawsDAOffset+1))->Fill(module,499+ladder,
602                                                                             100.*nNSideChannelsLayer5/fgkNumberOfPSideStrips);
603       else ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenOffset+fSSDRawsOffset-fSSDRawsDAOffset+1))->Fill(module,499+ladder,0.0001);
604     }//layer 5                                                                                                                      
605     if(layer == 6) {
606       if(nPSideChannelsLayer6 > 0)
607         ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenOffset+fSSDRawsOffset-fSSDRawsDAOffset+2))->Fill(module,599+ladder,
608                                                                             100.*nPSideChannelsLayer6/fgkNumberOfPSideStrips);
609       else ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenOffset+fSSDRawsOffset-fSSDRawsDAOffset+2))->Fill(module,599+ladder,0.0001);
610       if(nNSideChannelsLayer6 > 0)
611         ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenOffset+fSSDRawsOffset-fSSDRawsDAOffset+3))->Fill(module,599+ladder,
612                                                                             100.*nNSideChannelsLayer6/fgkNumberOfPSideStrips);
613       else ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenOffset+fSSDRawsOffset-fSSDRawsDAOffset+3))->Fill(module,599+ladder,0.0001);
614     }//layer 6                                                                                                                      
615   }//module loop
616 }
617
618 //____________________________________________________________________________ 
619 void AliITSQASSDDataMakerRec::InitRecPoints()
620 {
621   // Initialization for RECPOINTS - SSD -
622  
623   fGenOffset = (fAliITSQADataMakerRec->fRecPointsQAList)->GetEntries();
624   Int_t nModuleOffset = 500;
625   Int_t nITSTotalModules = AliITSgeomTGeo::GetNModules();
626
627   TH1F *fHistModuleIdLayer5 = new TH1F("fHistModuleIdLayer5",
628                                        "Module Id - Layer 5;Module Id;Entries",
629                                        fgkSSDMODULESLAYER5,
630                                        nModuleOffset - 0.5,
631                                        nITSTotalModules-fgkSSDMODULESLAYER6+0.5);
632   fAliITSQADataMakerRec->Add2RecPointsList(fHistModuleIdLayer5, 
633                                            fGenOffset + 0);
634   fSSDhTask += 1;
635   TH1F *fHistModuleIdLayer6 = new TH1F("fHistModuleIdLayer6",
636                                        "Module Id - Layer 6;Module Id;Entries",
637                                        fgkSSDMODULESLAYER6,
638                                        nModuleOffset+fgkSSDMODULESLAYER5 - 0.5,
639                                        nITSTotalModules + 0.5);
640   fAliITSQADataMakerRec->Add2RecPointsList(fHistModuleIdLayer6, 
641                                            fGenOffset + 1);
642   fSSDhTask += 1;
643   TH1F *fHistClusterPerEventLayer5 = new TH1F("fHistClusterPerEventLayer5",
644                                               "N_{clusters} - Layer 5;N_{clusters};Entries;",
645                                               100,0.1,5000);
646   fAliITSQADataMakerRec->Add2RecPointsList(fHistClusterPerEventLayer5,
647                                            fGenOffset + 2);
648   fSSDhTask += 1;
649   TH1F *fHistClusterPerEventLayer6 = new TH1F("fHistClusterPerEventLayer6",
650                                               "N_{clusters} - Layer 6;N_{clusters};Entries;",
651                                               100,0.1,5000);
652   fAliITSQADataMakerRec->Add2RecPointsList(fHistClusterPerEventLayer6,
653                                            fGenOffset + 3);
654   fSSDhTask += 1;
655   TH1F *fHistLocalXLayer5 = new TH1F("fHistLocalXLayer5",
656                                      "Local x coord.- Layer 5;x [cm];Entries;",
657                                      100,-4.,4.);
658   fAliITSQADataMakerRec->Add2RecPointsList(fHistLocalXLayer5,
659                                            fGenOffset + 4);
660   fSSDhTask += 1;
661   TH1F *fHistLocalXLayer6 = new TH1F("fHistLocalXLayer6",
662                                      "Local x coord.- Layer 6;x [cm];Entries;",
663                                      100,-4.,4.);
664   fAliITSQADataMakerRec->Add2RecPointsList(fHistLocalXLayer6, 
665                                            fGenOffset + 5);
666   fSSDhTask += 1;
667   TH1F *fHistLocalZLayer5 = new TH1F("fHistLocalZLayer5",
668                                      "Local z coord.- Layer 5;z [cm];Entries;",
669                                      100,-4.,4.);
670   fAliITSQADataMakerRec->Add2RecPointsList(fHistLocalZLayer5, 
671                                            fGenOffset + 6);
672   fSSDhTask += 1;
673   TH1F *fHistLocalZLayer6 = new TH1F("fHistLocalZLayer6",
674                                      "Local z coord.- Layer 6;z [cm];Entries;",
675                                      100,-4.,4.);
676   fAliITSQADataMakerRec->Add2RecPointsList(fHistLocalZLayer6, 
677                                            fGenOffset + 7);
678   fSSDhTask += 1;
679   TH1F *fHistGlobalXLayer5 = new TH1F("fHistGlobalXLayer5",
680                                       "Global x - Layer 5;x [cm];Entries;",
681                                       100,-40.,40.);
682   fAliITSQADataMakerRec->Add2RecPointsList(fHistGlobalXLayer5, 
683                                            fGenOffset + 8);
684   fSSDhTask += 1;
685   TH1F *fHistGlobalXLayer6 = new TH1F("fHistGlobalXLayer6",
686                                       "Global x - Layer 6;x [cm];Entries;",
687                                       100,-45.,45.);
688   fAliITSQADataMakerRec->Add2RecPointsList(fHistGlobalXLayer6, 
689                                            fGenOffset + 9);
690   fSSDhTask += 1;
691   TH1F *fHistGlobalYLayer5 = new TH1F("fHistGlobalYLayer5",
692                                       "Global y - Layer 5;y [cm];Entries;",
693                                       100,-40.,40);
694   fAliITSQADataMakerRec->Add2RecPointsList(fHistGlobalYLayer5, 
695                                            fGenOffset + 10);
696   fSSDhTask += 1;
697   TH1F *fHistGlobalYLayer6 = new TH1F("fHistGlobalYLayer6",
698                                       "Global y - Layer 6;y [cm];Entries;",
699                                       100,-45.,45.);
700   fAliITSQADataMakerRec->Add2RecPointsList(fHistGlobalYLayer6, 
701                                            fGenOffset + 11);
702   fSSDhTask += 1;
703   TH1F *fHistGlobalZLayer5 = new TH1F("fHistGlobalZLayer5",
704                                       "Global z - Layer 5;z [cm];Entries;",
705                                       100,-45.,45);
706   fAliITSQADataMakerRec->Add2RecPointsList(fHistGlobalZLayer5, 
707                                            fGenOffset + 12);
708   fSSDhTask += 1;
709   TH1F *fHistGlobalZLayer6 = new TH1F("fHistGlobalZLayer6",
710                                       "Global z - Layer 6;z [cm];Entries;",
711                                       100,-55.,55.);
712   fAliITSQADataMakerRec->Add2RecPointsList(fHistGlobalZLayer6, 
713                                            fGenOffset + 13);
714   fSSDhTask += 1;
715   TH1F *fHistPhiLayer5 = new TH1F("fHistPhiLayer5",
716                                   "#phi - Layer 5;#phi [rad];Entries;",
717                                   100,-TMath::Pi(),TMath::Pi());
718   fAliITSQADataMakerRec->Add2RecPointsList(fHistPhiLayer5, 
719                                            fGenOffset + 14);
720   fSSDhTask += 1;
721   TH1F *fHistPhiLayer6 = new TH1F("fHistPhiLayer6",
722                                   "#phi - Layer 6;#phi [rad];Entries;",
723                                   100,-TMath::Pi(),TMath::Pi());
724   fAliITSQADataMakerRec->Add2RecPointsList(fHistPhiLayer6, 
725                                            fGenOffset + 15);
726   fSSDhTask += 1;
727   TH1F *fHistThetaLayer5 = new TH1F("fHistThetaLayer5",
728                                     "#theta - Layer 5;#theta [rad];Entries;",
729                                     100,-TMath::Pi(),TMath::Pi());
730   fAliITSQADataMakerRec->Add2RecPointsList(fHistThetaLayer5, 
731                                            fGenOffset + 16);
732   fSSDhTask += 1;
733   TH1F *fHistThetaLayer6 = new TH1F("fHistThetaLayer6",
734                                     "#theta - Layer 6;#theta [rad];Entries;",
735                                     100,-TMath::Pi(),TMath::Pi());
736   fAliITSQADataMakerRec->Add2RecPointsList(fHistThetaLayer6, 
737                                            fGenOffset + 17);
738   fSSDhTask += 1;
739   TH1F *fHistRadiusLayer5 = new TH1F("fHistRadiusLayer5",
740                                      "r - Layer 5;r [cm];Entries;",
741                                      100,35.,50.);
742   fAliITSQADataMakerRec->Add2RecPointsList(fHistRadiusLayer5, 
743                                            fGenOffset + 18);
744   fSSDhTask += 1;
745   TH1F *fHistRadiusLayer6 = new TH1F("fHistRadiusLayer6",
746                                      "r - Layer 6;r [cm];Entries;",
747                                      100,35.,50.);
748   fAliITSQADataMakerRec->Add2RecPointsList(fHistRadiusLayer6, 
749                                            fGenOffset + 19);
750   fSSDhTask += 1;
751   TH1F *fHistClusterTypeLayer5 = new TH1F("fHistClusterTypeLayer5",
752                                           "CL type - Layer 5;Cluster type;Entries;",
753                                           150,0,150);
754   fAliITSQADataMakerRec->Add2RecPointsList(fHistClusterTypeLayer5, 
755                                            fGenOffset + 20);
756   fSSDhTask += 1;
757   TH1F *fHistClusterTypeLayer6 = new TH1F("fHistClusterTypeLayer6",
758                                           "CL type - Layer 6;Cluster type;Entries;",
759                                           150,0,150);
760   fAliITSQADataMakerRec->Add2RecPointsList(fHistClusterTypeLayer6, 
761                                            fGenOffset + 21);
762   fSSDhTask += 1;
763   TH1F *fHistChargeRatioLayer5 = new TH1F("fHistChargeRatioLayer5",
764                                           "Charge ratio - Layer 5;q_{ratio};Entries;",
765                                           100,-2.0,2.0);
766   fAliITSQADataMakerRec->Add2RecPointsList(fHistChargeRatioLayer5, 
767                                            fGenOffset + 22);
768   fSSDhTask += 1;
769   TH1F *fHistChargeRatioLayer6 = new TH1F("fHistChargeRatioLayer6",
770                                           "Charge ratio - Layer 6;q_{ratio};Entries;",
771                                           100,-2.0,2.0);
772   fAliITSQADataMakerRec->Add2RecPointsList(fHistChargeRatioLayer6, 
773                                            fGenOffset + 23);
774   fSSDhTask += 1;
775   TH1F *fHistChargekeVLayer5 = new TH1F("fHistChargekeVLayer5",
776                                         "Charge - Layer 5;q [keV];Entries;",
777                                         100,0.,300.);
778   fAliITSQADataMakerRec->Add2RecPointsList(fHistChargekeVLayer5, 
779                                            fGenOffset + 24);
780   fSSDhTask += 1;
781   TH1F *fHistChargekeVLayer6 = new TH1F("fHistChargekeVLayer6",
782                                         "Charge - Layer 6;q [keV];Entries;",
783                                         100,0.,300.);
784   fAliITSQADataMakerRec->Add2RecPointsList(fHistChargekeVLayer6, 
785                                            fGenOffset + 25);
786   fSSDhTask += 1;
787   TH1F *fHistChargePSideLayer5 = new TH1F("fHistChargePSideLayer5",
788                                           "Charge P- Layer 5;q_{P} [keV];Entries;",
789                                           100,0.,300.);
790   fAliITSQADataMakerRec->Add2RecPointsList(fHistChargePSideLayer5,
791                                            fGenOffset + 26);
792   fSSDhTask += 1;
793   TH1F *fHistChargePSideLayer6 = new TH1F("fHistChargePSideLayer6",
794                                           "Charge P- Layer 6;q_{P} [keV];Entries;",
795                                           100,0.,300.);
796   fAliITSQADataMakerRec->Add2RecPointsList(fHistChargePSideLayer6,
797                                            fGenOffset + 27);
798   fSSDhTask += 1;
799   TH1F *fHistChargeNSideLayer5 = new TH1F("fHistChargeNSideLayer5",
800                                           "Charge N- Layer 5;q_{N} [keV];Entries;",
801                                           100,0.,300.);
802   fAliITSQADataMakerRec->Add2RecPointsList(fHistChargeNSideLayer5,
803                                            fGenOffset + 28);
804   fSSDhTask += 1;
805   TH1F *fHistChargeNSideLayer6 = new TH1F("fHistChargeNSideLayer6",
806                                           "Charge N- Layer 6;q_{N} [keV];Entries;",
807                                           100,0.,300.);
808   fAliITSQADataMakerRec->Add2RecPointsList(fHistChargeNSideLayer6,
809                                            fGenOffset + 29);
810   fSSDhTask += 1;
811   TH1F *fHistChargeRatio2Layer5 = new TH1F("fHistChargeRatio2Layer5",
812                                           "Charge Ratio qN/qP - Layer 5;q_{N}/q_{P};Entries;",
813                                           100,0,2);
814   fAliITSQADataMakerRec->Add2RecPointsList(fHistChargeRatio2Layer5,
815                                            fGenOffset + 30);
816   fSSDhTask += 1;
817   TH1F *fHistChargeRatio2Layer6 = new TH1F("fHistChargeRatio2Layer6",
818                                            "Charge Ratio qN/qP - Layer 6;q_{N}/q_{P};Entries;",
819                                            100,0,2);
820   fAliITSQADataMakerRec->Add2RecPointsList(fHistChargeRatio2Layer6,
821                                            fGenOffset + 31);
822   fSSDhTask += 1;
823   TH2F *fHistChargePNSideLayer5 = new TH2F("fHistChargePNSideLayer5",
824                                            "Charge correlation - Layer 5;q_{P} [keV];q_{N} [keV]",
825                                            100,0.,300.,
826                                            100,0.,300.);
827   fAliITSQADataMakerRec->Add2RecPointsList(fHistChargePNSideLayer5,
828                                            fGenOffset + 32);
829   fSSDhTask += 1;
830   TH2F *fHistChargePNSideLayer6 = new TH2F("fHistChargePNSideLayer6",
831                                            "Charge correlation - Layer 6;q_{P} [keV];q_{N} [keV]",
832                                            100,0.,300.,
833                                            100,0.,300.);
834   fAliITSQADataMakerRec->Add2RecPointsList(fHistChargePNSideLayer6,
835                                            fGenOffset + 33);
836   fSSDhTask += 1;
837   TH2F *fHistChargeMapLayer5 = new TH2F("fHistChargeMapLayer5",
838                                         "Charge map;N_{modules};N_{Ladders}",
839                                         fgkSSDMODULESPERLADDERLAYER5,
840                                         -0.5,fgkSSDMODULESPERLADDERLAYER5+0.5,
841                                         3*fgkSSDLADDERSLAYER5,
842                                         -0.5,fgkSSDLADDERSLAYER5+0.5);
843   fAliITSQADataMakerRec->Add2RecPointsList(fHistChargeMapLayer5, 
844                                            fGenOffset + 34);
845   fSSDhTask += 1;
846   TH2F *fHistChargeMapLayer6 = new TH2F("fHistChargeMapLayer6",
847                                         "Charge map;N_{modules};N_{Ladders}",
848                                         fgkSSDMODULESPERLADDERLAYER6,
849                                         -0.5,fgkSSDMODULESPERLADDERLAYER6+0.5,
850                                         3*fgkSSDLADDERSLAYER6,
851                                         -0.5,fgkSSDLADDERSLAYER6+0.5);
852   fAliITSQADataMakerRec->Add2RecPointsList(fHistChargeMapLayer6, 
853                                            fGenOffset + 35);
854   fSSDhTask += 1;
855
856   AliDebug(1,Form("%d SSD Recs histograms booked\n",fSSDhTask));
857 }
858
859 //____________________________________________________________________________ 
860 void AliITSQASSDDataMakerRec::MakeRecPoints(TTree *clustersTree)
861 {
862   // Fill QA for recpoints - SSD -
863
864   Int_t gLayer = 0, gLadder = 0, gModule = 0;
865   Int_t lLadderLocationY = 0;
866   TBranch *branchRecP = clustersTree->GetBranch("ITSRecPoints");
867   if (!branchRecP) { 
868     AliError("can't get the branch with the ITS clusters !");
869     return;
870   }
871   static TClonesArray statRecpoints("AliITSRecPoint");
872   TClonesArray *recpoints = &statRecpoints;
873   branchRecP->SetAddress(&recpoints);
874   Int_t nClustersLayer5 = 0, nClustersLayer6 = 0;
875   Int_t npoints = 0;      
876   Float_t cluglo[3]={0.,0.,0.}; 
877   for(Int_t module = 0; module < clustersTree->GetEntries(); module++){
878     branchRecP->GetEvent(module);
879     npoints += recpoints->GetEntries();
880     AliITSgeomTGeo::GetModuleId(module,gLayer,gLadder,gModule);
881     lLadderLocationY = 3*gLadder;
882
883     for(Int_t j = 0;j < recpoints->GetEntries(); j++){
884       AliITSRecPoint *recp = (AliITSRecPoint*)recpoints->At(j);    
885       Int_t layer = recp->GetLayer();
886       recp->GetGlobalXYZ(cluglo);
887       Float_t radius = TMath::Sqrt(cluglo[0]*cluglo[0]+cluglo[1]*cluglo[1]); 
888       Float_t phi = TMath::ATan2(cluglo[1],cluglo[0]);
889       Float_t theta = TMath::ATan2(radius,cluglo[2]);
890       Double_t chargeRatio = recp->GetChargeRatio();
891       Double_t clusterCharge = recp->GetQ();
892       Double_t chargePSide = clusterCharge*(1. + chargeRatio);
893       Double_t chargeNSide = clusterCharge*(1. - chargeRatio);
894       if(layer == 4) {
895         fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 0)->Fill(module);
896         fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 4)->Fill(recp->GetDetLocalX());
897         fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 6)->Fill(recp->GetDetLocalZ());
898         fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 8)->Fill(cluglo[0]);
899         fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 10)->Fill(cluglo[1]);
900         fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 12)->Fill(cluglo[2]);
901         fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 14)->Fill(phi);
902         fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 16)->Fill(theta);
903         fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 18)->Fill(radius);
904         fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 20)->Fill(recp->GetType());
905         fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 22)->Fill(recp->GetChargeRatio());
906         fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 24)->Fill(recp->GetQ());
907         fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 26)->Fill(chargePSide);
908         fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 28)->Fill(chargeNSide);
909         if(chargePSide != 0.) fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 30)->Fill(chargeNSide/chargePSide);
910         fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 32)->Fill(chargePSide,chargeNSide);
911         fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 34)->SetBinContent(gModule,lLadderLocationY,recp->GetQ());
912         nClustersLayer5 += 1;
913       }//layer 5 histograms
914       if(layer == 5) {
915         fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 1)->Fill(module);
916         fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 5)->Fill(recp->GetDetLocalX());
917         fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 7)->Fill(recp->GetDetLocalZ());
918         fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 9)->Fill(cluglo[0]);
919         fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 11)->Fill(cluglo[1]);
920         fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 13)->Fill(cluglo[2]);
921         fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 15)->Fill(phi);
922         fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 17)->Fill(theta);
923         fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 19)->Fill(radius);
924         fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 21)->Fill(recp->GetType());
925         fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 23)->Fill(recp->GetChargeRatio());
926         fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 25)->Fill(recp->GetQ());
927         fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 27)->Fill(chargePSide);
928         fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 29)->Fill(chargeNSide);
929         if(chargePSide != 0.) fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 31)->Fill(chargeNSide/chargePSide);
930         fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 33)->Fill(chargePSide,chargeNSide);
931         fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 35)->SetBinContent(gModule,lLadderLocationY,recp->GetQ());
932         nClustersLayer6 += 1;
933       }//layer 6 histograms
934     }//rec. points loop
935   }//module loop
936
937   fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 2)->Fill(nClustersLayer5);
938   fAliITSQADataMakerRec->GetRecPointsData(fGenOffset + 3)->Fill(nClustersLayer6);
939
940   statRecpoints.Clear();
941 }
942