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