Project
Loading...
Searching...
No Matches
PadCalibCCDBBuilder.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
15
17#include <iostream>
18#include <string>
19#include <map>
20#include <memory>
21#include "TFile.h"
22#include "TH2.h"
23#include "TMath.h"
24#include "TString.h"
25#include "TTree.h"
26
27using namespace o2::trd::constants;
28
29namespace o2::trd
30{
31
32void PadCalibCCDBBuilder::checkIfIsolatedHotPadCandidate(TH2F* hDet, std::vector<int> coordinates, float upperLimit, int areaContainedWithin)
33{
34 auto numberOfCoordinates = coordinates.size();
35 if (numberOfCoordinates != 4) {
36 std::cerr << "Invalid size of the coordinates vector!" << std::endl;
37 return;
38 }
39 float averageGain = computeDetectorAverage(hDet);
40
41 if (hDet->GetBinContent(coordinates[0], coordinates[1]) > upperLimit * averageGain) {
42 int sizeOfHotArea = isolatedHotPadsContainmentSize(hDet, coordinates[0], coordinates[1]);
43 if (sizeOfHotArea > 0 && sizeOfHotArea < areaContainedWithin) {
44 replaceIsolatedHotPads(hDet, coordinates[0], coordinates[1], sizeOfHotArea);
45 }
46 } else if (hDet->GetBinContent(coordinates[2], coordinates[3]) > upperLimit * averageGain) {
47 int sizeOfHotArea = isolatedHotPadsContainmentSize(hDet, coordinates[2], coordinates[3]);
48 if (sizeOfHotArea > 0 && sizeOfHotArea < areaContainedWithin) {
49 replaceIsolatedHotPads(hDet, coordinates[2], coordinates[3], sizeOfHotArea);
50 }
51 } else if (hDet->GetBinContent(coordinates[0], coordinates[1]) == 0 && hDet->GetBinContent(coordinates[2], coordinates[3]) != 0) {
52 int sizeOfHotArea = isolatedHotPadsContainmentSize(hDet, coordinates[2], coordinates[3]);
53 if (sizeOfHotArea > 0 && sizeOfHotArea < areaContainedWithin) {
54 replaceIsolatedHotPads(hDet, coordinates[2], coordinates[3], sizeOfHotArea);
55 }
56 }
57}
58
59void PadCalibCCDBBuilder::checkIfSmallerCloserToCenter(TH2F* hDet, std::vector<int> coordinates, float allowedDifference)
60{
61 if (hDet->GetBinContent(coordinates[0], coordinates[1]) == 0 || hDet->GetBinContent(coordinates[2], coordinates[3]) == 0) {
62 return;
63 }
64
65 float xCenter = hDet->GetNbinsX() / 2.;
66 float yCenter = hDet->GetNbinsY() / 2.;
67
68 std::vector<float> vCenter, vPad1, vPad2;
69 vCenter.push_back(hDet->GetNbinsX() / 2.);
70 vCenter.push_back(hDet->GetNbinsY() / 2.);
71
72 vPad1.push_back(hDet->GetXaxis()->GetBinCenter(coordinates[0]));
73 vPad1.push_back(hDet->GetYaxis()->GetBinCenter(coordinates[1]));
74
75 vPad2.push_back(hDet->GetXaxis()->GetBinCenter(coordinates[2]));
76 vPad2.push_back(hDet->GetYaxis()->GetBinCenter(coordinates[3]));
77
78 float dist1 = computeDistance(vPad1, vCenter);
79 float dist2 = computeDistance(vPad2, vCenter);
80
81 if ((dist1 < dist2) && ((hDet->GetBinContent(coordinates[2], coordinates[3]) - hDet->GetBinContent(coordinates[0], coordinates[1])) > allowedDifference)) {
82 replacePadCloserToCenter(hDet, coordinates[0], coordinates[1]);
83 }
84
85 if ((dist1 > dist2) && ((hDet->GetBinContent(coordinates[0], coordinates[1]) - hDet->GetBinContent(coordinates[2], coordinates[3])) > allowedDifference)) {
86 replacePadCloserToCenter(hDet, coordinates[2], coordinates[3]);
87 }
88}
89
90std::vector<int> PadCalibCCDBBuilder::compareGain(TH2F* hDet, int column, int row, int shiftcolumn, int shiftrow, float allowedDifference)
91{
92 std::vector<int> coordinates = {-1, -1, -1, -1};
93
94 int colMax = hDet->GetNbinsX();
95 int rowMax = hDet->GetNbinsY();
96
97 // only allow shift along one axis and only by one pad
98 if (!(shiftcolumn == 1 && shiftrow == 0) && !(shiftcolumn == 0 && shiftrow == 1)) {
99 return coordinates;
100 }
101
102 // cheks that the pad is valid
103 if ((column >= colMax) || (row >= rowMax)) {
104 return coordinates;
105 }
106
107 if ((column == colMax && shiftcolumn == 1) || (row == rowMax && shiftrow == 1)) {
108 return coordinates; // do not compare with overflow
109 }
110
111 float gain1 = hDet->GetBinContent(column, row);
112 float gain2 = hDet->GetBinContent(column + shiftcolumn, row + shiftrow);
113
114 if ((gain1 == 0 && gain2 > 0) || (gain1 > 0 && gain2 == 0) || (abs(gain1 - gain2) > allowedDifference)) {
115 coordinates[0] = column;
116 coordinates[1] = row;
117 coordinates[2] = column + shiftcolumn;
118 coordinates[3] = row + shiftrow;
119 }
120
121 return coordinates;
122}
123
125{ // computes an average over filled cells
126 // cells are accessed through their values, not bin coordinates
127 // the average os computed over absolute values as inter/extrapolated cells
128 // have negatiove values
129
130 float average = 0.;
131 int nBinsUsed = 0;
132 for (int irow = 0; irow < hDet->GetNbinsY(); irow++) {
133 for (int icol = 0; icol < hDet->GetNbinsX(); icol++) {
134 float currentGain = TMath::Abs(hDet->GetBinContent(icol + 1, irow + 1));
135 if (currentGain == 0) {
136 continue;
137 }
138 average += currentGain;
139 nBinsUsed++;
140 }
141 }
142 average /= nBinsUsed;
143
144 return average;
145}
146
147float PadCalibCCDBBuilder::computeDistance(std::vector<float> pad1, std::vector<float> pad2)
148{
149 float distance = -1.;
150
151 auto numberOfCoordinates = pad1.size();
152 if (numberOfCoordinates != pad2.size()) {
153 std::cerr << "Something fishy with the pad coordinates!" << std::endl;
154 return distance;
155 }
156
157 for (int i = 0; i < numberOfCoordinates; i++) {
158 distance += TMath::Power(pad1[i] - pad2[i], 2);
159 }
160 distance = TMath::Sqrt(distance);
161
162 return distance;
163}
164
165TH2F* PadCalibCCDBBuilder::createNormalizedMap(TH2F* hDet, TString sNewName)
166{ // clones the filled 2d map
167 // computes an average
168 // replaces each bin conetnt with ratio of gain over the average
169 if (sNewName == "") { // create a default name
170 sNewName = hDet->GetName();
171 sNewName += "_normalized";
172 }
173 TH2F* hDetNormalized = (TH2F*)hDet->Clone(sNewName.Data());
174
175 float average = computeDetectorAverage(hDet);
176
177 for (int irow = 0; irow < hDet->GetNbinsY(); irow++) {
178 for (int icol = 0; icol < hDet->GetNbinsX(); icol++) {
179 float currentGain = hDet->GetBinContent(hDet->GetXaxis()->FindBin(icol), hDet->GetYaxis()->FindBin(irow));
180 float newGain = currentGain / average;
181 hDetNormalized->SetBinContent(hDetNormalized->GetXaxis()->FindBin(icol), hDetNormalized->GetYaxis()->FindBin(irow), newGain);
182 }
183 }
184
185 return hDetNormalized;
186}
187
188void PadCalibCCDBBuilder::fillInTheGap(TH2F* hDet, int column, int row, float newGain)
189{ // takes hDet and replaces content of bin (column,row) with gain
190 // CHANGES THE TH2 GIVEN IN ARGUMENT!
191 float currentGain = hDet->GetBinContent(column + 1, row + 1);
192 // float currentGain = hDet->GetBinContent(hDet->GetXaxis()->FindBin(column), hDet->GetYaxis()->FindBin(row));
193 if (currentGain != 0) {
194 return; // make sure we don't replace gain, just fill in gaps
195 }
196 float factor = 1;
197 hDet->SetBinContent(column + 1, row + 1, factor * newGain);
198 // hDet->SetBinContent(hDet->GetXaxis()->FindBin(column), hDet->GetYaxis()->FindBin(row), factor*newGain);
199}
200
201TH2F* PadCalibCCDBBuilder::fillTheMap(TH2F* hDet, TString sNewName, int nbuffer)
202{ // clones the map and fills the clone
203 // will fill any map with at least 1 hit!
204 // the map is cloned to limit propagation of neighboring bin content
205 if (sNewName == "") { // create default name
206 sNewName = hDet->GetName();
207 sNewName += "_filled";
208 }
209 TH2F* hDetFilled = (TH2F*)hDet->Clone(sNewName);
210
211 TH2F* hDetTemp = (TH2F*)hDet->Clone("hDetTemp"); // use as intermediate det in the filling process
212 // find empty bins
213 std::vector<std::vector<int>> emptyBinsColRow = findEmpty(hDetTemp);
214 // loop over empty bins of th clone and fill them with the average gain
215 // calculated from the gain in neighboring bins in the "Temp" map
216 auto nEmptyBins = emptyBinsColRow.size();
217
218 int firstFilledX = hDetFilled->FindFirstBinAbove();
219 int lastFilledX = hDetFilled->FindLastBinAbove();
220 int nBinsX = hDetFilled->GetNbinsX();
221
222 int firstFilledY = hDetFilled->FindFirstBinAbove(0, 2);
223 int lastFilledY = hDetFilled->FindLastBinAbove(0, 2);
224 int nBinsY = hDetFilled->GetNbinsY();
225
226 while (nEmptyBins != 0) {
227
228 for (int ibin = 0; ibin < nEmptyBins; ibin++) {
229 // printf("filling bin (%i:%i) \n", emptyBinsColRow[ibin][0], emptyBinsColRow[ibin][1]);
230 int flippedCoordinateX = nBinsX - hDetFilled->GetXaxis()->FindBin(emptyBinsColRow[ibin][0]) + 1;
231 int flippedCoordinateY = nBinsY - hDetFilled->GetYaxis()->FindBin(emptyBinsColRow[ibin][1]) + 1;
232 float mirroredGain = hDetFilled->GetBinContent(flippedCoordinateX, hDetFilled->GetYaxis()->FindBin(emptyBinsColRow[ibin][1]));
233 //
234 if (mirroredGain == 0) {
235 mirroredGain = hDetFilled->GetBinContent(hDetFilled->GetXaxis()->FindBin(emptyBinsColRow[ibin][0]), flippedCoordinateY);
236 }
237 //
238 if (mirroredGain == 0) {
239 mirroredGain = getAverageFromNeighbors(hDetTemp, emptyBinsColRow[ibin][0], emptyBinsColRow[ibin][1], nbuffer);
240 }
241 //
242 float factor = -1;
243 if (mirroredGain < 0) {
244 factor = 1;
245 }
246 fillInTheGap(hDetFilled, emptyBinsColRow[ibin][0], emptyBinsColRow[ibin][1], factor * mirroredGain);
247 }
248 //
249 auto nEmptyPrevious = emptyBinsColRow.size();
250 emptyBinsColRow.clear();
251 hDetTemp = (TH2F*)hDetFilled->Clone("hDetTemp");
252 emptyBinsColRow = findEmpty(hDetTemp);
253 nEmptyBins = emptyBinsColRow.size();
254 if (nEmptyPrevious == nEmptyBins) {
255 break; // will break out of the loop if no more empty pads can be filled
256 }
257 } // will continue the loop till all bins are filled
258
259 delete hDetTemp;
260
261 return hDetFilled;
262}
263
264std::vector<std::vector<int>> PadCalibCCDBBuilder::findEmpty(TH2F* hDetectorMap)
265{ // finds the coordinates (col,row) of all empty bins
266 std::vector<std::vector<int>> emptyBins;
267
268 for (int irow = 0; irow < hDetectorMap->GetNbinsY(); irow++) {
269 for (int icolumn = 0; icolumn < hDetectorMap->GetNbinsX(); icolumn++) {
270 float gain = hDetectorMap->GetBinContent(icolumn + 1, irow + 1);
271 if (gain == 0) {
272 std::vector<int> coordinates; // todo fixed length and then set col/row as std::vector[0/1] = xx?
273 coordinates.push_back(icolumn);
274 coordinates.push_back(irow);
275 emptyBins.push_back(coordinates);
276 }
277 } // loop over columns
278 } // loop over rows
279 return emptyBins;
280}
281
282std::vector<std::vector<int>> PadCalibCCDBBuilder::findInhomogeneities(TH2F* hDet, float allowedDifference)
283{ // finds bins that have 1+ neighbour with significantly different content
284 // gives the coordonates of the pair
285 std::vector<std::vector<int>> suspiciousBinPairs;
286
287 // check for edges - this operation goes before filling
288 // edges along X:
289 int xFirst = hDet->FindFirstBinAbove();
290 int xLast = hDet->FindLastBinAbove(); // stop the process at penultimate vs ultimate row/column
291 // // edges along Y:
292 int yFirst = hDet->FindFirstBinAbove(0, 2);
293 int yLast = hDet->FindLastBinAbove(0, 2); // stop the process at penultimate vs ultimate row/column
294
295 // int nbins_x = hDet->GetNbinsX();
296 // int nbins_y = hDet->GetNbinsY();
297 for (int irow = 0; irow < hDet->GetNbinsY(); irow++) {
298
299 int thisRow = hDet->GetXaxis()->FindBin(irow);
300 // if( thisRow < yFirst || thisRow > yLast ) continue;
301
302 for (int icolumn = 0; icolumn < hDet->GetNbinsX(); icolumn++) {
303
304 int thisColumn = hDet->GetXaxis()->FindBin(icolumn);
305 // if( thisColumn < xFirst || thisColumn > xLast ) continue;
306
307 std::vector<int> pair = compareGain(hDet, thisColumn, thisRow, 1, 0, allowedDifference);
308 if (!(std::any_of(pair.begin(), pair.end(), [](int i) { return i == -1; }))) {
309 suspiciousBinPairs.push_back(pair);
310 }
311 pair.clear();
312
313 pair = compareGain(hDet, thisColumn, thisRow, 0, 1, allowedDifference);
314 if (!(std::any_of(pair.begin(), pair.end(), [](int i) { return i == -1; }))) {
315 suspiciousBinPairs.push_back(pair);
316 }
317
318 } // loop over columns
319
320 } // loop over rows
321
322 return suspiciousBinPairs;
323}
324
325float PadCalibCCDBBuilder::getAverageFromNeighbors(TH2F* hDet, int column, int row, int nbuffer)
326{ // takes bin (column,row) from hDet map
327 // and averages the gain in its (up to) 8 neighbours
328 float average = 0.;
329 std::vector<float> gainNeighbor;
330 int offset = nbuffer / 2;
331
332 for (int irow = 0; irow < nbuffer; irow++) {
333
334 int rowNeighbor = (row - offset) + irow;
335 if (rowNeighbor < 0 || rowNeighbor >= hDet->GetNbinsY()) {
336 continue; // avoids under and overflow
337 }
338 for (int icol = 0; icol < nbuffer; icol++) {
339 if (icol == 1 && irow == 1) {
340 continue; // exclude self
341 }
342 int colNeighbor = (column - offset) + icol;
343 if (colNeighbor < 0 || colNeighbor >= hDet->GetNbinsX()) {
344 continue; // avoids under and overflow
345 }
346 float tempGain = TMath::Abs(hDet->GetBinContent(hDet->GetXaxis()->FindBin(colNeighbor), hDet->GetYaxis()->FindBin(rowNeighbor)));
347 if (tempGain <= 0) {
348 continue; // exclude empty/negative bins
349 }
350 gainNeighbor.push_back(tempGain);
351 }
352 }
353 auto numberOfNeighbors = gainNeighbor.size();
354 if (numberOfNeighbors < 1) {
355 return 0; // if empty, return 0
356 }
357
358 average = std::accumulate(gainNeighbor.begin(), gainNeighbor.end(), decltype(gainNeighbor)::value_type(0.0)) / numberOfNeighbors;
359
360 return average;
361}
362
363TH2F* PadCalibCCDBBuilder::getDetectorMap(TTree* tree, int nDet, float mingain, float maxgain, TString sDetName)
364{ // creates a th2 map of a detector nDet
365 // allows to limit the range of accepted adc gain by setting
366 // mingain and maxgain (default range 0-10k)
367 if (sDetName == "") {
368 sDetName = Form("hDet%i", nDet);
369 }
370 int nTrdRows = NROWC1;
371 int detInSupermodule = nDet % 30; // set the correct # of rows for stack 2
372 if (detInSupermodule >= 12 && detInSupermodule <= 17) {
373 nTrdRows = NROWC0;
374 }
375 // create the 2d map to be filled
376 TH2F* hDetector = new TH2F(sDetName.Data(), sDetName.Data(), NCOLUMN, 0, NCOLUMN, nTrdRows, 0, nTrdRows);
377 // set branches of our tree
379 // loop over tree and fill histo
380 int nentries = tree->GetEntries();
381 for (int ientry = 0; ientry < nentries; ientry++) {
382 tree->GetEntry(ientry);
383 if ((int)mDet != nDet) {
384 continue;
385 }
386 if (mChi < 0 || mAmp <= 0 || mSgm <= 0 || mSgm > 1000) {
387 continue;
388 }
389 // TODO add setters to change cuts
390 // if (mChiMax < mChiMin && mChi > mChiMax)
391 // continue;
392 if (mAdc < mingain || mAdc > maxgain) {
393 continue;
394 }
395 hDetector->SetBinContent(hDetector->GetXaxis()->FindBin(mCol), hDetector->GetYaxis()->FindBin(mRow), mAdc);
396 }
397 return hDetector;
398}
399
400bool PadCalibCCDBBuilder::isHotAreaIsolated(TH2F* hDet, int column, int row, int matrixSize)
401{
402 bool isIsolated = kFALSE;
403 float averageGain = computeDetectorAverage(hDet);
404 int nSurroundingNotHot = 0;
405 int nMaxHot = TMath::Power(matrixSize + 2, 2) - TMath::Power(matrixSize, 2);
406 float averageAround = 0.;
407 int nUsedBins = 0;
408
409 int nHotOffset = 0; // offsets the nMaxHot criterion for cells at edges
410 if ((column == 1 || column == hDet->GetNbinsX()) && row > 1 && row < hDet->GetNbinsY()) {
411 nHotOffset = matrixSize + 2;
412 } else if ((row == 1 || row == hDet->GetNbinsY()) && column > 1 && column < hDet->GetNbinsX()) {
413 nHotOffset = matrixSize + 2;
414 } else if ((column == 1 || column == hDet->GetNbinsX()) && (row == 1 || row == hDet->GetNbinsY())) {
415 nHotOffset = nMaxHot / 2 + 1;
416 }
417
418 for (int i = 0; i < matrixSize + 2; i++) {
419 int icol = i - 1;
420 for (int j = 0; j < matrixSize + 2; j++) {
421 int jrow = j - 1;
422 if ((-1 < icol) && (icol < matrixSize) && (-1 < jrow) && (jrow < matrixSize)) {
423 continue;
424 }
425 float temp = TMath::Abs(hDet->GetBinContent(column + icol, row + jrow));
426 if (temp != 0) {
427 nUsedBins++;
428 averageAround += temp;
429 } else if (temp == 0) {
430 nSurroundingNotHot++;
431 }
432 }
433 }
434
435 if (nUsedBins > 0) {
436 averageAround /= nUsedBins;
437 }
438 if (averageAround < 2 * averageGain && nSurroundingNotHot <= nHotOffset) { //<= nMaxHot){
439 isIsolated = kTRUE;
440 } else if (nSurroundingNotHot == nMaxHot) {
441 isIsolated = kTRUE;
442 }
443
444 return isIsolated;
445}
446
448{
449 int nsize = 0;
450 bool isContained = kFALSE;
451 while (!isContained) {
452 nsize++;
453 isContained = isHotAreaIsolated(hDet, column, row, nsize);
454 if (nsize == 4) {
455 return -1;
456 }
457 }
458 return nsize;
459}
460
461void PadCalibCCDBBuilder::populateEmptyNormalizedMap(TH2F* hDet, float valueToSet)
462{ // sets all cells in an empty normalized map to a given value
463 // by default all cells set to -1
464
465 if (!hDet || hDet->GetEntries() != 0) {
466 std::cout << "Histogram does not exist or is not empty!";
467 return;
468 }
469 for (int icol = 0; icol < hDet->GetNbinsX(); icol++) {
470 for (int irow = 0; irow < hDet->GetNbinsY(); irow++) {
471 hDet->SetBinContent(icol + 1, irow + 1, valueToSet);
472 }
473 }
474}
475
476void PadCalibCCDBBuilder::removeEdges(TH2F* hDet, int nsize)
477{ // sets all cells in edges (along Y) of custom size (default size 2 columns) to 0
478 if (!hDet || hDet->GetEntries() == 0) {
479 return;
480 }
481 for (int icol = 0; icol < nsize; icol++) {
482 for (int irow = 0; irow < hDet->GetNbinsY(); irow++) {
483 hDet->SetBinContent(icol + 1, irow + 1, 0);
484 hDet->SetBinContent(hDet->GetNbinsX() - icol, irow, 0);
485 }
486 }
487}
488
489void PadCalibCCDBBuilder::removeExtremePads(TH2F* hDet, float upperLimit, float lowerLimit)
490{ // sets very hot (> 2*average) and very cold (< average/2) cells to 0
491 if (!hDet || hDet->GetEntries() == 0) {
492 return;
493 }
494 float average = computeDetectorAverage(hDet);
495
496 for (int irow = 0; irow < hDet->GetNbinsY(); irow++) {
497 for (int icol = 0; icol < hDet->GetNbinsX(); icol++) {
498 float value = hDet->GetBinContent(icol + 1, irow + 1);
499 if (value > upperLimit * average || value < lowerLimit * average) {
500 hDet->SetBinContent(icol + 1, irow + 1, 0);
501 }
502 }
503 }
504}
505
506void PadCalibCCDBBuilder::replacePadCloserToCenter(TH2F* hDet, int xcloser, int ycloser)
507{
508 if (!hDet || hDet->GetEntries() == 0) {
509 std::cerr << "invalid histogram!" << std::endl;
510 return;
511 }
512
513 float newGain = 0.;
514 hDet->SetBinContent(xcloser, ycloser, newGain);
515}
516
517void PadCalibCCDBBuilder::replaceIsolatedHotPads(TH2F* hDet, int column, int row, int nsize)
518{
519 for (int jrow = 0; jrow < nsize; jrow++) {
520 for (int icol = 0; icol < nsize; icol++) {
521 hDet->SetBinContent(column + icol, row + jrow, 0);
522 }
523 }
524}
525
527{
528 tree->SetBranchAddress("det", &mDet);
529 tree->SetBranchAddress("col", &mCol);
530 tree->SetBranchAddress("row", &mRow);
531 tree->SetBranchAddress("mean", &mAdc);
532 tree->SetBranchAddress("chi2", &mChi);
533 tree->SetBranchAddress("sigma", &mSgm);
534 tree->SetBranchAddress("amplitude", &mAmp);
535}
536
537void PadCalibCCDBBuilder::smoothenTheDetector(TH2F* hDet, float allowedDifference)
538{
539 std::vector<std::vector<int>> SuspiciousBinPairs = findInhomogeneities(hDet, allowedDifference);
540 auto numberOfPairs = SuspiciousBinPairs.size();
541 if (numberOfPairs == 0) {
542 return;
543 }
544
545 for (int i = 0; i < numberOfPairs; i++) {
546 std::vector<int> susPair = SuspiciousBinPairs[i];
547 checkIfIsolatedHotPadCandidate(hDet, susPair);
548 checkIfSmallerCloserToCenter(hDet, susPair, allowedDifference);
549 }
550}
551
553{
554 if (!hDet || hDet->GetEntries() == 0) {
555 return nullptr;
556 }
557 // set a name for the new histo
558 if (sName == "") {
559 sName = hDet->GetName();
560 sName += "_transformed";
561 }
562
563 int nCols = hDet->GetNbinsX();
564 int nRows = hDet->GetNbinsY();
565
566 TH2F* hDetCopy = new TH2F(sName.Data(), sName.Data(), nCols, 0, nCols, nRows, 0, nRows);
567
568 for (int icol = 0; icol < nCols; icol++) {
569 for (int irow = 0; irow < nRows; irow++) {
570 hDetCopy->SetBinContent(icol + 1, irow + 1, TMath::Abs(hDet->GetBinContent(icol + 1, irow + 1)));
571 }
572 }
573
574 return hDetCopy;
575}
576
577} // namespace o2::trd
uint32_t pad2
uint32_t pad1
int32_t i
Krypton calibration.
uint32_t j
Definition RawData.h:0
TH2F * fillTheMap(TH2F *hDet, TString sNewName="", int nbuffer=3)
void removeExtremePads(TH2F *hDet, float upperLimit=2., float lowerLimit=0.5)
void removeEdges(TH2F *hDet, int nsize=2)
TH2F * transformMapIntoAbsoluteValues(TH2F *hDet, TString sName="")
void replaceIsolatedHotPads(TH2F *hDet, int column, int row, int nsize)
void replacePadCloserToCenter(TH2F *hDet, int column, int row)
bool isHotAreaIsolated(TH2F *hDet, int column, int row, int matrixSize=1)
std::vector< std::vector< int > > findInhomogeneities(TH2F *hDet, float allowedDifference)
int isolatedHotPadsContainmentSize(TH2F *hDet, int column, int row)
void fillInTheGap(TH2F *hDet, int column, int row, float newGain)
std::vector< int > compareGain(TH2F *hDet, int column, int row, int shiftcolumn, int shiftrow, float allowedDifference)
void populateEmptyNormalizedMap(TH2F *hDet, float valueToSet=-1)
void checkIfIsolatedHotPadCandidate(TH2F *hDet, std::vector< int > coordinates, float upperLimit=1.5, int areaContainedWithin=4)
std::vector< std::vector< int > > findEmpty(TH2F *hDetectorMap)
TH2F * createNormalizedMap(TH2F *hDet, TString sNewName="")
float getAverageFromNeighbors(TH2F *hDet, int column, int row, int nbuffer=3)
void checkIfSmallerCloserToCenter(TH2F *hDet, std::vector< int > coordinates, float allowedDifference)
TH2F * getDetectorMap(TTree *tree, int nDet, float mingain=0, float maxgain=10 '000, TString sDetName="")
void smoothenTheDetector(TH2F *hDet, float allowedDifference=1000)
float computeDistance(std::vector< float > pad1, std::vector< float > pad2)
GLsizei GLsizei GLfloat distance
Definition glcorearb.h:5506
GLsizei const GLfloat * value
Definition glcorearb.h:819
GLintptr offset
Definition glcorearb.h:660
constexpr int NCOLUMN
the number of pad columns for each chamber
Definition Constants.h:41
constexpr int NROWC0
the number of pad rows for chambers of type C0 (installed in stack 2)
Definition Constants.h:42
constexpr int NROWC1
the number of pad rows for chambers of type C1 (installed in stacks 0, 1, 3 and 4)
Definition Constants.h:43
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))
std::vector< int > row