Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
TrackTpcCut.cxx
1/*
2 * TrackTpcBasicCut.cxx
3 *
4 * Created on: 21 cze 2017
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9
10#include "TrackTpcCut.h"
11
12
13#include <TString.h>
14
15#include "Cout.h"
16#include "Cut.h"
17#include "DataFormat.h"
18#include "ExpTrack.h"
19#include "StdString.h"
20#include "Package.h"
21#include "Parameter.h"
22#include "TpcTrack.h"
23#include "Track.h"
24
25namespace Hal {
26 const Int_t TrackTpcCut::fgTpcHitsId = 0;
27 const Int_t TrackTpcCut::fgChargeId = 1;
28 const Int_t TrackTpcCut::fgSigmaPionId = 2;
29 const Int_t TrackTpcCut::fgSigmaKaonId = 3;
30 const Int_t TrackTpcCut::fgSigmaProtonId = 4;
31 const Int_t TrackTpcCut::fgSigmaElectronId = 5;
32 const Int_t TrackTpcCut::fgDeDxId = 6;
33
34 TrackTpcCut::TrackTpcCut() : TrackExpCut(7) {
35 SetUnitName("TpcHits [N]", TpcHits());
36 SetUnitName("TpcCharge [q]", Charge());
37 SetUnitName("#sigma#pi", PionSigma());
38 SetUnitName("#sigmaK", KaonSigma());
39 SetUnitName("#sigmaP", ProtonSigma());
40 SetUnitName("#sigmae", ElectronSigma());
41 SetUnitName("dEdX [kV/cm]", DeDx());
42 fParticleType = PionSigma();
43 SetMinMax(-1E+29, 1E+29, PionSigma());
44 SetMinMax(-1E+29, 1E+29, KaonSigma());
45 SetMinMax(-1E+29, 1E+29, ProtonSigma());
46 SetMinMax(-1E+29, 1E+29, ElectronSigma());
47 SetMinMax(0, 1E+29, DeDx());
48 SetMinMax(-1, 1, Charge());
49 SetMinMax(0, 90, TpcHits());
50 fMode = kNotBad;
51 }
52
53 Bool_t TrackTpcCut::Init(Int_t task_id) {
54 Bool_t stat = TrackExpCut::Init(task_id);
55 if (stat == kFALSE) return kFALSE;
56 if (TpcAvaiable(task_id)) return kTRUE;
57 return kFALSE;
58 }
59
60 void TrackTpcCut::SetSigma(Double_t min, Double_t max, TString opt) {
61 if (Hal::Std::FindParam(opt, "pi")) {
62 SetMinMax(min, max, PionSigma());
63 } else if (Hal::Std::FindParam(opt, "K")) {
64 SetMinMax(min, max, KaonSigma());
65 } else if (Hal::Std::FindParam(opt, "p")) {
66 SetMinMax(min, max, ProtonSigma());
67 } else if (Hal::Std::FindParam(opt, "e")) {
68 SetMinMax(min, max, ElectronSigma());
69 } else {
70 Cout::Text("Wrong SetSigma flag please use pi/K/p/e", "L", kOrange);
71 }
72 }
73
74 void TrackTpcCut::SetCharge(Int_t i) { SetMinAndMax(i, Charge()); }
75
76 void TrackTpcCut::SetNHits(Int_t min, Int_t max) { SetMinMax(min, max, TpcHits()); }
77
78 Package* TrackTpcCut::Report() const {
79 Package* pack = TrackCut::Report();
80 TString sigma_name;
81 switch (fParticleType) {
82 case fgSigmaPionId: sigma_name = "PionSigma"; break;
83 case fgSigmaKaonId: sigma_name = "KaonSigma"; break;
84 case fgSigmaProtonId: sigma_name = "ProtonSigma"; break;
85 case fgSigmaElectronId: sigma_name = "ElectronSigma"; break;
86 default: sigma_name = "UnknownSigma"; break;
87 }
88 ParameterString* str = new ParameterString("ActiveSigma", sigma_name);
89 pack->AddObject(str);
90 switch (fMode) {
91 case kNotBad: {
92 ParameterString* stt = new ParameterString("Mode", "NotBad");
93 pack->AddObject(stt);
94 } break;
95 case kGood: {
96 ParameterString* stt = new ParameterString("Mode", "Good");
97 pack->AddObject(stt);
98 } break;
99 }
100 return pack;
101 }
102
103 void TrackTpcCut::SetDeDx(Double_t min, Double_t max) { SetMinMax(min, max, DeDx()); }
104
105 TrackTpcCut::~TrackTpcCut() {}
106
107 Bool_t TrackTpcCut::Pass(Track* track) {
108 TpcTrack* tpc = (TpcTrack*) ((ExpTrack*) track)->GetDetTrack(DetectorID::kTPC);
109 if (tpc == NULL) return ForcedUpdate(kFALSE);
110 SetValue(track->GetCharge(), fgChargeId);
111 SetValue(tpc->GetDeDx(), fgDeDxId);
112 SetValue(tpc->GetNHits(), fgTpcHitsId);
113 SetValue(tpc->GetSigmaPion(), fgSigmaPionId);
114 SetValue(tpc->GetSigmaElectron(), fgSigmaElectronId);
115 SetValue(tpc->GetSigmaKaon(), fgSigmaKaonId);
116 SetValue(tpc->GetSigmaProton(), fgSigmaProtonId);
117 return ForcedUpdate(Verify());
118 }
119
120 Bool_t TrackTpcCut::Verify() {
121 switch (fMode) {
122 case kGood: {
123 for (int i = fgSigmaPionId; i < fgSigmaPionId + 4; i++) {
124 if (i == fParticleType) { // inside "banana bounds"
125 if (GetValue(i) < GetMin(i)) return kFALSE;
126 if (GetValue(i) > GetMax(i)) return kFALSE;
127 } else {
128 // must be outside "banana"
129 if (GetValue(i) > GetMin(i) && GetValue(i) < GetMax(i)) return kFALSE;
130 }
131 }
132 } break;
133 case kNotBad: {
134 // inside banana
135 if (GetValue(fParticleType) < GetMin(fParticleType)) return kFALSE;
136 if (GetValue(fParticleType) > GetMax(fParticleType)) return kFALSE;
137 } break;
138 }
139 // tpc dedx
140 if (GetValue(fgDeDxId) < GetMin(fgDeDxId)) return kFALSE;
141 if (GetValue(fgDeDxId) > GetMax(fgDeDxId)) return kFALSE;
142 // hits
143 if (GetValue(fgTpcHitsId) < GetMin(fgTpcHitsId)) return kFALSE;
144 if (GetValue(fgTpcHitsId) > GetMax(fgTpcHitsId)) return kFALSE;
145 // charge
146 if (GetValue(fgChargeId) < GetMin(fgChargeId)) return kFALSE;
147 if (GetValue(fgChargeId) > GetMax(fgChargeId)) return kFALSE;
148 return kTRUE;
149 }
150
151 TrackTpcCut::TrackTpcCut(const TrackTpcCut& other) :
152 TrackExpCut(other), fParticleType(other.fParticleType), fMode(other.fMode) {}
153
154 void TrackTpcCut::SetActiveSigma(TString flag) {
155 if (Hal::Std::FindParam(flag, "pi")) {
156 fParticleType = PionSigma();
157 } else if (Hal::Std::FindParam(flag, "K")) {
158 fParticleType = KaonSigma();
159 } else if (Hal::Std::FindParam(flag, "p")) {
160 fParticleType = ProtonSigma();
161 } else if (Hal::Std::FindParam(flag, "e")) {
162 fParticleType = ElectronSigma();
163 } else {
164 Cout::Text("Wrong SetActiveSigma flag please use pi/K/p/e", "L", kOrange);
165 }
166 }
167} // namespace Hal
static void Text(TString text, TString option="L", Color_t color=-1)
Definition Cout.cxx:92
void AddObject(TObject *object)
Definition Package.cxx:209
Float_t GetSigmaPion() const
Definition TpcTrack.h:54
Float_t GetDeDx() const
Definition TpcTrack.h:94
Int_t GetNHits() const
Definition TpcTrack.h:49
Float_t GetSigmaProton() const
Definition TpcTrack.h:64
Float_t GetSigmaKaon() const
Definition TpcTrack.h:59
Float_t GetSigmaElectron() const
Definition TpcTrack.h:69
void SetActiveSigma(TString flag)
static Int_t PionSigma()
Definition TrackTpcCut.h:86
static Int_t ProtonSigma()
Definition TrackTpcCut.h:96
static Int_t ElectronSigma()
static Int_t KaonSigma()
Definition TrackTpcCut.h:91
Double_t GetCharge() const
Definition Track.h:184