Getting the geometry file from GRP - needed to determine the DDL mapping (Panos)
[u/mrichter/AliRoot.git] / ITS / AliITSQASSDDataMakerRec.cxx
1 /**************************************************************************
2  * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15 /* $Id$    */
16 //  *************************************************************
17 //  Checks the quality assurance 
18 //  by comparing with reference data
19 //  contained in a DB
20 //  -------------------------------------------------------------
21 //  W. Ferrarese + P. Cerello Feb 2008
22 //  INFN Torino
23
24 // --- ROOT system ---
25 #include <TH2D.h>
26 #include <TTree.h>
27 #include <TMath.h>
28 #include <TString.h>
29 #include <TSystem.h>
30
31 // --- Standard library ---
32
33 // --- AliRoot header files ---
34 #include "AliITSQASSDDataMakerRec.h"
35 #include "AliQADataMakerRec.h"
36 #include "AliLog.h"
37 #include "AliQA.h"
38 #include "AliQAChecker.h"
39 #include "AliRawReader.h"
40 #include "AliRawReaderRoot.h"
41 #include "AliITSRawStreamSSD.h"
42 #include "AliITSgeomTGeo.h"
43 #include "AliRawEventHeaderBase.h"
44 #include "AliITSRecPoint.h"
45
46 #include "AliCDBManager.h"
47 #include "AliCDBEntry.h"
48
49 ClassImp(AliITSQASSDDataMakerRec)
50
51 AliITSQASSDDataMakerRec::AliITSQASSDDataMakerRec(AliITSQADataMakerRec *aliITSQADataMakerRec, Bool_t kMode, Int_t ldc) :
52 TObject(),
53 fAliITSQADataMakerRec(aliITSQADataMakerRec),
54 fSSDEvent(0),
55 fkOnline(kMode),
56 fLDC(ldc),
57 fSSDRawsOffset(0),
58 fSSDhRaws(0),
59 fSSDhRecs(0),
60 fRawsOffset(0),
61 fRecsOffset(0) {
62   // Default constructor   
63   //initilize the raw signal vs strip number histograms
64   Int_t fLayer = 0,fLadder = 0, fModule = 0;
65   TString fTitle; Int_t fHistCounter = 0;
66   if(fkOnline) {
67     AliCDBManager * man = AliCDBManager::Instance();
68     man->SetDefaultStorage("local://$ALICE_ROOT");
69     Int_t runNumber = atoi(gSystem->Getenv("DATE_RUN_NUMBER"));
70     if(!runNumber) 
71       AliInfo("DATE_RUN_NUMBER not defined!!!\n");
72
73     man->SetRun(runNumber);
74     AliCDBEntry *geomGRP = man->Get("GRP/Geometry/Data");
75     if(!geomGRP) AliInfo("GRP geometry not found!!!\n");
76
77     for(Int_t i = 500; i < fgkSSDMODULES + 500; i++) {
78       AliITSgeomTGeo::GetModuleId(i,fLayer,fLadder,fModule);
79       fTitle = "SSD_RawSignal_Layer"; fTitle += fLayer;
80       fTitle += "_Ladder"; fTitle += fLadder;
81       fTitle += "_Module"; fTitle += fModule; 
82       fHistSSDRawSignalModule[fHistCounter] = new TH1D(fTitle.Data(),fTitle.Data(),1540,0,1540);
83       fHistCounter += 1;
84     }
85   }//online flag
86   else {
87     for(Int_t i = 0; i < fgkSSDMODULES; i++) {
88       fHistSSDRawSignalModule[i]=NULL;
89     }
90   }
91 }
92
93 //____________________________________________________________________________ 
94 AliITSQASSDDataMakerRec::AliITSQASSDDataMakerRec(const AliITSQASSDDataMakerRec& qadm) :
95 TObject(),
96 fAliITSQADataMakerRec(qadm.fAliITSQADataMakerRec),
97 fSSDEvent(qadm.fSSDEvent),
98 fkOnline(qadm.fkOnline),
99 fLDC(qadm.fLDC),
100 fSSDRawsOffset(qadm.fSSDRawsOffset),
101 fSSDhRaws(qadm.fSSDhRaws),
102 fSSDhRecs(qadm.fSSDhRecs),
103 fRawsOffset(qadm.fRawsOffset),
104 fRecsOffset(qadm.fRecsOffset) {
105   //copy ctor 
106   fAliITSQADataMakerRec->SetName((const char*)qadm.fAliITSQADataMakerRec->GetName()) ; 
107   fAliITSQADataMakerRec->SetTitle((const char*)qadm.fAliITSQADataMakerRec->GetTitle());
108 }
109
110 //__________________________________________________________________
111 AliITSQASSDDataMakerRec& AliITSQASSDDataMakerRec::operator = (const AliITSQASSDDataMakerRec& qac )
112 {
113   // Equal operator.
114   this->~AliITSQASSDDataMakerRec();
115   new(this) AliITSQASSDDataMakerRec(qac);
116   return *this;
117 }
118
119 //__________________________________________________________________
120 AliITSQASSDDataMakerRec::~AliITSQASSDDataMakerRec() {
121   // destructor
122   for(Int_t i = 0; i < fgkSSDMODULES; i++) 
123     if(fHistSSDRawSignalModule[i]) delete fHistSSDRawSignalModule[i];
124 }
125
126 //____________________________________________________________________________ 
127 void AliITSQASSDDataMakerRec::StartOfDetectorCycle()
128 {
129   //Detector specific actions at start of cycle
130   AliDebug(1,"AliITSQADM::Start of SSD Cycle\n");
131 }
132
133 //____________________________________________________________________________ 
134 void AliITSQASSDDataMakerRec::EndOfDetectorCycle(AliQA::TASKINDEX_t /*task*/, TObjArray* /*list*/)
135 {
136   // launch the QA checking
137   AliDebug(1,"AliITSDM instantiates checker with Run(AliQA::kITS, task, list)\n"); 
138   
139   //scaling SSD occupancy plots
140   if(fkOnline) {
141     if(fSSDEvent != 0) {
142       ((TH2F *)fAliITSQADataMakerRec->GetRawsData(fRawsOffset+28))->Scale(1./fSSDEvent);
143       ((TH2F *)fAliITSQADataMakerRec->GetRawsData(fRawsOffset+29))->Scale(1./fSSDEvent);
144     }
145     Int_t fLayer = 0, fLadder = 0;
146     Int_t fOccPosition = 0; 
147     for(Int_t iLayer = 5; iLayer < 7; iLayer++) {
148       for(Int_t iLadder = 1; iLadder < AliITSgeomTGeo::GetNLadders(iLayer) + 1; iLadder++) {
149         fOccPosition  = (fLayer == 5) ? fLadder : fLadder + fgkSSDLADDERSLAYER5;
150         if(fSSDEvent != 0) {
151           //P-SIDE OCCUPANCY - scaling
152           fAliITSQADataMakerRec->GetRawsData(fRawsOffset + fSSDRawsOffset - 1 + 2*fOccPosition - 1)->Scale(1./fSSDEvent);
153           //N-SIDE OCCUPANCY - scaling
154           fAliITSQADataMakerRec->GetRawsData(fRawsOffset + fSSDRawsOffset - 1 + 2*fOccPosition)->Scale(1./fSSDEvent);
155         }//ssd events != 0
156       }//ladder loop
157     }//layer loop
158   }//online flag for SSD
159   //AliQAChecker::Instance()->Run( AliQA::kITS , task, list);
160 }
161
162 //____________________________________________________________________________ 
163 void AliITSQASSDDataMakerRec::InitRaws() {  
164
165   // Initialization for RAW data - SSD -
166   fRawsOffset = (fAliITSQADataMakerRec->fRawsQAList)->GetEntries();
167
168   if(fkOnline) {
169     AliInfo("Book Online Histograms for SSD\n");
170   }
171   else {
172     AliInfo("Book Offline Histograms for SSD\n ");
173   }
174   AliInfo(Form("Number of histograms (SPD+SDD): %d\n",fRawsOffset));
175   TString fTitle = 0;
176   //book online QA histos
177   if(fkOnline) {
178     TH1F *fHistSSDEventType = new TH1F("fHistSSDEventType",
179                                        ";Event type;Events",
180                                        31,-1,30);
181     fAliITSQADataMakerRec->Add2RawsList(fHistSSDEventType, 
182                                         fRawsOffset+fSSDRawsOffset);
183     fSSDRawsOffset += 1;
184     TH1F *fHistSSDDataSize = new TH1F("fHistSSDDataSize",
185                                       ";log(SSD data size) [Bytes];Events",
186                                       100,3,8);
187     fAliITSQADataMakerRec->Add2RawsList(fHistSSDDataSize, 
188                                         fRawsOffset+fSSDRawsOffset);
189     fSSDRawsOffset += 1;
190     TH1F *fHistSSDDataSizePercentage = new TH1F("fHistSSDDataSizePercentage",
191                                                 ";SSD data size [%];Events",
192                                                 100,0,100);
193     fAliITSQADataMakerRec->Add2RawsList(fHistSSDDataSizePercentage, 
194                                         fRawsOffset+fSSDRawsOffset);
195     fSSDRawsOffset += 1;
196     TH1F *fHistSSDDDLId = new TH1F("fHistSSDDDLId",
197                                    ";DDL id;Events",20,510.5,530.5);
198     fAliITSQADataMakerRec->Add2RawsList(fHistSSDDDLId, 
199                                         fRawsOffset+fSSDRawsOffset);
200     fSSDRawsOffset += 1;
201     TH1F *fHistSSDDataSizePerDDL = new TH1F("fHistSSDDataSizePerDDL",
202                                             ";DDL id;<SSD data size> [MB]",
203                                             20,510.5,530.5);
204     fAliITSQADataMakerRec->Add2RawsList(fHistSSDDataSizePerDDL, 
205                                         fRawsOffset+fSSDRawsOffset);
206     fSSDRawsOffset += 1;
207     TH1F *fHistSSDDataSizeDDL[fgkNumOfDDLs];
208     for(Int_t i = 1; i < fgkNumOfDDLs+1; i++) {
209       fTitle = "fHistSSDDataSizeDDL"; fTitle += i+511;
210       fHistSSDDataSizeDDL[i-1] = new TH1F(fTitle.Data(),
211                                           ";log(SSD data size) [Bytes];Events",
212                                           100,1,8);
213       fAliITSQADataMakerRec->Add2RawsList(fHistSSDDataSizeDDL[i-1], 
214                                           fRawsOffset+fSSDRawsOffset);
215       fSSDRawsOffset += 1;
216     }
217     
218     TH1F *fHistSSDLDCId = new TH1F("fHistSSDLDCId",";LDC id;Events",10,0.5,10.5);
219     fAliITSQADataMakerRec->Add2RawsList(fHistSSDLDCId, 
220                                         fRawsOffset+fSSDRawsOffset);
221     fSSDRawsOffset += 1;
222     TH1F *fHistSSDDataSizePerLDC = new TH1F("fHistSSDDataSizePerLDC",
223                                             ";LDC id;<SSD data size> [MB]",
224                                             100,0,20);
225     fAliITSQADataMakerRec->Add2RawsList(fHistSSDDataSizePerLDC, 
226                                         fRawsOffset+fSSDRawsOffset);
227     fSSDRawsOffset += 1;
228     TH1F *fHistSSDDataSizeLDC[fgkNumOfLDCs];
229     for(Int_t i = 1; i < fgkNumOfLDCs+1; i++) {
230       fTitle = "fHistSSDDataSizeLDC"; fTitle += i;
231       fHistSSDDataSizeLDC[i-1] = new TH1F(fTitle.Data(),
232                                           ";log(SSD data size) [Bytes];Events",
233                                           100,1,8);
234       fAliITSQADataMakerRec->Add2RawsList(fHistSSDDataSizeLDC[i-1], 
235                                           fRawsOffset+fSSDRawsOffset);
236       fSSDRawsOffset += 1;
237     }
238
239     //top level occupancy plots
240     TH2D *fHistSSDOccupancyLayer5 = new TH2D("fHistSSDOccupancyLayer5",
241                                              ";N_{modules};N_{Ladders}",
242                                              fgkSSDMODULESPERLADDERLAYER5,
243                                              0,fgkSSDMODULESPERLADDERLAYER5,
244                                              3*fgkSSDLADDERSLAYER5,
245                                              0,fgkSSDLADDERSLAYER5);  
246     Char_t fLabel[3];
247     for(Int_t iBin = 1; iBin < fgkSSDMODULESPERLADDERLAYER5 + 1; iBin++){
248       sprintf(fLabel,"%d",iBin);
249       fHistSSDOccupancyLayer5->GetXaxis()->SetBinLabel(iBin,fLabel);
250     }
251     fAliITSQADataMakerRec->Add2RawsList(fHistSSDOccupancyLayer5, fRawsOffset+fSSDRawsOffset);
252     fSSDRawsOffset += 1;
253     TH2D *fHistSSDOccupancyLayer6 = new TH2D("fHistSSDOccupancyLayer6",
254                                              ";N_{modules};N_{Ladders}",
255                                              fgkSSDMODULESPERLADDERLAYER6,
256                                              0,fgkSSDMODULESPERLADDERLAYER6,
257                                              3*fgkSSDLADDERSLAYER6,
258                                              0,fgkSSDLADDERSLAYER6);
259     for(Int_t iBin = 1; iBin < fgkSSDMODULESPERLADDERLAYER6 + 1; iBin++){
260       sprintf(fLabel,"%d",iBin);
261       fHistSSDOccupancyLayer6->GetXaxis()->SetBinLabel(iBin,fLabel);
262     }
263     fAliITSQADataMakerRec->Add2RawsList(fHistSSDOccupancyLayer6, fRawsOffset+fSSDRawsOffset);
264     fSSDRawsOffset += 1;
265
266     //Occupancy per ladder
267     fSSDhRaws = fSSDRawsOffset;
268     TH1D *fHistOccupancyLadder[2*(fgkSSDLADDERSLAYER5 + fgkSSDLADDERSLAYER6)];
269     for(Int_t iLayer = 5; iLayer < 7; iLayer++) {
270       for(Int_t iLadder = 1; iLadder < AliITSgeomTGeo::GetNLadders(iLayer) + 1; iLadder++) {
271         //P-side occupancy plots
272         fTitle = "fHistSSD_Occupancy_Layer"; fTitle += iLayer;
273         fTitle += "_Ladder"; fTitle += iLadder; fTitle += "_PSide";
274         fHistOccupancyLadder[fSSDhRaws] = 
275           new TH1D(fTitle.Data(),
276                    fTitle.Data(),
277                    AliITSgeomTGeo::GetNDetectors(iLayer),
278                    0.5,AliITSgeomTGeo::GetNDetectors(iLayer)+0.5);
279         fHistOccupancyLadder[fSSDhRaws]->GetXaxis()->SetTitleColor(1);
280         fHistOccupancyLadder[fSSDhRaws]->GetXaxis()->SetTitle("Module number");
281         fHistOccupancyLadder[fSSDhRaws]->GetYaxis()->SetTitle("Occupancy [%]");
282         fAliITSQADataMakerRec->Add2RawsList(fHistOccupancyLadder[fSSDhRaws], 
283                                             fRawsOffset+fSSDhRaws);     
284         fSSDhRaws++;
285         //N-side occupancy plots
286         fTitle = "fHistSSD_Occupancy_Layer"; fTitle += iLayer;
287         fTitle += "_Ladder"; fTitle += iLadder; fTitle += "_NSide";
288         fHistOccupancyLadder[fSSDhRaws] = 
289           new TH1D(fTitle.Data(),
290                    fTitle.Data(),
291                    AliITSgeomTGeo::GetNDetectors(iLayer),
292                    0.5,AliITSgeomTGeo::GetNDetectors(iLayer)+0.5);
293         fHistOccupancyLadder[fSSDhRaws]->GetXaxis()->SetTitleColor(1);
294         fHistOccupancyLadder[fSSDhRaws]->GetXaxis()->SetTitle("Module number");
295         fHistOccupancyLadder[fSSDhRaws]->GetYaxis()->SetTitle("Occupancy [%]");
296         fAliITSQADataMakerRec->Add2RawsList(fHistOccupancyLadder[fSSDhRaws], 
297                                             fRawsOffset+fSSDhRaws);     
298         fSSDhRaws++;
299       }//ladder loop
300     }//layer loop
301   }//online flag
302   AliDebug(1,Form("%d SSD Raws histograms booked\n",fSSDhRaws));
303   AliInfo(Form("Number of histograms (SPD+SDD+SSD): %d\n",fRawsOffset+fSSDhRaws));  
304 }
305
306 //____________________________________________________________________________
307 void AliITSQASSDDataMakerRec::MakeRaws(AliRawReader* rawReader) { 
308   // Fill QA for RAW - SSD -
309   Int_t fStripNumber;
310   Int_t fHistPosition;
311   Int_t fLayer = 0,fLadder = 0, fModule = 0;
312   
313   Double_t fSizePerDDL[fgkNumOfDDLs] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
314   Double_t fSizePerLDC[fgkNumOfLDCs] = {0.,0.,0.};
315   Double_t sumSSDDataSize = 0.0;
316   Double_t eventSize = -1.0;
317
318   if(fkOnline) {
319     //reset the signal vs strip number histograms
320     for(Int_t i = 0; i < fgkSSDMODULES; i++) 
321       fHistSSDRawSignalModule[i]->Reset();
322   
323     rawReader->Select("ITSSSD",-1,-1);  
324     rawReader->Reset(); //rawReader->NextEvent();   
325     (fAliITSQADataMakerRec->GetRawsData(fRawsOffset))->Fill(rawReader->GetType());
326     if(rawReader->GetType() == 7)
327       fSSDEvent += 1;
328
329     AliITSRawStreamSSD fSSDStream(rawReader);    
330     AliRawReaderRoot *rootReader = (AliRawReaderRoot *)rawReader;
331     if(rootReader) {
332       const AliRawEventHeaderBase *header = rootReader->GetEventHeader();
333       if(header)
334         eventSize = header->GetEventSize();
335     }
336     while (fSSDStream.Next()) {
337       if(fSSDStream.GetModuleID() < 0) continue;
338       fSizePerDDL[rawReader->GetDDLID()] = rawReader->GetDataSize();
339       fSizePerLDC[rawReader->GetLDCId()-6] = rawReader->GetDataSize();
340       AliITSgeomTGeo::GetModuleId(fSSDStream.GetModuleID(),fLayer,fLadder,fModule);
341       fStripNumber = (fSSDStream.GetSideFlag() == 0) ? fSSDStream.GetStrip() : fSSDStream.GetStrip() + fgkNumberOfPSideStrips;
342       fHistPosition = (fLayer == 5) ? ((fLadder - 1)*fgkSSDMODULESPERLADDERLAYER5 + fModule - 1) : ((fLadder - 1)*fgkSSDMODULESPERLADDERLAYER6 + fModule + fgkSSDMODULESLAYER5 - 1);
343       //AliInfo(Form("ModulePosition: %d - Layer: %d - Ladder: %d - Module: %d\n",fHistPosition,fLayer,fLadder,fModule));
344       fHistSSDRawSignalModule[fHistPosition]->Fill(fStripNumber,fSSDStream.GetSignal());
345     }//streamer loop   
346
347     
348     for(Int_t i = 0; i < fgkNumOfDDLs; i++) {
349       sumSSDDataSize += fSizePerDDL[i];
350       if(fSizePerDDL[i] > 0) {
351         (fAliITSQADataMakerRec->GetRawsData(fRawsOffset+3))->Fill(i+512);
352         (fAliITSQADataMakerRec->GetRawsData(fRawsOffset+5+i))->Fill(TMath::Log10(fSizePerDDL[i]));
353       }
354       (fAliITSQADataMakerRec->GetRawsData(fRawsOffset+4))->Fill(i+512,fSizePerDDL[i]/1e+06);
355     }
356     for(Int_t i = 0; i < fgkNumOfLDCs; i++) {
357       if(fSizePerLDC[i] > 0) {
358         (fAliITSQADataMakerRec->GetRawsData(fRawsOffset+21))->Fill(i+6);
359         (fAliITSQADataMakerRec->GetRawsData(fRawsOffset+23+i))->Fill(TMath::Log10(fSizePerLDC[0]));
360       }
361       (fAliITSQADataMakerRec->GetRawsData(fRawsOffset+22))->Fill(i+6,fSizePerLDC[i]/1e+06);
362     }
363     if(sumSSDDataSize) 
364       (fAliITSQADataMakerRec->GetRawsData(fRawsOffset+1))->Fill(TMath::Log10(sumSSDDataSize));
365     if(eventSize)
366       (fAliITSQADataMakerRec->GetRawsData(fRawsOffset+2))->Fill(100.*sumSSDDataSize/eventSize);
367  
368     //AliInfo(Form("EVENT: %d\n",fSSDEvent));
369     Double_t occupancy = 0.0;
370     Int_t lLadderLocationY = 0;    
371     Int_t fOccPosition = 0;
372     for(Int_t i = 0; i < fgkSSDMODULES; i++) {
373       AliITSgeomTGeo::GetModuleId(i+500,fLayer,fLadder,fModule); 
374       fOccPosition  = (fLayer == 5) ? fLadder : fLadder + fgkSSDLADDERSLAYER5;
375       //P-SIDE OCCUPANCY
376       occupancy = GetSSDOccupancyRaws(fHistSSDRawSignalModule[i],0);
377       fAliITSQADataMakerRec->GetRawsData(fRawsOffset + fSSDRawsOffset - 1 + 2*fOccPosition - 1)->Fill(fModule,occupancy);
378       lLadderLocationY = 3*fLadder; // sideP=1 sideN=0
379       if(fLayer == 5)
380         ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fRawsOffset+28))->SetBinContent(fModule,lLadderLocationY,occupancy);
381       else if(fLayer == 6)
382         ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fRawsOffset+29))->SetBinContent(fModule,lLadderLocationY,occupancy);
383       //N-SIDE OCCUPANCY
384       occupancy = GetSSDOccupancyRaws(fHistSSDRawSignalModule[i],1);
385       fAliITSQADataMakerRec->GetRawsData(fRawsOffset + fSSDRawsOffset - 1 + 2*fOccPosition)->Fill(fModule,occupancy);
386       if(fLayer == 5)
387         ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fRawsOffset+28))->SetBinContent(fModule,lLadderLocationY-1,occupancy);
388       else if(fLayer == 6)
389         ((TH2D *)fAliITSQADataMakerRec->GetRawsData(fRawsOffset+29))->SetBinContent(fModule,lLadderLocationY-1,occupancy);
390     }
391   }//online flag for SSD
392 }
393
394 //____________________________________________________________________________ 
395 Double_t AliITSQASSDDataMakerRec::GetSSDOccupancyRaws(TH1 *lHisto, Int_t stripside) { 
396   // bo: TDC >0 or # of sigmas wrt noise ?
397   //stripside == 0 --> P-side
398   //stripside == 1 --> N-side
399   Int_t lNumFiredBins = 0;
400   for(Int_t iBin = 1 + stripside*fgkNumberOfPSideStrips; iBin < fgkNumberOfPSideStrips*(1 + stripside); iBin++){
401     if (lHisto->GetBinContent(iBin) > 0)
402       lNumFiredBins++; 
403   }
404   
405   Double_t lOccupancy = (100.*lNumFiredBins)/fgkNumberOfPSideStrips; // percentage
406   //AliInfo(Form("Fired strips: %d - Total strips: %d - Occupancy :%lf\n",lNumFiredBins,lHisto->GetNbinsX(),lOccupancy));
407   
408   return lOccupancy;
409 }
410
411
412 //____________________________________________________________________________ 
413 void AliITSQASSDDataMakerRec::InitRecPoints()
414 {
415   // Initialization for RECPOINTS - SSD -
416   fRecsOffset = (fAliITSQADataMakerRec->fRecPointsQAList)->GetEntries();
417   Int_t nModuleOffset = 500;
418   Int_t nITSTotalModules = AliITSgeomTGeo::GetNModules();
419
420   TH1F *fHistModuleIdLayer5 = new TH1F("fHistModuleIdLayer5",
421                                        "Module Id - Layer 5;Module Id;Entries",
422                                        fgkSSDMODULESLAYER5,
423                                        nModuleOffset - 0.5,
424                                        nITSTotalModules-fgkSSDMODULESLAYER6+0.5);
425   fAliITSQADataMakerRec->Add2RecPointsList(fHistModuleIdLayer5, 
426                                            fRecsOffset + fSSDhRecs);
427   fSSDhRecs += 1;
428   TH1F *fHistModuleIdLayer6 = new TH1F("fHistModuleIdLayer6",
429                                        "Module Id - Layer 6;Module Id;Entries",
430                                        fgkSSDMODULESLAYER6,
431                                        nModuleOffset+fgkSSDMODULESLAYER5 - 0.5,
432                                        nITSTotalModules + 0.5);
433   fAliITSQADataMakerRec->Add2RecPointsList(fHistModuleIdLayer6, 
434                                            fRecsOffset + fSSDhRecs);
435   fSSDhRecs += 1;
436   TH1F *fHistLocalXLayer5 = new TH1F("fHistLocalXLayer5",
437                                      "Local x coord.- Layer 5;x [cm];Entries;",
438                                      100,-4.,4.);
439   fAliITSQADataMakerRec->Add2RecPointsList(fHistLocalXLayer5,
440                                            fRecsOffset + fSSDhRecs);
441   fSSDhRecs += 1;
442   TH1F *fHistLocalXLayer6 = new TH1F("fHistLocalXLayer6",
443                                      "Local x coord.- Layer 6;x [cm];Entries;",
444                                      100,-4.,4.);
445   fAliITSQADataMakerRec->Add2RecPointsList(fHistLocalXLayer6, 
446                                            fRecsOffset + fSSDhRecs);
447   fSSDhRecs += 1;
448   TH1F *fHistLocalZLayer5 = new TH1F("fHistLocalZLayer5",
449                                      "Local z coord.- Layer 5;z [cm];Entries;",
450                                      100,-4.,4.);
451   fAliITSQADataMakerRec->Add2RecPointsList(fHistLocalZLayer5, 
452                                            fRecsOffset + fSSDhRecs);
453   fSSDhRecs += 1;
454   TH1F *fHistLocalZLayer6 = new TH1F("fHistLocalZLayer6",
455                                      "Local z coord.- Layer 6;z [cm];Entries;",
456                                      100,-4.,4.);
457   fAliITSQADataMakerRec->Add2RecPointsList(fHistLocalZLayer6, 
458                                            fRecsOffset + fSSDhRecs);
459   fSSDhRecs += 1;
460   TH1F *fHistGlobalXLayer5 = new TH1F("fHistGlobalXLayer5",
461                                       "Global x - Layer 5;x [cm];Entries;",
462                                       100,-40.,40.);
463   fAliITSQADataMakerRec->Add2RecPointsList(fHistGlobalXLayer5, 
464                                            fRecsOffset + fSSDhRecs);
465   fSSDhRecs += 1;
466   TH1F *fHistGlobalXLayer6 = new TH1F("fHistGlobalXLayer6",
467                                       "Global x - Layer 6;x [cm];Entries;",
468                                       100,-45.,45.);
469   fAliITSQADataMakerRec->Add2RecPointsList(fHistGlobalXLayer6, 
470                                            fRecsOffset + fSSDhRecs);
471   fSSDhRecs += 1;
472   TH1F *fHistGlobalYLayer5 = new TH1F("fHistGlobalYLayer5",
473                                       "Global y - Layer 5;y [cm];Entries;",
474                                       100,-40.,40);
475   fAliITSQADataMakerRec->Add2RecPointsList(fHistGlobalYLayer5, 
476                                            fRecsOffset + fSSDhRecs);
477   fSSDhRecs += 1;
478   TH1F *fHistGlobalYLayer6 = new TH1F("fHistGlobalYLayer6",
479                                       "Global y - Layer 6;y [cm];Entries;",
480                                       100,-45.,45.);
481   fAliITSQADataMakerRec->Add2RecPointsList(fHistGlobalYLayer6, 
482                                            fRecsOffset + fSSDhRecs);
483   fSSDhRecs += 1;
484   TH1F *fHistGlobalZLayer5 = new TH1F("fHistGlobalZLayer5",
485                                       "Global z - Layer 5;z [cm];Entries;",
486                                       100,-45.,45);
487   fAliITSQADataMakerRec->Add2RecPointsList(fHistGlobalZLayer5, 
488                                            fRecsOffset + fSSDhRecs);
489   fSSDhRecs += 1;
490   TH1F *fHistGlobalZLayer6 = new TH1F("fHistGlobalZLayer6",
491                                       "Global z - Layer 6;z [cm];Entries;",
492                                       100,-55.,55.);
493   fAliITSQADataMakerRec->Add2RecPointsList(fHistGlobalZLayer6, 
494                                            fRecsOffset + fSSDhRecs);
495   fSSDhRecs += 1;
496   TH1F *fHistPhiLayer5 = new TH1F("fHistPhiLayer5",
497                                   "#phi - Layer 5;#phi [rad];Entries;",
498                                   100,-TMath::Pi(),TMath::Pi());
499   fAliITSQADataMakerRec->Add2RecPointsList(fHistPhiLayer5, 
500                                            fRecsOffset + fSSDhRecs);
501   fSSDhRecs += 1;
502   TH1F *fHistPhiLayer6 = new TH1F("fHistPhiLayer6",
503                                   "#phi - Layer 6;#phi [rad];Entries;",
504                                   100,-TMath::Pi(),TMath::Pi());
505   fAliITSQADataMakerRec->Add2RecPointsList(fHistPhiLayer6, 
506                                            fRecsOffset + fSSDhRecs);
507   fSSDhRecs += 1;
508   TH1F *fHistThetaLayer5 = new TH1F("fHistThetaLayer5",
509                                     "#theta - Layer 5;#theta [rad];Entries;",
510                                     100,-TMath::Pi(),TMath::Pi());
511   fAliITSQADataMakerRec->Add2RecPointsList(fHistThetaLayer5, 
512                                            fRecsOffset + fSSDhRecs);
513   fSSDhRecs += 1;
514   TH1F *fHistThetaLayer6 = new TH1F("fHistThetaLayer6",
515                                     "#theta - Layer 6;#theta [rad];Entries;",
516                                     100,-TMath::Pi(),TMath::Pi());
517   fAliITSQADataMakerRec->Add2RecPointsList(fHistThetaLayer6, 
518                                            fRecsOffset + fSSDhRecs);
519   fSSDhRecs += 1;
520   TH1F *fHistRadiusLayer5 = new TH1F("fHistRadiusLayer5",
521                                      "r - Layer 5;r [cm];Entries;",
522                                      100,35.,50.);
523   fAliITSQADataMakerRec->Add2RecPointsList(fHistRadiusLayer5, 
524                                            fRecsOffset + fSSDhRecs);
525   fSSDhRecs += 1;
526   TH1F *fHistRadiusLayer6 = new TH1F("fHistRadiusLayer6",
527                                      "r - Layer 6;r [cm];Entries;",
528                                      100,35.,50.);
529   fAliITSQADataMakerRec->Add2RecPointsList(fHistRadiusLayer6, 
530                                            fRecsOffset + fSSDhRecs);
531   fSSDhRecs += 1;
532   TH1F *fHistClusterTypeLayer5 = new TH1F("fHistClusterTypeLayer5",
533                                           "CL type - Layer 5;Cluster type;Entries;",
534                                           150,0,150);
535   fAliITSQADataMakerRec->Add2RecPointsList(fHistClusterTypeLayer5, 
536                                            fRecsOffset + fSSDhRecs);
537   fSSDhRecs += 1;
538   TH1F *fHistClusterTypeLayer6 = new TH1F("fHistClusterTypeLayer6",
539                                           "CL type - Layer 6;Cluster type;Entries;",
540                                           150,0,150);
541   fAliITSQADataMakerRec->Add2RecPointsList(fHistClusterTypeLayer6, 
542                                            fRecsOffset + fSSDhRecs);
543   fSSDhRecs += 1;
544   TH1F *fHistChargeRatioLayer5 = new TH1F("fHistChargeRatioLayer5",
545                                           "Charge ratio - Layer 5;q_{ratio};Entries;",
546                                           100,-2.0,2.0);
547   fAliITSQADataMakerRec->Add2RecPointsList(fHistChargeRatioLayer5, 
548                                            fRecsOffset + fSSDhRecs);
549   fSSDhRecs += 1;
550   TH1F *fHistChargeRatioLayer6 = new TH1F("fHistChargeRatioLayer6",
551                                           "Charge ratio - Layer 6;q_{ratio};Entries;",
552                                           100,-2.0,2.0);
553   fAliITSQADataMakerRec->Add2RecPointsList(fHistChargeRatioLayer6, 
554                                            fRecsOffset + fSSDhRecs);
555   fSSDhRecs += 1;
556   TH1F *fHistChargekeVLayer5 = new TH1F("fHistChargekeVLayer5",
557                                         "Charge - Layer 5;q [keV];Entries;",
558                                         100,0.,300.);
559   fAliITSQADataMakerRec->Add2RecPointsList(fHistChargekeVLayer5, 
560                                            fRecsOffset + fSSDhRecs);
561   fSSDhRecs += 1;
562   TH1F *fHistChargekeVLayer6 = new TH1F("fHistChargekeVLayer6",
563                                         "Charge - Layer 6;q [keV];Entries;",
564                                         100,0.,300.);
565   fAliITSQADataMakerRec->Add2RecPointsList(fHistChargekeVLayer6, 
566                                            fRecsOffset + fSSDhRecs);
567   fSSDhRecs += 1;
568   TH1F *fHistChargeADCLayer5 = new TH1F("fHistChargeADCLayer5",
569                                         "Charge - Layer 5;q [ADC];Entries;",
570                                         100,0.,300.);
571   fAliITSQADataMakerRec->Add2RecPointsList(fHistChargeADCLayer5, 
572                                            fRecsOffset + fSSDhRecs);
573   fSSDhRecs += 1;
574   TH1F *fHistChargeADCLayer6 = new TH1F("fHistChargeADCLayer6",
575                                         "Charge - Layer 6;q [ADC];Entries;",
576                                         100,0.,300.);
577   fAliITSQADataMakerRec->Add2RecPointsList(fHistChargeADCLayer6, 
578                                            fRecsOffset + fSSDhRecs);
579   fSSDhRecs += 1;
580   TH2F *fHistChargeMapLayer5 = new TH2F("fHistChargeMapLayer5",
581                                         "Charge map;N_{modules};N_{Ladders}",
582                                         fgkSSDMODULESPERLADDERLAYER5,
583                                         -0.5,fgkSSDMODULESPERLADDERLAYER5+0.5,
584                                         3*fgkSSDLADDERSLAYER5,
585                                         -0.5,fgkSSDLADDERSLAYER5+0.5);
586   fAliITSQADataMakerRec->Add2RecPointsList(fHistChargeMapLayer5, 
587                                            fRecsOffset + fSSDhRecs);
588   fSSDhRecs += 1;
589   TH2F *fHistChargeMapLayer6 = new TH2F("fHistChargeMapLayer6",
590                                         "Charge map;N_{modules};N_{Ladders}",
591                                         fgkSSDMODULESPERLADDERLAYER6,
592                                         -0.5,fgkSSDMODULESPERLADDERLAYER6+0.5,
593                                         3*fgkSSDLADDERSLAYER6,
594                                         -0.5,fgkSSDLADDERSLAYER6+0.5);
595   fAliITSQADataMakerRec->Add2RecPointsList(fHistChargeMapLayer6, 
596                                            fRecsOffset + fSSDhRecs);
597   fSSDhRecs += 1;
598
599 // custom code here
600 //fSSDhRecs must be incremented by one unit every time a histogram is ADDED to the QA List
601
602   AliDebug(1,Form("%d SSD Recs histograms booked\n",fSSDhRecs));
603 }
604
605 //____________________________________________________________________________ 
606 void AliITSQASSDDataMakerRec::MakeRecPoints(TTree *clustersTree)
607 {
608   // Fill QA for recpoints - SSD -
609   Int_t fLayer = 0, fLadder = 0, fModule = 0;
610   Int_t lLadderLocationY = 0;
611   TBranch *branchRecP = clustersTree->GetBranch("ITSRecPoints");
612   if (!branchRecP) { 
613     AliError("can't get the branch with the ITS clusters !");
614     return;
615   }
616   TClonesArray * recpoints = new TClonesArray("AliITSRecPoint") ;
617   branchRecP->SetAddress(&recpoints);
618   Int_t npoints = 0;      
619   Float_t cluglo[3]={0.,0.,0.}; 
620   for(Int_t module = 0; module < clustersTree->GetEntries(); module++){
621     branchRecP->GetEvent(module);
622     npoints += recpoints->GetEntries();
623     AliITSgeomTGeo::GetModuleId(module,fLayer,fLadder,fModule);
624     lLadderLocationY = 3*fLadder;
625
626     for(Int_t j = 0;j < recpoints->GetEntries(); j++){
627       AliITSRecPoint *recp = (AliITSRecPoint*)recpoints->At(j);    
628       Int_t layer = recp->GetLayer();
629       recp->GetGlobalXYZ(cluglo);
630       Float_t radius = TMath::Sqrt(cluglo[0]*cluglo[0]+cluglo[1]*cluglo[1]); 
631       Float_t phi = TMath::ATan2(cluglo[1],cluglo[0]);
632       Float_t theta = TMath::ATan2(radius,cluglo[2]);
633       if(layer == 4) {
634         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 0)->Fill(module);
635         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 2)->Fill(recp->GetDetLocalX());
636         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 4)->Fill(recp->GetDetLocalZ());
637         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 6)->Fill(cluglo[0]);
638         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 8)->Fill(cluglo[1]);
639         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 10)->Fill(cluglo[2]);
640         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 12)->Fill(phi);
641         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 14)->Fill(theta);
642         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 16)->Fill(radius);
643         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 18)->Fill(recp->GetType());
644         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 20)->Fill(recp->GetChargeRatio());
645         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 22)->Fill(recp->GetQ());
646         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 26)->SetBinContent(fModule,lLadderLocationY,recp->GetQ());
647       }//layer 5 histograms
648       if(layer == 5) {
649         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 1)->Fill(module);
650         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 3)->Fill(recp->GetDetLocalX());
651         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 5)->Fill(recp->GetDetLocalZ());
652         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 7)->Fill(cluglo[0]);
653         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 9)->Fill(cluglo[1]);
654         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 11)->Fill(cluglo[2]);
655         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 13)->Fill(phi);
656         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 15)->Fill(theta);
657         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 17)->Fill(radius);
658         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 19)->Fill(recp->GetType());
659         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 21)->Fill(recp->GetChargeRatio());
660         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 23)->Fill(recp->GetQ());
661         fAliITSQADataMakerRec->GetRecPointsData(fRecsOffset + 27)->SetBinContent(fModule,lLadderLocationY,recp->GetQ());
662       }//layer 6 histograms
663     }//rec. points loop
664   }//module loop
665
666   recpoints->Delete();
667   delete recpoints;
668 }