11 #include <pxd/calibration/PXDValidationAlgorithm.h>
22 #include <boost/format.hpp>
38 void getNumberOfBins(
const std::shared_ptr<TH1I>& histo_ptr,
unsigned short& nBinsU,
unsigned short& nBinsV)
40 set<unsigned short> uBinSet;
41 set<unsigned short> vBinSet;
44 for (
auto histoBin = 1; histoBin <= histo_ptr->GetXaxis()->GetNbins(); histoBin++) {
46 string label = histo_ptr->GetXaxis()->GetBinLabel(histoBin);
49 istringstream stream(label);
51 getline(stream, token,
'_');
52 getline(stream, token,
'_');
53 unsigned short uBin = std::stoi(token);
55 getline(stream, token,
'_');
56 unsigned short vBin = std::stoi(token);
62 if (uBinSet.empty() || vBinSet.empty()) {
63 B2FATAL(
"Not able to determine the grid size. Something is wrong with collected data.");
65 nBinsU = *uBinSet.rbegin() + 1;
66 nBinsV = *vBinSet.rbegin() + 1;
73 set<unsigned short> sensorSet;
76 for (
auto histoBin = 1; histoBin <= histo_ptr->GetXaxis()->GetNbins(); histoBin++) {
78 string label = histo_ptr->GetXaxis()->GetBinLabel(histoBin);
81 istringstream stream(label);
83 getline(stream, token,
'_');
84 VxdID sensorID(token);
85 sensorSet.insert(sensorID.getID());
87 return sensorSet.size();
93 PXDValidationAlgorithm::PXDValidationAlgorithm():
95 , minTrackPoints(1000), save2DHists(false)
100 " -------------------------- PXDValidationAlgorithm ---------------------------------\n"
102 " Algorithm for filling validation histograms. \n"
103 " ----------------------------------------------------------------------------------------\n"
125 m_exp = expRuns.back().first;
126 m_run = expRuns.back().second;
127 B2INFO(
"Current ExpRuns: [("
128 << expRuns.front().first <<
", " << expRuns.front().second <<
"), ("
132 auto cluster_counter = getObjectPtr<TH1I>(
"PXDTrackClusterCounter");
133 auto point_counter = getObjectPtr<TH1I>(
"PXDTrackPointCounter");
139 unsigned short nBinsU = 0;
140 unsigned short nBinsV = 0;
144 B2INFO(
"Start info collection using a " << nBinsU <<
"x" << nBinsV <<
" grid per sensor.");
145 B2INFO(
"Number of collected track points is " << point_counter->GetEntries()
146 <<
" in " << nSensors <<
" sensors.");
149 B2WARNING(
"Not enough Data: Only " << point_counter->GetEntries() <<
" hits were collected but " <<
minTrackPoints
155 auto hPassedHitsLayer1 = getObjectPtr<TH2F>(
"hPassedHitsLayer1");
156 auto hTotalHitsLayer1 = getObjectPtr<TH2F>(
"hTotalHitsLayer1");
157 auto hPassedHitsLayer2 = getObjectPtr<TH2F>(
"hPassedHitsLayer2");
158 auto hTotalHitsLayer2 = getObjectPtr<TH2F>(
"hTotalHitsLayer2");
161 if (!hPassedHitsLayer1)
return c_Failure;
163 if (!hPassedHitsLayer2)
return c_Failure;
167 TDirectory* currentDir = gDirectory;
172 std::string fileName = (this->
getPrefix()) +
"Validation.root";
173 B2INFO(
"Creating file " << fileName);
174 m_file = std::make_shared<TFile>(fileName.c_str(),
"RECREATE");
180 B2INFO(
"Creating TTree.");
181 m_tree = std::make_shared<TTree>(
"tree",
"PXD validation data");
184 m_hD0 =
new TH1F(
"hD0",
"Corrected d0;#Delta d0/#sqrt{2} [cm];Counts", 100, -0.03, 0.03);
185 m_hZ0 =
new TH1F(
"hZ0",
"Corrected z0;#Delta z0/#sqrt{2} [cm];Counts", 100, -0.03, 0.03);
231 auto tree_d0z0 = getObjectPtr<TTree>(
"tree_d0z0");
234 tree_d0z0->SetBranchAddress(
"d0", &d0);
235 tree_d0z0->SetBranchAddress(
"z0", &z0);
240 string cuts =
"abs(d0)<0.03&&abs(z0)<0.03";
243 for (
int i = 0; i < tree_d0z0->GetEntries(); i++) {
244 tree_d0z0->GetEntry(i);
245 if (fabs(d0) > 0.03 || fabs(z0) > 0.03)
255 for (
auto histoBin = 1; histoBin <= cluster_counter->GetXaxis()->GetNbins(); histoBin++) {
257 string label = cluster_counter->GetXaxis()->GetBinLabel(histoBin);
260 istringstream stream(label);
262 getline(stream, token,
'_');
263 VxdID sensorID(token);
265 getline(stream, token,
'_');
266 unsigned short uBin = std::stoi(token);
268 getline(stream, token,
'_');
269 unsigned short vBin = std::stoi(token);
272 int numberOfClusters = cluster_counter->GetBinContent(histoBin);
273 int numberOfPoints = point_counter->GetBinContent(histoBin);
276 m_uBin.emplace_back(uBin);
277 m_vBin.emplace_back(vBin);
285 if (
m_exp == expRunsAll.back().first &&
286 m_run == expRunsAll.back().second) {
287 B2INFO(
"Reached Final ExpRun: (" <<
m_exp <<
", " <<
m_run <<
")");
290 B2INFO(
"Writing Successful.");
319 if (m_boundaries.empty()) {
320 B2INFO(
"This is the first run encountered, let's say it is a boundary.");