CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes
GeometryInterface Class Reference

#include <GeometryInterface.h>

Classes

struct  InterestingQuantities
 

Public Types

typedef ID Column
 
typedef int ID
 
typedef double Value
 
typedef std::vector< std::pair< Column, Value > > Values
 

Public Member Functions

std::vector< InterestingQuantities > const & allModules ()
 
Value binWidth (ID id)
 
std::pair< Column, Valueextract (Column const &col, InterestingQuantities const &iq)
 
Value extract (ID id, DetId did, edm::Event *ev=nullptr, int16_t col=0, int16_t row=0)
 
void extractColumns (std::vector< Column > const &names, InterestingQuantities const &iq, Values &out)
 
std::string formatValue (Column, Value)
 
 GeometryInterface (const edm::ParameterSet &, edm::ConsumesCollector &&, edm::Transition transition=edm::Transition::BeginRun)
 
ID intern (std::string const &id)
 
void load (edm::EventSetup const &iSetup)
 
bool loaded ()
 
Value maxValue (ID id)
 
Value minValue (ID id)
 
std::string pretty (Column col)
 
std::string unintern (ID id)
 

Static Public Attributes

static const Value UNDEFINED = 999999999.9f
 

Private Member Functions

void addExtractor (ID id, std::function< Value(InterestingQuantities const &iq)> func, Value min=UNDEFINED, Value max=UNDEFINED, Value binwidth=1)
 
void loadFEDCabling (const SiPixelFedCablingMap *)
 
void loadFromSiPixelCoordinates (const TrackerGeometry &, const TrackerTopology &, const SiPixelFedCablingMap &, const edm::ParameterSet &)
 
void loadFromTopology (const TrackerGeometry &, const TrackerTopology &, const edm::ParameterSet &)
 
void loadModuleLevel (const edm::ParameterSet &iConfig)
 
void loadTimebased (const edm::ParameterSet &iConfig)
 

Private Attributes

std::vector< InterestingQuantitiesall_modules
 
std::map< ID, Valuebin_width
 
std::string cablingMapLabel_
 
std::vector< std::function< Value(InterestingQuantities const &iq)> > extractors
 
std::map< std::pair< Column, Value >, std::string > format_value
 
const edm::ParameterSet iConfig
 
std::map< std::string, IDids {std::make_pair(std::string("INVALID"), ID(0))}
 
bool is_loaded = false
 
edm::ESGetToken< SiPixelFedCablingMap, SiPixelFedCablingMapRcdlabeledSiPixelFedCablingMapToken_
 
ID max_id = 0
 
std::map< ID, Valuemax_value
 
std::map< ID, Valuemin_value
 
edm::ESGetToken< SiPixelFedCablingMap, SiPixelFedCablingMapRcdsiPixelFedCablingMapToken_
 
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecordtrackerGeometryToken_
 
edm::ESGetToken< TrackerTopology, TrackerTopologyRcdtrackerTopologyToken_
 

Detailed Description

Definition at line 34 of file GeometryInterface.h.

Member Typedef Documentation

◆ Column

Definition at line 40 of file GeometryInterface.h.

◆ ID

typedef int GeometryInterface::ID

Definition at line 37 of file GeometryInterface.h.

◆ Value

typedef double GeometryInterface::Value

Definition at line 41 of file GeometryInterface.h.

◆ Values

typedef std::vector<std::pair<Column, Value> > GeometryInterface::Values

Definition at line 46 of file GeometryInterface.h.

Constructor & Destructor Documentation

◆ GeometryInterface()

GeometryInterface::GeometryInterface ( const edm::ParameterSet conf,
edm::ConsumesCollector &&  iC,
edm::Transition  transition = edm::Transition::BeginRun 
)

Definition at line 34 of file GeometryInterface.cc.

References edm::ParameterSet::getParameter(), and AlCaHLTBitMon_QueryRunRegistry::string.

37  : iConfig(conf), cablingMapLabel_{conf.getParameter<std::string>("CablingMapLabel")} {
38  if (transition == edm::Transition::BeginRun) {
43  if (!cablingMapLabel_.empty()) {
47  }
48  } else {
54  if (!cablingMapLabel_.empty()) {
58  }
59  }
60 }
std::string cablingMapLabel_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > trackerTopologyToken_
const edm::ParameterSet iConfig
edm::ESGetToken< SiPixelFedCablingMap, SiPixelFedCablingMapRcd > labeledSiPixelFedCablingMapToken_
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerGeometryToken_
edm::ESGetToken< SiPixelFedCablingMap, SiPixelFedCablingMapRcd > siPixelFedCablingMapToken_

Member Function Documentation

◆ addExtractor()

void GeometryInterface::addExtractor ( ID  id,
std::function< Value(InterestingQuantities const &iq)>  func,
Value  min = UNDEFINED,
Value  max = UNDEFINED,
Value  binwidth = 1 
)
inlineprivate

◆ allModules()

std::vector<InterestingQuantities> const& GeometryInterface::allModules ( )
inline

Definition at line 99 of file GeometryInterface.h.

References all_modules.

Referenced by SiPixelPhase1GeometryDebug::analyze(), HistogramManager::book(), and HistogramManager::loadFromDQMStore().

99 { return all_modules; }
std::vector< InterestingQuantities > all_modules

◆ binWidth()

Value GeometryInterface::binWidth ( ID  id)
inline

Definition at line 103 of file GeometryInterface.h.

References bin_width, and l1ctLayer2EG_cff::id.

Referenced by HistogramManager::book().

103 { return bin_width[id]; };
std::map< ID, Value > bin_width

◆ extract() [1/2]

std::pair<Column, Value> GeometryInterface::extract ( Column const &  col,
InterestingQuantities const &  iq 
)
inline

Definition at line 76 of file GeometryInterface.h.

References cms::cuda::assert(), cuy::col, extractors, l1ctLayer2EG_cff::id, UNDEFINED, unintern(), and heppy_batch::val.

Referenced by SiPixelPhase1GeometryDebug::analyze(), HistogramManager::book(), extractColumns(), and HistogramManager::fillInternal().

76  {
77  assert(col != 0 || !"Extracting invalid column.");
78  ID id = col;
79  assert(ID(extractors.size()) > id || !"extractors vector too small!");
80  auto& ex = extractors[id];
81  if (!ex) { // we have never heard about this. This is a typo for sure.
82  edm::LogError("GeometryInterface") << "Undefined column used: " << unintern(id) << ". Check your spelling.\n";
83  } else {
84  auto val = ex(iq);
85  if (val != UNDEFINED) {
86  return std::make_pair(Column{id}, val);
87  }
88  }
89  return std::make_pair(col, UNDEFINED);
90  }
Log< level::Error, false > LogError
assert(be >=bs)
std::string unintern(ID id)
static const Value UNDEFINED
col
Definition: cuy.py:1009
std::vector< std::function< Value(InterestingQuantities const &iq)> > extractors

◆ extract() [2/2]

Value GeometryInterface::extract ( ID  id,
DetId  did,
edm::Event ev = nullptr,
int16_t  col = 0,
int16_t  row = 0 
)
inline

Definition at line 92 of file GeometryInterface.h.

References cuy::col, makeMEIFBenchmarkPlots::ev, extractors, and l1ctLayer2EG_cff::id.

92  {
93  InterestingQuantities iq = {ev, did, col, row};
94  return extractors[id](iq);
95  }
col
Definition: cuy.py:1009
std::vector< std::function< Value(InterestingQuantities const &iq)> > extractors

◆ extractColumns()

void GeometryInterface::extractColumns ( std::vector< Column > const &  names,
InterestingQuantities const &  iq,
Values out 
)
inline

Definition at line 66 of file GeometryInterface.h.

References cuy::col, extract(), names, MillePedeFileConverter_cfg::out, and heppy_batch::val.

Referenced by HistogramManager::book(), HistogramManager::executeExtend(), HistogramManager::executeGroupBy(), HistogramManager::executePerEventHarvesting(), HistogramManager::fill(), and HistogramManager::loadFromDQMStore().

66  {
67  out.clear();
68  for (Column const& col : names) {
69  auto val = extract(col, iq);
70  out.push_back(val);
71  }
72  }
const std::string names[nVars_]
std::pair< Column, Value > extract(Column const &col, InterestingQuantities const &iq)
col
Definition: cuy.py:1009

◆ formatValue()

std::string GeometryInterface::formatValue ( Column  col,
Value  val 
)

Definition at line 485 of file GeometryInterface.cc.

References cuy::col, format_value, createfilelist::int, Skims_PA_cff::name, pretty(), AlCaHLTBitMon_QueryRunRegistry::string, cond::impl::to_string(), UNDEFINED, heppy_batch::val, and relativeConstraints::value.

Referenced by HistogramManager::makePathName().

485  {
486  auto it = format_value.find(std::make_pair(col, val));
487  if (it != format_value.end())
488  return it->second;
489 
490  // non-number output names (_pO etc.) are hardwired here.
492  std::string value = "_" + std::to_string(int(val));
493  if (val == 0)
494  value = ""; // hide Barrel_0 etc.
495  if (name == "PXDisk" && val > 0) // +/- sign for disk num
496  value = "_+" + std::to_string(int(val));
497  // pretty (legacy?) names for Shells and HalfCylinders
498  std::map<int, std::string> shellname{{11, "_mI"}, {12, "_mO"}, {21, "_pI"}, {22, "_pO"}};
499  if (name == "HalfCylinder" || name == "Shell")
500  value = shellname[int(val)];
501  if (val == UNDEFINED)
502  value = "_UNDEFINED";
503  return format_value[std::make_pair(col, val)] = name + value;
504 }
std::map< std::pair< Column, Value >, std::string > format_value
std::string pretty(Column col)
std::string to_string(const V &value)
Definition: OMSAccess.h:77
Definition: value.py:1
static const Value UNDEFINED
col
Definition: cuy.py:1009

◆ intern()

ID GeometryInterface::intern ( std::string const &  id)
inline

Definition at line 106 of file GeometryInterface.h.

References extractors, l1ctLayer2EG_cff::id, ids, and max_id.

Referenced by SiPixelPhase1GeometryDebug::analyze(), loadFEDCabling(), loadFromSiPixelCoordinates(), loadFromTopology(), loadModuleLevel(), loadTimebased(), and SummationSpecification::parse_columns().

106  {
107  auto it = ids.find(id);
108  if (it == ids.end()) {
109  ids[id] = ++max_id;
110  extractors.resize(max_id + 1);
111  }
112  return ids[id];
113  };
std::map< std::string, ID > ids
std::vector< std::function< Value(InterestingQuantities const &iq)> > extractors

◆ load()

void GeometryInterface::load ( edm::EventSetup const &  iSetup)

Definition at line 62 of file GeometryInterface.cc.

References electrons_cff::bool, cablingMapLabel_, MillePedeFileConverter_cfg::e, extractors, edm::EventSetup::getData(), iConfig, ids, is_loaded, labeledSiPixelFedCablingMapToken_, loadFEDCabling(), loadFromSiPixelCoordinates(), loadFromTopology(), loadModuleLevel(), loadTimebased(), dqm-mbProfile::log, max_value, min_value, siPixelFedCablingMapToken_, trackerGeometryToken_, and trackerTopologyToken_.

Referenced by HistogramManager::book(), and HistogramManager::executePerLumiHarvesting().

62  {
63  const TrackerGeometry& trackerGeometry = iSetup.getData(trackerGeometryToken_);
64  const TrackerTopology& trackerTopology = iSetup.getData(trackerTopologyToken_);
65  const SiPixelFedCablingMap& siPixelFedCablingMap = iSetup.getData(siPixelFedCablingMapToken_);
66 
67  const SiPixelFedCablingMap* labeledSiPixelFedCablingMap = &siPixelFedCablingMap;
68  if (!cablingMapLabel_.empty()) {
69  labeledSiPixelFedCablingMap = &iSetup.getData(labeledSiPixelFedCablingMapToken_);
70  }
71 
72  //loadFromAlignment(iSetup, iConfig);
73  loadFromTopology(trackerGeometry, trackerTopology, iConfig);
76  loadFEDCabling(labeledSiPixelFedCablingMap);
77  loadFromSiPixelCoordinates(trackerGeometry, trackerTopology, siPixelFedCablingMap, iConfig);
78  edm::LogInfo log("GeometryInterface");
79  log << "Known colum names:\n";
80  for (const auto& e : ids)
81  log << "+++ column: " << e.first << " ok " << bool(extractors[e.second]) << " min " << min_value[e.second]
82  << " max " << max_value[e.second] << "\n";
83  is_loaded = true;
84 }
std::map< ID, Value > max_value
std::string cablingMapLabel_
std::map< std::string, ID > ids
void loadFromTopology(const TrackerGeometry &, const TrackerTopology &, const edm::ParameterSet &)
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > trackerTopologyToken_
void loadModuleLevel(const edm::ParameterSet &iConfig)
void loadFromSiPixelCoordinates(const TrackerGeometry &, const TrackerTopology &, const SiPixelFedCablingMap &, const edm::ParameterSet &)
const edm::ParameterSet iConfig
edm::ESGetToken< SiPixelFedCablingMap, SiPixelFedCablingMapRcd > labeledSiPixelFedCablingMapToken_
void loadFEDCabling(const SiPixelFedCablingMap *)
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerGeometryToken_
edm::ESGetToken< SiPixelFedCablingMap, SiPixelFedCablingMapRcd > siPixelFedCablingMapToken_
std::vector< std::function< Value(InterestingQuantities const &iq)> > extractors
void loadTimebased(const edm::ParameterSet &iConfig)
std::map< ID, Value > min_value

◆ loaded()

bool GeometryInterface::loaded ( )
inline

Definition at line 52 of file GeometryInterface.h.

References is_loaded.

Referenced by HistogramManager::book(), and HistogramManager::executePerLumiHarvesting().

52 { return is_loaded; };

◆ loadFEDCabling()

void GeometryInterface::loadFEDCabling ( const SiPixelFedCablingMap labeledSiPixelFedCablingMap)
private

Definition at line 453 of file GeometryInterface.cc.

References addExtractor(), GeometryInterface::InterestingQuantities::col, runTauDisplay::gp, intern(), DetId::rawId(), GeometryInterface::InterestingQuantities::row, and GeometryInterface::InterestingQuantities::sourceModule.

Referenced by load().

453  {
454  std::shared_ptr<SiPixelFrameReverter> siPixelFrameReverter =
455  // I think passing the bare pointer here is safe, but who knows...
456  std::make_shared<SiPixelFrameReverter>(labeledSiPixelFedCablingMap);
457 
458  addExtractor(intern("FED"), [siPixelFrameReverter](InterestingQuantities const& iq) {
459  if (iq.sourceModule == 0xFFFFFFFF)
460  return Value(iq.col); // hijacked for the raw data plugin
461  return Value(siPixelFrameReverter->findFedId(iq.sourceModule.rawId()));
462  });
463 
464  // TODO: ranges should be set manually below, since booking probably cannot
465  // infer them correctly (no ROC-level granularity)
466  // PERF: this is slow. Prefer SiPixelCordinates versions here.
467  addExtractor(intern("LinkInFed"), [siPixelFrameReverter](InterestingQuantities const& iq) {
468  if (iq.sourceModule == 0xFFFFFFFF)
469  return Value(iq.row); // hijacked for the raw data plugin
470  sipixelobjects::GlobalPixel gp = {iq.row, iq.col};
471  return Value(siPixelFrameReverter->findLinkInFed(iq.sourceModule.rawId(), gp));
472  });
473  // not sure if this is useful anywhere.
474  addExtractor(intern("RocInLink"), [siPixelFrameReverter](InterestingQuantities const& iq) {
475  sipixelobjects::GlobalPixel gp = {iq.row, iq.col};
476  return Value(siPixelFrameReverter->findRocInLink(iq.sourceModule.rawId(), gp));
477  });
478  // This might be equivalent to our ROC numbering.
479  addExtractor(intern("RocInDet"), [siPixelFrameReverter](InterestingQuantities const& iq) {
480  sipixelobjects::GlobalPixel gp = {iq.row, iq.col};
481  return Value(siPixelFrameReverter->findRocInDet(iq.sourceModule.rawId(), gp));
482  });
483 }
void addExtractor(ID id, std::function< Value(InterestingQuantities const &iq)> func, Value min=UNDEFINED, Value max=UNDEFINED, Value binwidth=1)
global coordinates (row and column in DetUnit, as in PixelDigi)
Definition: GlobalPixel.h:6
ID intern(std::string const &id)

◆ loadFromSiPixelCoordinates()

void GeometryInterface::loadFromSiPixelCoordinates ( const TrackerGeometry trackerGeometry,
const TrackerTopology trackerTopology,
const SiPixelFedCablingMap siPixelFedCablingMap,
const edm::ParameterSet iConfig 
)
private

Definition at line 197 of file GeometryInterface.cc.

References addExtractor(), GeometryInterface::InterestingQuantities::col, extractors, edm::ParameterSet::getParameter(), iConfig, recoMuon::in, intern(), SiPixelPI::quadrant(), GeometryInterface::InterestingQuantities::row, GeometryInterface::InterestingQuantities::sourceModule, and UNDEFINED.

Referenced by load().

200  {
201  // TODO: SiPixelCoordinates has a large overlap with theis GeometryInterface
202  // in general.
203  // Rough convention is to use own code for things that are easy and fast to
204  // determine, and use SiPixelCoordinates for complicated things.
205  // SiPixelCoordinates uses lookup maps for everything, so it is faster than
206  // most other code, but still slow on DQM scales.
207  int phase = iConfig.getParameter<int>("upgradePhase");
208 
209  // this shared pointer is kept alive by the references in the lambdas that follow.
210  // That is a bit less obvious than keeping it as a member but more correct.
211  auto coord = std::make_shared<SiPixelCoordinates>(phase);
212 
213  // note that we should reeinit for each event. But this probably won't explode
214  // thanks to the massive memoization in SiPixelCoordinates which is completely
215  // initialized while booking.
216  coord->init(&trackerTopology, &trackerGeometry, &siPixelFedCablingMap);
217 
218  // SiPixelCoordinates uses a different convention for UNDEFINED:
219  auto from_coord = [](double in) { return (in == -9999.0) ? UNDEFINED : Value(in); };
220 
221  // Rings are a concept that cannot be derived from bitmasks.
222  addExtractor(intern("PXRing"), [coord, from_coord](InterestingQuantities const& iq) {
223  return from_coord(coord->ring(iq.sourceModule));
224  });
225 
226  // Quadrant names.
227  auto pxbarrel = extractors[intern("PXBarrel")];
228  addExtractor(
229  intern("HalfCylinder"),
230  [coord, pxbarrel](InterestingQuantities const& iq) {
231  if (pxbarrel(iq) != UNDEFINED)
232  return UNDEFINED;
233  int quadrant = coord->quadrant(iq.sourceModule);
234  switch (quadrant) {
235  case 1:
236  return Value(12); // mO
237  case 2:
238  return Value(11); // mI
239  case 3:
240  return Value(22); // pO
241  case 4:
242  return Value(21); // pI
243  default:
244  return UNDEFINED;
245  }
246  },
247  0,
248  0 // N/A
249  );
250  addExtractor(
251  intern("Shell"),
252  [coord, pxbarrel](InterestingQuantities const& iq) {
253  if (pxbarrel(iq) == UNDEFINED)
254  return UNDEFINED;
255  int quadrant = coord->quadrant(iq.sourceModule);
256  switch (quadrant) {
257  case 1:
258  return Value(12); // mO
259  case 2:
260  return Value(11); // mI
261  case 3:
262  return Value(22); // pO
263  case 4:
264  return Value(21); // pI
265  default:
266  return UNDEFINED;
267  }
268  },
269  0,
270  0 // N/A
271  );
272 
273  // Online Numbering.
274  addExtractor(intern("SignedLadder"), [coord, from_coord](InterestingQuantities const& iq) {
275  return from_coord(coord->signed_ladder(iq.sourceModule()));
276  });
277  addExtractor(intern("SignedModule"), [coord, from_coord](InterestingQuantities const& iq) {
278  return from_coord(coord->signed_module(iq.sourceModule()));
279  });
280  addExtractor(intern("SignedBlade"), [coord, from_coord](InterestingQuantities const& iq) {
281  return from_coord(coord->signed_blade(iq.sourceModule()));
282  });
283 
284  // Flipped and Outer ladders
285  addExtractor(intern("OuterLadder"), [coord, from_coord](InterestingQuantities const& iq) {
286  return from_coord(coord->outer(iq.sourceModule()));
287  });
288  addExtractor(intern("FlippedLadder"), [coord, from_coord](InterestingQuantities const& iq) {
289  return from_coord(coord->flipped(iq.sourceModule()));
290  });
291 
292  // Pixel Map axis.
293  // TODO: automatic range and binning for phase0 are incorrect.
294  // Should be set manually here.
295  addExtractor(
296  intern("SignedModuleCoord"), // BPIX x
297  [coord, from_coord](InterestingQuantities const& iq) {
298  return from_coord(coord->signed_module_coord(iq.sourceModule(), std::make_pair(int(iq.row), int(iq.col))));
299  },
300  UNDEFINED,
301  UNDEFINED,
302  1.0 / 8.0);
303  addExtractor(
304  intern("SignedLadderCoord"), // BPIX y
305  [coord, from_coord](InterestingQuantities const& iq) {
306  return from_coord(coord->signed_ladder_coord(iq.sourceModule(), std::make_pair(int(iq.row), int(iq.col))));
307  },
308  UNDEFINED,
309  UNDEFINED,
310  1.0 / 2.0);
311  addExtractor(
312  intern("SignedDiskCoord"), // FPIX x (per-ring)
313  [coord, from_coord](InterestingQuantities const& iq) {
314  return from_coord(coord->signed_disk_coord(iq.sourceModule(), std::make_pair(int(iq.row), int(iq.col))));
315  },
316  UNDEFINED,
317  UNDEFINED,
318  1.0 / 8.0);
319  addExtractor(
320  intern("SignedDiskRingCoord"), // FPIX x (FPIX-as-one-plot)
321  [coord, from_coord](InterestingQuantities const& iq) {
322  return from_coord(coord->signed_disk_ring_coord(iq.sourceModule(), std::make_pair(int(iq.row), int(iq.col))));
323  },
324  UNDEFINED,
325  UNDEFINED,
326  1.0 / 16.0);
327  addExtractor(
328  intern("SignedBladePanelCoord"), // FPIX y
329  [coord, from_coord, phase](InterestingQuantities const& iq) {
330  if (phase == 0) {
331  return from_coord(coord->signed_blade_coord(iq.sourceModule(), std::make_pair(int(iq.row), int(iq.col))));
332  } else if (phase == 1) {
333  return from_coord(
334  coord->signed_blade_panel_coord(iq.sourceModule(), std::make_pair(int(iq.row), int(iq.col))));
335  } else {
336  return UNDEFINED; // TODO: phase2
337  }
338  },
339  UNDEFINED,
340  UNDEFINED,
341  phase == 1 ? 0.25 : 0.2);
342  addExtractor(
343  intern("SignedShiftedBladePanelCoord"), // FPIX-as-one y
344  [coord, from_coord, phase](InterestingQuantities const& iq) {
345  if (phase == 0) {
346  return from_coord(coord->signed_blade_coord(iq.sourceModule(), std::make_pair(int(iq.row), int(iq.col))));
347  } else if (phase == 1) {
348  return from_coord(
349  coord->signed_shifted_blade_panel_coord(iq.sourceModule(), std::make_pair(int(iq.row), int(iq.col))));
350  } else {
351  return UNDEFINED; // TODO: phase2
352  }
353  },
354  UNDEFINED,
355  UNDEFINED,
356  phase == 1 ? 0.25 : 0.1 // half-roc for phase0
357  );
358  addExtractor(
359  intern("SignedBladePanel"), // per-module FPIX y
360  [coord, from_coord](InterestingQuantities const& iq) {
361  return from_coord(coord->signed_blade_panel_coord(iq.sourceModule(), std::make_pair(int(iq.row), int(iq.col))));
362  },
363  UNDEFINED,
364  UNDEFINED,
365  1.0 / 2.0);
366 
367  addExtractor(
368  intern("SignedBladePanel"),
369  [coord, from_coord](InterestingQuantities const& iq) {
370  return from_coord(coord->signed_blade_panel_coord(iq.sourceModule(), std::make_pair(int(iq.row), int(iq.col))));
371  },
372  UNDEFINED,
373  UNDEFINED,
374  1.0 / 2.0);
375 
376  // more readout-related things.
377  addExtractor(intern("ROC"), [coord, from_coord](InterestingQuantities const& iq) {
378  return from_coord(coord->roc(iq.sourceModule(), std::make_pair(int(iq.row), int(iq.col))));
379  });
380  addExtractor(intern("Sector"), [coord, from_coord](InterestingQuantities const& iq) {
381  return from_coord(coord->sector(iq.sourceModule()));
382  });
383  addExtractor(intern("Channel"), [coord, from_coord](InterestingQuantities const& iq) {
384  return from_coord(coord->channel(iq.sourceModule(), std::make_pair(int(iq.row), int(iq.col))));
385  });
386 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void addExtractor(ID id, std::function< Value(InterestingQuantities const &iq)> func, Value min=UNDEFINED, Value max=UNDEFINED, Value binwidth=1)
int quadrant(const DetId &detid, const TrackerTopology *tTopo_, bool phase_)
const edm::ParameterSet iConfig
static const Value UNDEFINED
std::vector< std::function< Value(InterestingQuantities const &iq)> > extractors
ID intern(std::string const &id)

◆ loadFromTopology()

void GeometryInterface::loadFromTopology ( const TrackerGeometry trackerGeometry,
const TrackerTopology trackerTopology,
const edm::ParameterSet iConfig 
)
private

Definition at line 86 of file GeometryInterface.cc.

References addExtractor(), all_modules, cms::cuda::assert(), TrackerGeometry::detIds(), MillePedeFileConverter_cfg::e, makeMuonMisalignmentScenario::endcap, extractors, format_value, edm::ParameterSet::getParameter(), iConfig, l1ctLayer2EG_cff::id, TrackerGeometry::idToDetUnit(), intern(), SiPixelOfflineDQM_client_cff::isUpgrade, mod(), Skims_PA_cff::name, PixelTopology::ncolumns(), PixelTopology::nrows(), TrackerTopology::PBLadder, TrackerTopology::PBLayer, TrackerTopology::PBModule, TrackerTopology::PFBlade, TrackerTopology::PFDisk, TrackerTopology::PFModule, TrackerTopology::PFPanel, TrackerTopology::PFSide, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, GeometryInterface::InterestingQuantities::sourceModule, PixelGeomDetUnit::specificTopology(), AlCaHLTBitMon_QueryRunRegistry::string, groupFilesInBlocks::tt, and UNDEFINED.

Referenced by load().

88  {
89  std::vector<ID> geomquantities;
90 
91  struct TTField {
92  const TrackerTopology* tt;
94  Value operator()(InterestingQuantities const& iq) {
95  if (tt->hasField(iq.sourceModule, field))
96  return tt->getField(iq.sourceModule, field);
97  else
98  return UNDEFINED;
99  };
100  };
101 
102  const TrackerTopology* tt = &trackerTopology;
103 
104  std::vector<std::pair<std::string, TTField>> namedPartitions{
105  {"PXEndcap", {tt, TrackerTopology::PFSide}},
106 
107  {"PXLayer", {tt, TrackerTopology::PBLayer}},
108  {"PXLadder", {tt, TrackerTopology::PBLadder}},
109  {"PXBModule", {tt, TrackerTopology::PBModule}},
110 
111  {"PXBlade", {tt, TrackerTopology::PFBlade}},
112  {"PXDisk", {tt, TrackerTopology::PFDisk}},
113  {"PXPanel", {tt, TrackerTopology::PFPanel}},
114  {"PXFModule", {tt, TrackerTopology::PFModule}},
115  };
116 
117  for (auto& e : namedPartitions) {
118  geomquantities.push_back(intern(e.first));
119  addExtractor(intern(e.first), e.second, UNDEFINED, UNDEFINED);
120  }
121 
122  auto pxbarrel = [](InterestingQuantities const& iq) {
123  return iq.sourceModule.subdetId() == PixelSubdetector::PixelBarrel ? 0 : UNDEFINED;
124  };
125  auto pxforward = [](InterestingQuantities const& iq) {
126  return iq.sourceModule.subdetId() == PixelSubdetector::PixelEndcap ? 0 : UNDEFINED;
127  };
128  auto pxall = [](InterestingQuantities const& iq) { return 0; };
129  addExtractor(intern("PXBarrel"), pxbarrel, 0, 0);
130  addExtractor(intern("PXForward"), pxforward, 0, 0);
131  addExtractor(intern("PXAll"), pxall, 0, 0);
132 
133  // Redefine the disk numbering to use the sign
134  auto pxendcap = extractors[intern("PXEndcap")];
135  auto diskid = intern("PXDisk");
136  auto pxdisk = extractors[diskid];
137  extractors[diskid] = [pxdisk, pxendcap](InterestingQuantities const& iq) {
138  auto disk = pxdisk(iq);
139  if (disk == UNDEFINED)
140  return UNDEFINED;
141  auto endcap = pxendcap(iq);
142  return endcap == 1 ? -disk : disk;
143  };
144 
145  // DetId and module names
146  auto detid = [](InterestingQuantities const& iq) {
147  uint32_t id = iq.sourceModule.rawId();
148  return Value(id);
149  };
150  addExtractor(intern("DetId"), detid, 0, 0 // No sane value possible here.
151  );
152  // these are just aliases with special handling in formatting
153  // the names are created with PixelBarrelName et. al. later
154  addExtractor(intern("PXModuleName"), detid, 0, 0);
155 
156  int phase = iConfig.getParameter<int>("upgradePhase");
157  bool isUpgrade = phase == 1;
158 
159  // Now traverse the detector and collect whatever we need.
160  auto detids = trackerGeometry.detIds();
161  for (DetId id : detids) {
162  if (id.subdetId() != PixelSubdetector::PixelBarrel && id.subdetId() != PixelSubdetector::PixelEndcap)
163  continue;
164  auto iq = InterestingQuantities{nullptr, id, 0, 0};
165 
166  // prepare pretty names
167  std::string name = "";
168  if (id.subdetId() == PixelSubdetector::PixelBarrel) { // Barrel
170  name = mod.name();
171  } else { // assume Endcap
173  name = mod.name();
174  }
175  format_value[std::make_pair(intern("PXModuleName"), Value(id.rawId()))] = name;
176 
177  // we record each module 4 times, one for each corner, so we also get ROCs
178  // in booking (at least for the ranges)
179  const PixelGeomDetUnit* detUnit = dynamic_cast<const PixelGeomDetUnit*>(trackerGeometry.idToDetUnit(id));
180  assert(detUnit);
181  const PixelTopology* topo = &detUnit->specificTopology();
182  iq.row = 0;
183  iq.col = 0;
184  all_modules.push_back(iq);
185  iq.row = topo->nrows() - 1;
186  iq.col = 0;
187  all_modules.push_back(iq);
188  iq.row = 0;
189  iq.col = topo->ncolumns() - 1;
190  all_modules.push_back(iq);
191  iq.row = topo->nrows() - 1;
192  iq.col = topo->ncolumns() - 1;
193  all_modules.push_back(iq);
194  }
195 }
std::map< std::pair< Column, Value >, std::string > format_value
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
virtual int ncolumns() const =0
const DetIdContainer & detIds() const override
Returm a vector of all GeomDet DetIds (including those of GeomDetUnits)
void addExtractor(ID id, std::function< Value(InterestingQuantities const &iq)> func, Value min=UNDEFINED, Value max=UNDEFINED, Value binwidth=1)
virtual int nrows() const =0
assert(be >=bs)
Definition: TTTypes.h:54
const edm::ParameterSet iConfig
std::vector< InterestingQuantities > all_modules
static const Value UNDEFINED
Definition: DetId.h:17
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
std::vector< std::function< Value(InterestingQuantities const &iq)> > extractors
ID intern(std::string const &id)
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4

◆ loadModuleLevel()

void GeometryInterface::loadModuleLevel ( const edm::ParameterSet iConfig)
private

Definition at line 439 of file GeometryInterface.cc.

References addExtractor(), GeometryInterface::InterestingQuantities::col, edm::ParameterSet::getParameter(), iConfig, intern(), and GeometryInterface::InterestingQuantities::row.

Referenced by load().

439  {
440  // stuff that is within modules. Might require some phase0/phase1/strip switching later
441  addExtractor(
442  intern("row"),
443  [](InterestingQuantities const& iq) { return Value(iq.row); },
444  0,
445  iConfig.getParameter<int>("module_rows") - 1);
446  addExtractor(
447  intern("col"),
448  [](InterestingQuantities const& iq) { return Value(iq.col); },
449  0,
450  iConfig.getParameter<int>("module_cols") - 1);
451 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void addExtractor(ID id, std::function< Value(InterestingQuantities const &iq)> func, Value min=UNDEFINED, Value max=UNDEFINED, Value binwidth=1)
const edm::ParameterSet iConfig
ID intern(std::string const &id)

◆ loadTimebased()

void GeometryInterface::loadTimebased ( const edm::ParameterSet iConfig)
private

Definition at line 388 of file GeometryInterface.cc.

References addExtractor(), edm::EventBase::bunchCrossing(), edm::ParameterSet::getParameter(), iConfig, intern(), HistogramManager_cfi::lumiblock, edm::EventBase::luminosityBlock(), HistogramManager_cfi::n_onlineblocks, HistogramManager_cfi::onlineblock, GeometryInterface::InterestingQuantities::sourceEvent, and UNDEFINED.

Referenced by load().

388  {
389  // extractors for quantities that are roughly time-based. We cannot book plots based on these; they have to
390  // be grouped away in step1.
391  addExtractor(
392  intern("Lumisection"),
393  [](InterestingQuantities const& iq) {
394  if (!iq.sourceEvent)
395  return UNDEFINED;
396  return Value(iq.sourceEvent->luminosityBlock());
397  },
398  1,
399  iConfig.getParameter<int>("max_lumisection"));
400 
401  int onlineblock = iConfig.getParameter<int>("onlineblock");
402  int n_onlineblocks = iConfig.getParameter<int>("n_onlineblocks");
403  addExtractor(
404  intern("OnlineBlock"),
405  [onlineblock](InterestingQuantities const& iq) {
406  if (!iq.sourceEvent)
407  return UNDEFINED;
408  return Value(onlineblock + iq.sourceEvent->luminosityBlock() / onlineblock);
409  },
410  // note: this range is not visible anywhere (if the RenderPlugin does its job),
411  // but the strange range allows the RenderPlugin to know the block size.
412  onlineblock,
414 
415  int lumiblock = iConfig.getParameter<int>("lumiblock");
416  addExtractor(
417  intern("LumiBlock"),
418  [lumiblock](InterestingQuantities const& iq) {
419  if (!iq.sourceEvent)
420  return UNDEFINED;
421  // The '-1' is for making 1-10 the same block rather than 0-9
422  // The '+0.5' makes the block span an integer range rather n.5-m.5
423  return Value(((iq.sourceEvent->luminosityBlock() - 1) / lumiblock) + 0.5);
424  },
425  -0.5,
426  iConfig.getParameter<int>("max_lumisection") / lumiblock);
427 
428  addExtractor(
429  intern("BX"),
430  [](InterestingQuantities const& iq) {
431  if (!iq.sourceEvent)
432  return UNDEFINED;
433  return Value(iq.sourceEvent->bunchCrossing());
434  },
435  1,
436  iConfig.getParameter<int>("max_bunchcrossing"));
437 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void addExtractor(ID id, std::function< Value(InterestingQuantities const &iq)> func, Value min=UNDEFINED, Value max=UNDEFINED, Value binwidth=1)
const edm::ParameterSet iConfig
static const Value UNDEFINED
ID intern(std::string const &id)

◆ maxValue()

Value GeometryInterface::maxValue ( ID  id)
inline

Definition at line 101 of file GeometryInterface.h.

References l1ctLayer2EG_cff::id, and max_value.

Referenced by HistogramManager::book().

101 { return max_value[id]; };
std::map< ID, Value > max_value

◆ minValue()

Value GeometryInterface::minValue ( ID  id)
inline

Definition at line 102 of file GeometryInterface.h.

References l1ctLayer2EG_cff::id, and min_value.

Referenced by HistogramManager::book().

102 { return min_value[id]; };
std::map< ID, Value > min_value

◆ pretty()

std::string GeometryInterface::pretty ( Column  col)
inline

Definition at line 125 of file GeometryInterface.h.

References cuy::col, and unintern().

Referenced by HistogramManager::book(), HistogramManager::executeExtend(), formatValue(), and HistogramManager::makePathName().

125 { return unintern(col); }
std::string unintern(ID id)
col
Definition: cuy.py:1009

◆ unintern()

std::string GeometryInterface::unintern ( ID  id)
inline

Definition at line 118 of file GeometryInterface.h.

References MillePedeFileConverter_cfg::e, and ids.

Referenced by extract(), and pretty().

118  {
119  for (auto& e : ids)
120  if (e.second == id)
121  return e.first;
122  return "INVALID";
123  }
std::map< std::string, ID > ids

Member Data Documentation

◆ all_modules

std::vector<InterestingQuantities> GeometryInterface::all_modules
private

Definition at line 180 of file GeometryInterface.h.

Referenced by allModules(), and loadFromTopology().

◆ bin_width

std::map<ID, Value> GeometryInterface::bin_width
private

Definition at line 163 of file GeometryInterface.h.

Referenced by addExtractor(), and binWidth().

◆ cablingMapLabel_

std::string GeometryInterface::cablingMapLabel_
private

Definition at line 152 of file GeometryInterface.h.

Referenced by load().

◆ extractors

std::vector<std::function<Value(InterestingQuantities const& iq)> > GeometryInterface::extractors
private

◆ format_value

std::map<std::pair<Column, Value>, std::string> GeometryInterface::format_value
private

Definition at line 167 of file GeometryInterface.h.

Referenced by formatValue(), and loadFromTopology().

◆ iConfig

const edm::ParameterSet GeometryInterface::iConfig
private

◆ ids

std::map<std::string, ID> GeometryInterface::ids {std::make_pair(std::string("INVALID"), ID(0))}
private

Definition at line 183 of file GeometryInterface.h.

Referenced by intern(), load(), and unintern().

◆ is_loaded

bool GeometryInterface::is_loaded = false
private

Definition at line 154 of file GeometryInterface.h.

Referenced by load(), and loaded().

◆ labeledSiPixelFedCablingMapToken_

edm::ESGetToken<SiPixelFedCablingMap, SiPixelFedCablingMapRcd> GeometryInterface::labeledSiPixelFedCablingMapToken_
private

Definition at line 151 of file GeometryInterface.h.

Referenced by load().

◆ max_id

ID GeometryInterface::max_id = 0
private

Definition at line 184 of file GeometryInterface.h.

Referenced by intern().

◆ max_value

std::map<ID, Value> GeometryInterface::max_value
private

Definition at line 161 of file GeometryInterface.h.

Referenced by addExtractor(), load(), and maxValue().

◆ min_value

std::map<ID, Value> GeometryInterface::min_value
private

Definition at line 162 of file GeometryInterface.h.

Referenced by addExtractor(), load(), and minValue().

◆ siPixelFedCablingMapToken_

edm::ESGetToken<SiPixelFedCablingMap, SiPixelFedCablingMapRcd> GeometryInterface::siPixelFedCablingMapToken_
private

Definition at line 150 of file GeometryInterface.h.

Referenced by load().

◆ trackerGeometryToken_

edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> GeometryInterface::trackerGeometryToken_
private

Definition at line 141 of file GeometryInterface.h.

Referenced by load().

◆ trackerTopologyToken_

edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> GeometryInterface::trackerTopologyToken_
private

Definition at line 142 of file GeometryInterface.h.

Referenced by load().

◆ UNDEFINED

const GeometryInterface::Value GeometryInterface::UNDEFINED = 999999999.9f
static