]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSQASDDDataMakerRec.cxx
Bug fix
[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   rawReader->SelectEquipment(17,fgkeqOffset,fgkeqOffset + fgkDDLidRange); 
309
310   rawReader->Reset();       
311   AliITSRawStream *stream;
312   
313   if(fkOnline==kTRUE)
314     {
315       if(GetHLTMode()==kTRUE)
316         {
317           AliInfo("Online  mode: HLT C compressed mode used for SDD\n");
318           stream = new AliITSRawStreamSDDCompressed(rawReader); }
319       else{ 
320         AliInfo("Online  mode: HLT A mode used for SDD\n");
321         stream = new AliITSRawStreamSDD(rawReader);}     
322     }
323   else 
324     {
325       if(fHLTSDD->IsHLTmodeC()==kTRUE){
326           AliInfo("Offline  mode: HLT C compressed mode used for SDD\n");
327         stream = new AliITSRawStreamSDDCompressed(rawReader);
328       }else 
329         {
330         AliInfo("Offline  mode: HLT A mode used for SDD\n");
331         stream = new AliITSRawStreamSDD(rawReader);
332       }
333     }
334   
335   //ckeck on HLT mode
336                   
337
338   
339   //  AliITSRawStreamSDD s(rawReader); 
340   stream->SetDDLModuleMap(fDDLModuleMap);
341   
342   Int_t lay, lad, det; 
343
344   Int_t index=0;
345   if(fkOnline) {
346     for(Int_t moduleSDD =0; moduleSDD<fgknSDDmodules; moduleSDD++){
347         for(Int_t iside=0;iside<fgknSide;iside++) {
348           if(fSDDhTask > 41 + index) fAliITSQADataMakerRec->GetRawsData(41 + index +fGenOffset)->Reset();
349           index++;
350         }
351     }
352   }
353   
354   Int_t cnt = 0;
355   Int_t ildcID = -1;
356   Int_t iddl = -1;
357   Int_t isddmod = -1;
358   Int_t coord1, coord2, signal, moduleSDD, ioffset, iorder, activeModule, index1;
359   
360   while(stream->Next()) {
361     ildcID = rawReader->GetLDCId();
362     iddl = rawReader->GetDDLID() - fgkDDLIDshift;
363     isddmod = fDDLModuleMap->GetModuleNumber(iddl,stream->GetCarlosId());
364     //  cout<<"isddmod "<<isddmod<<endl;
365     if(isddmod==-1){
366       AliDebug(1,Form("Found module with iddl: %d, stream->GetCarlosId: %d \n",iddl,stream->GetCarlosId() ));
367       continue;
368     }
369     if(stream->IsCompletedModule()) {
370       AliDebug(1,Form("IsCompletedModule == KTRUE\n"));
371       continue;
372     } 
373     
374     coord1 = stream->GetCoord1();
375     coord2 = stream->GetCoord2();
376     signal = stream->GetSignal();
377     
378      moduleSDD = isddmod - fgkmodoffset;
379
380     if(isddmod <fgkmodoffset|| isddmod>fgknSDDmodules+fgkmodoffset-1) {
381       AliDebug(1,Form( "Module SDD = %d, resetting it to 1 \n",isddmod));
382       isddmod = 1;
383     }
384
385     fAliITSQADataMakerRec->GetRawsData(0 +fGenOffset)->Fill(isddmod); 
386     
387     AliITSgeomTGeo::GetModuleId(isddmod, lay, lad, det);
388     ioffset = 3;
389     iorder = 1;
390     if(lay==4) { 
391       ioffset += 14;
392       iorder = 2;   
393     } 
394     fAliITSQADataMakerRec->GetRawsData(iorder +fGenOffset)->Fill(lad);
395     fAliITSQADataMakerRec->GetRawsData(ioffset+lad-1 +fGenOffset)->Fill(det); //-1 because ladder# starts from 1    
396     
397     if(lay==3)    fAliITSQADataMakerRec->GetRawsData(39+fGenOffset)->Fill(det,lad);
398     if(lay==4) { 
399       fAliITSQADataMakerRec->GetRawsData(40+fGenOffset)->Fill(det,lad);}
400
401     Short_t iside = stream->GetChannel();
402     activeModule = moduleSDD;
403     index1 = activeModule * 2 + iside;
404     
405     if(index1<0){
406       AliDebug(1,Form("Wrong index number %d - patched to 0\n",index1));
407       index1 = 0;
408     }
409     
410     //    cout<< fSDDhTask<<endl;
411     if(fkOnline) {
412       if(fSDDhTask > 41 + index1) {
413         //      cout<<index1<<endl;
414         //cout<<"Fill"<< fAliITSQADataMakerRec->GetRawsData(41 + index1 +fGenOffset)->GetName()<<endl;
415         ((TProfile2D *)(fAliITSQADataMakerRec->GetRawsData(41 + index1 +fGenOffset)))->Fill(coord2, coord1, signal);
416         ((TProfile2D *)(fAliITSQADataMakerRec->GetRawsData(41 + index1 + 260*2 +fGenOffset)))->Fill(coord2, coord1, signal);
417       }
418     }
419     cnt++;
420     if(!(cnt%10000)) AliDebug(1,Form(" %d raw digits read",cnt));
421   }
422   AliDebug(1,Form("Event completed, %d raw digits read",cnt)); 
423   delete stream;
424   stream = NULL; 
425  }
426
427 //____________________________________________________________________________ 
428 void AliITSQASDDDataMakerRec::InitRecPoints()
429 {
430   // Initialization for RECPOINTS - SDD -
431
432  fGenOffset = (fAliITSQADataMakerRec->fRecPointsQAList)->GetEntries();
433   Int_t nOnline=1;
434   Int_t  nOnline2=1;
435   Int_t  nOnline3=1; 
436   Int_t  nOnline4=1;
437   if(fkOnline)
438     {
439       //      cout<<"konline"<<endl;
440       nOnline=4;
441       nOnline2=28;
442       nOnline3=64;
443       nOnline4=14;
444     }
445
446   
447   TH1F *h0 = new TH1F("SDDLay3TotCh","Layer 3 total charge",1000/nOnline,-0.5, 499.5); //position number 0
448   h0->GetXaxis()->SetTitle("ADC value");
449   h0->GetYaxis()->SetTitle("Entries");
450   fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h0)), 0 +fGenOffset,kFALSE);
451   delete h0;
452   fSDDhTask++;
453  
454   TH1F *h1 = new TH1F("SDDLay4TotCh","Layer 4 total charge",1000/nOnline,-0.5, 499.5);//position number 1
455   h1->GetXaxis()->SetTitle("ADC value");
456   h1->GetYaxis()->SetTitle("Entries");
457   fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h1)), 1 +fGenOffset,kFALSE);
458   delete h1;
459   fSDDhTask++;
460
461   char hisnam[50];
462   TH2F *h2 = new TH2F("SDDGlobalCoordDistribYX","YX Global Coord Distrib",5600/nOnline2,-28,28,5600/nOnline2,-28,28);//position number 2
463   h2->GetYaxis()->SetTitle("Y[cm]");
464   h2->GetXaxis()->SetTitle("X[cm]");
465   fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h2)),2+fGenOffset,kTRUE);
466   delete h2;
467   fSDDhTask++;
468
469   TH2F *h3 = new TH2F("SDDGlobalCoordDistribRZ","RZ Global Coord Distrib",6400/nOnline3,-32,32,1400/nOnline4,12,26);//position number 3
470   h3->GetYaxis()->SetTitle("R[cm]");
471   h3->GetXaxis()->SetTitle("Z[cm]");
472   fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h3)),3+fGenOffset,kTRUE);
473   delete h3;
474   fSDDhTask++;
475   
476   TH2F *h4 = new TH2F("SDDGlobalCoordDistribL3PHIZ","#varphi Z Global Coord Distrib L3",6400/nOnline3,-32,32,360/nOnline,-TMath::Pi(),TMath::Pi());//position number 4
477   h4->GetYaxis()->SetTitle("#phi[rad]");
478   h4->GetXaxis()->SetTitle("Z[cm]");
479   fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h4)),4+fGenOffset,kFALSE);
480   delete h4;
481   fSDDhTask++;
482
483   TH2F *h5 = new TH2F("SDDGlobalCoordDistribL4PHIZ","#varphi Z Global Coord Distrib L4",6400/nOnline3,-32,32,360/nOnline,-TMath::Pi(),TMath::Pi());//position number 5
484   h5->GetYaxis()->SetTitle("#phi[rad]");
485   h5->GetXaxis()->SetTitle("Z[cm]");
486   fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h5)),5+fGenOffset,kFALSE);
487   delete h5;
488   fSDDhTask++;
489   
490   TH1F *h6 = new TH1F("SDDModPatternRP","Modules pattern RP",fgknSDDmodules,239.5,499.5); //position number 6
491   h6->GetXaxis()->SetTitle("Module number"); //spd offset = 240
492   h6->GetYaxis()->SetTitle("Entries");
493   fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h6)),6 +fGenOffset,kTRUE);
494   delete h6;
495   fSDDhTask++;
496   TH1F *h7 = new TH1F("SDDLadPatternL3RP","Ladder pattern L3 RP",14,0.5,14.5);  //position number 7
497   h7->GetXaxis()->SetTitle("Ladder #, Layer 3");
498   h7->GetYaxis()->SetTitle("Entries");
499   fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h7)),7 +fGenOffset,kTRUE);
500   delete h7;
501   fSDDhTask++;
502   TH1F *h8 = new TH1F("SDDLadPatternL4RP","Ladder pattern L4 RP",22,0.5,22.5); //position number 8
503   h8->GetXaxis()->SetTitle("Ladder #, Layer 4");
504   h8->GetYaxis()->SetTitle("Entries");
505   fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h8)),8 +fGenOffset,kTRUE);
506   delete h8;
507   fSDDhTask++;
508   TH2F *h9 = new TH2F("SDDLocalCoordDistrib","Local Coord Distrib",1000/nOnline,-4,4,1000/nOnline,-4,4);//position number 9
509   h9->GetXaxis()->SetTitle("X local coord, drift, cm");
510   h9->GetYaxis()->SetTitle("Z local coord, anode, cm");
511   fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h9)),9 +fGenOffset,kTRUE);
512   delete h9;
513   fSDDhTask++;
514
515
516     TH1F *h10 = new TH1F("SDDrdistrib_Layer3" ,"SDD r distribution Layer3" ,100,14.,18.);//position number 10 (L3)
517     h10->GetXaxis()->SetTitle("r[cm]");
518     h10->GetXaxis()->CenterTitle();
519     h10->GetYaxis()->SetTitle("Entries");
520     fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h10)),10 +fGenOffset,kTRUE);
521     delete h10;
522     fSDDhTask++;
523
524     TH1F *h11 = new TH1F("SDDrdistrib_Layer4" ,"SDD r distribution Layer4" ,100,22.,26.);// and position number 11 (L4)
525     h11->GetXaxis()->SetTitle("r[cm]");
526     h11->GetXaxis()->CenterTitle();
527     h11->GetYaxis()->SetTitle("Entries");
528     fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h11)),11 +fGenOffset,kTRUE);
529     delete h11;
530     fSDDhTask++;
531
532   for(Int_t iLay=0; iLay<=1; iLay++){
533     sprintf(hisnam,"SDDphidistrib_Layer%d",iLay+3);
534     TH1F *h12 = new TH1F(hisnam,hisnam,180,-TMath::Pi(),TMath::Pi());//position number 12 (L3) and position number 13 (L4)
535     h12->GetXaxis()->SetTitle("#varphi[rad]");
536     h12->GetXaxis()->CenterTitle();
537     h12->GetYaxis()->SetTitle("Entries");
538     fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h12)),iLay+12+fGenOffset,kTRUE);
539     delete h12;
540     fSDDhTask++;
541   }
542
543   if(fkOnline)
544     {
545       TH2F *h14 = new TH2F("SDDGlobalCoordDistribYXFSE","YX Global Coord Distrib FSE",5600/nOnline2,-28,28,5600/nOnline2,-28,28);//position number 14
546       h14->GetYaxis()->SetTitle("Y[cm]");
547       h14->GetXaxis()->SetTitle("X[cm]");
548       fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h14)),14+fGenOffset,kTRUE);
549       delete h14;
550       fSDDhTask++;
551       
552       TH2F *h15 = new TH2F("SDDGlobalCoordDistribRZFSE","RZ Global Coord Distrib FSE",Int_t(6400/nOnline3),-32,32,1400/nOnline4,12,26);//position number 15
553       h15->GetYaxis()->SetTitle("R[cm]");
554       h15->GetXaxis()->SetTitle("Z[cm]");
555       fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h15)),15+fGenOffset,kTRUE);
556       delete h15;
557       fSDDhTask++;
558       
559     }//online
560
561
562
563   AliDebug(1,Form("%d SDD Recs histograms booked\n",fSDDhTask));
564
565
566 }
567
568 //____________________________________________________________________________ 
569 void AliITSQASDDDataMakerRec::MakeRecPoints(TTree * clustersTree)
570 {
571
572  // Fill QA for RecPoints - SDD -
573   Int_t lay, lad, det; 
574   TBranch *branchRecP = clustersTree->GetBranch("ITSRecPoints");
575   if (!branchRecP) {
576     AliError("can't get the branch with the ITS clusters !");
577     return;
578   }
579
580   static TClonesArray statRecpoints("AliITSRecPoint") ;
581   TClonesArray *recpoints = &statRecpoints;
582   branchRecP->SetAddress(&recpoints);
583   Int_t npoints = 0;      
584   Float_t cluglo[3]={0.,0.,0.}; 
585   if(fkOnline)
586     {
587       for(Int_t i=14;i<16;i++)
588         {
589           fAliITSQADataMakerRec->GetRecPointsData(i+fGenOffset)->Reset();
590         }
591     }
592   for(Int_t module=0; module<clustersTree->GetEntries();module++){
593     branchRecP->GetEvent(module);
594     npoints += recpoints->GetEntries();
595     AliITSgeomTGeo::GetModuleId(module, lay, lad, det);
596     //printf("modnumb %d, lay %d, lad %d, det %d \n",module, lay, lad, det);
597     for(Int_t j=0;j<recpoints->GetEntries();j++){
598       AliITSRecPoint *recp = (AliITSRecPoint*)recpoints->At(j);    
599       fAliITSQADataMakerRec->GetRecPointsData(6 +fGenOffset)->Fill(module);//modpatternrp
600       recp->GetGlobalXYZ(cluglo);
601       Float_t rad=TMath::Sqrt(cluglo[0]*cluglo[0]+cluglo[1]*cluglo[1]); 
602       Float_t phi=TMath::ATan2(cluglo[1],cluglo[0]);
603       fAliITSQADataMakerRec->GetRecPointsData(9 +fGenOffset)->Fill(recp->GetDetLocalX(),recp->GetDetLocalZ());//local distribution
604       fAliITSQADataMakerRec->GetRecPointsData(2 +fGenOffset)->Fill(cluglo[0],cluglo[1]);//global distribution YX
605       fAliITSQADataMakerRec->GetRecPointsData(3 +fGenOffset)->Fill(cluglo[2],rad);//global distribution rz
606       if(fkOnline)
607         {
608           fAliITSQADataMakerRec->GetRecPointsData(14 +fGenOffset)->Fill(cluglo[0],cluglo[1]);//global distribution YX FSE
609           fAliITSQADataMakerRec->GetRecPointsData(15 +fGenOffset)->Fill(cluglo[2],rad);//global distribution rz FSE
610         }
611       if(recp->GetLayer() ==2) {
612         fAliITSQADataMakerRec->GetRecPointsData(0 +fGenOffset)->Fill(recp->GetQ()) ;//total charge of layer 3
613         fAliITSQADataMakerRec->GetRecPointsData(7 +fGenOffset)->Fill(lad);//lad pattern layer 3
614         fAliITSQADataMakerRec->GetRecPointsData(10 +fGenOffset)->Fill(rad);//r distribution layer 3
615         fAliITSQADataMakerRec->GetRecPointsData(12 +fGenOffset)->Fill(phi);// phi distribution layer 3
616         fAliITSQADataMakerRec->GetRecPointsData(4 +fGenOffset)->Fill(cluglo[2],phi);// phi distribution layer 3
617       }
618       else if(recp->GetLayer() ==3) {
619         fAliITSQADataMakerRec->GetRecPointsData(1 +fGenOffset)->Fill(recp->GetQ()) ;//total charge layer 4
620         fAliITSQADataMakerRec->GetRecPointsData(8 +fGenOffset)->Fill(lad);//ladpatternlayer4
621         fAliITSQADataMakerRec->GetRecPointsData(11 +fGenOffset)->Fill(rad);//r distribution
622         fAliITSQADataMakerRec->GetRecPointsData(13 +fGenOffset)->Fill(phi);//phi distribution
623         fAliITSQADataMakerRec->GetRecPointsData(5 +fGenOffset)->Fill(cluglo[2],phi);// phi distribution layer 4
624       }
625     }
626   }
627   statRecpoints.Clear();
628
629 }
630
631 //_______________________________________________________________
632
633 void AliITSQASDDDataMakerRec::SetHLTModeFromEnvironment()
634 {
635
636    Int_t  hltmode= ::atoi(gSystem->Getenv("HLT_MODE"));
637
638    if(hltmode==1)
639      {
640        AliInfo("Online mode: HLT mode A selected from environment for SDD\n");
641        SetHLTMode(kFALSE);
642      }
643    else
644      if(hltmode==2)
645        {
646        AliInfo("Online mode: HLT mode C compressed selected from environment for SDD\n");
647        SetHLTMode(kTRUE);
648        }
649 }