CbmRoot
Loading...
Searching...
No Matches
PairAnalysisCutCombi.cxx
Go to the documentation of this file.
1/* Copyright (C) 2015-2020 Justus-Liebig-Universitaet Giessen, Giessen
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Julian Book [committer] */
4
5/* Advanced cut class.
6
7 Add cuts that are applied only for certain types of e.g. tracks or under
8 some defined condition: AddCut(AnalysisCuts *cuts, AnalysisCuts *range)
9
10 Example - apply TRD PID only for track with 3-4 reconstructed hits
11
12 // TRD reconstruction cuts
13 PairAnalysisVarCuts *recTRD = new PairAnalysisVarCuts("recTRD","recTRD");
14 recTRD->AddCut(PairAnalysisVarManager::kTRDHits, 3., 4.);
15
16 // TRD Pid - 1-dimensional
17 PairAnalysisVarCuts *pidTRD = new PairAnalysisVarCuts("pidTRD","pidTRD");
18 pidTRD->AddCut(PairAnalysisVarManager::kTRDPidANN, 0.5, 1.5);
19
20 // build PID cut depending on track quality
21 PairAnalysisCutCombi *pidTRDavai = new PairAnalysisCutCombi("TRDPidAvai","TRDPidAvai");
22 pidTRDavai->AddCut(pidTRD, recTRD);
23*/
24
26
28
30
32 : AnalysisCuts()
33 , fNActiveCuts(0)
34 , fActiveCutsMask(0)
35 , fSelectedCutsMask(0)
36 , fCutType(ECutType::kAll)
37{
38 //
39 // Default Constructor
40 //
41 for (Int_t i = 0; i < kNmaxCuts; ++i) {
42 fRangeCuts[i] = 0x0;
43 fCuts[i] = 0x0;
44 }
45}
46
47//______________________________________________
48PairAnalysisCutCombi::PairAnalysisCutCombi(const char* name, const char* title)
49 : AnalysisCuts(name, title)
50 , fNActiveCuts(0)
51 , fActiveCutsMask(0)
52 , fSelectedCutsMask(0)
53 , fCutType(ECutType::kAll)
54{
55 //
56 // Named Constructor
57 //
58 for (Int_t i = 0; i < kNmaxCuts; ++i) {
59 fRangeCuts[i] = 0x0;
60 fCuts[i] = 0x0;
61 }
62}
63
64//______________________________________________
66{
67 //
68 // Default Destructor
69 //
70 for (Int_t i = 0; i < kNmaxCuts; ++i) {
71 if (fRangeCuts[i]) delete fRangeCuts[i];
72 if (fCuts[i]) delete fCuts[i];
73 }
74}
75
76//______________________________________________
78{
79 //
80 // add CutCombi cuts
81 //
82 if (fNActiveCuts == kNmaxCuts) {
83 Warning("AddCut", "Too many cuts added!");
84 return;
85 }
86
88 fRangeCuts[fNActiveCuts] = range;
89 fCuts[fNActiveCuts] = cuts;
91}
92
93
94//______________________________________________
96{
97 //
98 // make cut decision
99 //
100
101 if (!track) return kFALSE;
102
103 //Fill values
104 Double_t* values = PairAnalysisVarManager::GetData();
105 PairAnalysisVarManager::Fill(track, values);
106
108 return (IsSelected(values));
109}
110
111//________________________________________________________________________
112Bool_t PairAnalysisCutCombi::IsSelected(Double_t* const values)
113{
114 //
115 // Make cut decision
116 //
117
118 //reset
120 SetSelected(kFALSE);
121
122 // loop overe all cuts
123 for (Int_t iCut = 0; iCut < fNActiveCuts; ++iCut) {
125
126 if (!fRangeCuts[iCut] || !fCuts[iCut]) continue;
127
128 // check the range(s) where cuts should be applied
129 if (!fRangeCuts[iCut]->IsSelected(values)) continue;
130
131 // check decision
132 if (!fCuts[iCut]->IsSelected(values)) CLRBIT(fSelectedCutsMask, iCut);
133
134 // cut type and intermediate decision
135 if (fCutType == ECutType::kAll && !TESTBIT(fSelectedCutsMask, iCut)) return kFALSE;
136 }
137
138 // cut type and final decision
139 Bool_t isSelected = (fSelectedCutsMask == fActiveCutsMask);
140 if (fCutType == ECutType::kAny) isSelected = (fSelectedCutsMask > 0);
141 SetSelected(isSelected);
142 return isSelected;
143}
144
145//________________________________________________________________________
146void PairAnalysisCutCombi::Print(const Option_t* /*option*/) const
147{
148 //
149 // Print cuts and the range
150 //
151 printf("-----------------------------------------------------------------\n");
152 printf("cut ranges for '%s'\n", GetTitle());
153 if (fCutType == ECutType::kAll) { printf("All Cuts have to be fulfilled\n"); }
154 else {
155 printf("Any Cut has to be fulfilled\n");
156 }
157
158 for (Int_t iCut = 0; iCut < fNActiveCuts; ++iCut) {
159 fCuts[iCut]->Print();
160 printf("For the following conditions:\n");
161 fRangeCuts[iCut]->Print();
162 }
163 printf("-----------------------------------------------------------------\n");
164}
ClassImp(PairAnalysisCutCombi) PairAnalysisCutCombi
#define SETBIT(n, i)
Definition RTypes.h:15
#define TESTBIT(n, i)
Definition RTypes.h:17
#define CLRBIT(n, i)
Definition RTypes.h:16
virtual void SetSelected(Bool_t dec)
AnalysisCuts * fCuts[kNmaxCuts]
void AddCut(AnalysisCuts *cuts, AnalysisCuts *range)
virtual void Print(const Option_t *option="") const
AnalysisCuts * fRangeCuts[kNmaxCuts]
static const Int_t kNmaxCuts
virtual Bool_t IsSelected(Double_t *const values)
static void Fill(const TObject *particle, Double_t *const values)