Belle II Software development
vxdDigitMaskingModule.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#include "vxd/modules/vxdMask/vxdDigitMaskingModule.h"
10
11#include <framework/datastore/StoreArray.h>
12
13#include <svd/dataobjects/SVDShaperDigit.h>
14#include <pxd/dataobjects/PXDDigit.h>
15
16#include <pxd/online/PXDIgnoredPixelsMap.h>
17#include <svd/online/SVDIgnoredStripsMap.h>
18
19#include <pxd/geometry/SensorInfo.h>
20#include <svd/geometry/SensorInfo.h>
21
22#include <vxd/geometry/GeoCache.h>
23#include <vxd/geometry/SensorInfoBase.h>
24
25#include <boost/format.hpp>
26
27#include "TDirectory.h"
28
29using namespace std;
30using boost::format;
31using namespace Belle2;
32
33//-----------------------------------------------------------------
34// Register the Module
35//-----------------------------------------------------------------
36REG_MODULE(vxdDigitMasking);
37
38
39//-----------------------------------------------------------------
40// Implementation
41//-----------------------------------------------------------------
42
44{
45 //Set module properties
46 setDescription("vxdDigitMasking of pixels and strips in PXD and SVD base on their fireing");
47 setPropertyFlags(c_ParallelProcessingCertified); // specify this flag if you need parallel processing
48
49 addParam("histogramDirectoryName", m_histogramDirectoryName, "Name of the directory where histograms will be placed",
50 std::string("maskVXD"));
52 addParam("nEventsProcess", m_nEventsProcess, "Number of events to process", m_nEventsProcess);
54 addParam("AppendMaskFile", m_AppendMaskFile, "Set option for append of existing file or recreate new list", m_AppendMaskFile);
55
56 addParam("PXDChargeCut", m_PXDChargeCut, "Cut for Charge of PXD pixel", m_PXDChargeCut);
57 addParam("SVDuChargeCut", m_SVDuChargeCut, "Cut for Charge of SVD U strip", m_SVDuChargeCut);
58 addParam("SVDvChargeCut", m_SVDvChargeCut, "Cut for Charge of SVD V strip", m_SVDvChargeCut);
59
60 addParam("PXDCut", m_PXDCut, "Cut for masking of PXD pixel - preset for 1 kEvent", m_PXDCut);
61 addParam("SVDuCut", m_SVDuCut, "Cut for masking of SVD U strip - preset for 1 kEvent", m_SVDuCut);
62 addParam("SVDvCut", m_SVDvCut, "Cut for masking of SVD V strip - preset for 1 kEvent", m_SVDvCut);
63
64 addParam("PXDMaskFileBasicName", m_PXDMaskFileBasicName, "Name of file with list of masked channels",
65 std::string("PXD_MaskFiredBasic.xml"));
66 addParam("SVDMaskFileBasicName", m_SVDMaskFileBasicName, "Name of file with list of masked channels",
67 std::string("SVD_MaskFiredBasic.xml"));
68 addParam("PXDMaskFileRunName", m_PXDMaskFileRunName, "Name of file with list of masked channels",
69 std::string("PXD_MaskFired_RunXXX.xml"));
70 addParam("SVDMaskFileRunName", m_SVDMaskFileRunName, "Name of file with list of masked channels",
71 std::string("SVD_MaskFired_RunXXX.xml"));
72}
73
74
75vxdDigitMaskingModule::~vxdDigitMaskingModule()
76{
77}
78
79//------------------------------------------------------------------
80// Function to define histograms
81//-----------------------------------------------------------------
82
84{
86 if (gTools->getNumberOfLayers() == 0) {
87 B2WARNING("Missing geometry for VXD, check steering file.");
88 return;
89 }
90 if (gTools->getNumberOfPXDLayers() == 0) {
91 B2WARNING("Missing geometry for PXD, PXD-masking is skiped.");
92 }
93 if (gTools->getNumberOfSVDLayers() == 0) {
94 B2WARNING("Missing geometry for SVD, SVD-masking is skiped.");
95 }
96
97 // Create a separate histogram directories and cd into it.
98 TDirectory* oldDir = gDirectory;
99 if (m_histogramDirectoryName != "") {
100 oldDir->mkdir(m_histogramDirectoryName.c_str());// do not use return value with ->cd(), its ZERO if dir already exists
101 oldDir->cd(m_histogramDirectoryName.c_str());
102 }
103
104 int nPXDSensors = gTools->getNumberOfPXDSensors();
105 if (gTools->getNumberOfPXDLayers() != 0) {
106 m_PXDHitMapUV = new TH2F*[nPXDSensors];
107 m_PXDMaskUV = new TH2F*[nPXDSensors];
108
109 for (int i = 0; i < nPXDSensors; i++) {
110 VxdID id = gTools->getSensorIDFromPXDIndex(i);
111 int iLayer = id.getLayerNumber();
112 int iLadder = id.getLadderNumber();
113 int iSensor = id.getSensorNumber();
114 VxdID sensorID(iLayer, iLadder, iSensor);
115 PXD::SensorInfo SensorInfo = dynamic_cast<const PXD::SensorInfo&>(VXD::GeoCache::getInstance().getSensorInfo(sensorID));
116 string sensorDescr = str(format("%1%_%2%_%3%") % iLayer % iLadder % iSensor);
117
118 int nPixelsU = SensorInfo.getUCells();
119 int nPixelsV = SensorInfo.getVCells();
120 //----------------------------------------------------------------
121 // Hitmaps: Number of pixels by coordinate
122 //----------------------------------------------------------------
123 string name = str(format("PXD_%1%_PixelHitmap") % sensorDescr);
124 string title = str(format("PXD Sensor %1% Pixel Hitmap") % sensorDescr);
125 m_PXDHitMapUV[i] = new TH2F(name.c_str(), title.c_str(), nPixelsU, 0, nPixelsU, nPixelsV, 0, nPixelsV);
126 m_PXDHitMapUV[i]->GetXaxis()->SetTitle("u position [pitch units]");
127 m_PXDHitMapUV[i]->GetYaxis()->SetTitle("v position [pitch units]");
128 m_PXDHitMapUV[i]->GetZaxis()->SetTitle("hits");
129
130 name = str(format("PXD_%1%_PixelMaskmap") % sensorDescr);
131 title = str(format("PXD Sensor %1% Pixel Maskmap") % sensorDescr);
132 m_PXDMaskUV[i] = new TH2F(name.c_str(), title.c_str(), nPixelsU, 0, nPixelsU, nPixelsV, 0, nPixelsV);
133 m_PXDMaskUV[i]->GetXaxis()->SetTitle("u position [pitch units]");
134 m_PXDMaskUV[i]->GetYaxis()->SetTitle("v position [pitch units]");
135 m_PXDMaskUV[i]->GetZaxis()->SetTitle("mask");
136 }
137 }
138 int nSVDSensors = gTools->getNumberOfSVDSensors();
139 if (gTools->getNumberOfPXDLayers() != 0) {
140 m_SVDHitMapU = new TH1F*[nSVDSensors];
141 m_SVDHitMapV = new TH1F*[nSVDSensors];
142 m_SVDHitMapU2 = new TH1F*[nSVDSensors];
143 m_SVDHitMapV2 = new TH1F*[nSVDSensors];
144 m_SVDMaskU = new TH1F*[nSVDSensors];
145 m_SVDMaskV = new TH1F*[nSVDSensors];
146 m_SVDMaskU2 = new TH1F*[nSVDSensors];
147 m_SVDMaskV2 = new TH1F*[nSVDSensors];
148
149 for (int i = 0; i < nSVDSensors; i++) {
150 VxdID id = gTools->getSensorIDFromSVDIndex(i);
151 int iLayer = id.getLayerNumber();
152 int iLadder = id.getLadderNumber();
153 int iSensor = id.getSensorNumber();
154 VxdID sensorID(iLayer, iLadder, iSensor);
155 SVD::SensorInfo SensorInfo = dynamic_cast<const SVD::SensorInfo&>(VXD::GeoCache::getInstance().getSensorInfo(sensorID));
156 string sensorDescr = str(format("%1%_%2%_%3%") % iLayer % iLadder % iSensor);
157
158 int nStripsU = SensorInfo.getUCells();
159 int nStripsV = SensorInfo.getVCells();
160 //----------------------------------------------------------------
161 // Hitmaps: Number of strips by coordinate
162 //----------------------------------------------------------------
163 string name = str(format("SVD_%1%_StripHitmapU") % sensorDescr);
164 string title = str(format("SVD Sensor %1% Strip Hitmap in U") % sensorDescr);
165 m_SVDHitMapU[i] = new TH1F(name.c_str(), title.c_str(), nStripsU, 0, nStripsU);
166 m_SVDHitMapU[i]->GetXaxis()->SetTitle("u position [pitch units]");
167 m_SVDHitMapU[i]->GetYaxis()->SetTitle("hits");
168 name = str(format("SVD_%1%_StripHitmapV") % sensorDescr);
169 title = str(format("SVD Sensor %1% Strip Hitmap in V") % sensorDescr);
170 m_SVDHitMapV[i] = new TH1F(name.c_str(), title.c_str(), nStripsV, 0, nStripsV);
171 m_SVDHitMapV[i]->GetXaxis()->SetTitle("v position [pitch units]");
172 m_SVDHitMapV[i]->GetYaxis()->SetTitle("hits");
173
174 name = str(format("SVD_%1%_StripMaskmapU") % sensorDescr);
175 title = str(format("SVD Sensor %1% Strip Maskmap in U") % sensorDescr);
176 m_SVDMaskU[i] = new TH1F(name.c_str(), title.c_str(), nStripsU, 0, nStripsU);
177 m_SVDMaskU[i]->GetXaxis()->SetTitle("u position [pitch units]");
178 m_SVDMaskU[i]->GetYaxis()->SetTitle("mask");
179 name = str(format("SVD_%1%_StripMaskmapV") % sensorDescr);
180 title = str(format("SVD Sensor %1% Strip Maskmap in V") % sensorDescr);
181 m_SVDMaskV[i] = new TH1F(name.c_str(), title.c_str(), nStripsV, 0, nStripsV);
182 m_SVDMaskV[i]->GetXaxis()->SetTitle("v position [pitch units]");
183 m_SVDMaskV[i]->GetYaxis()->SetTitle("mask");
184
185 name = str(format("SVD_%1%_StripHitmapU2") % sensorDescr);
186 title = str(format("SVD Sensor %1% Strip Hitmap 2 samples in U") % sensorDescr);
187 m_SVDHitMapU2[i] = new TH1F(name.c_str(), title.c_str(), nStripsU, 0, nStripsU);
188 m_SVDHitMapU2[i]->GetXaxis()->SetTitle("u position [pitch units]");
189 m_SVDHitMapU2[i]->GetYaxis()->SetTitle("hits");
190 name = str(format("SVD_%1%_StripHitmapV2") % sensorDescr);
191 title = str(format("SVD Sensor %1% Strip Hitmap 2 samples in V") % sensorDescr);
192 m_SVDHitMapV2[i] = new TH1F(name.c_str(), title.c_str(), nStripsV, 0, nStripsV);
193 m_SVDHitMapV2[i]->GetXaxis()->SetTitle("v position [pitch units]");
194 m_SVDHitMapV2[i]->GetYaxis()->SetTitle("hits");
195
196 name = str(format("SVD_%1%_StripMaskmapU2") % sensorDescr);
197 title = str(format("SVD Sensor %1% Strip Maskmap 2 samples in U") % sensorDescr);
198 m_SVDMaskU2[i] = new TH1F(name.c_str(), title.c_str(), nStripsU, 0, nStripsU);
199 m_SVDMaskU2[i]->GetXaxis()->SetTitle("u position [pitch units]");
200 m_SVDMaskU2[i]->GetYaxis()->SetTitle("mask");
201 name = str(format("SVD_%1%_StripMaskmapV2") % sensorDescr);
202 title = str(format("SVD Sensor %1% Strip Maskmap 2 samples in V") % sensorDescr);
203 m_SVDMaskV2[i] = new TH1F(name.c_str(), title.c_str(), nStripsV, 0, nStripsV);
204 m_SVDMaskV2[i]->GetXaxis()->SetTitle("v position [pitch units]");
205 m_SVDMaskV2[i]->GetYaxis()->SetTitle("mask");
206
207 }
208 }
209 m_nEventsPlane = new long[nPXDSensors + nSVDSensors];
210 // cd back to root directory
211 oldDir->cd();
212}
213
214
216{
217 //Register histograms (calls back defineHisto)
218 REG_HISTOGRAM
219
220 auto gTools = VXD::GeoCache::getInstance().getGeoTools();
221 if (gTools->getNumberOfPXDLayers() != 0) {
222 //Register collections
224 //Store names to speed up creation later
225 m_storePXDDigitsName = storePXDDigits.getName();
226 }
227 if (gTools->getNumberOfSVDLayers() != 0) {
228 //Register collections
230 //Store names to speed up creation later
231 m_storeSVDShaperDigitsName = storeSVDDigits.getName();
232 }
233}
234
236{
237 auto gTools = VXD::GeoCache::getInstance().getGeoTools();
238 int nPXDSensors = gTools->getNumberOfPXDSensors();
239 int nSVDSensors = gTools->getNumberOfSVDSensors();
241 for (int i = 0; i < (nPXDSensors + nSVDSensors); i++) {
242 m_nEventsPlane[i] = 0;
243 }
244}
245
246
248{
250 auto gTools = VXD::GeoCache::getInstance().getGeoTools();
251 int nPXDSensors = gTools->getNumberOfPXDSensors();
252 if (gTools->getNumberOfPXDLayers() != 0) {
253 const StoreArray<PXDDigit> storePXDDigits(m_storePXDDigitsName);
254 // If there are no digits, leave
255 if (storePXDDigits && storePXDDigits.getEntries()) {
256 int firstPXDLayer = gTools->getFirstPXDLayer();
257 int lastPXDLayer = gTools->getLastPXDLayer();
258
259 for (const PXDDigit& digit : storePXDDigits) {
260 if (digit.getCharge() < m_PXDChargeCut) continue;
261 int iLayer = digit.getSensorID().getLayerNumber();
262 if ((iLayer < firstPXDLayer) || (iLayer > lastPXDLayer)) continue;
263 int iLadder = digit.getSensorID().getLadderNumber();
264 int iSensor = digit.getSensorID().getSensorNumber();
265 VxdID sensorID(iLayer, iLadder, iSensor);
266 int index = gTools->getPXDSensorIndex(sensorID);
267 if (m_PXDHitMapUV[index] != NULL) m_PXDHitMapUV[index]->Fill(digit.getUCellID(), digit.getVCellID());
268 m_nEventsPlane[index]++;
269 }
270 }
271 }
272 if (gTools->getNumberOfSVDLayers() != 0) {
274 // If there are no digits, leave
275 if (storeSVDDigits && storeSVDDigits.getEntries()) {
276 int firstSVDLayer = gTools->getFirstSVDLayer();
277 int lastSVDLayer = gTools->getLastSVDLayer();
278
279 for (const SVDShaperDigit& digit : storeSVDDigits) {
280 int iLayer = digit.getSensorID().getLayerNumber();
281 if ((iLayer < firstSVDLayer) || (iLayer > lastSVDLayer)) continue;
282 int iLadder = digit.getSensorID().getLadderNumber();
283 int iSensor = digit.getSensorID().getSensorNumber();
284 VxdID sensorID(iLayer, iLadder, iSensor);
285 int index = gTools->getSVDSensorIndex(sensorID);
286 SVDShaperDigit::APVFloatSamples samples = digit.getSamples();
287
288 if (digit.isUStrip()) {
289 int iCont = 0;
290 for (size_t i = 0; i < SVDShaperDigit::c_nAPVSamples; ++i) {
291 float fCharge1 = samples[i];
292 if (fCharge1 > m_SVDuChargeCut)
293 iCont++;
294 }
295 if (iCont == 1) {
296 if (m_SVDHitMapU[index] != NULL) m_SVDHitMapU[index]->Fill(digit.getCellID());
297 m_nEventsPlane[nPXDSensors + index]++;
298 }
299 if (iCont > 1)
300 if (m_SVDHitMapU2[index] != NULL) m_SVDHitMapU2[index]->Fill(digit.getCellID());
301 } else {
302 int iCont = 0;
303 for (size_t i = 0; i < SVDShaperDigit::c_nAPVSamples; ++i) {
304 float fCharge1 = samples[i];
305 if (fCharge1 > m_SVDvChargeCut)
306 iCont++;
307 }
308 if (iCont == 1) {
309 if (m_SVDHitMapV[index] != NULL) m_SVDHitMapV[index]->Fill(digit.getCellID());
310 m_nEventsPlane[nPXDSensors + index]++;
311 }
312 if (iCont > 1)
313 if (m_SVDHitMapV2[index] != NULL) m_SVDHitMapV2[index]->Fill(digit.getCellID());
314 }
315 }
316 }
317 }
318}
319
321{
322
323 auto gTools = VXD::GeoCache::getInstance().getGeoTools();
324
325 if (m_nRealEventsProcess < 500) {
326 TString message = Form("Not enough data: %li < 500, terminate without masking file create.", m_nRealEventsProcess);
327 B2WARNING(message.Data());
328 return;
329 }
331
332 // Maskin border for all sensors at 1000 events!:
333 float PXDCut = m_PXDCut;
334
335 float SVDUCut = m_SVDuCut;
336 float SVDVCut = m_SVDvCut;
337
338 // correction for unmerged events and different No. of proces events:
339 PXDCut *= m_nEventsProcessFraction * m_nEventsProcess / 1000.0;
340 SVDUCut *= m_nEventsProcessFraction * m_nEventsProcess / 1000.0;
341 SVDVCut *= m_nEventsProcessFraction * m_nEventsProcess / 1000.0;
342
343 FILE* MaskList;
344
345 int nPXDSensors = gTools->getNumberOfPXDSensors();
346 int nSVDSensors = gTools->getNumberOfSVDSensors();
347 if (gTools->getNumberOfPXDLayers() != 0) {
348 TString message = Form("Start to create masking from %i events (fraction: %6.3f)", (int)m_nRealEventsProcess,
350 B2INFO(message.Data());
351
352 std::string FileName = str(format("%1%") % m_PXDMaskFileBasicName);
353 std::string ignoredPixelsListName = str(format("%1%") % FileName);
354 std::unique_ptr<PXDIgnoredPixelsMap> m_ignoredPixelsBasicList = unique_ptr<PXDIgnoredPixelsMap>(new PXDIgnoredPixelsMap(
355 ignoredPixelsListName));
356 FileName = str(format("%1%") % m_PXDMaskFileRunName);
357 ignoredPixelsListName = str(format("%1%") % FileName);
358 std::unique_ptr<PXDIgnoredPixelsMap> m_ignoredPixelsList = unique_ptr<PXDIgnoredPixelsMap>(new PXDIgnoredPixelsMap(
359 ignoredPixelsListName));
360 MaskList = fopen(FileName.data(), "w");
361 fprintf(MaskList, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
362 fprintf(MaskList, "<Meta>\n");
363 fprintf(MaskList, " <Date>19.02.2018</Date>\n");
364 fprintf(MaskList, " <Description short=\"Ignore strip list for PXD planes in 2018 VXD phase2 and phase3\">\n");
365 fprintf(MaskList, " Crude initial list of bad pixels\n");
366 fprintf(MaskList, " </Description>\n");
367 fprintf(MaskList, " <Author>Peter Kodys</Author>\n");
368 fprintf(MaskList, "</Meta>\n");
369 fprintf(MaskList, "<PXD>\n");
370 for (int i = 0; i < nPXDSensors; i++) {
371 if (m_nEventsPlane[i] == 0) continue;
372 VxdID id = gTools->getSensorIDFromPXDIndex(i);
373 int iLayer = id.getLayerNumber();
374 int iLadder = id.getLadderNumber();
375 int iSensor = id.getSensorNumber();
376 fprintf(MaskList, " <layer n=\"%i\">\n", iLayer);
377 fprintf(MaskList, " <ladder n=\"%i\">\n", iLadder);
378 fprintf(MaskList, " <sensor n=\"%i\">\n", iSensor);
379 fprintf(MaskList, " <!-- vxdDigitMasking rectangular parts of the sensor -->\n");
380 fprintf(MaskList, " <!--pixels uStart = \"070\" uEnd = \"110\" vStart = \"0\" vEnd = \"500\"></pixels-->\n");
381 fprintf(MaskList, "\n");
382 fprintf(MaskList, " <!-- Individual pixels can be masked, too -->\n");
383 fprintf(MaskList, " <!--pixels uStart = \"130\" vStart = \"500\"></pixels-->\n");
384 fprintf(MaskList, "\n");
385 fprintf(MaskList, " <!-- ROW is V / COLUMN is U -->\n");
386 fprintf(MaskList, "\n");
387 fprintf(MaskList, " <!-- Individual rows and columns can be masked, too -->\n");
388 fprintf(MaskList, " <!--pixels vStart = \"500\"></pixels-->\n");
389 fprintf(MaskList, " <!--pixels uStart = \"120\"></pixels-->\n");
390 fprintf(MaskList, "\n");
391 fprintf(MaskList, " <!-- Ranges of rows and columns can be masked, too -->\n");
392 fprintf(MaskList, " <!--pixels vStart = \"100\" vEnd = \"120\"></pixels-->\n");
393 fprintf(MaskList, " <!--pixels uStart = \"120\" uEnd = \"202\"></pixels-->\n");
394 fprintf(MaskList, "\n");
395 for (int i1 = 0; i1 < m_PXDMaskUV[i]->GetNbinsX(); ++i1) {
396 for (int i2 = 0; i2 < m_PXDMaskUV[i]->GetNbinsY(); ++i2) {
397 int ExistMask = 0;
398 if (m_AppendMaskFile) {
399 if (!m_ignoredPixelsBasicList->pixelOK(VxdID(iLayer, iLadder, iSensor), PXDIgnoredPixelsMap::map_pixel(i1, i2))) {
400 ExistMask += 1;
401 }
402 if (!m_ignoredPixelsList->pixelOK(VxdID(iLayer, iLadder, iSensor), PXDIgnoredPixelsMap::map_pixel(i1, i2))) {
403 ExistMask += 1;
404 }
405 }
406 if (ExistMask || (m_PXDHitMapUV[i]->GetBinContent(i1 + 1, i2 + 1) > PXDCut)) {
407 fprintf(MaskList, " <pixels uStart = \"%04i\" vStart = \"%04i\"></pixels>\n", i1, i2);
408 m_PXDMaskUV[i]->SetBinContent(i1 + 1, i2 + 1, 1 + ExistMask);
409 }
410 }
411 }
412 fprintf(MaskList, "\n");
413 fprintf(MaskList, " </sensor>\n");
414 fprintf(MaskList, " </ladder>\n");
415 fprintf(MaskList, " </layer>\n");
416 }
417 fprintf(MaskList, "</PXD>\n");
418 fclose(MaskList);
419 }
420
421 if (gTools->getNumberOfSVDLayers() != 0) {
422 std::string FileName = str(format("%1%") % m_SVDMaskFileBasicName);
423 std::string ignoredPixelsListName = str(format("%1%") % FileName);
424 std::unique_ptr<SVDIgnoredStripsMap> m_ignoredStripsBasicList = unique_ptr<SVDIgnoredStripsMap>(new SVDIgnoredStripsMap(
425 ignoredPixelsListName));
426 string FileName2 = str(format("%1%") % m_SVDMaskFileRunName);
427 string ignoredPixelsListName2 = str(format("%1%") % FileName2);
428 std::unique_ptr<SVDIgnoredStripsMap> m_ignoredStripsList = unique_ptr<SVDIgnoredStripsMap>(new SVDIgnoredStripsMap(
429 ignoredPixelsListName2));
430 MaskList = fopen(FileName2.data(), "w");
431 fprintf(MaskList, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
432 fprintf(MaskList, "<Meta>\n");
433 fprintf(MaskList, " <Date>19.02.2018</Date>\n");
434 fprintf(MaskList, " <Description short=\"Ignore strip list for SVD planes in 2018 VXD phase2 and phase3\">\n");
435 fprintf(MaskList, " Crude initial list of bad strips\n");
436 fprintf(MaskList, " </Description>\n");
437 fprintf(MaskList, " <Author>Peter Kodys</Author>\n");
438 fprintf(MaskList, "</Meta>\n");
439 fprintf(MaskList, "<SVD>\n");
440 for (int i = 0; i < nSVDSensors; i++) {
441 if (m_nEventsPlane[nPXDSensors + i] == 0) continue;
442 VxdID id = gTools->getSensorIDFromSVDIndex(i);
443 int iLayer = id.getLayerNumber();
444 int iLadder = id.getLadderNumber();
445 int iSensor = id.getSensorNumber();
446 fprintf(MaskList, " <layer n=\"%i\">\n", iLayer);
447 fprintf(MaskList, " <ladder n=\"%i\">\n", iLadder);
448 fprintf(MaskList, " <sensor n=\"%i\">\n", iSensor);
449 fprintf(MaskList, " <side side=\"u\">\n");
450 fprintf(MaskList, " <!-- stripsFromTo fromStrip = \"620\" toStrip = \"767\"></stripsFromTo-->\n");
451 fprintf(MaskList, " <!-- Individual strips can be masked, too -->\n");
452 int nMaskedU = 0;
453 int nMaskedV = 0;
454 for (int i1 = 0; i1 < m_SVDMaskU[i]->GetNbinsX(); ++i1) {
455 int ExistMask = 0;
456 if (m_AppendMaskFile) {
457 if (!m_ignoredStripsBasicList->stripOK(VxdID(iLayer, iLadder, iSensor, 1), (unsigned short) i1)) {
458 ExistMask += 1;
459 }
460 if (!m_ignoredStripsList->stripOK(VxdID(iLayer, iLadder, iSensor, 1), (unsigned short) i1)) {
461 ExistMask += 1;
462 }
463 }
464 int sTS = 0;
465 if (m_SVDHitMapU[i]->GetBinContent(i1 + 1) > SVDUCut)
466 sTS = 1;
467
468 if (ExistMask || (sTS)) {
469 fprintf(MaskList, " <strip stripNo = \"%i\"></strip>\n", i1);
470 m_SVDMaskU[i]->SetBinContent(i1 + 1, 1 + ExistMask);
471 nMaskedU++;
472 }
473 }
474 fprintf(MaskList, " </side>\n");
475 fprintf(MaskList, " <side side=\"v\">\n");
476 for (int i2 = 0; i2 < m_SVDMaskV[i]->GetNbinsX(); ++i2) {
477 int ExistMask = 0;
478 if (m_AppendMaskFile) {
479 if (!m_ignoredStripsBasicList->stripOK(VxdID(iLayer, iLadder, iSensor, 0), (unsigned short) i2)) {
480 ExistMask += 1;
481 }
482 if (!m_ignoredStripsList->stripOK(VxdID(iLayer, iLadder, iSensor, 0), (unsigned short) i2)) {
483 ExistMask += 1;
484 }
485 }
486 int sTS = 0;
487 if (m_SVDHitMapV[i]->GetBinContent(i2 + 1) > SVDVCut)
488 sTS = 1;
489
490 if (ExistMask || (sTS)) {
491 fprintf(MaskList, " <strip stripNo = \"%i\"></strip>\n", i2);
492 m_SVDMaskV[i]->SetBinContent(i2 + 1, 1 + ExistMask);
493 nMaskedV++;
494 }
495 }
496 fprintf(MaskList, " </side>\n");
497 fprintf(MaskList, " </sensor>\n");
498 TString message = Form("SVD(%i,%i,%i) masked %i U strips in: %s", iLayer, iLadder, iSensor, nMaskedU, ignoredPixelsListName.data());
499 B2INFO(message.Data());
500 message = Form("SVD(%i,%i,%i) masked %i V strips in: %s", iLayer, iLadder, iSensor, nMaskedV, ignoredPixelsListName.data());
501 B2INFO(message.Data());
502 fprintf(MaskList, " </ladder>\n");
503 fprintf(MaskList, " </layer>\n");
504 }
505 fprintf(MaskList, "</SVD>\n");
506 fclose(MaskList);
507
508//------------------------------------------------------------------
509// the same for 2 and more fired samples in strip
510//-----------------------------------------------------------------
511 FileName = str(format("%1%.2samples") % m_SVDMaskFileBasicName);
512 ignoredPixelsListName = str(format("%1%") % FileName);
513 std::unique_ptr<SVDIgnoredStripsMap> m_ignoredStripsBasicList2 = unique_ptr<SVDIgnoredStripsMap>(new SVDIgnoredStripsMap(
514 ignoredPixelsListName));
515 FileName2 = str(format("%1%.2samples") % m_SVDMaskFileRunName);
516 ignoredPixelsListName2 = str(format("%1%") % FileName2);
517 std::unique_ptr<SVDIgnoredStripsMap> m_ignoredStripsList2 = unique_ptr<SVDIgnoredStripsMap>(new SVDIgnoredStripsMap(
518 ignoredPixelsListName2));
519 MaskList = fopen(FileName2.data(), "w");
520 fprintf(MaskList, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
521 fprintf(MaskList, "<Meta>\n");
522 fprintf(MaskList, " <Date>19.02.2018</Date>\n");
523 fprintf(MaskList,
524 " <Description short=\"Ignore strip list for SVD planes for 2-samples and more over charge cut in 2018 VXD phase2 and phase3\">\n");
525 fprintf(MaskList, " Crude initial list of bad strips\n");
526 fprintf(MaskList, " </Description>\n");
527 fprintf(MaskList, " <Author>Peter Kodys</Author>\n");
528 fprintf(MaskList, "</Meta>\n");
529 fprintf(MaskList, "<SVD>\n");
530 for (int i = 0; i < nSVDSensors; i++) {
531 if (m_nEventsPlane[nPXDSensors + i] == 0) continue;
532 VxdID id = gTools->getSensorIDFromSVDIndex(i);
533 int iLayer = id.getLayerNumber();
534 int iLadder = id.getLadderNumber();
535 int iSensor = id.getSensorNumber();
536 fprintf(MaskList, " <layer n=\"%i\">\n", iLayer);
537 fprintf(MaskList, " <ladder n=\"%i\">\n", iLadder);
538 fprintf(MaskList, " <sensor n=\"%i\">\n", iSensor);
539 fprintf(MaskList, " <side side=\"u\">\n");
540 fprintf(MaskList, " <!-- stripsFromTo fromStrip = \"620\" toStrip = \"767\"></stripsFromTo-->\n");
541 fprintf(MaskList, " <!-- Individual strips can be masked, too -->\n");
542 int nMaskedU = 0;
543 int nMaskedV = 0;
544 for (int i1 = 0; i1 < m_SVDMaskU2[i]->GetNbinsX(); ++i1) {
545 int ExistMask = 0;
546 if (m_AppendMaskFile) {
547 if (!m_ignoredStripsBasicList2->stripOK(VxdID(iLayer, iLadder, iSensor, 1), (unsigned short) i1)) {
548 ExistMask += 1;
549 }
550 if (!m_ignoredStripsList2->stripOK(VxdID(iLayer, iLadder, iSensor, 1), (unsigned short) i1)) {
551 ExistMask += 1;
552 }
553 }
554 int sTS = 0;
555 if (m_SVDHitMapU2[i]->GetBinContent(i1 + 1) > SVDUCut)
556 sTS = 1;
557
558 if (ExistMask || (sTS)) {
559 fprintf(MaskList, " <strip stripNo = \"%i\"></strip>\n", i1);
560 m_SVDMaskU2[i]->SetBinContent(i1 + 1, 1 + ExistMask);
561 nMaskedU++;
562 }
563 }
564 fprintf(MaskList, " </side>\n");
565 fprintf(MaskList, " <side side=\"v\">\n");
566 for (int i2 = 0; i2 < m_SVDMaskV2[i]->GetNbinsX(); ++i2) {
567 int ExistMask = 0;
568 if (m_AppendMaskFile) {
569 if (!m_ignoredStripsBasicList2->stripOK(VxdID(iLayer, iLadder, iSensor, 0), (unsigned short) i2)) {
570 ExistMask += 1;
571 }
572 if (!m_ignoredStripsList2->stripOK(VxdID(iLayer, iLadder, iSensor, 0), (unsigned short) i2)) {
573 ExistMask += 1;
574 }
575 }
576 int sTS = 0;
577 if (m_SVDHitMapV2[i]->GetBinContent(i2 + 1) > SVDVCut)
578 sTS = 1;
579
580 if (ExistMask || (sTS)) {
581 fprintf(MaskList, " <strip stripNo = \"%i\"></strip>\n", i2);
582 m_SVDMaskV2[i]->SetBinContent(i2 + 1, 1 + ExistMask);
583 nMaskedV++;
584 }
585 }
586 fprintf(MaskList, " </side>\n");
587 fprintf(MaskList, " </sensor>\n");
588 TString message = Form("SVD(%i,%i,%i) masked %i U strips in: %s", iLayer, iLadder, iSensor, nMaskedU, ignoredPixelsListName.data());
589 B2INFO(message.Data());
590 message = Form("SVD(%i,%i,%i) masked %i V strips in: %s", iLayer, iLadder, iSensor, nMaskedV, ignoredPixelsListName.data());
591 B2INFO(message.Data());
592 fprintf(MaskList, " </ladder>\n");
593 fprintf(MaskList, " </layer>\n");
594 }
595 fprintf(MaskList, "</SVD>\n");
596 fclose(MaskList);
597 }
598
599}
600
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
Definition: HistoModule.h:29
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80
The PXD digit class.
Definition: PXDDigit.h:27
This class provides a check for ignored (=cold, hot or otherwise deffective) pixels for the use in PX...
std::pair< unsigned short, unsigned short > map_pixel
Simple structure for a pixel, u = map_pixel.first, v = map_pixel.second.
Specific implementation of SensorInfo for PXD Sensors which provides additional pixel specific inform...
Definition: SensorInfo.h:23
This class provides a list of ignored (=cold, hot or otherwise deffective) strips for the use in SVD ...
The SVD ShaperDigit class.
static const std::size_t c_nAPVSamples
Number of APV samples stored.
std::array< APVFloatSampleType, c_nAPVSamples > APVFloatSamples
array of APVFloatSampleType objects
Specific implementation of SensorInfo for SVD Sensors which provides additional sensor specific infor...
Definition: SensorInfo.h:25
const std::string & getName() const
Return name under which the object is saved in the DataStore.
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a referecne to the SensorInfo of a given SensorID.
Definition: GeoCache.cc:67
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:214
const GeoTools * getGeoTools()
Return a raw pointer to a GeoTools object.
Definition: GeoCache.h:142
unsigned short getNumberOfPXDSensors() const
Get number of PXD sensors.
Definition: GeoTools.h:133
int getVCells() const
Return number of pixel/strips in v direction.
int getUCells() const
Return number of pixel/strips in u direction.
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
baseType getLayerNumber() const
Get the layer id.
Definition: VxdID.h:96
void initialize() override final
Initialize.
float m_SVDvChargeCut
Cut for charge of SVD v strip - in ADU.
long m_nEventsProcess
Number of events to process.
TH1F ** m_SVDHitMapV
SVD hitmaps for v strips and timestamp by plane.
std::string m_PXDMaskFileRunName
Name of file with list of PXD masked channels.
TH1F ** m_SVDHitMapU2
SVD hitmaps for u strips and timestamp by plane.
long * m_nEventsPlane
How many events in plane.
void defineHisto() override final
Histogram definitions such as TH1(), TH2(), TNtuple(), TTree()....
float m_PXDCut
Cut for masking of PXD pixel - preset for 1 kEvent.
TH2F ** m_PXDMaskUV
mask for pixels by PXD plane
std::string m_SVDMaskFileBasicName
Name of file with list of SVD basic masked channels.
void event() override final
Event.
int m_AppendMaskFile
Set option for append of existing file or recreate new list.
std::string m_storeSVDShaperDigitsName
SVDShaperDigits StoreArray name.
std::string m_histogramDirectoryName
directory fo histograms name
std::string m_SVDMaskFileRunName
Name of file with list of SVD masked channels.
float m_SVDuChargeCut
Cut for charge of SVD u strip - in ADU.
std::string m_PXDMaskFileBasicName
Name of file with list of PXD basic masked channels.
TH1F ** m_SVDMaskV
SVD mask for v strips by plane.
long m_nRealEventsProcess
Real Number of events to process.
TH1F ** m_SVDMaskU2
SVD mask for u strips by plane.
void endRun() override final
End run.
TH2F ** m_PXDHitMapUV
Hitmaps for pixels by PXD plane.
TH1F ** m_SVDHitMapU
SVD hitmaps for u strips and timestamp by plane.
void beginRun() override final
Begin run.
TH1F ** m_SVDHitMapV2
SVD hitmaps for v strips and timestamp by plane.
float m_SVDvCut
Cut for masking of SVD v strip - preset for 1 kEvent.
float m_PXDChargeCut
Cut for charge of PXD pixel - in ADU.
TH1F ** m_SVDMaskV2
SVD mask for v strips by plane.
float m_SVDuCut
Cut for masking of SVD u strip - preset for 1 kEvent.
float m_nEventsProcessFraction
Fraction of events to process to expected No.
TH1F ** m_SVDMaskU
SVD mask for u strips by plane.
std::string m_storePXDDigitsName
PXDDigits StoreArray name.
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.
STL namespace.