4 const std::string& tree_name) {
5 std::cout <<
"ATKFParticleFinder::InitInput()\n";
10 in_file_ = TFile::Open(file_name.c_str(),
"read");
11 config_ = (AnalysisTree::Configuration*)
in_file_->Get(
"Configuration");
13 in_chain_ =
new TChain(tree_name.c_str());
18 auto branch_conf_kftr =
config_->GetBranchConfig(
"VtxTracks");
33 std::cout <<
"ATKFParticleFinder::InitOutput()\n";
35 out_file_ = TFile::Open(file_name.c_str(),
"recreate");
37 AnalysisTree::BranchConfig ParticlesRecoBranch(
38 "ParticlesReconstructed", AnalysisTree::DetType::kParticle);
40 ParticlesRecoBranch.AddField<
int>(
"daughter1id");
41 ParticlesRecoBranch.AddField<
int>(
"daughter2id");
46 out_tree_ =
new TTree(
"aTree",
"AnalysisTree ParticlesReco");
52 .GetFieldId(
"daughter1id");
54 .GetFieldId(
"daughter2id");
58 std::cout <<
"ATKFParticleFinder::Finish()\n";
65 if (n_events < 0 || n_events >
in_chain_->GetEntries())
68 std::cout <<
"ATKFParticleFinder::Run() " << n_events <<
" events\n";
70 for (
int i_event = 0; i_event < n_events; i_event++) {
71 std::cout <<
"eveNo = " << i_event <<
"\n";
73 KFParticleTopoReconstructor* eventTopoReconstructor =
80 eventTopoReconstructor->SortTracks();
81 eventTopoReconstructor->ReconstructParticles();
94 auto* TR =
new KFParticleTopoReconstructor;
98 TR->GetKFParticleFinder()->SetMaxDistanceBetweenParticlesCut(
104 int n_good_tracks = 0;
106 for (
int i_track = 0; i_track <
kf_tracks_->GetNumberOfChannels();
108 const AnalysisTree::Track& rec_track =
kf_tracks_->GetChannel(i_track);
115 KFPTrackVector track_vector1, track_vector2;
116 track_vector1.Resize(n_good_tracks);
120 for (
int i_track = 0; i_track <
kf_tracks_->GetNumberOfChannels();
122 const AnalysisTree::Track& rec_track =
kf_tracks_->GetChannel(i_track);
128 for (Int_t iP = 0; iP < 3; iP++)
129 track_vector1.SetParameter(
131 track_vector1.SetParameter(rec_track.GetPx(), 3, j_track);
132 track_vector1.SetParameter(rec_track.GetPy(), 4, j_track);
133 track_vector1.SetParameter(rec_track.GetPz(), 5, j_track);
135 for (Int_t iC = 0; iC < 21; iC++)
136 track_vector1.SetCovariance(cov_matrix.at(iC), iC, j_track);
137 for (Int_t iF = 0; iF < 10; iF++)
138 track_vector1.SetFieldCoefficient(
139 rec_track.GetField<
float>(
mf_field_id_ + iF), iF, j_track);
141 track_vector1.SetPDG(-1, j_track);
143 track_vector1.SetPDG(rec_track.GetField<
int>(
pdg_field_id_), j_track);
144 track_vector1.SetQ(rec_track.GetField<
int>(
q_field_id_), j_track);
146 track_vector1.SetPVIndex(0, j_track);
148 track_vector1.SetPVIndex(-1, j_track);
151 track_vector1.SetId(rec_track.GetId(), j_track);
154 TR->Init(track_vector1, track_vector2);
156 KFPVertex primVtx_tmp;
160 primVtx_tmp.SetCovarianceMatrix(0, 0, 0, 0, 0, 0);
161 primVtx_tmp.SetNContributors(0);
162 primVtx_tmp.SetChi2(-100);
163 std::vector<int> pvTrackIds;
164 KFVertex pv(primVtx_tmp);
165 TR->AddPV(pv, pvTrackIds);
167 std::cout << track_vector1.Size() <<
"\n";
173 const KFParticleTopoReconstructor* eventTR) {
176 for (
unsigned int iP = 0; iP < eventTR->GetParticles().size(); iP++) {
177 const KFParticle& particle = eventTR->GetParticles()[iP];
183 particle.GetMass(mass, masserr);
184 particlerec->SetMass(mass);
187 particlerec->SetMomentum(
188 particle.GetPx(), particle.GetPy(), particle.GetPz());
189 particlerec->SetPid(particle.GetPDG());
204 const double t =
sqrt(1.
f + tx * tx + ty * ty);
205 const double t3 = t * t * t;
206 const double dpxdtx = q / qp * (1.f + ty * ty) / t3;
207 const double dpxdty = -q / qp * tx * ty / t3;
208 const double dpxdqp = -q / (qp * qp) * tx / t;
209 const double dpydtx = -q / qp * tx * ty / t3;
210 const double dpydty = q / qp * (1.f + tx * tx) / t3;
211 const double dpydqp = -q / (qp * qp) * ty / t;
212 const double dpzdtx = -q / qp * tx / t3;
213 const double dpzdty = -q / qp * ty / t3;
214 const double dpzdqp = -q / (qp * qp * t3);
216 const double F[6][5] = {{1.f, 0.f, 0.f, 0.f, 0.f},
217 {0.f, 1.f, 0.f, 0.f, 0.f},
218 {0.f, 0.f, 0.f, 0.f, 0.f},
219 {0.f, 0.f, dpxdtx, dpxdty, dpxdqp},
220 {0.f, 0.f, dpydtx, dpydty, dpydqp},
221 {0.f, 0.f, dpzdtx, dpzdty, dpzdqp}};
224 for (
int i = 0;
i < 5;
i++)
225 for (
int j = 0; j < 6; j++) {
227 for (
int k = 0; k < 5; k++) {
240 std::vector<float> cov(21, 0);
241 for (
int i = 0, l = 0;
i < 6;
i++)
242 for (
int j = 0; j <=
i; j++, l++) {
244 for (
int k = 0; k < 5; k++) {
245 cov[l] += F[
i][k] * VFT[k][j];