forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdumpTRDClusterMatrices.C
More file actions
94 lines (76 loc) · 2.84 KB
/
dumpTRDClusterMatrices.C
File metadata and controls
94 lines (76 loc) · 2.84 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
// 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.
#include "AliCDBManager.h"
#include "AliGeomManager.h"
#include "AliTRDgeometry.h"
#include "TGeoMatrix.h"
#include <iostream>
#include <fstream>
/*
This macro loads the TRD geometry taking into account the alignment from Run 2
and dumps the inverse of all cluster matrices to a file.
To load the matrices add the following include and method to
GeometryFlat.h:
#include <fstream>
GPUd() bool readMatricesFromFile()
{
std::ifstream fIn("matrices.dat", std::ios::in | std::ios::binary);
if (!fIn) {
printf("Cannot read file\n");
return false;
}
for (int32_t iDet = 0; iDet < constants::NCHAMBER; ++iDet) {
float m[12];
for (int32_t j=0; j<12; ++j) {
fIn.read((char*) &m[j], sizeof(float));
}
mMatrixCache[iDet] = o2::gpu::Transform3D(m);
}
return true;
}
Don't forget to uncomment the line in createGeo.C which calls this method.
Note that only 521 chambers are installed.
*/
void dumpTRDClusterMatrices()
{
auto man = AliCDBManager::Instance();
if (!man->IsDefaultStorageSet()) {
man->SetDefaultStorage("local:///cvmfs/alice-ocdb.cern.ch/calibration/data/2015/OCDB");
man->SetRun(244340);
}
AliGeomManager::LoadGeometry();
AliGeomManager::ApplyAlignObjsFromCDB("ITS TPC TRD TOF");
auto geo = new AliTRDgeometry();
std::ofstream fOut("matrices.dat", std::ios::out | std::ios::binary);
if (!fOut) {
printf("Cannot open file\n");
return;
}
int32_t nMatrices = 0;
for (int32_t i = 0; i < 540; ++i) {
// dump all available matrices to a file
auto matrix = geo->GetClusterMatrix(i);
if (!matrix) {
printf("No matrix for chamber %i\n", i);
continue;
}
++nMatrices;
auto matrixO2 = matrix->Inverse();
auto tr = matrixO2.GetTranslation();
auto rot = matrixO2.GetRotationMatrix();
float m[12] = {static_cast<float>(rot[0]), static_cast<float>(rot[1]), static_cast<float>(rot[2]), static_cast<float>(tr[0]), static_cast<float>(rot[3]), static_cast<float>(rot[4]), static_cast<float>(rot[5]), static_cast<float>(tr[1]), static_cast<float>(rot[6]), static_cast<float>(rot[7]), static_cast<float>(rot[8]), static_cast<float>(tr[2])};
for (int32_t j = 0; j < 12; ++j) {
fOut.write((char*)&m[j], sizeof(float));
}
}
fOut.close();
printf("Dumped %i matrices\n", nMatrices);
}