]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCQADataMakerRec.cxx
Cosmic tracker as an intergral part of the central ALICE reconstruction.
[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
44f32dd2 24
0ab2a4cc 25 Updated July 2011:
26 ==================
27
28 Major changes to accomodate updates of general DQM/QA changes to have per
29 trigger histograms (for a given event specie).
30
31 1) One instance of AliTPCdataQA only. (This also solves some old wishes by
32 offline team to use less memory because event the 2d arrays for this object
33 is not used). This now has a new flag for only keeping DQM info event by
34 event! For this reason there is no need for a special DQM reset any more
35 between runs!
36
37 2) Fill the histogram for each event. The histograms are no longer filled
38 from the AliTPCdataQA but per event.
39
40 3) Use profiles for the RAW info. By adding the profiles event by event we
41 get the correct event averages WITHOUT having to normalize in the end!
42 Results should therefore also be directly mergable when that feature will
43 come. (none of the other histograms are merged).
44
45 This means that from the DQM/QA point of view the TPC DQM is now fully
46 standard and should ease future developments.
47
1267cf3a 48 Updated June 2010:
49 ==================
44f32dd2 50
1267cf3a 51 The "beautification" of the online DQM histograms have been moved to
52 an amore macro.
53
54 The per event RAW histograms have been modified in AliTPCdataQA and
55 the copies have therefore also been modified here.
56
57 The AliTPCdataQA can now be configured a bit from here: time bin
58 range (extended default range to 1-1000, event range at start:
59 0-100000, 1000 events per bin). (At least the parameters are not
60 hardcoded:-)
61
62 Implementation:
63 ===============
44f32dd2 64
65 For the QA of the RAW data we use the class, AliTPCdataQA, from the
66 existing TPC Calibration framework (which is more advanced than the
1267cf3a 67 standard QA framework) and extract the histograms at the end. The
68 Analyse method of the AliTPCdataQA class is called in the method,
69 EndOfDetectorCycle, and there also: 1d histogram(s) are projected
70 and added to the QA list.
44f32dd2 71*/
72
73#include "AliTPCQADataMakerRec.h"
74
75// --- ROOT system ---
76#include <TClonesArray.h>
be4f1702 77#include <TString.h>
78#include <TSystem.h>
ce0175fa 79#include <TBox.h>
5e10013b 80#include <TLine.h>
1267cf3a 81#include <TAxis.h>
44f32dd2 82
83// --- Standard library ---
84
85// --- AliRoot header files ---
86#include "AliQAChecker.h"
87#include "AliESDEvent.h"
88#include "AliESDtrack.h"
89#include "AliLog.h"
90#include "AliTPCCalPad.h"
adcdb395 91#include "AliTPCCalROC.h"
44f32dd2 92#include "AliTPCClustersRow.h"
93#include "AliTPCclusterMI.h"
44ed7a66 94#include "AliSimDigits.h"
44f32dd2 95
1267cf3a 96
44f32dd2 97ClassImp(AliTPCQADataMakerRec)
98
99//____________________________________________________________________________
100AliTPCQADataMakerRec::AliTPCQADataMakerRec() :
ce0175fa 101AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kTPC),
102 "TPC Rec Quality Assurance Data Maker"),
1267cf3a 103fTPCdataQA(NULL),
1267cf3a 104fRawFirstTimeBin(1),
105fRawLastTimeBin(1000)
44f32dd2 106{
107 // ctor
57acd2d2 108
be4f1702 109 for(Int_t i = 0; i < 6; i++)
110 fMapping[i] = 0;
44f32dd2 111}
112
113//____________________________________________________________________________
114AliTPCQADataMakerRec::AliTPCQADataMakerRec(const AliTPCQADataMakerRec& qadm) :
336156cc 115 AliQADataMakerRec(),
ce0175fa 116 fTPCdataQA(NULL),
1267cf3a 117 fRawFirstTimeBin(qadm.GetRawFirstTimeBin()),
118 fRawLastTimeBin(qadm.GetRawLastTimeBin())
44f32dd2 119{
120 //copy ctor
121 // Does not copy the calibration object, instead InitRaws have to be
122 // called again
123 SetName((const char*)qadm.GetName()) ;
124 SetTitle((const char*)qadm.GetTitle());
125
be4f1702 126 for(Int_t i = 0; i < 6; i++)
127 fMapping[i] = 0;
44f32dd2 128}
129
130//__________________________________________________________________
131AliTPCQADataMakerRec& AliTPCQADataMakerRec::operator = (const AliTPCQADataMakerRec& qadm )
132{
133 // Equal operator.
134 this->~AliTPCQADataMakerRec();
135 new(this) AliTPCQADataMakerRec(qadm);
136 return *this;
137}
be4f1702 138
139//__________________________________________________________________
140AliTPCQADataMakerRec::~AliTPCQADataMakerRec()
141{
142 // Destructor
0ab2a4cc 143 delete fTPCdataQA;
be4f1702 144
145 for(Int_t i = 0; i < 6; i++)
146 delete fMapping[i];
147}
44f32dd2 148
149//____________________________________________________________________________
4e25ac79 150void AliTPCQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
44f32dd2 151{
152 //Detector specific actions at end of cycle
92664bc8 153 ResetEventTrigClasses();
92664bc8 154
4e25ac79 155 AliQAChecker::Instance()->Run(AliQAv1::kTPC, task, list) ;
44f32dd2 156}
157
ce0175fa 158
44f32dd2 159//____________________________________________________________________________
160void AliTPCQADataMakerRec::InitESDs()
161{
162 //create ESDs histograms in ESDs subdir
7d297381 163 const Bool_t expert = kTRUE ;
164 const Bool_t image = kTRUE ;
165
57acd2d2 166 TH1F * histESDclusters =
44f32dd2 167 new TH1F("hESDclusters", "N TPC clusters per track; N clusters; Counts",
168 160, 0, 160);
57acd2d2 169 histESDclusters->Sumw2();
0ab2a4cc 170 Add2ESDsList(histESDclusters, kClusters, !expert, image);
44f32dd2 171
57acd2d2 172 TH1F * histESDratio =
44f32dd2 173 new TH1F("hESDratio", "Ratio: TPC clusters / findable; Ratio: cluster/findable; Counts",
174 100, 0, 1);
57acd2d2 175 histESDratio->Sumw2();
7d297381 176 Add2ESDsList(histESDratio, kRatio, !expert, image);
44f32dd2 177
57acd2d2 178 TH1F * histESDpt =
44f32dd2 179 new TH1F("hESDpt", "P_{T} distribution; p_{T} [GeV/c]; Counts",
180 50, 0, 5);
57acd2d2 181 histESDpt->Sumw2();
7d297381 182 Add2ESDsList(histESDpt, kPt, !expert, image);
92664bc8 183 //
184 ClonePerTrigClass(AliQAv1::kESDS); // this should be the last line
44f32dd2 185}
186
187//____________________________________________________________________________
188void AliTPCQADataMakerRec::InitRaws()
189{
336156cc 190 //
191 // Adding the raw
be4f1702 192 //
193
194 // Modified: 7/7 - 2008
195 // Laurent Aphecetche pointed out that the mapping was read from file
196 // for each event, so now we read in the map here and set if for
197 // the raw data qa
7d297381 198 const Bool_t expert = kTRUE ;
199 const Bool_t saveCorr = kTRUE ;
200 const Bool_t image = kTRUE ;
201
cbe00405 202 // It might happen that we will be in this method a few times
203 // (we create the dataQA at the first call to this method)
204 if(!fTPCdataQA) {
205 fTPCdataQA = new AliTPCdataQA();
206 LoadMaps(); // Load Altro maps
207 fTPCdataQA->SetAltroMapping(fMapping); // set Altro mapping
208 fTPCdataQA->SetRangeTime(fRawFirstTimeBin, fRawLastTimeBin); // set time bin interval
209 fTPCdataQA->SetIsDQM(kTRUE);
210 }
211
0ab2a4cc 212 TProfile * histRawsOccupancyVsSector =
213 new TProfile("hRawsOccupancyVsSector", "Occupancy vs sector; Sector; Occupancy",
adcdb395 214 72, 0, 72);
ce0175fa 215 histRawsOccupancyVsSector->SetMarkerStyle(20);
216 histRawsOccupancyVsSector->SetOption("P");
217 histRawsOccupancyVsSector->SetStats(kFALSE);
218 Add2RawsList(histRawsOccupancyVsSector, kRawsOccupancyVsSector, !expert, image, !saveCorr);
adcdb395 219
0ab2a4cc 220 TProfile * histRawsQVsSector =
221 new TProfile("hRawsQVsSector", "<Q> vs sector; Sector; <Q>",
ce0175fa 222 72, 0, 72);
556a0e5b 223 Add2RawsList(histRawsQVsSector, kRawsQVsSector, expert, !image, !saveCorr);
adcdb395 224
0ab2a4cc 225 TProfile * histRawsQmaxVsSector =
226 new TProfile("hRawsQmaxVsSector", "<Qmax> vs sector; Sector; <Qmax>",
ce0175fa 227 72, 0, 72);
ce0175fa 228 histRawsQmaxVsSector->SetMarkerStyle(20);
229 histRawsQmaxVsSector->SetOption("P");
230 histRawsQmaxVsSector->SetStats(kFALSE);
231 Add2RawsList(histRawsQmaxVsSector, kRawsQmaxVsSector, !expert, image, !saveCorr);
92664bc8 232 //
233 ClonePerTrigClass(AliQAv1::kRAWS); // this should be the last line
44f32dd2 234}
235
44ed7a66 236//____________________________________________________________________________
237void AliTPCQADataMakerRec::InitDigits()
238{
239 const Bool_t expert = kTRUE ;
240 const Bool_t image = kTRUE ;
241 TH1F * histDigitsADC =
242 new TH1F("hDigitsADC", "Digit ADC distribution; ADC; Counts",
243 1000, 0, 1000);
244 histDigitsADC->Sumw2();
245 Add2DigitsList(histDigitsADC, kDigitsADC, !expert, image);
92664bc8 246 //
247 ClonePerTrigClass(AliQAv1::kDIGITS); // this should be the last line
44ed7a66 248}
249
44f32dd2 250//____________________________________________________________________________
251void AliTPCQADataMakerRec::InitRecPoints()
252{
7d297381 253 const Bool_t expert = kTRUE ;
254 const Bool_t image = kTRUE ;
255
57acd2d2 256 TH1F * histRecPointsQmaxShort =
44f32dd2 257 new TH1F("hRecPointsQmaxShort", "Qmax distrbution (short pads); Qmax; Counts",
adcdb395 258 100, 0, 300);
57acd2d2 259 histRecPointsQmaxShort->Sumw2();
7d297381 260 Add2RecPointsList(histRecPointsQmaxShort, kQmaxShort, !expert, image);
44f32dd2 261
57acd2d2 262 TH1F * histRecPointsQmaxMedium =
44f32dd2 263 new TH1F("hRecPointsQmaxMedium", "Qmax distrbution (medium pads); Qmax; Counts",
adcdb395 264 100, 0, 300);
57acd2d2 265 histRecPointsQmaxMedium->Sumw2();
7d297381 266 Add2RecPointsList(histRecPointsQmaxMedium, kQmaxMedium, !expert, image);
44f32dd2 267
57acd2d2 268 TH1F * histRecPointsQmaxLong =
44f32dd2 269 new TH1F("hRecPointsQmaxLong", "Qmax distrbution (long pads); Qmax; Counts",
adcdb395 270 100, 0, 300);
57acd2d2 271 histRecPointsQmaxLong->Sumw2();
7d297381 272 Add2RecPointsList(histRecPointsQmaxLong, kQmaxLong, !expert, image);
44f32dd2 273
57acd2d2 274 TH1F * histRecPointsQShort =
44f32dd2 275 new TH1F("hRecPointsQShort", "Q distrbution (short pads); Q; Counts",
adcdb395 276 100, 0, 2000);
57acd2d2 277 histRecPointsQShort->Sumw2();
7d297381 278 Add2RecPointsList(histRecPointsQShort, kQShort, !expert, image);
44f32dd2 279
57acd2d2 280 TH1F * histRecPointsQMedium =
44f32dd2 281 new TH1F("hRecPointsQMedium", "Q distrbution (medium pads); Q; Counts",
adcdb395 282 100, 0, 2000);
57acd2d2 283 histRecPointsQMedium->Sumw2();
7d297381 284 Add2RecPointsList(histRecPointsQMedium, kQMedium, !expert, image);
44f32dd2 285
57acd2d2 286 TH1F * histRecPointsQLong =
44f32dd2 287 new TH1F("hRecPointsQLong", "Q distrbution (long pads); Q; Counts",
adcdb395 288 100, 0, 2000);
57acd2d2 289 histRecPointsQLong->Sumw2();
7d297381 290 Add2RecPointsList(histRecPointsQLong, kQLong, !expert, image);
44f32dd2 291
57acd2d2 292 TH1F * histRecPointsRow =
44f32dd2 293 new TH1F("hRecPointsRow", "Clusters per row; Row; Counts",
294 159, 0, 159);
57acd2d2 295 histRecPointsRow->Sumw2();
7d297381 296 Add2RecPointsList(histRecPointsRow, kRow, !expert, image);
92664bc8 297 //
298 ClonePerTrigClass(AliQAv1::kRECPOINTS); // this should be the last line
44f32dd2 299}
300
301//____________________________________________________________________________
302void AliTPCQADataMakerRec::MakeESDs(AliESDEvent * esd)
303{
304 // make QA data from ESDs
eca4fa66 305
44f32dd2 306 const Int_t nESDTracks = esd->GetNumberOfTracks();
307 Int_t nTPCtracks = 0;
308 for(Int_t i = 0; i < nESDTracks; i++) {
309
310 AliESDtrack * track = esd->GetTrack(i);
311
312 if ((track->GetStatus() & AliESDtrack::kTPCrefit)==0)
313 continue;
314
315 nTPCtracks++;
316
317 Int_t nTPCclusters = track->GetTPCNcls();
318 Int_t nTPCclustersFindable = track->GetTPCNclsF();
47a596d8 319 if ( nTPCclustersFindable<=0) continue;
0ab2a4cc 320 FillESDsData(kClusters,nTPCclusters);
92664bc8 321 FillESDsData(kRatio,Float_t(nTPCclusters)/Float_t(nTPCclustersFindable));
322 FillESDsData(kPt,track->Pt());
44f32dd2 323 }
92664bc8 324 //
325 IncEvCountCycleESDs();
326 IncEvCountTotalESDs();
327 //
44f32dd2 328}
329
330//____________________________________________________________________________
331void AliTPCQADataMakerRec::MakeRaws(AliRawReader* rawReader)
332{
333 //
334 // To make QA for the RAW data we use the TPC Calibration framework
335 // to handle the data and then in the end extract the data
336 //
eca4fa66 337
60f9f416 338 GetRawsData(0); // dummy call to init raw data
eca4fa66 339 rawReader->Reset() ;
0ab2a4cc 340 if (! fTPCdataQA ) {
341
342 AliError("No TPC data QA (no call to InitRaws?)!!!!") ;
343 } else {
344
345 if(fTPCdataQA->GetIsDQM() == kFALSE)
346 AliError("Data QA has to be initialized as DQM!!!!") ;
347
348 // Fill profile data
349 fTPCdataQA->ResetProfiles();
350
351 if(fTPCdataQA->ProcessEvent(rawReader)) { // means that TPC data was processed
352
353 fTPCdataQA->FillOccupancyProfile();
354
355 // Fill histograms
356 TObjArray *arrRW = GetMatchingRawsData(kRawsOccupancyVsSector); // all kRawsOccupancyVsSector clones matching to triggers
357 for (int ih=arrRW->GetEntriesFast();ih--;) {
358 TProfile* hRawsOccupancyVsSector = dynamic_cast<TProfile*>(arrRW->At(ih));
359 if (hRawsOccupancyVsSector) hRawsOccupancyVsSector->Add(fTPCdataQA->GetHistOccVsSector());
360 }
361 arrRW = GetMatchingRawsData(kRawsQVsSector);
362 for (int ih=arrRW->GetEntriesFast();ih--;) {
363 TProfile* hRawsQVsSector = dynamic_cast<TProfile*>(arrRW->At(ih));
364 if (hRawsQVsSector) hRawsQVsSector->Add(fTPCdataQA->GetHistQVsSector());
365 }
366 arrRW = GetMatchingRawsData(kRawsQmaxVsSector);
367 for (int ih=arrRW->GetEntriesFast();ih--;) {
368 TProfile* hRawsQmaxVsSector = dynamic_cast<TProfile*>(arrRW->At(ih));
369 if (hRawsQmaxVsSector) hRawsQmaxVsSector->Add(fTPCdataQA->GetHistQmaxVsSector());
370 }
371 //
372 IncEvCountCycleRaws();
373 IncEvCountTotalRaws();
374 //
375 }
6252ceeb 376 }
377}
44f32dd2 378
44ed7a66 379//____________________________________________________________________________
380void AliTPCQADataMakerRec::MakeDigits(TTree* digitTree)
381{
6252ceeb 382
44ed7a66 383 TBranch* branch = digitTree->GetBranch("Segment");
384 AliSimDigits* digArray = 0;
385 branch->SetAddress(&digArray);
386
387 Int_t nEntries = Int_t(digitTree->GetEntries());
388
389 for (Int_t n = 0; n < nEntries; n++) {
390
391 digitTree->GetEvent(n);
392
393 if (digArray->First())
394 do {
395 Float_t dig = digArray->CurrentDigit();
396
92664bc8 397 FillDigitsData(kDigitsADC,dig);
44ed7a66 398 } while (digArray->Next());
399 }
92664bc8 400 //
401 IncEvCountCycleDigits();
402 IncEvCountTotalDigits();
403 //
44ed7a66 404}
405
44f32dd2 406//____________________________________________________________________________
407void AliTPCQADataMakerRec::MakeRecPoints(TTree* recTree)
408{
c75ba816 409
8305642e 410 AliTPCClustersRow* clrow = 0x0;
411 TBranch* branch = recTree->GetBranch("Segment");
412 branch->SetAddress(&clrow);
413 TClonesArray * clarray = 0x0;
44f32dd2 414
415 const Int_t nEntries = Int_t(recTree->GetEntries());
416 for (Int_t i = 0; i < nEntries; i++) {
417
418 branch->GetEntry(i);
741dac00 419
8305642e 420 clarray = clrow->GetArray();
741dac00 421
8305642e 422 if (!clarray) continue;
741dac00 423
8305642e 424 const Int_t nClusters = clarray->GetEntriesFast();
44f32dd2 425 for (Int_t icl=0; icl < nClusters; icl++){
426
427 AliTPCclusterMI* cluster =
8305642e 428 (AliTPCclusterMI*)clarray->At(icl);
44f32dd2 429
430 Float_t Qmax = cluster->GetMax();
431 Float_t Q = cluster->GetQ();
432 Int_t row = cluster->GetRow();
433
434 if(cluster->GetDetector()<36) { // IROC (short pads)
435
92664bc8 436 FillRecPointsData(kQmaxShort,Qmax);
437 FillRecPointsData(kQShort,Q);
44f32dd2 438 } else { // OROC (medium and long pads)
439 row += 63;
440 if(cluster->GetRow()<64) { // medium pads
441
92664bc8 442 FillRecPointsData(kQmaxMedium,Qmax);
443 FillRecPointsData(kQMedium,Q);
44f32dd2 444 } else { // long pads
445
92664bc8 446 FillRecPointsData(kQmaxLong,Qmax);
447 FillRecPointsData(kQLong,Q);
44f32dd2 448 }
449 }
450
92664bc8 451 FillRecPointsData(kRow,row);
44f32dd2 452 } // end loop over clusters
453 } // end loop over tree
92664bc8 454 //
455 IncEvCountCycleRecPoints();
456 IncEvCountTotalRecPoints();
457 //
44f32dd2 458}
be4f1702 459
460//____________________________________________________________________________
461void AliTPCQADataMakerRec::LoadMaps()
462{
463 TString path = gSystem->Getenv("ALICE_ROOT");
464 path += "/TPC/mapping/Patch";
465
466 for(Int_t i = 0; i < 6; i++) {
ce0175fa 467
468 if(fMapping[i]!=0) // mapping already loaded
469 continue;
be4f1702 470 TString path2 = path;
471 path2 += i;
472 path2 += ".data";
473 fMapping[i] = new AliTPCAltroMapping(path2.Data());
474 }
475}
476