forked from wiechula/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shared clusters, found clusters and crossed rows TASK for TPC QC
- Loading branch information
Laura Serksnyte
committed
Dec 14, 2023
1 parent
12ca838
commit 714640a
Showing
5 changed files
with
214 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |