SPD RecPoints QA (M. Nicassio)
[u/mrichter/AliRoot.git] / ITS / AliITSQASPDDataMakerRec.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 //  M. Nicassio D. Elia INFN Bari March 2008
24 //  maria.nicassio@ba.infn.it
25     
26
27 // --- ROOT system ---
28 #include <TTree.h>
29 #include <TH1.h>
30 #include <TH2.h>
31 #include <TMath.h>
32 // --- Standard library ---
33
34 // --- AliRoot header files ---
35 #include "AliITSQADataMakerRec.h"
36 #include "AliITSQASPDDataMakerRec.h"
37 #include "AliLog.h"
38 #include "AliQA.h"
39 #include "AliRawReader.h"
40 #include "AliITSRecPoint.h"
41 ClassImp(AliITSQASPDDataMakerRec)
42
43 //____________________________________________________________________________
44 AliITSQASPDDataMakerRec::AliITSQASPDDataMakerRec(AliITSQADataMakerRec *aliITSQADataMakerRec, Bool_t kMode, Short_t ldc) :
45 TObject(),
46 fAliITSQADataMakerRec(aliITSQADataMakerRec),
47 fkOnline(kMode),
48 fLDC(ldc),
49 fSPDhRaws(0),
50 fSPDhRecs(0),
51 fRawsOffset(0),
52 fRecsOffset(0)
53 {
54   //ctor used to discriminate OnLine-Offline analysis  
55 }
56
57 //____________________________________________________________________________ 
58 AliITSQASPDDataMakerRec::AliITSQASPDDataMakerRec(const AliITSQASPDDataMakerRec& qadm) :
59 TObject(),
60 fAliITSQADataMakerRec(qadm.fAliITSQADataMakerRec),
61 fkOnline(qadm.fkOnline),
62 fLDC(qadm.fLDC),
63 fSPDhRaws(qadm.fSPDhRaws),
64 fSPDhRecs(qadm.fSPDhRecs),
65 fRawsOffset(qadm.fRawsOffset),
66 fRecsOffset(qadm.fRecsOffset)
67 {
68   //copy ctor 
69   fAliITSQADataMakerRec->SetName((const char*)qadm.fAliITSQADataMakerRec->GetName()) ; 
70   fAliITSQADataMakerRec->SetTitle((const char*)qadm.fAliITSQADataMakerRec->GetTitle());
71   }
72
73 //__________________________________________________________________
74 AliITSQASPDDataMakerRec::~AliITSQASPDDataMakerRec(){
75   // destructor
76
77 }
78 //__________________________________________________________________
79
80 AliITSQASPDDataMakerRec& AliITSQASPDDataMakerRec::operator = (const AliITSQASPDDataMakerRec& qac )
81 {
82   // Equal operator.
83   this->~AliITSQASPDDataMakerRec();
84   new(this) AliITSQASPDDataMakerRec(qac);
85   return *this;
86 }
87
88 //____________________________________________________________________________ 
89 void AliITSQASPDDataMakerRec::StartOfDetectorCycle()
90 {
91   //Detector specific actions at start of cycle
92   AliDebug(1,"AliITSQADM::Start of SPD Cycle\n");
93 }
94
95 //____________________________________________________________________________ 
96 void AliITSQASPDDataMakerRec::EndOfDetectorCycle(AliQA::TASKINDEX_t /*task*/, TObjArray* /*list*/)
97 {
98   // launch the QA checking
99   AliDebug(1,"AliITSDM instantiates checker with Run(AliQA::kITS, task, list)\n"); 
100   
101   //AliQAChecker::Instance()->Run( AliQA::kITS , task, list);
102 }
103
104 //____________________________________________________________________________ 
105 void AliITSQASPDDataMakerRec::InitRaws()
106
107   // Initialization for RAW data - SPD -
108   fRawsOffset = (fAliITSQADataMakerRec->fRawsQAList)->GetEntries();
109
110   // custom code here
111
112   //fSPDhRaws must be incremented by one unit every time a histogram is ADDED to the QA List
113
114   AliDebug(1,Form("%d SPD Raws histograms booked\n",fSPDhRaws));
115
116 }
117
118
119 //____________________________________________________________________________
120 void AliITSQASPDDataMakerRec::MakeRaws(AliRawReader* /*rawReader*/)
121
122   // Fill QA for RAW - SPD -
123 }
124
125 //____________________________________________________________________________ 
126 void AliITSQASPDDataMakerRec::InitRecPoints()
127 {
128   // Initialization for RECPOINTS - SPD -
129   fRecsOffset = (fAliITSQADataMakerRec->fRecPointsQAList)->GetEntries();
130
131
132   TH1F* hlayer= new TH1F("LayPattern_SPD","Layer map - SPD",6,0.,6.);
133   hlayer->GetXaxis()->SetTitle("Layer number");
134   hlayer->GetYaxis()->SetTitle("Entries");
135   fAliITSQADataMakerRec->Add2RecPointsList(hlayer, fSPDhRecs+fRecsOffset); 
136   fSPDhRecs++;
137
138   TH1F** hmod = new TH1F*[2];
139   TH1F** hxl  = new TH1F*[2];
140   TH1F** hzl  = new TH1F*[2];
141   TH1F** hxg  = new TH1F*[2];
142   TH1F** hyg  = new TH1F*[2];
143   TH1F** hzg  = new TH1F*[2];
144   TH1F** hr   = new TH1F*[2];
145   TH1F** hphi = new TH1F*[2];
146   TH1F** hMultSPDcl = new TH1F*[2];
147   TH2F** hNyNz = new TH2F*[2];  // y and z cluster length
148   TH2F** hPhiZ = new TH2F*[2];
149
150   Float_t xlim[2]={4.5,8.};
151   Float_t zlim[2]={15.,15.};
152
153   Char_t name[50];
154   Char_t title[50];
155   for (Int_t iLay=0;iLay<2;iLay++) {
156     sprintf(name,"ModPattern_SPD%d",iLay+1);
157     sprintf(title,"Module map - SPD Layer %d",iLay+1);
158     hmod[iLay]=new TH1F(name,title,fgknSPDmodules,0,fgknSPDmodules);
159     hmod[iLay]->GetXaxis()->SetTitle("Module number");
160     hmod[iLay]->GetYaxis()->SetTitle("Entries");
161     fAliITSQADataMakerRec->Add2RecPointsList(hmod[iLay], fSPDhRecs +fRecsOffset); 
162     fSPDhRecs++;
163
164     sprintf(name,"xLoc_SPD%d",iLay+1);
165     sprintf(title,"Local x coordinate - SPD Layer %d",iLay+1);
166     hxl[iLay]=new TH1F(name,title,100,-4.,4.);
167     hxl[iLay]->GetXaxis()->SetTitle("Local x [cm]");
168     hxl[iLay]->GetYaxis()->SetTitle("Entries");
169     fAliITSQADataMakerRec->Add2RecPointsList(hxl[iLay], fSPDhRecs +fRecsOffset);
170     fSPDhRecs++;
171
172     sprintf(name,"zLoc_SPD%d",iLay+1);
173     sprintf(title,"Local z coordinate - SPD Layer %d",iLay+1);
174     hzl[iLay]=new TH1F(name,title,100,-4.,4.);
175     hzl[iLay]->GetXaxis()->SetTitle("Local z [cm]");
176     hzl[iLay]->GetYaxis()->SetTitle("Entries");
177     fAliITSQADataMakerRec->Add2RecPointsList(hzl[iLay], fSPDhRecs+fRecsOffset); 
178     fSPDhRecs++;
179
180     sprintf(name,"xGlob_SPD%d",iLay+1);
181     sprintf(title,"Global x coordinate - SPD Layer %d",iLay+1);
182     hxg[iLay]=new TH1F(name,title,100,-xlim[iLay],xlim[iLay]);
183     hxg[iLay]->GetXaxis()->SetTitle("Global x [cm]");
184     hxg[iLay]->GetYaxis()->SetTitle("Entries");
185     fAliITSQADataMakerRec->Add2RecPointsList(hxg[iLay],fSPDhRecs+fRecsOffset);  
186     fSPDhRecs++;
187
188     sprintf(name,"yGlob_SPD%d",iLay+1);
189     sprintf(title,"Global y coordinate - SPD Layer %d",iLay+1);
190     hyg[iLay]=new TH1F(name,title,100,-xlim[iLay],xlim[iLay]);
191     hyg[iLay]->GetXaxis()->SetTitle("Global y [cm]");
192     hyg[iLay]->GetYaxis()->SetTitle("Entries");
193     fAliITSQADataMakerRec->Add2RecPointsList(hyg[iLay], fSPDhRecs+fRecsOffset); 
194     fSPDhRecs++;
195
196     sprintf(name,"zGlob_SPD%d",iLay+1);
197     sprintf(title,"Global z coordinate - SPD Layer %d",iLay+1);
198     hzg[iLay]=new TH1F(name,title,150,-zlim[iLay],zlim[iLay]);
199     hzg[iLay]->GetXaxis()->SetTitle("Global z [cm]");
200     hzg[iLay]->GetYaxis()->SetTitle("Entries");
201     fAliITSQADataMakerRec->Add2RecPointsList(hzg[iLay], fSPDhRecs+fRecsOffset); 
202     fSPDhRecs++;
203
204     sprintf(name,"r_SPD%d",iLay+1);
205     sprintf(title,"Radius - SPD Layer %d",iLay+1);
206     hr[iLay]=new TH1F(name,title,100,0.,10.);
207     hr[iLay]->GetXaxis()->SetTitle("r [cm]");
208     hr[iLay]->GetYaxis()->SetTitle("Entries");
209     fAliITSQADataMakerRec->Add2RecPointsList(hr[iLay], fSPDhRecs+fRecsOffset);  
210     fSPDhRecs++;
211
212     sprintf(name,"phi_SPD%d",iLay+1);
213     sprintf(title,"#varphi - SPD Layer %d",iLay+1);
214     hphi[iLay]=new TH1F(name,title,600,0.,2*TMath::Pi());
215     hphi[iLay]->GetXaxis()->SetTitle("#varphi [rad]");
216     hphi[iLay]->GetYaxis()->SetTitle("Entries");
217     fAliITSQADataMakerRec->Add2RecPointsList(hphi[iLay], fSPDhRecs+fRecsOffset);
218     fSPDhRecs++;
219     
220     sprintf(name,"SizeYvsZ_SPD%d",iLay+1);
221     sprintf(title,"Cluster dimension - SPD Layer %d",iLay+1);
222     hNyNz[iLay]=new TH2F(name,title,100,0.,100.,100,0.,100.);
223     hNyNz[iLay]->GetXaxis()->SetTitle("z length");
224     hNyNz[iLay]->GetYaxis()->SetTitle("y length");
225     fAliITSQADataMakerRec->Add2RecPointsList(hNyNz[iLay], fSPDhRecs+fRecsOffset); 
226     fSPDhRecs++;
227
228     sprintf(name,"phi_z_SPD%d",iLay+1);
229     sprintf(title,"#varphi vs z - SPD Layer %d",iLay+1);
230     hPhiZ[iLay]=new TH2F(name,title,150,-zlim[iLay],zlim[iLay],100,0.,2*TMath::Pi());
231     hPhiZ[iLay]->GetXaxis()->SetTitle("Global z [cm]");
232     hPhiZ[iLay]->GetYaxis()->SetTitle("#varphi [rad]");
233     fAliITSQADataMakerRec->Add2RecPointsList(hPhiZ[iLay], fSPDhRecs+fRecsOffset);
234     fSPDhRecs++;
235
236   }
237
238   TH2F *hrPhi=new TH2F("r_phi_SPD","#varphi vs r - SPD",100,0.,10.,100,0.,2*TMath::Pi());
239   hrPhi->GetXaxis()->SetTitle("r [cm]");
240   hrPhi->GetYaxis()->SetTitle("#varphi [rad]");
241   fAliITSQADataMakerRec->Add2RecPointsList(hrPhi, fSPDhRecs+fRecsOffset);
242   fSPDhRecs++;
243
244   TH2F *hxy=new TH2F("x_y_SPD","Global y vs x - SPD",200,-10.,10.,200,-10.,10.);
245   hxy->GetXaxis()->SetTitle("Global x [cm]");
246   hxy->GetYaxis()->SetTitle("Global y [cm]");
247   fAliITSQADataMakerRec->Add2RecPointsList(hxy, fSPDhRecs+fRecsOffset);
248   fSPDhRecs++;
249
250   for (Int_t iLay=0;iLay<2;iLay++) {
251     sprintf(name,"Multiplicity_SPD%d",iLay+1);
252     sprintf(title,"Cluster multiplicity - SPD Layer %d",iLay+1);
253     hMultSPDcl[iLay]=new TH1F(name,title,200,0.,200.);
254     hMultSPDcl[iLay]->GetXaxis()->SetTitle("Cluster multiplicity");
255     hMultSPDcl[iLay]->GetYaxis()->SetTitle("Entries");
256     fAliITSQADataMakerRec->Add2RecPointsList(hMultSPDcl[iLay], fSPDhRecs+fRecsOffset);
257     fSPDhRecs++;
258   } 
259
260   TH2F *hMultSPDcl2MultSPDcl1 =
261             new TH2F("MultCorrelation_SPD","Cluster multiplicity correlation - SPD",200,0.,200.,200,0.,200.);
262   hMultSPDcl2MultSPDcl1->GetXaxis()->SetTitle("Clusters multiplicity (Layer 1)");
263   hMultSPDcl2MultSPDcl1->GetYaxis()->SetTitle("Clusters multiplicity (Layer 2)"); 
264   fAliITSQADataMakerRec->Add2RecPointsList(hMultSPDcl2MultSPDcl1, fSPDhRecs+fRecsOffset);
265   fSPDhRecs++;
266
267   AliDebug(1,Form("%d SPD Recs histograms booked\n",fSPDhRecs));
268
269 }
270
271 //____________________________________________________________________________ 
272 void AliITSQASPDDataMakerRec::MakeRecPoints(TTree * clusterTree)
273 {
274   // Fill QA for RecPoints - SPD -
275       TClonesArray* itsClusters = new TClonesArray("AliITSRecPoint");
276       TBranch* itsClusterBranch=clusterTree->GetBranch("ITSRecPoints");
277       if (!itsClusterBranch) {
278         AliError("can't get the branch with the ITS clusters !");
279         return;
280       }
281       itsClusterBranch->SetAddress(&itsClusters);
282       Int_t nItsMods = (Int_t)clusterTree->GetEntries();
283
284       Float_t cluGlo[3] = {0.,0.,0.};
285       Int_t nClusters[2] = {0,0};
286
287       for (Int_t iIts=0; iIts < nItsMods; iIts++) {
288
289       if (!clusterTree->GetEvent(iIts))    continue;
290       Int_t nCluster = itsClusters->GetEntriesFast();
291       // loop over clusters
292       while(nCluster--) {
293         AliITSRecPoint* cluster = (AliITSRecPoint*)itsClusters->UncheckedAt(nCluster);
294
295         if (cluster->GetLayer()>1)        continue;
296         Int_t lay=cluster->GetLayer();
297         fAliITSQADataMakerRec->GetRecPointsData(0 +fRecsOffset)->Fill(lay);
298         cluster->GetGlobalXYZ(cluGlo);
299         Float_t rad=TMath::Sqrt(cluGlo[0]*cluGlo[0]+cluGlo[1]*cluGlo[1]);
300         Float_t phi= TMath::Pi() + TMath::ATan2(-cluGlo[1],-cluGlo[0]);
301         if (lay==0) {
302           fAliITSQADataMakerRec->GetRecPointsData(1 +fRecsOffset)->Fill(iIts);
303           fAliITSQADataMakerRec->GetRecPointsData(2 +fRecsOffset)->Fill(cluster->GetDetLocalX());
304           fAliITSQADataMakerRec->GetRecPointsData(3 +fRecsOffset)->Fill(cluster->GetDetLocalZ());
305           fAliITSQADataMakerRec->GetRecPointsData(4 +fRecsOffset)->Fill(cluGlo[0]);
306           fAliITSQADataMakerRec->GetRecPointsData(5 +fRecsOffset)->Fill(cluGlo[1]);
307           fAliITSQADataMakerRec->GetRecPointsData(6 +fRecsOffset)->Fill(cluGlo[2]);
308           fAliITSQADataMakerRec->GetRecPointsData(7 +fRecsOffset)->Fill(rad);
309           fAliITSQADataMakerRec->GetRecPointsData(8 +fRecsOffset)->Fill(phi);
310           fAliITSQADataMakerRec->GetRecPointsData(9 +fRecsOffset)->Fill(cluster->GetNz(),cluster->GetNy());
311           fAliITSQADataMakerRec->GetRecPointsData(10 +fRecsOffset)->Fill(cluGlo[2],phi);
312         } else  {
313           fAliITSQADataMakerRec->GetRecPointsData(11 +fRecsOffset)->Fill(iIts);
314           fAliITSQADataMakerRec->GetRecPointsData(12 +fRecsOffset)->Fill(cluster->GetDetLocalX());
315           fAliITSQADataMakerRec->GetRecPointsData(13 +fRecsOffset)->Fill(cluster->GetDetLocalZ());
316           fAliITSQADataMakerRec->GetRecPointsData(14 +fRecsOffset)->Fill(cluGlo[0]);
317           fAliITSQADataMakerRec->GetRecPointsData(15 +fRecsOffset)->Fill(cluGlo[1]);
318           fAliITSQADataMakerRec->GetRecPointsData(16 +fRecsOffset)->Fill(cluGlo[2]);
319           fAliITSQADataMakerRec->GetRecPointsData(17 +fRecsOffset)->Fill(rad);
320           fAliITSQADataMakerRec->GetRecPointsData(18 +fRecsOffset)->Fill(phi);
321           fAliITSQADataMakerRec->GetRecPointsData(19 +fRecsOffset)->Fill(cluster->GetNz(),cluster->GetNy());
322           fAliITSQADataMakerRec->GetRecPointsData(20 +fRecsOffset)->Fill(cluGlo[2],phi);
323         }
324         fAliITSQADataMakerRec->GetRecPointsData(21 +fRecsOffset)->Fill(rad,phi);
325         fAliITSQADataMakerRec->GetRecPointsData(22 +fRecsOffset)->Fill(cluGlo[0],cluGlo[1]);
326
327         nClusters[lay]++; 
328       } // end of cluster loop
329     } // end of its "subdetector" loop
330
331     for (Int_t iLay=0; iLay<2; iLay++)
332       fAliITSQADataMakerRec->GetRecPointsData(23+iLay +fRecsOffset)->Fill(nClusters[iLay]);
333
334     fAliITSQADataMakerRec->GetRecPointsData(25 +fRecsOffset)->Fill(nClusters[0],nClusters[1]);
335
336     if (itsClusters) {
337       itsClusters->Delete();
338       delete itsClusters;
339       itsClusters = 0;
340     }
341
342 }