Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TpcClusterQA.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TpcClusterQA.cc
1 
2 #include "TpcClusterQA.h"
3 
6 #include <fun4all/SubsysReco.h>
7 
8 #include <qautils/QAHistManagerDef.h>
9 
11 
12 #include <phool/PHCompositeNode.h>
13 #include <phool/getClass.h>
14 #include <trackbase/ActsGeometry.h>
15 #include <trackbase/TpcDefs.h>
17 #include <trackbase/TrkrCluster.h>
20 #include <trackbase/TrkrDefs.h>
21 
22 #include <qautils/QAHistManagerDef.h>
23 #include <qautils/QAUtil.h>
24 
25 #include <TH1F.h>
26 #include <TH2F.h>
27 
28 //____________________________________________________________________________..
30  : SubsysReco(name)
31 {
32 }
33 
34 //____________________________________________________________________________..
36 {
37 }
38 
39 //____________________________________________________________________________..
41 {
43 }
44 
45 //____________________________________________________________________________..
47 {
48  // find tpc geometry
49  auto geomContainer =
50  findNode::getClass<PHG4TpcCylinderGeomContainer>(topNode, "CYLINDERCELLGEOM_SVTX");
51  if (!geomContainer)
52  {
53  std::cout << PHWHERE << " unable to find DST node CYLINDERCELLGEOM_SVTX" << std::endl;
55  }
56  // TPC has 3 regions, inner, mid and outer
57  std::vector<int> region_layer_low = {7, 23, 39};
58  std::vector<int> region_layer_high = {22, 38, 54};
59 
60  // make a layer to region multimap
61  const auto range = geomContainer->get_begin_end();
62  for (auto iter = range.first; iter != range.second; ++iter)
63  {
64  m_layers.insert(iter->first);
65 
66  for (int region = 0; region < 3; ++region)
67  {
68  if (iter->first >= region_layer_low[region] && iter->first <= region_layer_high[region])
69  m_layerRegionMap.insert(std::make_pair(iter->first, region));
70  }
71  }
72 
73  createHistos();
74 
76 }
77 
78 //____________________________________________________________________________..
80 {
81  auto clusterContainer = findNode::getClass<TrkrClusterContainer>(topNode, "TRKR_CLUSTER");
82  if (!clusterContainer)
83  {
84  std::cout << PHWHERE << "No cluster container, bailing" << std::endl;
86  }
87 
88  auto tGeometry = findNode::getClass<ActsGeometry>(topNode, "ActsGeometry");
89  if (!tGeometry)
90  {
91  std::cout << PHWHERE << "No acts geometry on node tree, bailing" << std::endl;
93  }
94 
96  assert(hm);
97 
98  TH2 *h_totalclusters = dynamic_cast<TH2 *>(hm->getHisto(Form("%stotal_clusters", getHistoPrefix().c_str())));
99  TH2 *h_clusterssector = dynamic_cast<TH2 *>(hm->getHisto(Form("%sncluspersector", getHistoPrefix().c_str())));
100 
101  struct HistoList
102  {
103  TH1 *crphisize = nullptr;
104  TH1 *czsize = nullptr;
105  TH1 *crphierr = nullptr;
106  TH1 *czerr = nullptr;
107  TH1 *cedge = nullptr;
108  TH1 *coverlap = nullptr;
109  };
110 
111  int hitsetkeynum = 0;
112  using HistoMap = std::map<int, HistoList>;
113  HistoMap histos;
114 
115  for (auto &region : {0, 1, 2})
116  {
117  HistoList hist;
118  hist.crphisize = dynamic_cast<TH1 *>(hm->getHisto(Form("%sphisize_%i", getHistoPrefix().c_str(), region)));
119  hist.czsize = dynamic_cast<TH1 *>(hm->getHisto(Form("%szsize_%i", getHistoPrefix().c_str(), region)));
120  hist.crphierr = dynamic_cast<TH1 *>(hm->getHisto(Form("%srphi_error_%i", getHistoPrefix().c_str(), region)));
121  hist.czerr = dynamic_cast<TH1 *>(hm->getHisto(Form("%sz_error_%i", getHistoPrefix().c_str(), region)));
122  hist.cedge = dynamic_cast<TH1 *>(hm->getHisto(Form("%sclusedge_%i", getHistoPrefix().c_str(), region)));
123  hist.coverlap = dynamic_cast<TH1 *>(hm->getHisto(Form("%sclusoverlap_%i", getHistoPrefix().c_str(), region)));
124 
125  histos.insert(std::make_pair(region, hist));
126  }
127  auto fill = [](TH1 *h, float val)
128  { if (h) h->Fill(val); };
129 
130  float nclusperevent[24] = {0};
131  for (auto &hsk : clusterContainer->getHitSetKeys(TrkrDefs::TrkrId::tpcId))
132  {
133  int numclusters = 0;
134 
135  auto range = clusterContainer->getClusters(hsk);
136  int sector = TpcDefs::getSectorId(hsk);
137  int side = TpcDefs::getSide(hsk);
138  if (side > 0) sector += 12;
139  for (auto iter = range.first; iter != range.second; ++iter)
140  {
141  const auto cluskey = iter->first;
142  const auto cluster = iter->second;
143  const auto it = m_layerRegionMap.find(TrkrDefs::getLayer(cluskey));
144  int region = it->second;
145  const auto hiter = histos.find(region);
146  if (hiter == histos.end())
147  {
148  continue;
149  }
150 
151  fill(hiter->second.crphisize, cluster->getPhiSize());
152  fill(hiter->second.czsize, cluster->getZSize());
153  fill(hiter->second.crphierr, cluster->getRPhiError());
154  fill(hiter->second.czerr, cluster->getZError());
155  fill(hiter->second.cedge, cluster->getEdge());
156  fill(hiter->second.coverlap, cluster->getOverlap());
157 
158  numclusters++;
159  }
160 
161  nclusperevent[sector] += numclusters;
162  h_totalclusters->Fill(hitsetkeynum, numclusters);
163  m_totalClusters += numclusters;
164  hitsetkeynum++;
165  }
166  for (int i = 0; i < 24; i++)
167  {
168  h_clusterssector->Fill(i, nclusperevent[i]);
169  }
170  m_event++;
172 }
173 
175 {
177  assert(hm);
178 
179  TH2 *h_totalclusters = dynamic_cast<TH2 *>(hm->getHisto(Form("%snclusperrun", getHistoPrefix().c_str())));
180  h_totalclusters->Fill(runnumber, (float) m_totalClusters / m_event);
182 }
183 //____________________________________________________________________________..
185 {
187 }
188 
190 {
191  return std::string("h_") + Name() + std::string("_");
192 }
194 {
196  assert(hm);
197  {
198  auto h = new TH2F(Form("%snclusperrun", getHistoPrefix().c_str()),
199  "TPC Clusters per event per run number", 10000, 23000, 33000, 1000, 0, 1000);
200  h->GetXaxis()->SetTitle("Run number");
201  h->GetYaxis()->SetTitle("Clusters per event");
202  hm->registerHisto(h);
203  }
204  {
205  auto h = new TH2F(Form("%sncluspersector", getHistoPrefix().c_str()),
206  "TPC Clusters per event per sector", 24, 0, 24, 1000, 0, 1000);
207  h->GetXaxis()->SetTitle("Sector number");
208  h->GetYaxis()->SetTitle("Clusters per event");
209  hm->registerHisto(h);
210  }
211  for (auto &region : {0, 1, 2})
212  {
213  {
214  auto h = new TH1F(Form("%sphisize_%i", getHistoPrefix().c_str(), region),
215  Form("TPC cluster #phi size region_%i", region), 10, 0, 10);
216  h->GetXaxis()->SetTitle("Cluster #phi_{size}");
217  hm->registerHisto(h);
218  }
219  {
220  auto h = new TH1F(Form("%szsize_%i", getHistoPrefix().c_str(), region),
221  Form("TPC cluster z size region_%i", region), 10, 0, 10);
222  h->GetXaxis()->SetTitle("Cluster z_{size}");
223  hm->registerHisto(h);
224  }
225  {
226  auto h = new TH1F(Form("%srphi_error_%i", getHistoPrefix().c_str(), region),
227  Form("TPC r#Delta#phi error region_%i", region), 100, 0, 0.075);
228  h->GetXaxis()->SetTitle("r#Delta#phi error [cm]");
229  hm->registerHisto(h);
230  }
231  {
232  auto h = new TH1F(Form("%sz_error_%i", getHistoPrefix().c_str(), region),
233  Form("TPC z error region_%i", region), 100, 0, 0.18);
234  h->GetXaxis()->SetTitle("z error [cm]");
235  hm->registerHisto(h);
236  }
237  {
238  auto h = new TH1F(Form("%sclusedge_%i", getHistoPrefix().c_str(), region),
239  Form("TPC hits on edge_%i", region), 30, 0, 30);
240  h->GetXaxis()->SetTitle("Cluster edge");
241  hm->registerHisto(h);
242  }
243  {
244  auto h = new TH1F(Form("%sclusoverlap_%i", getHistoPrefix().c_str(), region),
245  Form("TPC clus overlap_%i", region), 30, 0, 30);
246  h->GetXaxis()->SetTitle("Cluster overlap");
247  hm->registerHisto(h);
248  }
249  }
250 
251  {
252  auto h = new TH2F(Form("%stotal_clusters", getHistoPrefix().c_str()),
253  "TPC clusters per hitsetkey", 1152, 0, 1152, 10000, 0, 10000);
254  h->GetXaxis()->SetTitle("Hitsetkey number");
255  h->GetYaxis()->SetTitle("Number of clusters");
256  hm->registerHisto(h);
257  }
258 
259  return;
260 }