Skip to content

Commit

Permalink
Shared clusters, found clusters and crossed rows TASK for TPC QC
Browse files Browse the repository at this point in the history
  • Loading branch information
Laura Serksnyte committed Dec 14, 2023
1 parent 12ca838 commit 714640a
Show file tree
Hide file tree
Showing 5 changed files with 214 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Detectors/TPC/qc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ o2_add_library(TPCQC
src/DCSPTemperature.cxx
src/SACs.cxx
src/IDCsVsSACs.cxx
src/TrackClusters.cxx
PUBLIC_LINK_LIBRARIES O2::TPCBase
O2::DataFormatsTPC
O2::GPUO2Interface
O2::TPCCalibration)
O2::TPCCalibration
O2::GlobalTracking)


o2_target_root_dictionary(TPCQC
Expand All @@ -33,7 +35,8 @@ o2_target_root_dictionary(TPCQC
include/TPCQC/CalPadWrapper.h
include/TPCQC/DCSPTemperature.h
include/TPCQC/SACs.h
include/TPCQC/IDCsVsSACs.h)
include/TPCQC/IDCsVsSACs.h
include/TPCQC/TrackClusters.h)

o2_add_test(PID
COMPONENT_NAME tpc
Expand Down Expand Up @@ -66,6 +69,12 @@ o2_add_test(IDCsVsSACs
SOURCES test/test_IDCsVsSACs.cxx
LABELS tpc)

o2_add_test(TrackClusters
COMPONENT_NAME tpc
PUBLIC_LINK_LIBRARIES O2::TPCQC
SOURCES test/test_TrackClusters.cxx
LABELS tpc)

o2_add_test_root_macro(macro/runPID.C
PUBLIC_LINK_LIBRARIES O2::TPCQC
O2::DataFormatsTPC
Expand Down
76 changes: 76 additions & 0 deletions Detectors/TPC/qc/include/TPCQC/TrackClusters.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// 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 TrackClusters.h
/// @author Laura Serksnyte
///

#ifndef AliceO2_TPC_QC_TRACKCLUSTERS_H
#define AliceO2_TPC_QC_TRACKCLUSTERS_H

// root includes
#include "TH1F.h"

// o2 includes
#include "DataFormatsTPC/Defs.h"
#include "DataFormatsTPC/TrackTPC.h"

namespace o2::tpc
{
class TrackTPC;
struct ClusterNativeAccess;

namespace qc
{

/// @brief Shared cluster and crossed rows TPC quality control task
class TrackClusters
{
public:
/// \brief Constructor.
TrackClusters() = default;

/// bool extracts intormation from track and fills it to histograms
/// @return true if information can be extracted and filled to histograms
bool processTrackAndClusters(const std::vector<o2::tpc::TrackTPC>* tracks, const o2::tpc::ClusterNativeAccess* clusterIndex, std::vector<o2::tpc::TPCClRefElem>* clusRefs);

/// Initialize all histograms
void initializeHistograms();

/// Reset all histograms
void resetHistograms();

/// Dump results to a file
void dumpToFile(std::string filename);

// To set the elementary track cuts
void setTrackClustersCuts(int minNCls = 60, float mindEdxTot = 10.0, float absEta = 1.)
{
mCutMinNCls = minNCls;
mCutMindEdxTot = mindEdxTot;
mCutAbsEta = absEta;
}

std::unordered_map<std::string, std::vector<std::unique_ptr<TH1>>>& getMapOfHisto() { return mMapHist; }
const std::unordered_map<std::string, std::vector<std::unique_ptr<TH1>>>& getMapOfHisto() const { return mMapHist; }

private:
int mCutMinNCls = 60; // minimum N clusters
float mCutMindEdxTot = 10.f; // dEdxTot min value
float mCutAbsEta = 1.f; // AbsTgl max cut
std::unordered_map<std::string, std::vector<std::unique_ptr<TH1>>> mMapHist;
ClassDefNV(TrackClusters, 1)
};
} // namespace qc
} // namespace o2::tpc

#endif
1 change: 1 addition & 0 deletions Detectors/TPC/qc/src/TPCQCLinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#pragma link C++ class o2::tpc::qc::DCSPTemperature + ;
#pragma link C++ class o2::tpc::qc::SACs + ;
#pragma link C++ class o2::tpc::qc::IDCsVsSACs + ;
#pragma link C++ class o2::tpc::qc::TrackClusters + ;
#pragma link C++ function o2::tpc::qc::helpers::makeLogBinning + ;
#pragma link C++ function o2::tpc::qc::helpers::setStyleHistogram1D + ;
#pragma link C++ function o2::tpc::qc::helpers::setStyleHistogram2D + ;
Expand Down
104 changes: 104 additions & 0 deletions Detectors/TPC/qc/src/TrackClusters.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
// 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 binsSharedClusters{160, 0., 160.};
const binning binsFoundClusters{160, 0., 160.};
const binning binsCrossedRows{160, 0., 160.};

//______________________________________________________________________________
void TrackClusters::initializeHistograms()
{
TH1::AddDirectory(false);
mMapHist["sharedClusters"].emplace_back(std::make_unique<TH1F>("sharedClusters", "sharedClusters;NSharedClusters;Entries", binsSharedClusters.bins, binsSharedClusters.min, binsSharedClusters.max));
mMapHist["foundClusters"].emplace_back(std::make_unique<TH1F>("foundClusters", "foundClusters;foundClusters;Entries", binsFoundClusters.bins, binsFoundClusters.min, binsFoundClusters.max));
mMapHist["crossedRows"].emplace_back(std::make_unique<TH1F>("crossedRows", "crossedRows;crossedRows;Entries", binsCrossedRows.bins, binsCrossedRows.min, binsCrossedRows.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::fillSharedClustersMap(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 || abs(eta) > mCutAbsEta) {
continue;
}

uint8_t shared = 999, found = 999, crossed = 999;

o2::TrackMethods::countTPCClusters(track, *clusRefs, mBufVec, *clusterIndex, shared, found, crossed);

mMapHist["sharedClusters"][0]->Fill(shared);
mMapHist["foundClusters"][0]->Fill(found);
mMapHist["crossedRows"][0]->Fill(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();
}
22 changes: 22 additions & 0 deletions Detectors/TPC/qc/test/test_TrackClusters.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// 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 BOOST_TEST_MODULE Test TPC QC
#define BOOST_TEST_MAIN
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>
#include "DataFormatsTPC/Defs.h"
#include "TPCQC/TrackClusters.h"

BOOST_AUTO_TEST_CASE(ReadWriteROOTFile)
{
o2::tpc::qc::TrackClusters trackClusters;
}

0 comments on commit 714640a

Please sign in to comment.