Fix for the case of non-existent calibration files
[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 <TH2F.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 "AliITSQADataMakerRec.h"
35 #include "AliITSQASSDDataMakerRec.h"
36 #include "AliQADataMakerRec.h"
37 #include "AliLog.h"
38 #include "AliQAv1.h"
39 #include "AliQAChecker.h"
40 #include "AliRawReader.h"
41 #include "AliRawReaderRoot.h"
42 #include "AliITSRawStreamSSD.h"
43 #include "AliITSgeomTGeo.h"
44 #include "AliRawEventHeaderBase.h"
45 #include "AliITSRecPoint.h"
46 #include "AliITSRecPointContainer.h"
47 #include "AliITSdigitSSD.h"
48 #include "AliITSBadChannelsSSDv2.h"
49
50 #include "AliCDBManager.h"
51 #include "AliCDBEntry.h"
52
53 ClassImp(AliITSQASSDDataMakerRec)
54
55 AliITSQASSDDataMakerRec::AliITSQASSDDataMakerRec(AliITSQADataMakerRec *aliITSQADataMakerRec, Bool_t kMode, Int_t ldc) :
56 TObject(),
57   fAliITSQADataMakerRec(aliITSQADataMakerRec),
58   fkOnline(kMode),
59   fLDC(ldc),
60   fSSDRawsOffset(0), fSSDRawsDAOffset(0),
61   fSSDRawsCommonLevelOffset(0),
62   fSSDhRawsTask(0),
63   fSSDhDigitsTask(0),
64   fSSDhRecPointsTask(0),
65   fGenRawsOffset(0),
66   fGenDigitsOffset(0),
67   fGenRecPointsOffset(0),
68   fCDBManager(0) {
69   // Default constructor   
70   //initilize the raw signal vs strip number histograms
71   fGenRawsOffset = new Int_t[AliRecoParam::kNSpecies];
72   fGenRecPointsOffset = new Int_t[AliRecoParam::kNSpecies];
73   fGenDigitsOffset = new Int_t[AliRecoParam::kNSpecies];
74   for(Int_t i=0; i<AliRecoParam::kNSpecies; i++) {
75     fGenRawsOffset[i] = 0;
76     fGenRecPointsOffset[i] = 0;
77     fGenDigitsOffset[i]=0;
78   }
79   if(fkOnline) {
80     fCDBManager = AliCDBManager::Instance();
81     //fCDBManager->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
82     fCDBManager->SetDefaultStorage(gSystem->Getenv("AMORE_CDB_URI"));
83
84     Int_t runNumber = 1;
85     if(!gSystem->Getenv("DATE_RUN_NUMBER")) {
86       AliWarning("DATE_RUN_NUMBER not defined!!!\n"); }
87     else {
88       runNumber = atoi(gSystem->Getenv("DATE_RUN_NUMBER"));}
89     fCDBManager->SetRun(runNumber);
90     AliCDBEntry *geomGRP = fCDBManager->Get("GRP/Geometry/Data");
91     if(!geomGRP) AliWarning("GRP geometry not found!!!\n");
92     
93     Int_t gLayer = 0,gLadder = 0, gModule = 0;
94     Int_t gHistCounterRawSignal = 0, gHistCounterCM = 0;
95     TString gTitle; 
96
97     for(Int_t iModule = 500; iModule < fgkSSDMODULES + 500; iModule++) {
98       AliITSgeomTGeo::GetModuleId(iModule,gLayer,gLadder,gModule);
99       gTitle = "SSD_RawSignal_Layer"; gTitle += gLayer;
100       gTitle += "_Ladder"; gTitle += gLadder;
101       gTitle += "_Module"; gTitle += gModule;
102       fHistSSDRawSignalModule[gHistCounterRawSignal] = new TH1F(gTitle.Data(),gTitle.Data(),
103                                                                 2*fgkNumberOfPSideStrips,0,2*fgkNumberOfPSideStrips);
104       gHistCounterRawSignal += 1;
105       
106       for(Int_t iStrip = 0; iStrip < 2*fgkNumberOfPSideStrips; iStrip++)
107         fOccupancyMatrix[iModule-500][iStrip] = 0; 
108
109       //CM histograms
110       gTitle = "SSD_CM_PSide_Layer"; gTitle += gLayer;
111       gTitle += "_Ladder"; gTitle += gLadder;
112       gTitle += "_Module"; gTitle += gModule;
113       fHistSSDCMModule[gHistCounterCM] = new TH1F(gTitle.Data(),gTitle.Data(),
114                                                   100,-50.,50.);
115       fHistSSDCMModule[gHistCounterCM]->GetXaxis()->SetTitle("CM");
116       gHistCounterCM += 1;
117     }//module loop
118
119     for(Int_t iModule = 500; iModule < fgkSSDMODULES + 500; iModule++) {
120       AliITSgeomTGeo::GetModuleId(iModule,gLayer,gLadder,gModule);
121       gTitle = "SSD_CM_NSide_Layer"; gTitle += gLayer;
122       gTitle += "_Ladder"; gTitle += gLadder;
123       gTitle += "_Module"; gTitle += gModule;
124       fHistSSDCMModule[gHistCounterCM] = new TH1F(gTitle.Data(),gTitle.Data(),
125                                                   100,-50.,50.);
126       fHistSSDCMModule[gHistCounterCM]->GetXaxis()->SetTitle("CM");
127       gHistCounterCM += 1;
128
129     }
130   }//online flag
131   else {
132     fCDBManager = NULL;
133     for(Int_t iModule = 0; iModule < fgkSSDMODULES; iModule++) {
134       fHistSSDCMModule[iModule] = NULL;
135       fHistSSDCMModule[fgkSSDMODULES+iModule] = NULL;
136       fHistSSDRawSignalModule[iModule] = NULL;
137     }
138   }
139 }
140 /*
141 //____________________________________________________________________________ 
142 AliITSQASSDDataMakerRec::AliITSQASSDDataMakerRec(const AliITSQASSDDataMakerRec& qadm) :
143 TObject(),
144 fAliITSQADataMakerRec(qadm.fAliITSQADataMakerRec),
145 fkOnline(qadm.fkOnline),
146 fLDC(qadm.fLDC),
147 fSSDRawsOffset(qadm.fSSDRawsOffset), fSSDRawsDAOffset(qadm.fSSDRawsDAOffset),
148 fSSDRawsCommonLevelOffset(qadm.fSSDRawsCommonLevelOffset),
149 fSSDhRawsTask(qadm.fSSDhRawsTask),
150 fSSDhDigitsTask(qadm.fSSDhDigitsTask),
151 fSSDhRecPointsTask(qadm.fSSDhRecPointsTask),
152 fGenRawsOffset(qadm.fGenRawsOffset),
153 fGenDigitsOffset(qadm.fGenDigitsOffset),
154 fGenRecPointsOffset(qadm.fGenRecPointsOffset),
155 fCDBManager(qadm.fCDBManager) {
156 //copy ctor 
157 fAliITSQADataMakerRec->SetName((const char*)qadm.fAliITSQADataMakerRec->GetName()) ; 
158 fAliITSQADataMakerRec->SetTitle((const char*)qadm.fAliITSQADataMakerRec->GetTitle());
159 }
160
161 //__________________________________________________________________
162 AliITSQASSDDataMakerRec& AliITSQASSDDataMakerRec::operator = (const AliITSQASSDDataMakerRec& qac )
163 {
164 // Equal operator.
165 this->~AliITSQASSDDataMakerRec();
166 new(this) AliITSQASSDDataMakerRec(qac);
167 return *this;
168 }
169 */
170 //__________________________________________________________________
171 AliITSQASSDDataMakerRec::~AliITSQASSDDataMakerRec() {
172   // destructor
173   if(fkOnline) {
174     for(Int_t iModule = 0; iModule < fgkSSDMODULES; iModule++) {
175       if(fHistSSDRawSignalModule[iModule]) delete fHistSSDRawSignalModule[iModule];
176       if(fHistSSDCMModule[iModule]) delete fHistSSDCMModule[iModule];
177       if(fHistSSDCMModule[fgkSSDMODULES+iModule]) delete fHistSSDCMModule[fgkSSDMODULES+iModule];
178     }
179     
180     if(fCDBManager) delete fCDBManager;
181   }
182 }
183
184 //____________________________________________________________________________ 
185 void AliITSQASSDDataMakerRec::StartOfDetectorCycle()
186 {
187   // start of detector cycle
188
189   if(fAliITSQADataMakerRec->ListExists(AliQAv1::kRAWS)==kFALSE)return;
190
191   //if ( fAliITSQADataMakerRec->GetRawsData(0) == NULL ) // Raws not defined
192   //return ;
193  
194   //for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
195   //if (!AliQAv1::Instance()->IsEventSpecieSet(specie)) continue;
196   //cout << "StartOfDetectorCycle: Event specie " << specie << " is set" << endl;
197
198   //Detector specific actions at start of cycle
199   AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQADM::Start of SSD Cycle\n");
200   //Int_t specie = fAliITSQADataMakerRec->GetEventSpecie();
201
202   //}//event specie loop
203
204 }
205
206 //____________________________________________________________________________ 
207 void AliITSQASSDDataMakerRec::ResetRawsMonitoredObjects() 
208 {
209   //Resetting the raw data monitored objects
210   //Data size per DDL
211   //for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
212   //if (!AliQAv1::Instance()->IsEventSpecieSet(specie)) continue;
213   /*((TH1F *)(fAliITSQADataMakerRec->ResetRawsData(fGenRawsOffset[specie]+4)));
214   //Data size per LDC
215   ((TH1F *)(fAliITSQADataMakerRec->ResetRawsData(fGenRawsOffset[specie]+22)));*/
216   Int_t specie = fAliITSQADataMakerRec->GetEventSpecie();
217   //cout << "(AliITSQASSDDataMakerRec::ResetRawsMonitoredObjects): Event specie " << specie << " is set" << endl;
218   //online part
219   if(fkOnline) {
220     for(Int_t iModule = 500; iModule < fgkSSDMODULES + 500; iModule++) {
221       for(Int_t iStrip = 0; iStrip < 2*fgkNumberOfPSideStrips; iStrip++)
222         fOccupancyMatrix[iModule-500][iStrip] = 0;
223     }//module loop
224     
225     //for(Int_t iSSDOffset = 0; iSSDOffset < fSSDRawsCommonLevelOffset; iSSDOffset++)
226     //(fAliITSQADataMakerRec->ResetRawsData(fGenRawsOffset[specie]+iSSDOffset));
227     //for(Int_t iSSDOffset = fSSDRawsCommonLevelOffset; iSSDOffset < fSSDRawsOffset; iSSDOffset++)
228     //(fAliITSQADataMakerRec->ResetRawsData(fGenRawsOffset[specie]+iSSDOffset));
229
230     Int_t gHistPositionOccupancyPerLadder = 0;
231     Int_t gLayer = 0, gLadder = 0, gModule = 0;
232     for(Int_t iModule = 0; iModule < fgkSSDMODULES; iModule++) {
233       AliITSgeomTGeo::GetModuleId(iModule+500,gLayer,gLadder,gModule);
234       
235       gHistPositionOccupancyPerLadder = (gLayer == 5) ? 2*(gLadder - 1) : 2*(gLadder - 1 + fgkSSDLADDERSLAYER5);
236       
237       //P-SIDE OCCUPANCY
238       int offs = fGenRawsOffset[specie]+fSSDRawsCommonLevelOffset+fgkSSDMODULES;
239       fAliITSQADataMakerRec->ResetRawsData(offs+gHistPositionOccupancyPerLadder);
240       //N-SIDE OCCUPANCY
241       fAliITSQADataMakerRec->ResetRawsData(offs+gHistPositionOccupancyPerLadder+1);
242       //
243       fAliITSQADataMakerRec->ResetRawsData(offs+2*fgkSSDLADDERSLAYER5+2*fgkSSDLADDERSLAYER6);
244       fAliITSQADataMakerRec->ResetRawsData(offs+2*fgkSSDLADDERSLAYER5+2*fgkSSDLADDERSLAYER6+1);
245     }//module loop
246   }//online flag
247   //
248 }
249
250 //____________________________________________________________________________ 
251 void AliITSQASSDDataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray** /*list*/)
252 {
253   // finalize ssd cycle
254   //
255   Int_t specie = fAliITSQADataMakerRec->GetEventSpecie();
256   //cout << "(AliITSQASSDDataMakerRec::EndOfDetectorCycle): Event specie " << specie << " is set" << endl;
257   
258   // launch the QA checking
259   AliDebug(AliQAv1::GetQADebugLevel(),"AliITSDM instantiates checker with Run(AliQAv1::kITS, task, list)\n"); 
260   AliDebug(AliQAv1::GetQADebugLevel(), Form("Offset: %d\n",fGenRawsOffset[specie]));
261   //Printf("Offset: %d\n",fGenRawsOffset[specie]);
262
263   if(task == AliQAv1::kRAWS) {
264     //
265     for (int trCl=-1;trCl<fAliITSQADataMakerRec->GetNTrigClasses();trCl++) { // RS Loop over all trigger classes (+ global counter, -1)
266       //
267       TObjArray &harr = *fAliITSQADataMakerRec->GetRawsDataOfTrigClass(trCl);
268       int offs = fGenRawsOffset[specie];
269       int nSSDEventPerCycle = fAliITSQADataMakerRec->GetEvCountCycleRaws(trCl);
270       //    
271       //Data size per DDL
272       for(Int_t i = 0; i < fgkNumOfDDLs; i++) {
273         if (!(harr[offs+5+i] && harr[offs+4+i])) continue;
274         Double_t gSizePerDDL = ((TH1*)harr[offs+5+i])->GetMean();
275         //cout<<"DDL: "<<i+512<<" - Size: "<<gSizePerDDL<<" - Mean: "<<gSizePerDDL<<endl;
276         //cout<<"Entries: "<<((TH1*)harr[offs+5+i])->GetEntries()<<endl;
277         ((TH1*)harr[offs+4])->SetBinContent(i+1,gSizePerDDL);
278         //cout<<"After filling DDL: "<<i+512<<" - Size: "<< ((TH1F*)harr[offs+4+i])->GetBinContent(i+1)<<endl;
279       }
280       //
281       //Data size per LDC
282       for(Int_t i = 0; i < fgkNumOfLDCs; i++) {
283         if ( !(harr[offs+23+i]&&harr[offs+22+i])) continue;
284         Double_t gSizePerLDC = ((TH1*)harr[offs+23+i])->GetMean();
285         ((TH1*)harr[offs+22])->SetBinContent(i+1,gSizePerLDC);
286         //cout<<"LDC: "<<i+170<<" - Size: "<<gSizePerLDC<<" - Mean: "<<" - Size: "<<((TH1*)harr[offs+23+i])->GetMean()<<endl;
287       }
288       //
289       //if (harr[offs+4])  cout<<"Data size/ DDL entries: "<<((TH1*)harr[offs+4 ])->GetEntries()<< " mean: " << ((TH1*)harr[offs+4])->GetMean()<<endl;   
290       //if (harr[offs+22]) cout<<"Data size/ LDC entries: "<<((TH1*)harr[offs+22])->GetEntries()<< " mean: " << ((TH1*)harr[offs+22])->GetMean()<<endl;
291       //
292       //online part
293       if(fkOnline) {
294         //Output of the DA
295         MonitorOCDBObjects(trCl);
296         //Monitor common mode values
297         MonitorCMValues(trCl);
298         //
299         Int_t gHistPositionOccupancyPerModule = 0;
300         Int_t gLayer = 0, gLadder = 0, gModule = 0;
301         //occupancy per module
302         for(Int_t iModule = 0; iModule < fgkSSDMODULES; iModule++) {
303           AliITSgeomTGeo::GetModuleId(iModule+500,gLayer,gLadder,gModule);        
304           gHistPositionOccupancyPerModule = (gLayer == 5) ? ((gLadder - 1)*fgkSSDMODULESPERLADDERLAYER5 + gModule - 1) : ((gLadder - 1)*fgkSSDMODULESPERLADDERLAYER6 + gModule + fgkSSDMODULESLAYER5 - 1);
305           TH1* htmp = (TH1*)harr[offs+fSSDRawsCommonLevelOffset+gHistPositionOccupancyPerModule];
306           if (htmp) {
307             for(Int_t iBins = 1; iBins < fHistSSDRawSignalModule[iModule]->GetXaxis()->GetNbins(); iBins++) htmp->SetBinContent(iBins,fOccupancyMatrix[iModule][iBins-1]);
308             if(nSSDEventPerCycle != 0) htmp->Scale(100./nSSDEventPerCycle);
309           }//module loop
310         }
311         //
312         //occupancy per ladder
313         Int_t gHistPositionOccupancyPerLadder = 0;
314         Int_t lLadderLocationY = 0;
315         Double_t occupancy = 0.0, occupancyThreshold = 0.0, occupancyAverage = 0.0;
316         for(Int_t iModule = 0; iModule < fgkSSDMODULES; iModule++) {
317           AliITSgeomTGeo::GetModuleId(iModule+500,gLayer,gLadder,gModule);
318           //
319           gHistPositionOccupancyPerModule = (gLayer == 5) ? ((gLadder - 1)*fgkSSDMODULESPERLADDERLAYER5 + gModule - 1) : ((gLadder - 1)*fgkSSDMODULESPERLADDERLAYER6 + gModule + fgkSSDMODULESLAYER5 - 1);
320           gHistPositionOccupancyPerLadder = (gLayer == 5) ? 2*(gLadder - 1) : 2*(gLadder - 1 + fgkSSDLADDERSLAYER5);
321           //
322           TH1* htmpo = (TH1*)harr[offs+fSSDRawsCommonLevelOffset+gHistPositionOccupancyPerModule];
323           TH1* h1t = 0;
324           TH2* h2t = 0;
325           if (htmpo) {
326             //P-SIDE OCCUPANCY
327             occupancy          = GetOccupancyModule(htmpo,0,0,0);
328             occupancyThreshold = GetOccupancyModule(htmpo,0,1,3);
329             occupancyAverage   = GetOccupancyModule(htmpo,0,2,0);
330             if ( (h1t=(TH1*)harr[offs+fSSDRawsCommonLevelOffset+fgkSSDMODULES+gHistPositionOccupancyPerLadder]) ) h1t->SetBinContent(gModule,occupancy);
331             lLadderLocationY = 3*gLadder; // sideP=1 sideN=0 
332             if(gLayer == 5) {
333               //occupancy per module - no threshold
334               if ( (h2t=(TH2*)harr[offs+fSSDRawsCommonLevelOffset+fgkSSDMODULES+2*fgkSSDLADDERSLAYER5+2*fgkSSDLADDERSLAYER6])   ) h2t->SetBinContent(gModule,lLadderLocationY,occupancy);
335               //occupancy per module - threshold @ 3%
336               if ( (h2t=(TH2*)harr[offs+fSSDRawsCommonLevelOffset+fgkSSDMODULES+2*fgkSSDLADDERSLAYER5+2*fgkSSDLADDERSLAYER6+2]) ) h2t->SetBinContent(gModule,lLadderLocationY,occupancyThreshold);
337               //average occupancy per module
338               if ( (h2t=(TH2*)harr[offs+fSSDRawsCommonLevelOffset+fgkSSDMODULES+2*fgkSSDLADDERSLAYER5+2*fgkSSDLADDERSLAYER6+4]) ) h2t->SetBinContent(gModule,lLadderLocationY,occupancyAverage);
339             }
340             else if(gLayer == 6) {
341               //occupancy per module - no threshold
342               if ( (h2t=(TH2*)harr[offs+fSSDRawsCommonLevelOffset+fgkSSDMODULES+2*fgkSSDLADDERSLAYER5+2*fgkSSDLADDERSLAYER6+1]) ) h2t->SetBinContent(gModule,lLadderLocationY,occupancy);
343               //occupancy per module - threshold @ 3%
344               if ( (h2t=(TH2*)harr[offs+fSSDRawsCommonLevelOffset+fgkSSDMODULES+2*fgkSSDLADDERSLAYER5+2*fgkSSDLADDERSLAYER6+3]) ) h2t->SetBinContent(gModule,lLadderLocationY,occupancyThreshold);
345               //average occupancy per module
346               if ( (h2t=(TH2*)harr[offs+fSSDRawsCommonLevelOffset+fgkSSDMODULES+2*fgkSSDLADDERSLAYER5+2*fgkSSDLADDERSLAYER6+5]) ) h2t->SetBinContent(gModule,lLadderLocationY,occupancyAverage);
347             }
348             //
349             //N-SIDE OCCUPANCY
350             //
351             occupancy          = GetOccupancyModule(htmpo,1,0,0);   
352             occupancyThreshold = GetOccupancyModule(htmpo,1,1,3);   
353             occupancyAverage   = GetOccupancyModule(htmpo,1,2,0);   
354             if ( (h1t=(TH1*)harr[offs+fSSDRawsCommonLevelOffset+fgkSSDMODULES+gHistPositionOccupancyPerLadder+1]) ) h1t->SetBinContent(gModule,occupancy);
355             if(gLayer == 5) {
356               //occupancy per module - no threshold
357               if ( (h2t=(TH2*)harr[offs+fSSDRawsCommonLevelOffset+fgkSSDMODULES+2*fgkSSDLADDERSLAYER5+2*fgkSSDLADDERSLAYER6])   ) h2t->SetBinContent(gModule,lLadderLocationY-1,occupancy);
358               //occupancy per module - threshold @ 3%
359               if ( (h2t=(TH2*)harr[offs+fSSDRawsCommonLevelOffset+fgkSSDMODULES+2*fgkSSDLADDERSLAYER5+2*fgkSSDLADDERSLAYER6+2]) ) h2t->SetBinContent(gModule,lLadderLocationY-1,occupancyThreshold);
360               //average occupancy per module
361               if ( (h2t=(TH2*)harr[offs+fSSDRawsCommonLevelOffset+fgkSSDMODULES+2*fgkSSDLADDERSLAYER5+2*fgkSSDLADDERSLAYER6+4]) ) h2t->SetBinContent(gModule,lLadderLocationY-1,occupancyAverage);
362             }
363             else if(gLayer == 6) {
364               //occupancy per module - no threshold
365               if ( (h2t=(TH2*)harr[offs+fSSDRawsCommonLevelOffset+fgkSSDMODULES+2*fgkSSDLADDERSLAYER5+2*fgkSSDLADDERSLAYER6+1]) ) h2t->SetBinContent(gModule,lLadderLocationY-1,occupancy);
366               //occupancy per module - threshold @ 3%
367   if ( (h2t=(TH2*)harr[offs+fSSDRawsCommonLevelOffset+fgkSSDMODULES+2*fgkSSDLADDERSLAYER5+2*fgkSSDLADDERSLAYER6+3]) ) h2t->SetBinContent(gModule,lLadderLocationY-1,occupancyThreshold);
368               //average occupancy per module
369               if ( (h2t=(TH2*)harr[offs+fSSDRawsCommonLevelOffset+fgkSSDMODULES+2*fgkSSDLADDERSLAYER5+2*fgkSSDLADDERSLAYER6+5]) ) h2t->SetBinContent(gModule,lLadderLocationY-1,occupancyAverage);
370             }
371           } // htmpo
372         }//module loop
373       }//online flag for SSD
374       //
375       //TH2* h2tmp = (TH2*)harr[offs+fSSDRawsCommonLevelOffset+fgkSSDMODULES+2*fgkSSDLADDERSLAYER5+2*fgkSSDLADDERSLAYER6];
376       //if (h2tmp) AliInfo(Form("Entries 2d occupancy no thres- lay 5: %d"),h2tmp->GetEntries());
377       //h2tmp = (TH2*)harr[offs+fSSDRawsCommonLevelOffset+fgkSSDMODULES+2*fgkSSDLADDERSLAYER5+2*fgkSSDLADDERSLAYER6+3];
378       //cout<<"entries 2d occupancy thres- lay 6: "<<h2tmp->GetEntries()<< " mean: " << h2tmp->GetMean() << endl; //Somehow the other occupancy maps do give nonzero values for GetMean() here
379       //
380       // TH1* h1tmp = (TH1*)harr[fGenRawsOffset[1]+4];
381       // if (h1tmp) cout<<"Data size/ DDL entries: "<<h1tmp->GetEntries()<< " mean: " << h1tmp->GetMean()<<endl;   
382       //Reset of the raws
383     } //  RS Loop over all trigger classes (+ global counter, -1)
384     //AliQAChecker::Instance()->Run( AliQAv1::kITS , task, list);
385     //
386     ResetRawsMonitoredObjects();
387   }//raw data end of cycle
388   //
389       
390   // 
391 }
392
393 //____________________________________________________________________________ 
394 Int_t AliITSQASSDDataMakerRec::InitRaws() {  
395   // Initialization for RAW data - SSD -
396   const Bool_t expert   = kTRUE ; 
397   const Bool_t saveCorr = kTRUE ; 
398   const Bool_t image    = kTRUE ; 
399   Int_t rv = 0 ; 
400   fSSDRawsOffset = 0;
401
402   //for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
403   //if (!AliQAv1::Instance()->IsEventSpecieSet(specie)) continue;
404   Int_t specie = fAliITSQADataMakerRec->GetEventSpecie();
405   //cout << "(AliITSQASSDDataMakerRec::InitRaws): Event specie " << specie << " is set" << endl;
406   //cout << "(AliITSQASSDDataMakerRec::InitRaws): Offset " << offsRw << endl;
407   int offsRw = fGenRawsOffset[specie];
408     
409     
410   if(fkOnline) {
411     AliDebug(AliQAv1::GetQADebugLevel(), "Book Online Histograms for SSD\n");
412   }
413   else {
414     AliDebug(AliQAv1::GetQADebugLevel(), "Book Offline Histograms for SSD\n ");
415   }
416   AliDebug(AliQAv1::GetQADebugLevel(), Form("Number of histograms (SPD+SDD): %d\n",offsRw));
417   
418   TString gTitle;
419   TString gName;
420   //book online-offline QA histos
421   TH1F *fHistSSDEventType = new TH1F("fHistSSDEventType",
422                                      "SSD Event Type;Event type;Events",
423                                      31,-1,30);
424   fHistSSDEventType->SetStats(kFALSE);
425   rv = fAliITSQADataMakerRec->Add2RawsList(fHistSSDEventType, 
426                                            offsRw+fSSDRawsOffset, expert, !image, !saveCorr);
427   fSSDRawsOffset += 1;
428   //cout<<"(AliITSQASSDDataMakerRec::InitRaws): "<<offsRw+fSSDRawsOffset-1<<" - Name: "<<(fAliITSQADataMakerRec->GetRawsData(offsRw))->GetName()<<endl;
429   TH1F *fHistSSDDataSize = new TH1F("fHistSSDDataSize",
430                                     "SSD Data Size;(SSD data size) [KB];Events",
431                                     1000,0,500);
432   rv = fAliITSQADataMakerRec->Add2RawsList(fHistSSDDataSize, 
433                                            offsRw+fSSDRawsOffset, !expert, image, !saveCorr);
434   fSSDRawsOffset += 1;
435   TH1F *fHistSSDDataSizePercentage = new TH1F("fHistSSDDataSizePercentage",
436                                               "SSD Data Size Percentage;SSD data size [%];Events",
437                                               1000,0,100);
438   rv = fAliITSQADataMakerRec->Add2RawsList(fHistSSDDataSizePercentage, 
439                                            offsRw+fSSDRawsOffset, expert, !image, !saveCorr);
440   fSSDRawsOffset += 1;
441   TH1F *fHistSSDDDLId = new TH1F("fHistSSDDDLId",
442                                  "SSD DDL Id;DDL id;Events",16,511.5,527.5);
443   fHistSSDDDLId->SetStats(kFALSE);
444   rv = fAliITSQADataMakerRec->Add2RawsList(fHistSSDDDLId, 
445                                            offsRw+fSSDRawsOffset, expert, !image, !saveCorr);
446   fSSDRawsOffset += 1;
447   TH1F *fHistSSDDataSizePerDDL = new TH1F("fHistSSDDataSizePerDDL",
448                                           "SSD Data Size Per DDL;DDL id;<SSD data size> [KB]",
449                                           16,511.5,527.5);
450   fHistSSDDataSizePerDDL->SetStats(kFALSE);
451   rv = fAliITSQADataMakerRec->Add2RawsList(fHistSSDDataSizePerDDL, 
452                                            offsRw+fSSDRawsOffset, !expert, image, !saveCorr);
453
454   fSSDRawsOffset += 1;
455   TH1F *fHistSSDDataSizeDDL[fgkNumOfDDLs];
456   for(Int_t i = 1; i < fgkNumOfDDLs+1; i++) {
457     gName = Form("fHistSSDDataSizeDDL%d", i+511) ;
458     gTitle = Form("SSD Data Size DDL %d", i+511) ;
459     fHistSSDDataSizeDDL[i-1] = new TH1F(gName.Data(),
460                                         Form("%s;(SSD data size) [KB];Events", gTitle.Data()),
461                                         100,0,50);
462     rv = fAliITSQADataMakerRec->Add2RawsList(fHistSSDDataSizeDDL[i-1], 
463                                              offsRw+fSSDRawsOffset, expert, !image, !saveCorr);
464     fSSDRawsOffset += 1;
465   }
466   
467   TH1F *fHistSSDLDCId = new TH1F("fHistSSDLDCId","SSD LDC Id;LDC id;Events",8,169.5,177.5);
468   fHistSSDLDCId->SetStats(kFALSE);
469   rv = fAliITSQADataMakerRec->Add2RawsList(fHistSSDLDCId, 
470                                            offsRw+fSSDRawsOffset, expert, !image, !saveCorr);
471   fSSDRawsOffset += 1;
472   TH1F *fHistSSDDataSizePerLDC = new TH1F("fHistSSDDataSizePerLDC",
473                                           "SSD Data Size Per LDC;LDC id;<SSD data size> [KB]",
474                                           8,169.5,177.5);
475   fHistSSDDataSizePerLDC->SetStats(kFALSE);
476   rv = fAliITSQADataMakerRec->Add2RawsList(fHistSSDDataSizePerLDC, 
477                                            offsRw+fSSDRawsOffset, expert, !image, !saveCorr);  fSSDRawsOffset += 1;
478   TH1F *fHistSSDDataSizeLDC[fgkNumOfLDCs];
479   for(Int_t i = 1; i < fgkNumOfLDCs+1; i++) {
480     gName = "fHistSSDDataSizeLDC"; 
481     if(i == 1) gName += "170";
482     if(i == 2) gName += "171";
483     if(i == 3) gName += "172";
484     if(i == 4) gName += "173";
485     if(i == 5) gName += "174";
486     if(i == 6) gName += "175";
487     if(i == 7) gName += "176";
488     if(i == 8) gName += "177";
489     
490     gTitle = "SSD Data Size LDC "; gTitle += gName.Data();
491     fHistSSDDataSizeLDC[i-1] = new TH1F(gName.Data(),
492                                         Form("%s;SSD data size [KB];Events", gTitle.Data()),
493                                         1000,0,100);
494     rv = fAliITSQADataMakerRec->Add2RawsList(fHistSSDDataSizeLDC[i-1], 
495                                              offsRw+fSSDRawsOffset, expert, !image, !saveCorr);
496     fSSDRawsOffset += 1;
497   }
498   fSSDRawsCommonLevelOffset = fSSDRawsOffset;
499   
500   if(fkOnline) {
501     Int_t gLayer = 0, gLadder = 0, gModule = 0;
502     //occupancy per SSD module
503     TH1F *fHistSSDOccupancyModule[fgkSSDMODULES]; 
504     for(Int_t i = 500; i < fgkSSDMODULES + 500; i++) {
505       AliITSgeomTGeo::GetModuleId(i,gLayer,gLadder,gModule);
506       gName = "fHistSSD_Occupancy_Layer";
507       gTitle = "SSD Occupancy Layer";
508       if(gLayer == 5) {
509         gName += gLayer; gName += "_Ladder"; 
510         gName += 499+gLadder;
511         gTitle += gLayer; gTitle += "_Ladder"; 
512         gTitle += 499+gLadder;
513       }
514       if(gLayer == 6) {
515         gName += gLayer; gName += "_Ladder"; 
516         gName += 599+gLadder;
517         gTitle += gLayer; gTitle += "_Ladder"; 
518         gTitle += 599+gLadder;
519       }
520       gName += "_Module"; gName += gModule; 
521       gTitle += "_Module"; gTitle += gModule; 
522       
523       fHistSSDOccupancyModule[i-500] = new TH1F(gName.Data(),Form("%s;N_{strip};Occupancy [%%]", gTitle.Data()),
524                                                 2*fgkNumberOfPSideStrips,0,2*fgkNumberOfPSideStrips);
525       fHistSSDOccupancyModule[i-500]->GetXaxis()->SetTitleColor(1);
526       rv = fAliITSQADataMakerRec->Add2RawsList(fHistSSDOccupancyModule[i-500], 
527                                                offsRw+fSSDRawsOffset, expert, !image, !saveCorr);
528       fSSDRawsOffset += 1;
529     }
530     
531     //Occupancy per SSD ladder
532     Int_t occupancyCounter = 0;
533     TH1F *fHistSSDOccupancyLadder[2*(fgkSSDLADDERSLAYER5 + fgkSSDLADDERSLAYER6)];
534     for(Int_t iLayer = 5; iLayer < 7; iLayer++) {
535       for(Int_t iLadder = 1; iLadder < AliITSgeomTGeo::GetNLadders(iLayer) + 1; iLadder++) {
536         //P-side occupancy plots
537         gName  = "fHistSSD_Occupancy_Layer"; 
538         gTitle = "SSD Occupancy Layer"; 
539         if(iLayer == 5) {
540           gName += iLayer; gName += "_Ladder"; 
541           gName += 499+iLadder;
542           gTitle += iLayer; gTitle += "_Ladder"; 
543           gTitle += 499+iLadder;
544         }
545         if(iLayer == 6) {
546           gName += iLayer; gName += "_Ladder"; 
547           gName += 599+iLadder;
548           gTitle += iLayer; gTitle += "_Ladder"; 
549           gTitle += 599+iLadder;
550         }
551         gName += "_PSide";
552         gTitle += "_PSide";
553         fHistSSDOccupancyLadder[occupancyCounter] = new TH1F(gName.Data(),
554                                                              Form("%s;Module number;Occupancy [%%]", gTitle.Data()),
555                                                              AliITSgeomTGeo::GetNDetectors(iLayer),
556                                                              0.5,AliITSgeomTGeo::GetNDetectors(iLayer)+0.5);
557         fHistSSDOccupancyLadder[occupancyCounter]->GetXaxis()->SetTitleColor(1);
558         rv = fAliITSQADataMakerRec->Add2RawsList(fHistSSDOccupancyLadder[occupancyCounter], 
559                                                  offsRw+fSSDRawsOffset, expert, !image, !saveCorr);
560         occupancyCounter += 1; fSSDRawsOffset += 1;
561         //N-side occupancy plots
562         gName = "fHistSSD_Occupancy_Layer"; 
563         gTitle = "SSD Occupancy Layer"; 
564         if(iLayer == 5) {
565           gName += iLayer; gName += "_Ladder"; 
566           gName += 499+iLadder;
567           gTitle += iLayer; gTitle += "_Ladder"; 
568           gTitle += 499+iLadder;
569         }
570         if(iLayer == 6) {
571           gName += iLayer; gName += "_Ladder"; 
572           gName += 599+iLadder;
573           gTitle += iLayer; gTitle += "_Ladder"; 
574           gTitle += 599+iLadder;
575         }
576         gName += "_NSide";
577         gTitle += "_NSide";
578         fHistSSDOccupancyLadder[occupancyCounter] = new TH1F(gName.Data(),
579                                                              Form("%s;Module number;Occupancy [%%]", gTitle.Data()),
580                                                              AliITSgeomTGeo::GetNDetectors(iLayer),
581                                                              0.5,AliITSgeomTGeo::GetNDetectors(iLayer)+0.5);
582         fHistSSDOccupancyLadder[occupancyCounter]->GetXaxis()->SetTitleColor(1);
583         rv = fAliITSQADataMakerRec->Add2RawsList(fHistSSDOccupancyLadder[occupancyCounter], 
584                                                  offsRw+fSSDRawsOffset, expert, !image, !saveCorr);
585         occupancyCounter += 1; fSSDRawsOffset += 1;
586       }//ladder loop
587     }//layer loop
588
589     //top level occupancy plots
590     //occupancy per module - no threshold
591     TH2F *fHistSSDOccupancyLayer5 = new TH2F("fHistSSDOccupancyLayer5",
592                                              "SSD Occupancy (Layer 5) - No threshold;N_{modules};N_{Ladders}",
593                                              fgkSSDMODULESPERLADDERLAYER5,
594                                              0,fgkSSDMODULESPERLADDERLAYER5,
595                                              3*fgkSSDLADDERSLAYER5,
596                                              500,500+fgkSSDLADDERSLAYER5);  
597     fHistSSDOccupancyLayer5->GetZaxis()->SetRangeUser(0.0,100.0);
598     Char_t fLabel[3];
599     for(Int_t iBin = 1; iBin < fgkSSDMODULESPERLADDERLAYER5 + 1; iBin++){
600       snprintf(fLabel,2,"%d",iBin);
601       fHistSSDOccupancyLayer5->GetXaxis()->SetBinLabel(iBin,fLabel);
602     }
603     fHistSSDOccupancyLayer5->SetStats(kFALSE);
604     rv = fAliITSQADataMakerRec->Add2RawsList(fHistSSDOccupancyLayer5, 
605                                              offsRw+fSSDRawsOffset, expert, !image, !saveCorr);
606     fSSDRawsOffset += 1;
607     TH2F *fHistSSDOccupancyLayer6 = new TH2F("fHistSSDOccupancyLayer6",
608                                              "Occupancy per module (Layer 6) - No threshold;N_{modules};N_{Ladders}",
609                                              fgkSSDMODULESPERLADDERLAYER6,
610                                              0,fgkSSDMODULESPERLADDERLAYER6,
611                                              3*fgkSSDLADDERSLAYER6,
612                                              600,600+fgkSSDLADDERSLAYER6);
613     fHistSSDOccupancyLayer6->GetZaxis()->SetRangeUser(0.0,100.0);
614     for(Int_t iBin = 1; iBin < fgkSSDMODULESPERLADDERLAYER6 + 1; iBin++){
615       snprintf(fLabel,2,"%d",iBin);
616       fHistSSDOccupancyLayer6->GetXaxis()->SetBinLabel(iBin,fLabel);
617     }
618     fHistSSDOccupancyLayer6->SetStats(kFALSE);
619     rv = fAliITSQADataMakerRec->Add2RawsList(fHistSSDOccupancyLayer6, 
620                                              offsRw+fSSDRawsOffset, expert, !image, !saveCorr);
621     fSSDRawsOffset += 1;
622
623     //occupancy per module - threshold @ 3%
624     TH2F *fHistSSDOccupancyThresholdLayer5 = new TH2F("fHistSSDOccupancyThresholdLayer5",
625                                                       "Occupancy per module (Layer 5) - Threshold 3%;N_{modules};N_{Ladders};Entries",
626                                                       fgkSSDMODULESPERLADDERLAYER5,
627                                                       0,fgkSSDMODULESPERLADDERLAYER5,
628                                                       3*fgkSSDLADDERSLAYER5,
629                                                       500,500+fgkSSDLADDERSLAYER5);  
630     fHistSSDOccupancyThresholdLayer5->GetZaxis()->SetRangeUser(3.0,10.0);
631     for(Int_t iBin = 1; iBin < fgkSSDMODULESPERLADDERLAYER5 + 1; iBin++){
632       snprintf(fLabel,2,"%d",iBin);
633       fHistSSDOccupancyThresholdLayer5->GetXaxis()->SetBinLabel(iBin,fLabel);
634     }
635     fHistSSDOccupancyThresholdLayer5->SetStats(kFALSE);
636     rv = fAliITSQADataMakerRec->Add2RawsList(fHistSSDOccupancyThresholdLayer5, 
637                                              offsRw+fSSDRawsOffset, expert, !image, !saveCorr);
638     fSSDRawsOffset += 1;
639     TH2F *fHistSSDOccupancyThresholdLayer6 = new TH2F("fHistSSDOccupancyThresholdLayer6",
640                                                       "Occupancy per module (Layer 6) - Threshold 3%;N_{modules};N_{Ladders}",
641                                                       fgkSSDMODULESPERLADDERLAYER6,
642                                                       0,fgkSSDMODULESPERLADDERLAYER6,
643                                                       3*fgkSSDLADDERSLAYER6,
644                                                       600,600+fgkSSDLADDERSLAYER6);
645     fHistSSDOccupancyThresholdLayer6->GetZaxis()->SetRangeUser(3.0,10.0);
646     for(Int_t iBin = 1; iBin < fgkSSDMODULESPERLADDERLAYER6 + 1; iBin++){
647       snprintf(fLabel,2,"%d",iBin);
648       fHistSSDOccupancyThresholdLayer6->GetXaxis()->SetBinLabel(iBin,fLabel);
649     }
650     fHistSSDOccupancyThresholdLayer6->SetStats(kFALSE);
651     rv = fAliITSQADataMakerRec->Add2RawsList(fHistSSDOccupancyThresholdLayer6, 
652                                              offsRw+fSSDRawsOffset, expert, !image, !saveCorr);
653     fSSDRawsOffset += 1;
654
655     //Average occupancy per module
656     TH2F *fHistSSDAverageOccupancyLayer5 = new TH2F("fHistSSDAverageOccupancyLayer5",
657                                                     "Average occupancy per module (Layer 5);N_{modules};N_{Ladders}",
658                                                     fgkSSDMODULESPERLADDERLAYER5,
659                                                     0,fgkSSDMODULESPERLADDERLAYER5,
660                                                     3*fgkSSDLADDERSLAYER5,
661                                                     500,500+fgkSSDLADDERSLAYER5);  
662     fHistSSDAverageOccupancyLayer5->GetZaxis()->SetRangeUser(0.0,5.0);
663     for(Int_t iBin = 1; iBin < fgkSSDMODULESPERLADDERLAYER5 + 1; iBin++){
664       snprintf(fLabel,2,"%d",iBin);
665       fHistSSDAverageOccupancyLayer5->GetXaxis()->SetBinLabel(iBin,fLabel);
666     }
667     fHistSSDAverageOccupancyLayer5->SetStats(kFALSE);
668     rv = fAliITSQADataMakerRec->Add2RawsList(fHistSSDAverageOccupancyLayer5, 
669                                              offsRw+fSSDRawsOffset, !expert, image, !saveCorr);
670     fSSDRawsOffset += 1;
671     TH2F *fHistSSDAverageOccupancyLayer6 = new TH2F("fHistSSDAverageOccupancyLayer6",
672                                                     "Average occupancy per module (Layer 6);N_{modules};N_{Ladders}",
673                                                     fgkSSDMODULESPERLADDERLAYER6,
674                                                     0,fgkSSDMODULESPERLADDERLAYER6,
675                                                     3*fgkSSDLADDERSLAYER6,
676                                                     600,600+fgkSSDLADDERSLAYER6);
677     fHistSSDAverageOccupancyLayer6->GetZaxis()->SetRangeUser(0.0,5.0);
678     for(Int_t iBin = 1; iBin < fgkSSDMODULESPERLADDERLAYER6 + 1; iBin++){
679       snprintf(fLabel,2,"%d",iBin);
680       fHistSSDAverageOccupancyLayer6->GetXaxis()->SetBinLabel(iBin,fLabel);
681     }
682     fHistSSDAverageOccupancyLayer6->SetStats(kFALSE);
683     rv = fAliITSQADataMakerRec->Add2RawsList(fHistSSDAverageOccupancyLayer6, 
684                                              offsRw+fSSDRawsOffset, !expert, image, !saveCorr);
685     fSSDRawsOffset += 1;
686
687     //Output of the DA
688     TH2F *fHistSSDPSideBadChannelMapLayer5 = new TH2F("fHistSSDPSideBadChannelMapLayer5",
689                                                       "Layer 5;N_{module};N_{ladder}",
690                                                       22,1,23,
691                                                       34,500,534);
692     fHistSSDPSideBadChannelMapLayer5->GetXaxis()->SetTitleColor(1);
693     fHistSSDPSideBadChannelMapLayer5->SetStats(kFALSE);
694     fHistSSDPSideBadChannelMapLayer5->GetYaxis()->SetTitleOffset(1.8);
695     fHistSSDPSideBadChannelMapLayer5->GetXaxis()->SetNdivisions(22);
696     fHistSSDPSideBadChannelMapLayer5->GetYaxis()->SetNdivisions(34);
697     fHistSSDPSideBadChannelMapLayer5->GetXaxis()->SetLabelSize(0.03);
698     fHistSSDPSideBadChannelMapLayer5->GetYaxis()->SetLabelSize(0.03);
699     fHistSSDPSideBadChannelMapLayer5->GetZaxis()->SetTitleOffset(1.6);
700     fHistSSDPSideBadChannelMapLayer5->GetZaxis()->SetTitle("Bad channels (p-side)[%]");
701     rv = fAliITSQADataMakerRec->Add2RawsList(fHistSSDPSideBadChannelMapLayer5, 
702                                              offsRw+fSSDRawsOffset, expert, !image, !saveCorr);
703     fSSDRawsOffset += 1; fSSDRawsDAOffset += 1;
704     
705     TH2F *fHistSSDNSideBadChannelMapLayer5 = new TH2F("fHistSSDNSideBadChannelMapLayer5",
706                                                       "Layer 5;N_{module};N_{ladder}",
707                                                       22,1,23,
708                                                       34,500,534);
709     fHistSSDNSideBadChannelMapLayer5->GetXaxis()->SetTitleColor(1);
710     fHistSSDNSideBadChannelMapLayer5->SetStats(kFALSE);
711     fHistSSDNSideBadChannelMapLayer5->GetYaxis()->SetTitleOffset(1.8);
712     fHistSSDNSideBadChannelMapLayer5->GetXaxis()->SetNdivisions(22);
713     fHistSSDNSideBadChannelMapLayer5->GetYaxis()->SetNdivisions(34);
714     fHistSSDNSideBadChannelMapLayer5->GetXaxis()->SetLabelSize(0.03);
715     fHistSSDNSideBadChannelMapLayer5->GetYaxis()->SetLabelSize(0.03);
716     fHistSSDNSideBadChannelMapLayer5->GetZaxis()->SetTitleOffset(1.6);
717     fHistSSDNSideBadChannelMapLayer5->GetZaxis()->SetTitle("Bad channels (n-side)[%]");
718     rv = fAliITSQADataMakerRec->Add2RawsList(fHistSSDNSideBadChannelMapLayer5, 
719                                              offsRw+fSSDRawsOffset, expert, !image, !saveCorr);
720     fSSDRawsOffset += 1; fSSDRawsDAOffset += 1;
721     
722     TH2F *fHistSSDPSideBadChannelMapLayer6 = new TH2F("fHistSSDPSideBadChannelMapLayer6",
723                                                       "Layer 6;N_{module};N_{ladder}",
724                                                       25,1,26,
725                                                       38,600,638);
726     fHistSSDPSideBadChannelMapLayer6->GetXaxis()->SetTitleColor(1);
727     fHistSSDPSideBadChannelMapLayer6->SetStats(kFALSE);
728     fHistSSDPSideBadChannelMapLayer6->GetYaxis()->SetTitleOffset(1.8);
729     fHistSSDPSideBadChannelMapLayer6->GetXaxis()->SetNdivisions(25);
730     fHistSSDPSideBadChannelMapLayer6->GetYaxis()->SetNdivisions(38);
731     fHistSSDPSideBadChannelMapLayer6->GetXaxis()->SetLabelSize(0.03);
732     fHistSSDPSideBadChannelMapLayer6->GetYaxis()->SetLabelSize(0.03);
733     fHistSSDPSideBadChannelMapLayer6->GetZaxis()->SetTitleOffset(1.6);
734     fHistSSDPSideBadChannelMapLayer6->GetZaxis()->SetTitle("Bad channels (p-side)[%]");
735     rv = fAliITSQADataMakerRec->Add2RawsList(fHistSSDPSideBadChannelMapLayer6, 
736                                              offsRw+fSSDRawsOffset, expert, !image, !saveCorr);
737     fSSDRawsOffset += 1; fSSDRawsDAOffset += 1;
738     
739     TH2F *fHistSSDNSideBadChannelMapLayer6 = new TH2F("fHistSSDNSideBadChannelMapLayer6",
740                                                       "Layer 6;N_{module};N_{ladder}",
741                                                       25,1,26,
742                                                       38,600,638);
743     fHistSSDNSideBadChannelMapLayer6->GetXaxis()->SetTitleColor(1);
744     fHistSSDNSideBadChannelMapLayer6->SetStats(kFALSE);
745     fHistSSDNSideBadChannelMapLayer6->GetYaxis()->SetTitleOffset(1.8);
746     fHistSSDNSideBadChannelMapLayer6->GetXaxis()->SetNdivisions(25);
747     fHistSSDNSideBadChannelMapLayer6->GetYaxis()->SetNdivisions(38);
748     fHistSSDNSideBadChannelMapLayer6->GetXaxis()->SetLabelSize(0.03);
749     fHistSSDNSideBadChannelMapLayer6->GetYaxis()->SetLabelSize(0.03);
750     fHistSSDNSideBadChannelMapLayer6->GetZaxis()->SetTitleOffset(1.6);
751     fHistSSDNSideBadChannelMapLayer6->GetZaxis()->SetTitle("Bad channels (n-side)[%]");
752     rv = fAliITSQADataMakerRec->Add2RawsList(fHistSSDNSideBadChannelMapLayer6, 
753                                              offsRw+fSSDRawsOffset, expert, !image, !saveCorr);
754     fSSDRawsOffset += 1; fSSDRawsDAOffset += 1;
755
756     //Common mode values
757     TH2F *fHistSSDPSideCommonModeMapLayer5 = new TH2F("fHistSSDPSideCommonModeMapLayer5",
758                                                       "Layer 5 - CM (P-side);N_{module};N_{ladder}",
759                                                       22,1,23,
760                                                       34,500,534);
761     fHistSSDPSideCommonModeMapLayer5->GetXaxis()->SetTitleColor(1);
762     fHistSSDPSideCommonModeMapLayer5->SetStats(kFALSE);
763     fHistSSDPSideCommonModeMapLayer5->GetYaxis()->SetTitleOffset(1.8);
764     fHistSSDPSideCommonModeMapLayer5->GetXaxis()->SetNdivisions(22);
765     fHistSSDPSideCommonModeMapLayer5->GetYaxis()->SetNdivisions(34);
766     fHistSSDPSideCommonModeMapLayer5->GetXaxis()->SetLabelSize(0.03);
767     fHistSSDPSideCommonModeMapLayer5->GetYaxis()->SetLabelSize(0.03);
768     fHistSSDPSideCommonModeMapLayer5->GetZaxis()->SetTitleOffset(1.6);
769     fHistSSDPSideCommonModeMapLayer5->GetZaxis()->SetTitle("RMS(CM) (P-side)");
770     rv = fAliITSQADataMakerRec->Add2RawsList(fHistSSDPSideCommonModeMapLayer5, 
771                                              offsRw+fSSDRawsOffset, expert, !image, !saveCorr);
772     fSSDRawsOffset += 1; fSSDRawsDAOffset += 1;
773     
774     TH2F *fHistSSDNSideCommonModeMapLayer5 = new TH2F("fHistSSDNSideCommonModeMapLayer5",
775                                                       "Layer 5 - CM (N-side);N_{module};N_{ladder}",
776                                                       22,1,23,
777                                                       34,500,534);
778     fHistSSDNSideCommonModeMapLayer5->GetXaxis()->SetTitleColor(1);
779     fHistSSDNSideCommonModeMapLayer5->SetStats(kFALSE);
780     fHistSSDNSideCommonModeMapLayer5->GetYaxis()->SetTitleOffset(1.8);
781     fHistSSDNSideCommonModeMapLayer5->GetXaxis()->SetNdivisions(22);
782     fHistSSDNSideCommonModeMapLayer5->GetYaxis()->SetNdivisions(34);
783     fHistSSDNSideCommonModeMapLayer5->GetXaxis()->SetLabelSize(0.03);
784     fHistSSDNSideCommonModeMapLayer5->GetYaxis()->SetLabelSize(0.03);
785     fHistSSDNSideCommonModeMapLayer5->GetZaxis()->SetTitleOffset(1.6);
786     fHistSSDNSideCommonModeMapLayer5->GetZaxis()->SetTitle("RMS(CM) (N-side)");
787     rv = fAliITSQADataMakerRec->Add2RawsList(fHistSSDNSideCommonModeMapLayer5, 
788                                              offsRw+fSSDRawsOffset, expert, !image, !saveCorr);
789     fSSDRawsOffset += 1; fSSDRawsDAOffset += 1;
790     
791     TH2F *fHistSSDPSideCommonModeMapLayer6 = new TH2F("fHistSSDPSideCommonModeMapLayer6",
792                                                       "Layer 6 - CM (P-side);N_{module};N_{ladder}",
793                                                       25,1,26,
794                                                       38,600,638);
795     fHistSSDPSideCommonModeMapLayer6->GetXaxis()->SetTitleColor(1);
796     fHistSSDPSideCommonModeMapLayer6->SetStats(kFALSE);
797     fHistSSDPSideCommonModeMapLayer6->GetYaxis()->SetTitleOffset(1.8);
798     fHistSSDPSideCommonModeMapLayer6->GetXaxis()->SetNdivisions(25);
799     fHistSSDPSideCommonModeMapLayer6->GetYaxis()->SetNdivisions(38);
800     fHistSSDPSideCommonModeMapLayer6->GetXaxis()->SetLabelSize(0.03);
801     fHistSSDPSideCommonModeMapLayer6->GetYaxis()->SetLabelSize(0.03);
802     fHistSSDPSideCommonModeMapLayer6->GetZaxis()->SetTitleOffset(1.6);
803     fHistSSDPSideCommonModeMapLayer6->GetZaxis()->SetTitle("RMS(CM) (P-side)");
804     rv = fAliITSQADataMakerRec->Add2RawsList(fHistSSDPSideCommonModeMapLayer6, 
805                                              offsRw+fSSDRawsOffset, expert, !image, !saveCorr);
806     fSSDRawsOffset += 1; fSSDRawsDAOffset += 1;
807     
808     TH2F *fHistSSDNSideCommonModeMapLayer6 = new TH2F("fHistSSDNSideCommonModeMapLayer6",
809                                                       "Layer 6 - CM (N-side);N_{module};N_{ladder}",
810                                                       25,1,26,
811                                                       38,600,638);
812     fHistSSDNSideCommonModeMapLayer6->GetXaxis()->SetTitleColor(1);
813     fHistSSDNSideCommonModeMapLayer6->SetStats(kFALSE);
814     fHistSSDNSideCommonModeMapLayer6->GetYaxis()->SetTitleOffset(1.8);
815     fHistSSDNSideCommonModeMapLayer6->GetXaxis()->SetNdivisions(25);
816     fHistSSDNSideCommonModeMapLayer6->GetYaxis()->SetNdivisions(38);
817     fHistSSDNSideCommonModeMapLayer6->GetXaxis()->SetLabelSize(0.03);
818     fHistSSDNSideCommonModeMapLayer6->GetYaxis()->SetLabelSize(0.03);
819     fHistSSDNSideCommonModeMapLayer6->GetZaxis()->SetTitleOffset(1.6);
820     fHistSSDNSideCommonModeMapLayer6->GetZaxis()->SetTitle("RMS(CM) (N-side)");
821     rv = fAliITSQADataMakerRec->Add2RawsList(fHistSSDNSideCommonModeMapLayer6, 
822                                              offsRw+fSSDRawsOffset, expert, !image, !saveCorr);
823     fSSDRawsOffset += 1; fSSDRawsDAOffset += 1;
824   }//online flag
825   
826   fSSDhRawsTask = fSSDRawsOffset;
827   AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SSD Raws histograms booked\n",fSSDhRawsTask));
828   AliDebug(AliQAv1::GetQADebugLevel(), Form("Number of histograms (SPD+SDD+SSD): %d\n",offsRw+fSSDhRawsTask));  
829   AliDebug(AliQAv1::GetQADebugLevel(),Form("Number of histograms (SPD+SDD+SSD): %d\n",offsRw+fSSDRawsOffset));
830   
831   /*
832     fSSDhTask = fSSDRawsOffset;
833     AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SSD Raws histograms booked\n",fSSDhTask));
834     AliDebug(AliQAv1::GetQADebugLevel(), Form("Number of histograms (SPD+SDD+SSD): %d\n",offsRw+fSSDhTask));  
835     AliDebug(AliQAv1::GetQADebugLevel(),Form("Number of histograms (SPD+SDD+SSD): %d\n",offsRw+fSSDRawsOffset));
836   */
837
838
839   //} //event species loop
840
841   return rv ; 
842
843
844 }
845
846 //____________________________________________________________________________
847 Int_t AliITSQASSDDataMakerRec::MakeRaws(AliRawReader* rawReader) 
848
849   // Fill QA for RAW - SSD -
850   Int_t rv = 0 ; 
851   Int_t gStripNumber;
852   Int_t gHistPosition;
853   Int_t gLayer = 0,gLadder = 0, gModule = 0;
854
855   Double_t gSizePerDDL[fgkNumOfDDLs] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
856   Double_t gSizePerLDC[fgkNumOfLDCs] = {0.,0.,0.,0.,0.,0.,0.,0.};
857   Double_t sumSSDDataSize = 0.0;
858   Double_t eventSize = -1.0;
859
860   // RS: I've commented this loop over species: makes no sense in the event loop
861   //  for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
862   //    if (!AliQAv1::Instance()->IsEventSpecieSet(specie)) continue;
863   int specie = fAliITSQADataMakerRec->GetEventSpecie(); 
864   //cout << "MakeRaws: Event specie " << specie << " is set" << endl;
865   //
866   int offsRw = fGenRawsOffset[specie];
867   //
868   //AliInfo(Form("offsRw %d\n",offsRw));
869   if(fkOnline) {
870     //reset the signal vs strip number histograms
871     for(Int_t iModule = 0; iModule < fgkSSDMODULES; iModule++)
872       fHistSSDRawSignalModule[iModule]->Reset();
873   }//online flag
874   
875   rawReader->Select("ITSSSD",-1,-1);  
876   rawReader->Reset(); //rawReader->NextEvent();   
877   //AliInfo(Form("offsRw %d\n",offsRw));
878   fAliITSQADataMakerRec->FillRawsData(offsRw,rawReader->GetType());
879   
880   AliITSRawStreamSSD gSSDStream(rawReader);    
881   AliRawReaderRoot *rootReader = (AliRawReaderRoot *)rawReader;
882   if(rootReader) {
883     const AliRawEventHeaderBase *header = rootReader->GetEventHeader();
884     if(header)
885       eventSize = header->GetEventSize();
886   }
887   while (gSSDStream.Next()) {
888     if(gSSDStream.GetModuleID() < 0) continue;
889     /*cout<<"DDL: "<<rawReader->GetDDLID()<<
890       " - LDC: "<<rawReader->GetLDCId()<<
891       " - Size: "<<rawReader->GetDataSize()<<
892       " - Equipment size: "<<rawReader->GetEquipmentSize()<<endl;*/
893     Int_t ddlid = rawReader->GetDDLID();
894     if(ddlid<0){
895       AliError("GetDDLID returns a negative value");
896       continue;
897     }
898     gSizePerDDL[ddlid] = rawReader->GetDataSize();
899     //gSizePerLDC[rawReader->GetLDCId()-8] = rawReader->GetDataSize();
900     AliITSgeomTGeo::GetModuleId(gSSDStream.GetModuleID(),gLayer,gLadder,gModule);
901     gHistPosition = (gLayer == 5) ? ((gLadder - 1)*fgkSSDMODULESPERLADDERLAYER5 + gModule - 1) : ((gLadder - 1)*fgkSSDMODULESPERLADDERLAYER6 + gModule + fgkSSDMODULESLAYER5 - 1);
902     if(fkOnline) {
903       if(gSSDStream.GetStrip() < 0) {
904         //Printf("Layer: %d - Ladder: %d - Module: %d - Strip: %d - Signal: %lf",gLayer,gLadder,gModule,gSSDStream.GetStrip(),gSSDStream.GetSignal());
905         if(TMath::Abs(gSSDStream.GetStrip()) < 7)
906           fHistSSDCMModule[gHistPosition]->Fill(gSSDStream.GetSignal());
907         if(TMath::Abs(gSSDStream.GetStrip()) > 6)
908           fHistSSDCMModule[fgkSSDMODULES+gHistPosition]->Fill(gSSDStream.GetSignal());
909       }//CM values
910       else {
911         gStripNumber = (gSSDStream.GetSideFlag() == 0) ? gSSDStream.GetStrip() : -gSSDStream.GetStrip() + 2*fgkNumberOfPSideStrips;
912         //AliDebug(AliQAv1::GetQADebugLevel(), Form("ModulePosition: %d - Layer: %d - Ladder: %d - Module: %d\n",gHistPosition,gLayer,gLadder,gModule));
913         fHistSSDRawSignalModule[gHistPosition]->Fill(gStripNumber,gSSDStream.GetSignal());
914         //fAliITSQADataMakerRec->FillRawsData(offsRw+gHistPosition+fSSDRawsCommonLevelOffset,gStripNumber,gSSDStream.GetSignal());
915       }//normal strip signal
916     }//online flag
917   }//streamer loop   
918   
919   //event size calculation and filling info
920   for(Int_t i = 0; i < fgkNumOfDDLs; i++) {
921     sumSSDDataSize += gSizePerDDL[i];
922     if(gSizePerDDL[i] > 0) {
923       fAliITSQADataMakerRec->FillRawsData(offsRw+3,i+512);
924       fAliITSQADataMakerRec->FillRawsData(offsRw+5+i,gSizePerDDL[i]/1e+03);
925       //if(i == 5)
926       //cout<<gSizePerDDL[i]/1e+03<<endl;
927       //cout<<"Event: "<<nSSDEventPerCycle<<" - DDL: "<<i+512<<
928       //" - Data size: "<<gSizePerDDL[i]/1e+03<<endl;
929     }
930     //(fAliITSQADataMakerRec->FillRawsData(offsRw+4),i+512,gSizePerDDL[i]/1e+06);
931   }
932   for(Int_t i = 0; i < fgkNumOfLDCs; i++) {
933     //LDC 170
934     if(i == 0)
935       gSizePerLDC[i] = gSizePerDDL[8] + gSizePerDDL[9];
936     //LDC 171
937     if(i == 1)
938       gSizePerLDC[i] = gSizePerDDL[10] + gSizePerDDL[11];
939     //LDC 172
940     if(i == 2)
941       gSizePerLDC[i] = gSizePerDDL[12] + gSizePerDDL[13];
942     //LDC 173
943     if(i == 3)
944       gSizePerLDC[i] = gSizePerDDL[14] + gSizePerDDL[15];
945     //LDC 174
946     if(i == 4)
947       gSizePerLDC[i] = gSizePerDDL[0] + gSizePerDDL[1];
948     //LDC 175
949     if(i == 5)
950       gSizePerLDC[i] = gSizePerDDL[2] + gSizePerDDL[3];
951       //LDC 176
952     if(i == 6)
953       gSizePerLDC[i] = gSizePerDDL[4] + gSizePerDDL[5];
954     //LDC 177
955     if(i == 7)
956       gSizePerLDC[i] = gSizePerDDL[6] + gSizePerDDL[7];
957     
958     if(gSizePerLDC[i] > 0) fAliITSQADataMakerRec->FillRawsData(offsRw+21,i+170);
959     fAliITSQADataMakerRec->FillRawsData(offsRw+23+i,gSizePerLDC[i]/1e+03);
960     //cout<<"Event: "<<nSSDEventPerCycle<<" - LDC: "<<i+170<<
961     //" - Data size: "<<gSizePerLDC[i]<<endl;
962     
963     //(fAliITSQADataMakerRec->FillRawsData(offsRw+22),i+6,gSizePerLDC[i]/1e+06);
964   }
965   
966   // RS Invalid
967   //    for(Int_t i = 0; i < fgkNumOfDDLs; i++) {
968   //      Double_t gSizePerDDL = ((TH1F *)fAliITSQADataMakerRec->GetRawsData(offsRw+5+i))->GetMean();
969   //if(i == 5)
970   //cout<<"DDL: "<<i+512<<" - Size: "<<gSizePerDDL<<
971   //" - Mean: "<<((TH1F *)fAliITSQADataMakerRec->GetRawsData(offsRw+5+i))->GetMean()<<endl;
972   //    }
973   
974   if(sumSSDDataSize) fAliITSQADataMakerRec->FillRawsData(offsRw+1,sumSSDDataSize/1e+03);
975   if(eventSize) fAliITSQADataMakerRec->FillRawsData(offsRw+2,100.*sumSSDDataSize/eventSize);
976   
977   //Occupancy calculation
978   if(fkOnline) {
979     for(Int_t iModule = 0; iModule < fgkSSDMODULES; iModule++) {
980       GetOccupancyStrip(fHistSSDRawSignalModule[iModule],fOccupancyMatrix[iModule]);
981       //if(iModule == 156) {    
982       //cout<<"========================================"<<endl;
983       //AliITSgeomTGeo::GetModuleId(656,gLayer,gLadder,gModule);
984       /*for(Int_t iBin = 1; iBin < fHistSSDRawSignalModule[iModule]->GetXaxis()->GetNbins(); iBin++) {
985         if((iBin >= 750)&&(iBin <= 780))
986         cout<<"Event: "<<nSSDEventPerCycle<<" - Ladder: "<<gLadder+499<<
987         " - Module: "<<gModule<<" - Strip: "<<iBin<<
988         " - Signal: "<<fHistSSDRawSignalModule[iModule]->GetBinContent(iBin)<<endl;
989         }*///strip loop --> to be removed
990       //}//module cut --> to be removed
991     }//module loop
992   }//online flag for SSD
993   
994   // RS Invalid
995   //cout<<"Event type entries: "<<((TH1*)fAliITSQADataMakerRec->GetRawsData(offsRw))->GetEntries()<<endl;
996   //cout<<"DDL id entries at MR: "<<((TH1F *)fAliITSQADataMakerRec->GetRawsData(offsRw+3))->GetEntries()<< endl;    
997   //cout<<"LDC id entries at MR: "<<((TH1F *)fAliITSQADataMakerRec->GetRawsData(offsRw+21))->GetEntries()<< endl; 
998   
999   //  } //event species loop // commented by RS
1000   //
1001   return rv ; 
1002 }
1003
1004 //____________________________________________________________________________ //
1005 void AliITSQASSDDataMakerRec::GetOccupancyStrip(TH1 *lHisto, Int_t *occupancyMatrix) { 
1006   //Increments the entries in the occupancy matrix based 
1007   //on whether the signal for each strip is larger than the cutoff
1008   //Currently the cutoff is at 0 which means that if ZS
1009   //works, whatever comes from the FEROM is considered as "signal"
1010   //Double_t cutoff = 0.0;
1011   TString histname = lHisto->GetName();
1012   //cout<<histname.Data()<<endl;
1013   //if(histname.Contains("Layer5_Ladder8_Module3")) {
1014   for(Int_t iBin = 1; iBin < lHisto->GetXaxis()->GetNbins(); iBin++) {
1015     Double_t y = lHisto->GetBinContent(iBin);
1016     if(y) {
1017       occupancyMatrix[iBin-1] += 1;
1018     }
1019     //if((iBin >= 750)&&(iBin <= 780))
1020     //cout<<"Strip: "<<iBin<<
1021     //" - Signal: "<<y<<
1022     //" - Occupancy: "<<occupancyMatrix[iBin-1]<<endl;
1023     
1024   }
1025   //}
1026 }
1027
1028 //____________________________________________________________________________ 
1029 Double_t AliITSQASSDDataMakerRec::GetOccupancyModule(TH1 *lHisto, 
1030                                                      Int_t stripside,
1031                                                      Int_t mode,
1032                                                      Double_t threshold) {
1033   //Mode 0: calculates the occupancy of a module 
1034   //        without a threshold in the strip occupancy
1035   //Mode 1: calculates the occupancy of a module 
1036   //        with the set threshold in the strip occupancy
1037   //Mode 2: calculates the average occupancy of a module 
1038
1039   // bo: TDC >0 or # of sigmas wrt noise ?
1040   //stripside == 0 --> P-side
1041   //stripside == 1 --> N-side
1042   Int_t lNumFiredBins = 0;
1043   Double_t sumOccupancy = 0.0;
1044   TString histname = lHisto->GetName();
1045   for(Int_t iBin = 1 + stripside*fgkNumberOfPSideStrips; iBin < fgkNumberOfPSideStrips*(1 + stripside); iBin++){
1046     /*if(histname.Contains("Layer5_Ladder507_Module3")) {
1047       cout<<lHisto->GetName()<<
1048       " - Strip: "<<iBin<<
1049       " - Bin content: "<<lHisto->GetBinContent(iBin)<<endl;
1050       }*/
1051     if (lHisto->GetBinContent(iBin) > threshold) {
1052       lNumFiredBins++; 
1053       sumOccupancy = lHisto->GetBinContent(iBin);
1054     }
1055   }
1056   
1057   Double_t lOccupancy = 0.0;
1058   if((mode == 0)||(mode == 1))
1059     lOccupancy = (100.*lNumFiredBins)/fgkNumberOfPSideStrips; // percentage  
1060   else if(mode == 2)
1061     lOccupancy = 100.*sumOccupancy/fgkNumberOfPSideStrips;
1062
1063   /* if(histname.Contains("Layer5_Ladder507_Module3"))
1064      cout<<"Fired strips: "<<lNumFiredBins<<
1065      " - Occupancy: "<<lOccupancy<<endl;*/
1066   ;
1067   //AliDebug(AliQAv1::GetQADebugLevel(), Form("Fired strips: %d - Total strips: %d - Occupancy :%lf\n",lNumFiredBins,lHisto->GetNbinsX(),lOccupancy));
1068   
1069   return lOccupancy;
1070 }
1071
1072 //____________________________________________________________________________
1073 void AliITSQASSDDataMakerRec::MonitorCMValues(Int_t trCl) 
1074 {
1075   //Monitor in AMORE the CM values
1076   //for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
1077   //if (!AliQAv1::Instance()->IsEventSpecieSet(specie)) continue;
1078   //cout << "MonitorCMValues: Event specie " << specie << " is set" << endl;
1079   Int_t specie = fAliITSQADataMakerRec->GetEventSpecie();
1080   int offsRw = fGenRawsOffset[specie];
1081    
1082   //compute the rms of the CM values
1083   Int_t gLayer = 0, gLadder = 0, gModule = 0;
1084   Double_t rmsPsideCM = 0.0, rmsNsideCM = 0.0;
1085   for(Int_t i = 0; i < fgkSSDMODULES; i++) {
1086     rmsPsideCM = 0.0; rmsNsideCM = 0.0;
1087     AliITSgeomTGeo::GetModuleId(i+500,gLayer,gLadder,gModule);
1088     //Printf("%s - %s",((TH1*)list->At(i))->GetName(),
1089     //((TH1*)list->At(1698+i))->GetName());
1090     rmsPsideCM = fHistSSDCMModule[i]->GetRMS();
1091     rmsNsideCM = fHistSSDCMModule[fgkSSDMODULES+i]->GetRMS();
1092     //Printf("rmsPside: %lf - rmsNside: %lf",rmsPsideCM,rmsNsideCM);
1093     if(gLayer == 5) {
1094       TH2* h4 = (TH2*)fAliITSQADataMakerRec->GetRawsData(offsRw+fSSDRawsOffset-fSSDRawsDAOffset+4,trCl);
1095       if (h4) h4->SetBinContent(gModule,gLadder,rmsPsideCM);
1096       TH2* h5 = (TH2*)fAliITSQADataMakerRec->GetRawsData(offsRw+fSSDRawsOffset-fSSDRawsDAOffset+5,trCl);
1097       if (h5) h5->SetBinContent(gModule,gLadder,rmsNsideCM);
1098     }
1099     if(gLayer == 6) {
1100       TH2* h6 = (TH2*)fAliITSQADataMakerRec->GetRawsData(offsRw+fSSDRawsOffset-fSSDRawsDAOffset+6,trCl);
1101       if (h6) h6->SetBinContent(gModule,gLadder,rmsPsideCM);
1102       TH2* h7 = (TH2*)fAliITSQADataMakerRec->GetRawsData(offsRw+fSSDRawsOffset-fSSDRawsDAOffset+7,trCl);
1103       if (h7) h7->SetBinContent(gModule,gLadder,rmsNsideCM);
1104     }
1105   }//module loopcdcd
1106    //}//event species loop
1107 }
1108
1109 //____________________________________________________________________________
1110 void AliITSQASSDDataMakerRec::MonitorOCDBObjects(Int_t trCl) 
1111
1112   //Monitor in AMORE the output of the DA
1113   //Currently only the bad channel list is monitored
1114   //Todo: Noise - Pedestal
1115
1116
1117   //for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
1118   //if (!AliQAv1::Instance()->IsEventSpecieSet(specie)) continue;
1119   //cout << "MonitorOCDBObjects: Event specie " << specie << " is set" << endl;
1120   Int_t specie = fAliITSQADataMakerRec->GetEventSpecie();
1121   int offsRw = fGenRawsOffset[specie];
1122   fAliITSQADataMakerRec->SetEventSpecie(AliRecoParam::ConvertIndex(specie));
1123   
1124   //((TH2F *)fAliITSQADataMakerRec->ResetRawsData(offsRw+fSSDRawsOffset-fSSDRawsDAOffset));
1125   //((TH2F *)fAliITSQADataMakerRec->ResetRawsData(offsRw+fSSDRawsOffset-fSSDRawsDAOffset+1));
1126   //((TH2F *)fAliITSQADataMakerRec->ResetRawsData(offsRw+fSSDRawsOffset-fSSDRawsDAOffset+2));
1127   //((TH2F *)fAliITSQADataMakerRec->ResetRawsData(offsRw+fSSDRawsOffset-fSSDRawsDAOffset+3));
1128   
1129   AliCDBEntry *entryBadChannelsSSD = fCDBManager->Get("ITS/Calib/BadChannelsSSD");
1130   if(!entryBadChannelsSSD)AliError("OCDB entry for the bad channel list is not valid!"); 
1131   AliITSBadChannelsSSDv2 *badchannelsSSD = NULL;
1132   if(entryBadChannelsSSD)badchannelsSSD = (AliITSBadChannelsSSDv2 *)entryBadChannelsSSD->GetObject();
1133   if(!badchannelsSSD)
1134     AliError("Bad channel list object is not a valid AliITSBadChannelsSSD object!");
1135
1136   //_____________________________________________________________________________//                       
1137   Int_t nBadPSideChannels = 0, nBadNSideChannels = 0;
1138   Int_t layer = 0, ladder = 0, module = 0;
1139   Int_t nPSideChannelsLayer5 = 0, nNSideChannelsLayer5 = 0;
1140   Int_t nPSideChannelsLayer6 = 0, nNSideChannelsLayer6 = 0;
1141   //_____________________________________________________________________________//                      
1142
1143   for(Int_t i = 0; i < fgkSSDMODULES; i++) {
1144     AliITSgeomTGeo::GetModuleId(i+500,layer,ladder,module);
1145     nBadPSideChannels = 0, nBadNSideChannels = 0;
1146     nPSideChannelsLayer5 = 0, nNSideChannelsLayer5 = 0;
1147     nPSideChannelsLayer6 = 0, nNSideChannelsLayer6 = 0;
1148
1149     Int_t badChannel = 0;
1150     if(badchannelsSSD){
1151       for(Int_t j = 0; j < fgkNumberOfPSideStrips; j++) {
1152         badChannel = (Int_t)(badchannelsSSD->GetBadChannelP(i,j));
1153         if(badChannel != 0) {
1154           if(layer == 5)
1155             nPSideChannelsLayer5 += 1;
1156           if(layer == 6)
1157             nPSideChannelsLayer6 += 1;
1158           nBadPSideChannels += 1;
1159         }//badchannel flag != 0
1160         badChannel = (Int_t)(badchannelsSSD->GetBadChannelN(i,j));
1161         if(badChannel != 0) {
1162           if(layer == 5)
1163             nNSideChannelsLayer5 += 1;
1164           if(layer == 6)
1165             nNSideChannelsLayer6 += 1;
1166           nBadNSideChannels += 1;
1167         }//badchannel flag != 0
1168       }//loop over strips
1169     }
1170
1171     //cout << "Bad channels P side module " << module << ": " << nBadPSideChannels << endl;
1172     //cout << "Bad channels N side module " << module << ": " << nBadNSideChannels << endl;
1173     
1174     if(layer == 5) {
1175       /*if((module == 10)&&(ladder == 10)) {
1176         cout<<"Npside bad: "<<nPSideChannelsLayer5<<" - Total: "<<fgkNumberOfPSideStrips<<" - Percentage: "<<(100.*nPSideChannelsLayer5/fgkNumberOfPSideStrips)<<endl;
1177         }*/
1178       TH2* h0 = (TH2*)fAliITSQADataMakerRec->GetRawsData(offsRw+fSSDRawsOffset-fSSDRawsDAOffset,trCl);
1179       if (h0) {
1180         if(nPSideChannelsLayer5 > 0) h0->SetBinContent(module,ladder,100.*nPSideChannelsLayer5/fgkNumberOfPSideStrips);
1181         else                         h0->SetBinContent(module,ladder,0.0001);
1182       }
1183       TH2* h1 = (TH2*)fAliITSQADataMakerRec->GetRawsData(offsRw+fSSDRawsOffset-fSSDRawsDAOffset+1,trCl);
1184       if (h1) {
1185         if(nNSideChannelsLayer5 > 0) h1->SetBinContent(module,ladder,100.*nNSideChannelsLayer5/fgkNumberOfPSideStrips);
1186         else                         h1->SetBinContent(module,ladder,0.0001);
1187       }
1188     }//layer 5                                                                    
1189     if(layer == 6) {
1190       TH2* h2 = (TH2*)fAliITSQADataMakerRec->GetRawsData(offsRw+fSSDRawsOffset-fSSDRawsDAOffset+2,trCl);
1191       if (h2) {
1192         if(nPSideChannelsLayer6 > 0) h2->SetBinContent(module,ladder,100.*nPSideChannelsLayer6/fgkNumberOfPSideStrips);
1193         else                         h2->SetBinContent(module,ladder,0.0001);
1194       }
1195       TH2* h3 = (TH2*)fAliITSQADataMakerRec->GetRawsData(offsRw+fSSDRawsOffset-fSSDRawsDAOffset+3,trCl);      
1196       if (h3) {
1197         if(nNSideChannelsLayer6 > 0) h3->SetBinContent(module,ladder,100.*nNSideChannelsLayer6/fgkNumberOfPSideStrips);
1198         else                         h3->SetBinContent(module,ladder,0.0001);
1199       }
1200     }//layer 6                                                              
1201   }//module loop
1202   
1203   //cout << "entries bad channel layer 5 n side " << ((TH2F *)fAliITSQADataMakerRec->GetRawsData(offsRw+fSSDRawsOffset-fSSDRawsDAOffset+1))->GetEntries() << " - Bad channels P side layer 5 module 10 ladder 10: " << ((TH2F *)fAliITSQADataMakerRec->GetRawsData(offsRw+fSSDRawsOffset-fSSDRawsDAOffset))->GetBinContent(10,10)<<endl;
1204
1205
1206   //} //event species loop
1207
1208
1209 }
1210
1211 //____________________________________________________________________________ 
1212 Int_t AliITSQASSDDataMakerRec::InitDigits() { 
1213   // Initialization for DIGIT data - SSD -
1214   const Bool_t expert   = kTRUE ; 
1215   const Bool_t image    = kTRUE ; 
1216   Int_t rv = 0 ; 
1217   //  fGenDigitsOffset = (fAliITSQADataMakerRec->fDigitsQAList[AliRecoParam::kDefault])->GetEntries();
1218   
1219   // custom code here
1220   TH1F *fHistSSDModule = new TH1F("fHistSSDDigitsModule",
1221                                   ";SSD Module Number;N_{DIGITS}",
1222                                   1698,499.5,2197.5);  
1223   rv =  fAliITSQADataMakerRec->Add2DigitsList(fHistSSDModule,
1224                                               fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 0, !expert, image);
1225   fSSDhDigitsTask += 1;
1226   TH2F *fHistSSDModuleStrip = new TH2F("fHistSSDDigitsModuleStrip",
1227                                        ";N_{Strip};N_{Module}",
1228                                        1540,0,1540,1698,499.5,2197.5);  
1229   rv = fAliITSQADataMakerRec->Add2DigitsList(fHistSSDModuleStrip,
1230                                              fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 1, !expert, image);
1231   fSSDhDigitsTask += 1;
1232   
1233   AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SSD Digits histograms booked\n",fSSDhDigitsTask));
1234   return rv ; 
1235 }
1236
1237 //____________________________________________________________________________
1238 Int_t AliITSQASSDDataMakerRec::MakeDigits(TTree *digits) 
1239
1240   // Fill QA for DIGIT - SSD -
1241   //  AliITS *fITS  = (AliITS*)gAlice->GetModule("ITS");
1242   //  fITS->SetTreeAddress();
1243   //  TClonesArray *iSSDdigits  = fITS->DigitsAddress(2);
1244   //  
1245   Int_t rv = 0 ; 
1246   TBranch *branchD = digits->GetBranch("ITSDigitsSSD");
1247   if (!branchD) { 
1248     AliError("can't get the branch with the SSD ITS digits !");
1249     return rv;
1250   }
1251   
1252   static TClonesArray statDigits("AliITSdigitSSD");
1253   TClonesArray *iSSDdigits = &statDigits;
1254   branchD->SetAddress(&iSSDdigits);  
1255   for(Int_t iModule = 500; iModule < 2198; iModule++) {
1256     iSSDdigits->Clear();
1257     digits->GetEvent(iModule);    
1258     Int_t ndigits = iSSDdigits->GetEntries();
1259     //printf("Module = %i \t ndigits = %i\t offset = %i \n",iModule,ndigits,fAliITSQADataMakerRec->GetEventSpecie() );
1260     fAliITSQADataMakerRec->FillDigitsData(fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 0,iModule,ndigits);
1261     if(ndigits != 0)
1262       AliDebug(AliQAv1::GetQADebugLevel(),Form("Module: %d - Digits: %d",iModule,ndigits));
1263     
1264     for (Int_t iDigit = 0; iDigit < ndigits; iDigit++) {
1265       AliITSdigit *dig = (AliITSdigit*)iSSDdigits->UncheckedAt(iDigit);
1266       Int_t fStripNumber = (dig->GetCoord1() == 0) ? dig->GetCoord2() : dig->GetCoord2() + fgkNumberOfPSideStrips;
1267       fAliITSQADataMakerRec->FillDigitsData(fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 1,fStripNumber,iModule,dig->GetSignal());
1268     }//digit loop
1269   }//module loop
1270   //
1271   return rv ; 
1272 }
1273
1274 //____________________________________________________________________________ 
1275 Int_t AliITSQASSDDataMakerRec::InitRecPoints()
1276 {
1277   // Initialization for RECPOINTS - SSD -
1278   const Bool_t expert   = kTRUE ; 
1279   const Bool_t image    = kTRUE ; 
1280   Int_t rv = 0 ; 
1281   //AliInfo(Form("fAliITSQADataMakerRec->GetEventSpecie() %d\n",fAliITSQADataMakerRec->GetEventSpecie()));
1282   //AliInfo(Form("fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] %d\n",fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]));
1283   //  fGenRecPointsOffset = (fAliITSQADataMakerRec->fRecPointsQAList[AliRecoParam::kDefault])->GetEntries();
1284   //AliDebug(AliQAv1::GetQADebugLevel(), Form("**-------*-*-*-*-*-*-***************AliITSQASSDataMakerRec::MakeRecpoints offset %d \t %d \n",fGenOffset,fGenRecPointsOffset));
1285   Int_t nModuleOffset = 500;
1286   Int_t nITSTotalModules = AliITSgeomTGeo::GetNModules();
1287
1288   TH1F *fHistSSDModuleIdLayer5 = new TH1F("fHistSSDModuleIdLayer5",
1289                                           "Module Id - Layer 5;Module Id;Entries",
1290                                           fgkSSDMODULESLAYER5,
1291                                           nModuleOffset - 0.5,
1292                                           nITSTotalModules-fgkSSDMODULESLAYER6+0.5);
1293   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDModuleIdLayer5, 
1294                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 0, expert, !image);
1295   fSSDhRecPointsTask += 1;
1296   TH1F *fHistSSDModuleIdLayer6 = new TH1F("fHistSSDModuleIdLayer6",
1297                                           "Module Id - Layer 6;Module Id;Entries",
1298                                           fgkSSDMODULESLAYER6,
1299                                           nModuleOffset+fgkSSDMODULESLAYER5 - 0.5,
1300                                           nITSTotalModules + 0.5);
1301   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDModuleIdLayer6, 
1302                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 1, expert, !image);
1303   fSSDhRecPointsTask += 1;
1304   TH1F *fHistSSDClusterPerEventLayer5 = new TH1F("fHistSSDClusterPerEventLayer5",
1305                                                  "N_{clusters} - Layer 5;N_{clusters};Entries;",
1306                                                  100,0.1,5000);
1307   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDClusterPerEventLayer5,
1308                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 2, expert, !image);
1309   fSSDhRecPointsTask += 1;
1310   TH1F *fHistSSDClusterPerEventLayer6 = new TH1F("fHistSSDClusterPerEventLayer6",
1311                                                  "N_{clusters} - Layer 6;N_{clusters};Entries;",
1312                                                  100,0.1,5000);
1313   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDClusterPerEventLayer6,
1314                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 3, expert, !image);
1315   fSSDhRecPointsTask += 1;
1316   TH1F *fHistSSDLocalXLayer5 = new TH1F("fHistSSDLocalXLayer5",
1317                                         "Local x coord.- Layer 5;x [cm];Entries;",
1318                                         100,-4.,4.);
1319   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDLocalXLayer5,
1320                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 4, expert, !image);
1321   fSSDhRecPointsTask += 1;
1322   TH1F *fHistSSDLocalXLayer6 = new TH1F("fHistSSDLocalXLayer6",
1323                                         "Local x coord.- Layer 6;x [cm];Entries;",
1324                                         100,-4.,4.);
1325   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDLocalXLayer6, 
1326                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 5, expert, !image);
1327   fSSDhRecPointsTask += 1;
1328   TH1F *fHistSSDLocalZLayer5 = new TH1F("fHistSSDLocalZLayer5",
1329                                         "Local z coord.- Layer 5;z [cm];Entries;",
1330                                         100,-4.,4.);
1331   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDLocalZLayer5, 
1332                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 6, expert, !image);
1333   fSSDhRecPointsTask += 1;
1334   TH1F *fHistSSDLocalZLayer6 = new TH1F("fHistSSDLocalZLayer6",
1335                                         "Local z coord.- Layer 6;z [cm];Entries;",
1336                                         100,-4.,4.);
1337   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDLocalZLayer6, 
1338                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 7, expert, !image);
1339   fSSDhRecPointsTask += 1;
1340   TH1F *fHistSSDGlobalXLayer5 = new TH1F("fHistSSDGlobalXLayer5",
1341                                          "Global x - Layer 5;x [cm];Entries;",
1342                                          100,-40.,40.);
1343   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDGlobalXLayer5, 
1344                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 8, expert, !image);
1345   fSSDhRecPointsTask += 1;
1346   TH1F *fHistSSDGlobalXLayer6 = new TH1F("fHistSSDGlobalXLayer6",
1347                                          "Global x - Layer 6;x [cm];Entries;",
1348                                          100,-45.,45.);
1349   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDGlobalXLayer6, 
1350                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 9, expert, !image);
1351   fSSDhRecPointsTask += 1;
1352   TH1F *fHistSSDGlobalYLayer5 = new TH1F("fHistSSDGlobalYLayer5",
1353                                          "Global y - Layer 5;y [cm];Entries;",
1354                                          100,-40.,40);
1355   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDGlobalYLayer5, 
1356                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 10, expert, !image);
1357   fSSDhRecPointsTask += 1;
1358   TH1F *fHistSSDGlobalYLayer6 = new TH1F("fHistSSDGlobalYLayer6",
1359                                          "Global y - Layer 6;y [cm];Entries;",
1360                                          100,-45.,45.);
1361   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDGlobalYLayer6, 
1362                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 11, expert, !image);
1363   fSSDhRecPointsTask += 1;
1364   TH1F *fHistSSDGlobalZLayer5 = new TH1F("fHistSSDGlobalZLayer5",
1365                                          "Global z - Layer 5;z [cm];Entries;",
1366                                          100,-45.,45);
1367   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDGlobalZLayer5, 
1368                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 12, expert, !image);
1369   fSSDhRecPointsTask += 1;
1370   TH1F *fHistSSDGlobalZLayer6 = new TH1F("fHistSSDGlobalZLayer6",
1371                                          "Global z - Layer 6;z [cm];Entries;",
1372                                          100,-55.,55.);
1373   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDGlobalZLayer6, 
1374                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 13, expert, !image);
1375   fSSDhRecPointsTask += 1;
1376   TH1F *fHistSSDPhiLayer5 = new TH1F("fHistSSDPhiLayer5",
1377                                      "#phi - Layer 5;#phi [rad];Entries;",
1378                                      100,-TMath::Pi(),TMath::Pi());
1379   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDPhiLayer5, 
1380                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 14, expert, !image);
1381   fSSDhRecPointsTask += 1;
1382   TH1F *fHistSSDPhiLayer6 = new TH1F("fHistSSDPhiLayer6",
1383                                      "#phi - Layer 6;#phi [rad];Entries;",
1384                                      100,-TMath::Pi(),TMath::Pi());
1385   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDPhiLayer6, 
1386                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 15, expert, !image);
1387   fSSDhRecPointsTask += 1;
1388   TH1F *fHistSSDThetaLayer5 = new TH1F("fHistSSDThetaLayer5",
1389                                        "#theta - Layer 5;#theta [rad];Entries;",
1390                                        100,-TMath::Pi(),TMath::Pi());
1391   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDThetaLayer5, 
1392                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 16, expert, !image);
1393   fSSDhRecPointsTask += 1;
1394   TH1F *fHistSSDThetaLayer6 = new TH1F("fHistSSDThetaLayer6",
1395                                        "#theta - Layer 6;#theta [rad];Entries;",
1396                                        100,-TMath::Pi(),TMath::Pi());
1397   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDThetaLayer6, 
1398                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 17, expert, !image);
1399   fSSDhRecPointsTask += 1;
1400   TH1F *fHistSSDRadiusLayer5 = new TH1F("fHistSSDRadiusLayer5",
1401                                         "r - Layer 5;r [cm];Entries;",
1402                                         100,35.,50.);
1403   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDRadiusLayer5, 
1404                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 18, expert, !image);
1405   fSSDhRecPointsTask += 1;
1406   TH1F *fHistSSDRadiusLayer6 = new TH1F("fHistSSDRadiusLayer6",
1407                                         "r - Layer 6;r [cm];Entries;",
1408                                         100,35.,50.);
1409   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDRadiusLayer6, 
1410                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 19, expert, !image);
1411   fSSDhRecPointsTask += 1;
1412   TH1F *fHistSSDClusterTypeLayer5 = new TH1F("fHistSSDClusterTypeLayer5",
1413                                              "CL type - Layer 5;Cluster type;Entries;",
1414                                              150,0,150);
1415   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDClusterTypeLayer5, 
1416                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 20, expert, !image);
1417   fSSDhRecPointsTask += 1;
1418   TH1F *fHistSSDClusterTypeLayer6 = new TH1F("fHistSSDClusterTypeLayer6",
1419                                              "CL type - Layer 6;Cluster type;Entries;",
1420                                              150,0,150);
1421   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDClusterTypeLayer6, 
1422                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 21, expert, !image);
1423   fSSDhRecPointsTask += 1;
1424   TH1F *fHistSSDChargeRatioLayer5 = new TH1F("fHistSSDChargeRatioLayer5",
1425                                              "Charge ratio - Layer 5;q_{ratio};Entries;",
1426                                              100,-2.0,2.0);
1427   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDChargeRatioLayer5, 
1428                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 22, expert, !image);
1429   fSSDhRecPointsTask += 1;
1430   TH1F *fHistSSDChargeRatioLayer6 = new TH1F("fHistSSDChargeRatioLayer6",
1431                                              "Charge ratio - Layer 6;q_{ratio};Entries;",
1432                                              100,-2.0,2.0);
1433   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDChargeRatioLayer6, 
1434                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 23, expert, !image);
1435   fSSDhRecPointsTask += 1;
1436   TH1F *fHistSSDChargekeVLayer5 = new TH1F("fHistSSDChargekeVLayer5",
1437                                            "Charge - Layer 5;q [keV];Entries;",
1438                                            100,0.,300.);
1439   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDChargekeVLayer5, 
1440                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 24, !expert, image);
1441   fSSDhRecPointsTask += 1;
1442   TH1F *fHistSSDChargekeVLayer6 = new TH1F("fHistSSDChargekeVLayer6",
1443                                            "Charge - Layer 6;q [keV];Entries;",
1444                                            100,0.,300.);
1445   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDChargekeVLayer6, 
1446                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 25, !expert, image);
1447   fSSDhRecPointsTask += 1;
1448   TH1F *fHistSSDChargePSideLayer5 = new TH1F("fHistSSDChargePSideLayer5",
1449                                              "Charge P- Layer 5;q_{P} [keV];Entries;",
1450                                              100,0.,300.);
1451   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDChargePSideLayer5,
1452                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 26, expert, !image);
1453   fSSDhRecPointsTask += 1;
1454   TH1F *fHistSSDChargePSideLayer6 = new TH1F("fHistSSDChargePSideLayer6",
1455                                              "Charge P- Layer 6;q_{P} [keV];Entries;",
1456                                              100,0.,300.);
1457   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDChargePSideLayer6,
1458                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 27, expert, !image);
1459   fSSDhRecPointsTask += 1;
1460   TH1F *fHistSSDChargeNSideLayer5 = new TH1F("fHistSSDChargeNSideLayer5",
1461                                              "Charge N- Layer 5;q_{N} [keV];Entries;",
1462                                              100,0.,300.);
1463   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDChargeNSideLayer5,
1464                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 28, expert, !image);
1465   fSSDhRecPointsTask += 1;
1466   TH1F *fHistSSDChargeNSideLayer6 = new TH1F("fHistSSDChargeNSideLayer6",
1467                                              "Charge N- Layer 6;q_{N} [keV];Entries;",
1468                                              100,0.,300.);
1469   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDChargeNSideLayer6,
1470                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 29, expert, !image);
1471   fSSDhRecPointsTask += 1;
1472   TH1F *fHistSSDChargeRatio2Layer5 = new TH1F("fHistSSDChargeRatio2Layer5",
1473                                               "Charge Ratio qN/qP - Layer 5;q_{N}/q_{P};Entries;",
1474                                               100,0,2);
1475   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDChargeRatio2Layer5,
1476                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 30, expert, !image);
1477   fSSDhRecPointsTask += 1;
1478   TH1F *fHistSSDChargeRatio2Layer6 = new TH1F("fHistSSDChargeRatio2Layer6",
1479                                               "Charge Ratio qN/qP - Layer 6;q_{N}/q_{P};Entries;",
1480                                               100,0,2);
1481   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDChargeRatio2Layer6,
1482                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 31, expert, !image);
1483   fSSDhRecPointsTask += 1;
1484   TH2F *fHistSSDChargePNSideLayer5 = new TH2F("fHistSSDChargePNSideLayer5",
1485                                               "Charge correlation - Layer 5;q_{P} [keV];q_{N} [keV]",
1486                                               100,0.,300.,
1487                                               100,0.,300.);
1488   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDChargePNSideLayer5,
1489                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 32, expert, !image);
1490   fSSDhRecPointsTask += 1;
1491   TH2F *fHistSSDChargePNSideLayer6 = new TH2F("fHistSSDChargePNSideLayer6",
1492                                               "Charge correlation - Layer 6;q_{P} [keV];q_{N} [keV]",
1493                                               100,0.,300.,
1494                                               100,0.,300.);
1495   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDChargePNSideLayer6,
1496                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 33, expert, !image);
1497   fSSDhRecPointsTask += 1;
1498   TH2F *fHistSSDChargeMapLayer5 = new TH2F("fHistSSDChargeMapLayer5",
1499                                            "Charge map;N_{modules};N_{Ladders}",
1500                                            fgkSSDMODULESPERLADDERLAYER5,
1501                                            -0.5,fgkSSDMODULESPERLADDERLAYER5+0.5,
1502                                            3*fgkSSDLADDERSLAYER5,
1503                                            -0.5,fgkSSDLADDERSLAYER5+0.5);
1504   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDChargeMapLayer5, 
1505                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 34, expert, !image);
1506   fSSDhRecPointsTask += 1;
1507   TH2F *fHistSSDChargeMapLayer6 = new TH2F("fHistSSDChargeMapLayer6",
1508                                            "Charge map;N_{modules};N_{Ladders}",
1509                                            fgkSSDMODULESPERLADDERLAYER6,
1510                                            -0.5,fgkSSDMODULESPERLADDERLAYER6+0.5,
1511                                            3*fgkSSDLADDERSLAYER6,
1512                                            -0.5,fgkSSDLADDERSLAYER6+0.5);
1513   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDChargeMapLayer6, 
1514                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 35, expert, !image);
1515   fSSDhRecPointsTask += 1;
1516   TH2F *fHistSSDClusterMapLayer5 = new TH2F("fHistSSDClusterMapLayer5",
1517                                             "Layer 5;N_{module};N_{ladder}",
1518                                             22,1,23,
1519                                             34,500,534);
1520   fHistSSDClusterMapLayer5->GetXaxis()->SetTitleColor(1);
1521   fHistSSDClusterMapLayer5->SetStats(kFALSE);
1522   fHistSSDClusterMapLayer5->GetYaxis()->SetTitleOffset(1.8);
1523   fHistSSDClusterMapLayer5->GetXaxis()->SetNdivisions(22);
1524   fHistSSDClusterMapLayer5->GetYaxis()->SetNdivisions(34);
1525   fHistSSDClusterMapLayer5->GetXaxis()->SetLabelSize(0.03);
1526   fHistSSDClusterMapLayer5->GetYaxis()->SetLabelSize(0.03);
1527   fHistSSDClusterMapLayer5->GetZaxis()->SetTitleOffset(1.4);
1528   fHistSSDClusterMapLayer5->GetZaxis()->SetTitle("N_{clusters}");
1529   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDClusterMapLayer5,
1530                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 36, !expert, image);
1531   fSSDhRecPointsTask += 1;
1532   TH2F *fHistSSDClusterMapLayer6 = new TH2F("fHistSSDClusterMapLayer6",
1533                                             "Layer 6;N_{module};N_{ladder}",
1534                                             25,1,26,
1535                                             38,600,638);
1536   fHistSSDClusterMapLayer6->GetXaxis()->SetTitleColor(1);
1537   fHistSSDClusterMapLayer6->SetStats(kFALSE);
1538   fHistSSDClusterMapLayer6->GetYaxis()->SetTitleOffset(1.8);
1539   fHistSSDClusterMapLayer6->GetXaxis()->SetNdivisions(25);
1540   fHistSSDClusterMapLayer6->GetYaxis()->SetNdivisions(38);
1541   fHistSSDClusterMapLayer6->GetXaxis()->SetLabelSize(0.03);
1542   fHistSSDClusterMapLayer6->GetYaxis()->SetLabelSize(0.03);
1543   fHistSSDClusterMapLayer6->GetZaxis()->SetTitleOffset(1.4);
1544   fHistSSDClusterMapLayer6->GetZaxis()->SetTitle("N_{clusters}");
1545   rv = fAliITSQADataMakerRec->Add2RecPointsList(fHistSSDClusterMapLayer6,
1546                                                 fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 37, !expert, image);
1547   fSSDhRecPointsTask += 1;
1548   //printf ("%d SSD Recs histograms booked\n",fSSDhRecPointsTask);
1549   AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SSD Recs histograms booked\n",fSSDhRecPointsTask));
1550   return rv ; 
1551 }
1552
1553 //____________________________________________________________________________ 
1554 Int_t AliITSQASSDDataMakerRec::MakeRecPoints(TTree *clustersTree)
1555 {
1556   // Fill QA for recpoints - SSD -
1557   //printf("*-*-*-*-*-*-*---*-*-*-------*-*-*-*-*-*-***************AliITSQASSDataMakerRec::MakeRecpoints called \n");
1558   //
1559   Int_t rv = 0 ; 
1560   Int_t gLayer = 0, gLadder = 0, gModule = 0;
1561   Int_t lLadderLocationY = 0;
1562   TClonesArray *recpoints = NULL;
1563   AliITSRecPointContainer* rpcont=AliITSRecPointContainer::Instance();
1564   rpcont->FetchClusters(0,clustersTree); 
1565   if(!rpcont->GetStatusOK() || !rpcont->IsSSDActive()){
1566     AliError("can't get SSD clusters !");
1567     return rv;
1568   }
1569  
1570   //AliInfo(Form("fAliITSQADataMakerRec->GetEventSpecie() %d\n",fAliITSQADataMakerRec->GetEventSpecie()));
1571   //AliInfo(Form("fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] %d\n",fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]));
1572   Int_t nClustersLayer5 = 0, nClustersLayer6 = 0;
1573   Int_t npoints = 0;      
1574   Float_t cluglo[3]={0.,0.,0.}; 
1575   //printf("*-*-*-*-*-*-*---*-*-*-------*-*-*-*-*-*-***************AliITSQASSDataMakerRec::MakeRecpoints STEP1 \n");
1576   // AliITSgeomTGeo::GetModuleIndex() issues an error in case the arguments
1577   // are illegal and returns -1
1578   Int_t firMod = TMath::Max(0,AliITSgeomTGeo::GetModuleIndex(5,1,1));
1579   Int_t lasMod =  AliITSgeomTGeo::GetNModules();
1580   for(Int_t module = firMod; module < lasMod; module++){
1581     recpoints = rpcont->UncheckedGetClusters(module);
1582     npoints += recpoints->GetEntries();
1583     AliITSgeomTGeo::GetModuleId(module,gLayer,gLadder,gModule);
1584     //printf("SSDDataMAkerRec:::::::::::::::::::::::gLayer ========== %d \n\n",gLayer);
1585     lLadderLocationY = 3*gLadder;
1586     ////printf("*-*-*-*-*-*-*---*-*-*-------*-*-*-*-*-*-***************AliITSQASSDataMakerRec::MakeRecpoints inside loop \n");
1587     for(Int_t j = 0;j < recpoints->GetEntries(); j++){
1588       ////printf("*-*-*-*-*-*-*---*-*-*-------*-*-*-*-*-*-***************AliITSQASSDataMakerRec::MakeRecpoints inside loop 2\n");
1589       AliITSRecPoint *recp = (AliITSRecPoint*)recpoints->At(j);    
1590       Int_t layer = recp->GetLayer();
1591       //printf("SSDDataMAkerRec:::::::::::::::::::::::layer ========== %d \n\n",layer);
1592       recp->GetGlobalXYZ(cluglo);
1593       Float_t radius = TMath::Sqrt(cluglo[0]*cluglo[0]+cluglo[1]*cluglo[1]); 
1594       Float_t phi = TMath::ATan2(cluglo[1],cluglo[0]);
1595       Float_t theta = TMath::ATan2(radius,cluglo[2]);
1596       Double_t chargeRatio = recp->GetChargeRatio();
1597       Double_t clusterCharge = recp->GetQ();
1598       Double_t chargePSide = clusterCharge*(1. + chargeRatio);
1599       Double_t chargeNSide = clusterCharge*(1. - chargeRatio);
1600       if(layer == 4) {
1601         //printf("-*-*-*-*-*-***************AliITSQASSDataMakerRec::MakeRecpoints Filling 4 called \n");
1602         fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 20,recp->GetType());
1603
1604         if(recp->GetType() != 1) continue;
1605         fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 0,module);
1606         fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 4,recp->GetDetLocalX());
1607         fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 6,recp->GetDetLocalZ());
1608         fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 8,cluglo[0]);
1609         fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 10,cluglo[1]);
1610         fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 12,cluglo[2]);
1611         fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 14,phi);
1612         fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 16,theta);
1613         fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 18,radius);
1614         fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 22,recp->GetChargeRatio());
1615         fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 24,recp->GetQ());
1616         fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 26,chargePSide);
1617         fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 28,chargeNSide);
1618         if(chargePSide != 0.) fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 30,chargeNSide/chargePSide);
1619         fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 32,chargePSide,chargeNSide);
1620         fAliITSQADataMakerRec->SetRecPointsDataBinContent(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 34,gModule,lLadderLocationY,recp->GetQ());
1621         fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 36,gModule,499+gLadder,1);
1622         nClustersLayer5 += 1;
1623       }//layer 5 histograms
1624       if(layer == 5) {
1625         //printf("-*-*-*-*-*-***************AliITSQASSDataMakerRec::MakeRecpoints Filling 5 called \n");
1626         fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 21,recp->GetType());
1627
1628         if(recp->GetType() != 1) continue;
1629         fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 1,module);
1630         fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 5,recp->GetDetLocalX());
1631         fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 7,recp->GetDetLocalZ());
1632         fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 9,cluglo[0]);
1633         fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 11,cluglo[1]);
1634         fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 13,cluglo[2]);
1635         fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 15,phi);
1636         fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 17,theta);
1637         fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 19,radius);
1638         fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 23,recp->GetChargeRatio());
1639         fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 25,recp->GetQ());
1640         fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 27,chargePSide);
1641         fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 29,chargeNSide);
1642         if(chargePSide != 0.) fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 31,chargeNSide/chargePSide);
1643         fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 33,chargePSide,chargeNSide);
1644         fAliITSQADataMakerRec->SetRecPointsDataBinContent(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 35,gModule,lLadderLocationY,recp->GetQ());
1645         fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 37,gModule,599+gLadder,1);
1646         nClustersLayer6 += 1;
1647       }//layer 6 histograms
1648     }//rec. points loop
1649   }//module loop
1650   
1651   //printf("-*-*-*-*-*-***************AliITSQASSDataMakerRec::MakeRecpoints Filling called \n");
1652   fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 2,nClustersLayer5);
1653   fAliITSQADataMakerRec->FillRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + 3,nClustersLayer6);
1654   //
1655   return rv ; 
1656 }
1657
1658 //____________________________________________________________________________ 
1659 Int_t AliITSQASSDDataMakerRec::GetOffset(AliQAv1::TASKINDEX_t task,Int_t specie) const {
1660   // Returns offset number according to the specified task 
1661   Int_t offset=0;
1662   if( task == AliQAv1::kRAWS ) {
1663     offset=fGenRawsOffset[specie];  
1664   }
1665   else if( task == AliQAv1::kDIGITSR ) {
1666     offset=fGenDigitsOffset[specie];   
1667   }
1668   else if( task == AliQAv1::kRECPOINTS ) {
1669     offset=fGenRecPointsOffset[specie];   
1670   }
1671
1672   return offset;
1673 }
1674
1675 //_______________________________________________________________
1676
1677 void AliITSQASSDDataMakerRec::SetOffset(AliQAv1::TASKINDEX_t task, Int_t offset, Int_t specie) {
1678   // Returns offset number according to the specified task
1679   if( task == AliQAv1::kRAWS ) {
1680     fGenRawsOffset[specie]=offset;
1681   }
1682   else if( task == AliQAv1::kDIGITSR ) {
1683     fGenDigitsOffset[specie]=offset;
1684   }
1685   else if( task == AliQAv1::kRECPOINTS ) {
1686     fGenRecPointsOffset[specie]=offset;
1687   }
1688 }
1689
1690 //____________________________________________________________________________ 
1691 Int_t AliITSQASSDDataMakerRec::GetTaskHisto(AliQAv1::TASKINDEX_t task) {
1692   // Returns the number of histograms associated to the specified task
1693   Int_t histotot=0;
1694
1695   if( task == AliQAv1::kRAWS ) {
1696     histotot=fSSDhRawsTask;  
1697   }
1698   else if( task == AliQAv1::kDIGITSR ) {
1699     histotot=fSSDhDigitsTask;
1700   }
1701   else if( task == AliQAv1::kRECPOINTS ){
1702     histotot=fSSDhRecPointsTask;   
1703   }
1704   else { 
1705     AliWarning("No task has been selected. TaskHisto set to zero.\n");
1706   }
1707
1708   return histotot;
1709 }
1710
1711 //____________________________________________________________________________ 
1712 void AliITSQASSDDataMakerRec::ResetDetector(AliQAv1::TASKINDEX_t task)
1713 {
1714   if(task==AliQAv1::kRAWS) {
1715     ResetRawsMonitoredObjects();
1716   }
1717
1718 }