BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
h3l_pair_selector.C
Go to the documentation of this file.
1
2#include "TFile.h"
3#include "TH1F.h"
4#include "TTreeReader.h"
5#include "TTreeReaderArray.h"
6#include "TTreeReaderValue.h"
7
8#include <TSystem.h>
9// #include "BmnHypNuclPair.h"
10
11using namespace std;
12
15
16// best by me for EXP
39
40// best by me for MC
41// Float_t pathMin = 1.1;
42// Float_t pathMax = 35;
43// Float_t dca2Min = 3.6;
44// Float_t dca2Max = 100;
45// Float_t dca12Min = 0.0;
46// Float_t dca12Max = 6.0;
47// Float_t mom1Min = 4.5;
48// Float_t mom1Max = 10.5;
49// Float_t mom2Min = 0.0;
50// Float_t mom2Max = 1.1;
51// Float_t dca1Min = 0.00;
52// Float_t dca1Max = 1000.0;
53// Float_t dca0Min = 0.08;
54// Float_t dca0Max = 0.65;
55// Int_t fsd1Min = 0 ;
56// Int_t fsd1Max = 4 ;
57// Int_t fsd2Min = 0 ;
58// Int_t fsd2Max = 4 ;
59// Int_t gem1Min = 3 ;
60// Int_t gem1Max = 7 ;
61// Int_t gem2Min = 0 ;
62// Int_t gem2Max = 7 ;
63
64void h3l_pair_selector(TString inputFileName = "/home/merz/data/h3l_sim/h3lPairs_XeCsI_3.8AGeV_mb_4mln.root",
65 TString outputFileName = "/home/merz/data/h3l_sim/h3lSelect_XeCsI_3.8AGeV_mb_4mln.root")
66{
67
68 if (gSystem->AccessPathName(inputFileName))
69 return;
70
71 cout << "File: " << inputFileName << endl;
72 TFile* inFile = TFile::Open(inputFileName);
73
74 TTreeReader myReader("bmndata", inFile);
75 TTreeReaderArray<BmnHypNuclPair> pairs(myReader, "pairs");
76
77 TFile outFile(outputFileName, "recreate");
78 vector<Float_t> Path;
79 vector<Float_t> Dca0;
80 vector<Float_t> Dca1;
81 vector<Float_t> Dca2;
82 vector<Float_t> Dca12;
83 vector<Float_t> He3Mass;
84 vector<Float_t> Dedx;
85 vector<Float_t> InvMass;
86 vector<Int_t> NHitsSil1;
87 vector<Int_t> NHitsGem1;
88 vector<Int_t> NHitsSil2;
89 vector<Int_t> NHitsGem2;
90 vector<Float_t> Px1;
91 vector<Float_t> Py1;
92 vector<Float_t> Pz1;
93 vector<Float_t> Px2;
94 vector<Float_t> Py2;
95 vector<Float_t> Pz2;
96 vector<Int_t> NTrInEvent;
97
98 TTree t1("H3L", "H3L");
99 t1.Branch("path", &Path);
100 t1.Branch("dca0", &Dca0);
101 t1.Branch("dca1", &Dca1);
102 t1.Branch("dca2", &Dca2);
103 t1.Branch("dca12", &Dca12);
104 t1.Branch("He3Mass", &He3Mass);
105 t1.Branch("dedx", &Dedx);
106 t1.Branch("invMass", &InvMass);
107 t1.Branch("nHitsSil1", &NHitsSil1);
108 t1.Branch("nHitsGem1", &NHitsGem1);
109 t1.Branch("nHitsSil2", &NHitsSil2);
110 t1.Branch("nHitsGem2", &NHitsGem2);
111 t1.Branch("Px1", &Px1);
112 t1.Branch("Py1", &Py1);
113 t1.Branch("Pz1", &Pz1);
114 t1.Branch("Px2", &Px2);
115 t1.Branch("Py2", &Py2);
116 t1.Branch("Pz2", &Pz2);
117 t1.Branch("nTrInEvent", &NTrInEvent);
118
119 int evId = 0;
120
121 while (myReader.Next()) {
122 Path.clear();
123 Dca0.clear();
124 Dca1.clear();
125 Dca2.clear();
126 Dca12.clear();
127 He3Mass.clear();
128 Dedx.clear();
129 InvMass.clear();
130 NHitsSil1.clear();
131 NHitsGem1.clear();
132 NHitsSil2.clear();
133 NHitsGem2.clear();
134 Px1.clear();
135 Py1.clear();
136 Pz1.clear();
137 Px2.clear();
138 Py2.clear();
139 Pz2.clear();
140 NTrInEvent.clear();
141
142 if (evId % 10000 == 0)
143 printf("evId = %d\n", evId);
144 evId++;
145 for (BmnHypNuclPair pair : pairs) {
146 Float_t mass = pair.GetInvMass();
147 if (mass > invMassMax)
148 continue;
149 if (mass < invMassMin)
150 continue;
151 Float_t path = pair.GetPath();
152 Float_t dedx = pair.GetDedx();
153 Float_t mom1 = pair.GetMom1();
154 Float_t dca0 = pair.GetDCA0();
155 Float_t massTof = pair.GetM2();
156 Float_t dca12 = pair.GetDCA12() / pair.GetdDCA12();
157 Float_t dca1 = pair.GetDCA1() / pair.GetdDCA1();
158 Float_t dca2 = pair.GetDCA2() / pair.GetdDCA2();
159 Float_t mom2 = pair.GetMom2();
160 Int_t nH1fsd = pair.GetNHitsPart1("SILICON");
161 Int_t nH2fsd = pair.GetNHitsPart2("SILICON");
162 Int_t nH1gem = pair.GetNHitsPart1("GEM");
163 Int_t nH2gem = pair.GetNHitsPart2("GEM");
164 Float_t px1 = pair.GetPx1();
165 Float_t py1 = pair.GetPy1();
166 Float_t pz1 = pair.GetPz1();
167 Float_t px2 = pair.GetPx2();
168 Float_t py2 = pair.GetPy2();
169 Float_t pz2 = pair.GetPz2();
170 Int_t nTr = pair.GetNTrInEvent();
171
172 if (nH1fsd < fsd1Min || nH1fsd > fsd1Max)
173 continue;
174 if (nH2fsd < fsd2Min || nH2fsd > fsd2Max)
175 continue;
176 if (nH1gem < gem1Min || nH1gem > gem1Max)
177 continue;
178 if (nH2gem < gem2Min || nH2gem > gem2Max)
179 continue;
180 if (path < pathMin || path > pathMax)
181 continue;
182 // if (dca1 < dca1Min || dca1 > dca1Max) continue;
183 if (dca2 < dca2Min || dca2 > dca2Max)
184 continue;
185 if (dca12 < dca12Min || dca12 > dca12Max)
186 continue;
187 if (mom1 < mom1Min || mom1 > mom1Max)
188 continue;
189 if (mom2 < mom2Min || mom2 > mom2Max)
190 continue;
191 if (dca0 < dca0Min || dca0 > dca0Max)
192 continue;
193
194 TLorentzVector lPos, lNeg;
195 lPos.SetXYZM(px1, py1, pz1, 2.8094135);
196 lNeg.SetXYZM(px2, py2, pz2, 0.1395704);
197 TLorentzVector lHyp = lPos + lNeg;
198 Float_t pt = lHyp.Pt();
199 if (pt < 0.2)
200 continue;
201
202 Path.push_back(path);
203 Dca0.push_back(dca0);
204 Dca1.push_back(dca1);
205 Dca2.push_back(dca2);
206 Dca12.push_back(dca12);
207 He3Mass.push_back(massTof);
208 Dedx.push_back(dedx);
209 InvMass.push_back(mass);
210 NHitsSil1.push_back(nH1fsd);
211 NHitsGem1.push_back(nH1gem);
212 NHitsSil2.push_back(nH2fsd);
213 NHitsGem2.push_back(nH2gem);
214 Px1.push_back(px1);
215 Py1.push_back(py1);
216 Pz1.push_back(pz1);
217 Px2.push_back(px2);
218 Py2.push_back(py2);
219 Pz2.push_back(pz2);
220 NTrInEvent.push_back(nTr);
221 }
222 t1.Fill();
223 }
224
225 inFile->Close();
226
227 t1.Write();
228 outFile.Close();
229}
int Int_t
float Float_t
R__EXTERN TSystem * gSystem
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
void Close(Option_t *option="") override
Double_t Pt() const
void SetXYZM(Double_t x, Double_t y, Double_t z, Double_t m)
virtual Int_t Fill()
Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0) const override
virtual Int_t Branch(const char *folder, Int_t bufsize=32000, Int_t splitlevel=99)
Float_t pathMin
Int_t fsd1Min
Float_t invMassMax
Float_t mom2Min
Float_t dca12Max
Float_t dca1Max
Float_t dca2Max
Float_t dca0Max
Float_t invMassMin
Float_t dca0Min
Int_t fsd2Max
Float_t dca1Min
Int_t fsd1Max
Int_t gem2Min
Float_t dca12Min
Float_t mom1Min
Int_t fsd2Min
void h3l_pair_selector(TString inputFileName="/home/merz/data/h3l_sim/h3lPairs_XeCsI_3.8AGeV_mb_4mln.root", TString outputFileName="/home/merz/data/h3l_sim/h3lSelect_XeCsI_3.8AGeV_mb_4mln.root")
Float_t dca2Min
Float_t mom1Max
Int_t gem1Min
Float_t pathMax
Int_t gem1Max
Int_t gem2Max
Float_t mom2Max
Definition json.hpp:4446