forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrackClusters.cxx
More file actions
110 lines (91 loc) · 4.25 KB
/
TrackClusters.cxx
File metadata and controls
110 lines (91 loc) · 4.25 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
// 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.
#define _USE_MATH_DEFINES
#include <cmath>
#include <memory>
// root includes
#include "TFile.h"
#include "TObjArray.h"
// o2 includes
#include "DataFormatsTPC/TrackTPC.h"
#include "TPCQC/TrackClusters.h"
#include "TPCQC/Tracks.h"
#include "TPCQC/Helpers.h"
#include "GPUO2InterfaceRefit.h"
#include "GlobalTracking/TrackMethods.h"
ClassImp(o2::tpc::qc::TrackClusters);
using namespace o2::tpc::qc;
struct binning {
int bins;
double min;
double max;
};
const binning binsClusters{160, 0., 160.};
const binning binsSharedClusters{160, 0., 160.};
const binning binsFoundClusters{160, 0., 160.};
const binning binsCrossedRows{160, 0., 160.};
const binning binsRatio{150, 0., 1.5};
//______________________________________________________________________________
void TrackClusters::initializeHistograms()
{
TH1::AddDirectory(false);
mMapHist["clusters"].emplace_back(std::make_unique<TH1F>("clusters", "Clusters;NClusters;Entries", binsClusters.bins, binsClusters.min, binsClusters.max));
mMapHist["sharedClusters"].emplace_back(std::make_unique<TH1F>("sharedClusters", "sharedClusters;NSharedClusters;Entries", binsSharedClusters.bins, binsSharedClusters.min, binsSharedClusters.max));
mMapHist["crossedRows"].emplace_back(std::make_unique<TH1F>("crossedRows", "crossedRows;NCrossedRows;Entries", binsCrossedRows.bins, binsCrossedRows.min, binsCrossedRows.max));
mMapHist["sharedClustersOverClusters"].emplace_back(std::make_unique<TH1F>("sharedClustersOverClusters", "sharedClustersOverClusters;NSharedClusters/NClusters;Entries", binsRatio.bins, binsRatio.min, binsRatio.max));
mMapHist["clustersOverCrossedRow"].emplace_back(std::make_unique<TH1F>("clustersOverCrossedRow", "clustersOverCrossedRow;NClusters/NCrossedRows;Entries", binsRatio.bins, binsRatio.min, binsRatio.max));
}
//______________________________________________________________________________
void TrackClusters::resetHistograms()
{
for (const auto& pair : mMapHist) {
for (auto& hist : pair.second) {
hist->Reset();
}
}
}
//______________________________________________________________________________
bool TrackClusters::processTrackAndClusters(const std::vector<o2::tpc::TrackTPC>* tracks, const o2::tpc::ClusterNativeAccess* clusterIndex, std::vector<o2::tpc::TPCClRefElem>* clusRefs)
{
std::vector<unsigned char> mBufVec;
mBufVec.resize(clusterIndex->nClustersTotal);
o2::gpu::GPUO2InterfaceRefit::fillSharedClustersAndOccupancyMap(clusterIndex, *tracks, clusRefs->data(), mBufVec.data());
for (auto const& track : (*tracks)) {
const auto dEdxTot = track.getdEdx().dEdxTotTPC;
const auto nCls = uint8_t(track.getNClusters());
const auto eta = track.getEta();
if (nCls < mCutMinNCls || dEdxTot < mCutMindEdxTot || std::fabs(eta) > mCutAbsEta) {
continue;
}
uint8_t shared = 200, found = 0, crossed = 0;
o2::TrackMethods::countTPCClusters(track, *clusRefs, mBufVec, *clusterIndex, shared, found, crossed);
mMapHist["clusters"][0]->Fill(found);
mMapHist["sharedClusters"][0]->Fill(shared);
mMapHist["crossedRows"][0]->Fill(crossed);
mMapHist["sharedClustersOverClusters"][0]->Fill(static_cast<float>(shared) / static_cast<float>(found));
mMapHist["clustersOverCrossedRow"][0]->Fill(static_cast<float>(found) / static_cast<float>(crossed));
}
return true;
}
//______________________________________________________________________________
void TrackClusters::dumpToFile(const std::string filename)
{
auto f = std::unique_ptr<TFile>(TFile::Open(filename.c_str(), "recreate"));
for (const auto& [name, histos] : mMapHist) {
TObjArray arr;
arr.SetName(name.data());
for (auto& hist : histos) {
arr.Add(hist.get());
}
arr.Write(arr.GetName(), TObject::kSingleKey);
}
f->Close();
}