Skip to content

Commit 169a0ab

Browse files
Laura Serksnyteshahor02
authored andcommitted
Shared clusters, found clusters and crossed rows TASK for TPC QC
1 parent 195e97e commit 169a0ab

File tree

5 files changed

+214
-2
lines changed

5 files changed

+214
-2
lines changed

Detectors/TPC/qc/CMakeLists.txt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ o2_add_library(TPCQC
1818
src/DCSPTemperature.cxx
1919
src/SACs.cxx
2020
src/IDCsVsSACs.cxx
21+
src/TrackClusters.cxx
2122
PUBLIC_LINK_LIBRARIES O2::TPCBase
2223
O2::DataFormatsTPC
2324
O2::GPUO2Interface
24-
O2::TPCCalibration)
25+
O2::TPCCalibration
26+
O2::GlobalTracking)
2527

2628

2729
o2_target_root_dictionary(TPCQC
@@ -33,7 +35,8 @@ o2_target_root_dictionary(TPCQC
3335
include/TPCQC/CalPadWrapper.h
3436
include/TPCQC/DCSPTemperature.h
3537
include/TPCQC/SACs.h
36-
include/TPCQC/IDCsVsSACs.h)
38+
include/TPCQC/IDCsVsSACs.h
39+
include/TPCQC/TrackClusters.h)
3740

3841
o2_add_test(PID
3942
COMPONENT_NAME tpc
@@ -66,6 +69,12 @@ o2_add_test(IDCsVsSACs
6669
SOURCES test/test_IDCsVsSACs.cxx
6770
LABELS tpc)
6871

72+
o2_add_test(TrackClusters
73+
COMPONENT_NAME tpc
74+
PUBLIC_LINK_LIBRARIES O2::TPCQC
75+
SOURCES test/test_TrackClusters.cxx
76+
LABELS tpc)
77+
6978
o2_add_test_root_macro(macro/runPID.C
7079
PUBLIC_LINK_LIBRARIES O2::TPCQC
7180
O2::DataFormatsTPC
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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+
12+
///
13+
/// @file TrackClusters.h
14+
/// @author Laura Serksnyte
15+
///
16+
17+
#ifndef AliceO2_TPC_QC_TRACKCLUSTERS_H
18+
#define AliceO2_TPC_QC_TRACKCLUSTERS_H
19+
20+
// root includes
21+
#include "TH1F.h"
22+
23+
// o2 includes
24+
#include "DataFormatsTPC/Defs.h"
25+
#include "DataFormatsTPC/TrackTPC.h"
26+
27+
namespace o2::tpc
28+
{
29+
class TrackTPC;
30+
struct ClusterNativeAccess;
31+
32+
namespace qc
33+
{
34+
35+
/// @brief Shared cluster and crossed rows TPC quality control task
36+
class TrackClusters
37+
{
38+
public:
39+
/// \brief Constructor.
40+
TrackClusters() = default;
41+
42+
/// bool extracts intormation from track and fills it to histograms
43+
/// @return true if information can be extracted and filled to histograms
44+
bool processTrackAndClusters(const std::vector<o2::tpc::TrackTPC>* tracks, const o2::tpc::ClusterNativeAccess* clusterIndex, std::vector<o2::tpc::TPCClRefElem>* clusRefs);
45+
46+
/// Initialize all histograms
47+
void initializeHistograms();
48+
49+
/// Reset all histograms
50+
void resetHistograms();
51+
52+
/// Dump results to a file
53+
void dumpToFile(std::string filename);
54+
55+
// To set the elementary track cuts
56+
void setTrackClustersCuts(int minNCls = 60, float mindEdxTot = 10.0, float absEta = 1.)
57+
{
58+
mCutMinNCls = minNCls;
59+
mCutMindEdxTot = mindEdxTot;
60+
mCutAbsEta = absEta;
61+
}
62+
63+
std::unordered_map<std::string, std::vector<std::unique_ptr<TH1>>>& getMapOfHisto() { return mMapHist; }
64+
const std::unordered_map<std::string, std::vector<std::unique_ptr<TH1>>>& getMapOfHisto() const { return mMapHist; }
65+
66+
private:
67+
int mCutMinNCls = 60; // minimum N clusters
68+
float mCutMindEdxTot = 10.f; // dEdxTot min value
69+
float mCutAbsEta = 1.f; // AbsTgl max cut
70+
std::unordered_map<std::string, std::vector<std::unique_ptr<TH1>>> mMapHist;
71+
ClassDefNV(TrackClusters, 1)
72+
};
73+
} // namespace qc
74+
} // namespace o2::tpc
75+
76+
#endif

Detectors/TPC/qc/src/TPCQCLinkDef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#pragma link C++ class o2::tpc::qc::DCSPTemperature + ;
2424
#pragma link C++ class o2::tpc::qc::SACs + ;
2525
#pragma link C++ class o2::tpc::qc::IDCsVsSACs + ;
26+
#pragma link C++ class o2::tpc::qc::TrackClusters + ;
2627
#pragma link C++ function o2::tpc::qc::helpers::makeLogBinning + ;
2728
#pragma link C++ function o2::tpc::qc::helpers::setStyleHistogram1D + ;
2829
#pragma link C++ function o2::tpc::qc::helpers::setStyleHistogram2D + ;
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
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+
12+
#define _USE_MATH_DEFINES
13+
14+
#include <cmath>
15+
#include <memory>
16+
17+
// root includes
18+
#include "TFile.h"
19+
#include "TObjArray.h"
20+
21+
// o2 includes
22+
#include "DataFormatsTPC/TrackTPC.h"
23+
#include "TPCQC/TrackClusters.h"
24+
#include "TPCQC/Tracks.h"
25+
#include "TPCQC/Helpers.h"
26+
#include "GPUO2InterfaceRefit.h"
27+
#include "GlobalTracking/TrackMethods.h"
28+
29+
ClassImp(o2::tpc::qc::TrackClusters);
30+
using namespace o2::tpc::qc;
31+
32+
struct binning {
33+
int bins;
34+
double min;
35+
double max;
36+
};
37+
38+
const binning binsSharedClusters{160, 0., 160.};
39+
const binning binsFoundClusters{160, 0., 160.};
40+
const binning binsCrossedRows{160, 0., 160.};
41+
42+
//______________________________________________________________________________
43+
void TrackClusters::initializeHistograms()
44+
{
45+
TH1::AddDirectory(false);
46+
mMapHist["sharedClusters"].emplace_back(std::make_unique<TH1F>("sharedClusters", "sharedClusters;NSharedClusters;Entries", binsSharedClusters.bins, binsSharedClusters.min, binsSharedClusters.max));
47+
mMapHist["foundClusters"].emplace_back(std::make_unique<TH1F>("foundClusters", "foundClusters;foundClusters;Entries", binsFoundClusters.bins, binsFoundClusters.min, binsFoundClusters.max));
48+
mMapHist["crossedRows"].emplace_back(std::make_unique<TH1F>("crossedRows", "crossedRows;crossedRows;Entries", binsCrossedRows.bins, binsCrossedRows.min, binsCrossedRows.max));
49+
}
50+
51+
//______________________________________________________________________________
52+
void TrackClusters::resetHistograms()
53+
{
54+
for (const auto& pair : mMapHist) {
55+
for (auto& hist : pair.second) {
56+
hist->Reset();
57+
}
58+
}
59+
}
60+
61+
//______________________________________________________________________________
62+
bool TrackClusters::processTrackAndClusters(const std::vector<o2::tpc::TrackTPC>* tracks, const o2::tpc::ClusterNativeAccess* clusterIndex, std::vector<o2::tpc::TPCClRefElem>* clusRefs)
63+
{
64+
65+
std::vector<unsigned char> mBufVec;
66+
mBufVec.resize(clusterIndex->nClustersTotal);
67+
68+
o2::gpu::GPUO2InterfaceRefit::fillSharedClustersMap(clusterIndex, *tracks, clusRefs->data(), mBufVec.data());
69+
70+
for (auto const& track : (*tracks)) {
71+
const auto dEdxTot = track.getdEdx().dEdxTotTPC;
72+
const auto nCls = uint8_t(track.getNClusters());
73+
const auto eta = track.getEta();
74+
75+
if (nCls < mCutMinNCls || dEdxTot < mCutMindEdxTot || abs(eta) > mCutAbsEta) {
76+
continue;
77+
}
78+
79+
uint8_t shared = 200, found = 0, crossed = 0;
80+
81+
o2::TrackMethods::countTPCClusters(track, *clusRefs, mBufVec, *clusterIndex, shared, found, crossed);
82+
83+
mMapHist["sharedClusters"][0]->Fill(shared);
84+
mMapHist["foundClusters"][0]->Fill(found);
85+
mMapHist["crossedRows"][0]->Fill(crossed);
86+
}
87+
88+
return true;
89+
}
90+
91+
//______________________________________________________________________________
92+
void TrackClusters::dumpToFile(const std::string filename)
93+
{
94+
auto f = std::unique_ptr<TFile>(TFile::Open(filename.c_str(), "recreate"));
95+
for (const auto& [name, histos] : mMapHist) {
96+
TObjArray arr;
97+
arr.SetName(name.data());
98+
for (auto& hist : histos) {
99+
arr.Add(hist.get());
100+
}
101+
arr.Write(arr.GetName(), TObject::kSingleKey);
102+
}
103+
f->Close();
104+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
12+
#define BOOST_TEST_MODULE Test TPC QC
13+
#define BOOST_TEST_MAIN
14+
#define BOOST_TEST_DYN_LINK
15+
#include <boost/test/unit_test.hpp>
16+
#include "DataFormatsTPC/Defs.h"
17+
#include "TPCQC/TrackClusters.h"
18+
19+
BOOST_AUTO_TEST_CASE(ReadWriteROOTFile)
20+
{
21+
o2::tpc::qc::TrackClusters trackClusters;
22+
}

0 commit comments

Comments
 (0)