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");
141 unsigned short nBinsU = 0;
142 unsigned short nBinsV = 0;
146 B2INFO(
"Start info collection using a " << nBinsU <<
"x" << nBinsV <<
" grid per sensor.");
147 B2INFO(
"Number of collected track points is " << point_counter->GetEntries()
148 <<
" in " << nSensors <<
" sensors.");
151 B2WARNING(
"Not enough Data: Only " << point_counter->GetEntries() <<
" hits were collected but " <<
minTrackPoints
157 auto hPassedHitsLayer1 = getObjectPtr<TH2F>(
"hPassedHitsLayer1");
158 auto hTotalHitsLayer1 = getObjectPtr<TH2F>(
"hTotalHitsLayer1");
159 auto hPassedHitsLayer2 = getObjectPtr<TH2F>(
"hPassedHitsLayer2");
160 auto hTotalHitsLayer2 = getObjectPtr<TH2F>(
"hTotalHitsLayer2");
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)
253 for (
auto histoBin = 1; histoBin <= cluster_counter->GetXaxis()->GetNbins(); histoBin++) {
255 string label = cluster_counter->GetXaxis()->GetBinLabel(histoBin);
258 istringstream stream(label);
260 getline(stream, token,
'_');
261 VxdID sensorID(token);
263 getline(stream, token,
'_');
264 unsigned short uBin = std::stoi(token);
266 getline(stream, token,
'_');
267 unsigned short vBin = std::stoi(token);
270 int numberOfClusters = cluster_counter->GetBinContent(histoBin);
271 int numberOfPoints = point_counter->GetBinContent(histoBin);
274 m_uBin.emplace_back(uBin);
275 m_vBin.emplace_back(vBin);
283 if (
m_exp == expRunsAll.back().first &&
284 m_run == expRunsAll.back().second) {
285 B2INFO(
"Reached Final ExpRun: (" <<
m_exp <<
", " <<
m_run <<
")");
288 B2INFO(
"Writing Successful.");
317 if (m_boundaries.empty()) {
318 B2INFO(
"This is the first run encountered, let's say it is a boundary.");