CbmRoot
Loading...
Searching...
No Matches
CbmLitQualitySort.cxx
Go to the documentation of this file.
1/* Copyright (C) 2011-2013 GSI/JINR-LIT, Darmstadt/Dubna
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Andrey Lebedev [committer] */
4
6
7#include "data/CbmLitTrack.h"
8
9#include <algorithm>
10
12
14
15//LitStatus CbmLitQualitySort::DoSort(
16// TrackPtrIterator itBegin,
17// TrackPtrIterator itEnd)
18//{
19// if (itBegin == itEnd) { return kLITSUCCESS; }
20//
21// SortNofHits(itBegin, itEnd);
22// //SortLastPlaneId(itBegin, itEnd);
23//
24// return kLITSUCCESS;
25//}
26//
27//LitStatus CbmLitQualitySort::DoSort(
28// TrackPtrVector& tracks)
29//{
30// return DoSort(tracks.begin(), tracks.end());
31//}
32
34{
35 std::sort(itBegin, itEnd, [](const CbmLitTrack* track1, const CbmLitTrack* track2) {
36 return track1->GetNofHits() > track2->GetNofHits();
37 });
38
39 Int_t maxNofHits = (*itBegin)->GetNofHits();
40 Int_t minNofHits = (*(itEnd - 1))->GetNofHits();
41
42 for (Int_t iNofHits = minNofHits; iNofHits <= maxNofHits; iNofHits++) {
43 CbmLitTrack value;
44 value.SetNofHits(iNofHits);
45
46 std::pair<TrackPtrIterator, TrackPtrIterator> bounds;
47 bounds = std::equal_range(itBegin, itEnd, &value, [](const CbmLitTrack* track1, const CbmLitTrack* track2) {
48 return track1->GetNofHits() > track2->GetNofHits();
49 });
50
51 if (bounds.first == bounds.second) {
52 continue;
53 }
54
55 std::sort(bounds.first, bounds.second, [](const CbmLitTrack* track1, const CbmLitTrack* track2) {
56 return ((track1->GetChi2() / track1->GetNDF()) < (track2->GetChi2() / track2->GetNDF()));
57 });
58 }
59 return kLITSUCCESS;
60}
61
63{
64 std::sort(itBegin, itEnd, [](const CbmLitTrack* track1, const CbmLitTrack* track2) {
65 return track1->GetLastStationId() > track2->GetLastStationId();
66 });
67
68 Int_t maxPlaneId = (*itBegin)->GetLastStationId();
69 Int_t minPlaneId = (*(itEnd - 1))->GetLastStationId();
70
71 for (Int_t iPlaneId = minPlaneId; iPlaneId <= maxPlaneId; iPlaneId++) {
72 CbmLitTrack value;
73 value.SetLastStationId(iPlaneId);
74
75 std::pair<TrackPtrIterator, TrackPtrIterator> bounds;
76 bounds = std::equal_range(itBegin, itEnd, &value, [](const CbmLitTrack* track1, const CbmLitTrack* track2) {
77 return track1->GetLastStationId() > track2->GetLastStationId();
78 });
79
80 if (bounds.first == bounds.second) {
81 continue;
82 }
83
84 std::sort(bounds.first, bounds.second, [](const CbmLitTrack* track1, const CbmLitTrack* track2) {
85 return ((track1->GetChi2() / track1->GetNDF()) < (track2->GetChi2() / track2->GetNDF()));
86 });
87 }
88 return kLITSUCCESS;
89}
90
92{
93 std::sort(itBegin, itEnd, [](const CbmLitTrack* track1, const CbmLitTrack* track2) {
94 return ((track1->GetChi2() / track1->GetNDF()) < (track2->GetChi2() / track2->GetNDF()));
95 });
96 return kLITSUCCESS;
97}
LitStatus
Definition CbmLitEnums.h:29
@ kLITSUCCESS
Definition CbmLitEnums.h:30
Base data class for track.
std::vector< CbmTofTrack * >::iterator TrackPtrIterator
Definition CbmTofTypes.h:25
CbmLitQualitySort()
Constructor.
static LitStatus DoSortNofHits(TrackPtrIterator itBegin, TrackPtrIterator itEnd)
Sort array of tracks by quality.
virtual ~CbmLitQualitySort()
Destructor.
static LitStatus DoSortLastStation(TrackPtrIterator itBegin, TrackPtrIterator itEnd)
Sort array of tracks by quality using last station id and chi square.
static LitStatus DoSortChiSqOverNDF(TrackPtrIterator itBegin, TrackPtrIterator itEnd)
Sort array of tracks by quality using (chi square / NDF).
Base data class for track.
Definition CbmLitTrack.h:34
void SetNofHits(Int_t nofHits)
Definition CbmLitTrack.h:88
Int_t GetNDF() const
Definition CbmLitTrack.h:65
Int_t GetNofHits() const
Definition CbmLitTrack.h:62
void SetLastStationId(Int_t lastPlaneId)
Definition CbmLitTrack.h:89
Int_t GetLastStationId() const
Definition CbmLitTrack.h:70
litfloat GetChi2() const
Definition CbmLitTrack.h:64