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