Make and print an image of QA user flagged histograms (Yves)
[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 "AliQAv1.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 fSSDhRawsTask(0),
62 fSSDhRecPointsTask(0),
63 fGenRawsOffset(0),
64 fGenRecPointsOffset(0),
65 fCDBManager(0) {
66   // Default constructor   
67   //initilize the raw signal vs strip number histograms
68   if(fkOnline) {
69     fCDBManager = AliCDBManager::Instance();
70     //fCDBManager->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
71     fCDBManager->SetDefaultStorage(gSystem->Getenv("AMORE_CDB_URI"));
72     Int_t runNumber = atoi(gSystem->Getenv("DATE_RUN_NUMBER"));
73     if(!runNumber) 
74       AliInfo("DATE_RUN_NUMBER not defined!!!\n");
75     
76     fCDBManager->SetRun(runNumber);
77     AliCDBEntry *geomGRP = fCDBManager->Get("GRP/Geometry/Data");
78     if(!geomGRP) AliInfo("GRP geometry not found!!!\n");
79     
80     Int_t gLayer = 0,gLadder = 0, gModule = 0;
81     Int_t gHistCounter = 0;
82     TString gTitle; 
83
84     for(Int_t iModule = 500; iModule < fgkSSDMODULES + 500; iModule++) {
85       AliITSgeomTGeo::GetModuleId(iModule,gLayer,gLadder,gModule);
86       gTitle = "SSD_RawSignal_Layer"; gTitle += gLayer;
87       gTitle += "_Ladder"; gTitle += gLadder;
88       gTitle += "_Module"; gTitle += gModule;
89       fHistSSDRawSignalModule[gHistCounter] = new TH1D(gTitle.Data(),gTitle.Data(),
90                                                        2*fgkNumberOfPSideStrips,0,2*fgkNumberOfPSideStrips);
91       gHistCounter += 1;
92       
93       for(Int_t iStrip = 0; iStrip < 2*fgkNumberOfPSideStrips; iStrip++)
94         fOccupancyMatrix[iModule-500][iStrip] = 0; 
95     }//module loop
96   }//online flag
97   else {
98     for(Int_t iModule = 0; iModule < fgkSSDMODULES; iModule++) 
99       fHistSSDRawSignalModule[iModule]=NULL;
100     fCDBManager = NULL;
101   }
102 }
103
104 //____________________________________________________________________________ 
105 AliITSQASSDDataMakerRec::AliITSQASSDDataMakerRec(const AliITSQASSDDataMakerRec& qadm) :
106 TObject(),
107 fAliITSQADataMakerRec(qadm.fAliITSQADataMakerRec),
108 fSSDEvent(qadm.fSSDEvent),
109 fSSDEventPerCycle(qadm.fSSDEventPerCycle),
110 fkOnline(qadm.fkOnline),
111 fLDC(qadm.fLDC),
112 fSSDRawsOffset(qadm.fSSDRawsOffset), fSSDRawsDAOffset(qadm.fSSDRawsDAOffset),
113 fSSDRawsCommonLevelOffset(qadm.fSSDRawsCommonLevelOffset),
114 fSSDhRawsTask(qadm.fSSDhRawsTask),
115 fSSDhRecPointsTask(qadm.fSSDhRecPointsTask),
116 fGenRawsOffset(qadm.fGenRawsOffset),
117 fGenRecPointsOffset(qadm.fGenRecPointsOffset),
118 fCDBManager(qadm.fCDBManager) {
119   //copy ctor 
120   fAliITSQADataMakerRec->SetName((const char*)qadm.fAliITSQADataMakerRec->GetName()) ; 
121   fAliITSQADataMakerRec->SetTitle((const char*)qadm.fAliITSQADataMakerRec->GetTitle());
122 }
123
124 //__________________________________________________________________
125 AliITSQASSDDataMakerRec& AliITSQASSDDataMakerRec::operator = (const AliITSQASSDDataMakerRec& qac )
126 {
127   // Equal operator.
128   this->~AliITSQASSDDataMakerRec();
129   new(this) AliITSQASSDDataMakerRec(qac);
130   return *this;
131 }
132
133 //__________________________________________________________________
134 AliITSQASSDDataMakerRec::~AliITSQASSDDataMakerRec() {
135   // destructor
136   for(Int_t iModule = 0; iModule < fgkSSDMODULES; iModule++)
137     if(fHistSSDRawSignalModule[iModule]) delete fHistSSDRawSignalModule[iModule];
138   if(fCDBManager) delete fCDBManager;
139 }
140
141 //____________________________________________________________________________ 
142 void AliITSQASSDDataMakerRec::StartOfDetectorCycle()
143 {
144   if (  fAliITSQADataMakerRec->GetRawsData(0) == NULL ) // Raws not defined
145     return ; 
146
147   //Detector specific actions at start of cycle
148   AliDebug(1,"AliITSQADM::Start of SSD Cycle\n");    
149
150   //Data size per DDL
151   ((TH1D *)(fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+4)))->Reset();
152   //Data size per LDC
153   ((TH1D *)(fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+22)))->Reset();
154
155   //online part
156   if(fkOnline) {
157     for(Int_t iModule = 500; iModule < fgkSSDMODULES + 500; iModule++) {
158       for(Int_t iStrip = 0; iStrip < 2*fgkNumberOfPSideStrips; iStrip++)
159         fOccupancyMatrix[iModule-500][iStrip] = 0; 
160     }//module loop
161
162     Int_t gHistPositionOccupancyPerLadder = 0;
163     Int_t gLayer = 0, gLadder = 0, gModule = 0;
164     for(Int_t iModule = 0; iModule < fgkSSDMODULES; iModule++) {
165       AliITSgeomTGeo::GetModuleId(iModule+500,gLayer,gLadder,gModule);
166       
167       gHistPositionOccupancyPerLadder = (gLayer == 5) ? 2*(gLadder - 1) : 2*(gLadder - 1 + fgkSSDLADDERSLAYER5);
168       
169       //P-SIDE OCCUPANCY
170       fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsCommonLevelOffset+fgkSSDMODULES+gHistPositionOccupancyPerLadder)->Reset();
171       //N-SIDE OCCUPANCY
172       fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsCommonLevelOffset+fgkSSDMODULES+gHistPositionOccupancyPerLadder+1)->Reset();
173
174       ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsCommonLevelOffset+fgkSSDMODULES+2*fgkSSDLADDERSLAYER5+2*fgkSSDLADDERSLAYER6))->Reset();
175       ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsCommonLevelOffset+fgkSSDMODULES+2*fgkSSDLADDERSLAYER5+2*fgkSSDLADDERSLAYER6+1))->Reset();
176     }//module loop
177   }//online flag
178 }
179
180 //____________________________________________________________________________ 
181 void AliITSQASSDDataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t /*task*/, TObjArray* /*list*/)
182 {
183   // launch the QA checking
184   if (  fAliITSQADataMakerRec->GetRawsData(0) == NULL ) // Raws not defined
185     return ; 
186   // launch the QA checking
187   AliDebug(1,"AliITSDM instantiates checker with Run(AliQAv1::kITS, task, list)\n"); 
188   AliInfo(Form("Offset: %d\n",fGenRawsOffset));
189   //Data size per DDL
190   for(Int_t i = 0; i < fgkNumOfDDLs; i++) {
191     Double_t gSizePerDDL = TMath::Power(10,(fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+5+i))->GetMean())/1e+06;
192     //cout<<"DDL: "<<i+2<<" - Size: "<<gSizePerDDL<<" - Mean: "<<
193     //(fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+5+i))->GetMean()<<endl;
194     ((TH1D *)(fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+4)))->SetBinContent(i+2,gSizePerDDL);
195   }
196   
197   //Data size per LDC
198   for(Int_t i = 0; i < fgkNumOfLDCs; i++) {
199     Double_t gSizePerLDC = TMath::Power(10,(fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+23+i))->GetMean())/1e+06;
200     ((TH1D *)(fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+22)))->SetBinContent(i+6,gSizePerLDC);
201   }
202
203   //online part
204   if(fkOnline) {
205     //Output of the DA
206     MonitorOCDBObjects();
207
208     Int_t gHistPositionOccupancyPerModule = 0;
209     Int_t gLayer = 0, gLadder = 0, gModule = 0;
210     //occupancy per module
211     for(Int_t iModule = 0; iModule < fgkSSDMODULES; iModule++) {
212       AliITSgeomTGeo::GetModuleId(iModule+500,gLayer,gLadder,gModule);
213
214       gHistPositionOccupancyPerModule = (gLayer == 5) ? ((gLadder - 1)*fgkSSDMODULESPERLADDERLAYER5 + gModule - 1) : ((gLadder - 1)*fgkSSDMODULESPERLADDERLAYER6 + gModule + fgkSSDMODULESLAYER5 - 1);
215       for(Int_t iBins = 1; iBins < fHistSSDRawSignalModule[iModule]->GetXaxis()->GetNbins(); iBins++)
216         fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsCommonLevelOffset+gHistPositionOccupancyPerModule)->SetBinContent(iBins,fOccupancyMatrix[iModule][iBins-1]);
217       
218       if(fSSDEventPerCycle != 0)
219         ((TH1F *)(fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsCommonLevelOffset+gHistPositionOccupancyPerModule)))->Scale(100./fSSDEventPerCycle);
220     }//module loop
221
222     //occupancy per ladder
223     Int_t gHistPositionOccupancyPerLadder = 0;
224     Int_t lLadderLocationY = 0;
225     Double_t occupancy = 0.0, occupancyThreshold = 0.0, occupancyAverage = 0.0;
226     for(Int_t iModule = 0; iModule < fgkSSDMODULES; iModule++) {
227       AliITSgeomTGeo::GetModuleId(iModule+500,gLayer,gLadder,gModule);
228       
229       gHistPositionOccupancyPerModule = (gLayer == 5) ? ((gLadder - 1)*fgkSSDMODULESPERLADDERLAYER5 + gModule - 1) : ((gLadder - 1)*fgkSSDMODULESPERLADDERLAYER6 + gModule + fgkSSDMODULESLAYER5 - 1);
230       gHistPositionOccupancyPerLadder = (gLayer == 5) ? 2*(gLadder - 1) : 2*(gLadder - 1 + fgkSSDLADDERSLAYER5);
231       
232       //P-SIDE OCCUPANCY
233       occupancy = GetOccupancyModule((TH1 *)fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsCommonLevelOffset+gHistPositionOccupancyPerModule),0,0,0);
234       occupancyThreshold = GetOccupancyModule((TH1 *)fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsCommonLevelOffset+gHistPositionOccupancyPerModule),0,1,3);
235       occupancyAverage = GetOccupancyModule((TH1 *)fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsCommonLevelOffset+gHistPositionOccupancyPerModule),0,2,0);
236
237       fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsCommonLevelOffset+fgkSSDMODULES+gHistPositionOccupancyPerLadder)->Fill(gModule,occupancy);
238       lLadderLocationY = 3*gLadder; // sideP=1 sideN=0 
239       if(gLayer == 5) {
240         //occupancy per module - no threshold
241         ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsCommonLevelOffset+fgkSSDMODULES+2*fgkSSDLADDERSLAYER5+2*fgkSSDLADDERSLAYER6))->SetBinContent(gModule,lLadderLocationY,occupancy);
242         //occupancy per module - threshold @ 3%
243         ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsCommonLevelOffset+fgkSSDMODULES+2*fgkSSDLADDERSLAYER5+2*fgkSSDLADDERSLAYER6+2))->SetBinContent(gModule,lLadderLocationY,occupancyThreshold);
244         //average occupancy per module
245         ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsCommonLevelOffset+fgkSSDMODULES+2*fgkSSDLADDERSLAYER5+2*fgkSSDLADDERSLAYER6+4))->SetBinContent(gModule,lLadderLocationY,occupancyAverage);
246       }
247       else if(gLayer == 6) {
248         //occupancy per module - no threshold
249         ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsCommonLevelOffset+fgkSSDMODULES+2*fgkSSDLADDERSLAYER5+2*fgkSSDLADDERSLAYER6+1))->SetBinContent(gModule,lLadderLocationY,occupancy);
250         //occupancy per module - threshold @ 3%
251         ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsCommonLevelOffset+fgkSSDMODULES+2*fgkSSDLADDERSLAYER5+2*fgkSSDLADDERSLAYER6+3))->SetBinContent(gModule,lLadderLocationY,occupancyThreshold);
252         //average occupancy per module
253         ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsCommonLevelOffset+fgkSSDMODULES+2*fgkSSDLADDERSLAYER5+2*fgkSSDLADDERSLAYER6+5))->SetBinContent(gModule,lLadderLocationY,occupancyAverage);
254       }
255
256       //N-SIDE OCCUPANCY
257       occupancy = GetOccupancyModule((TH1 *)fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsCommonLevelOffset+gHistPositionOccupancyPerModule),1,0,0);   
258       occupancyThreshold = GetOccupancyModule((TH1 *)fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsCommonLevelOffset+gHistPositionOccupancyPerModule),1,1,3);   
259       occupancyAverage = GetOccupancyModule((TH1 *)fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsCommonLevelOffset+gHistPositionOccupancyPerModule),1,2,0);   
260
261       fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsCommonLevelOffset+fgkSSDMODULES+gHistPositionOccupancyPerLadder+1)->Fill(gModule,occupancy);
262       if(gLayer == 5) {
263         //occupancy per module - no threshold
264         ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsCommonLevelOffset+fgkSSDMODULES+2*fgkSSDLADDERSLAYER5+2*fgkSSDLADDERSLAYER6))->SetBinContent(gModule,lLadderLocationY-1,occupancy);
265         //occupancy per module - threshold @ 3%
266         ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsCommonLevelOffset+fgkSSDMODULES+2*fgkSSDLADDERSLAYER5+2*fgkSSDLADDERSLAYER6+2))->SetBinContent(gModule,lLadderLocationY-1,occupancyThreshold);
267         //average occupancy per module
268         ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsCommonLevelOffset+fgkSSDMODULES+2*fgkSSDLADDERSLAYER5+2*fgkSSDLADDERSLAYER6+4))->SetBinContent(gModule,lLadderLocationY-1,occupancyAverage);
269       }
270       else if(gLayer == 6) {
271         //occupancy per module - no threshold
272         ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsCommonLevelOffset+fgkSSDMODULES+2*fgkSSDLADDERSLAYER5+2*fgkSSDLADDERSLAYER6+1))->SetBinContent(gModule,lLadderLocationY-1,occupancy);
273         //occupancy per module - threshold @ 3%
274         ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsCommonLevelOffset+fgkSSDMODULES+2*fgkSSDLADDERSLAYER5+2*fgkSSDLADDERSLAYER6+3))->SetBinContent(gModule,lLadderLocationY-1,occupancyThreshold);
275         //average occupancy per module
276         ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsCommonLevelOffset+fgkSSDMODULES+2*fgkSSDLADDERSLAYER5+2*fgkSSDLADDERSLAYER6+5))->SetBinContent(gModule,lLadderLocationY-1,occupancyAverage);
277       }
278     }//module loop
279   }//online flag for SSD
280
281   fSSDEventPerCycle = 0;
282   
283  // AliQAChecker::Instance()->Run( AliQAv1::kITS , task, list);
284 }
285
286 //____________________________________________________________________________ 
287 void AliITSQASSDDataMakerRec::InitRaws() {  
288   // Initialization for RAW data - SSD -
289   const Bool_t expert   = kTRUE ; 
290   const Bool_t saveCorr = kTRUE ; 
291   const Bool_t image    = kTRUE ; 
292
293   fGenRawsOffset = (fAliITSQADataMakerRec->fRawsQAList[AliRecoParam::kDefault])->GetEntries();
294
295   if(fkOnline) {
296     AliInfo("Book Online Histograms for SSD\n");
297   }
298   else {
299     AliInfo("Book Offline Histograms for SSD\n ");
300   }
301   AliInfo(Form("Number of histograms (SPD+SDD): %d\n",fGenRawsOffset));
302   TString gTitle = 0;
303   //book online-offline QA histos
304   TH1D *fHistSSDEventType = new TH1D("SSD/DataSize/fHistSSDEventType",
305                                      ";Event type;Events",
306                                      31,-1,30);
307   fAliITSQADataMakerRec->Add2RawsList(fHistSSDEventType, 
308                                       fGenRawsOffset+fSSDRawsOffset, expert, !image, !saveCorr);
309   fSSDRawsOffset += 1;
310   TH1D *fHistSSDDataSize = new TH1D("SSD/DataSize/fHistSSDDataSize",
311                                     ";log(SSD data size) [Bytes];Events",
312                                     100,3,8);
313   fAliITSQADataMakerRec->Add2RawsList(fHistSSDDataSize, 
314                                       fGenRawsOffset+fSSDRawsOffset, expert, !image, !saveCorr);
315   fSSDRawsOffset += 1;
316   TH1D *fHistSSDDataSizePercentage = new TH1D("SSD/DataSize/fHistSSDDataSizePercentage",
317                                               ";SSD data size [%];Events",
318                                               100,0,100);
319   fAliITSQADataMakerRec->Add2RawsList(fHistSSDDataSizePercentage, 
320                                       fGenRawsOffset+fSSDRawsOffset, expert, !image, !saveCorr);
321   fSSDRawsOffset += 1;
322   TH1D *fHistSSDDDLId = new TH1D("SSD/DDL/fHistSSDDDLId",
323                                  ";DDL id;Events",20,510.5,530.5);
324   fAliITSQADataMakerRec->Add2RawsList(fHistSSDDDLId, 
325                                       fGenRawsOffset+fSSDRawsOffset, expert, !image, !saveCorr);
326   fSSDRawsOffset += 1;
327   TH1D *fHistSSDDataSizePerDDL = new TH1D("SSD/DataSize/fHistSSDDataSizePerDDL",
328                                           ";DDL id;<SSD data size> [MB]",
329                                           20,510.5,530.5);
330   fAliITSQADataMakerRec->Add2RawsList(fHistSSDDataSizePerDDL, 
331                                       fGenRawsOffset+fSSDRawsOffset, !expert, image, !saveCorr);
332   fSSDRawsOffset += 1;
333   TH1D *fHistSSDDataSizeDDL[fgkNumOfDDLs];
334   for(Int_t i = 1; i < fgkNumOfDDLs+1; i++) {
335     gTitle = "SSD/DDL/fHistSSDDataSizeDDL"; gTitle += i+511;
336     fHistSSDDataSizeDDL[i-1] = new TH1D(gTitle.Data(),
337                                         ";log(SSD data size) [Bytes];Events",
338                                         100,1,8);
339     fAliITSQADataMakerRec->Add2RawsList(fHistSSDDataSizeDDL[i-1], 
340                                         fGenRawsOffset+fSSDRawsOffset, expert, !image, !saveCorr);
341     fSSDRawsOffset += 1;
342   }
343   
344   TH1D *fHistSSDLDCId = new TH1D("SSD/LDC/fHistSSDLDCId",";LDC id;Events",10,0.5,10.5);
345   fAliITSQADataMakerRec->Add2RawsList(fHistSSDLDCId, 
346                                       fGenRawsOffset+fSSDRawsOffset, expert, !image, !saveCorr);
347   fSSDRawsOffset += 1;
348   TH1D *fHistSSDDataSizePerLDC = new TH1D("SSD/DataSize/fHistSSDDataSizePerLDC",
349                                           ";LDC id;<SSD data size> [MB]",
350                                           20,0.5,20.5);
351   fAliITSQADataMakerRec->Add2RawsList(fHistSSDDataSizePerLDC, 
352                                       fGenRawsOffset+fSSDRawsOffset, !expert, image, !saveCorr);
353   fSSDRawsOffset += 1;
354   TH1D *fHistSSDDataSizeLDC[fgkNumOfLDCs];
355   for(Int_t i = 1; i < fgkNumOfLDCs+1; i++) {
356     gTitle = "SSD/LDC/fHistSSDDataSizeLDC"; 
357     if(i == 1) gTitle += "082";
358     if(i == 2) gTitle += "086";
359     if(i == 3) gTitle += "085";
360     fHistSSDDataSizeLDC[i-1] = new TH1D(gTitle.Data(),
361                                         ";log(SSD data size) [Bytes];Events",
362                                         100,1,8);
363     fAliITSQADataMakerRec->Add2RawsList(fHistSSDDataSizeLDC[i-1], 
364                                         fGenRawsOffset+fSSDRawsOffset, expert, !image, !saveCorr);
365     fSSDRawsOffset += 1;
366   }
367   fSSDRawsCommonLevelOffset = fSSDRawsOffset;
368
369   if(fkOnline) {
370     Int_t gLayer = 0, gLadder = 0, gModule = 0;
371     //occupancy per SSD module
372     TH1D *fHistSSDOccupancyModule[fgkSSDMODULES]; 
373     for(Int_t i = 500; i < fgkSSDMODULES + 500; i++) {
374       AliITSgeomTGeo::GetModuleId(i,gLayer,gLadder,gModule);
375       gTitle = "SSD/Occupancy/Layer"; gTitle += gLayer;
376       gTitle += "/Ladder"; 
377       if(gLayer == 5) {
378         gTitle +=  499+gLadder;
379         gTitle += "/fHistSSD_Occupancy_Layer"; gTitle += gLayer;
380         gTitle += "_Ladder"; 
381         gTitle += 499+gLadder;
382       }
383       if(gLayer == 6) {
384         gTitle += 599+gLadder;
385         gTitle += "/fHistSSD_Occupancy_Layer"; gTitle += gLayer;
386         gTitle += "_Ladder"; 
387         gTitle += 599+gLadder;
388       }
389       gTitle += "_Module"; gTitle += gModule; 
390       fHistSSDOccupancyModule[i-500] = new TH1D(gTitle.Data(),gTitle.Data(),
391                                                 2*fgkNumberOfPSideStrips,0,2*fgkNumberOfPSideStrips);
392       fHistSSDOccupancyModule[i-500]->GetXaxis()->SetTitleColor(1);
393       fHistSSDOccupancyModule[i-500]->GetXaxis()->SetTitle("N_{strip}");
394       fHistSSDOccupancyModule[i-500]->GetYaxis()->SetTitle("Occupancy [%]");
395       fAliITSQADataMakerRec->Add2RawsList(fHistSSDOccupancyModule[i-500], 
396                                           fGenRawsOffset+fSSDRawsOffset, expert, !image, !saveCorr);
397       fSSDRawsOffset += 1;
398     }
399
400     //Occupancy per SSD ladder
401     Int_t occupancyCounter = 0;
402     TH1D *fHistSSDOccupancyLadder[2*(fgkSSDLADDERSLAYER5 + fgkSSDLADDERSLAYER6)];
403     for(Int_t iLayer = 5; iLayer < 7; iLayer++) {
404       for(Int_t iLadder = 1; iLadder < AliITSgeomTGeo::GetNLadders(iLayer) + 1; iLadder++) {
405         //P-side occupancy plots
406         gTitle = "SSD/Occupancy/Layer"; gTitle += iLayer;
407         gTitle += "/Ladder";
408         if(iLayer == 5) {
409           gTitle += 499+iLadder;
410           gTitle += "/fHistSSD_Occupancy_Layer"; gTitle += iLayer;
411           gTitle += "_Ladder"; 
412           gTitle += 499+iLadder;
413         }
414         if(iLayer == 6) {
415           gTitle += 599+iLadder;
416           gTitle += "/fHistSSD_Occupancy_Layer"; gTitle += iLayer;
417           gTitle += "_Ladder"; 
418           gTitle += 599+iLadder;
419         }
420         gTitle += "_PSide";
421         fHistSSDOccupancyLadder[occupancyCounter] = new TH1D(gTitle.Data(),
422                                                              gTitle.Data(),
423                                                              AliITSgeomTGeo::GetNDetectors(iLayer),
424                                                              0.5,AliITSgeomTGeo::GetNDetectors(iLayer)+0.5);
425         fHistSSDOccupancyLadder[occupancyCounter]->GetXaxis()->SetTitleColor(1);
426         fHistSSDOccupancyLadder[occupancyCounter]->GetXaxis()->SetTitle("Module number");
427         fHistSSDOccupancyLadder[occupancyCounter]->GetYaxis()->SetTitle("Occupancy [%]");
428         fAliITSQADataMakerRec->Add2RawsList(fHistSSDOccupancyLadder[occupancyCounter], 
429                                             fGenRawsOffset+fSSDRawsOffset, expert, !image, !saveCorr);
430         occupancyCounter += 1; fSSDRawsOffset += 1;
431         //N-side occupancy plots
432         gTitle = "SSD/Occupancy/Layer"; gTitle += iLayer;
433         gTitle += "/Ladder";
434         if(iLayer == 5) {
435           gTitle += 499+iLadder;
436           gTitle += "/fHistSSD_Occupancy_Layer"; gTitle += iLayer;
437           gTitle += "_Ladder"; 
438           gTitle += 499+iLadder;
439         }
440         if(iLayer == 6) {
441           gTitle += 599+iLadder;
442           gTitle += "/fHistSSD_Occupancy_Layer"; gTitle += iLayer;
443           gTitle += "_Ladder"; 
444           gTitle += 599+iLadder;
445         }
446         gTitle += "_NSide";
447         fHistSSDOccupancyLadder[occupancyCounter] = new TH1D(gTitle.Data(),
448                                                              gTitle.Data(),
449                                                              AliITSgeomTGeo::GetNDetectors(iLayer),
450                                                              0.5,AliITSgeomTGeo::GetNDetectors(iLayer)+0.5);
451         fHistSSDOccupancyLadder[occupancyCounter]->GetXaxis()->SetTitleColor(1);
452         fHistSSDOccupancyLadder[occupancyCounter]->GetXaxis()->SetTitle("Module number");
453         fHistSSDOccupancyLadder[occupancyCounter]->GetYaxis()->SetTitle("Occupancy [%]");
454         fAliITSQADataMakerRec->Add2RawsList(fHistSSDOccupancyLadder[occupancyCounter], 
455                                             fGenRawsOffset+fSSDRawsOffset, expert, !image, !saveCorr);
456         occupancyCounter += 1; fSSDRawsOffset += 1;
457       }//ladder loop
458     }//layer loop
459
460     //top level occupancy plots
461     //occupancy per module - no threshold
462     TH2D *fHistSSDOccupancyLayer5 = new TH2D("SSD/Occupancy/Layer5/fHistSSDOccupancyLayer5",
463                                              ";N_{modules};N_{Ladders}",
464                                              fgkSSDMODULESPERLADDERLAYER5,
465                                              0,fgkSSDMODULESPERLADDERLAYER5,
466                                              3*fgkSSDLADDERSLAYER5,
467                                              5000,500+fgkSSDLADDERSLAYER5);  
468     fHistSSDOccupancyLayer5->SetTitle("Occupancy per module (Layer 5) - No threshold");
469     fHistSSDOccupancyLayer5->GetZaxis()->SetRangeUser(0.0,100.0);
470     Char_t fLabel[3];
471     for(Int_t iBin = 1; iBin < fgkSSDMODULESPERLADDERLAYER5 + 1; iBin++){
472       sprintf(fLabel,"%d",iBin);
473       fHistSSDOccupancyLayer5->GetXaxis()->SetBinLabel(iBin,fLabel);
474     }
475     fAliITSQADataMakerRec->Add2RawsList(fHistSSDOccupancyLayer5, 
476                                         fGenRawsOffset+fSSDRawsOffset, expert, !image, !saveCorr);
477     fSSDRawsOffset += 1;
478     TH2D *fHistSSDOccupancyLayer6 = new TH2D("SSD/Occupancy/Layer6/fHistSSDOccupancyLayer6",
479                                              ";N_{modules};N_{Ladders}",
480                                              fgkSSDMODULESPERLADDERLAYER6,
481                                              0,fgkSSDMODULESPERLADDERLAYER6,
482                                              3*fgkSSDLADDERSLAYER6,
483                                              600,600+fgkSSDLADDERSLAYER6);
484     fHistSSDOccupancyLayer6->SetTitle("Occupancy per module (Layer 6) - No threshold");
485     fHistSSDOccupancyLayer6->GetZaxis()->SetRangeUser(0.0,100.0);
486     for(Int_t iBin = 1; iBin < fgkSSDMODULESPERLADDERLAYER6 + 1; iBin++){
487       sprintf(fLabel,"%d",iBin);
488       fHistSSDOccupancyLayer6->GetXaxis()->SetBinLabel(iBin,fLabel);
489     }
490     fAliITSQADataMakerRec->Add2RawsList(fHistSSDOccupancyLayer6, 
491                                         fGenRawsOffset+fSSDRawsOffset, expert, !image, !saveCorr);
492     fSSDRawsOffset += 1;
493
494     //occupancy per module - threshold @ 3%
495     TH2D *fHistSSDOccupancyThresholdLayer5 = new TH2D("SSD/Occupancy/Layer5/fHistSSDOccupancyThresholdLayer5",
496                                              ";N_{modules};N_{Ladders}",
497                                              fgkSSDMODULESPERLADDERLAYER5,
498                                              0,fgkSSDMODULESPERLADDERLAYER5,
499                                              3*fgkSSDLADDERSLAYER5,
500                                              500,500+fgkSSDLADDERSLAYER5);  
501     fHistSSDOccupancyThresholdLayer5->SetTitle("Occupancy per module (Layer 5) - Threshold 3%");
502     fHistSSDOccupancyThresholdLayer5->GetZaxis()->SetRangeUser(3.0,10.0);
503     for(Int_t iBin = 1; iBin < fgkSSDMODULESPERLADDERLAYER5 + 1; iBin++){
504       sprintf(fLabel,"%d",iBin);
505       fHistSSDOccupancyThresholdLayer5->GetXaxis()->SetBinLabel(iBin,fLabel);
506      }
507      fAliITSQADataMakerRec->Add2RawsList(fHistSSDOccupancyThresholdLayer5, 
508                                          fGenRawsOffset+fSSDRawsOffset, expert, !image, !saveCorr);
509     fSSDRawsOffset += 1;
510     TH2D *fHistSSDOccupancyThresholdLayer6 = new TH2D("SSD/Occupancy/Layer6/fHistSSDOccupancyThresholdLayer6",
511                                              ";N_{modules};N_{Ladders}",
512                                              fgkSSDMODULESPERLADDERLAYER6,
513                                              0,fgkSSDMODULESPERLADDERLAYER6,
514                                              3*fgkSSDLADDERSLAYER6,
515                                              600,600+fgkSSDLADDERSLAYER6);
516     fHistSSDOccupancyThresholdLayer6->SetTitle("Occupancy per module (Layer 6) - Threshold 3%");
517     fHistSSDOccupancyThresholdLayer6->GetZaxis()->SetRangeUser(3.0,10.0);
518     for(Int_t iBin = 1; iBin < fgkSSDMODULESPERLADDERLAYER6 + 1; iBin++){
519       sprintf(fLabel,"%d",iBin);
520       fHistSSDOccupancyThresholdLayer6->GetXaxis()->SetBinLabel(iBin,fLabel);
521     }
522     fAliITSQADataMakerRec->Add2RawsList(fHistSSDOccupancyThresholdLayer6, 
523                                         fGenRawsOffset+fSSDRawsOffset, expert, !image, !saveCorr);
524     fSSDRawsOffset += 1;
525
526     //Average occupancy per module
527     TH2D *fHistSSDAverageOccupancyLayer5 = new TH2D("SSD/Occupancy/Layer5/fHistSSDAverageOccupancyLayer5",
528                                              ";N_{modules};N_{Ladders}",
529                                              fgkSSDMODULESPERLADDERLAYER5,
530                                              0,fgkSSDMODULESPERLADDERLAYER5,
531                                              3*fgkSSDLADDERSLAYER5,
532                                              500,500+fgkSSDLADDERSLAYER5);  
533     fHistSSDAverageOccupancyLayer5->SetTitle("Average occupancy per module (Layer 5)");
534     fHistSSDAverageOccupancyLayer5->GetZaxis()->SetRangeUser(0.0,5.0);
535     for(Int_t iBin = 1; iBin < fgkSSDMODULESPERLADDERLAYER5 + 1; iBin++){
536       sprintf(fLabel,"%d",iBin);
537       fHistSSDAverageOccupancyLayer5->GetXaxis()->SetBinLabel(iBin,fLabel);
538     }
539     fAliITSQADataMakerRec->Add2RawsList(fHistSSDAverageOccupancyLayer5, 
540                                         fGenRawsOffset+fSSDRawsOffset);
541     fSSDRawsOffset += 1;
542     TH2D *fHistSSDAverageOccupancyLayer6 = new TH2D("SSD/Occupancy/Layer6/fHistSSDAverageOccupancyLayer6",
543                                              ";N_{modules};N_{Ladders}",
544                                              fgkSSDMODULESPERLADDERLAYER6,
545                                              0,fgkSSDMODULESPERLADDERLAYER6,
546                                              3*fgkSSDLADDERSLAYER6,
547                                              600,600+fgkSSDLADDERSLAYER6);
548     fHistSSDAverageOccupancyLayer6->SetTitle("Average occupancy per module (Layer 6)");
549     fHistSSDAverageOccupancyLayer6->GetZaxis()->SetRangeUser(0.0,5.0);
550     for(Int_t iBin = 1; iBin < fgkSSDMODULESPERLADDERLAYER6 + 1; iBin++){
551       sprintf(fLabel,"%d",iBin);
552       fHistSSDAverageOccupancyLayer6->GetXaxis()->SetBinLabel(iBin,fLabel);
553     }
554     fAliITSQADataMakerRec->Add2RawsList(fHistSSDAverageOccupancyLayer6, 
555                                         fGenRawsOffset+fSSDRawsOffset, !expert, image, !saveCorr);
556     fSSDRawsOffset += 1;
557
558     //Output of the DA
559     TH2D *fHistPSideBadChannelMapLayer5 = new TH2D("SSD/BadChannels/fHistPSideBadChannelMapLayer5",
560                                                    "Layer 5;N_{module};N_{ladder}",
561                                                    22,1,23,
562                                                    34,500,534);
563     fHistPSideBadChannelMapLayer5->GetXaxis()->SetTitleColor(1);
564     fHistPSideBadChannelMapLayer5->SetStats(kFALSE);
565     fHistPSideBadChannelMapLayer5->GetYaxis()->SetTitleOffset(1.8);
566     fHistPSideBadChannelMapLayer5->GetXaxis()->SetNdivisions(22);
567     fHistPSideBadChannelMapLayer5->GetYaxis()->SetNdivisions(34);
568     fHistPSideBadChannelMapLayer5->GetXaxis()->SetLabelSize(0.03);
569     fHistPSideBadChannelMapLayer5->GetYaxis()->SetLabelSize(0.03);
570     fHistPSideBadChannelMapLayer5->GetZaxis()->SetTitleOffset(1.6);
571     fHistPSideBadChannelMapLayer5->GetZaxis()->SetTitle("Bad channels (p-side)[%]");
572     fAliITSQADataMakerRec->Add2RawsList(fHistPSideBadChannelMapLayer5, 
573                                         fGenRawsOffset+fSSDRawsOffset, expert, !image, !saveCorr);
574     fSSDRawsOffset += 1; fSSDRawsDAOffset += 1;
575
576     TH2D *fHistNSideBadChannelMapLayer5 = new TH2D("SSD/BadChannels/fHistNSideBadChannelMapLayer5",
577                                                    "Layer 5;N_{module};N_{ladder}",
578                                                    22,1,23,
579                                                    34,500,534);
580     fHistNSideBadChannelMapLayer5->GetXaxis()->SetTitleColor(1);
581     fHistNSideBadChannelMapLayer5->SetStats(kFALSE);
582     fHistNSideBadChannelMapLayer5->GetYaxis()->SetTitleOffset(1.8);
583     fHistNSideBadChannelMapLayer5->GetXaxis()->SetNdivisions(22);
584     fHistNSideBadChannelMapLayer5->GetYaxis()->SetNdivisions(34);
585     fHistNSideBadChannelMapLayer5->GetXaxis()->SetLabelSize(0.03);
586     fHistNSideBadChannelMapLayer5->GetYaxis()->SetLabelSize(0.03);
587     fHistNSideBadChannelMapLayer5->GetZaxis()->SetTitleOffset(1.6);
588     fHistNSideBadChannelMapLayer5->GetZaxis()->SetTitle("Bad channels (n-side)[%]");
589     fAliITSQADataMakerRec->Add2RawsList(fHistNSideBadChannelMapLayer5, 
590                                         fGenRawsOffset+fSSDRawsOffset, expert, !image, !saveCorr);
591     fSSDRawsOffset += 1; fSSDRawsDAOffset += 1;
592
593     TH2D *fHistPSideBadChannelMapLayer6 = new TH2D("SSD/BadChannels/fHistPSideBadChannelMapLayer6",
594                                                    "Layer 6;N_{module};N_{ladder}",
595                                                    25,1,26,
596                                                    38,600,638);
597     fHistPSideBadChannelMapLayer6->GetXaxis()->SetTitleColor(1);
598     fHistPSideBadChannelMapLayer6->SetStats(kFALSE);
599     fHistPSideBadChannelMapLayer6->GetYaxis()->SetTitleOffset(1.8);
600     fHistPSideBadChannelMapLayer6->GetXaxis()->SetNdivisions(25);
601     fHistPSideBadChannelMapLayer6->GetYaxis()->SetNdivisions(38);
602     fHistPSideBadChannelMapLayer6->GetXaxis()->SetLabelSize(0.03);
603     fHistPSideBadChannelMapLayer6->GetYaxis()->SetLabelSize(0.03);
604     fHistPSideBadChannelMapLayer6->GetZaxis()->SetTitleOffset(1.6);
605     fHistPSideBadChannelMapLayer6->GetZaxis()->SetTitle("Bad channels (p-side)[%]");
606     fAliITSQADataMakerRec->Add2RawsList(fHistPSideBadChannelMapLayer6, 
607                                         fGenRawsOffset+fSSDRawsOffset, expert, !image, !saveCorr);
608     fSSDRawsOffset += 1; fSSDRawsDAOffset += 1;
609
610     TH2D *fHistNSideBadChannelMapLayer6 = new TH2D("SSD/BadChannels/fHistNSideBadChannelMapLayer6",
611                                                    "Layer 6;N_{module};N_{ladder}",
612                                                    25,1,26,
613                                                    38,600,638);
614     fHistNSideBadChannelMapLayer6->GetXaxis()->SetTitleColor(1);
615     fHistNSideBadChannelMapLayer6->SetStats(kFALSE);
616     fHistNSideBadChannelMapLayer6->GetYaxis()->SetTitleOffset(1.8);
617     fHistNSideBadChannelMapLayer6->GetXaxis()->SetNdivisions(25);
618     fHistNSideBadChannelMapLayer6->GetYaxis()->SetNdivisions(38);
619     fHistNSideBadChannelMapLayer6->GetXaxis()->SetLabelSize(0.03);
620     fHistNSideBadChannelMapLayer6->GetYaxis()->SetLabelSize(0.03);
621     fHistNSideBadChannelMapLayer6->GetZaxis()->SetTitleOffset(1.6);
622     fHistNSideBadChannelMapLayer6->GetZaxis()->SetTitle("Bad channels (n-side)[%]");
623     fAliITSQADataMakerRec->Add2RawsList(fHistNSideBadChannelMapLayer6, 
624                                         fGenRawsOffset+fSSDRawsOffset, expert, !image, !saveCorr);
625     fSSDRawsOffset += 1; fSSDRawsDAOffset += 1;
626   }//online flag
627
628   fSSDhRawsTask = fSSDRawsOffset;
629   AliDebug(1,Form("%d SSD Raws histograms booked\n",fSSDhRawsTask));
630   AliInfo(Form("Number of histograms (SPD+SDD+SSD): %d\n",fGenRawsOffset+fSSDhRawsTask));  
631   AliDebug(1,Form("Number of histograms (SPD+SDD+SSD): %d\n",fGenRawsOffset+fSSDRawsOffset));
632   
633   /*
634   fSSDhTask = fSSDRawsOffset;
635   AliDebug(1,Form("%d SSD Raws histograms booked\n",fSSDhTask));
636   AliInfo(Form("Number of histograms (SPD+SDD+SSD): %d\n",fGenRawsOffset+fSSDhTask));  
637   AliDebug(1,Form("Number of histograms (SPD+SDD+SSD): %d\n",fGenRawsOffset+fSSDRawsOffset));
638   */
639 }
640
641 //____________________________________________________________________________
642 void AliITSQASSDDataMakerRec::MakeRaws(AliRawReader* rawReader) { 
643   // Fill QA for RAW - SSD -
644   Int_t gStripNumber;
645   Int_t gHistPosition;
646   Int_t gLayer = 0,gLadder = 0, gModule = 0;
647   
648   Double_t gSizePerDDL[fgkNumOfDDLs] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
649   Double_t gSizePerLDC[fgkNumOfLDCs] = {0.,0.,0.};
650   Double_t sumSSDDataSize = 0.0;
651   Double_t eventSize = -1.0;
652
653   if(fkOnline) {
654     //reset the signal vs strip number histograms
655     for(Int_t iModule = 0; iModule < fgkSSDMODULES; iModule++)
656       fHistSSDRawSignalModule[iModule]->Reset();
657   }//online flag
658
659   rawReader->Select("ITSSSD",-1,-1);  
660   rawReader->Reset(); //rawReader->NextEvent();   
661   (fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset))->Fill(rawReader->GetType());
662   if(rawReader->GetType() == 7) {
663     fSSDEvent += 1;
664     fSSDEventPerCycle += 1;
665   }
666
667   AliITSRawStreamSSD gSSDStream(rawReader);    
668   AliRawReaderRoot *rootReader = (AliRawReaderRoot *)rawReader;
669   if(rootReader) {
670     const AliRawEventHeaderBase *header = rootReader->GetEventHeader();
671     if(header)
672       eventSize = header->GetEventSize();
673   }
674   while (gSSDStream.Next()) {
675     if(gSSDStream.GetModuleID() < 0) continue;
676     /*cout<<"DDL: "<<rawReader->GetDDLID()<<
677       " - LDC: "<<rawReader->GetLDCId()<<
678       " - Size: "<<rawReader->GetDataSize()<<
679       " - Equipment size: "<<rawReader->GetEquipmentSize()<<endl;*/
680     gSizePerDDL[rawReader->GetDDLID()] = rawReader->GetDataSize();
681     gSizePerLDC[rawReader->GetLDCId()-6] = rawReader->GetDataSize();
682     AliITSgeomTGeo::GetModuleId(gSSDStream.GetModuleID(),gLayer,gLadder,gModule);
683     if(gSSDStream.GetStrip() < 0) continue;
684     gStripNumber = (gSSDStream.GetSideFlag() == 0) ? gSSDStream.GetStrip() : -gSSDStream.GetStrip() + 2*fgkNumberOfPSideStrips;
685     gHistPosition = (gLayer == 5) ? ((gLadder - 1)*fgkSSDMODULESPERLADDERLAYER5 + gModule - 1) : ((gLadder - 1)*fgkSSDMODULESPERLADDERLAYER6 + gModule + fgkSSDMODULESLAYER5 - 1);
686     //AliInfo(Form("ModulePosition: %d - Layer: %d - Ladder: %d - Module: %d\n",gHistPosition,gLayer,gLadder,gModule));
687     if(fkOnline)
688       fHistSSDRawSignalModule[gHistPosition]->Fill(gStripNumber,gSSDStream.GetSignal());
689     //fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+gHistPosition+fSSDRawsCommonLevelOffset)->Fill(gStripNumber,gSSDStream.GetSignal());
690   }//streamer loop   
691   
692   //event size calculation and filling info
693   for(Int_t i = 0; i < fgkNumOfDDLs; i++) {
694     sumSSDDataSize += gSizePerDDL[i];
695     if(gSizePerDDL[i] > 0) {
696       (fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+3))->Fill(i+512);
697       (fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+5+i))->Fill(TMath::Log10(gSizePerDDL[i]));
698     }
699     //(fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+4))->Fill(i+512,gSizePerDDL[i]/1e+06);
700   }
701   for(Int_t i = 0; i < fgkNumOfLDCs; i++) {
702     if(gSizePerLDC[i] > 0) {
703       (fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+21))->Fill(i+6);
704       //LDC 082
705       if(i == 0)
706         gSizePerLDC[i] = gSizePerDDL[8] + gSizePerDDL[9] + gSizePerDDL[10] +
707           gSizePerDDL[11] + gSizePerDDL[12] + gSizePerDDL[13];
708       //LDC 086
709       if(i == 1)
710         gSizePerLDC[i] = gSizePerDDL[3] + gSizePerDDL[4] + gSizePerDDL[5] +
711           gSizePerDDL[6] + gSizePerDDL[7];
712       //LDC 085
713       if(i == 2)
714         gSizePerLDC[i] = gSizePerDDL[0] + gSizePerDDL[1] + gSizePerDDL[2] +
715           gSizePerDDL[14] + gSizePerDDL[15];
716       (fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+23+i))->Fill(TMath::Log10(gSizePerLDC[i]));
717       //cout<<"Event: "<<fSSDEventPerCycle<<" - LDC: "<<i+6<<
718       //" - Data size: "<<gSizePerLDC[i]<<endl;
719     }
720     //(fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+22))->Fill(i+6,gSizePerLDC[i]/1e+06);
721   }
722   if(sumSSDDataSize) 
723     (fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+1))->Fill(TMath::Log10(sumSSDDataSize));
724   if(eventSize)
725     (fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+2))->Fill(100.*sumSSDDataSize/eventSize);
726
727   //Occupancy calculation
728   if(fkOnline) {
729     for(Int_t iModule = 0; iModule < fgkSSDMODULES; iModule++) {
730       GetOccupancyStrip(fHistSSDRawSignalModule[iModule],fOccupancyMatrix[iModule]);
731       //if(iModule == 156) {    
732         //cout<<"========================================"<<endl;
733         //AliITSgeomTGeo::GetModuleId(656,gLayer,gLadder,gModule);
734         /*for(Int_t iBin = 1; iBin < fHistSSDRawSignalModule[iModule]->GetXaxis()->GetNbins(); iBin++) {
735           if((iBin >= 750)&&(iBin <= 780))
736           cout<<"Event: "<<fSSDEventPerCycle<<" - Ladder: "<<gLadder+499<<
737           " - Module: "<<gModule<<" - Strip: "<<iBin<<
738           " - Signal: "<<fHistSSDRawSignalModule[iModule]->GetBinContent(iBin)<<endl;
739           }*///strip loop --> to be removed
740       //}//module cut --> to be removed
741     }//module loop
742   }//online flag for SSD
743 }
744
745 //____________________________________________________________________________ //
746 void AliITSQASSDDataMakerRec::GetOccupancyStrip(TH1 *lHisto, Int_t *occupancyMatrix) { 
747   //Increments the entries in the occupancy matrix based 
748   //on whether the signal for each strip is larger than the cutoff
749   //Currently the cutoff is at 0 which means that if ZS
750   //works, whatever comes from the FEROM is considered as "signal"
751   //Double_t cutoff = 0.0;
752   TString histname = lHisto->GetName();
753   //cout<<histname.Data()<<endl;
754   //if(histname.Contains("Layer5_Ladder8_Module3")) {
755   for(Int_t iBin = 1; iBin < lHisto->GetXaxis()->GetNbins(); iBin++) {
756     Double_t y = lHisto->GetBinContent(iBin);
757     if(y) {
758       occupancyMatrix[iBin-1] += 1;
759     }
760     //if((iBin >= 750)&&(iBin <= 780))
761     //cout<<"Strip: "<<iBin<<
762     //" - Signal: "<<y<<
763     //" - Occupancy: "<<occupancyMatrix[iBin-1]<<endl;
764     
765   }
766   //}
767 }
768
769 //____________________________________________________________________________ 
770 Double_t AliITSQASSDDataMakerRec::GetOccupancyModule(TH1 *lHisto, 
771                                                      Int_t stripside,
772                                                      Int_t mode,
773                                                      Double_t threshold) {
774   //Mode 0: calculates the occupancy of a module 
775   //        without a threshold in the strip occupancy
776   //Mode 1: calculates the occupancy of a module 
777   //        with the set threshold in the strip occupancy
778   //Mode 2: calculates the average occupancy of a module 
779
780   // bo: TDC >0 or # of sigmas wrt noise ?
781   //stripside == 0 --> P-side
782   //stripside == 1 --> N-side
783   Int_t lNumFiredBins = 0;
784   Double_t sumOccupancy = 0.0;
785   TString histname = lHisto->GetName();
786   for(Int_t iBin = 1 + stripside*fgkNumberOfPSideStrips; iBin < fgkNumberOfPSideStrips*(1 + stripside); iBin++){
787     /*if(histname.Contains("Layer5_Ladder507_Module3")) {
788       cout<<lHisto->GetName()<<
789       " - Strip: "<<iBin<<
790       " - Bin content: "<<lHisto->GetBinContent(iBin)<<endl;
791       }*/
792     if (lHisto->GetBinContent(iBin) > threshold) {
793       lNumFiredBins++; 
794       sumOccupancy = lHisto->GetBinContent(iBin);
795     }
796   }
797   
798   Double_t lOccupancy = 0.0;
799   if((mode == 0)||(mode == 1))
800     lOccupancy = (100.*lNumFiredBins)/fgkNumberOfPSideStrips; // percentage  
801   else if(mode == 2)
802     lOccupancy = 100.*sumOccupancy/fgkNumberOfPSideStrips;
803
804   /*if(histname.Contains("Layer5_Ladder507_Module3"))
805     cout<<"Fired strips: "<<lNumFiredBins<<
806     " - Occupancy: "<<lOccupancy<<endl;*/
807   //AliInfo(Form("Fired strips: %d - Total strips: %d - Occupancy :%lf\n",lNumFiredBins,lHisto->GetNbinsX(),lOccupancy));
808   
809   return lOccupancy;
810 }
811
812 //____________________________________________________________________________
813 void AliITSQASSDDataMakerRec::MonitorOCDBObjects() { 
814   //Monitor in AMORE the output of the DA
815   //Currently only the bad channel list is monitored
816   //Todo: Noise - Pedestal
817   ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsOffset-fSSDRawsDAOffset))->Reset();
818   ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsOffset-fSSDRawsDAOffset+1))->Reset();
819   ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsOffset-fSSDRawsDAOffset+2))->Reset();
820   ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsOffset-fSSDRawsDAOffset+3))->Reset();
821
822   AliCDBEntry *entryBadChannelsSSD = fCDBManager->Get("ITS/Calib/BadChannelsSSD");
823   if(!entryBadChannelsSSD) 
824     AliError("OCDB entry for the bad channel list is not valid!"); 
825   AliITSBadChannelsSSDv2 *badchannelsSSD = (AliITSBadChannelsSSDv2 *)entryBadChannelsSSD->GetObject();
826   if(!badchannelsSSD)
827     AliError("Bad channel list object is not a valid AliITSBadChannelsSSD object!");
828
829   //_____________________________________________________________________________//                       
830   Int_t nBadPSideChannels = 0, nBadNSideChannels = 0;
831   Int_t layer = 0, ladder = 0, module = 0;
832   Int_t nPSideChannelsLayer5 = 0, nNSideChannelsLayer5 = 0;
833   Int_t nPSideChannelsLayer6 = 0, nNSideChannelsLayer6 = 0;
834   //_____________________________________________________________________________//                      
835
836   for(Int_t i = 0; i < fgkSSDMODULES; i++) {
837     AliITSgeomTGeo::GetModuleId(i+500,layer,ladder,module);
838     nBadPSideChannels = 0, nBadNSideChannels = 0;
839     nPSideChannelsLayer5 = 0, nNSideChannelsLayer5 = 0;
840     nPSideChannelsLayer6 = 0, nNSideChannelsLayer6 = 0;
841
842     Int_t badChannel = 0;
843     for(Int_t j = 0; j < fgkNumberOfPSideStrips; j++) {
844       badChannel = (Int_t)(badchannelsSSD->GetBadChannelP(i,j));
845       if(badChannel != 0) {
846         if(layer == 5)
847           nPSideChannelsLayer5 += 1;
848         if(layer == 6)
849           nPSideChannelsLayer6 += 1;
850         nBadPSideChannels += 1;
851       }//badchannel flag != 0
852       badChannel = (Int_t)(badchannelsSSD->GetBadChannelN(i,j));
853       if(badChannel != 0) {
854         if(layer == 5)
855           nNSideChannelsLayer5 += 1;
856         if(layer == 6)
857           nNSideChannelsLayer6 += 1;
858         nBadNSideChannels += 1;
859       }//badchannel flag != 0
860     }//loop over strips
861     if(layer == 5) {
862       if(nPSideChannelsLayer5 > 0)
863         ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsOffset-fSSDRawsDAOffset))->Fill(module,499+ladder,
864                                                                             100.*nPSideChannelsLayer5/fgkNumberOfPSideStrips);
865       else ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsOffset-fSSDRawsDAOffset))->Fill(module,499+ladder,0.0001);
866       if(nNSideChannelsLayer5 > 0)
867         ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsOffset-fSSDRawsDAOffset+1))->Fill(module,499+ladder,
868                                                                             100.*nNSideChannelsLayer5/fgkNumberOfPSideStrips);
869       else ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsOffset-fSSDRawsDAOffset+1))->Fill(module,499+ladder,0.0001);
870     }//layer 5                                                                                                                      
871     if(layer == 6) {
872       if(nPSideChannelsLayer6 > 0)
873         ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsOffset-fSSDRawsDAOffset+2))->Fill(module,599+ladder,
874                                                                             100.*nPSideChannelsLayer6/fgkNumberOfPSideStrips);
875       else ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsOffset-fSSDRawsDAOffset+2))->Fill(module,599+ladder,0.0001);
876       if(nNSideChannelsLayer6 > 0)
877         ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsOffset-fSSDRawsDAOffset+3))->Fill(module,599+ladder,
878                                                                             100.*nNSideChannelsLayer6/fgkNumberOfPSideStrips);
879       else ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fGenRawsOffset+fSSDRawsOffset-fSSDRawsDAOffset+3))->Fill(module,599+ladder,0.0001);
880     }//layer 6                                                                                                                      
881   }//module loop
882 }
883
884 //____________________________________________________________________________ 
885 void AliITSQASSDDataMakerRec::InitRecPoints()
886 {
887   // Initialization for RECPOINTS - SSD -
888   const Bool_t expert   = kTRUE ; 
889   const Bool_t image    = kTRUE ; 
890   
891   fGenRecPointsOffset = (fAliITSQADataMakerRec->fRecPointsQAList[AliRecoParam::kDefault])->GetEntries();
892   //AliInfo(Form("**-------*-*-*-*-*-*-***************AliITSQASSDataMakerRec::MakeRecpoints offset %d \t %d \n",fGenOffset,fGenRecPointsOffset));
893   Int_t nModuleOffset = 500;
894   Int_t nITSTotalModules = AliITSgeomTGeo::GetNModules();
895
896   TH1F *fHistSSDModuleIdLayer5 = new TH1F("SSD/Statistics/fHistSSDModuleIdLayer5",
897                                        "Module Id - Layer 5;Module Id;Entries",
898                                        fgkSSDMODULESLAYER5,
899                                        nModuleOffset - 0.5,
900                                        nITSTotalModules-fgkSSDMODULESLAYER6+0.5);
901   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDModuleIdLayer5, 
902                                            fGenRecPointsOffset + 0, expert, !image);
903   fSSDhRecPointsTask += 1;
904   TH1F *fHistSSDModuleIdLayer6 = new TH1F("SSD/Statistics/fHistSSDModuleIdLayer6",
905                                        "Module Id - Layer 6;Module Id;Entries",
906                                        fgkSSDMODULESLAYER6,
907                                        nModuleOffset+fgkSSDMODULESLAYER5 - 0.5,
908                                        nITSTotalModules + 0.5);
909   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDModuleIdLayer6, 
910                                            fGenRecPointsOffset + 1, expert, !image);
911   fSSDhRecPointsTask += 1;
912   TH1F *fHistSSDClusterPerEventLayer5 = new TH1F("SSD/Statistics/fHistSSDClusterPerEventLayer5",
913                                               "N_{clusters} - Layer 5;N_{clusters};Entries;",
914                                               100,0.1,5000);
915   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDClusterPerEventLayer5,
916                                            fGenRecPointsOffset + 2, expert, !image);
917   fSSDhRecPointsTask += 1;
918   TH1F *fHistSSDClusterPerEventLayer6 = new TH1F("SSD/Statistics/fHistSSDClusterPerEventLayer6",
919                                               "N_{clusters} - Layer 6;N_{clusters};Entries;",
920                                               100,0.1,5000);
921   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDClusterPerEventLayer6,
922                                            fGenRecPointsOffset + 3, expert, !image);
923   fSSDhRecPointsTask += 1;
924   TH1F *fHistSSDLocalXLayer5 = new TH1F("SSD/Coordinates/fHistSSDLocalXLayer5",
925                                      "Local x coord.- Layer 5;x [cm];Entries;",
926                                      100,-4.,4.);
927   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDLocalXLayer5,
928                                            fGenRecPointsOffset + 4, expert, !image);
929   fSSDhRecPointsTask += 1;
930   TH1F *fHistSSDLocalXLayer6 = new TH1F("SSD/Coordinates/fHistSSDLocalXLayer6",
931                                      "Local x coord.- Layer 6;x [cm];Entries;",
932                                      100,-4.,4.);
933   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDLocalXLayer6, 
934                                            fGenRecPointsOffset + 5, expert, !image);
935   fSSDhRecPointsTask += 1;
936   TH1F *fHistSSDLocalZLayer5 = new TH1F("SSD/Coordinates/fHistSSDLocalZLayer5",
937                                      "Local z coord.- Layer 5;z [cm];Entries;",
938                                      100,-4.,4.);
939   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDLocalZLayer5, 
940                                            fGenRecPointsOffset + 6, expert, !image);
941   fSSDhRecPointsTask += 1;
942   TH1F *fHistSSDLocalZLayer6 = new TH1F("SSD/Coordinates/fHistSSDLocalZLayer6",
943                                      "Local z coord.- Layer 6;z [cm];Entries;",
944                                      100,-4.,4.);
945   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDLocalZLayer6, 
946                                            fGenRecPointsOffset + 7, expert, !image);
947   fSSDhRecPointsTask += 1;
948   TH1F *fHistSSDGlobalXLayer5 = new TH1F("SSD/Coordinates/fHistSSDGlobalXLayer5",
949                                       "Global x - Layer 5;x [cm];Entries;",
950                                       100,-40.,40.);
951   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDGlobalXLayer5, 
952                                            fGenRecPointsOffset + 8, expert, !image);
953   fSSDhRecPointsTask += 1;
954   TH1F *fHistSSDGlobalXLayer6 = new TH1F("SSD/Coordinates/fHistSSDGlobalXLayer6",
955                                       "Global x - Layer 6;x [cm];Entries;",
956                                       100,-45.,45.);
957   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDGlobalXLayer6, 
958                                            fGenRecPointsOffset + 9, expert, !image);
959   fSSDhRecPointsTask += 1;
960   TH1F *fHistSSDGlobalYLayer5 = new TH1F("SSD/Coordinates/fHistSSDGlobalYLayer5",
961                                       "Global y - Layer 5;y [cm];Entries;",
962                                       100,-40.,40);
963   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDGlobalYLayer5, 
964                                            fGenRecPointsOffset + 10, expert, !image);
965   fSSDhRecPointsTask += 1;
966   TH1F *fHistSSDGlobalYLayer6 = new TH1F("SSD/Coordinates/fHistSSDGlobalYLayer6",
967                                       "Global y - Layer 6;y [cm];Entries;",
968                                       100,-45.,45.);
969   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDGlobalYLayer6, 
970                                            fGenRecPointsOffset + 11, expert, !image);
971   fSSDhRecPointsTask += 1;
972   TH1F *fHistSSDGlobalZLayer5 = new TH1F("SSD/Coordinates/fHistSSDGlobalZLayer5",
973                                       "Global z - Layer 5;z [cm];Entries;",
974                                       100,-45.,45);
975   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDGlobalZLayer5, 
976                                            fGenRecPointsOffset + 12, expert, !image);
977   fSSDhRecPointsTask += 1;
978   TH1F *fHistSSDGlobalZLayer6 = new TH1F("SSD/Coordinates/fHistSSDGlobalZLayer6",
979                                       "Global z - Layer 6;z [cm];Entries;",
980                                       100,-55.,55.);
981   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDGlobalZLayer6, 
982                                            fGenRecPointsOffset + 13, expert, !image);
983   fSSDhRecPointsTask += 1;
984   TH1F *fHistSSDPhiLayer5 = new TH1F("SSD/Coordinates/fHistSSDPhiLayer5",
985                                   "#phi - Layer 5;#phi [rad];Entries;",
986                                   100,-TMath::Pi(),TMath::Pi());
987   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDPhiLayer5, 
988                                            fGenRecPointsOffset + 14, expert, !image);
989   fSSDhRecPointsTask += 1;
990   TH1F *fHistSSDPhiLayer6 = new TH1F("SSD/Coordinates/fHistSSDPhiLayer6",
991                                   "#phi - Layer 6;#phi [rad];Entries;",
992                                   100,-TMath::Pi(),TMath::Pi());
993   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDPhiLayer6, 
994                                            fGenRecPointsOffset + 15, expert, !image);
995   fSSDhRecPointsTask += 1;
996   TH1F *fHistSSDThetaLayer5 = new TH1F("SSD/Coordinates/fHistSSDThetaLayer5",
997                                     "#theta - Layer 5;#theta [rad];Entries;",
998                                     100,-TMath::Pi(),TMath::Pi());
999   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDThetaLayer5, 
1000                                            fGenRecPointsOffset + 16, expert, !image);
1001   fSSDhRecPointsTask += 1;
1002   TH1F *fHistSSDThetaLayer6 = new TH1F("SSD/Coordinates/fHistSSDThetaLayer6",
1003                                     "#theta - Layer 6;#theta [rad];Entries;",
1004                                     100,-TMath::Pi(),TMath::Pi());
1005   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDThetaLayer6, 
1006                                            fGenRecPointsOffset + 17, expert, !image);
1007   fSSDhRecPointsTask += 1;
1008   TH1F *fHistSSDRadiusLayer5 = new TH1F("SSD/Coordinates/fHistSSDRadiusLayer5",
1009                                      "r - Layer 5;r [cm];Entries;",
1010                                      100,35.,50.);
1011   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDRadiusLayer5, 
1012                                            fGenRecPointsOffset + 18, expert, !image);
1013   fSSDhRecPointsTask += 1;
1014   TH1F *fHistSSDRadiusLayer6 = new TH1F("SSD/Coordinates/fHistSSDRadiusLayer6",
1015                                      "r - Layer 6;r [cm];Entries;",
1016                                      100,35.,50.);
1017   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDRadiusLayer6, 
1018                                            fGenRecPointsOffset + 19, expert, !image);
1019   fSSDhRecPointsTask += 1;
1020   TH1F *fHistSSDClusterTypeLayer5 = new TH1F("SSD/ClusterCharge/Layer5/fHistSSDClusterTypeLayer5",
1021                                           "CL type - Layer 5;Cluster type;Entries;",
1022                                           150,0,150);
1023   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDClusterTypeLayer5, 
1024                                            fGenRecPointsOffset + 20, expert, !image);
1025   fSSDhRecPointsTask += 1;
1026   TH1F *fHistSSDClusterTypeLayer6 = new TH1F("SSD/ClusterCharge/Layer6/fHistSSDClusterTypeLayer6",
1027                                           "CL type - Layer 6;Cluster type;Entries;",
1028                                           150,0,150);
1029   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDClusterTypeLayer6, 
1030                                            fGenRecPointsOffset + 21, expert, !image);
1031   fSSDhRecPointsTask += 1;
1032   TH1F *fHistSSDChargeRatioLayer5 = new TH1F("SSD/ClusterCharge/Layer5/fHistSSDChargeRatioLayer5",
1033                                           "Charge ratio - Layer 5;q_{ratio};Entries;",
1034                                           100,-2.0,2.0);
1035   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDChargeRatioLayer5, 
1036                                            fGenRecPointsOffset + 22, expert, !image);
1037   fSSDhRecPointsTask += 1;
1038   TH1F *fHistSSDChargeRatioLayer6 = new TH1F("SSD/ClusterCharge/Layer6/fHistSSDChargeRatioLayer6",
1039                                           "Charge ratio - Layer 6;q_{ratio};Entries;",
1040                                           100,-2.0,2.0);
1041   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDChargeRatioLayer6, 
1042                                            fGenRecPointsOffset + 23, expert, !image);
1043   fSSDhRecPointsTask += 1;
1044   TH1F *fHistSSDChargekeVLayer5 = new TH1F("SSD/ClusterCharge/Layer5/fHistSSDChargekeVLayer5",
1045                                         "Charge - Layer 5;q [keV];Entries;",
1046                                         100,0.,300.);
1047   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDChargekeVLayer5, 
1048                                            fGenRecPointsOffset + 24, !expert, image);
1049   fSSDhRecPointsTask += 1;
1050   TH1F *fHistSSDChargekeVLayer6 = new TH1F("SSD/ClusterCharge/Layer6/fHistSSDChargekeVLayer6",
1051                                         "Charge - Layer 6;q [keV];Entries;",
1052                                         100,0.,300.);
1053   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDChargekeVLayer6, 
1054                                            fGenRecPointsOffset + 25, !expert, image);
1055   fSSDhRecPointsTask += 1;
1056   TH1F *fHistSSDChargePSideLayer5 = new TH1F("SSD/ClusterCharge/Layer5/fHistSSDChargePSideLayer5",
1057                                           "Charge P- Layer 5;q_{P} [keV];Entries;",
1058                                           100,0.,300.);
1059   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDChargePSideLayer5,
1060                                            fGenRecPointsOffset + 26, expert, !image);
1061   fSSDhRecPointsTask += 1;
1062   TH1F *fHistSSDChargePSideLayer6 = new TH1F("SSD/ClusterCharge/Layer6/fHistSSDChargePSideLayer6",
1063                                           "Charge P- Layer 6;q_{P} [keV];Entries;",
1064                                           100,0.,300.);
1065   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDChargePSideLayer6,
1066                                            fGenRecPointsOffset + 27, expert, !image);
1067   fSSDhRecPointsTask += 1;
1068   TH1F *fHistSSDChargeNSideLayer5 = new TH1F("SSD/ClusterCharge/Layer5/fHistSSDChargeNSideLayer5",
1069                                           "Charge N- Layer 5;q_{N} [keV];Entries;",
1070                                           100,0.,300.);
1071   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDChargeNSideLayer5,
1072                                            fGenRecPointsOffset + 28, expert, !image);
1073   fSSDhRecPointsTask += 1;
1074   TH1F *fHistSSDChargeNSideLayer6 = new TH1F("SSD/ClusterCharge/Layer6/fHistSSDChargeNSideLayer6",
1075                                           "Charge N- Layer 6;q_{N} [keV];Entries;",
1076                                           100,0.,300.);
1077   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDChargeNSideLayer6,
1078                                            fGenRecPointsOffset + 29, expert, !image);
1079   fSSDhRecPointsTask += 1;
1080   TH1F *fHistSSDChargeRatio2Layer5 = new TH1F("SSD/ClusterCharge/Layer5/fHistSSDChargeRatio2Layer5",
1081                                           "Charge Ratio qN/qP - Layer 5;q_{N}/q_{P};Entries;",
1082                                           100,0,2);
1083   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDChargeRatio2Layer5,
1084                                            fGenRecPointsOffset + 30, expert, !image);
1085   fSSDhRecPointsTask += 1;
1086   TH1F *fHistSSDChargeRatio2Layer6 = new TH1F("SSD/ClusterCharge/Layer6/fHistSSDChargeRatio2Layer6",
1087                                            "Charge Ratio qN/qP - Layer 6;q_{N}/q_{P};Entries;",
1088                                            100,0,2);
1089   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDChargeRatio2Layer6,
1090                                            fGenRecPointsOffset + 31, expert, !image);
1091   fSSDhRecPointsTask += 1;
1092   TH2F *fHistSSDChargePNSideLayer5 = new TH2F("SSD/ClusterCharge/Layer5/fHistSSDChargePNSideLayer5",
1093                                            "Charge correlation - Layer 5;q_{P} [keV];q_{N} [keV]",
1094                                            100,0.,300.,
1095                                            100,0.,300.);
1096   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDChargePNSideLayer5,
1097                                            fGenRecPointsOffset + 32, expert, !image);
1098   fSSDhRecPointsTask += 1;
1099   TH2F *fHistSSDChargePNSideLayer6 = new TH2F("SSD/ClusterCharge/Layer6/fHistSSDChargePNSideLayer6",
1100                                            "Charge correlation - Layer 6;q_{P} [keV];q_{N} [keV]",
1101                                            100,0.,300.,
1102                                            100,0.,300.);
1103   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDChargePNSideLayer6,
1104                                            fGenRecPointsOffset + 33, expert, !image);
1105   fSSDhRecPointsTask += 1;
1106   TH2F *fHistSSDChargeMapLayer5 = new TH2F("SSD/ClusterCharge/Layer5/fHistSSDChargeMapLayer5",
1107                                         "Charge map;N_{modules};N_{Ladders}",
1108                                         fgkSSDMODULESPERLADDERLAYER5,
1109                                         -0.5,fgkSSDMODULESPERLADDERLAYER5+0.5,
1110                                         3*fgkSSDLADDERSLAYER5,
1111                                         -0.5,fgkSSDLADDERSLAYER5+0.5);
1112   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDChargeMapLayer5, 
1113                                            fGenRecPointsOffset + 34, expert, !image);
1114   fSSDhRecPointsTask += 1;
1115   TH2F *fHistSSDChargeMapLayer6 = new TH2F("SSD/ClusterCharge/Layer6/fHistSSDChargeMapLayer6",
1116                                         "Charge map;N_{modules};N_{Ladders}",
1117                                         fgkSSDMODULESPERLADDERLAYER6,
1118                                         -0.5,fgkSSDMODULESPERLADDERLAYER6+0.5,
1119                                         3*fgkSSDLADDERSLAYER6,
1120                                         -0.5,fgkSSDLADDERSLAYER6+0.5);
1121   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDChargeMapLayer6, 
1122                                            fGenRecPointsOffset + 35, expert, !image);
1123   fSSDhRecPointsTask += 1;
1124   TH2F *fHistSSDClusterMapLayer5 = new TH2F("SSD/Statistics/Layer5/fHistSSDClusterMapLayer5",
1125                                          "Layer 5;N_{module};N_{ladder}",
1126                                          22,1,23,
1127                                          34,500,534);
1128   fHistSSDClusterMapLayer5->GetXaxis()->SetTitleColor(1);
1129   fHistSSDClusterMapLayer5->SetStats(kFALSE);
1130   fHistSSDClusterMapLayer5->GetYaxis()->SetTitleOffset(1.8);
1131   fHistSSDClusterMapLayer5->GetXaxis()->SetNdivisions(22);
1132   fHistSSDClusterMapLayer5->GetYaxis()->SetNdivisions(34);
1133   fHistSSDClusterMapLayer5->GetXaxis()->SetLabelSize(0.03);
1134   fHistSSDClusterMapLayer5->GetYaxis()->SetLabelSize(0.03);
1135   fHistSSDClusterMapLayer5->GetZaxis()->SetTitleOffset(1.4);
1136   fHistSSDClusterMapLayer5->GetZaxis()->SetTitle("N_{clusters}");
1137   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDClusterMapLayer5,
1138                                            fGenRecPointsOffset + 36, !expert, image);
1139   fSSDhRecPointsTask += 1;
1140   TH2F *fHistSSDClusterMapLayer6 = new TH2F("SSD/Statistics/Layer6/fHistSSDClusterMapLayer6",
1141                                          "Layer 6;N_{module};N_{ladder}",
1142                                          25,1,26,
1143                                          38,600,638);
1144   fHistSSDClusterMapLayer6->GetXaxis()->SetTitleColor(1);
1145   fHistSSDClusterMapLayer6->SetStats(kFALSE);
1146   fHistSSDClusterMapLayer6->GetYaxis()->SetTitleOffset(1.8);
1147   fHistSSDClusterMapLayer6->GetXaxis()->SetNdivisions(25);
1148   fHistSSDClusterMapLayer6->GetYaxis()->SetNdivisions(38);
1149   fHistSSDClusterMapLayer6->GetXaxis()->SetLabelSize(0.03);
1150   fHistSSDClusterMapLayer6->GetYaxis()->SetLabelSize(0.03);
1151   fHistSSDClusterMapLayer6->GetZaxis()->SetTitleOffset(1.4);
1152   fHistSSDClusterMapLayer6->GetZaxis()->SetTitle("N_{clusters}");
1153   fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDClusterMapLayer6,
1154                                            fGenRecPointsOffset + 37, !expert, image);
1155   fSSDhRecPointsTask += 1;
1156   //printf ("%d SSD Recs histograms booked\n",fSSDhRecPointsTask);
1157   AliDebug(1,Form("%d SSD Recs histograms booked\n",fSSDhRecPointsTask));
1158 }
1159
1160 //____________________________________________________________________________ 
1161 void AliITSQASSDDataMakerRec::MakeRecPoints(TTree *clustersTree)
1162 {
1163   // Fill QA for recpoints - SSD -
1164   //printf("*-*-*-*-*-*-*---*-*-*-------*-*-*-*-*-*-***************AliITSQASSDataMakerRec::MakeRecpoints called \n");
1165   Int_t gLayer = 0, gLadder = 0, gModule = 0;
1166   Int_t lLadderLocationY = 0;
1167   TBranch *branchRecP = clustersTree->GetBranch("ITSRecPoints");
1168   if (!branchRecP) { 
1169     AliError("can't get the branch with the ITS clusters !");
1170     return;
1171   }
1172   static TClonesArray statRecpoints("AliITSRecPoint");
1173   TClonesArray *recpoints = &statRecpoints;
1174   branchRecP->SetAddress(&recpoints);
1175   Int_t nClustersLayer5 = 0, nClustersLayer6 = 0;
1176   Int_t npoints = 0;      
1177   Float_t cluglo[3]={0.,0.,0.}; 
1178   //printf("*-*-*-*-*-*-*---*-*-*-------*-*-*-*-*-*-***************AliITSQASSDataMakerRec::MakeRecpoints STEP1 \n");
1179   for(Int_t module = 0; module < clustersTree->GetEntries(); module++){
1180     branchRecP->GetEvent(module);
1181     npoints += recpoints->GetEntries();
1182     AliITSgeomTGeo::GetModuleId(module,gLayer,gLadder,gModule);
1183     //printf("SSDDataMAkerRec:::::::::::::::::::::::gLayer ========== %d \n\n",gLayer);
1184     lLadderLocationY = 3*gLadder;
1185     ////printf("*-*-*-*-*-*-*---*-*-*-------*-*-*-*-*-*-***************AliITSQASSDataMakerRec::MakeRecpoints inside loop \n");
1186     for(Int_t j = 0;j < recpoints->GetEntries(); j++){
1187       ////printf("*-*-*-*-*-*-*---*-*-*-------*-*-*-*-*-*-***************AliITSQASSDataMakerRec::MakeRecpoints inside loop 2\n");
1188       AliITSRecPoint *recp = (AliITSRecPoint*)recpoints->At(j);    
1189       Int_t layer = recp->GetLayer();
1190       //printf("SSDDataMAkerRec:::::::::::::::::::::::layer ========== %d \n\n",layer);
1191       recp->GetGlobalXYZ(cluglo);
1192       Float_t radius = TMath::Sqrt(cluglo[0]*cluglo[0]+cluglo[1]*cluglo[1]); 
1193       Float_t phi = TMath::ATan2(cluglo[1],cluglo[0]);
1194       Float_t theta = TMath::ATan2(radius,cluglo[2]);
1195       Double_t chargeRatio = recp->GetChargeRatio();
1196       Double_t clusterCharge = recp->GetQ();
1197       Double_t chargePSide = clusterCharge*(1. + chargeRatio);
1198       Double_t chargeNSide = clusterCharge*(1. - chargeRatio);
1199       if(layer == 4) {
1200         //printf("-*-*-*-*-*-***************AliITSQASSDataMakerRec::MakeRecpoints Filling 4 called \n");
1201         fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 0)->Fill(module);
1202         fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 4)->Fill(recp->GetDetLocalX());
1203         fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 6)->Fill(recp->GetDetLocalZ());
1204         fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 8)->Fill(cluglo[0]);
1205         fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 10)->Fill(cluglo[1]);
1206         fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 12)->Fill(cluglo[2]);
1207         fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 14)->Fill(phi);
1208         fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 16)->Fill(theta);
1209         fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 18)->Fill(radius);
1210         fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 20)->Fill(recp->GetType());
1211         fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 22)->Fill(recp->GetChargeRatio());
1212         fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 24)->Fill(recp->GetQ());
1213         fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 26)->Fill(chargePSide);
1214         fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 28)->Fill(chargeNSide);
1215         if(chargePSide != 0.) fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 30)->Fill(chargeNSide/chargePSide);
1216         fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 32)->Fill(chargePSide,chargeNSide);
1217         fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 34)->SetBinContent(gModule,lLadderLocationY,recp->GetQ());
1218         ((TH2F *)fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 36))->Fill(gModule,499+gLadder,1);
1219         nClustersLayer5 += 1;
1220       }//layer 5 histograms
1221       if(layer == 5) {
1222         //printf("-*-*-*-*-*-***************AliITSQASSDataMakerRec::MakeRecpoints Filling 5 called \n");
1223         fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 1)->Fill(module);
1224         fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 5)->Fill(recp->GetDetLocalX());
1225         fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 7)->Fill(recp->GetDetLocalZ());
1226         fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 9)->Fill(cluglo[0]);
1227         fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 11)->Fill(cluglo[1]);
1228         fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 13)->Fill(cluglo[2]);
1229         fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 15)->Fill(phi);
1230         fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 17)->Fill(theta);
1231         fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 19)->Fill(radius);
1232         fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 21)->Fill(recp->GetType());
1233         fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 23)->Fill(recp->GetChargeRatio());
1234         fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 25)->Fill(recp->GetQ());
1235         fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 27)->Fill(chargePSide);
1236         fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 29)->Fill(chargeNSide);
1237         if(chargePSide != 0.) fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 31)->Fill(chargeNSide/chargePSide);
1238         fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 33)->Fill(chargePSide,chargeNSide);
1239         fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 35)->SetBinContent(gModule,lLadderLocationY,recp->GetQ());
1240         ((TH2F *)fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 37))->Fill(gModule,599+gLadder,1);
1241         nClustersLayer6 += 1;
1242       }//layer 6 histograms
1243     }//rec. points loop
1244   }//module loop
1245   
1246   //printf("-*-*-*-*-*-***************AliITSQASSDataMakerRec::MakeRecpoints Filling called \n");
1247   fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 2)->Fill(nClustersLayer5);
1248   fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset + 3)->Fill(nClustersLayer6);
1249
1250   statRecpoints.Clear();
1251 }
1252
1253 //____________________________________________________________________________ 
1254 Int_t AliITSQASSDDataMakerRec::GetOffset(AliQAv1::TASKINDEX_t task) {
1255   // Returns offset number according to the specified task 
1256   Int_t offset=0;
1257   if( task == AliQAv1::kRAWS ) {
1258     offset=fGenRawsOffset;  
1259   }
1260   else if( task == AliQAv1::kRECPOINTS ) {
1261     offset=fGenRecPointsOffset;   
1262   }
1263   else {
1264     AliInfo("No task has been selected. Offset set to zero.\n");
1265   }
1266
1267   return offset;
1268 }
1269
1270 //____________________________________________________________________________ 
1271 Int_t AliITSQASSDDataMakerRec::GetTaskHisto(AliQAv1::TASKINDEX_t task) {
1272   // Returns the number of histograms associated to the specified task
1273   Int_t histotot=0;
1274
1275   if( task == AliQAv1::kRAWS ) {
1276     histotot=fSSDhRawsTask;  
1277   }
1278   else if( task == AliQAv1::kRECPOINTS ){
1279     histotot=fSSDhRecPointsTask;   
1280   }
1281   else { 
1282     AliInfo("No task has been selected. TaskHisto set to zero.\n");
1283   }
1284
1285   return histotot;
1286 }