-
Notifications
You must be signed in to change notification settings - Fork 499
Expand file tree
/
Copy pathAlignableDetectorTOF.cxx
More file actions
133 lines (122 loc) · 4.69 KB
/
AlignableDetectorTOF.cxx
File metadata and controls
133 lines (122 loc) · 4.69 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
// 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 AlignableDetectorTOF.h
/// @author ruben.shahoyan@cern.ch, michael.lettrich@cern.ch
/// @since 2021-02-01
/// @brief Wrapper for TOF detector
#include "Align/AlignableDetectorTOF.h"
#include "Align/AlignableVolume.h"
#include "Align/AlignableSensorTOF.h"
#include "Align/Controller.h"
#include "DataFormatsGlobalTracking/RecoContainer.h"
#include "DataFormatsTOF/Cluster.h"
#include "TOFBase/Geo.h"
#include <TGeoManager.h>
ClassImp(o2::align::AlignableDetectorTOF);
namespace o2
{
namespace align
{
//____________________________________________
AlignableDetectorTOF::AlignableDetectorTOF(Controller* ctr) : AlignableDetector(DetID::TOF, ctr)
{
// default c-tor
}
//____________________________________________
void AlignableDetectorTOF::defineVolumes()
{
// define TOF volumes
//
constexpr int NSect = 18;
int labDet = getDetLabel();
AlignableSensorTOF* strip = nullptr;
//
// AddVolume( volTOF = new AlignableVolume("TOF") ); // no main volume, why?
AlignableVolume* sect[NSect] = {};
AlignableVolume* volTOF = nullptr; // fictious envelope
addVolume(volTOF = new AlignableVolume("TOF_envelope", getDetLabel(), mController));
volTOF->setDummyEnvelope();
//
int cnt = 0;
for (int isc = 0; isc < NSect; isc++) {
for (int istr = 1; istr <= o2::tof::Geo::NSTRIPXSECTOR; istr++) { // strip
const char* symname = Form("TOF/sm%02d/strip%02d", isc, istr);
addVolume(strip = new AlignableSensorTOF(symname, o2::base::GeometryManager::getSensID(DetID::TOF, cnt), getSensLabel(cnt), isc, mController));
cnt++;
if (!gGeoManager->GetAlignableEntry(symname)) {
strip->setDummy(true);
// continue;
}
if (!sect[isc]) {
sect[isc] = new AlignableVolume(Form("TOF/sm%02d", isc), getNonSensLabel(isc), mController);
sect[isc]->setParent(volTOF);
}
strip->setParent(sect[isc]);
} // strip
} // layer
for (int isc = 0; isc < NSect; isc++) {
if (sect[isc]) {
addVolume(sect[isc]);
}
}
}
//____________________________________________
int AlignableDetectorTOF::processPoints(GIndex gid, int npntCut, bool inv)
{
// Extract the points corresponding to this detector, recalibrate/realign them to the
// level of the "starting point" for the alignment/calibration session.
// If inv==true, the track propagates in direction of decreasing tracking X
// (i.e. upper leg of cosmic track)
//
int npoints = 0;
auto algTrack = mController->getAlgTrack();
auto recoData = mController->getRecoContainer();
auto TOFClusters = recoData->getTOFClusters();
if (TOFClusters.empty()) {
return -1; // source not loaded?
}
const auto& clus = TOFClusters[gid.getIndex()];
int det[5] = {}, ch = clus.getMainContributingChannel();
o2::tof::Geo::getVolumeIndices(ch, det);
int sensID = o2::tof::Geo::getStripNumberPerSM(det[1], det[2]) + clus.getSector() * o2::tof::Geo::NSTRIPXSECTOR;
auto* sensor = (AlignableSensorTOF*)getSensor(sensID);
if (sensor->isDummy()) {
LOGP(error, "Dummy sensor {} is referred by a track", sensID);
return 0;
}
double loc[3] = {(det[4] + 0.5) * o2::tof::Geo::XPAD - o2::tof::Geo::XHALFSTRIP, 0., (det[3] - 0.5) * o2::tof::Geo::ZPAD}, locCorr[3] = {}, traCorr[3] = {};
const auto& matAlg = sensor->getMatrixClAlg();
matAlg.LocalToMaster(loc, locCorr);
// rotate to tracking
const auto& matT2L = sensor->getMatrixT2L();
matT2L.MasterToLocal(locCorr, traCorr);
//
auto& pnt = algTrack->addDetectorPoint();
const auto* sysE = sensor->getAddError(); // additional syst error
pnt.setYZErrTracking(clus.getSigmaY2() + sysE[0] * sysE[0], clus.getSigmaYZ(), clus.getSigmaZ2() + sysE[1] * sysE[1]);
if (getUseErrorParam()) { // errors will be calculated just before using the point in the fit, using track info
pnt.setNeedUpdateFromTrack();
}
pnt.setXYZTracking(traCorr[0], traCorr[1], traCorr[2]);
pnt.setSensor(sensor);
pnt.setAlphaSens(sensor->getAlpTracking());
pnt.setXSens(sensor->getXTracking());
pnt.setDetID(mDetID);
pnt.setSID(sensor->getSID());
pnt.setContainsMeasurement();
pnt.setInvDir(inv);
pnt.init();
npoints++;
mNPoints += npoints;
return npoints;
}
} // namespace align
} // namespace o2