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