CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Enumerations | Functions | Variables
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)
 

Variables

static const std::array
< std::string, 3 > 
t_titles = {{"gain", "pedestal", "correlation"}}
 

Enumeration Type Documentation

Function Documentation

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

References cms::cuda::assert(), cuy::col, ztail::d, change_name::diff, SiStripPI::max, reco::castor::maxDiff(), alignCSCRings::r, sistrip::SpyUtilities::range(), t_gain, and t_pedestal.

Referenced by gainCalibHelper::SiPixelGainCalibDiffAndRatioBase< myType, nIOVs, ntags, PayloadType >::fill().

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

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

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

References cuy::col, ztail::d, SiStripPI::max, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, sistrip::SpyUtilities::range(), DetId::subdetId(), t_correlation, and t_gain.

Referenced by gainCalibHelper::SiPixelGainCalibrationCorrelations< PayloadType >::fill(), and gainCalibHelper::SiPixelGainCalibrationValuesByPart< myType, PayloadType >::fill().

236  {
237  std::vector<uint32_t> detids;
238  payload->getDetIds(detids);
239 
240  bool isCorrelation_ = hBPix.get()->InheritsFrom(TH2::Class()) && (theType == gainCalibPI::t_correlation);
241 
242  for (const auto& d : detids) {
243  int subid = DetId(d).subdetId();
244  auto range = payload->getRange(d);
245  int numberOfRowsToAverageOver = payload->getNumberOfRowsToAverageOver();
246  int ncols = payload->getNCols(d);
247  int nRocsInRow = (range.second - range.first) / ncols / numberOfRowsToAverageOver;
248  unsigned int nRowsForHLT = 1;
249  int nrows = std::max((payload->getNumberOfRowsToAverageOver() * nRocsInRow),
250  nRowsForHLT); // dirty trick to make it work for the HLT payload
251 
252  auto rangeAndCol = payload->getRangeAndNCols(d);
253  bool isDeadColumn;
254  bool isNoisyColumn;
255 
256  for (int col = 0; col < ncols; col++) {
257  for (int row = 0; row < nrows; row++) {
258  float gain = payload->getGain(col, row, rangeAndCol.first, rangeAndCol.second, isDeadColumn, isNoisyColumn);
259  float ped = payload->getPed(col, row, rangeAndCol.first, rangeAndCol.second, isDeadColumn, isNoisyColumn);
260 
261  switch (subid) {
263  if (isCorrelation_) {
264  hBPix->Fill(gain, ped);
265  } else {
266  hBPix->Fill((theType == gainCalibPI::t_gain ? gain : ped));
267  }
268  break;
269  }
271  if (isCorrelation_) {
272  hFPix->Fill(gain, ped);
273  } else {
274  hFPix->Fill((theType == gainCalibPI::t_gain ? gain : ped));
275  }
276  break;
277  }
278  default:
279  edm::LogError("gainCalibPI::fillTheHistos") << d << " is not a Pixel DetId" << std::endl;
280  break;
281  } // switch on subid
282  } // row loop
283  } // column loop
284  } // detid loop
285  } // filltheHistos
Log< level::Error, false > LogError
const uint16_t range(const Frame &aFrame)
tuple d
Definition: ztail.py:151
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
Definition: DetId.h:17
int col
Definition: cuy.py:1009
template<typename PayloadType >
static void gainCalibHelper::gainCalibPI::fillThePerModuleMap ( const std::shared_ptr< PayloadType > &  payload,
AvgMap &  map,
gainCalibPI::type  theType 
)
static

Definition at line 187 of file SiPixelGainCalibHelper.h.

References cuy::col, ztail::d, SiStripPI::max, sistrip::SpyUtilities::range(), t_gain, and t_pedestal.

Referenced by gainCalibHelper::SiPixelGainCalibrationMap< myType, PayloadType, myDetType >::fill(), and gainCalibHelper::SiPixelGainCalibrationByRegionComparisonBase< myType, PayloadType, nIOVs, ntags >::fill().

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

Variable Documentation

const std::array<std::string, 3> gainCalibHelper::gainCalibPI::t_titles = {{"gain", "pedestal", "correlation"}}
static