Belle II Software  release-08-01-10
hitMapMaker.cc
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 // Own header.
10 #include <arich/modules/arichDQM/hitMapMaker.h>
11 
12 // ARICH
13 #include <arich/dbobjects/ARICHChannelMapping.h>
14 #include <arich/dbobjects/ARICHMergerMapping.h>
15 #include <arich/dataobjects/ARICHHit.h>
16 
17 #include <mdst/dataobjects/Track.h>
18 
19 // Dataobject classes
20 #include <framework/database/DBObjPtr.h>
21 
22 #include <TH1F.h>
23 #include <TH2F.h>
24 #include <TCanvas.h>
25 #include <TStyle.h>
26 #include <TColor.h>
27 #include <TExec.h>
28 
29 #include <vector>
30 #include <fstream>
31 
32 namespace Belle2 {
38  TH2* moduleHitMap(TH1* hitMap, int moduleID)
39  {
40 
41  int m_moduleID = moduleID;
42 
44 
45  TH2* m_moduleHitMap = new TH2D(Form("HAPDHitMapMod%d", moduleID), Form("HAPD hit map module %d;nChX;nChY", moduleID), 12, 0.5, 12.5,
46  12,
47  0.5, 12.5);
48  TH1* m_hitMap = hitMap;
49 
50  for (int i = 0; i < 144; i++) {
51  int hitsNum = m_hitMap->GetBinContent((m_moduleID - 1) * 144 + i);
52  int xChn, yChn;
53  arichChMap->getXYFromAsic(i, xChn, yChn);
54  if (hitsNum != 0) {
55  m_moduleHitMap->Fill(xChn + 1, yChn + 1, hitsNum);
56  }
57  }
58 
59  return m_moduleHitMap;
60  }
61 
62  TH2* moduleDeadMap(TH1* hitMap, int moduleID)
63  {
64  int m_moduleID = moduleID;
65 
67 
68  TH2* m_moduleDeadMap = new TH2D(Form("HAPDDeadMapMod%d", moduleID), Form("HAPD alive/dead module %d;nChX;nChY", moduleID), 2, 0.5,
69  2.5,
70  2, 0.5, 2.5);
71  TH1* m_hitMap = hitMap;
72 
73  int deadCh[2][2] = {};
74 
75  for (int i = 0; i < 144; i++) {
76  int hitsNum = m_hitMap->GetBinContent((m_moduleID - 1) * 144 + i);
77  int xChn, yChn;
78  arichChMap->getXYFromAsic(i, xChn, yChn);
79  if (hitsNum == 0) deadCh[(int)xChn / 6][(int)yChn / 6]++;
80  }
81 
82  for (int j = 0; j < 2; j++) {
83  for (int k = 0; k < 2; k++) {
84  if (deadCh[j][k] > 18) {
85  m_moduleDeadMap->Fill(j + 1, k + 1, 1);
86  } else {
87  m_moduleDeadMap->Fill(j + 1, k + 1, 10);
88  }
89  }
90  }
91 
92  return m_moduleDeadMap;
93  }
94 
95  TH1* mergerClusterHitMap1D(TH1* hitMap, int mergerID)
96  {
97 
98  int m_mergerID = mergerID;
99 
101  DBObjPtr<ARICHMergerMapping> arichMergerMap;
102 
103  TH1* m_hitMap = hitMap;
104 
105  std::vector<int> moduleIDs;
106  for (int i = 1; i < 7; i++) {
107  moduleIDs.push_back(arichMergerMap->getModuleID(m_mergerID, i));
108  }
109 
110  TH1D* m_mergerHitMap1D = new TH1D("MergerHitMap1D", Form("Hit map in Merger Board %d", m_mergerID), 144 * 6, -0.5, 144 * 6 - 0.5);
111  for (int i = 1; i < 7; i++) {
112  for (int j = 0; j < 144; j++) {
113  int hitsNum = m_hitMap->GetBinContent((moduleIDs[i] - 1) * 144 + i);
114  m_mergerHitMap1D->Fill(144 * (i - 1) + j, hitsNum);
115  }
116  }
117  return m_mergerHitMap1D;
118  }
119 
120  TCanvas* mergerClusterHitMap2D(TH1* hitMap, int mergerID)
121  {
122  int m_mergerID = mergerID;
123 
125  DBObjPtr<ARICHMergerMapping> arichMergerMap;
126 
127  TH1* m_hitMap = hitMap;
128 
129 
130  std::vector<int> moduleIDs;
131  for (int i = 1; i < 7; i++) {
132  moduleIDs.push_back(arichMergerMap->getModuleID(m_mergerID, i));
133  }
134 
135  TCanvas* m_mergerHitMap = new TCanvas("MergerHitMap", "Hit map in Merger Board", 600, 400);
136  m_mergerHitMap->Divide(3, 2);
137  for (int i = 1; i < 7; i++) {
138  m_mergerHitMap->cd(i);
139  moduleHitMap(m_hitMap, moduleIDs[i])->Draw("coloz");
140  }
141  return m_mergerHitMap;
142  }
143 
144  TCanvas* sectorHitMap(TH1* hitMap, int sector)
145  {
146  // TH1* m_hitMap = NULL;
147  TH2* m_moduleHitMap = NULL;
148 
149  //m_hitMap = hitMap;
150  TPad* p_hitMaps[421] = {};
151  TCanvas* m_sectorHitMap = new TCanvas(Form("c_hitMap%d", sector - 1), Form("Hit map of sector%d", sector - 1), 600, 400);
152  for (int i = 1; i < 421; i++) {
153  for (int iRing = 0; iRing < 7; iRing++) {
154  if (((iRing + 13)*iRing / 2) * 6 + (iRing + 7) * (sector - 1) < i && i <= ((iRing + 13)*iRing / 2) * 6 + (iRing + 7) * (sector)) {
155  m_sectorHitMap->cd();
156  p_hitMaps[i] = new TPad(Form("p_hitMap%d", i), "",
157  (double)((double)(6 - iRing) / 2 + ((i - ((iRing + 13)*iRing / 2) * 6 + (iRing + 7) * (sector - 1) - 1) % (iRing + 7))) / 13,
158  (double)iRing / 7, (double)((double)(8 - iRing) / 2 + ((i - ((iRing + 13)*iRing / 2) * 6 + (iRing + 7) * (sector - 1) - 1) %
159  (iRing + 7))) / 13, (double)(iRing + 1) / 7);
160  p_hitMaps[i]->Draw();
161  p_hitMaps[i]->SetNumber(i);
162  m_sectorHitMap->cd(i);
163  m_moduleHitMap = moduleHitMap(hitMap, i);
164  m_moduleHitMap->SetTitleSize(0, "xyz");
165  m_moduleHitMap->SetTitle(0);
166  m_moduleHitMap->SetLineWidth(1);
167  gStyle->SetLabelColor(0, "xyz");
168  m_moduleHitMap->SetStats(0);
169  m_moduleHitMap->Draw("col");
170  }
171  }
172  }
173  return m_sectorHitMap;
174  }
175 
176  TCanvas* sectorDeadMap(TH1* hitMap, int sector)
177  {
178  //TH1* m_hitMap = NULL;
179  TH2* m_moduleDeadMap = NULL;
180  TExec* ex1 = NULL;
181 
182  //m_hitMap = hitMap;
183  TPad* p_hitMaps[421] = {};
184  TCanvas* m_sectorDeadMap = new TCanvas(Form("c_deadMap%d", sector - 1), Form("Dead chip map of sector%d", sector - 1), 600, 400);
185  for (int i = 1; i < 421; i++) {
186  for (int iRing = 0; iRing < 7; iRing++) {
187  if (((iRing + 13)*iRing / 2) * 6 + (iRing + 7) * (sector - 1) < i && i <= ((iRing + 13)*iRing / 2) * 6 + (iRing + 7) * (sector)) {
188  m_sectorDeadMap->cd();
189  p_hitMaps[i] = new TPad(Form("p_deadMap%d", i), "",
190  (double)((double)(6 - iRing) / 2 + ((i - ((iRing + 13)*iRing / 2) * 6 + (iRing + 7) * (sector - 1) - 1) % (iRing + 7))) / 13,
191  (double)iRing / 7, (double)((double)(8 - iRing) / 2 + ((i - ((iRing + 13)*iRing / 2) * 6 + (iRing + 7) * (sector - 1) - 1) %
192  (iRing + 7))) / 13, (double)(iRing + 1) / 7);
193  p_hitMaps[i]->Draw();
194  p_hitMaps[i]->SetNumber(i);
195  m_sectorDeadMap->cd(i);
196  m_moduleDeadMap = moduleDeadMap(hitMap, i);
197  m_moduleDeadMap->SetTitleSize(0, "xyz");
198  m_moduleDeadMap->SetTitle(0);
199  m_moduleDeadMap->SetLineWidth(1);
200  m_moduleDeadMap->SetStats(0);
201  gStyle->SetLabelColor(0, "xyz");
202  ex1 = new TExec("ex1", "deadPalette();");
203  ex1->Draw();
204  m_moduleDeadMap->Draw("colz");
205  }
206  }
207  }
208  return m_sectorDeadMap;
209  }
210 
211  void deadPalette()
212  {
213  static Int_t colors[50];
214  static Bool_t initialized = kFALSE;
215  Double_t Red[3] = { 1.00, 0.00, 0.00};
216  Double_t Green[3] = { 0.00, 0.00, 0.00};
217  Double_t Blue[3] = { 0.00, 1.00, 1.00};
218  Double_t Length[3] = { 0.00, 0.20, 1.00 };
219  if (!initialized) {
220  Int_t FI = TColor::CreateGradientColorTable(3, Length, Red, Green, Blue, 50);
221  for (int i = 0; i < 50; i++) colors[i] = FI + i;
222  initialized = kTRUE;
223  return;
224  }
225  gStyle->SetPalette(50, colors);
226  }
227 
229 }
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
TH2 * moduleHitMap(TH1 *hitMap, int moduleID)
Make hit map in HAPD view (12*12 channels)
Definition: hitMapMaker.cc:38
TH2 * moduleDeadMap(TH1 *hitMap, int moduleID)
Make chip dead/alive map in HAPD view (2*2 chips)
Definition: hitMapMaker.cc:62
TCanvas * mergerClusterHitMap2D(TH1 *hitMap, int mergerID)
Make display of 6 HAPDs' 2D hit map of the Merger Board.
Definition: hitMapMaker.cc:120
TH1 * mergerClusterHitMap1D(TH1 *hitMap, int mergerID)
Make 1D hit map of specified Merger Board.
Definition: hitMapMaker.cc:95
TCanvas * sectorDeadMap(TH1 *hitMap, int sector)
Make display of 70 HAPDs' 2D dead/alive map of the sector.
Definition: hitMapMaker.cc:176
TCanvas * sectorHitMap(TH1 *hitMap, int sector)
Make display of 70 HAPDs' 2D hit map of the sector.
Definition: hitMapMaker.cc:144
Abstract base class for different kinds of events.