ITSSPDPHYSda:
[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),
e41192d7 51fHLTMode(0),
8c823e5a 52fSubDetector(subDet),
1aa7c4f5 53fLDC(ldc),
8c823e5a 54fSPDDataMaker(NULL),
55fSDDDataMaker(NULL),
56fSSDDataMaker(NULL)
1aa7c4f5 57{
1aa7c4f5 58 //ctor used to discriminate OnLine-Offline analysis
8c823e5a 59 if(fSubDetector < 0 || fSubDetector > 3) {
60 AliError("Error: fSubDetector number out of range; return\n");
61 }
62
63 // Initialization for RAW data
64 if(fSubDetector == 0 || fSubDetector == 1) {
65 AliDebug(1,"AliITSQADM::Create SPD DataMakerRec\n");
66 fSPDDataMaker = new AliITSQASPDDataMakerRec(this,fkOnline);
67 }
68 if(fSubDetector == 0 || fSubDetector == 2) {
69 AliDebug(1,"AliITSQADM::Create SDD DataMakerRec\n");
70 fSDDDataMaker = new AliITSQASDDDataMakerRec(this,fkOnline);
e41192d7 71 if(fkOnline){SetHLTMode(fSDDDataMaker->GetHLTMode()); }
8c823e5a 72 }
73 if(fSubDetector == 0 || fSubDetector == 3) {
74 AliDebug(1,"AliITSQADM::Create SSD DataMakerRec\n");
75 fSSDDataMaker = new AliITSQASSDDataMakerRec(this,fkOnline);
76 }
1aa7c4f5 77}
78
79//____________________________________________________________________________
8c823e5a 80AliITSQADataMakerRec::~AliITSQADataMakerRec(){
81 // destructor
82 if(fSPDDataMaker)delete fSPDDataMaker;
83 if(fSDDDataMaker)delete fSDDDataMaker;
84 if(fSSDDataMaker)delete fSSDDataMaker;
04236e67 85}
86
87//____________________________________________________________________________
88AliITSQADataMakerRec::AliITSQADataMakerRec(const AliITSQADataMakerRec& qadm) :
8c823e5a 89AliQADataMakerRec(),
9db10425 90fkOnline(qadm.fkOnline),
e41192d7 91fHLTMode(qadm.fHLTMode),
8c823e5a 92fSubDetector(qadm.fSubDetector),
9db10425 93fLDC(qadm.fLDC),
8c823e5a 94fSPDDataMaker(NULL),
95fSDDDataMaker(NULL),
96fSSDDataMaker(NULL)
04236e67 97{
98 //copy ctor
99 SetName((const char*)qadm.GetName()) ;
8c823e5a 100 SetTitle((const char*)qadm.GetTitle());
04236e67 101}
102
103//__________________________________________________________________
104AliITSQADataMakerRec& AliITSQADataMakerRec::operator = (const AliITSQADataMakerRec& qac )
105{
106 // Equal operator.
107 this->~AliITSQADataMakerRec();
108 new(this) AliITSQADataMakerRec(qac);
109 return *this;
110}
111
112//____________________________________________________________________________
8c823e5a 113void AliITSQADataMakerRec::StartOfDetectorCycle()
04236e67 114{
115 //Detector specific actions at start of cycle
116 AliDebug(1,"AliITSQADM::Start of ITS Cycle\n");
8c823e5a 117 if(fSubDetector == 0 || fSubDetector == 1) fSPDDataMaker->StartOfDetectorCycle();
118 if(fSubDetector == 0 || fSubDetector == 2) fSDDDataMaker->StartOfDetectorCycle();
119 if(fSubDetector == 0 || fSubDetector == 3) fSSDDataMaker->StartOfDetectorCycle();
04236e67 120}
121
122//____________________________________________________________________________
92a357bf 123void AliITSQADataMakerRec::EndOfDetectorCycle(AliQA::TASKINDEX_t task, TObjArray* list)
04236e67 124{
125 // launch the QA checking
126 AliDebug(1,"AliITSDM instantiates checker with Run(AliQA::kITS, task, list)\n");
8c823e5a 127 if(fSubDetector == 0 || fSubDetector == 1) fSPDDataMaker->EndOfDetectorCycle(task, list);
128 if(fSubDetector == 0 || fSubDetector == 2) fSDDDataMaker->EndOfDetectorCycle(task, list);
129 if(fSubDetector == 0 || fSubDetector == 3) fSSDDataMaker->EndOfDetectorCycle(task, list);
04236e67 130
c71529b0 131 AliQAChecker *qac = AliQAChecker::Instance();
132 AliITSQAChecker *qacb = (AliITSQAChecker *) qac->GetDetQAChecker(0);
3647765c 133 if(fSubDetector == 0 ){
134 qacb->SetTaskOffset(fSPDDataMaker->GetOffset(), fSDDDataMaker->GetOffset(), fSSDDataMaker->GetOffset()); //Setting the offset for the QAChecker list
135 }
c71529b0 136 qac->Run( AliQA::kITS , task, list); //temporary skipping the checking
04236e67 137}
138
139//____________________________________________________________________________
8c823e5a 140void AliITSQADataMakerRec::EndOfDetectorCycle(const char * /*fgDataName*/)
04236e67 141{
8c823e5a 142 //eventually used for different AliQAChecker::Instance()->Run
04236e67 143}
144
145//____________________________________________________________________________
146void AliITSQADataMakerRec::InitRaws()
147{
8c823e5a 148 // Initialization for RAW data
149 if(fSubDetector == 0 || fSubDetector == 1) {
150 AliDebug(1,"AliITSQADM:: SPD InitRaws\n");
151 fSPDDataMaker->InitRaws();
1aa7c4f5 152 }
8c823e5a 153 if(fSubDetector == 0 || fSubDetector == 2) {
154 AliDebug(1,"AliITSQADM:: SDD InitRaws\n");
155 fSDDDataMaker->InitRaws();
04236e67 156 }
8c823e5a 157 if(fSubDetector == 0 || fSubDetector == 3) {
158 AliDebug(1,"AliITSQADM:: SSD InitRaws\n");
159 fSSDDataMaker->InitRaws();
04236e67 160 }
1aa7c4f5 161}
162
04236e67 163//____________________________________________________________________________
164void AliITSQADataMakerRec::MakeRaws(AliRawReader* rawReader)
165{
8c823e5a 166 // Fill QA for RAW
167 if(fSubDetector == 0 || fSubDetector == 1) fSPDDataMaker->MakeRaws(rawReader);
168 if(fSubDetector == 0 || fSubDetector == 2) fSDDDataMaker->MakeRaws(rawReader);
169 if(fSubDetector == 0 || fSubDetector == 3) fSSDDataMaker->MakeRaws(rawReader);
1aa7c4f5 170}
04236e67 171
172//____________________________________________________________________________
173void AliITSQADataMakerRec::InitRecPoints()
174{
1aa7c4f5 175 // Initialization for RECPOINTS
8c823e5a 176 if(fSubDetector == 0 || fSubDetector == 1) {
177 AliDebug(1,"AliITSQADM:: SPD InitRecPoints\n");
178 fSPDDataMaker->InitRecPoints();
04236e67 179 }
8c823e5a 180 if(fSubDetector == 0 || fSubDetector == 2) {
181 AliDebug(1,"AliITSQADM:: SDD InitRecPoints\n");
182 fSDDDataMaker->InitRecPoints();
1aa7c4f5 183 }
8c823e5a 184 if(fSubDetector == 0 || fSubDetector == 3) {
185 AliDebug(1,"AliITSQADM:: SSD InitRecPoints\n");
186 fSSDDataMaker->InitRecPoints();
1aa7c4f5 187 }
1aa7c4f5 188}
04236e67 189
190//____________________________________________________________________________
191void AliITSQADataMakerRec::MakeRecPoints(TTree * clustersTree)
192{
1aa7c4f5 193 // Fill QA for recpoints
8c823e5a 194 if(fSubDetector == 0 || fSubDetector == 1) fSPDDataMaker->MakeRecPoints(clustersTree);
195 if(fSubDetector == 0 || fSubDetector == 2) fSDDDataMaker->MakeRecPoints(clustersTree);
196 if(fSubDetector == 0 || fSubDetector == 3) fSSDDataMaker->MakeRecPoints(clustersTree);
04236e67 197}
198
d7d87ceb 199
a90a332e 200//____________________________________________________________________________
201void AliITSQADataMakerRec::InitESDs()
202{
203 // Create ESDs histograms in ESDs subdir
204
585a6e79 205 Bool_t expertHistogram = kTRUE;
206
a90a332e 207 TH1F *hESDClustersMI =
208 new TH1F("hESDClustersMI", "N ITS clusters per track (MI); N clusters; Counts",
209 7, -0.5, 6.5);
210 hESDClustersMI->Sumw2();
211 hESDClustersMI->SetMinimum(0);
212 Add2ESDsList(hESDClustersMI, 0);
213
214 TH1F *hESDClusterMapMI =
d7d87ceb 215 new TH1F("hESDClusterMapMI", "N tracks with point Layer (MI); Layer; N tracks",
a90a332e 216 6, -0.5, 5.5);
217 hESDClusterMapMI->Sumw2();
218 hESDClusterMapMI->SetMinimum(0);
585a6e79 219 Add2ESDsList(hESDClusterMapMI, 1, expertHistogram);
a90a332e 220
221 TH1F *hESDClustersSA =
222 new TH1F("hESDClustersSA", "N ITS clusters per track (SA); N clusters; Counts",
223 7, -0.5, 6.5);
224 hESDClustersSA->Sumw2();
225 hESDClustersSA->SetMinimum(0);
226 Add2ESDsList(hESDClustersSA, 2);
227
228 TH1F *hESDClusterMapSA =
d7d87ceb 229 new TH1F("hESDClusterMapSA", "N tracks with point Layer (SA); Layer; N tracks",
a90a332e 230 6, -0.5, 5.5);
231 hESDClusterMapSA->Sumw2();
232 hESDClusterMapSA->SetMinimum(0);
585a6e79 233 Add2ESDsList(hESDClusterMapSA, 3, expertHistogram);
a90a332e 234
235 TH1F *hSPDVertexX =
236 new TH1F("hSPDVertexX","SPD Vertex x; x [cm]; N events",
237 10000,-2,2);
238 hSPDVertexX->Sumw2();
239 Add2ESDsList(hSPDVertexX, 4);
240
241 TH1F *hSPDVertexY =
242 new TH1F("hSPDVertexY","SPD Vertex y; y [cm]; N events",
243 10000,-2,2);
244 hSPDVertexY->Sumw2();
245 Add2ESDsList(hSPDVertexY, 5);
246
247 TH1F *hSPDVertexZ =
d7d87ceb 248 new TH1F("hSPDVertexZ","SPD Vertex Z; z [cm]; N events",
a90a332e 249 10000,-20,20);
250 hSPDVertexZ->Sumw2();
251 Add2ESDsList(hSPDVertexZ, 6);
252
253 TH1F *hSPDVertexContrOverMult =
254 new TH1F("hSPDVertexContrOverMult","SPD Vertex: contributors / multiplicity; N contributors / SPD multiplicity; N events",
255 100,-4,20);
256 hSPDVertexContrOverMult->Sumw2();
585a6e79 257 Add2ESDsList(hSPDVertexContrOverMult, 7, expertHistogram);
a90a332e 258
259 TH1F *hTrkVertexX =
260 new TH1F("hTrkVertexX","ITS+TPC Trk Vertex x; x [cm]; N events",
261 10000,-2,2);
262 hTrkVertexX->Sumw2();
585a6e79 263 Add2ESDsList(hTrkVertexX, 8, expertHistogram);
a90a332e 264
265 TH1F *hTrkVertexY =
266 new TH1F("hTrkVertexY","ITS+TPC Trk Vertex y; y [cm]; N events",
267 10000,-2,2);
268 hTrkVertexY->Sumw2();
585a6e79 269 Add2ESDsList(hTrkVertexY, 9, expertHistogram);
a90a332e 270
271 TH1F *hTrkVertexZ =
d7d87ceb 272 new TH1F("hTrkVertexZ","ITS+TPC Trk Vertex Z; z [cm]; N events",
a90a332e 273 10000,-20,20);
274 hTrkVertexZ->Sumw2();
585a6e79 275 Add2ESDsList(hTrkVertexZ, 10, expertHistogram);
a90a332e 276
d7d87ceb 277 TH1F *hTrkVertexContrOverITSrefit5 =
278 new TH1F("hTrkVertexContrOverITSrefit5","ITS+TPC Trk Vertex: contributors / tracks; N contributors / N trks kITSrefit with 5 or 6 clusters; N events",
279 100,-4,2);
280 hTrkVertexContrOverITSrefit5->Sumw2();
585a6e79 281 Add2ESDsList(hTrkVertexContrOverITSrefit5, 11, expertHistogram);
a90a332e 282
283 TH1F *hSPDTrkVertexDeltaX =
284 new TH1F("hSPDTrkVertexDeltaX","Comparison of SPD and Trk vertices: x; xSPD-xTrk [cm]; N events",
285 1000,-1,1);
286 hSPDTrkVertexDeltaX->Sumw2();
585a6e79 287 Add2ESDsList(hSPDTrkVertexDeltaX, 12, expertHistogram);
a90a332e 288
289 TH1F *hSPDTrkVertexDeltaY =
290 new TH1F("hSPDTrkVertexDeltaY","Comparison of SPD and Trk vertices: y; ySPD-yTrk [cm]; N events",
291 1000,-1,1);
292 hSPDTrkVertexDeltaY->Sumw2();
585a6e79 293 Add2ESDsList(hSPDTrkVertexDeltaY, 13, expertHistogram);
a90a332e 294
295 TH1F *hSPDTrkVertexDeltaZ =
296 new TH1F("hSPDTrkVertexDeltaZ","Comparison of SPD and Trk vertices: z; zSPD-zTrk [cm]; N events",
297 1000,-1,1);
298 hSPDTrkVertexDeltaZ->Sumw2();
299 Add2ESDsList(hSPDTrkVertexDeltaZ, 14);
300
a8100152 301 // SPD Tracklets
302
303 TH1F* hSPDTracklets =
304 new TH1F("hSPDTracklets","N SPD Tracklets; N tracklets; Counts",300,0.,300.);
305 hSPDTracklets->Sumw2();
306 Add2ESDsList(hSPDTracklets, 15);
307
308 TH1F* hSPDTrackletsDePhi =
309 new TH1F("hSPDTrackletsDePhi","DeltaPhi SPD Tracklets; DeltaPhi [rad]; N events",200,-0.2,0.2);
310 hSPDTrackletsDePhi->Sumw2();
311 Add2ESDsList(hSPDTrackletsDePhi, 16);
312
313 TH1F* hSPDTrackletsPhi =
314 new TH1F("hSPDTrackletsPhi","Phi SPD Tracklets; Phi [rad]; N events",1000,0.,2*TMath::Pi());
315 hSPDTrackletsPhi->Sumw2();
316 Add2ESDsList(hSPDTrackletsPhi, 17);
317
318 TH1F* hSPDTrackletsTheta =
319 new TH1F("hSPDTrackletsTheta","Theta SPD Tracklets; Theta [rad]; N events",500,0.,TMath::Pi());
320 hSPDTrackletsTheta->Sumw2();
321 Add2ESDsList(hSPDTrackletsTheta, 18);
322
882ac7f1 323 // map of layers skipped by tracking (set in AliITSRecoParam)
324 TH1F *hESDSkippedLayers =
325 new TH1F("hESDSkippedLayers", "Map of layers skipped by tracking; Layer; Skipped",
326 6, -0.5, 5.5);
327 hESDSkippedLayers->Sumw2();
328 hESDSkippedLayers->SetMinimum(0);
329 Add2ESDsList(hESDSkippedLayers, 19, expertHistogram);
330
331
a90a332e 332 return;
333}
334
335//____________________________________________________________________________
336void AliITSQADataMakerRec::MakeESDs(AliESDEvent *esd)
337{
338 // Make QA data from ESDs
339
340 const Int_t nESDTracks = esd->GetNumberOfTracks();
d7d87ceb 341 Int_t nITSrefit5 = 0;
a90a332e 342
882ac7f1 343 Int_t idet,status;
344 Float_t xloc,zloc;
345
a90a332e 346 // loop on tracks
347 for(Int_t i = 0; i < nESDTracks; i++) {
348
349 AliESDtrack *track = esd->GetTrack(i);
350
351 Int_t nclsITS = track->GetNcls(0);
352
353 Bool_t itsrefit=kFALSE,tpcin=kFALSE;
354 if ((track->GetStatus() & AliESDtrack::kITSrefit)) itsrefit=kTRUE;
355 if ((track->GetStatus() & AliESDtrack::kTPCin)) tpcin=kTRUE;
d7d87ceb 356 if(nclsITS>=5 && itsrefit) nITSrefit5++;
a90a332e 357
358 if(tpcin) {
359 GetESDsData(0)->Fill(nclsITS);
360 } else {
361 GetESDsData(2)->Fill(nclsITS);
362 }
363
364 for(Int_t layer=0; layer<6; layer++) {
365
366 if(TESTBIT(track->GetITSClusterMap(),layer)) {
367 if(tpcin) {
368 GetESDsData(1)->Fill(layer);
369 } else {
370 GetESDsData(3)->Fill(layer);
371 }
372 }
882ac7f1 373 track->GetITSModuleIndexInfo(layer,idet,status,xloc,zloc);
374 if(status==3) GetESDsData(19)->SetBinContent(layer,1);
a90a332e 375 }
376
377 } // end loop on tracks
378
379 // vertices
380 const AliESDVertex *vtxSPD = esd->GetPrimaryVertexSPD();
381 const AliESDVertex *vtxTrk = esd->GetPrimaryVertex();
382
a90a332e 383 Int_t mult = ((AliMultiplicity*)(esd->GetMultiplicity()))->GetNumberOfTracklets();
384 if(mult>0)
385 GetESDsData(7)->Fill((Float_t)(vtxSPD->GetNContributors())/(Float_t)mult);
386
d7d87ceb 387 if(nITSrefit5>0)
388 GetESDsData(11)->Fill((Float_t)(vtxTrk->GetNIndices())/(Float_t)nITSrefit5);
a90a332e 389
d7d87ceb 390 if(vtxSPD->GetNContributors()>0) {
391 GetESDsData(4)->Fill(vtxSPD->GetXv());
392 GetESDsData(5)->Fill(vtxSPD->GetYv());
393 GetESDsData(6)->Fill(vtxSPD->GetZv());
394 }
a90a332e 395
d7d87ceb 396 if(vtxTrk->GetNContributors()>0) {
397 GetESDsData(8)->Fill(vtxTrk->GetXv());
398 GetESDsData(9)->Fill(vtxTrk->GetYv());
399 GetESDsData(10)->Fill(vtxTrk->GetZv());
400 }
401
402 if(vtxSPD->GetNContributors()>0 &&
403 vtxTrk->GetNContributors()>0) {
404 GetESDsData(12)->Fill(vtxSPD->GetXv()-vtxTrk->GetXv());
405 GetESDsData(13)->Fill(vtxSPD->GetYv()-vtxTrk->GetYv());
406 GetESDsData(14)->Fill(vtxSPD->GetZv()-vtxTrk->GetZv());
407 }
a90a332e 408
a8100152 409 // SPD Tracklets
410
411 // Loop over tracklets
412 GetESDsData(15)->Fill(mult);
413 for (Int_t itr=0; itr<mult; ++itr) {
414 Float_t dePhiTr = ((AliMultiplicity*)(esd->GetMultiplicity()))->GetDeltaPhi(itr);
415 Float_t phiTr = ((AliMultiplicity*)(esd->GetMultiplicity()))->GetPhi(itr);
416 Float_t thetaTr = ((AliMultiplicity*)(esd->GetMultiplicity()))->GetTheta(itr);
417 GetESDsData(16)->Fill(dePhiTr);
418 GetESDsData(17)->Fill(phiTr);
419 GetESDsData(18)->Fill(thetaTr);
420 } // end loop on tracklets
421
a90a332e 422 return;
423}