13#include <TGeoManager.h>
14#include <Fit/FitResult.h>
20 fGlobalMatches(nullptr),
25 fParticlePair(nullptr),
26 fParticlePair_MC(nullptr),
27 fParticlePair_RECO(nullptr),
35 fEoSNode(
"root://ncm.jinr.ru/"),
39 fMcVertex.SetXYZ(0., 0., 0.);
42 if (
config == BmnGemStripConfiguration::GEM_CONFIG::RunSpring2018)
45 else if (
config == BmnGemStripConfiguration::GEM_CONFIG::RunSpring2017)
49 cout <<
"BmnGemStripConfiguration not defined !!!" << endl;
55 TString gPathGemConfig = gSystem->Getenv(
"VMCWORKDIR");
56 gPathGemConfig +=
"/parameters/gem/XMLConfigs/";
61 cout <<
" Current Configuration : RunSpring2017" <<
"\n";
66 cout <<
" Current Configuration : RunSpring2018" <<
"\n";
71 cout <<
" Current Configuration : RunSpring2018" <<
"\n";
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.;
84 Bool_t isMC = fAnalType[0].Contains(
"eve") && !fAnalType[0].Contains(
"dst");
91 X = fEventVertex->
GetX();
92 Y = fEventVertex->
GetY();
93 Z = fEventVertex->
GetZ();
97 TVector3 protonV0(proton_V0.GetX(), proton_V0.GetY(), proton_V0.GetZ());
99 TVector3 pionV0(pion_V0.GetX(), pion_V0.GetY(), pion_V0.GetZ());
102 TVector3 protonVp(proton_Vp.GetX(), proton_Vp.GetY(), proton_Vp.GetZ());
104 TVector3 pionVp(pion_Vp.GetX(), pion_Vp.GetY(), pion_Vp.GetZ());
108 Double_t protonVpVp = TVector3(protonVp - Vp).Mag();
111 Double_t pionVpVp = TVector3(pionVp - Vp).Mag();
114 Double_t protonV0PionV0 = TVector3(protonV0 - pionV0).Mag();
119 vector <Double_t> cuts;
120 cuts.push_back(protonVpVp);
121 cuts.push_back(pionVpVp);
122 cuts.push_back(protonV0PionV0);
128FairTrackParam BmnTwoParticleDecay::KalmanTrackPropagation(
BmnGlobalTrack* track, Int_t pdg, Double_t Z) {
136 FairTrackParam param;
137 map <Double_t, FairMCPoint*> firstPoint;
139 for (Int_t iPoint = 0; iPoint < fSilPoints->GetEntriesFast(); iPoint++) {
141 Int_t TrackID = silPoint->GetTrackID();
143 if (TrackID != iTrack)
146 firstPoint[silPoint->
GetZIn()] = silPoint;
149 FairMCPoint* point =
nullptr;
150 if (firstPoint.size() == 0)
151 for (Int_t iPoint = 0; iPoint < fGemPoints->GetEntriesFast(); iPoint++) {
153 Int_t TrackID = gemPoint->GetTrackID();
155 if (TrackID != iTrack)
158 firstPoint[gemPoint->
GetZIn()] = gemPoint;
161 point = firstPoint.begin()->second;
166 Double_t Px = point->GetPx();
167 Double_t Py = point->GetPy();
168 Double_t Pz = point->GetPz();
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());
185Bool_t BmnTwoParticleDecay::CheckTrack(
BmnGlobalTrack* track, Int_t pdgCode, Double_t& mom, Double_t& eta) {
190 Double_t Pz = Abs(p) / Sqrt(1 + Tx * Tx + Ty * Ty);
192 Int_t sign = CheckSign(fPDG->GetParticle(pdgCode)->Charge());
195 eta = 0.5 * Log((Abs(p) + Pz) / (Abs(p) - Pz));
203void BmnTwoParticleDecay::Analysis() {
204 TLorentzVector lPos, lNeg;
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");
209 for (Int_t iTrack = 0; iTrack < arr->GetEntriesFast(); iTrack++) {
214 TParticlePDG* particle1 = fPDG->GetParticle(((
CbmMCTrack*) arr->UncheckedAt(iTrack))->GetPdgCode());
218 Double_t Q1 = particle1->Charge();
222 if (FindFirstPointOnMCTrack(iTrack, track1, CheckSign(Q1)) ==
kBMNERROR)
227 if (fIsCbmDst && track1->
GetNHits() < 4)
231 if (!CheckTrack(track1, fPdgParticle1, _p1, _eta1))
234 for (Int_t jTrack = 0; jTrack < arr->GetEntriesFast(); jTrack++) {
235 if (iTrack == jTrack)
242 TParticlePDG* particle2 = fPDG->GetParticle(((
CbmMCTrack*) arr->UncheckedAt(jTrack))->GetPdgCode());
245 Double_t Q2 = particle2->Charge();
249 if (FindFirstPointOnMCTrack(jTrack, track2, CheckSign(Q2)) ==
kBMNERROR)
254 if (fIsCbmDst && track2->
GetNHits() < 4)
258 if (!CheckTrack(track2, fPdgParticle2, _p2, _eta2))
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);
279 FairTrackParam proton_V0, pion_V0;
280 proton_V0 = KalmanTrackPropagation(track1, fPdgParticle1, V0Z);
281 pion_V0 = KalmanTrackPropagation(track2, fPdgParticle2, V0Z);
283 Double_t V0X = .5 * (proton_V0.GetX() + pion_V0.GetX());
284 Double_t V0Y = .5 * (proton_V0.GetY() + pion_V0.GetY());
291 if (V0X < xCutMin || V0X > xCutMax || V0Y < yCutMin || V0Y > yCutMax)
294 vector <Double_t> geomTopology = GeomTopology(proton_V0, pion_V0, proton_Vp, pion_Vp);
301 tof400 = 1, tof700 = 2
310 partPair.
SetDCA1(geomTopology.at(0));
311 partPair.
SetDCA2(geomTopology.at(1));
312 partPair.
SetDCA12(geomTopology.at(2));
314 TVector3 V0(V0X, V0Y, V0Z);
316 Vp.SetX(isMC ? fMcVertex.X() : fEventVertex->GetX());
317 Vp.SetY(isMC ? fMcVertex.Y() : fEventVertex->GetY());
318 Vp.SetZ(isMC ? fMcVertex.Z() : fEventVertex->GetZ());
320 Double_t path = TVector3(V0 - Vp).Mag();
332 Int_t nHitsGem1 = gemTrack1->
GetNHits();
336 Int_t nHitsGem2 = gemTrack2->
GetNHits();
353 vector <Int_t> particle1{nHitsSil1, nHitsGem1};
354 vector <Int_t> particle2{nHitsSil2, nHitsGem2};
363 Double_t Tx1, Ty1, Tx2, Ty2, p1, p2;
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();
375 armenPodol = ArmenterosPodol(proton_V0, pion_V0);
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());
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());
389 partPair.
SetInvMass(TLorentzVector((lPos + lNeg)).Mag());
395 Double_t PzPart1 = Abs(p1) * A1;
396 Double_t PzPart2 = Abs(p2) * A2;
398 Double_t PzPart0 = PzPart1 + PzPart2;
399 Double_t PxPart0 = PzPart1 * Tx1 + PzPart2 * Tx2;
400 Double_t PyPart0 = PzPart1 * Ty1 + PzPart2 * Ty2;
402 Double_t TxPart0 = PxPart0 / PzPart0;
403 Double_t TyPart0 = PyPart0 / PzPart0;
405 Double_t xPart0 = TxPart0 * (Vp.Z() - V0.Z()) + V0.X();
406 Double_t yPart0 = TyPart0 * (Vp.Z() - V0.Z()) + V0.Y();
408 Double_t dca0 = Sqrt(Sq(xPart0 - Vp.X()) + Sq(yPart0 - Vp.Y()));
413 if (fAnalType[0].Contains(
"dst") && !fAnalType[0].Contains(
"eve") && fAnalType[1].Contains(
"OFF"))
414 new((*fParticlePair)[fParticlePair->GetEntriesFast()])
BmnParticlePair(partPair);
417 if (isMC && fAnalType[1].Contains(
"OFF")) {
421 new((*fParticlePair_MC)[fParticlePair_MC->GetEntriesFast()])
BmnParticlePair(partPair);
425 if (fAnalType[1].Contains(
"ON")) {
432 new((*fParticlePair_RECO)[fParticlePair_RECO->GetEntriesFast()])
BmnParticlePair(partPair);
440 cout <<
"\nBmnTwoParticleDecay::Init()" << endl;
442 FairRootManager* ioman = FairRootManager::Instance();
443 TString inFile = (TString) ioman->GetInFile()->GetName();
445 if (inFile.Contains(
"cbm"))
450 if (fGeomFile.IsNull())
451 Fatal(
"BmnTwoParticleDecay::Init()",
"No geometry file passed!!!");
453 TGeoManager::Import(fGeomFile.Data());
456 Char_t* geoFileName = (Char_t*)
"current_geo_file.root";
459 cout <<
"Geometry file can't be read from the database" << endl;
462 TGeoManager::Import(geoFileName);
468 cout <<
"Something is wrong when getting run info from DB..." << endl;
472 fBranchGemPoints =
"StsPoint";
473 fBranchSilPoints =
"SiliconPoint";
474 fBranchGlobalTracks =
"BmnGlobalTrack";
475 fBranchMCTracks =
"MCTrack";
476 fBranchGlobalMatch =
"BmnGlobalTrackMatch";
477 fBranchVertex =
"BmnVertex";
479 fDstHeader = (
DstEventHeader*) ioman->GetObject(
"DstEventHeader.");
481 fGemPoints = (TClonesArray*) ioman->GetObject(fBranchGemPoints.Data());
482 fSilPoints = (TClonesArray*) ioman->GetObject(fBranchSilPoints.Data());
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");
489 fMCTracks = (TClonesArray*) ioman->GetObject(fBranchMCTracks.Data());
490 fGlobalMatches = (TClonesArray*) ioman->GetObject(fBranchGlobalMatch.Data());
491 fVertex = (TClonesArray*) ioman->GetObject(fBranchVertex.Data());
493 TString dataSet = (fMCTracks && fGlobalTracks) ?
"eve + dst" :
494 (fMCTracks && !fGlobalTracks) ?
"eve" :
495 (!fMCTracks && fGlobalTracks) ?
"dst" :
"";
497 TString isMatching = fGlobalMatches ?
"matchON" :
"matchOFF";
499 fAnalType.push_back(dataSet);
500 fAnalType.push_back(isMatching);
503 const Char_t* className =
"BmnParticlePair";
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;
509 fParticlePair_MC =
new TClonesArray(className);
510 ioman->Register(
"ParticlePair_MC",
"Lambda", fParticlePair_MC, isWriteEveBranch);
512 fParticlePair_RECO =
new TClonesArray(className);
513 ioman->Register(
"ParticlePair_RECO",
"Lambda", fParticlePair_RECO, isWriteDstBranch);
515 fParticlePair =
new TClonesArray(className);
516 ioman->Register(
"ParticlePair",
"Lambda", fParticlePair, isWriteBranch);
520 ioman->Register(
"DstEventHeaderExtended.",
"Lambda", fPhysInfo, isWriteBranch);
522 fPDG = TDatabasePDG::Instance();
528 FairRunAna::Instance()->SetField(fMagField);
529 fField = FairRunAna::Instance()->GetField();
532 fPdgParticle1 = fPDG1;
533 fPdgParticle2 = fPDG2;
534 cout <<
"PDG, particle1 = " << fPdgParticle1 << endl;
535 cout <<
"PDG, particle2 = " << fPdgParticle2 << endl;
538 fPDGDecay = (fPDG1 == 2212 && fPDG2 == -211) ? 3122 :
539 (fPDG1 == 211 && fPDG2 == -211) ? 310 : -1;
542 if (!fDigiDir.IsNull()) {
544 Bool_t isEoS = (fDigiDir.Contains(
"/eos")) ? kTRUE : kFALSE;
546 TString
f = (isEoS ? fEoSNode :
"") + fDigiDir + TString::Format(
"bmn_run%d_digi.root", fRunId);
550 TChain* ch =
new TChain(
"bmndata");
554 TClonesArray* trigFD =
nullptr;
555 TClonesArray* trigBD =
nullptr;
557 ch->SetBranchAddress(
"BmnEventHeader.", &eHeader);
558 ch->SetBranchAddress(
"BD", &trigBD);
559 ch->SetBranchAddress(
"SI", &trigFD);
561 for (Int_t iEvent = 0; iEvent < ch->GetEntries(); iEvent++) {
562 ch->GetEntry(iEvent);
564 if (iEvent % 10000 == 0)
565 cout <<
"digiFile#, processing event: " << iEvent << endl;
567 fTrigCountMap[eHeader->
GetEventId()] = make_pair(trigBD->GetEntriesFast(), trigFD->GetEntriesFast());
579 fParticlePair_MC->Delete();
580 fParticlePair_RECO->Delete();
581 fParticlePair->Delete();
585 fPhysInfo->SetRunId(fDstHeader->GetRunId());
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);
595 if (fEventCounter % 500 == 0)
596 cout <<
"Event# " << fEventCounter << endl;
599 if (fAnalType[0].Contains(
"eve") && !fAnalType[0].Contains(
"dst")) {
600 for (Int_t iTrack = 0; iTrack < fMCTracks->GetEntriesFast(); iTrack++) {
609 fEventVertex = (
BmnVertex*) fVertex->UncheckedAt(0);
610 fPhysInfo->
SetVp(fEventVertex->
GetX(), fEventVertex->
GetY(), fEventVertex->
GetZ());
616 TVector3 realVert(fEventVertex->
GetX(), fEventVertex->
GetY(), fEventVertex->
GetZ());
617 TVector3 roughVert(0., 0., 0.);
619 const Double_t vertexCut = 100.;
621 for (Int_t iProj = 0; iProj < 3; iProj++)
622 if (Abs(TVector3(roughVert - realVert)[iProj]) > vertexCut)
632 cout <<
"\n-I- [BmnTwoParticleDecay::Finish] " << endl;
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();
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;
645 Double_t mom2 = 1. / pion.GetQp();
646 Double_t Tx2 = pion.GetTx();
647 Double_t Ty2 = pion.GetTy();
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;
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;
662 return TVector2(alpha, Pt);
666 const Int_t nPlanes = 10;
668 Bool_t isBadPair = kFALSE;
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;
675 Double_t zPlane[nPlanes];
676 Double_t
Dist[nPlanes];
681 for (Int_t iPlane = 0; iPlane < nPlanes; ++iPlane) {
682 zPlane[iPlane] = zMax - iPlane * zStep;
691 Dist[iPlane] = Sqrt(Sq(par1.GetX() - par2.GetX()) + Sq(par1.GetY() - par2.GetY()));
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);
707 map <Double_t, Double_t> dist_zPlanes;
709 for (Int_t iPlane = 0; iPlane < nPlanes; iPlane++)
710 dist_zPlanes[
Dist[iPlane]] = zPlane[iPlane];
712 z_0 = dist_zPlanes.begin()->second;
Bool_t IsParCorrect(const FairTrackParam *par, const Bool_t isField)
Float_t Dist(Float_t x1, Float_t y1, Float_t x2, Float_t y2)
void SetScale(Double_t factor)
BmnGemStripStation * GetStation(Int_t station_num)
BmnGemStripStation * GetGemStation(Int_t station_num)
Double_t GetXMaxStation()
Double_t GetYMinStation()
Double_t GetXMinStation()
Double_t GetYMaxStation()
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)
FairTrackParam * GetParamFirst()
void SetParamFirst(FairTrackParam &par)
virtual void Exec(Option_t *option)
virtual InitStatus Init()
virtual ~BmnTwoParticleDecay()
Double_t GetStartZ() const
Double_t GetStartY() const
Int_t GetMotherId() const
Double_t GetStartX() const
static UniRun * GetRun(int period_number, int run_number)
get run from the database
static int ReadGeometryFile(int period_number, int run_number, char *geo_file_path, bool usePrevGeometryIfMissing=false)
double * GetFieldVoltage()
get field voltage of the current run