CMS 3D CMS Logo

Enumerations | Functions
gainCalibHelper::gainCalibPI Namespace Reference

Enumerations

enum  type { t_gain = 0, t_pedestal = 1, t_correlation = 2 }
 

Functions

template<typename PayloadType >
static std::array< std::shared_ptr< TH1F >, 2 > fillDiffAndRatio (const std::shared_ptr< PayloadType > &payload_A, const std::shared_ptr< PayloadType > &payload_B, const gainCalibPI::type &theType)
 
template<typename PayloadType >
static void fillTheHisto (const std::shared_ptr< PayloadType > &payload, std::shared_ptr< TH1F > h1, gainCalibPI::type theType, const std::vector< uint32_t > &wantedIds={})
 
template<typename PayloadType >
static void fillTheHistos (const std::shared_ptr< PayloadType > &payload, std::shared_ptr< TH1 > hBPix, std::shared_ptr< TH1 > hFPix, gainCalibPI::type theType)
 
template<typename PayloadType >
static void fillThePerModuleMap (const std::shared_ptr< PayloadType > &payload, AvgMap &map, gainCalibPI::type theType)
 

Enumeration Type Documentation

◆ type

Enumerator
t_gain 
t_pedestal 
t_correlation 

Definition at line 39 of file SiPixelGainCalibHelper.h.

39 { t_gain = 0, t_pedestal = 1, t_correlation = 2 };

Function Documentation

◆ fillDiffAndRatio()

template<typename PayloadType >
static std::array<std::shared_ptr<TH1F>, 2> gainCalibHelper::gainCalibPI::fillDiffAndRatio ( const std::shared_ptr< PayloadType > &  payload_A,
const std::shared_ptr< PayloadType > &  payload_B,
const gainCalibPI::type theType 
)
static

Definition at line 44 of file SiPixelGainCalibHelper.h.

46  {
47  std::array<std::shared_ptr<TH1F>, 2> arr;
48 
49  std::vector<uint32_t> detids_A;
50  payload_A->getDetIds(detids_A);
51  std::vector<uint32_t> detids_B;
52  payload_B->getDetIds(detids_B);
53 
54  std::vector<float> v_ratios;
55  std::vector<float> v_diffs;
56 
57  if (detids_A != detids_B) {
58  edm::LogError("fillDiffAndRatio") << "the list of DetIds for the two payloads are not equal"
59  << " cannot make any comparison!" << std::endl;
60  }
61 
62  assert(detids_A == detids_B);
63  for (const auto& d : detids_A) {
64  auto range = payload_A->getRange(d);
65  int numberOfRowsToAverageOver = payload_A->getNumberOfRowsToAverageOver();
66  int ncols = payload_A->getNCols(d);
67  int nRocsInRow = (range.second - range.first) / ncols / numberOfRowsToAverageOver;
68  unsigned int nRowsForHLT = 1;
69  int nrows = std::max((payload_A->getNumberOfRowsToAverageOver() * nRocsInRow),
70  nRowsForHLT); // dirty trick to make it work for the HLT payload
71 
72  auto rAndCol_A = payload_A->getRangeAndNCols(d);
73  auto rAndCol_B = payload_B->getRangeAndNCols(d);
74  bool isDeadCol, isNoisyCol;
75 
76  float ratio(-.1), diff(-1.);
77  for (int col = 0; col < ncols; col++) {
78  for (int row = 0; row < nrows; row++) {
79  switch (theType) {
80  case gainCalibPI::t_gain: {
81  auto gainA = payload_A->getGain(col, row, rAndCol_A.first, rAndCol_A.second, isDeadCol, isNoisyCol);
82  auto gainB = payload_B->getGain(col, row, rAndCol_B.first, rAndCol_B.second, isDeadCol, isNoisyCol);
83  ratio = gainB != 0 ? (gainA / gainB) : -1.; // if the ratio does not make sense the default is -1
84  diff = gainA - gainB;
85  break;
86  }
88  auto pedA = payload_A->getPed(col, row, rAndCol_A.first, rAndCol_A.second, isDeadCol, isNoisyCol);
89  auto pedB = payload_B->getPed(col, row, rAndCol_B.first, rAndCol_B.second, isDeadCol, isNoisyCol);
90  ratio = pedB != 0 ? (pedA / pedB) : -1.; // if the ratio does not make sense the default is -1
91  diff = pedA - pedB;
92  break;
93  }
94  default:
95  edm::LogError("gainCalibPI::fillTheHisto") << "Unrecognized type " << theType << std::endl;
96  break;
97  }
98  // fill the containers
99  v_diffs.push_back(diff);
100  v_ratios.push_back(ratio);
101  } // loop on rows
102  } // loop on cols
103  } // loop on detids
104 
105  std::sort(v_diffs.begin(), v_diffs.end());
106  std::sort(v_ratios.begin(), v_ratios.end());
107 
108  double minDiff = v_diffs.front();
109  double maxDiff = v_diffs.back();
110  double minRatio = v_ratios.front();
111  double maxRatio = v_ratios.back();
112 
113  arr[0] = std::make_shared<TH1F>("h_Ratio", "", 50, minRatio - 1., maxRatio + 1.);
114  arr[1] = std::make_shared<TH1F>("h_Diff", "", 50, minDiff - 1., maxDiff + 1.);
115 
116  for (const auto& r : v_ratios) {
117  arr[0]->Fill(r);
118  }
119  for (const auto& d : v_diffs) {
120  arr[1]->Fill(d);
121  }
122  return arr;
123  }

References cms::cuda::assert(), cuy::col, ztail::d, change_name::diff, SiStripPI::max, reco::castor::maxDiff(), hgcalPlots::ncols, alignCSCRings::r, FastTimerService_cff::range, particleFlowDisplacedVertex_cfi::ratio, t_gain, and t_pedestal.

◆ fillTheHisto()

template<typename PayloadType >
static void gainCalibHelper::gainCalibPI::fillTheHisto ( const std::shared_ptr< PayloadType > &  payload,
std::shared_ptr< TH1F >  h1,
gainCalibPI::type  theType,
const std::vector< uint32_t > &  wantedIds = {} 
)
static

Definition at line 128 of file SiPixelGainCalibHelper.h.

131  {}) {
132  std::vector<uint32_t> detids;
133  if (wantedIds.empty()) {
134  payload->getDetIds(detids);
135  } else {
136  detids.assign(wantedIds.begin(), wantedIds.end());
137  }
138 
139  for (const auto& d : detids) {
140  // skip the special case used to signal there are no attached dets
141  if (d == 0xFFFFFFFF)
142  continue;
143 
144  auto range = payload->getRange(d);
145  int numberOfRowsToAverageOver = payload->getNumberOfRowsToAverageOver();
146  int ncols = payload->getNCols(d);
147  int nRocsInRow = (range.second - range.first) / ncols / numberOfRowsToAverageOver;
148  unsigned int nRowsForHLT = 1;
149  int nrows = std::max((payload->getNumberOfRowsToAverageOver() * nRocsInRow),
150  nRowsForHLT); // dirty trick to make it work for the HLT payload
151 
152  auto rangeAndCol = payload->getRangeAndNCols(d);
153  bool isDeadColumn;
154  bool isNoisyColumn;
155 
156  COUT << "NCOLS: " << payload->getNCols(d) << " " << rangeAndCol.second << " NROWS:" << nrows
157  << ", RANGES: " << rangeAndCol.first.second - rangeAndCol.first.first
158  << ", Ratio: " << float(rangeAndCol.first.second - rangeAndCol.first.first) / rangeAndCol.second
159  << std::endl;
160 
161  float quid(-99999.);
162 
163  for (int col = 0; col < ncols; col++) {
164  for (int row = 0; row < nrows; row++) {
165  switch (theType) {
166  case gainCalibPI::t_gain:
167  quid = payload->getGain(col, row, rangeAndCol.first, rangeAndCol.second, isDeadColumn, isNoisyColumn);
168  break;
170  quid = payload->getPed(col, row, rangeAndCol.first, rangeAndCol.second, isDeadColumn, isNoisyColumn);
171  break;
172  default:
173  edm::LogError("gainCalibPI::fillTheHisto") << "Unrecognized type " << theType << std::endl;
174  break;
175  }
176  h1->Fill(quid);
177  } // loop on rows
178  } // loop on cols
179  } // loop on detids
180  } // fillTheHisto

Referenced by gainCalibHelper::SiPixelGainCalibrationValues< myType, PayloadType >::fill(), and gainCalibHelper::SiPixelGainCalibrationValuesPerRegion< isBarrel, myType, PayloadType >::fill().

◆ fillTheHistos()

template<typename PayloadType >
static void gainCalibHelper::gainCalibPI::fillTheHistos ( const std::shared_ptr< PayloadType > &  payload,
std::shared_ptr< TH1 >  hBPix,
std::shared_ptr< TH1 >  hFPix,
gainCalibPI::type  theType 
)
static

Definition at line 231 of file SiPixelGainCalibHelper.h.

234  {
235  std::vector<uint32_t> detids;
236  payload->getDetIds(detids);
237 
238  bool isCorrelation_ = hBPix.get()->InheritsFrom(TH2::Class()) && (theType == gainCalibPI::t_correlation);
239 
240  for (const auto& d : detids) {
241  int subid = DetId(d).subdetId();
242  auto range = payload->getRange(d);
243  int numberOfRowsToAverageOver = payload->getNumberOfRowsToAverageOver();
244  int ncols = payload->getNCols(d);
245  int nRocsInRow = (range.second - range.first) / ncols / numberOfRowsToAverageOver;
246  unsigned int nRowsForHLT = 1;
247  int nrows = std::max((payload->getNumberOfRowsToAverageOver() * nRocsInRow),
248  nRowsForHLT); // dirty trick to make it work for the HLT payload
249 
250  auto rangeAndCol = payload->getRangeAndNCols(d);
251  bool isDeadColumn;
252  bool isNoisyColumn;
253 
254  for (int col = 0; col < ncols; col++) {
255  for (int row = 0; row < nrows; row++) {
256  float gain = payload->getGain(col, row, rangeAndCol.first, rangeAndCol.second, isDeadColumn, isNoisyColumn);
257  float ped = payload->getPed(col, row, rangeAndCol.first, rangeAndCol.second, isDeadColumn, isNoisyColumn);
258 
259  switch (subid) {
261  if (isCorrelation_) {
262  hBPix->Fill(gain, ped);
263  } else {
264  hBPix->Fill((theType == gainCalibPI::t_gain ? gain : ped));
265  }
266  break;
267  }
269  if (isCorrelation_) {
270  hFPix->Fill(gain, ped);
271  } else {
272  hFPix->Fill((theType == gainCalibPI::t_gain ? gain : ped));
273  }
274  break;
275  }
276  default:
277  edm::LogError("gainCalibPI::fillTheHistos") << d << " is not a Pixel DetId" << std::endl;
278  break;
279  } // switch on subid
280  } // row loop
281  } // column loop
282  } // detid loop
283  } // filltheHistos

References HLT_FULL_cff::Class, cuy::col, ztail::d, PedestalClient_cfi::gain, SiStripPI::max, hgcalPlots::ncols, jets_cff::payload, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, FastTimerService_cff::range, DetId::subdetId(), t_correlation, and t_gain.

◆ fillThePerModuleMap()

template<typename PayloadType >
static void gainCalibHelper::gainCalibPI::fillThePerModuleMap ( const std::shared_ptr< PayloadType > &  payload,
AvgMap map,
gainCalibPI::type  theType 
)
static

Definition at line 185 of file SiPixelGainCalibHelper.h.

187  {
188  std::vector<uint32_t> detids;
189  payload->getDetIds(detids);
190 
191  for (const auto& d : detids) {
192  auto range = payload->getRange(d);
193  int numberOfRowsToAverageOver = payload->getNumberOfRowsToAverageOver();
194  int ncols = payload->getNCols(d);
195  int nRocsInRow = (range.second - range.first) / ncols / numberOfRowsToAverageOver;
196  unsigned int nRowsForHLT = 1;
197  int nrows = std::max((payload->getNumberOfRowsToAverageOver() * nRocsInRow),
198  nRowsForHLT); // dirty trick to make it work for the HLT payload
199 
200  auto rangeAndCol = payload->getRangeAndNCols(d);
201  bool isDeadColumn;
202  bool isNoisyColumn;
203 
204  float sumOfX(0.);
205  int nPixels(0);
206  for (int col = 0; col < ncols; col++) {
207  for (int row = 0; row < nrows; row++) {
208  nPixels++;
209  switch (theType) {
210  case gainCalibPI::t_gain:
211  sumOfX +=
212  payload->getGain(col, row, rangeAndCol.first, rangeAndCol.second, isDeadColumn, isNoisyColumn);
213  break;
215  sumOfX += payload->getPed(col, row, rangeAndCol.first, rangeAndCol.second, isDeadColumn, isNoisyColumn);
216  break;
217  default:
218  edm::LogError("gainCalibPI::fillThePerModuleMap") << "Unrecognized type " << theType << std::endl;
219  break;
220  } // switch on the type
221  } // rows
222  } // columns
223  // fill the return value map
224  map[d] = sumOfX / nPixels;
225  } // loop on the detId
226  } // fillThePerModuleMap

References cuy::col, ztail::d, genParticles_cff::map, SiStripPI::max, hgcalPlots::ncols, jets_cff::payload, FastTimerService_cff::range, t_gain, and t_pedestal.

gainCalibHelper::gainCalibPI::t_pedestal
Definition: SiPixelGainCalibHelper.h:39
change_name.diff
diff
Definition: change_name.py:13
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
hgcalPlots.ncols
ncols
Definition: hgcalPlots.py:105
gainCalibHelper::gainCalibPI::t_gain
Definition: SiPixelGainCalibHelper.h:39
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
PixelSubdetector::PixelEndcap
Definition: PixelSubdetector.h:11
HLT_FULL_cff.Class
Class
Definition: HLT_FULL_cff.py:8427
PixelSubdetector::PixelBarrel
Definition: PixelSubdetector.h:11
cuy.col
col
Definition: cuy.py:1010
reco::castor::maxDiff
float maxDiff(float one, float two, float three, float four)
Definition: CastorAlgoUtils.cc:19
cms::cuda::assert
assert(be >=bs)
gainCalibHelper::gainCalibPI::t_correlation
Definition: SiPixelGainCalibHelper.h:39
DetId
Definition: DetId.h:17
jets_cff.payload
payload
Definition: jets_cff.py:32
particleFlowDisplacedVertex_cfi.ratio
ratio
Definition: particleFlowDisplacedVertex_cfi.py:93
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
alignCSCRings.r
r
Definition: alignCSCRings.py:93
PedestalClient_cfi.gain
gain
Definition: PedestalClient_cfi.py:37
COUT
#define COUT
Definition: PVValidationHelpers.h:13
ztail.d
d
Definition: ztail.py:151
genParticles_cff.map
map
Definition: genParticles_cff.py:11