25#include "FairRootManager.h"
27#include "TDatabasePDG.h"
29#include "KFParticleTopoReconstructor.h"
30#include "KFTopoPerformance.h"
33#define M2E 2.6112004954086e-7
39 : fKFMcParticles(NULL)
42 , fStsTrackMatches(NULL)
44 , fKFparticleFinderQA(NULL)
49 , particlecounter_2daughters(0)
50 , particlecounter_3daughters(0)
51 , particlecounter_4daughters(0)
52 , particlecounter_all(0)
53 , fhPi0_NDaughters(NULL)
54 , fNofGeneratedPi0_allEvents(0)
55 , fNofPi0_kfparticle_allEvents(0)
57 , fNofPi0_kfparticle(0)
62 , fHistoList_kfparticle()
67 , fhInvMassPi0WithFullReco(NULL)
68 , fhInvMass2Gammas(NULL)
69 , fhInvMass2Gammas_cut(NULL)
70 , fhKF_particlevector(NULL)
71 , fhKF_trackvector(NULL)
73 , fhKF_NofPi0_signal(NULL)
74 , fhKF_NofPi0_trackvector(NULL)
76 , fhKF_invmass_fullReco(NULL)
87 FairRootManager* ioman = FairRootManager::Instance();
88 if (NULL == ioman) { Fatal(
"CbmAnaConversionKF::Init",
"RootManager not instantised!"); }
90 fKFMcParticles = (TClonesArray*) ioman->GetObject(
"KFMCParticles");
91 if (NULL ==
fKFMcParticles) { Fatal(
"CbmAnaConversionKF::Init",
"No KFMCParticles array!"); }
93 fMcTracks = (TClonesArray*) ioman->GetObject(
"MCTrack");
94 if (NULL ==
fMcTracks) { Fatal(
"CbmAnaConversionKF::Init",
"No MCTrack array!"); }
96 fStsTracks = (TClonesArray*) ioman->GetObject(
"StsTrack");
97 if (NULL ==
fStsTracks) { Fatal(
"CbmAnaConversionKF::Init",
"No StsTrack array!"); }
100 if (NULL ==
fStsTrackMatches) { Fatal(
"CbmAnaConversionKF::Init",
"No StsTrackMatch array!"); }
117 fhPi0_NDaughters =
new TH1D(
"fhPi0_NDaughters",
"fhPi0_NDaughters;number of daughers;#", 4, 0.5, 4.5);
118 fhPi0Ratio =
new TH1D(
"fhPi0Ratio",
"fhPi0Ratio; ratio;#", 1000, 0., 0.02);
119 fhPi0_mass =
new TH1D(
"fhPi0_mass",
"fhPi0_mass;mass;#", 500, 0., 0.5);
127 fhInvMass2Gammas =
new TH1D(
"fhInvMass2Gammas",
"fhInvMass2Gammas;invmass;#", 400, 0., 2.);
129 fhInvMass2Gammas_cut =
new TH1D(
"fhInvMass2Gammas_cut",
"fhInvMass2Gammas_cut;invmass;#", 400, 0., 2.);
132 fhKF_particlevector =
new TH1D(
"fhKF_particlevector",
"fhKF_particlevector;;#", 10, 0., 10.);
137 fhKF_trackvector =
new TH1D(
"fhKF_trackvector",
"fhKF_trackvector;;#", 10, 0., 10.);
143 fhKF_NofPi0 =
new TH1D(
"fhKF_NofPi0",
"fhKF_NofPi0;nof;#", 10, -0.5, 9.5);
145 fhKF_NofPi0_signal =
new TH1D(
"fhKF_NofPi0_signal",
"fhKF_NofPi0_signal;nof;#", 10, -0.5, 9.5);
151 fhKF_invmass_fullReco =
new TH1D(
"fhKF_invmass_fullReco",
"fhKF_invmass_fullReco;invmass;#", 400, 0., 2.);
159 gDirectory->mkdir(
"KF");
160 gDirectory->cd(
"KF");
164 gDirectory->cd(
"..");
166 cout <<
"CbmAnaConversionKF: Realtime - " <<
fTime << endl;
196 if (
fKFparticle) { cout <<
"CbmAnaConversionKF: kf works" << endl; }
198 cout <<
"CbmAnaConversionKF: kf works not" << endl;
378 cout <<
"CbmAnaConversionKF: test nof " << nofparticles << endl;
379 for (
int i = 0; i < nofparticles; i++) {
382 if (pdg == 111) { cout <<
"CbmAnaConversionKF: test successful!" << endl; }
386 vector<vector<int>> ids;
388 for (
unsigned int iPart = 0; iPart <
fSignalIds.size(); iPart++) {
389 if (particles[
fSignalIds[iPart]].GetPDG() != 111)
continue;
392 const KFParticle& pi0 = particles[
fSignalIds[iPart]];
393 vector<int> electrons;
394 for (
int iGamma = 0; iGamma < pi0.NDaughters(); iGamma++) {
395 const int GammaID = pi0.DaughterIds()[iGamma];
396 const KFParticle&
Gamma = particles[GammaID];
397 for (
int iElectron = 0; iElectron <
Gamma.NDaughters(); iElectron++) {
398 int ElectronID =
Gamma.DaughterIds()[iElectron];
399 const KFParticle& Electron = particles[ElectronID];
400 int STStrackID = Electron.DaughterIds()[0];
401 electrons.push_back(STStrackID);
404 ids.push_back(electrons);
407 if (ids.size() > 0) {
408 cout <<
"NEW TEST: (sts ids) ";
409 for (
unsigned int i = 0; i < ids.size(); i++) {
410 for (
int j = 0; j < 4; j++) {
411 cout <<
" " << ids[i][j];
420 for (
unsigned int i = 0; i < ids.size(); i++) {
421 for (
int j = 0; j < 4; j++) {
423 if (stsTrack == NULL)
return;
425 if (stsMatch == NULL)
return;
427 if (stsMcTrackId < 0)
return;
437 <<
",grandmotherid" << mother->
GetMotherId() <<
")";
442 cout <<
"mass: " << mass << endl;
451 TLorentzVector lorVec1;
454 TLorentzVector lorVec2;
457 TLorentzVector lorVec3;
460 TLorentzVector lorVec4;
465 sum = lorVec1 + lorVec2 + lorVec3 + lorVec4;
466 cout <<
"mc: \t" << sum.Px() <<
" / " << sum.Py() <<
" / " << sum.Pz() <<
" / " << sum.E()
467 <<
"\t => mag = " << sum.Mag() << endl;
475 Int_t pi0counter_trackvector = 0;
476 const KFPTrackVector* kftrackvector;
477 kftrackvector =
fKFtopo->GetTracks();
478 Int_t kftv_size = kftrackvector->Size();
479 cout <<
"CbmAnaConversionKF: size of kftrackvector: " << kftv_size << endl;
481 kfvector_int vector_pdgs = kftrackvector->PDG();
483 cout <<
"CbmAnaConversionKF: pdgs in trackvector: ";
484 for (
int i = 0; i < kftv_size; i++) {
485 cout << vector_pdgs[i] <<
" / ";
486 if (TMath::Abs(vector_pdgs[i]) == 111) {
487 pi0counter_trackvector++;
509 cout <<
"CbmAnaConversionKF: size of particlevector: " << pv_size << endl;
510 cout <<
"CbmAnaConversionKF: size of particleMatch: " <<
particleMatch.size() << endl;
512 Int_t electroncounter = 0;
513 Int_t pi0counter = 0;
514 Int_t pi0counter_signal = 0;
515 Int_t gammacounter = 0;
516 for (
int i = 0; i < pv_size; i++) {
540 cout <<
"CbmAnaConversionKF: nof electrons in particlevector: " << electroncounter << endl;
541 cout <<
"CbmAnaConversionKF: nof pi0 in particlevector: " << pi0counter << endl;
542 cout <<
"CbmAnaConversionKF: nof gamma in particlevector: " << gammacounter << endl;
550 for (
int a = 0; a < nof - 1; a++) {
551 for (
int b = a + 1; b < nof; b++) {
554 Double_t openingAngle = electron1.GetAngle(electron2);
556 TLorentzVector lorentzE1;
557 lorentzE1.SetPxPyPzE(electron1.GetPx(), electron1.GetPy(), electron1.GetPz(), electron1.GetE());
558 TLorentzVector lorentzE2;
559 lorentzE2.SetPxPyPzE(electron2.GetPx(), electron2.GetPy(), electron2.GetPz(), electron2.GetE());
560 TLorentzVector sum = lorentzE1 + lorentzE2;
561 Double_t invmass = sum.Mag();
563 if (openingAngle < 1 && invmass < 0.03) {
579 for (
int a = 0; a < nof - 1; a++) {
580 for (
int b = a + 1; b < nof; b++) {
599 for (
int a = 0; a < nof - 3; a++) {
600 for (
int b = a + 1; b < nof - 2; b++) {
601 for (
int c = b + 1; c < nof - 1; c++) {
602 for (
int d = c + 1; d < nof; d++) {
607 Int_t test1234 = check1 + check2 + check3 + check4;
608 if (test1234 != 2)
continue;
619 Double_t invmass_cut = 0.02;
621 if (particle1.GetZ() == particle2.GetZ() && particle3.GetZ() == particle4.GetZ()) {
624 if (invmass_12 < invmass_cut && invmass_34 < invmass_cut) { fill =
true; }
626 if (particle1.GetZ() == particle3.GetZ() && particle2.GetZ() == particle4.GetZ()) {
629 if (invmass_13 < invmass_cut && invmass_24 < invmass_cut) { fill =
true; }
631 if (particle1.GetZ() == particle4.GetZ() && particle2.GetZ() == particle3.GetZ()) {
634 if (invmass_14 < invmass_cut && invmass_23 < invmass_cut) { fill =
true; }
686 for (
int a = 0; a < nof - 1; a++) {
687 for (
int b = a + 1; b < nof; b++) {
695 if ((TMath::Abs(particle1.GetZ() - particle2.GetZ()) < 0.005) && (openingAngle < 5)) {
708 TVector3 momentum1(part1.GetPx(), part1.GetPy(), part1.GetPz());
709 Double_t energy1 = TMath::Sqrt(momentum1.Mag2() +
M2E);
710 TLorentzVector lorVec1(momentum1, energy1);
712 TVector3 momentum2(part2.GetPx(), part2.GetPy(), part2.GetPz());
713 Double_t energy2 = TMath::Sqrt(momentum2.Mag2() +
M2E);
714 TLorentzVector lorVec2(momentum2, energy2);
716 TVector3 momentum3(part3.GetPx(), part3.GetPy(), part3.GetPz());
717 Double_t energy3 = TMath::Sqrt(momentum3.Mag2() +
M2E);
718 TLorentzVector lorVec3(momentum3, energy3);
720 TVector3 momentum4(part4.GetPx(), part4.GetPy(), part4.GetPz());
721 Double_t energy4 = TMath::Sqrt(momentum4.Mag2() +
M2E);
722 TLorentzVector lorVec4(momentum4, energy4);
726 sum = lorVec1 + lorVec2 + lorVec3 + lorVec4;
734 TVector3 momentum1(part1.GetPx(), part1.GetPy(), part1.GetPz());
735 Double_t energy1 = TMath::Sqrt(momentum1.Mag2());
736 TLorentzVector lorVec1(momentum1, energy1);
738 TVector3 momentum2(part2.GetPx(), part2.GetPy(), part2.GetPz());
739 Double_t energy2 = TMath::Sqrt(momentum2.Mag2());
740 TLorentzVector lorVec2(momentum2, energy2);
744 sum = lorVec1 + lorVec2;
752 TVector3 momentum1(part1.GetPx(), part1.GetPy(), part1.GetPz());
753 Double_t energy1 = TMath::Sqrt(momentum1.Mag2() +
M2E);
754 TLorentzVector lorVec1(momentum1, energy1);
756 TVector3 momentum2(part2.GetPx(), part2.GetPy(), part2.GetPz());
757 Double_t energy2 = TMath::Sqrt(momentum2.Mag2() +
M2E);
758 TLorentzVector lorVec2(momentum2, energy2);
762 sum = lorVec1 + lorVec2;
770 TVector3 momentum1(part1.GetPx(), part1.GetPy(), part1.GetPz());
771 Double_t energy1 = TMath::Sqrt(momentum1.Mag2());
772 TLorentzVector lorVec1(momentum1, energy1);
774 TVector3 momentum2(part2.GetPx(), part2.GetPy(), part2.GetPz());
775 Double_t energy2 = TMath::Sqrt(momentum2.Mag2());
776 TLorentzVector lorVec2(momentum2, energy2);
779 Double_t angleBetweenPhotons = lorVec1.Angle(lorVec2.Vect());
780 Double_t theta = 180. * angleBetweenPhotons / TMath::Pi();
Data class for STS tracks.
static vector< vector< QAMCTrack > > mcTracks
TClonesArray * fStsTracks
std::vector< KFParticle > particlevector
Double_t Invmass_2gamma(KFParticle part1, KFParticle part2)
TClonesArray * fStsTrackMatches
const KFParticleTopoReconstructor * fKFtopo
TClonesArray * fKFMcParticles
TH1D * fhKF_NofPi0_signal
Double_t Invmass_4particlesRECO(KFParticle part1, KFParticle part2, KFParticle part3, KFParticle part4)
void SetSignalIds(std::vector< int > *signalids)
std::vector< int > fSignalIds
std::vector< std::vector< int > > fKF_photon_pairs
CbmKFParticleFinder * fKFparticle
TH1D * fhInvMassPi0WithFullReco
void SetKF(CbmKFParticleFinder *kfparticle, CbmKFParticleFinderQa *kfparticleQA)
std::vector< TH1 * > fHistoList_kfparticle
Double_t Invmass_2electrons(KFParticle part1, KFParticle part2)
TH1D * fhKF_particlevector
std::vector< int > fGhostIds
CbmKFParticleFinderQa * fKFparticleFinderQA
TH1D * fhKF_NofPi0_trackvector
std::vector< KFPartMatch > particleMatch
KFTopoPerformance * fKFtopoPerf
std::vector< int > electronIDs
TH1D * fhInvMass2Gammas_cut
Double_t Invmass_4particles(const CbmMCTrack *mctrack1, const CbmMCTrack *mctrack2, const CbmMCTrack *mctrack3, const CbmMCTrack *mctrack4)
void SetGhostIds(std::vector< int > *ghostids)
TH1D * fhKF_invmass_fullReco
virtual ~CbmAnaConversionKF()
std::vector< int > gammaIDs
Double_t OpeningAngleBetweenPhotons(KFParticle part1, KFParticle part2)
const KFParticleTopoReconstructor * GetTopoReconstructor() const
int32_t GetMotherId() const
int32_t GetPdgCode() const
void Get4Momentum(TLorentzVector &momentum) const
const CbmLink & GetMatchedLink() const