14#include "GaudiKernel/MsgStream.h"
15#include "GaudiKernel/ITHistSvc.h"
53 TFile *
file =
nullptr;
55 for (
int iFile = 0; iFile <
m_nFiles; iFile++) {
60 if (
file->GetNkeys() != 0)
break;
64 if (!
file)
return StatusCode::FAILURE;
67 TTree *matrix_tree = (TTree*)
file->Get(Form(
"am%d",
m_region.value()));
68 matrix_tree->SetBranchAddress(
"nplanes", &
m_nLayers);
69 matrix_tree->SetBranchAddress(
"ndim", &
m_nDim);
70 matrix_tree->SetBranchAddress(
"ndim2", &
m_nDim2);
71 matrix_tree->GetEntry(0);
92 return StatusCode::SUCCESS;
98 m_h_nSector =
new TH1I(
"h_nSector",
"number of sectors in merged file", 100, 0, 10000);
101 m_h_nHit =
new TH1I(
"h_nHit",
"number of hits in sector", 100, 0, 10000);
104 m_h_c =
new TH1F(
"h_c",
"Truth curvature in sector",100,-1e-8,1e-8);
107 m_h_d =
new TH1F(
"h_d",
"Truth d0 in sector",100,-2.5,2.5);
110 m_h_phi =
new TH1F(
"h_phi",
"Truth phi in sector",100,0,6.3);
113 m_h_coto =
new TH1F(
"h_coto",
"Truth coto in sector",100,-4,4);
116 m_h_z =
new TH1F(
"h_z",
"Truth z in sector",100,-200,200);
119 return StatusCode::SUCCESS;
130 TTree *old_tree = (TTree*)
file->Get(
"slice");
131 old_tree->SetBranchAddress(
"c_max", &
max.qOverPt);
132 old_tree->SetBranchAddress(
"c_min", &
min.qOverPt);
133 old_tree->SetBranchAddress(
"c_slices", &nBins.qOverPt);
135 old_tree->SetBranchAddress(
"phi_max", &
max.phi);
136 old_tree->SetBranchAddress(
"phi_min", &
min.phi);
137 old_tree->SetBranchAddress(
"phi_slices", &nBins.phi);
139 old_tree->SetBranchAddress(
"d0_max", &
max.d0);
140 old_tree->SetBranchAddress(
"d0_min", &
min.d0);
141 old_tree->SetBranchAddress(
"d0_slices", &nBins.d0);
143 old_tree->SetBranchAddress(
"z0_max", &
max.z0);
144 old_tree->SetBranchAddress(
"z0_min", &
min.z0);
145 old_tree->SetBranchAddress(
"z0_slices", &nBins.z0);
147 old_tree->SetBranchAddress(
"eta_max", &
max.eta);
148 old_tree->SetBranchAddress(
"eta_min", &
min.eta);
149 old_tree->SetBranchAddress(
"eta_slices", &nBins.eta);
151 old_tree->GetEntry(0);
154 TTree *new_tree =
new TTree(
"slice",
"Slice boundaries");
157 new_tree->Branch(
"c_max", &
max.qOverPt);
158 new_tree->Branch(
"c_min", &
min.qOverPt);
159 new_tree->Branch(
"c_slices", &nBins.qOverPt);
161 new_tree->Branch(
"phi_max", &
max.phi);
162 new_tree->Branch(
"phi_min", &
min.phi);
163 new_tree->Branch(
"phi_slices", &nBins.phi);
165 new_tree->Branch(
"d0_max", &
max.d0);
166 new_tree->Branch(
"d0_min", &
min.d0);
167 new_tree->Branch(
"d0_slices", &nBins.d0);
169 new_tree->Branch(
"z0_max", &
max.z0);
170 new_tree->Branch(
"z0_min", &
min.z0);
171 new_tree->Branch(
"z0_slices", &nBins.z0);
173 new_tree->Branch(
"eta_max", &
max.eta);
174 new_tree->Branch(
"eta_min", &
min.eta);
175 new_tree->Branch(
"eta_slices", &nBins.eta);
179 return StatusCode::SUCCESS;
186 for (
int iFile = 0; iFile <
m_nFiles; iFile++)
189 const string &fpath =
m_fpath[iFile];
191 TFile *
file = TFile::Open(fpath.c_str());
203 TTree *
tree = (TTree*)
file->Get(Form(
"am%d", region));
222 return StatusCode::SUCCESS;
234 std::stringstream name;
235 std::stringstream title;
236 name <<
"am" << region;
237 title <<
"Ambank " << region <<
" parameters";
238 TTree*
tree =
new TTree(name.str().c_str(), title.str().c_str());
254 double coverage = sector_info.second.track_bins.size();
256 m_h_c->Fill(sector_info.second.pars.qOverPt / coverage);
257 m_h_d->Fill(sector_info.second.pars.d0 / coverage);
258 m_h_phi->Fill(sector_info.second.pars.phi / coverage);
259 m_h_coto->Fill(sector_info.second.pars.eta / coverage);
260 m_h_z->Fill(sector_info.second.pars.z0 / coverage);
266 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
void fillTree(AccumulateMap &map, TTree *tree, int nLayers, int nCoords)
Writes the contents of an AccumulateMap into the supplied tree (one entry per sector).
Algorithm to merge matrix files, to be used for sector and constant generation.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Property< bool > m_Monitor
std::vector< AccumulateMap > m_sector_cum
void readTree(TTree *matrix_tree, int region)
StatusCode execute() override
Gaudi::Property< int > m_region
StatusCode initialize() override
StatusCode finalize() override
Gaudi::Property< int > m_nRegions
StatusCode bookHistograms()
Gaudi::Property< std::vector< std::string > > m_fpath
Gaudi::Property< bool > m_allregion
StatusCode copySliceTree(TFile *file)
FPGATrackSimMatrixMergeAlgo(const std::string &name, ISvcLocator *pSvcLocator)
ServiceHandle< ITHistSvc > m_tHistSvc
std::vector< std::string > files
file names and file pointers