Decode jitter word decoding and correct for jitter in the SDD cluster finder (F....
[u/mrichter/AliRoot.git] / ITS / AliITSQASDDDataMakerRec.cxx
1 /**************************************************************************
2  * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 //  *************************************************************
19 //  Checks the quality assurance 
20 //  by comparing with reference data
21 //  contained in a DB
22 //  -------------------------------------------------------------
23 //  W. Ferrarese + P. Cerello Feb 2008
24 //  M.Siciliano Aug 2008 QA RecPoints and HLT mode
25 //  INFN Torino
26
27 // --- ROOT system ---
28 #include <TProfile2D.h>
29 #include <TH2D.h>
30 #include <TBranch.h>
31 #include <TTree.h>
32 #include <TGaxis.h>
33 #include <TMath.h>
34 #include <TDirectory.h>
35 #include <TSystem.h>
36 // --- Standard library ---
37
38 // --- AliRoot header files ---
39 #include "AliITSQASDDDataMakerRec.h"
40 #include "AliLog.h"
41 #include "AliQA.h"
42 #include "AliQAChecker.h"
43 #include "AliRawReader.h"
44 #include "AliITSRawStream.h"
45 #include "AliITSRawStreamSDD.h"
46 #include "AliITSRawStreamSDDCompressed.h"
47 #include "AliITSDetTypeRec.h"
48 #include "AliITSRecPoint.h"
49 #include "AliITSgeomTGeo.h"
50 #include "AliITSHLTforSDD.h"
51 #include "AliCDBManager.h"
52 #include "AliCDBStorage.h"
53 #include "AliCDBEntry.h"
54
55
56 ClassImp(AliITSQASDDDataMakerRec)
57
58 //____________________________________________________________________________ 
59 AliITSQASDDDataMakerRec::AliITSQASDDDataMakerRec(AliITSQADataMakerRec *aliITSQADataMakerRec, Bool_t kMode, Short_t ldc) :
60 TObject(),
61 fAliITSQADataMakerRec(aliITSQADataMakerRec),
62 fkOnline(kMode),
63 fLDC(ldc),
64 fSDDhTask(0),
65 fGenOffset(0),
66 fTimeBinSize(1),
67 fDDLModuleMap(0),
68 fHLTMode(0),
69 fHLTSDD(0)
70 {
71   //ctor used to discriminate OnLine-Offline analysis
72   if(fLDC < 0 || fLDC > 4) {
73         AliError("Error: LDC number out of range; return\n");
74   }
75   if(!fkOnline){AliInfo("Offline mode: HLT set from AliITSDetTypeRec for SDD\n");}
76   else
77     if(fkOnline){
78       AliInfo("Online mode: HLT set from environment for SDD\n");
79       SetHLTModeFromEnvironment();
80     }
81   //fDDLModuleMap=NULL;
82 }
83
84 //____________________________________________________________________________ 
85 AliITSQASDDDataMakerRec::AliITSQASDDDataMakerRec(const AliITSQASDDDataMakerRec& qadm) :
86 TObject(),
87 fAliITSQADataMakerRec(qadm.fAliITSQADataMakerRec),
88 fkOnline(qadm.fkOnline),
89 fLDC(qadm.fLDC),
90 fSDDhTask(qadm.fSDDhTask),
91 fGenOffset(qadm.fGenOffset),
92 fTimeBinSize(1),
93 fDDLModuleMap(0),
94 fHLTMode(qadm.fHLTMode),
95 fHLTSDD( qadm.fHLTSDD)
96 {
97   //copy ctor 
98   fAliITSQADataMakerRec->SetName((const char*)qadm.fAliITSQADataMakerRec->GetName()) ; 
99   fAliITSQADataMakerRec->SetTitle((const char*)qadm.fAliITSQADataMakerRec->GetTitle());
100   fDDLModuleMap=NULL;
101 }
102
103 //____________________________________________________________________________ 
104 AliITSQASDDDataMakerRec::~AliITSQASDDDataMakerRec(){
105   // destructor
106   //    if(fDDLModuleMap) delete fDDLModuleMap;
107 }
108 //__________________________________________________________________
109 AliITSQASDDDataMakerRec& AliITSQASDDDataMakerRec::operator = (const AliITSQASDDDataMakerRec& qac )
110 {
111   // Equal operator.
112   this->~AliITSQASDDDataMakerRec();
113   new(this) AliITSQASDDDataMakerRec(qac);
114   return *this;
115 }
116
117 //____________________________________________________________________________ 
118 void AliITSQASDDDataMakerRec::StartOfDetectorCycle()
119 {
120   //Detector specific actions at start of cycle
121   AliDebug(1,"AliITSQADM::Start of SDD Cycle\n");
122 }
123
124 //____________________________________________________________________________ 
125 void AliITSQASDDDataMakerRec::EndOfDetectorCycle(AliQA::TASKINDEX_t /*task*/, TObjArray* /*list*/)
126 {
127   // launch the QA checking
128   AliDebug(1,"AliITSDM instantiates checker with Run(AliQA::kITS, task, list)\n"); 
129 }
130
131 //____________________________________________________________________________ 
132 void AliITSQASDDDataMakerRec::InitRaws()
133
134   // Initialization for RAW data - SDD -
135   fGenOffset = (fAliITSQADataMakerRec->fRawsQAList)->GetEntries();
136
137   AliCDBEntry *ddlMapSDD = AliCDBManager::Instance()->Get("ITS/Calib/DDLMapSDD");
138   Bool_t cacheStatus = AliCDBManager::Instance()->GetCacheFlag();
139   if(!ddlMapSDD)
140     {
141       AliError("Calibration object retrieval failed! SDD will not be processed");
142       fDDLModuleMap = NULL;
143       return;
144     }
145   fDDLModuleMap = (AliITSDDLModuleMapSDD*)ddlMapSDD->GetObject();
146   if(!cacheStatus)ddlMapSDD->SetObject(NULL);
147   ddlMapSDD->SetOwner(kTRUE);
148   if(!cacheStatus)
149     {
150       delete ddlMapSDD;
151     }
152
153   if(fkOnline==kFALSE){
154     AliInfo("Offline mode: HLTforSDDobject used \n");
155     AliCDBEntry *hltforSDD = AliCDBManager::Instance()->Get("ITS/Calib/HLTforSDD");
156     if(!hltforSDD){
157       AliError("Calibration object retrieval failed! SDD will not be processed");    
158       fHLTSDD=NULL;
159       return;
160     }  
161     fHLTSDD = (AliITSHLTforSDD*)hltforSDD->GetObject();
162     if(!cacheStatus)hltforSDD->SetObject(NULL);
163     hltforSDD->SetOwner(kTRUE);
164     if(!cacheStatus)
165       {
166         delete hltforSDD;
167       }
168   }
169   Int_t lay, lad, det;
170   Int_t LAY = -1;  //, LAD = -1;
171   char hname0[50];
172   Int_t indexlast = 0;
173   Int_t index1 = 0;
174
175   if(fLDC == 1 || fLDC == 2) LAY = 2;
176   if(fLDC == 3 || fLDC == 4) LAY = 3;
177   
178   if(fkOnline) {
179     AliInfo("Book Online Histograms for SDD\n");
180   }
181   else {
182     AliInfo("Book Offline Histograms for SDD\n ");
183   }
184   TH1D *h0 = new TH1D("SDDModPattern","HW Modules pattern",fgknSDDmodules,239.5,499.5);
185   h0->GetXaxis()->SetTitle("Module Number");
186   h0->GetYaxis()->SetTitle("Counts");
187   fAliITSQADataMakerRec->Add2RawsList((new TH1D(*h0)),0+fGenOffset,kTRUE,kFALSE);
188   delete h0;
189   fSDDhTask++;
190   if(fLDC==0 || fLDC==1 || fLDC==2){
191     TH1D *h1 = new TH1D("SDDLadPatternL3","Ladder pattern L3",14,0.5,14.5);  
192     h1->GetXaxis()->SetTitle("Ladder Number on Lay3");
193     h1->GetYaxis()->SetTitle("Counts");
194     fAliITSQADataMakerRec->Add2RawsList((new TH1D(*h1)),1+fGenOffset, kTRUE,kFALSE);
195         delete h1;
196     fSDDhTask++;
197   }     
198   if(fLDC==0 || fLDC==3 || fLDC==4){
199     TH1D *h2 = new TH1D("SDDLadPatternL4","Ladder pattern L4",22,0.5,22.5);  
200     h2->GetXaxis()->SetTitle("Ladder Number on Lay4");
201     h2->GetYaxis()->SetTitle("Counts");
202     fAliITSQADataMakerRec->Add2RawsList((new TH1D(*h2)),2+fGenOffset, kTRUE,kFALSE);
203         delete h2;
204     fSDDhTask++;
205   }
206   if(fLDC==0 || fLDC==1 || fLDC==2){
207         for(Int_t i=1; i<=fgkLADDonLAY3; i++) {
208       sprintf(hname0,"SDDModPattern_L3_%d",i);
209       TH1D *h3 = new TH1D(hname0,hname0,6,0.5,6.5);
210       h3->GetXaxis()->SetTitle("Module Number");
211       h3->GetYaxis()->SetTitle("Counts");
212       fAliITSQADataMakerRec->Add2RawsList((new TH1D(*h3)),i-1+3+fGenOffset, kTRUE, kFALSE);
213           delete h3;
214       fSDDhTask++;
215     }
216   }
217   if(fLDC==0 || fLDC==3 || fLDC==4){
218     for(Int_t i=1; i<=fgkLADDonLAY4; i++) {
219       sprintf(hname0,"SDDModPattern_L4_%d",i);
220       TH1D *h4 = new TH1D(hname0,hname0,8,0.5,8.5);
221       h4->GetXaxis()->SetTitle("Module Number");
222       h4->GetYaxis()->SetTitle("Counts");
223       fAliITSQADataMakerRec->Add2RawsList((new TH1D(*h4)),i-1+17+fGenOffset, kTRUE,kFALSE);
224           delete h4;
225       fSDDhTask++;
226     }
227   }
228
229   //zPhi distribution using ladder and modules numbers
230       TH2D *hphil3 = new TH2D("SDDphizL3","SDD #varphiz Layer3 ",6,0.5,6.5,14,0.5,14.5);
231       hphil3->GetXaxis()->SetTitle("z[#Module L3 ]");
232       hphil3->GetYaxis()->SetTitle("#varphi[#Ladder L3]");
233       fAliITSQADataMakerRec->Add2RawsList((new TH2D(*hphil3)),39+fGenOffset, kFALSE,kTRUE);
234       delete hphil3;
235       fSDDhTask++;
236
237       TH2D *hphil4 = new TH2D("SDDphizL4","SDD #varphiz Layer4 ",8,0.5,8.5,22,0.5,22.5);
238       hphil4->GetXaxis()->SetTitle("z[#Module L4]");
239       hphil4->GetYaxis()->SetTitle("#varphi[#Ladder L4]");
240       fAliITSQADataMakerRec->Add2RawsList((new TH2D(*hphil4)),40+fGenOffset, kFALSE,kTRUE);
241       delete hphil4;
242       fSDDhTask++;
243
244
245   Int_t indexlast1 = 0;
246   Int_t indexlast2 = 0;
247
248   if(fkOnline) {
249         fTimeBinSize = 4;
250     indexlast = 0;
251     index1 = 0;
252     indexlast1 = fSDDhTask;
253     //   cout<<"Last of the offline "<<fSDDhTask<<endl;
254     indexlast2 = 0;
255     char *hname[3];
256     for(Int_t i=0; i<3; i++) hname[i]= new char[50];
257     for(Int_t moduleSDD =0; moduleSDD<fgknSDDmodules; moduleSDD++){
258                 for(Int_t iside=0;iside<fgknSide;iside++){
259                         AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
260                         sprintf(hname[0],"SDDchargeMapFSE_L%d_%d_%d_%d",lay,lad,det,iside);
261                         sprintf(hname[1],"SDDChargeMapForSingleEvent_L%d_%d_%d_%d",lay,lad,det,iside);
262                         sprintf(hname[2],"SDDhmonoDMap_L%d_%d_%d_%d",lay,lad,det,iside);
263                         TProfile2D *fModuleChargeMapFSE = new TProfile2D(hname[0],hname[1],256/fTimeBinSize,-0.5,255.5,256,-0.5,255.5);
264                         fModuleChargeMapFSE->GetXaxis()->SetTitle("Time Bin");
265                         fModuleChargeMapFSE->GetYaxis()->SetTitle("Anode");
266                         fAliITSQADataMakerRec->Add2RawsList((new TProfile2D(*fModuleChargeMapFSE)),indexlast1 + index1 + fGenOffset,kTRUE,kFALSE);
267                         delete fModuleChargeMapFSE;
268                         
269                         fSDDhTask++;
270                         index1++;        
271                         indexlast2 = indexlast1 + index1;
272                 }
273         }
274
275     for(Int_t moduleSDD =0; moduleSDD<fgknSDDmodules; moduleSDD++){
276                 for(Int_t iside=0;iside<fgknSide;iside++){
277                         AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
278                         sprintf(hname[0],"SDDchargeMap_L%d_%d_%d_%d",lay,lad,det,iside);
279                         sprintf(hname[1],"SDDChargeMap_L%d_%d_%d_%d",lay,lad,det,iside);
280                         TProfile2D *fModuleChargeMap = new TProfile2D(hname[0],hname[1],256/fTimeBinSize,-0.5,255.5,256,-0.5,255.5);
281                         fModuleChargeMap->GetXaxis()->SetTitle("Time Bin");
282                         fModuleChargeMap->GetYaxis()->SetTitle("Anode");
283                         fAliITSQADataMakerRec->Add2RawsList((new TProfile2D(*fModuleChargeMap)),indexlast1 + index1 + fGenOffset,kTRUE,kFALSE);
284                         delete fModuleChargeMap;
285
286                         fSDDhTask++;
287                         index1++;        
288                         indexlast2 = indexlast1 + index1;
289                 }
290         }
291   
292 }  // kONLINE
293
294   AliDebug(1,Form("%d SDD Raws histograms booked\n",fSDDhTask));
295 }
296
297
298 //____________________________________________________________________________
299 void AliITSQASDDDataMakerRec::MakeRaws(AliRawReader* rawReader)
300
301   // Fill QA for RAW - SDD -
302   if(!fDDLModuleMap){
303     AliError("SDD DDL module map not available - skipping SDD QA");
304     return;
305   }
306   if(rawReader->GetType() != 7) return;  // skips non physical triggers
307   AliDebug(1,"entering MakeRaws\n");                 
308
309   rawReader->Reset();       
310   AliITSRawStream *stream;
311   
312   if(fkOnline==kTRUE)
313     {
314       if(GetHLTMode()==kTRUE)
315         {
316           AliInfo("Online  mode: HLT C compressed mode used for SDD\n");
317           stream = new AliITSRawStreamSDDCompressed(rawReader); }
318       else{ 
319         AliInfo("Online  mode: HLT A mode used for SDD\n");
320         stream = new AliITSRawStreamSDD(rawReader);}     
321     }
322   else 
323     {
324       if(fHLTSDD->IsHLTmodeC()==kTRUE){
325           AliInfo("Offline  mode: HLT C compressed mode used for SDD\n");
326         stream = new AliITSRawStreamSDDCompressed(rawReader);
327       }else 
328         {
329         AliInfo("Offline  mode: HLT A mode used for SDD\n");
330         stream = new AliITSRawStreamSDD(rawReader);
331       }
332     }
333   
334   //ckeck on HLT mode
335                   
336
337   
338   //  AliITSRawStreamSDD s(rawReader); 
339   stream->SetDDLModuleMap(fDDLModuleMap);
340   
341   Int_t lay, lad, det; 
342
343   Int_t index=0;
344   if(fkOnline) {
345     for(Int_t moduleSDD =0; moduleSDD<fgknSDDmodules; moduleSDD++){
346         for(Int_t iside=0;iside<fgknSide;iside++) {
347           if(fSDDhTask > 41 + index) fAliITSQADataMakerRec->GetRawsData(41 + index +fGenOffset)->Reset();
348           index++;
349         }
350     }
351   }
352   
353   Int_t cnt = 0;
354   Int_t ildcID = -1;
355   Int_t iddl = -1;
356   Int_t isddmod = -1;
357   Int_t coord1, coord2, signal, moduleSDD, ioffset, iorder, activeModule, index1;
358   
359   while(stream->Next()) {
360     ildcID = rawReader->GetLDCId();
361     iddl = rawReader->GetDDLID() - fgkDDLIDshift;
362     isddmod = fDDLModuleMap->GetModuleNumber(iddl,stream->GetCarlosId());
363     //  cout<<"isddmod "<<isddmod<<endl;
364     if(isddmod==-1){
365       AliDebug(1,Form("Found module with iddl: %d, stream->GetCarlosId: %d \n",iddl,stream->GetCarlosId() ));
366       continue;
367     }
368     if(stream->IsCompletedModule()) {
369       AliDebug(1,Form("IsCompletedModule == KTRUE\n"));
370       continue;
371     } 
372     if(stream->IsCompletedDDL()) {
373       AliDebug(1,Form("IsCompletedDDL == KTRUE\n"));
374       continue;
375     } 
376     
377     coord1 = stream->GetCoord1();
378     coord2 = stream->GetCoord2();
379     signal = stream->GetSignal();
380     
381      moduleSDD = isddmod - fgkmodoffset;
382
383     if(isddmod <fgkmodoffset|| isddmod>fgknSDDmodules+fgkmodoffset-1) {
384       AliDebug(1,Form( "Module SDD = %d, resetting it to 1 \n",isddmod));
385       isddmod = 1;
386     }
387
388     fAliITSQADataMakerRec->GetRawsData(0 +fGenOffset)->Fill(isddmod); 
389     
390     AliITSgeomTGeo::GetModuleId(isddmod, lay, lad, det);
391     ioffset = 3;
392     iorder = 1;
393     if(lay==4) { 
394       ioffset += 14;
395       iorder = 2;   
396     } 
397     fAliITSQADataMakerRec->GetRawsData(iorder +fGenOffset)->Fill(lad);
398     fAliITSQADataMakerRec->GetRawsData(ioffset+lad-1 +fGenOffset)->Fill(det); //-1 because ladder# starts from 1    
399     
400     if(lay==3)    fAliITSQADataMakerRec->GetRawsData(39+fGenOffset)->Fill(det,lad);
401     if(lay==4) { 
402       fAliITSQADataMakerRec->GetRawsData(40+fGenOffset)->Fill(det,lad);}
403
404     Short_t iside = stream->GetChannel();
405     activeModule = moduleSDD;
406     index1 = activeModule * 2 + iside;
407     
408     if(index1<0){
409       AliDebug(1,Form("Wrong index number %d - patched to 0\n",index1));
410       index1 = 0;
411     }
412     
413     //    cout<< fSDDhTask<<endl;
414     if(fkOnline) {
415       if(fSDDhTask > 41 + index1) {
416         //      cout<<index1<<endl;
417         //cout<<"Fill"<< fAliITSQADataMakerRec->GetRawsData(41 + index1 +fGenOffset)->GetName()<<endl;
418         ((TProfile2D *)(fAliITSQADataMakerRec->GetRawsData(41 + index1 +fGenOffset)))->Fill(coord2, coord1, signal);
419         ((TProfile2D *)(fAliITSQADataMakerRec->GetRawsData(41 + index1 + 260*2 +fGenOffset)))->Fill(coord2, coord1, signal);
420       }
421     }
422     cnt++;
423     if(!(cnt%10000)) AliDebug(1,Form(" %d raw digits read",cnt));
424   }
425   AliDebug(1,Form("Event completed, %d raw digits read",cnt)); 
426   delete stream;
427   stream = NULL; 
428  }
429
430 //____________________________________________________________________________ 
431 void AliITSQASDDDataMakerRec::InitRecPoints()
432 {
433   // Initialization for RECPOINTS - SDD -
434
435  fGenOffset = (fAliITSQADataMakerRec->fRecPointsQAList)->GetEntries();
436   Int_t nOnline=1;
437   Int_t  nOnline2=1;
438   Int_t  nOnline3=1; 
439   Int_t  nOnline4=1;
440   if(fkOnline)
441     {
442       //      cout<<"konline"<<endl;
443       nOnline=4;
444       nOnline2=28;
445       nOnline3=64;
446       nOnline4=14;
447     }
448
449   
450   TH1F *h0 = new TH1F("SDDLay3TotCh","Layer 3 total charge",1000/nOnline,-0.5, 499.5); //position number 0
451   h0->GetXaxis()->SetTitle("ADC value");
452   h0->GetYaxis()->SetTitle("Entries");
453   fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h0)), 0 +fGenOffset,kFALSE);
454   delete h0;
455   fSDDhTask++;
456  
457   TH1F *h1 = new TH1F("SDDLay4TotCh","Layer 4 total charge",1000/nOnline,-0.5, 499.5);//position number 1
458   h1->GetXaxis()->SetTitle("ADC value");
459   h1->GetYaxis()->SetTitle("Entries");
460   fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h1)), 1 +fGenOffset,kFALSE);
461   delete h1;
462   fSDDhTask++;
463
464   char hisnam[50];
465   TH2F *h2 = new TH2F("SDDGlobalCoordDistribYX","YX Global Coord Distrib",5600/nOnline2,-28,28,5600/nOnline2,-28,28);//position number 2
466   h2->GetYaxis()->SetTitle("Y[cm]");
467   h2->GetXaxis()->SetTitle("X[cm]");
468   fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h2)),2+fGenOffset,kTRUE);
469   delete h2;
470   fSDDhTask++;
471
472   TH2F *h3 = new TH2F("SDDGlobalCoordDistribRZ","RZ Global Coord Distrib",6400/nOnline3,-32,32,1400/nOnline4,12,26);//position number 3
473   h3->GetYaxis()->SetTitle("R[cm]");
474   h3->GetXaxis()->SetTitle("Z[cm]");
475   fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h3)),3+fGenOffset,kTRUE);
476   delete h3;
477   fSDDhTask++;
478   
479   TH2F *h4 = new TH2F("SDDGlobalCoordDistribL3PHIZ","#varphi Z Global Coord Distrib L3",6400/nOnline3,-32,32,360/nOnline,-TMath::Pi(),TMath::Pi());//position number 4
480   h4->GetYaxis()->SetTitle("#phi[rad]");
481   h4->GetXaxis()->SetTitle("Z[cm]");
482   fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h4)),4+fGenOffset,kFALSE);
483   delete h4;
484   fSDDhTask++;
485
486   TH2F *h5 = new TH2F("SDDGlobalCoordDistribL4PHIZ","#varphi Z Global Coord Distrib L4",6400/nOnline3,-32,32,360/nOnline,-TMath::Pi(),TMath::Pi());//position number 5
487   h5->GetYaxis()->SetTitle("#phi[rad]");
488   h5->GetXaxis()->SetTitle("Z[cm]");
489   fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h5)),5+fGenOffset,kFALSE);
490   delete h5;
491   fSDDhTask++;
492   
493   TH1F *h6 = new TH1F("SDDModPatternRP","Modules pattern RP",fgknSDDmodules,239.5,499.5); //position number 6
494   h6->GetXaxis()->SetTitle("Module number"); //spd offset = 240
495   h6->GetYaxis()->SetTitle("Entries");
496   fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h6)),6 +fGenOffset,kTRUE);
497   delete h6;
498   fSDDhTask++;
499   TH1F *h7 = new TH1F("SDDLadPatternL3RP","Ladder pattern L3 RP",14,0.5,14.5);  //position number 7
500   h7->GetXaxis()->SetTitle("Ladder #, Layer 3");
501   h7->GetYaxis()->SetTitle("Entries");
502   fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h7)),7 +fGenOffset,kTRUE);
503   delete h7;
504   fSDDhTask++;
505   TH1F *h8 = new TH1F("SDDLadPatternL4RP","Ladder pattern L4 RP",22,0.5,22.5); //position number 8
506   h8->GetXaxis()->SetTitle("Ladder #, Layer 4");
507   h8->GetYaxis()->SetTitle("Entries");
508   fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h8)),8 +fGenOffset,kTRUE);
509   delete h8;
510   fSDDhTask++;
511   TH2F *h9 = new TH2F("SDDLocalCoordDistrib","Local Coord Distrib",1000/nOnline,-4,4,1000/nOnline,-4,4);//position number 9
512   h9->GetXaxis()->SetTitle("X local coord, drift, cm");
513   h9->GetYaxis()->SetTitle("Z local coord, anode, cm");
514   fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h9)),9 +fGenOffset,kTRUE);
515   delete h9;
516   fSDDhTask++;
517
518
519     TH1F *h10 = new TH1F("SDDrdistrib_Layer3" ,"SDD r distribution Layer3" ,100,14.,18.);//position number 10 (L3)
520     h10->GetXaxis()->SetTitle("r[cm]");
521     h10->GetXaxis()->CenterTitle();
522     h10->GetYaxis()->SetTitle("Entries");
523     fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h10)),10 +fGenOffset,kTRUE);
524     delete h10;
525     fSDDhTask++;
526
527     TH1F *h11 = new TH1F("SDDrdistrib_Layer4" ,"SDD r distribution Layer4" ,100,22.,26.);// and position number 11 (L4)
528     h11->GetXaxis()->SetTitle("r[cm]");
529     h11->GetXaxis()->CenterTitle();
530     h11->GetYaxis()->SetTitle("Entries");
531     fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h11)),11 +fGenOffset,kTRUE);
532     delete h11;
533     fSDDhTask++;
534
535   for(Int_t iLay=0; iLay<=1; iLay++){
536     sprintf(hisnam,"SDDphidistrib_Layer%d",iLay+3);
537     TH1F *h12 = new TH1F(hisnam,hisnam,180,-TMath::Pi(),TMath::Pi());//position number 12 (L3) and position number 13 (L4)
538     h12->GetXaxis()->SetTitle("#varphi[rad]");
539     h12->GetXaxis()->CenterTitle();
540     h12->GetYaxis()->SetTitle("Entries");
541     fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h12)),iLay+12+fGenOffset,kTRUE);
542     delete h12;
543     fSDDhTask++;
544   }
545
546   if(fkOnline)
547     {
548       TH2F *h14 = new TH2F("SDDGlobalCoordDistribYXFSE","YX Global Coord Distrib FSE",5600/nOnline2,-28,28,5600/nOnline2,-28,28);//position number 14
549       h14->GetYaxis()->SetTitle("Y[cm]");
550       h14->GetXaxis()->SetTitle("X[cm]");
551       fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h14)),14+fGenOffset,kTRUE);
552       delete h14;
553       fSDDhTask++;
554       
555       TH2F *h15 = new TH2F("SDDGlobalCoordDistribRZFSE","RZ Global Coord Distrib FSE",Int_t(6400/nOnline3),-32,32,1400/nOnline4,12,26);//position number 15
556       h15->GetYaxis()->SetTitle("R[cm]");
557       h15->GetXaxis()->SetTitle("Z[cm]");
558       fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h15)),15+fGenOffset,kTRUE);
559       delete h15;
560       fSDDhTask++;
561       
562     }//online
563
564
565
566   AliDebug(1,Form("%d SDD Recs histograms booked\n",fSDDhTask));
567
568
569 }
570
571 //____________________________________________________________________________ 
572 void AliITSQASDDDataMakerRec::MakeRecPoints(TTree * clustersTree)
573 {
574
575  // Fill QA for RecPoints - SDD -
576   Int_t lay, lad, det; 
577   TBranch *branchRecP = clustersTree->GetBranch("ITSRecPoints");
578   if (!branchRecP) {
579     AliError("can't get the branch with the ITS clusters !");
580     return;
581   }
582
583   static TClonesArray statRecpoints("AliITSRecPoint") ;
584   TClonesArray *recpoints = &statRecpoints;
585   branchRecP->SetAddress(&recpoints);
586   Int_t npoints = 0;      
587   Float_t cluglo[3]={0.,0.,0.}; 
588   if(fkOnline)
589     {
590       for(Int_t i=14;i<16;i++)
591         {
592           fAliITSQADataMakerRec->GetRecPointsData(i+fGenOffset)->Reset();
593         }
594     }
595   for(Int_t module=0; module<clustersTree->GetEntries();module++){
596     branchRecP->GetEvent(module);
597     npoints += recpoints->GetEntries();
598     AliITSgeomTGeo::GetModuleId(module, lay, lad, det);
599     //printf("modnumb %d, lay %d, lad %d, det %d \n",module, lay, lad, det);
600     for(Int_t j=0;j<recpoints->GetEntries();j++){
601       AliITSRecPoint *recp = (AliITSRecPoint*)recpoints->At(j);    
602       fAliITSQADataMakerRec->GetRecPointsData(6 +fGenOffset)->Fill(module);//modpatternrp
603       recp->GetGlobalXYZ(cluglo);
604       Float_t rad=TMath::Sqrt(cluglo[0]*cluglo[0]+cluglo[1]*cluglo[1]); 
605       Float_t phi=TMath::ATan2(cluglo[1],cluglo[0]);
606       fAliITSQADataMakerRec->GetRecPointsData(9 +fGenOffset)->Fill(recp->GetDetLocalX(),recp->GetDetLocalZ());//local distribution
607       fAliITSQADataMakerRec->GetRecPointsData(2 +fGenOffset)->Fill(cluglo[0],cluglo[1]);//global distribution YX
608       fAliITSQADataMakerRec->GetRecPointsData(3 +fGenOffset)->Fill(cluglo[2],rad);//global distribution rz
609       if(fkOnline)
610         {
611           fAliITSQADataMakerRec->GetRecPointsData(14 +fGenOffset)->Fill(cluglo[0],cluglo[1]);//global distribution YX FSE
612           fAliITSQADataMakerRec->GetRecPointsData(15 +fGenOffset)->Fill(cluglo[2],rad);//global distribution rz FSE
613         }
614       if(recp->GetLayer() ==2) {
615         fAliITSQADataMakerRec->GetRecPointsData(0 +fGenOffset)->Fill(recp->GetQ()) ;//total charge of layer 3
616         fAliITSQADataMakerRec->GetRecPointsData(7 +fGenOffset)->Fill(lad);//lad pattern layer 3
617         fAliITSQADataMakerRec->GetRecPointsData(10 +fGenOffset)->Fill(rad);//r distribution layer 3
618         fAliITSQADataMakerRec->GetRecPointsData(12 +fGenOffset)->Fill(phi);// phi distribution layer 3
619         fAliITSQADataMakerRec->GetRecPointsData(4 +fGenOffset)->Fill(cluglo[2],phi);// phi distribution layer 3
620       }
621       else if(recp->GetLayer() ==3) {
622         fAliITSQADataMakerRec->GetRecPointsData(1 +fGenOffset)->Fill(recp->GetQ()) ;//total charge layer 4
623         fAliITSQADataMakerRec->GetRecPointsData(8 +fGenOffset)->Fill(lad);//ladpatternlayer4
624         fAliITSQADataMakerRec->GetRecPointsData(11 +fGenOffset)->Fill(rad);//r distribution
625         fAliITSQADataMakerRec->GetRecPointsData(13 +fGenOffset)->Fill(phi);//phi distribution
626         fAliITSQADataMakerRec->GetRecPointsData(5 +fGenOffset)->Fill(cluglo[2],phi);// phi distribution layer 4
627       }
628     }
629   }
630   statRecpoints.Clear();
631
632 }
633
634 //_______________________________________________________________
635
636 void AliITSQASDDDataMakerRec::SetHLTModeFromEnvironment()
637 {
638
639    Int_t  hltmode= ::atoi(gSystem->Getenv("HLT_MODE"));
640
641    if(hltmode==1)
642      {
643        AliInfo("Online mode: HLT mode A selected from environment for SDD\n");
644        SetHLTMode(kFALSE);
645      }
646    else
647      if(hltmode==2)
648        {
649        AliInfo("Online mode: HLT mode C compressed selected from environment for SDD\n");
650        SetHLTMode(kTRUE);
651        }
652 }