]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCQADataMakerRec.cxx
Debug printout removed.
[u/mrichter/AliRoot.git] / TPC / AliTPCQADataMakerRec.cxx
CommitLineData
44f32dd2 1/**************************************************************************
2 * Copyright(c) 1998-2007, 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
17/* $Id: $ */
18
19/*
20 Based on AliPHOSQADataMaker
21 Produces the data needed to calculate the quality assurance.
22 All data must be mergeable objects.
23 P. Christiansen, Lund, January 2008
24*/
25
26/*
27 Implementation:
28
29 We have chosen to have the histograms as non-persistent meber to
30 allow better debugging. In the copy constructor we then have to
31 assign the pointers to the existing histograms in the copied
32 list. This have been implemented but not tested.
33
34 For the QA of the RAW data we use the class, AliTPCdataQA, from the
35 existing TPC Calibration framework (which is more advanced than the
36 standard QA framework) and extract the histograms at the end. This
37 has been tested with zero-suppressed data. The Analyse method of the
38 AliTPCdataQA class is called in the method, EndOfDetectorCycle, and
39 there also: 1d histogram(s) are projected and added to the QA list.
40*/
41
42/*
43 TODO:
44 Sumw2 for RAW histogram(s)?
45 RecPoints and ESD could have many more histograms
46*/
47
48#include "AliTPCQADataMakerRec.h"
49
50// --- ROOT system ---
51#include <TClonesArray.h>
be4f1702 52#include <TString.h>
53#include <TSystem.h>
44f32dd2 54
55// --- Standard library ---
56
57// --- AliRoot header files ---
58#include "AliQAChecker.h"
59#include "AliESDEvent.h"
60#include "AliESDtrack.h"
61#include "AliLog.h"
62#include "AliTPCCalPad.h"
adcdb395 63#include "AliTPCCalROC.h"
44f32dd2 64#include "AliTPCClustersRow.h"
65#include "AliTPCclusterMI.h"
66
67ClassImp(AliTPCQADataMakerRec)
68
69//____________________________________________________________________________
70AliTPCQADataMakerRec::AliTPCQADataMakerRec() :
4e25ac79 71 AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kTPC),
44f32dd2 72 "TPC Rec Quality Assurance Data Maker"),
57acd2d2 73 fTPCdataQA(NULL)
44f32dd2 74{
75 // ctor
57acd2d2 76 fTPCdataQA = new AliTPCdataQA*[AliRecoParam::kNSpecies] ;
77 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++)
78 fTPCdataQA[specie] = NULL ;
79
be4f1702 80 for(Int_t i = 0; i < 6; i++)
81 fMapping[i] = 0;
44f32dd2 82}
83
84//____________________________________________________________________________
85AliTPCQADataMakerRec::AliTPCQADataMakerRec(const AliTPCQADataMakerRec& qadm) :
336156cc 86 AliQADataMakerRec(),
57acd2d2 87 fTPCdataQA(NULL)
44f32dd2 88{
89 //copy ctor
90 // Does not copy the calibration object, instead InitRaws have to be
91 // called again
92 SetName((const char*)qadm.GetName()) ;
93 SetTitle((const char*)qadm.GetTitle());
94
57acd2d2 95 fTPCdataQA = new AliTPCdataQA*[AliRecoParam::kNSpecies] ;
96 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++)
97 fTPCdataQA[specie] = NULL ;
98
be4f1702 99 for(Int_t i = 0; i < 6; i++)
100 fMapping[i] = 0;
101
44f32dd2 102 //
103 // Associate class histogram objects to the copies in the list
104 // Could also be done with the indexes
105 //
57acd2d2 106
44f32dd2 107}
108
109//__________________________________________________________________
110AliTPCQADataMakerRec& AliTPCQADataMakerRec::operator = (const AliTPCQADataMakerRec& qadm )
111{
112 // Equal operator.
113 this->~AliTPCQADataMakerRec();
114 new(this) AliTPCQADataMakerRec(qadm);
115 return *this;
116}
be4f1702 117
118//__________________________________________________________________
119AliTPCQADataMakerRec::~AliTPCQADataMakerRec()
120{
121 // Destructor
57acd2d2 122 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++)
123 if ( fTPCdataQA[specie] != NULL )
124 delete fTPCdataQA[specie] ;
125 delete[] fTPCdataQA;
be4f1702 126
127 for(Int_t i = 0; i < 6; i++)
128 delete fMapping[i];
129}
44f32dd2 130
131//____________________________________________________________________________
4e25ac79 132void AliTPCQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
44f32dd2 133{
134 //Detector specific actions at end of cycle
57acd2d2 135
136 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
4e25ac79 137 if ( !AliQAv1::Instance()->IsEventSpecieSet(specie) )
57acd2d2 138 continue ;
139 if(fTPCdataQA[specie] != NULL) { // do the final step of the QA for Raw data
44f32dd2 140
57acd2d2 141 fTPCdataQA[specie]->Analyse(); // 31/1-08 Analyse is now protected against
c75bf2f1 142 // RAW data files with no TPC data
57acd2d2 143
5e232cd6 144 SetEventSpecie(AliRecoParam::ConvertIndex(specie)) ;
57acd2d2 145 TH1F * histRawsOccupancy = (TH1F*)GetRawsData(kOccupancy) ;
146 TH1F * histRawsOccupancyVsSector = (TH1F*)GetRawsData(kOccupancyVsSector) ;
147 TH1F * histRawsNClustersPerEventVsSector = (TH1F*)GetRawsData(kNClustersPerEventVsSector) ;
148 TH1F * histRawsQVsSector = (TH1F*)GetRawsData(kQVsSector) ;
149 TH1F * histRawsQmaxVsSector = (TH1F*)GetRawsData(kQmaxVsSector) ;
150 if ( !histRawsOccupancy ||
151 !histRawsOccupancyVsSector ||
152 !histRawsNClustersPerEventVsSector ||
153 !histRawsQVsSector ||
154 !histRawsQmaxVsSector) {
155 AliError("Something very wrong here, corrupted memory ?????. Please check\n") ;
156 continue ;
157 }
158
159 //Add2RawsList(fTPCdataQA, 0);
160 // get the histograms and add them to the output
161 // 31/8-08 Histogram is only added if the Calibration class
162 // receives TPC data
163 const Int_t eventCounter = fTPCdataQA[specie]->GetEventCounter();
164 if(eventCounter>0) { // some TPC data has been processed
165
166 // Reset histograms and refill them
167 histRawsOccupancy->Reset();
168 histRawsOccupancyVsSector->Reset();
169 histRawsNClustersPerEventVsSector->Reset();
170 histRawsQVsSector->Reset();
171 histRawsQmaxVsSector->Reset();
adcdb395 172
57acd2d2 173 TH1F* hNorm72 = new TH1F("hNorm72", "histogram to normalize 72 sectors",
174 72, 0, 72);
175 hNorm72->Sumw2();
176 TH1F* hNorm108 = new TH1F("hNorm108", "histogram to normalize 108 sectors (medium and long pads are split up)",
177 108, 0, 108);
178 hNorm108->Sumw2();
179
180 for (Int_t iSec = 0; iSec < 72; iSec++) {
adcdb395 181
57acd2d2 182 AliTPCCalROC* occupancyROC =
183 fTPCdataQA[specie]->GetNoThreshold()->GetCalROC(iSec);
184 AliTPCCalROC* nclusterROC =
185 fTPCdataQA[specie]->GetNLocalMaxima()->GetCalROC(iSec);
186 AliTPCCalROC* qROC =
187 fTPCdataQA[specie]->GetMeanCharge()->GetCalROC(iSec);
188 AliTPCCalROC* qmaxROC =
189 fTPCdataQA[specie]->GetMaxCharge()->GetCalROC(iSec);
190
191 const Int_t nRows = occupancyROC->GetNrows();
192 for (Int_t iRow = 0; iRow < nRows; iRow++) {
193
194 Int_t helpSector = iSec;
195 if(iRow>=64)
196 helpSector += 36; // OROC (long pads)
197
198 const Int_t nPads = occupancyROC->GetNPads(iRow);
199 for (Int_t iPad = 0; iPad < nPads; iPad++) {
adcdb395 200
57acd2d2 201 histRawsOccupancy->Fill(occupancyROC->GetValue(iRow, iPad));
202 hNorm72->Fill(iSec);
203 histRawsOccupancyVsSector
204 ->Fill(iSec, occupancyROC->GetValue(iRow, iPad));
adcdb395 205
57acd2d2 206 const Int_t nClusters = TMath::Nint(nclusterROC->GetValue(iRow, iPad));
adcdb395 207
57acd2d2 208 if(nClusters>0) {
adcdb395 209
57acd2d2 210 histRawsNClustersPerEventVsSector->Fill(iSec, nClusters);
211 hNorm108->Fill(helpSector, nClusters);
212 histRawsQVsSector->Fill(helpSector,
213 nClusters*qROC->GetValue(iRow, iPad));
214 histRawsQmaxVsSector->Fill(helpSector,
215 nClusters*qmaxROC->GetValue(iRow, iPad));
216 }
217 }
218 }
219 } // end loop over sectors
adcdb395 220
57acd2d2 221 // Normalize histograms
222 histRawsOccupancyVsSector->Divide(hNorm72);
223 histRawsNClustersPerEventVsSector->Scale(1.0/Float_t(eventCounter));
224 histRawsQVsSector->Divide(hNorm108);
225 histRawsQmaxVsSector->Divide(hNorm108);
226 delete hNorm72;
227 delete hNorm108;
228 }
c75bf2f1 229 }
44f32dd2 230 }
4e25ac79 231 AliQAChecker::Instance()->Run(AliQAv1::kTPC, task, list) ;
44f32dd2 232}
233
234//____________________________________________________________________________
235void AliTPCQADataMakerRec::InitESDs()
236{
237 //create ESDs histograms in ESDs subdir
7d297381 238 const Bool_t expert = kTRUE ;
239 const Bool_t image = kTRUE ;
240
57acd2d2 241 TH1F * histESDclusters =
44f32dd2 242 new TH1F("hESDclusters", "N TPC clusters per track; N clusters; Counts",
243 160, 0, 160);
57acd2d2 244 histESDclusters->Sumw2();
7d297381 245 Add2ESDsList(histESDclusters, KClusters, !expert, image);
44f32dd2 246
57acd2d2 247 TH1F * histESDratio =
44f32dd2 248 new TH1F("hESDratio", "Ratio: TPC clusters / findable; Ratio: cluster/findable; Counts",
249 100, 0, 1);
57acd2d2 250 histESDratio->Sumw2();
7d297381 251 Add2ESDsList(histESDratio, kRatio, !expert, image);
44f32dd2 252
57acd2d2 253 TH1F * histESDpt =
44f32dd2 254 new TH1F("hESDpt", "P_{T} distribution; p_{T} [GeV/c]; Counts",
255 50, 0, 5);
57acd2d2 256 histESDpt->Sumw2();
7d297381 257 Add2ESDsList(histESDpt, kPt, !expert, image);
44f32dd2 258}
259
260//____________________________________________________________________________
261void AliTPCQADataMakerRec::InitRaws()
262{
336156cc 263 //
264 // Adding the raw
be4f1702 265 //
266
267 // Modified: 7/7 - 2008
268 // Laurent Aphecetche pointed out that the mapping was read from file
269 // for each event, so now we read in the map here and set if for
270 // the raw data qa
7d297381 271 const Bool_t expert = kTRUE ;
272 const Bool_t saveCorr = kTRUE ;
273 const Bool_t image = kTRUE ;
274
57acd2d2 275 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
5e232cd6 276 fTPCdataQA[specie] = new AliTPCdataQA(AliRecoParam::ConvertIndex(specie));
57acd2d2 277 LoadMaps(); // Load Altro maps
278 fTPCdataQA[specie]->SetAltroMapping(fMapping); // set Altro mapping
279 fTPCdataQA[specie]->SetRangeTime(100, 920); // set time bin interval
7d297381 280// Add2RawsList(fTPCdataQA, kTPCdataQ, !expert, image, !saveCorrA); // This is used by the AMORE monitoring <------- THIS WILL FAIL (YS)
57acd2d2 281 }
be4f1702 282
57acd2d2 283 TH1F * histRawsOccupancy =
adcdb395 284 new TH1F("hRawsOccupancy", "Occupancy (all pads); Occupancy; Counts",
285 100, 0, 1);
57acd2d2 286 histRawsOccupancy->Sumw2();
7d297381 287 Add2RawsList(histRawsOccupancy, kOccupancy, !expert, image, !saveCorr);
57acd2d2 288
289 TH1F * histRawsOccupancyVsSector =
adcdb395 290 new TH1F("hRawsOccupancyVsSector", "Occupancy vs sector; Sector; Occupancy",
291 72, 0, 72);
57acd2d2 292 histRawsOccupancyVsSector->Sumw2();
7d297381 293 Add2RawsList(histRawsOccupancyVsSector, kOccupancyVsSector, !expert, image, !saveCorr);
adcdb395 294
57acd2d2 295 TH1F * histRawsNClustersPerEventVsSector =
adcdb395 296 new TH1F("hRawsNClustersPerEventVsSector", "Nclusters per event vs sector; Sector; Nclusters per event",
297 72, 0, 72);
57acd2d2 298 histRawsNClustersPerEventVsSector->Sumw2();
7d297381 299 Add2RawsList(histRawsNClustersPerEventVsSector, kNClustersPerEventVsSector, !expert, image, !saveCorr);
adcdb395 300
57acd2d2 301 TH1F * histRawsQVsSector =
adcdb395 302 new TH1F("hRawsQVsSector", "<Q> vs sector (OROC med: 36-71, long: 72-107); Sector; <Q>",
303 108, 0, 108);
57acd2d2 304 histRawsQVsSector->Sumw2();
7d297381 305 Add2RawsList(histRawsQVsSector, kQVsSector, !expert, image, !saveCorr);
adcdb395 306
57acd2d2 307 TH1F * histRawsQmaxVsSector =
adcdb395 308 new TH1F("hRawsQmaxVsSector", "<Qmax> vs sector (OROC med: 36-71, long: 72-107); Sector; <Qmax>",
309 108, 0, 108);
57acd2d2 310 histRawsQmaxVsSector->Sumw2();
7d297381 311 Add2RawsList(histRawsQmaxVsSector, kQmaxVsSector, !expert, image, !saveCorr);
44f32dd2 312}
313
314//____________________________________________________________________________
315void AliTPCQADataMakerRec::InitRecPoints()
316{
7d297381 317 const Bool_t expert = kTRUE ;
318 const Bool_t image = kTRUE ;
319
57acd2d2 320 TH1F * histRecPointsQmaxShort =
44f32dd2 321 new TH1F("hRecPointsQmaxShort", "Qmax distrbution (short pads); Qmax; Counts",
adcdb395 322 100, 0, 300);
57acd2d2 323 histRecPointsQmaxShort->Sumw2();
7d297381 324 Add2RecPointsList(histRecPointsQmaxShort, kQmaxShort, !expert, image);
44f32dd2 325
57acd2d2 326 TH1F * histRecPointsQmaxMedium =
44f32dd2 327 new TH1F("hRecPointsQmaxMedium", "Qmax distrbution (medium pads); Qmax; Counts",
adcdb395 328 100, 0, 300);
57acd2d2 329 histRecPointsQmaxMedium->Sumw2();
7d297381 330 Add2RecPointsList(histRecPointsQmaxMedium, kQmaxMedium, !expert, image);
44f32dd2 331
57acd2d2 332 TH1F * histRecPointsQmaxLong =
44f32dd2 333 new TH1F("hRecPointsQmaxLong", "Qmax distrbution (long pads); Qmax; Counts",
adcdb395 334 100, 0, 300);
57acd2d2 335 histRecPointsQmaxLong->Sumw2();
7d297381 336 Add2RecPointsList(histRecPointsQmaxLong, kQmaxLong, !expert, image);
44f32dd2 337
57acd2d2 338 TH1F * histRecPointsQShort =
44f32dd2 339 new TH1F("hRecPointsQShort", "Q distrbution (short pads); Q; Counts",
adcdb395 340 100, 0, 2000);
57acd2d2 341 histRecPointsQShort->Sumw2();
7d297381 342 Add2RecPointsList(histRecPointsQShort, kQShort, !expert, image);
44f32dd2 343
57acd2d2 344 TH1F * histRecPointsQMedium =
44f32dd2 345 new TH1F("hRecPointsQMedium", "Q distrbution (medium pads); Q; Counts",
adcdb395 346 100, 0, 2000);
57acd2d2 347 histRecPointsQMedium->Sumw2();
7d297381 348 Add2RecPointsList(histRecPointsQMedium, kQMedium, !expert, image);
44f32dd2 349
57acd2d2 350 TH1F * histRecPointsQLong =
44f32dd2 351 new TH1F("hRecPointsQLong", "Q distrbution (long pads); Q; Counts",
adcdb395 352 100, 0, 2000);
57acd2d2 353 histRecPointsQLong->Sumw2();
7d297381 354 Add2RecPointsList(histRecPointsQLong, kQLong, !expert, image);
44f32dd2 355
57acd2d2 356 TH1F * histRecPointsRow =
44f32dd2 357 new TH1F("hRecPointsRow", "Clusters per row; Row; Counts",
358 159, 0, 159);
57acd2d2 359 histRecPointsRow->Sumw2();
7d297381 360 Add2RecPointsList(histRecPointsRow, kRow, !expert, image);
44f32dd2 361}
362
363//____________________________________________________________________________
364void AliTPCQADataMakerRec::MakeESDs(AliESDEvent * esd)
365{
366 // make QA data from ESDs
367
368 const Int_t nESDTracks = esd->GetNumberOfTracks();
369 Int_t nTPCtracks = 0;
370 for(Int_t i = 0; i < nESDTracks; i++) {
371
372 AliESDtrack * track = esd->GetTrack(i);
373
374 if ((track->GetStatus() & AliESDtrack::kTPCrefit)==0)
375 continue;
376
377 nTPCtracks++;
378
379 Int_t nTPCclusters = track->GetTPCNcls();
380 Int_t nTPCclustersFindable = track->GetTPCNclsF();
47a596d8 381 if ( nTPCclustersFindable<=0) continue;
57acd2d2 382 GetESDsData(KClusters)->Fill(nTPCclusters);
383 GetESDsData(kRatio)->Fill(Float_t(nTPCclusters)/Float_t(nTPCclustersFindable));
384 GetESDsData(kPt)->Fill(track->Pt());
44f32dd2 385 }
386}
387
388//____________________________________________________________________________
389void AliTPCQADataMakerRec::MakeRaws(AliRawReader* rawReader)
390{
391 //
392 // To make QA for the RAW data we use the TPC Calibration framework
393 // to handle the data and then in the end extract the data
394 //
78328afd 395 rawReader->Reset() ;
57acd2d2 396 fTPCdataQA[AliRecoParam::AConvert(fEventSpecie)]->ProcessEvent(rawReader);
397 }
44f32dd2 398
399//____________________________________________________________________________
400void AliTPCQADataMakerRec::MakeRecPoints(TTree* recTree)
401{
402 AliTPCClustersRow *clrow = new AliTPCClustersRow();
403 clrow->SetClass("AliTPCclusterMI");
404 clrow->SetArray(0);
405 clrow->GetArray()->ExpandCreateFast(10000);
406
407 TBranch* branch = recTree->GetBranch("Segment");
408 branch->SetAddress(&clrow);
409
410 const Int_t nEntries = Int_t(recTree->GetEntries());
411 for (Int_t i = 0; i < nEntries; i++) {
412
413 branch->GetEntry(i);
414
415 const Int_t nClusters = clrow->GetArray()->GetEntriesFast();
416 for (Int_t icl=0; icl < nClusters; icl++){
417
418 AliTPCclusterMI* cluster =
419 (AliTPCclusterMI*)clrow->GetArray()->At(icl);
420
421 Float_t Qmax = cluster->GetMax();
422 Float_t Q = cluster->GetQ();
423 Int_t row = cluster->GetRow();
424
425 if(cluster->GetDetector()<36) { // IROC (short pads)
426
57acd2d2 427 GetRecPointsData(kQmaxShort)->Fill(Qmax);
428 GetRecPointsData(kQShort)->Fill(Q);
44f32dd2 429 } else { // OROC (medium and long pads)
430 row += 63;
431 if(cluster->GetRow()<64) { // medium pads
432
57acd2d2 433 GetRecPointsData(kQmaxMedium)->Fill(Qmax);
434 GetRecPointsData(kQMedium)->Fill(Q);
44f32dd2 435 } else { // long pads
436
57acd2d2 437 GetRecPointsData(kQmaxLong)->Fill(Qmax);
438 GetRecPointsData(kQLong)->Fill(Q);
44f32dd2 439 }
440 }
441
57acd2d2 442 GetRecPointsData(kRow)->Fill(row);
44f32dd2 443 } // end loop over clusters
444 } // end loop over tree
445
446 delete clrow;
447}
be4f1702 448
449//____________________________________________________________________________
450void AliTPCQADataMakerRec::LoadMaps()
451{
452 TString path = gSystem->Getenv("ALICE_ROOT");
453 path += "/TPC/mapping/Patch";
454
455 for(Int_t i = 0; i < 6; i++) {
456 TString path2 = path;
457 path2 += i;
458 path2 += ".data";
459 fMapping[i] = new AliTPCAltroMapping(path2.Data());
460 }
461}
462