BmnRoot
Loading...
Searching...
No Matches
BmnTwoParticleDecay.cxx
Go to the documentation of this file.
1// @(#)bmnroot/physics/particles:$Id$
2// Author: Pavel Batyuk <pavel.batyuk@jinr.ru> 2017-12-27
3
5// //
6// BmnTwoParticleDecay //
7// //
8// A supplementary class for two-body decay reconstruction //
9// //
11#include <TCanvas.h>
12#include "TFile.h"
13#include <TGeoManager.h>
14#include <Fit/FitResult.h>
15#include "BmnTwoParticleDecay.h"
17
19: fEventCounter(0),
20 fGlobalMatches(nullptr),
21 fVertex(nullptr),
22 fGeometry(config),
23 fField(nullptr),
24 fKalman(nullptr),
25 fParticlePair(nullptr),
26 fParticlePair_MC(nullptr),
27 fParticlePair_RECO(nullptr),
28 fPDG1(2212), // proton
29 fPDG2(-211), // pion
30 fPdgParticle1(fPDG1),
31 fPdgParticle2(fPDG2),
32 fIsCbmDst(kFALSE),
33 fGeomFile(""),
34 fDigiDir(""),
35 fEoSNode("root://ncm.jinr.ru/"),
36 fDstHeader(nullptr),
37 fPhysInfo(nullptr)
38{
39 fMcVertex.SetXYZ(0., 0., 0.);
40 fRunId = runId;
41
42 if (config == BmnGemStripConfiguration::GEM_CONFIG::RunSpring2018)
43 fRunPeriod = 7;
44
45 else if (config == BmnGemStripConfiguration::GEM_CONFIG::RunSpring2017)
46 fRunPeriod = 6;
47
48 else {
49 cout << "BmnGemStripConfiguration not defined !!!" << endl;
50 throw;
51 }
52
53 // Create GEM detector ------------------------------------------------------
54
55 TString gPathGemConfig = gSystem->Getenv("VMCWORKDIR");
56 gPathGemConfig += "/parameters/gem/XMLConfigs/";
57 // Create GEM detector ------------------------------------------------------
58 switch (fGeometry) {
60 fDetector = new BmnGemStripStationSet(gPathGemConfig + "GemRunSpring2017.xml");
61 cout << " Current Configuration : RunSpring2017" << "\n";
62 break;
63
65 fDetector = new BmnGemStripStationSet(gPathGemConfig + "GemRunSpring2018.xml");
66 cout << " Current Configuration : RunSpring2018" << "\n";
67 break;
68
69 default:
70 fDetector = new BmnGemStripStationSet(gPathGemConfig + "GemRunSpring2018.xml");
71 cout << " Current Configuration : RunSpring2018" << "\n";
72 break;
73 }
74}
75
77 delete fDetector;
78}
79
80vector <Double_t> BmnTwoParticleDecay::GeomTopology(FairTrackParam proton_V0, FairTrackParam pion_V0, FairTrackParam proton_Vp, FairTrackParam pion_Vp) {
81 Double_t X = 0., Y = 0., Z = 0.;
82
83 // evetest.root -->
84 Bool_t isMC = fAnalType[0].Contains("eve") && !fAnalType[0].Contains("dst"); // only MC
85 if (isMC) {
86 X = fMcVertex.X();
87 Y = fMcVertex.Y();
88 Z = fMcVertex.Z();
89 }// bmndst.root -->
90 else {
91 X = fEventVertex->GetX();
92 Y = fEventVertex->GetY();
93 Z = fEventVertex->GetZ();
94 }
95 TVector3 Vp(X, Y, Z);
96 // Secondary proton at V0
97 TVector3 protonV0(proton_V0.GetX(), proton_V0.GetY(), proton_V0.GetZ());
98 // Secondary pion at V0
99 TVector3 pionV0(pion_V0.GetX(), pion_V0.GetY(), pion_V0.GetZ());
100
101 // Secondary proton extrapolated to Vp (Vp_prot_extrap)
102 TVector3 protonVp(proton_Vp.GetX(), proton_Vp.GetY(), proton_Vp.GetZ());
103 // Secondary pion extrapolated to Vp (Vp_pion_extrap)
104 TVector3 pionVp(pion_Vp.GetX(), pion_Vp.GetY(), pion_Vp.GetZ());
105
106 // 1)
107 // Distance beetween Vp and Vp_prot_extrap
108 Double_t protonVpVp = TVector3(protonVp - Vp).Mag();
109 // 2)
110 // Distance beetween Vp and Vp_prot_extrap
111 Double_t pionVpVp = TVector3(pionVp - Vp).Mag();
112 // 3)
113 // Distance between proton and pion at V0
114 Double_t protonV0PionV0 = TVector3(protonV0 - pionV0).Mag();
115 // 4)
116 // Distance between V0 and Vp along beamline
117 // Double_t vertexDiff = proton_V0.GetZ() - Z;
118
119 vector <Double_t> cuts;
120 cuts.push_back(protonVpVp);
121 cuts.push_back(pionVpVp);
122 cuts.push_back(protonV0PionV0);
123 // cuts.push_back(Abs(vertexDiff));
124
125 return cuts;
126}
127
128FairTrackParam BmnTwoParticleDecay::KalmanTrackPropagation(BmnGlobalTrack* track, Int_t pdg, Double_t Z) {
129 FairTrackParam parPredict = *(track->GetParamFirst());
130 fKalman->TGeoTrackPropagate(&parPredict, Z, pdg, nullptr, nullptr, kTRUE);
131 // track->SetParamFirst(parPredict);
132 return parPredict;
133}
134
135BmnStatus BmnTwoParticleDecay::FindFirstPointOnMCTrack(Int_t iTrack, BmnGlobalTrack* track, Int_t sign) {
136 FairTrackParam param;
137 map <Double_t, FairMCPoint*> firstPoint;
138
139 for (Int_t iPoint = 0; iPoint < fSilPoints->GetEntriesFast(); iPoint++) {
140 BmnSiliconPoint* silPoint = (BmnSiliconPoint*) fSilPoints->UncheckedAt(iPoint);
141 Int_t TrackID = silPoint->GetTrackID();
142
143 if (TrackID != iTrack)
144 continue;
145
146 firstPoint[silPoint->GetZIn()] = silPoint;
147 }
148
149 FairMCPoint* point = nullptr;
150 if (firstPoint.size() == 0)
151 for (Int_t iPoint = 0; iPoint < fGemPoints->GetEntriesFast(); iPoint++) {
152 CbmStsPoint* gemPoint = (CbmStsPoint*) fGemPoints->UncheckedAt(iPoint);
153 Int_t TrackID = gemPoint->GetTrackID();
154
155 if (TrackID != iTrack)
156 continue;
157
158 firstPoint[gemPoint->GetZIn()] = gemPoint;
159 }
160
161 point = firstPoint.begin()->second;
162
163 if (!point)
164 return kBMNERROR;
165
166 Double_t Px = point->GetPx();
167 Double_t Py = point->GetPy();
168 Double_t Pz = point->GetPz();
169 // cout << point << " " << point->GetZ() << endl;
170
171 param.SetTx(Px / Pz);
172 param.SetTy(Py / Pz);
173 param.SetQp(sign / Sqrt(Px * Px + Py * Py + Pz * Pz));
174 param.SetX(point->GetX());
175 param.SetY(point->GetY());
176 param.SetZ(point->GetZ());
177
178 if (IsParCorrect(&param, kTRUE)) {
179 track->SetParamFirst(param);
180 return kBMNSUCCESS;
181 } else
182 return kBMNERROR;
183}
184
185Bool_t BmnTwoParticleDecay::CheckTrack(BmnGlobalTrack* track, Int_t pdgCode, Double_t& mom, Double_t& eta) {
186 Double_t Tx = track->GetParamFirst()->GetTx();
187 Double_t Ty = track->GetParamFirst()->GetTy();
188 Double_t p = 1. / track->GetParamFirst()->GetQp();
189
190 Double_t Pz = Abs(p) / Sqrt(1 + Tx * Tx + Ty * Ty);
191
192 Int_t sign = CheckSign(fPDG->GetParticle(pdgCode)->Charge());
193
194 mom = Abs(p);
195 eta = 0.5 * Log((Abs(p) + Pz) / (Abs(p) - Pz));
196
197 if (sign * p < 0)
198 return kFALSE;
199 else
200 return kTRUE;
201}
202
203void BmnTwoParticleDecay::Analysis() {
204 TLorentzVector lPos, lNeg;
205
206 TClonesArray* arr = (fAnalType[1].Contains("ON") || fAnalType[0].Contains("dst")) ? fGlobalTracks : fMCTracks;
207 Bool_t isMC = fAnalType[0].Contains("eve") && !fAnalType[0].Contains("dst"); // only MC
208
209 for (Int_t iTrack = 0; iTrack < arr->GetEntriesFast(); iTrack++) {
210 BmnGlobalTrack Track1;
211 BmnGlobalTrack* track1 = &Track1;
212
213 if (isMC) {
214 TParticlePDG* particle1 = fPDG->GetParticle(((CbmMCTrack*) arr->UncheckedAt(iTrack))->GetPdgCode());
215 if (!particle1)
216 continue;
217
218 Double_t Q1 = particle1->Charge();
219 if (!(Q1 > 0))
220 continue;
221
222 if (FindFirstPointOnMCTrack(iTrack, track1, CheckSign(Q1)) == kBMNERROR)
223 continue;
224 } else
225 track1 = (BmnGlobalTrack*) arr->UncheckedAt(iTrack);
226
227 if (fIsCbmDst && track1->GetNHits() < 4)
228 continue;
229
230 Double_t _p1, _eta1;
231 if (!CheckTrack(track1, fPdgParticle1, _p1, _eta1))
232 continue;
233
234 for (Int_t jTrack = 0; jTrack < arr->GetEntriesFast(); jTrack++) {
235 if (iTrack == jTrack)
236 continue;
237
238 BmnGlobalTrack Track2;
239 BmnGlobalTrack* track2 = &Track2;
240
241 if (isMC) {
242 TParticlePDG* particle2 = fPDG->GetParticle(((CbmMCTrack*) arr->UncheckedAt(jTrack))->GetPdgCode());
243 if (!particle2)
244 continue;
245 Double_t Q2 = particle2->Charge();
246 if (!(Q2 < 0))
247 continue;
248
249 if (FindFirstPointOnMCTrack(jTrack, track2, CheckSign(Q2)) == kBMNERROR)
250 continue;
251 } else
252 track2 = (BmnGlobalTrack*) arr->UncheckedAt(jTrack);
253
254 if (fIsCbmDst && track2->GetNHits() < 4)
255 continue;
256
257 Double_t _p2, _eta2;
258 if (!CheckTrack(track2, fPdgParticle2, _p2, _eta2))
259 continue;
260
261 // Go to primary vertex Vp
262 Double_t Vpz = isMC ? fMcVertex.Z() : fEventVertex->GetZ();
263 FairTrackParam proton_Vp = KalmanTrackPropagation(track1, fPdgParticle1, Vpz);
264 FairTrackParam pion_Vp = KalmanTrackPropagation(track2, fPdgParticle2, Vpz);
265
266 Double_t V0Z = FindV0ByVirtualPlanes(track1, track2, .5 * (Vpz + fDetector->GetGemStation(0)->GetZPosition()));
267 if (V0Z < Vpz - 10. || V0Z > fDetector->GetGemStation(5)->GetZPosition()) // FIXME!
268 continue;
269
270 // Go to secondary vertex V0
271 // FairTrackParam proton_V0, pion_V0;
272 // vector <Double_t> geomTopology;
273 // Description of vector:
274 // DCA1 --> [0]
275 // DCA2 --> [1]
276 // DCA12 --> [2]
277
278 // Go to secondary vertex V0
279 FairTrackParam proton_V0, pion_V0;
280 proton_V0 = KalmanTrackPropagation(track1, fPdgParticle1, V0Z);
281 pion_V0 = KalmanTrackPropagation(track2, fPdgParticle2, V0Z);
282
283 Double_t V0X = .5 * (proton_V0.GetX() + pion_V0.GetX());
284 Double_t V0Y = .5 * (proton_V0.GetY() + pion_V0.GetY());
285
286 Double_t xCutMin = fDetector->GetStation(0)->GetXMinStation();
287 Double_t xCutMax = fDetector->GetStation(0)->GetXMaxStation();
288 Double_t yCutMin = fDetector->GetStation(0)->GetYMinStation();
289 Double_t yCutMax = fDetector->GetStation(0)->GetYMaxStation();
290
291 if (V0X < xCutMin || V0X > xCutMax || V0Y < yCutMin || V0Y > yCutMax)
292 continue;
293
294 vector <Double_t> geomTopology = GeomTopology(proton_V0, pion_V0, proton_Vp, pion_Vp);
295
296 BmnParticlePair partPair;
297
298 // trying to get tof info from tracks ...
299
300 enum {
301 tof400 = 1, tof700 = 2
302 };
303 partPair.SetBeta400Pair(track1->GetBeta(tof400), track2->GetBeta(tof400));
304 partPair.SetBeta700Pair(track1->GetBeta(tof700), track2->GetBeta(tof700));
305
306 partPair.SetV0Z(V0Z);
307 partPair.SetV0X(V0X);
308 partPair.SetV0Y(V0Y);
309
310 partPair.SetDCA1(geomTopology.at(0));
311 partPair.SetDCA2(geomTopology.at(1));
312 partPair.SetDCA12(geomTopology.at(2));
313
314 TVector3 V0(V0X, V0Y, V0Z);
315 TVector3 Vp;
316 Vp.SetX(isMC ? fMcVertex.X() : fEventVertex->GetX());
317 Vp.SetY(isMC ? fMcVertex.Y() : fEventVertex->GetY());
318 Vp.SetZ(isMC ? fMcVertex.Z() : fEventVertex->GetZ());
319 // TVector3 Vp(fEventVertex->GetX(), fEventVertex->GetY(), fEventVertex->GetZ());
320 Double_t path = TVector3(V0 - Vp).Mag();
321
322 partPair.SetPath(path);
323
324 partPair.SetMomPair(_p1, _p2);
325 partPair.SetEtaPair(_eta1, _eta2);
326
327 // partPair.SetNHitsPair(track1->GetNHits(), track2->GetNHits());
328
329 // Getting gem part of glob. track ...
330 Int_t gemIdx1 = track1->GetGemTrackIndex();
331 BmnTrack* gemTrack1 = (BmnTrack*) fGemTracks->UncheckedAt(gemIdx1);
332 Int_t nHitsGem1 = gemTrack1->GetNHits();
333
334 Int_t gemIdx2 = track2->GetGemTrackIndex();
335 BmnTrack* gemTrack2 = (BmnTrack*) fGemTracks->UncheckedAt(gemIdx2);
336 Int_t nHitsGem2 = gemTrack2->GetNHits();
337
338 // Getting sil. part of glob. track ...
339 Int_t nHitsSil1 = 0;
340 Int_t silIdx1 = track1->GetSilTrackIndex();
341 if (silIdx1 != -1) {
342 BmnTrack* silTrack1 = (BmnTrack*) fSiliconTracks->UncheckedAt(silIdx1);
343 nHitsSil1 = silTrack1->GetNHits();
344 }
345
346 Int_t nHitsSil2 = 0;
347 Int_t silIdx2 = track2->GetSilTrackIndex();
348 if (silIdx2 != -1) {
349 BmnTrack* silTrack2 = (BmnTrack*) fSiliconTracks->UncheckedAt(silIdx2);
350 nHitsSil2 = silTrack2->GetNHits();
351 }
352
353 vector <Int_t> particle1{nHitsSil1, nHitsGem1};
354 vector <Int_t> particle2{nHitsSil2, nHitsGem2};
355
356 partPair.SetNHitsPair(particle1, particle2);
357
358 // Skipping tracks having more than three silicon hits ...
359 if (partPair.GetNHitsPart1("SILICON") > 3 || partPair.GetNHitsPart2("SILICON") > 3) // FIXME
360 continue;
361
362 // Track params. are redefined
363 Double_t Tx1, Ty1, Tx2, Ty2, p1, p2;
364 Double_t A1, A2;
365
366 TVector2 armenPodol;
367
368 Tx1 = proton_V0.GetTx();
369 Ty1 = proton_V0.GetTy();
370 Tx2 = pion_V0.GetTx();
371 Ty2 = pion_V0.GetTy();
372 p1 = 1. / proton_V0.GetQp();
373 p2 = 1. / pion_V0.GetQp();
374
375 armenPodol = ArmenterosPodol(proton_V0, pion_V0);
376
377 A1 = 1. / Sqrt(Tx1 * Tx1 + Ty1 * Ty1 + 1);
378 lPos.SetXYZM(Tx1 * A1 * p1, Ty1 * A1 * p1, p1 * A1,
379 fPDG->GetParticle(fPdgParticle1)->Mass());
380
381 p2 *= -1.; // Since in the calculations pos. mom. values should be used
382
383 A2 = 1. / Sqrt(Tx2 * Tx2 + Ty2 * Ty2 + 1);
384 lNeg.SetXYZM(Tx2 * A2 * p2, Ty2 * A2 * p2, p2 * A2,
385 fPDG->GetParticle(fPdgParticle2)->Mass());
386
387 partPair.SetAlpha(armenPodol.X());
388 partPair.SetPtPodol(armenPodol.Y());
389 partPair.SetInvMass(TLorentzVector((lPos + lNeg)).Mag());
390
391 // Part to be used when estimating omega ... (dca0 needed), 0 means a primary particle to be decayed...
392 partPair.SetTxPair(Tx1, Tx2);
393 partPair.SetTyPair(Ty1, Ty2);
394
395 Double_t PzPart1 = Abs(p1) * A1;
396 Double_t PzPart2 = Abs(p2) * A2;
397
398 Double_t PzPart0 = PzPart1 + PzPart2;
399 Double_t PxPart0 = PzPart1 * Tx1 + PzPart2 * Tx2;
400 Double_t PyPart0 = PzPart1 * Ty1 + PzPart2 * Ty2;
401
402 Double_t TxPart0 = PxPart0 / PzPart0;
403 Double_t TyPart0 = PyPart0 / PzPart0;
404
405 Double_t xPart0 = TxPart0 * (Vp.Z() - V0.Z()) + V0.X();
406 Double_t yPart0 = TyPart0 * (Vp.Z() - V0.Z()) + V0.Y();
407
408 Double_t dca0 = Sqrt(Sq(xPart0 - Vp.X()) + Sq(yPart0 - Vp.Y()));
409
410 partPair.SetDCA0(dca0);
411
412 // To be used for real exp. data
413 if (fAnalType[0].Contains("dst") && !fAnalType[0].Contains("eve") && fAnalType[1].Contains("OFF"))
414 new((*fParticlePair)[fParticlePair->GetEntriesFast()]) BmnParticlePair(partPair);
415
416 // MC input, no matches
417 if (isMC && fAnalType[1].Contains("OFF")) {
418 partPair.SetMCTrackIdPart1(iTrack);
419 partPair.SetMCTrackIdPart2(jTrack);
420
421 new((*fParticlePair_MC)[fParticlePair_MC->GetEntriesFast()]) BmnParticlePair(partPair);
422 }
423
424 // Reco input with matches
425 if (fAnalType[1].Contains("ON")) {
426 partPair.SetMCTrackIdPart1(recoToMcIdx(iTrack));
427 partPair.SetMCTrackIdPart2(recoToMcIdx(jTrack));
428
429 partPair.SetRecoTrackIdPart1(iTrack);
430 partPair.SetRecoTrackIdPart2(jTrack);
431
432 new((*fParticlePair_RECO)[fParticlePair_RECO->GetEntriesFast()]) BmnParticlePair(partPair);
433 }
434 }
435 }
436}
437// -------------------------------------------------------------------
438
440 cout << "\nBmnTwoParticleDecay::Init()" << endl;
441
442 FairRootManager* ioman = FairRootManager::Instance();
443 TString inFile = (TString) ioman->GetInFile()->GetName();
444
445 if (inFile.Contains("cbm"))
446 fIsCbmDst = kTRUE;
447
448 if (fIsCbmDst) {
449
450 if (fGeomFile.IsNull())
451 Fatal("BmnTwoParticleDecay::Init()", "No geometry file passed!!!");
452 else
453 TGeoManager::Import(fGeomFile.Data());
454 } else {
455 // Read current geometry from database
456 Char_t* geoFileName = (Char_t*) "current_geo_file.root";
457 Int_t res_code = UniRun::ReadGeometryFile(fRunPeriod, fRunId, geoFileName);
458 if (res_code != 0) {
459 cout << "Geometry file can't be read from the database" << endl;
460 exit(-1);
461 }
462 TGeoManager::Import(geoFileName);
463 }
464
465 // Get run info..
466 UniRun* runInfo = UniRun::GetRun(fRunPeriod, fRunId);
467 if (!runInfo) {
468 cout << "Something is wrong when getting run info from DB..." << endl;
469 throw;
470 }
471
472 fBranchGemPoints = "StsPoint";
473 fBranchSilPoints = "SiliconPoint";
474 fBranchGlobalTracks = "BmnGlobalTrack";
475 fBranchMCTracks = "MCTrack";
476 fBranchGlobalMatch = "BmnGlobalTrackMatch";
477 fBranchVertex = "BmnVertex";
478
479 fDstHeader = (DstEventHeader*) ioman->GetObject("DstEventHeader.");
480
481 fGemPoints = (TClonesArray*) ioman->GetObject(fBranchGemPoints.Data());
482 fSilPoints = (TClonesArray*) ioman->GetObject(fBranchSilPoints.Data());
483
484 fGlobalTracks = (TClonesArray*) ioman->GetObject(fBranchGlobalTracks.Data());
485 fGemTracks = (TClonesArray*) ioman->GetObject("BmnGemTrack");
486 fSiliconTracks = (TClonesArray*) ioman->GetObject("BmnSiliconTrack");
487 fSilHits = (TClonesArray*) ioman->GetObject("BmnSiliconHit");
488
489 fMCTracks = (TClonesArray*) ioman->GetObject(fBranchMCTracks.Data());
490 fGlobalMatches = (TClonesArray*) ioman->GetObject(fBranchGlobalMatch.Data());
491 fVertex = (TClonesArray*) ioman->GetObject(fBranchVertex.Data());
492
493 TString dataSet = (fMCTracks && fGlobalTracks) ? "eve + dst" :
494 (fMCTracks && !fGlobalTracks) ? "eve" :
495 (!fMCTracks && fGlobalTracks) ? "dst" : "";
496
497 TString isMatching = fGlobalMatches ? "matchON" : "matchOFF";
498
499 fAnalType.push_back(dataSet);
500 fAnalType.push_back(isMatching);
501
502 // Particle pair branch for all data types
503 const Char_t* className = "BmnParticlePair";
504
505 Bool_t isWriteEveBranch = (dataSet.Contains("eve") && isMatching.Contains("OFF")) ? kTRUE : kFALSE;
506 Bool_t isWriteDstBranch = (dataSet.Contains("dst") && isMatching.Contains("ON")) ? kTRUE : kFALSE;
507 Bool_t isWriteBranch = (dataSet.Contains("dst") && isMatching.Contains("OFF")) ? kTRUE : kFALSE; // exp. data or dst without matches
508
509 fParticlePair_MC = new TClonesArray(className);
510 ioman->Register("ParticlePair_MC", "Lambda", fParticlePair_MC, isWriteEveBranch);
511
512 fParticlePair_RECO = new TClonesArray(className);
513 ioman->Register("ParticlePair_RECO", "Lambda", fParticlePair_RECO, isWriteDstBranch);
514
515 fParticlePair = new TClonesArray(className);
516 ioman->Register("ParticlePair", "Lambda", fParticlePair, isWriteBranch);
517
518 // Adding extended event header to output ....
519 fPhysInfo = new DstEventHeaderExtended();
520 ioman->Register("DstEventHeaderExtended.", "Lambda", fPhysInfo, isWriteBranch);
521
522 fPDG = TDatabasePDG::Instance();
523
524 fMagField = new BmnNewFieldMap("field_sp41v4_ascii_Extrap.root");
525 fMagField->SetScale(!fAnalType[0].Contains("eve") ? *runInfo->GetFieldVoltage() / 55.87 : 1.33); // FIXME
526 fMagField->Init();
527
528 FairRunAna::Instance()->SetField(fMagField);
529 fField = FairRunAna::Instance()->GetField();
530 fKalman = new BmnKalmanFilter();
531
532 fPdgParticle1 = fPDG1;
533 fPdgParticle2 = fPDG2;
534 cout << "PDG, particle1 = " << fPdgParticle1 << endl;
535 cout << "PDG, particle2 = " << fPdgParticle2 << endl;
536
537 // Possible two-particle decays are listed here (lambda0, K0-short):
538 fPDGDecay = (fPDG1 == 2212 && fPDG2 == -211) ? 3122 :
539 (fPDG1 == 211 && fPDG2 == -211) ? 310 : -1;
540
541 // Let's look whether a digi file exists to be connected to anal ...
542 if (!fDigiDir.IsNull()) {
543
544 Bool_t isEoS = (fDigiDir.Contains("/eos")) ? kTRUE : kFALSE;
545
546 TString f = (isEoS ? fEoSNode : "") + fDigiDir + TString::Format("bmn_run%d_digi.root", fRunId);
547
548 cout << f<< endl;
549
550 TChain* ch = new TChain("bmndata");
551 ch->Add(f.Data());
552
553 BmnEventHeader* eHeader = nullptr;
554 TClonesArray* trigFD = nullptr;
555 TClonesArray* trigBD = nullptr;
556
557 ch->SetBranchAddress("BmnEventHeader.", &eHeader);
558 ch->SetBranchAddress("BD", &trigBD);
559 ch->SetBranchAddress("SI", &trigFD);
560
561 for (Int_t iEvent = 0; iEvent < ch->GetEntries(); iEvent++) {
562 ch->GetEntry(iEvent);
563
564 if (iEvent % 10000 == 0)
565 cout << "digiFile#, processing event: " << iEvent << endl;
566
567 fTrigCountMap[eHeader->GetEventId()] = make_pair(trigBD->GetEntriesFast(), trigFD->GetEntriesFast());
568 }
569
570 delete ch;
571 }
572
573 return kSUCCESS;
574}
575
576// -------------------------------------------------------------------
577
578void BmnTwoParticleDecay::Exec(Option_t * option) {
579 fParticlePair_MC->Delete();
580 fParticlePair_RECO->Delete();
581 fParticlePair->Delete();
582
583 UInt_t id = fDstHeader->GetEventId();
584 fPhysInfo->SetEventId(id);
585 fPhysInfo->SetRunId(fDstHeader->GetRunId());
586
587 if (!fDigiDir.IsNull()) {
588 pair <Int_t, Int_t> trigPair = fTrigCountMap.find(id)->second;
589 fPhysInfo->SetBd(trigPair.first);
590 fPhysInfo->SetFd(trigPair.second);
591 }
592
593 fEventCounter++;
594
595 if (fEventCounter % 500 == 0)
596 cout << "Event# " << fEventCounter << endl;
597
598 // In case of MC-data one has to extract coordinates of Vp known exactly ...
599 if (fAnalType[0].Contains("eve") && !fAnalType[0].Contains("dst")) {
600 for (Int_t iTrack = 0; iTrack < fMCTracks->GetEntriesFast(); iTrack++) {
601 CbmMCTrack* mcTrack = (CbmMCTrack*) fMCTracks->UncheckedAt(iTrack);
602 if (mcTrack->GetMotherId() != -1)
603 continue;
604 fMcVertex.SetXYZ(mcTrack->GetStartX(), mcTrack->GetStartY(), mcTrack->GetStartZ());
605 break;
606 }
607 }// Real data ..
608 else {
609 fEventVertex = (BmnVertex*) fVertex->UncheckedAt(0);
610 fPhysInfo->SetVp(fEventVertex->GetX(), fEventVertex->GetY(), fEventVertex->GetZ());
611 fPhysInfo->SetNTracks(fEventVertex->GetNTracks());
612
613 if (fEventVertex->GetNTracks() < 2) // Num of tracks to be used for Vp reconstruction
614 return;
615
616 TVector3 realVert(fEventVertex->GetX(), fEventVertex->GetY(), fEventVertex->GetZ());
617 TVector3 roughVert(0., 0., 0.);
618
619 const Double_t vertexCut = 100.; // Difference between reconstructed Vp and its approximate position
620
621 for (Int_t iProj = 0; iProj < 3; iProj++)
622 if (Abs(TVector3(roughVert - realVert)[iProj]) > vertexCut)
623 return;
624 }
625 Analysis();
626}
627// -------------------------------------------------------------------
628
630 delete fKalman;
631 delete fMagField;
632 cout << "\n-I- [BmnTwoParticleDecay::Finish] " << endl;
633}
634
635TVector2 BmnTwoParticleDecay::ArmenterosPodol(FairTrackParam prot, FairTrackParam pion) {
636 Double_t mom1 = 1. / prot.GetQp();
637 Double_t Tx1 = prot.GetTx();
638 Double_t Ty1 = prot.GetTy();
639
640 Double_t mom1sq = mom1 * mom1;
641 Double_t Pz1 = Abs(mom1) / Sqrt(Tx1 * Tx1 + Ty1 * Ty1 + 1);
642 Double_t Px1 = Pz1 * Tx1;
643 Double_t Py1 = Pz1 * Ty1;
644
645 Double_t mom2 = 1. / pion.GetQp();
646 Double_t Tx2 = pion.GetTx();
647 Double_t Ty2 = pion.GetTy();
648
649 Double_t mom2sq = mom2 * mom2;
650 Double_t Pz2 = Abs(mom2) / Sqrt(Tx2 * Tx2 + Ty2 * Ty2 + 1);
651 Double_t Px2 = Pz2 * Tx2;
652 Double_t Py2 = Pz2 * Ty2;
653
654 Double_t momHyp2 = (Px1 + Px2) * (Px1 + Px2) + (Py1 + Py2) * (Py1 + Py2) + (Pz1 + Pz2) * (Pz1 + Pz2);
655 Double_t momHyp = Sqrt(momHyp2);
656 Double_t oneOver2MomHyp = 1 / (2 * momHyp);
657 Double_t L1 = (momHyp2 + mom1sq - mom2sq) * oneOver2MomHyp;
658 Double_t L2 = (momHyp2 + mom2sq - mom1sq) * oneOver2MomHyp;
659 Double_t alpha = (L1 - L2) / (L1 + L2);
660 Double_t Pt = Sqrt((mom1sq + mom2sq + momHyp2) * (mom1sq + mom2sq + momHyp2) - 2 * (mom1sq * mom1sq + mom2sq * mom2sq + momHyp2 * momHyp2)) * oneOver2MomHyp;
661
662 return TVector2(alpha, Pt);
663}
664
665Double_t BmnTwoParticleDecay::FindV0ByVirtualPlanes(BmnGlobalTrack* track1, BmnGlobalTrack* track2, Double_t z_0, Double_t range) {
666 const Int_t nPlanes = 10; // FIXME
667
668 Bool_t isBadPair = kFALSE;
669
670 while (range >= 0.1) {
671 Double_t zMax = z_0 + range;
672 Double_t zMin = z_0 - range;
673 Double_t zStep = (zMax - zMin) / nPlanes;
674
675 Double_t zPlane[nPlanes];
676 Double_t Dist[nPlanes];
677
678 FairTrackParam par1 = *(track1->GetParamFirst());
679 FairTrackParam par2 = *(track2->GetParamFirst());
680
681 for (Int_t iPlane = 0; iPlane < nPlanes; ++iPlane) {
682 zPlane[iPlane] = zMax - iPlane * zStep;
683 BmnStatus stat1 = fKalman->TGeoTrackPropagate(&par1, zPlane[iPlane], fPdgParticle1, nullptr, nullptr, kTRUE);
684 BmnStatus stat2 = fKalman->TGeoTrackPropagate(&par2, zPlane[iPlane], fPdgParticle2, nullptr, nullptr, kTRUE);
685
686 if (stat1 == kBMNERROR || stat2 == kBMNERROR) {
687 isBadPair = kTRUE;
688 break;
689 }
690
691 Dist[iPlane] = Sqrt(Sq(par1.GetX() - par2.GetX()) + Sq(par1.GetY() - par2.GetY()));
692 }
693
694 if (isBadPair)
695 return DBL_MAX;
696
697 TGraph V0(nPlanes, zPlane, Dist);
698 V0.Fit("pol2", "QF");
699 TF1 *fit_func = V0.GetFunction("pol2");
700 Double_t a = fit_func->GetParameter(2);
701
702 if (a < 0.) {
703 isBadPair = kTRUE;
704 break;
705 }
706
707 map <Double_t, Double_t> dist_zPlanes; // distance --> z-position
708
709 for (Int_t iPlane = 0; iPlane < nPlanes; iPlane++)
710 dist_zPlanes[Dist[iPlane]] = zPlane[iPlane];
711
712 z_0 = dist_zPlanes.begin()->second;
713
714 range /= 2;
715 }
716
717 if (!isBadPair)
718 return z_0;
719 else
720 return DBL_MAX;
721}
Bool_t IsParCorrect(const FairTrackParam *par, const Bool_t isField)
Definition BmnMath.cxx:59
Float_t Dist(Float_t x1, Float_t y1, Float_t x2, Float_t y2)
Definition BmnMath.cxx:432
float f
Definition P4_F32vec4.h:21
BmnStatus
Definition BmnEnums.h:24
@ kBMNERROR
Definition BmnEnums.h:26
@ kBMNSUCCESS
Definition BmnEnums.h:25
UInt_t GetEventId()
void SetScale(Double_t factor)
Definition BmnFieldMap.h:55
virtual void Init()
BmnGemStripStation * GetStation(Int_t station_num)
BmnGemStripStation * GetGemStation(Int_t station_num)
Int_t GetGemTrackIndex() const
Double_t GetBeta(Int_t tofID) const
Int_t GetSilTrackIndex() const
BmnStatus TGeoTrackPropagate(FairTrackParam *par, Double_t zOut, Int_t pdg, vector< Double_t > *F, Double_t *length, Bool_t isField)
void SetMCTrackIdPart2(Int_t id)
Int_t GetNHitsPart1(TString det="")
void SetAlpha(Double_t val)
void SetBeta700Pair(Double_t val1, Double_t val2)
void SetDCA2(Double_t val)
void SetTxPair(Double_t val1, Double_t val2)
void SetPtPodol(Double_t val)
Int_t GetNHitsPart2(TString det="")
void SetBeta400Pair(Double_t val1, Double_t val2)
void SetRecoTrackIdPart2(Int_t id)
void SetNHitsPair(vector< Int_t > part1, vector< Int_t > part2)
void SetTyPair(Double_t val1, Double_t val2)
void SetInvMass(Double_t val)
void SetV0Y(Double_t val)
void SetV0Z(Double_t val)
void SetDCA1(Double_t val)
void SetDCA12(Double_t val)
void SetMomPair(Double_t val1, Double_t val2)
void SetMCTrackIdPart1(Int_t id)
void SetRecoTrackIdPart1(Int_t id)
void SetDCA0(Double_t val)
void SetEtaPair(Double_t val1, Double_t val2)
void SetPath(Double_t val)
void SetV0X(Double_t val)
Double_t GetZIn() const
FairTrackParam * GetParamFirst()
Definition BmnTrack.h:72
Int_t GetNHits() const
Definition BmnTrack.h:44
void SetParamFirst(FairTrackParam &par)
Definition BmnTrack.h:85
virtual void Exec(Option_t *option)
virtual InitStatus Init()
Int_t GetNTracks() const
Definition BmnVertex.h:54
Double_t GetX() const
Definition BmnVertex.h:49
Double_t GetZ() const
Definition BmnVertex.h:51
Double_t GetY() const
Definition BmnVertex.h:50
Double_t GetStartZ() const
Definition CbmMCTrack.h:63
Double_t GetStartY() const
Definition CbmMCTrack.h:62
Int_t GetMotherId() const
Definition CbmMCTrack.h:57
Double_t GetStartX() const
Definition CbmMCTrack.h:61
Double_t GetZIn() const
Definition CbmStsPoint.h:71
void SetVp(Double_t x, Double_t y, Double_t z)
void SetEventId(UInt_t event_id)
UInt_t GetEventId()
static UniRun * GetRun(int period_number, int run_number)
get run from the database
Definition UniRun.cxx:177
static int ReadGeometryFile(int period_number, int run_number, char *geo_file_path, bool usePrevGeometryIfMissing=false)
Definition UniRun.cxx:1105
double * GetFieldVoltage()
get field voltage of the current run
Definition UniRun.h:125
#define L1