CbmRoot
Loading...
Searching...
No Matches
CbmStsTrackFinder.cxx
Go to the documentation of this file.
1/* Copyright (C) 2005-2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Volker Friese [committer], Evgeny Lavrik, Florian Uhlig */
4
5// -------------------------------------------------------------------------
6// ----- CbmStsTrackFinder source file -----
7// ----- Created 02/02/05 by V. Friese -----
8// -------------------------------------------------------------------------
9
10
11// Empty file, just there to please CINT
12
13#include "CbmStsTrackFinder.h"
14
15#include "CbmDigiManager.h"
16#include "CbmStsCluster.h"
17#include "CbmStsDigi.h"
18#include "CbmStsHit.h"
19#include "CbmStsTrack.h"
20#include "FairRootManager.h"
21#include "TClonesArray.h"
22
24 : TNamed()
25 , fDigiScheme(nullptr)
26 , fField(nullptr)
27 , fMvdHits(nullptr)
28 , fStsHits(nullptr)
29 , fTracks(nullptr)
30 , fStsClusters(nullptr)
31 , fVerbose(0)
32{
33}
34
35double CbmStsTrackFinder::VecMedian(std::vector<double>& vec)
36{
37 if (vec.empty()) {
38 return 0.;
39 }
40
41 auto mid = vec.size() / 2;
42 std::nth_element(vec.begin(), vec.begin() + mid, vec.end());
43 auto median = vec[mid];
44 if (!(vec.size() & 1)) {
45 auto max_it = std::max_element(vec.begin(), vec.begin() + mid);
46 median = (*max_it + median) / 2.0;
47 }
48 return median;
49}
50
52{
53 if (!fStsClusters) {
54 FairRootManager* ioman = FairRootManager::Instance();
55 assert(ioman);
56
57 fStsClusters = (TClonesArray*) ioman->GetObject("StsCluster");
58 assert(fStsClusters);
59 }
60
62
63 std::vector<double> dEdxAllveto;
64
65 double dr = 1.;
66 for (int iHit = 0; iHit < cbmStsTrack->GetNofStsHits(); ++iHit) {
67 bool frontVeto = kFALSE, backVeto = kFALSE;
68 CbmStsHit* stsHit = (CbmStsHit*) fStsHits->At(cbmStsTrack->GetStsHitIndex(iHit));
69
70 double x, y, z, xNext, yNext, zNext;
71 x = stsHit->GetX();
72 y = stsHit->GetY();
73 z = stsHit->GetZ();
74
75 if (iHit != cbmStsTrack->GetNofStsHits() - 1) {
76 CbmStsHit* stsHitNext = (CbmStsHit*) fStsHits->At(cbmStsTrack->GetStsHitIndex(iHit + 1));
77 xNext = stsHitNext->GetX();
78 yNext = stsHitNext->GetY();
79 zNext = stsHitNext->GetZ();
80 dr = sqrt((xNext - x) * (xNext - x) + (yNext - y) * (yNext - y) + (zNext - z) * (zNext - z))
81 / (zNext - z); // if *300um, you get real reconstructed dr
82 } // else dr stay previous
83
84 CbmStsCluster* frontCluster = (CbmStsCluster*) fStsClusters->At(stsHit->GetFrontClusterId());
85 CbmStsCluster* backCluster = (CbmStsCluster*) fStsClusters->At(stsHit->GetBackClusterId());
86
87 if (!frontCluster || !backCluster) {
88 LOG(info) << "CbmStsTrackFinder::CalculateEloss: no front or back cluster";
89 continue;
90 }
91
92 //check if at least one digi in a cluster has overflow --- charge is registered in the last ADC channel #31
93 for (int iDigi = 0; iDigi < frontCluster->GetNofDigis(); ++iDigi) {
94 if (CbmStsTrackFinder::MaxAdcVal() == (digiManager->Get<CbmStsDigi>(frontCluster->GetDigi(iDigi))->GetCharge()))
95 frontVeto = kTRUE;
96 }
97 for (int iDigi = 0; iDigi < backCluster->GetNofDigis(); ++iDigi) {
98 if (CbmStsTrackFinder::MaxAdcVal() == (digiManager->Get<CbmStsDigi>(backCluster->GetDigi(iDigi))->GetCharge()))
99 backVeto = kTRUE;
100 }
101
102 if (!frontVeto) dEdxAllveto.push_back((frontCluster->GetCharge()) / dr);
103 if (!backVeto) dEdxAllveto.push_back((backCluster->GetCharge()) / dr);
104 }
105
106 float dEdXSTS = CbmStsTrack::ELossOverflow();
107 if (dEdxAllveto.size() != 0) dEdXSTS = VecMedian(dEdxAllveto);
108 return dEdXSTS;
109}
110
112{
113 Int_t nStsTracks = fTracks->GetEntriesFast();
114 for (Int_t stsTrackIndex = 0; stsTrackIndex < nStsTracks; stsTrackIndex++) {
115 CbmStsTrack* cbmStsTrack = (CbmStsTrack*) fTracks->At(stsTrackIndex);
116 double dEdXSTS = CalculateEloss(cbmStsTrack);
117 cbmStsTrack->SetELoss(dEdXSTS);
118 }
119}
120
ClassImp(CbmConverterManager)
Data class for STS clusters.
Data class for a reconstructed hit in the STS.
Data class for STS tracks.
friend fvec sqrt(const fvec &a)
int32_t GetDigi(int32_t index) const
Get digi at position index.
Definition CbmCluster.h:76
int32_t GetNofDigis() const
Number of digis in cluster.
Definition CbmCluster.h:69
CbmDigiManager.
const Digi * Get(Int_t index) const
Get a digi object.
static CbmDigiManager * Instance()
Static instance.
double GetZ() const
Definition CbmHit.h:71
double GetY() const
Definition CbmPixelHit.h:74
double GetX() const
Definition CbmPixelHit.h:73
Data class for STS clusters.
double GetCharge() const
Get cluster charge @value Total cluster charge [e].
Data class for a single-channel message in the STS.
Definition CbmStsDigi.h:40
data class for a reconstructed 3-d hit in the STS
Definition CbmStsHit.h:35
int32_t GetFrontClusterId() const
Definition CbmStsHit.h:105
int32_t GetBackClusterId() const
Definition CbmStsHit.h:65
double CalculateEloss(CbmStsTrack *cbmStsTrack)
TClonesArray * fTracks
TClonesArray * fStsHits
double VecMedian(std::vector< double > &vec)
static constexpr int MaxAdcVal()
void FillEloss()
Calculate the median energy loss for the tracks and fill the respective data members.
TClonesArray * fStsClusters
int32_t GetStsHitIndex(int32_t iHit) const
void SetELoss(float ELoss)
static constexpr float ELossOverflow()
int32_t GetNofStsHits() const
Definition CbmStsTrack.h:93