Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
CutFuncs.cxx
1/*
2 * CutFuncs.cxx
3 *
4 * Created on: 25 lis 2023
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9#include "CutFuncs.h"
10#include "Cout.h"
11#include "EventComplexCut.h"
12#include "EventCut.h"
13#include "Std.h"
14#include "TrackComplexCut.h"
15#include "TrackCut.h"
16#include "TwoTrackComplexCut.h"
17#include "TwoTrackCut.h"
18
19namespace Hal {
20 namespace Cuts {
21 std::vector<Int_t> GetCollectionsFlags(Int_t startCol, TString option) {
22 std::vector<Int_t> res;
23 Int_t single = -2;
24 if (!Hal::Std::FindExpressionSingleValue(option, single, kTRUE)) { single = startCol; }
25 Int_t n, jump;
26 if (Hal::Std::FindExpressionTwoValues(option, n, jump, kTRUE)) {
27 for (int i = 0; i < n; i++) {
28 res.push_back(single);
29 single += jump;
30 }
31 return res;
32 } else {
33 res.push_back(single);
34 return res;
35 }
36 return res;
37 }
38
39 Hal::Cut* MakeCutCopy(const Hal::Cut& cut, TString flag, Bool_t acceptNulls) {
40 if (flag == "re") { // real stuff
41 auto upd = cut.GetUpdateRatio();
42 switch (upd) {
43 case ECutUpdate::kEvent: {
44 return new EventRealCut(static_cast<const EventCut&>(cut));
45 } break;
46 case ECutUpdate::kTrack: {
47 return new TrackRealCut(static_cast<const TrackCut&>(cut));
48 } break;
49 case ECutUpdate::kTwoTrack: {
50 return new TwoTrackRealCut(static_cast<const TwoTrackCut&>(cut));
51 } break;
52 case ECutUpdate::kTwoTrackBackground: {
53 return new TwoTrackRealCut(static_cast<const TwoTrackCut&>(cut));
54 } break;
55 default: return nullptr; break;
56 }
57 } else { // imaginary stuff
58 auto upd = cut.GetUpdateRatio();
59 switch (upd) {
60 case ECutUpdate::kEvent: {
61 auto tempcut = new EventImaginaryCut(static_cast<const EventCut&>(cut));
62 if (acceptNulls) static_cast<EventImaginaryCut*>(tempcut)->AcceptNulls(kTRUE);
63 return tempcut;
64 } break;
65 case ECutUpdate::kTrack: {
66 auto tempcut = new TrackImaginaryCut(static_cast<const TrackCut&>(cut));
67 if (acceptNulls) static_cast<TrackImaginaryCut*>(tempcut)->AcceptNulls(kTRUE);
68 return tempcut;
69 } break;
70 case ECutUpdate::kTwoTrack: {
71 auto tempcut = new TwoTrackImaginaryCut(static_cast<const TwoTrackCut&>(cut));
72 if (acceptNulls) static_cast<TwoTrackImaginaryCut*>(tempcut)->AcceptNulls(kTRUE);
73 return tempcut;
74 } break;
75 case ECutUpdate::kTwoTrackBackground: {
76 auto tempcut = new TwoTrackImaginaryCut(static_cast<const TwoTrackCut&>(cut));
77 if (acceptNulls) static_cast<TwoTrackImaginaryCut*>(tempcut)->AcceptNulls(kTRUE);
78 return tempcut;
79 } break;
80 default: return nullptr; break;
81 }
82 }
83 return nullptr;
84 }
85 TString GetCutUpdateRatioName(ECutUpdate upd) {
86 TString update_ratio_name;
87 switch (upd) {
88 case ECutUpdate::kEvent: update_ratio_name = "event"; break;
89 case ECutUpdate::kTrack: update_ratio_name = "track"; break;
90 case ECutUpdate::kTwoTrack: update_ratio_name = "two_track"; break;
91 case ECutUpdate::kTwoTrackBackground: update_ratio_name = "two_track<background>"; break;
92 default:
93 Cout::PrintInfo("Unknown update ratio", EInfo::kLowWarning);
94 update_ratio_name = "unknown";
95 break;
96 }
97 return update_ratio_name;
98 }
99 } // namespace Cuts
100} /* namespace Hal */
static void PrintInfo(TString text, Hal::EInfo status)
Definition Cout.cxx:370
Definition Cut.h:40
ECutUpdate GetUpdateRatio() const
Definition Cut.h:209