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