CbmRoot
Loading...
Searching...
No Matches
CbmRichRingTrackAssignIdeal.cxx
Go to the documentation of this file.
1/* Copyright (C) 2006-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Claudia Hoehne, Semen Lebedev, Denis Bertini [committer] */
4
13
14#include "CbmGlobalTrack.h"
15#include "CbmMCTrack.h"
16#include "CbmRichRing.h"
17#include "CbmTrackMatchNew.h"
18#include "FairRootManager.h"
19#include "FairTrackParam.h"
20#include "TClonesArray.h"
21
22#include <Logger.h>
23
24#include <iostream>
25
27
29
31{
32 FairRootManager* manager = FairRootManager::Instance();
33 if (nullptr == manager) LOG(fatal) << "CbmRichRingTrackAssignIdeal::Init(): FairRootManager is nullptr.";
34
35 fGlobalTracks = (TClonesArray*) manager->GetObject("GlobalTrack");
36 if (fGlobalTracks == nullptr) LOG(fatal) << "CbmRichRingTrackAssignIdeal::Init():No GlobalTrack.";
37
38 fRingMatches = (TClonesArray*) manager->GetObject("RichRingMatch");
39 if (fRingMatches == nullptr) LOG(fatal) << "CbmRichRingTrackAssignIdeal::Init():No RichRingMatch.";
40
41 fStsTrackMatches = (TClonesArray*) manager->GetObject("StsTrackMatch");
42 if (fStsTrackMatches == nullptr) LOG(fatal) << "CbmRichRingTrackAssignIdeal::Init():No StsTrackMatch.";
43}
44
45void CbmRichRingTrackAssignIdeal::DoAssign(CbmEvent* event, TClonesArray* rings, TClonesArray* richProj)
46{
47
48 if (event != nullptr) {
49 LOG(fatal) << "CbmRichRingTrackAssignIdeal::DoAssign(): CbmEvent is not nullptr. "
50 "This class does not support time-based mode. Please switch to event-by-event mode.";
51 }
52
53 Int_t nofTracks = richProj->GetEntriesFast();
54 Int_t nofRings = rings->GetEntriesFast();
55
56 for (Int_t iR = 0; iR < nofRings; iR++) {
57 CbmRichRing* ring = static_cast<CbmRichRing*>(rings->At(iR));
58 if (ring == nullptr) continue;
59 if (ring->GetNofHits() < fMinNofHitsInRing) continue;
60
61 CbmTrackMatchNew* ringMatch = static_cast<CbmTrackMatchNew*>(fRingMatches->At(iR));
62 if (ringMatch == nullptr) continue;
63 Int_t ringId = ringMatch->GetMatchedLink().GetIndex();
64
65 for (Int_t iT = 0; iT < nofTracks; iT++) {
66 FairTrackParam* proj = static_cast<FairTrackParam*>(richProj->At(iT));
67 if (proj == nullptr) continue;
68
69 // no projection to photodetector plane
70 if (proj->GetX() == 0 && proj->GetY() == 0) continue;
71
72 CbmGlobalTrack* gTrack = static_cast<CbmGlobalTrack*>(fGlobalTracks->At(iT));
73 if (gTrack == nullptr) continue;
74 if (gTrack->GetStsTrackIndex() == -1) continue;
75 CbmTrackMatchNew* trackMatch = static_cast<CbmTrackMatchNew*>(fStsTrackMatches->At(gTrack->GetStsTrackIndex()));
76 if (trackMatch == nullptr) continue;
77
78 if (trackMatch->GetMatchedLink().GetIndex() == ringId) {
79 gTrack->SetRichRingIndex(iR);
80 }
81 }
82 }
83}
TClonesArray * rings
Ideal Ring-Track Assignment. CbmRichRingMatch must be run prior to this procedure.
TClonesArray * richProj
Class characterising one event by a collection of links (indices) to data objects,...
Definition CbmEvent.h:34
int32_t GetStsTrackIndex() const
void SetRichRingIndex(int32_t iRing)
const CbmLink & GetMatchedLink() const
Definition CbmMatch.h:41
CbmRichRingTrackAssignIdeal()
Default constructor.
virtual void DoAssign(CbmEvent *event, TClonesArray *rings, TClonesArray *richProj)
Inherited from CbmRichRingTrackAssignBase.
void Init()
Inherited from CbmRichRingTrackAssignBase.
int32_t GetNofHits() const
Definition CbmRichRing.h:37