12 std::cout <<
"ATKFParticleFinder::InitInput()\n";
14 in_chain_ =
new AnalysisTree::Chain(file_name.c_str(), tree_name.c_str());
17 else if (
in_chain_->CheckBranchExistence(
"VtxTracks") == 2) {
20 if (
in_chain_->CheckBranchExistence(
"RecEventHeader") == 1) {
23 else if (
in_chain_->CheckBranchExistence(
"RecEventHeader") == 2) {
26 if (
in_chain_->CheckBranchExistence(
"SimParticles") == 1) {
29 else if (
in_chain_->CheckBranchExistence(
"SimParticles") == 2) {
32 std::string kf2sim_tracks_name =
in_chain_->GetConfiguration()->GetMatchName(
"VtxTracks",
"SimParticles");
33 if (
in_chain_->CheckBranchExistence(kf2sim_tracks_name) == 1) {
36 else if (
in_chain_->CheckBranchExistence(kf2sim_tracks_name) == 2) {
40 auto branch_conf_kftr =
in_chain_->GetConfiguration()->GetBranchConfig(
"VtxTracks");
63 std::cout <<
"ATKFParticleFinder::InitOutput()\n";
65 out_file_ = TFile::Open(file_name.c_str(),
"recreate");
67 AnalysisTree::BranchConfig ParticlesRecoBranch(
"ParticlesReconstructed", AnalysisTree::DetType::kParticle);
69 ParticlesRecoBranch.AddField<
int>(
"daughter1id");
70 ParticlesRecoBranch.AddField<
int>(
"daughter2id");
75 out_tree_ =
new TTree(
"aTree",
"AnalysisTree ParticlesReco");
127 int n_good_tracks = 0;
129 for (
unsigned int i_track = 0; i_track <
kf_tracks_->GetNumberOfChannels(); i_track++) {
130 const AnalysisTree::Track& rec_track =
kf_tracks_->GetChannel(i_track);
135 KFPTrackVector track_vector1, track_vector2;
136 track_vector1.Resize(n_good_tracks);
140 for (
unsigned int i_track = 0; i_track <
kf_tracks_->GetNumberOfChannels(); i_track++) {
141 const AnalysisTree::Track& rec_track =
kf_tracks_->GetChannel(i_track);
145 for (Int_t iP = 0; iP < 3; iP++)
146 track_vector1.SetParameter(rec_track.GetField<
float>(
par_field_id_ + iP), iP, j_track);
147 track_vector1.SetParameter(rec_track.GetPx(), 3, j_track);
148 track_vector1.SetParameter(rec_track.GetPy(), 4, j_track);
149 track_vector1.SetParameter(rec_track.GetPz(), 5, j_track);
151 for (Int_t iC = 0; iC < 21; iC++)
152 track_vector1.SetCovariance(cov_matrix.at(iC), iC, j_track);
153 for (Int_t iF = 0; iF < 10; iF++)
154 track_vector1.SetFieldCoefficient(rec_track.GetField<
float>(
mf_field_id_ + iF), iF, j_track);
155 if (
pid_mode_ == 0) track_vector1.SetPDG(-1, j_track);
159 if (sim_id > 0) pdg =
sim_particles_->GetChannel(sim_id).GetPid();
160 track_vector1.SetPDG(pdg, j_track);
162 track_vector1.SetQ(rec_track.GetField<
int>(
q_field_id_), j_track);
163 if (rec_track.GetField<
float>(
vtx_chi2_field_id_) < 3.) track_vector1.SetPVIndex(0, j_track);
165 track_vector1.SetPVIndex(-1, j_track);
167 track_vector1.SetId(rec_track.GetId(), j_track);
172 KFPVertex primVtx_tmp;
174 primVtx_tmp.SetCovarianceMatrix(0, 0, 0, 0, 0, 0);
175 primVtx_tmp.SetNContributors(0);
176 primVtx_tmp.SetChi2(-100);
177 std::vector<int> pvTrackIds;
178 KFVertex pv(primVtx_tmp);
181 std::cout << track_vector1.Size() <<
"\n";
190 for (
const auto& particle : eventTR->GetParticles()) {
195 particle.GetMass(mass, masserr);
196 particlerec->SetMass(mass);
199 particlerec->SetMomentum(particle.GetPx(), particle.GetPy(), particle.GetPz());
200 particlerec->SetPid(particle.GetPDG());
213 const double t =
sqrt(1.f + tx * tx + ty * ty);
214 const double t3 = t * t * t;
215 const double dpxdtx = q / qp * (1.f + ty * ty) / t3;
216 const double dpxdty = -q / qp * tx * ty / t3;
217 const double dpxdqp = -q / (qp * qp) * tx / t;
218 const double dpydtx = -q / qp * tx * ty / t3;
219 const double dpydty = q / qp * (1.f + tx * tx) / t3;
220 const double dpydqp = -q / (qp * qp) * ty / t;
221 const double dpzdtx = -q / qp * tx / t3;
222 const double dpzdty = -q / qp * ty / t3;
223 const double dpzdqp = -q / (qp * qp * t3);
225 const double F[6][5] = {{1.f, 0.f, 0.f, 0.f, 0.f}, {0.f, 1.f, 0.f, 0.f, 0.f},
226 {0.f, 0.f, 0.f, 0.f, 0.f}, {0.f, 0.f, dpxdtx, dpxdty, dpxdqp},
227 {0.f, 0.f, dpydtx, dpydty, dpydqp}, {0.f, 0.f, dpzdtx, dpzdty, dpzdqp}};
230 for (
int i = 0; i < 5; i++)
231 for (
int j = 0; j < 6; j++) {
233 for (
int k = 0; k < 5; k++) {
235 VFT[i][j] += track.GetField<
float>(
cov_field_id_ + k + i * (i + 1) / 2)
238 VFT[i][j] += track.GetField<
float>(
cov_field_id_ + i + k * (k + 1) / 2)
244 std::vector<float> cov(21, 0);
245 for (
int i = 0, l = 0; i < 6; i++)
246 for (
int j = 0; j <= i; j++, l++) {
248 for (
int k = 0; k < 5; k++) {
249 cov[l] += F[i][k] * VFT[k][j];
int daughter1_id_field_id_
int daughter2_id_field_id_
void Run(int n_events=-1)
AnalysisTree::Particles * sim_particles_
AnalysisTree::TrackDetector * kf_tracks_
AnalysisTree::Configuration out_config_
std::vector< float > GetCovMatrixCbm(const AnalysisTree::Track &track) const
void InitTopoReconstructor()
void InitInput(const std::string &file_name, const std::string &tree_name)
AnalysisTree::Chain * in_chain_
void InitOutput(const std::string &file_name="KFPF_output.root")
AnalysisTree::EventHeader * rec_event_header_
AnalysisTree::Matching * kf2sim_tracks_
KFParticleTopoReconstructor * topo_reconstructor_
AnalysisTree::Particles * particles_reco_
void WriteCandidates(const KFParticleTopoReconstructor *TR)