Bug fix (F. Prino)
[u/mrichter/AliRoot.git] / ITS / AliITSQADataMakerRec.cxx
CommitLineData
04236e67 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// -------------------------------------------------------------
8c823e5a 23// W. Ferrarese + P. Cerello Feb 2008
04236e67 24// INFN Torino
25
26// --- ROOT system ---
04236e67 27#include <TTree.h>
04236e67 28// --- Standard library ---
29
30// --- AliRoot header files ---
31#include "AliITSQADataMakerRec.h"
8c823e5a 32#include "AliITSQASPDDataMakerRec.h"
33#include "AliITSQASDDDataMakerRec.h"
34#include "AliITSQASSDDataMakerRec.h"
04236e67 35#include "AliLog.h"
36#include "AliQA.h"
37#include "AliQAChecker.h"
c71529b0 38#include "AliITSQAChecker.h"
04236e67 39#include "AliRawReader.h"
a90a332e 40#include "AliESDEvent.h"
41#include "AliESDtrack.h"
42#include "AliESDVertex.h"
43#include "AliMultiplicity.h"
04236e67 44
45ClassImp(AliITSQADataMakerRec)
46
47//____________________________________________________________________________
8c823e5a 48AliITSQADataMakerRec::AliITSQADataMakerRec(Bool_t kMode, Short_t subDet, Short_t ldc) :
49AliQADataMakerRec(AliQA::GetDetName(AliQA::kITS), "ITS Quality Assurance Data Maker"),
1aa7c4f5 50fkOnline(kMode),
8c823e5a 51fSubDetector(subDet),
1aa7c4f5 52fLDC(ldc),
8c823e5a 53fSPDDataMaker(NULL),
54fSDDDataMaker(NULL),
55fSSDDataMaker(NULL)
1aa7c4f5 56{
1aa7c4f5 57 //ctor used to discriminate OnLine-Offline analysis
8c823e5a 58 if(fSubDetector < 0 || fSubDetector > 3) {
59 AliError("Error: fSubDetector number out of range; return\n");
60 }
61
62 // Initialization for RAW data
63 if(fSubDetector == 0 || fSubDetector == 1) {
64 AliDebug(1,"AliITSQADM::Create SPD DataMakerRec\n");
65 fSPDDataMaker = new AliITSQASPDDataMakerRec(this,fkOnline);
66 }
67 if(fSubDetector == 0 || fSubDetector == 2) {
68 AliDebug(1,"AliITSQADM::Create SDD DataMakerRec\n");
69 fSDDDataMaker = new AliITSQASDDDataMakerRec(this,fkOnline);
70 }
71 if(fSubDetector == 0 || fSubDetector == 3) {
72 AliDebug(1,"AliITSQADM::Create SSD DataMakerRec\n");
73 fSSDDataMaker = new AliITSQASSDDataMakerRec(this,fkOnline);
74 }
1aa7c4f5 75}
76
77//____________________________________________________________________________
8c823e5a 78AliITSQADataMakerRec::~AliITSQADataMakerRec(){
79 // destructor
80 if(fSPDDataMaker)delete fSPDDataMaker;
81 if(fSDDDataMaker)delete fSDDDataMaker;
82 if(fSSDDataMaker)delete fSSDDataMaker;
04236e67 83}
84
85//____________________________________________________________________________
86AliITSQADataMakerRec::AliITSQADataMakerRec(const AliITSQADataMakerRec& qadm) :
8c823e5a 87AliQADataMakerRec(),
9db10425 88fkOnline(qadm.fkOnline),
8c823e5a 89fSubDetector(qadm.fSubDetector),
9db10425 90fLDC(qadm.fLDC),
8c823e5a 91fSPDDataMaker(NULL),
92fSDDDataMaker(NULL),
93fSSDDataMaker(NULL)
04236e67 94{
95 //copy ctor
96 SetName((const char*)qadm.GetName()) ;
8c823e5a 97 SetTitle((const char*)qadm.GetTitle());
04236e67 98}
99
100//__________________________________________________________________
101AliITSQADataMakerRec& AliITSQADataMakerRec::operator = (const AliITSQADataMakerRec& qac )
102{
103 // Equal operator.
104 this->~AliITSQADataMakerRec();
105 new(this) AliITSQADataMakerRec(qac);
106 return *this;
107}
108
109//____________________________________________________________________________
8c823e5a 110void AliITSQADataMakerRec::StartOfDetectorCycle()
04236e67 111{
112 //Detector specific actions at start of cycle
113 AliDebug(1,"AliITSQADM::Start of ITS Cycle\n");
8c823e5a 114 if(fSubDetector == 0 || fSubDetector == 1) fSPDDataMaker->StartOfDetectorCycle();
115 if(fSubDetector == 0 || fSubDetector == 2) fSDDDataMaker->StartOfDetectorCycle();
116 if(fSubDetector == 0 || fSubDetector == 3) fSSDDataMaker->StartOfDetectorCycle();
04236e67 117}
118
119//____________________________________________________________________________
92a357bf 120void AliITSQADataMakerRec::EndOfDetectorCycle(AliQA::TASKINDEX_t task, TObjArray* list)
04236e67 121{
122 // launch the QA checking
123 AliDebug(1,"AliITSDM instantiates checker with Run(AliQA::kITS, task, list)\n");
8c823e5a 124 if(fSubDetector == 0 || fSubDetector == 1) fSPDDataMaker->EndOfDetectorCycle(task, list);
125 if(fSubDetector == 0 || fSubDetector == 2) fSDDDataMaker->EndOfDetectorCycle(task, list);
126 if(fSubDetector == 0 || fSubDetector == 3) fSSDDataMaker->EndOfDetectorCycle(task, list);
04236e67 127
c71529b0 128 AliQAChecker *qac = AliQAChecker::Instance();
129 AliITSQAChecker *qacb = (AliITSQAChecker *) qac->GetDetQAChecker(0);
3647765c 130 if(fSubDetector == 0 ){
131 qacb->SetTaskOffset(fSPDDataMaker->GetOffset(), fSDDDataMaker->GetOffset(), fSSDDataMaker->GetOffset()); //Setting the offset for the QAChecker list
132 }
c71529b0 133 qac->Run( AliQA::kITS , task, list); //temporary skipping the checking
04236e67 134}
135
136//____________________________________________________________________________
8c823e5a 137void AliITSQADataMakerRec::EndOfDetectorCycle(const char * /*fgDataName*/)
04236e67 138{
8c823e5a 139 //eventually used for different AliQAChecker::Instance()->Run
04236e67 140}
141
142//____________________________________________________________________________
143void AliITSQADataMakerRec::InitRaws()
144{
8c823e5a 145 // Initialization for RAW data
146 if(fSubDetector == 0 || fSubDetector == 1) {
147 AliDebug(1,"AliITSQADM:: SPD InitRaws\n");
148 fSPDDataMaker->InitRaws();
1aa7c4f5 149 }
8c823e5a 150 if(fSubDetector == 0 || fSubDetector == 2) {
151 AliDebug(1,"AliITSQADM:: SDD InitRaws\n");
152 fSDDDataMaker->InitRaws();
04236e67 153 }
8c823e5a 154 if(fSubDetector == 0 || fSubDetector == 3) {
155 AliDebug(1,"AliITSQADM:: SSD InitRaws\n");
156 fSSDDataMaker->InitRaws();
04236e67 157 }
1aa7c4f5 158}
159
04236e67 160//____________________________________________________________________________
161void AliITSQADataMakerRec::MakeRaws(AliRawReader* rawReader)
162{
8c823e5a 163 // Fill QA for RAW
164 if(fSubDetector == 0 || fSubDetector == 1) fSPDDataMaker->MakeRaws(rawReader);
165 if(fSubDetector == 0 || fSubDetector == 2) fSDDDataMaker->MakeRaws(rawReader);
166 if(fSubDetector == 0 || fSubDetector == 3) fSSDDataMaker->MakeRaws(rawReader);
1aa7c4f5 167}
04236e67 168
169//____________________________________________________________________________
170void AliITSQADataMakerRec::InitRecPoints()
171{
1aa7c4f5 172 // Initialization for RECPOINTS
8c823e5a 173 if(fSubDetector == 0 || fSubDetector == 1) {
174 AliDebug(1,"AliITSQADM:: SPD InitRecPoints\n");
175 fSPDDataMaker->InitRecPoints();
04236e67 176 }
8c823e5a 177 if(fSubDetector == 0 || fSubDetector == 2) {
178 AliDebug(1,"AliITSQADM:: SDD InitRecPoints\n");
179 fSDDDataMaker->InitRecPoints();
1aa7c4f5 180 }
8c823e5a 181 if(fSubDetector == 0 || fSubDetector == 3) {
182 AliDebug(1,"AliITSQADM:: SSD InitRecPoints\n");
183 fSSDDataMaker->InitRecPoints();
1aa7c4f5 184 }
1aa7c4f5 185}
04236e67 186
187//____________________________________________________________________________
188void AliITSQADataMakerRec::MakeRecPoints(TTree * clustersTree)
189{
1aa7c4f5 190 // Fill QA for recpoints
8c823e5a 191 if(fSubDetector == 0 || fSubDetector == 1) fSPDDataMaker->MakeRecPoints(clustersTree);
192 if(fSubDetector == 0 || fSubDetector == 2) fSDDDataMaker->MakeRecPoints(clustersTree);
193 if(fSubDetector == 0 || fSubDetector == 3) fSSDDataMaker->MakeRecPoints(clustersTree);
04236e67 194}
195
a90a332e 196//____________________________________________________________________________
197void AliITSQADataMakerRec::InitESDs()
198{
199 // Create ESDs histograms in ESDs subdir
200
201 TH1F *hESDClustersMI =
202 new TH1F("hESDClustersMI", "N ITS clusters per track (MI); N clusters; Counts",
203 7, -0.5, 6.5);
204 hESDClustersMI->Sumw2();
205 hESDClustersMI->SetMinimum(0);
206 Add2ESDsList(hESDClustersMI, 0);
207
208 TH1F *hESDClusterMapMI =
209 new TH1F("hESDClusterMapMI", "N tracks with point Layer (MI); N tracks; Layer",
210 6, -0.5, 5.5);
211 hESDClusterMapMI->Sumw2();
212 hESDClusterMapMI->SetMinimum(0);
213 Add2ESDsList(hESDClusterMapMI, 1);
214
215 TH1F *hESDClustersSA =
216 new TH1F("hESDClustersSA", "N ITS clusters per track (SA); N clusters; Counts",
217 7, -0.5, 6.5);
218 hESDClustersSA->Sumw2();
219 hESDClustersSA->SetMinimum(0);
220 Add2ESDsList(hESDClustersSA, 2);
221
222 TH1F *hESDClusterMapSA =
223 new TH1F("hESDClusterMapSA", "N tracks with point Layer (SA); N tracks; Layer",
224 6, -0.5, 5.5);
225 hESDClusterMapSA->Sumw2();
226 hESDClusterMapSA->SetMinimum(0);
227 Add2ESDsList(hESDClusterMapSA, 3);
228
229 TH1F *hSPDVertexX =
230 new TH1F("hSPDVertexX","SPD Vertex x; x [cm]; N events",
231 10000,-2,2);
232 hSPDVertexX->Sumw2();
233 Add2ESDsList(hSPDVertexX, 4);
234
235 TH1F *hSPDVertexY =
236 new TH1F("hSPDVertexY","SPD Vertex y; y [cm]; N events",
237 10000,-2,2);
238 hSPDVertexY->Sumw2();
239 Add2ESDsList(hSPDVertexY, 5);
240
241 TH1F *hSPDVertexZ =
242 new TH1F("hSPDVertexZ","SPD Vertex z; z [cm]; N events",
243 10000,-20,20);
244 hSPDVertexZ->Sumw2();
245 Add2ESDsList(hSPDVertexZ, 6);
246
247 TH1F *hSPDVertexContrOverMult =
248 new TH1F("hSPDVertexContrOverMult","SPD Vertex: contributors / multiplicity; N contributors / SPD multiplicity; N events",
249 100,-4,20);
250 hSPDVertexContrOverMult->Sumw2();
251 Add2ESDsList(hSPDVertexContrOverMult, 7);
252
253 TH1F *hTrkVertexX =
254 new TH1F("hTrkVertexX","ITS+TPC Trk Vertex x; x [cm]; N events",
255 10000,-2,2);
256 hTrkVertexX->Sumw2();
257 Add2ESDsList(hTrkVertexX, 8);
258
259 TH1F *hTrkVertexY =
260 new TH1F("hTrkVertexY","ITS+TPC Trk Vertex y; y [cm]; N events",
261 10000,-2,2);
262 hTrkVertexY->Sumw2();
263 Add2ESDsList(hTrkVertexY, 9);
264
265 TH1F *hTrkVertexZ =
266 new TH1F("hTrkVertexZ","ITS+TPC Trk Vertex z; z [cm]; N events",
267 10000,-20,20);
268 hTrkVertexZ->Sumw2();
269 Add2ESDsList(hTrkVertexZ, 10);
270
271 TH1F *hTrkVertexContrOverITSrefit6 =
272 new TH1F("hTrkVertexContrOverITSrefit6","ITS+TPC Trk Vertex: contributors / tracks; N contributors / N trks kITSrefit with 6 clusters; N events",
273 100,-4,20);
274 hTrkVertexContrOverITSrefit6->Sumw2();
275 Add2ESDsList(hTrkVertexContrOverITSrefit6, 11);
276
277 TH1F *hSPDTrkVertexDeltaX =
278 new TH1F("hSPDTrkVertexDeltaX","Comparison of SPD and Trk vertices: x; xSPD-xTrk [cm]; N events",
279 1000,-1,1);
280 hSPDTrkVertexDeltaX->Sumw2();
281 Add2ESDsList(hSPDTrkVertexDeltaX, 12);
282
283 TH1F *hSPDTrkVertexDeltaY =
284 new TH1F("hSPDTrkVertexDeltaY","Comparison of SPD and Trk vertices: y; ySPD-yTrk [cm]; N events",
285 1000,-1,1);
286 hSPDTrkVertexDeltaY->Sumw2();
287 Add2ESDsList(hSPDTrkVertexDeltaY, 13);
288
289 TH1F *hSPDTrkVertexDeltaZ =
290 new TH1F("hSPDTrkVertexDeltaZ","Comparison of SPD and Trk vertices: z; zSPD-zTrk [cm]; N events",
291 1000,-1,1);
292 hSPDTrkVertexDeltaZ->Sumw2();
293 Add2ESDsList(hSPDTrkVertexDeltaZ, 14);
294
295 return;
296}
297
298//____________________________________________________________________________
299void AliITSQADataMakerRec::MakeESDs(AliESDEvent *esd)
300{
301 // Make QA data from ESDs
302
303 const Int_t nESDTracks = esd->GetNumberOfTracks();
304 Int_t nITSrefit6 = 0;
305
306 // loop on tracks
307 for(Int_t i = 0; i < nESDTracks; i++) {
308
309 AliESDtrack *track = esd->GetTrack(i);
310
311 Int_t nclsITS = track->GetNcls(0);
312
313 Bool_t itsrefit=kFALSE,tpcin=kFALSE;
314 if ((track->GetStatus() & AliESDtrack::kITSrefit)) itsrefit=kTRUE;
315 if ((track->GetStatus() & AliESDtrack::kTPCin)) tpcin=kTRUE;
316 if(nclsITS==6 && itsrefit) nITSrefit6++;
317
318 if(tpcin) {
319 GetESDsData(0)->Fill(nclsITS);
320 } else {
321 GetESDsData(2)->Fill(nclsITS);
322 }
323
324 for(Int_t layer=0; layer<6; layer++) {
325
326 if(TESTBIT(track->GetITSClusterMap(),layer)) {
327 if(tpcin) {
328 GetESDsData(1)->Fill(layer);
329 } else {
330 GetESDsData(3)->Fill(layer);
331 }
332 }
333
334 }
335
336 } // end loop on tracks
337
338 // vertices
339 const AliESDVertex *vtxSPD = esd->GetPrimaryVertexSPD();
340 const AliESDVertex *vtxTrk = esd->GetPrimaryVertex();
341
342 GetESDsData(4)->Fill(vtxSPD->GetXv());
343 GetESDsData(5)->Fill(vtxSPD->GetYv());
344 GetESDsData(6)->Fill(vtxSPD->GetZv());
345 Int_t mult = ((AliMultiplicity*)(esd->GetMultiplicity()))->GetNumberOfTracklets();
346 if(mult>0)
347 GetESDsData(7)->Fill((Float_t)(vtxSPD->GetNContributors())/(Float_t)mult);
348
349 GetESDsData(8)->Fill(vtxTrk->GetXv());
350 GetESDsData(9)->Fill(vtxTrk->GetYv());
351 GetESDsData(10)->Fill(vtxTrk->GetZv());
352 if(nITSrefit6>0)
353 GetESDsData(11)->Fill((Float_t)(vtxTrk->GetNIndices())/(Float_t)nITSrefit6);
354
355 GetESDsData(12)->Fill(vtxSPD->GetXv()-vtxTrk->GetXv());
356 GetESDsData(13)->Fill(vtxSPD->GetYv()-vtxTrk->GetYv());
357 GetESDsData(14)->Fill(vtxSPD->GetZv()-vtxTrk->GetZv());
358
359
360 return;
361}
04236e67 362