|
| 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 | +} |
0 commit comments