CbmRoot
Loading...
Searching...
No Matches
CbmAnaTreeContainer.cxx
Go to the documentation of this file.
1/* Copyright (C) 2023-2023 Warsaw University of Technology, Warsaw
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Daniel Wielanek [committer] */
5
6#include "AnalysisTree/Matching.hpp"
7
8#include <TChain.h>
9#include <TFile.h>
10
11#include <AnalysisTree/Configuration.hpp>
12
13#include <Hal/Cout.h>
14
16{
17 fEvent = new AnalysisTree::EventHeader();
18 fVtxTracks = new AnalysisTree::TrackDetector();
19 fTofHits = new AnalysisTree::HitDetector();
20 fVtx2Tof = new AnalysisTree::Matching();
21 fVtx2Mc = new AnalysisTree::Matching();
22 if (tree->GetBranch("VtxTracks.") == nullptr) {
23 Hal::Cout::PrintInfo("Lack of VtxTracks in AT", Hal::EInfo::kError);
24 return kFALSE;
25 }
26 if (tree->GetBranch("RecEventHeader.") == nullptr) {
27 Hal::Cout::PrintInfo("Lack of RecEventHeader in AT", Hal::EInfo::kError);
28 return kFALSE;
29 }
30 if (tree->GetBranch("TofHits.") == nullptr) {
31 Hal::Cout::PrintInfo("Lack of TofHits in AT", Hal::EInfo::kError);
32 return kFALSE;
33 }
34 if (tree->GetBranch("VtxTracks2TofHits.") == nullptr) {
35 Hal::Cout::PrintInfo("Lack of VtxTracks2TofHits tracks in AT", Hal::EInfo::kError);
36 return kFALSE;
37 }
38 tree->SetBranchAddress("VtxTracks.", &fVtxTracks);
39 tree->SetBranchAddress("RecEventHeader.", &fEvent);
40 tree->SetBranchAddress("TofHits.", &fTofHits);
41 tree->SetBranchAddress("VtxTracks2TofHits.", &fVtx2Tof);
42 tree->SetBranchStatus("VtxTracks.", 1);
43 tree->SetBranchStatus("RecEventHeader.", 1);
44 tree->SetBranchStatus("TofHits.", 1);
45 tree->SetBranchStatus("VtxTracks2TofHits.", 1);
46 if (tree->GetBranch("VtxTracks2SimParticles.")) {
47 tree->SetBranchAddress("VtxTracks2SimParticles.", &fVtx2Mc);
48 tree->SetBranchStatus("VtxTracks2SimParticles.", 1);
49 }
50
51 return kTRUE;
52}
53
55{
56 fEvent = new AnalysisTree::EventHeader();
57 fParticles = new AnalysisTree::Particles();
58 if (tree->GetBranch("SimEventHeader.") == nullptr) return kFALSE;
59 if (tree->GetBranch("SimParticles.") == nullptr) return kFALSE;
60 tree->SetBranchAddress("SimEventHeader.", &fEvent);
61 tree->SetBranchAddress("SimParticles.", &fParticles);
62 tree->SetBranchStatus("SimEventHeader.", 1);
63 tree->SetBranchStatus("SimParticles.", 1);
64 return kTRUE;
65}
66
68{
69 TFile* oldFile = gFile;
70 TDirectory* oldDir = gDirectory;
71
72 TFile* f = new TFile(file);
73 AnalysisTree::Configuration* conf = (AnalysisTree::Configuration*) f->Get("Configuration");
74 GetFieldIds().vtx_px = conf->GetBranchConfig("VtxTracks").GetFieldId("px");
75 GetFieldIds().vtx_py = conf->GetBranchConfig("VtxTracks").GetFieldId("py");
76 GetFieldIds().vtx_pz = conf->GetBranchConfig("VtxTracks").GetFieldId("pz");
77 GetFieldIds().vtx_dcax = conf->GetBranchConfig("VtxTracks").GetFieldId("dcax");
78 GetFieldIds().vtx_dcay = conf->GetBranchConfig("VtxTracks").GetFieldId("dcay");
79 GetFieldIds().vtx_dcaz = conf->GetBranchConfig("VtxTracks").GetFieldId("dcaz");
80
81 GetFieldIds().vtx_chi2 = conf->GetBranchConfig("VtxTracks").GetFieldId("chi2");
82 GetFieldIds().vtx_vtxchi2 = conf->GetBranchConfig("VtxTracks").GetFieldId("vtx_chi2");
83 GetFieldIds().vtx_q = conf->GetBranchConfig("VtxTracks").GetFieldId("q");
84 GetFieldIds().vtx_nhits = conf->GetBranchConfig("VtxTracks").GetFieldId("nhits");
85 GetFieldIds().vtx_mvdhits = conf->GetBranchConfig("VtxTracks").GetFieldId("nhits_mvd");
86
87
88 GetFieldIds().tof_mass2 = conf->GetBranchConfig("TofHits").GetFieldId("mass2");
89
90 GetFieldIds().vtx_x = conf->GetBranchConfig("VtxTracks").GetFieldId("x");
91 GetFieldIds().vtx_cx0 = conf->GetBranchConfig("VtxTracks").GetFieldId("cx0");
92 GetFieldIds().vtx_cov1 = conf->GetBranchConfig("VtxTracks").GetFieldId("cov1");
93 gFile = oldFile;
94 gDirectory = oldDir;
95
96 f->Close();
97 delete f;
98}
99
101{
102 TFile* oldFile = gFile;
103 TDirectory* oldDir = gDirectory;
104
105 TFile* f = new TFile(inFile);
106
107 AnalysisTree::Configuration* conf = (AnalysisTree::Configuration*) f->Get("Configuration");
108
109 GetFieldIds().px = conf->GetBranchConfig("SimParticles").GetFieldId("px");
110 GetFieldIds().py = conf->GetBranchConfig("SimParticles").GetFieldId("py");
111 GetFieldIds().pz = conf->GetBranchConfig("SimParticles").GetFieldId("pz");
112 GetFieldIds().mass = conf->GetBranchConfig("SimParticles").GetFieldId("mass");
113 GetFieldIds().pdg = conf->GetBranchConfig("SimParticles").GetFieldId("pid");
114 GetFieldIds().motherId = conf->GetBranchConfig("SimParticles").GetFieldId("mother_id");
115 GetFieldIds().event_b = conf->GetBranchConfig("SimEventHeader").GetFieldId("b");
116 GetFieldIds().event_psi = conf->GetBranchConfig("SimEventHeader").GetFieldId("psi_RP");
117 GetFieldIds().freezX = conf->GetBranchConfig("SimParticles").GetFieldId("xfreez");
118 GetFieldIds().freezY = conf->GetBranchConfig("SimParticles").GetFieldId("yfreez");
119 GetFieldIds().freezZ = conf->GetBranchConfig("SimParticles").GetFieldId("zfreez");
120 GetFieldIds().freezT = conf->GetBranchConfig("SimParticles").GetFieldId("tfreez");
121 gFile = oldFile;
122 gDirectory = oldDir;
123
124 f->Close();
125 delete f;
126}
AnalysisTree::EventHeader * fEvent
AnalysisTree::Particles * fParticles
AnalysisTree::TrackDetector * fVtxTracks
AnalysisTree::Matching * fVtx2Tof
AnalysisTree::Matching * fVtx2Mc
AnalysisTree::HitDetector * fTofHits
AnalysisTree::EventHeader * fEvent