Project
Loading...
Searching...
No Matches
TPCFastTransformQA.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
16
17#include "TPCFastTransformQA.h"
19#include "TPCFastTransform.h"
20#include "GPUCommonLogger.h"
21
22#include "AliTPCTransform.h"
23#include "AliTPCParam.h"
24#include "AliTPCRecoParam.h"
25#include "AliTPCcalibDB.h"
26#include "AliHLTTPCGeometry.h"
27#include "TFile.h"
28#include "TNtuple.h"
29#include "TStopwatch.h"
30
31#include <iostream>
32#include <iomanip>
33
34using namespace o2::gpu;
35using namespace std;
36
38
39int32_t TPCFastTransformQA::doQA(const TPCFastTransform& fastTransform)
40{
41 const char* fileName = "fastTransformQA.root";
42
43 AliTPCcalibDB* pCalib = AliTPCcalibDB::Instance();
44 if (!pCalib) {
45 return storeError(-1, "TPCFastTransformQA: No TPC calibration instance found");
46 }
47
48 AliTPCParam* tpcParam = pCalib->GetParameters();
49 if (!tpcParam) {
50 return storeError(-2, "TPCFastTransformQA: No TPCParam object found");
51 }
52
53 AliTPCTransform* origTransform = pCalib->GetTransform();
54 if (!origTransform) {
55 return storeError(-3, "TPCFastTransformQA: No TPC transformation found");
56 }
57
58 const AliTPCRecoParam* rec = origTransform->GetCurrentRecoParam();
59 if (!rec) {
60 return storeError(-5, "TPCFastTransformQA: No TPC Reco Param set in transformation");
61 }
62 rec->Print();
63
64 int32_t lastTimeBin = rec->GetLastBin();
65
66 // measure execution time
67 {
68 TStopwatch timer1;
69 double nCalls1 = 0;
70 double sum1 = 0;
71 for (Int_t iSec = 0; iSec < 1; iSec++) {
72 LOG(info) << "Measure original transformation time for TPC sector " << iSec << " ..";
73 int32_t nRows = tpcParam->GetNRow(iSec);
74 for (int32_t iRow = 0; iRow < nRows; iRow++) {
75 Int_t nPads = tpcParam->GetNPads(iSec, iRow);
76 for (float pad = 0.5; pad < nPads; pad += 1.) {
77 for (float time = 0; time < lastTimeBin; time++) {
78 Int_t is[] = {iSec};
79 double orig[3] = {static_cast<Double_t>(iRow), pad, time};
80 origTransform->Transform(orig, is, 0, 1);
81 nCalls1++;
82 sum1 += orig[0] + orig[1] + orig[2];
83 }
84 }
85 }
86 }
87 timer1.Stop();
88
89 TStopwatch timer2;
90 double nCalls2 = 0;
91 double sum2 = 0;
92 for (Int_t iSec = 0; iSec < 1; iSec++) {
93 LOG(info) << "Measure fast transformation time for TPC sector " << iSec << " ..";
94 int32_t nRows = tpcParam->GetNRow(iSec);
95 for (int32_t iRow = 0; iRow < nRows; iRow++) {
96 Int_t nPads = tpcParam->GetNPads(iSec, iRow);
97 int32_t slice = 0, slicerow = 0;
98 AliHLTTPCGeometry::Sector2Slice(slice, slicerow, iSec, iRow);
99 for (float pad = 0.5; pad < nPads; pad += 1.) {
100 for (float time = 0; time < lastTimeBin; time++) {
101 float fast[3];
102 fastTransform.Transform(slice, slicerow, pad, time, fast[0], fast[1], fast[2]);
103 nCalls2++;
104 sum2 += fast[0] + fast[1] + fast[2];
105 }
106 }
107 }
108 }
109 timer2.Stop();
110 LOG(info) << "nCalls1 = " << nCalls1;
111 LOG(info) << "nCalls2 = " << nCalls2;
112 LOG(info) << "Orig transformation : " << timer1.RealTime() * 1.e9 / nCalls1 << " ns / call";
113 LOG(info) << "Fast transformation : " << timer2.RealTime() * 1.e9 / nCalls2 << " ns / call";
114
115 LOG(info) << "Fast Transformation speedup: " << 1. * timer1.RealTime() / timer2.RealTime() * nCalls2 / nCalls1;
116
117 int32_t size = sizeof(fastTransform) + fastTransform.getFlatBufferSize();
118 LOG(info) << "Fast Transformation memory usage: " << size / 1000. / 1000. << " MB";
119 LOG(info) << "ignore this " << sum1 << " " << sum2;
120 }
121
122 if (1) {
123 TFile* file = new TFile(fileName, "RECREATE");
124 if (!file || !file->IsOpen()) {
125 return storeError(-1, "Can't recreate QA file !");
126 }
127 file->cd();
128 TNtuple* nt = new TNtuple("fastTransformQA", "fastTransformQA", "sec:row:pad:time:x:y:z:fx:fy:fz");
129
130 for (Int_t iSec = 0; iSec < 1; iSec++) {
131 int32_t nRows = tpcParam->GetNRow(iSec);
132 for (int32_t iRow = 0; iRow < nRows; iRow++) {
133 LOG(info) << "Write fastTransform QA for TPC sector " << iSec << ", row " << iRow << " ..";
134 Int_t nPads = tpcParam->GetNPads(iSec, iRow);
135 int32_t slice = 0, slicerow = 0;
136 AliHLTTPCGeometry::Sector2Slice(slice, slicerow, iSec, iRow);
137 for (float pad = 0.5; pad < nPads; pad += 1.) {
138 for (float time = 0; time < lastTimeBin; time++) {
139 Int_t is[] = {iSec};
140 double orig[3] = {static_cast<Double_t>(iRow), pad, time};
141 float fast[3];
142 origTransform->Transform(orig, is, 0, 1);
143 fastTransform.Transform(slice, slicerow, pad, time, fast[0], fast[1], fast[2]);
144 float entry[] = {(float)iSec, (float)iRow, pad, time, (float)orig[0], (float)orig[1], (float)orig[2], fast[0], fast[1], fast[2]};
145 nt->Fill(entry);
146 }
147 }
148 }
149 }
150 file->Write();
151 file->Close();
152 delete file;
153 }
154 return 0;
155}
156
157int32_t TPCFastTransformQA::doQA(long TimeStamp)
158{
159 TPCFastTransform fastTransform;
161
162 man.create(fastTransform, nullptr, TimeStamp);
163
164 return doQA(fastTransform);
165}
int16_t time
Definition RawEventData.h:4
Definition of TPCFastTransformManager class.
Definition of TPCFastTransform class.
size_t getFlatBufferSize() const
Gives size of the flat buffer.
Definition FlatObject.h:256
int32_t create(TPCFastTransform &spline, AliTPCTransform *transform, long TimeStamp)
_______________ Main functionality ________________________
int32_t doQA(long TimeStamp)
_______________ Main functionality ________________________
TPCFastTransformQA()
_____________ Constructors / destructors __________________________
GLuint entry
Definition glcorearb.h:5735
GLsizeiptr size
Definition glcorearb.h:659
Defining DataPointCompositeObject explicitly as copiable.
GPUReconstruction * rec
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"