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 40 of file SiPixelGainCalibHelper.h.

40 { 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 45 of file SiPixelGainCalibHelper.h.

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

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, jetUpdater_cfi::sort, 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 129 of file SiPixelGainCalibHelper.h.

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

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

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