CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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=0, 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 &conf)
 
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 (edm::EventSetup const &iSetup, const edm::ParameterSet &iConfig)
 
void loadFromSiPixelCoordinates (edm::EventSetup const &iSetup, const edm::ParameterSet &iConfig)
 
void loadFromTopology (edm::EventSetup const &iSetup, const edm::ParameterSet &iConfig)
 
void loadModuleLevel (edm::EventSetup const &iSetup, const edm::ParameterSet &iConfig)
 
void loadTimebased (edm::EventSetup const &iSetup, const edm::ParameterSet &iConfig)
 

Private Attributes

std::vector< InterestingQuantitiesall_modules
 
std::map< ID, Valuebin_width
 
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
 
ID max_id = 0
 
std::map< ID, Valuemax_value
 
std::map< ID, Valuemin_value
 

Detailed Description

Definition at line 24 of file GeometryInterface.h.

Member Typedef Documentation

Definition at line 30 of file GeometryInterface.h.

typedef int GeometryInterface::ID

Definition at line 27 of file GeometryInterface.h.

typedef double GeometryInterface::Value

Definition at line 31 of file GeometryInterface.h.

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

Definition at line 36 of file GeometryInterface.h.

Constructor & Destructor Documentation

GeometryInterface::GeometryInterface ( const edm::ParameterSet conf)
inline

Definition at line 38 of file GeometryInterface.h.

38 : iConfig(conf){};
const edm::ParameterSet iConfig

Member Function Documentation

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

Definition at line 141 of file GeometryInterface.h.

References TrackCollections2monitor_cff::func, triggerObjects_cff::id, SiStripPI::max, and min().

Referenced by loadFEDCabling(), loadFromSiPixelCoordinates(), loadFromTopology(), loadModuleLevel(), and loadTimebased().

145  {
146  max_value[id] = max;
147  min_value[id] = min;
148  bin_width[id] = binwidth;
149  extractors[id] = func;
150  }
std::map< ID, Value > max_value
std::map< ID, Value > bin_width
T min(T a, T b)
Definition: MathUtil.h:58
std::vector< std::function< Value(InterestingQuantities const &iq)> > extractors
std::map< ID, Value > min_value
std::vector<InterestingQuantities> const& GeometryInterface::allModules ( )
inline

Definition at line 87 of file GeometryInterface.h.

References all_modules.

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

87 { return all_modules; }
std::vector< InterestingQuantities > all_modules
Value GeometryInterface::binWidth ( ID  id)
inline

Definition at line 91 of file GeometryInterface.h.

References bin_width, and triggerObjects_cff::id.

Referenced by HistogramManager::book().

91 { return bin_width[id]; };
std::map< ID, Value > bin_width
std::pair<Column, Value> GeometryInterface::extract ( Column const &  col,
InterestingQuantities const &  iq 
)
inline

Definition at line 64 of file GeometryInterface.h.

References GeometryInterface::InterestingQuantities::col, extractors, triggerObjects_cff::id, unintern(), and heppy_batch::val.

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

64  {
65  assert(col != 0 || !"Extracting invalid column.");
66  ID id = col;
67  assert(ID(extractors.size()) > id || !"extractors vector too small!");
68  auto& ex = extractors[id];
69  if (!ex) { // we have never heard about this. This is a typo for sure.
70  edm::LogError("GeometryInterface") << "Undefined column used: " << unintern(id) << ". Check your spelling.\n";
71  } else {
72  auto val = ex(iq);
73  if (val != UNDEFINED) {
74  return std::make_pair(Column{id}, val);
75  }
76  }
77  return std::make_pair(col, UNDEFINED);
78  }
std::string unintern(ID id)
static const Value UNDEFINED
col
Definition: cuy.py:1010
std::vector< std::function< Value(InterestingQuantities const &iq)> > extractors
Value GeometryInterface::extract ( ID  id,
DetId  did,
edm::Event ev = 0,
int16_t  col = 0,
int16_t  row = 0 
)
inline

Definition at line 80 of file GeometryInterface.h.

References GeometryInterface::InterestingQuantities::col, ev, extractors, triggerObjects_cff::id, and GeometryInterface::InterestingQuantities::row.

80  {
81  InterestingQuantities iq = {ev, did, col, row};
82  return extractors[id](iq);
83  }
bool ev
col
Definition: cuy.py:1010
std::vector< std::function< Value(InterestingQuantities const &iq)> > extractors
void GeometryInterface::extractColumns ( std::vector< Column > const &  names,
InterestingQuantities const &  iq,
Values out 
)
inline

Definition at line 54 of file GeometryInterface.h.

References GeometryInterface::InterestingQuantities::col, extract(), and heppy_batch::val.

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

54  {
55  out.clear();
56  for (Column const& col : names) {
57  auto val = extract(col, iq);
58  out.push_back(val);
59  }
60  }
const std::string names[nVars_]
std::pair< Column, Value > extract(Column const &col, InterestingQuantities const &iq)
col
Definition: cuy.py:1010
std::string GeometryInterface::formatValue ( Column  col,
Value  val 
)

Definition at line 467 of file GeometryInterface.cc.

References format_value, createfilelist::int, Skims_PA_cff::name, pretty(), AlCaHLTBitMon_QueryRunRegistry::string, UNDEFINED, and relativeConstraints::value.

Referenced by HistogramManager::makePathName(), and pretty().

467  {
468  auto it = format_value.find(std::make_pair(col, val));
469  if (it != format_value.end())
470  return it->second;
471 
472  // non-number output names (_pO etc.) are hardwired here.
473  std::string name = pretty(col);
474  std::string value = "_" + std::to_string(int(val));
475  if (val == 0)
476  value = ""; // hide Barrel_0 etc.
477  if (name == "PXDisk" && val > 0) // +/- sign for disk num
478  value = "_+" + std::to_string(int(val));
479  // pretty (legacy?) names for Shells and HalfCylinders
480  std::map<int, std::string> shellname{{11, "_mI"}, {12, "_mO"}, {21, "_pI"}, {22, "_pO"}};
481  if (name == "HalfCylinder" || name == "Shell")
482  value = shellname[int(val)];
483  if (val == UNDEFINED)
484  value = "_UNDEFINED";
485  return format_value[std::make_pair(col, val)] = name + value;
486 }
std::map< std::pair< Column, Value >, std::string > format_value
std::string pretty(Column col)
Definition: value.py:1
static const Value UNDEFINED
ID GeometryInterface::intern ( std::string const &  id)
inline

Definition at line 94 of file GeometryInterface.h.

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

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

94  {
95  auto it = ids.find(id);
96  if (it == ids.end()) {
97  ids[id] = ++max_id;
98  extractors.resize(max_id + 1);
99  }
100  return ids[id];
101  };
std::map< std::string, ID > ids
std::vector< std::function< Value(InterestingQuantities const &iq)> > extractors
void GeometryInterface::load ( edm::EventSetup const &  iSetup)

Definition at line 44 of file GeometryInterface.cc.

References electrons_cff::bool, MillePedeFileConverter_cfg::e, extractors, iConfig, ids, is_loaded, loadFEDCabling(), loadFromSiPixelCoordinates(), loadFromTopology(), loadModuleLevel(), loadTimebased(), dqm-mbProfile::log, max_value, and min_value.

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

44  {
45  //loadFromAlignment(iSetup, iConfig);
46  loadFromTopology(iSetup, iConfig);
47  loadTimebased(iSetup, iConfig);
48  loadModuleLevel(iSetup, iConfig);
49  loadFEDCabling(iSetup, iConfig);
51  edm::LogInfo log("GeometryInterface");
52  log << "Known colum names:\n";
53  for (auto e : ids)
54  log << "+++ column: " << e.first << " ok " << bool(extractors[e.second]) << " min " << min_value[e.second]
55  << " max " << max_value[e.second] << "\n";
56  is_loaded = true;
57 }
std::map< ID, Value > max_value
std::map< std::string, ID > ids
void loadFromTopology(edm::EventSetup const &iSetup, const edm::ParameterSet &iConfig)
const edm::ParameterSet iConfig
void loadFEDCabling(edm::EventSetup const &iSetup, const edm::ParameterSet &iConfig)
void loadModuleLevel(edm::EventSetup const &iSetup, const edm::ParameterSet &iConfig)
std::vector< std::function< Value(InterestingQuantities const &iq)> > extractors
std::map< ID, Value > min_value
void loadTimebased(edm::EventSetup const &iSetup, const edm::ParameterSet &iConfig)
void loadFromSiPixelCoordinates(edm::EventSetup const &iSetup, const edm::ParameterSet &iConfig)
bool GeometryInterface::loaded ( )
inline

Definition at line 40 of file GeometryInterface.h.

References is_loaded, and load().

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

40 { return is_loaded; };
void GeometryInterface::loadFEDCabling ( edm::EventSetup const &  iSetup,
const edm::ParameterSet iConfig 
)
private

Definition at line 431 of file GeometryInterface.cc.

References addExtractor(), GeometryInterface::InterestingQuantities::col, edm::EventSetup::get(), edm::ParameterSet::getParameter(), runTauDisplay::gp, intern(), DetId::rawId(), GeometryInterface::InterestingQuantities::row, GeometryInterface::InterestingQuantities::sourceModule, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by load(), and pretty().

431  {
432  auto cablingMapLabel = iConfig.getParameter<std::string>("CablingMapLabel");
434  iSetup.get<SiPixelFedCablingMapRcd>().get(cablingMapLabel, theCablingMap);
435 
436  std::shared_ptr<SiPixelFrameReverter> siPixelFrameReverter =
437  // I think passing the bare pointer here is safe, but who knows...
438  std::make_shared<SiPixelFrameReverter>(iSetup, theCablingMap.operator->());
439 
440  addExtractor(intern("FED"), [siPixelFrameReverter](InterestingQuantities const& iq) {
441  if (iq.sourceModule == 0xFFFFFFFF)
442  return Value(iq.col); // hijacked for the raw data plugin
443  return Value(siPixelFrameReverter->findFedId(iq.sourceModule.rawId()));
444  });
445 
446  // TODO: ranges should be set manually below, since booking probably cannot
447  // infer them correctly (no ROC-level granularity)
448  // PERF: this is slow. Prefer SiPixelCordinates versions here.
449  addExtractor(intern("LinkInFed"), [siPixelFrameReverter](InterestingQuantities const& iq) {
450  if (iq.sourceModule == 0xFFFFFFFF)
451  return Value(iq.row); // hijacked for the raw data plugin
452  sipixelobjects::GlobalPixel gp = {iq.row, iq.col};
453  return Value(siPixelFrameReverter->findLinkInFed(iq.sourceModule.rawId(), gp));
454  });
455  // not sure if this is useful anywhere.
456  addExtractor(intern("RocInLink"), [siPixelFrameReverter](InterestingQuantities const& iq) {
457  sipixelobjects::GlobalPixel gp = {iq.row, iq.col};
458  return Value(siPixelFrameReverter->findRocInLink(iq.sourceModule.rawId(), gp));
459  });
460  // This might be equivalent to our ROC numbering.
461  addExtractor(intern("RocInDet"), [siPixelFrameReverter](InterestingQuantities const& iq) {
462  sipixelobjects::GlobalPixel gp = {iq.row, iq.col};
463  return Value(siPixelFrameReverter->findRocInDet(iq.sourceModule.rawId(), gp));
464  });
465 }
T getParameter(std::string const &) const
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)
void GeometryInterface::loadFromSiPixelCoordinates ( edm::EventSetup const &  iSetup,
const edm::ParameterSet iConfig 
)
private

Definition at line 178 of file GeometryInterface.cc.

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

Referenced by load(), and pretty().

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

Definition at line 59 of file GeometryInterface.cc.

References addExtractor(), all_modules, TrackerGeometry::detIds(), MillePedeFileConverter_cfg::e, makeMuonMisalignmentScenario::endcap, extractors, format_value, edm::EventSetup::get(), TrackerTopology::getField(), edm::ParameterSet::getParameter(), TrackerTopology::hasField(), triggerObjects_cff::id, TrackerGeometry::idToDetUnit(), intern(), SiPixelOfflineDQM_client_cff::isUpgrade, edm::ESHandleBase::isValid(), mod(), Skims_PA_cff::name, PixelBarrelName::name(), PixelEndcapName::name(), PixelTopology::ncolumns(), PixelTopology::nrows(), TrackerTopology::PBLadder, TrackerTopology::PBLayer, TrackerTopology::PBModule, TrackerTopology::PFBlade, TrackerTopology::PFDisk, TrackerTopology::PFModule, TrackerTopology::PFPanel, TrackerTopology::PFSide, HLT_2018_cff::phase, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, GeometryInterface::InterestingQuantities::sourceModule, PixelGeomDetUnit::specificTopology(), AlCaHLTBitMon_QueryRunRegistry::string, groupFilesInBlocks::tt, and UNDEFINED.

Referenced by load(), and pretty().

59  {
60  // Get a Topology
61  edm::ESHandle<TrackerTopology> trackerTopologyHandle;
62  iSetup.get<TrackerTopologyRcd>().get(trackerTopologyHandle);
63  assert(trackerTopologyHandle.isValid());
64 
65  std::vector<ID> geomquantities;
66 
67  struct TTField {
68  const TrackerTopology* tt;
70  Value operator()(InterestingQuantities const& iq) {
71  if (tt->hasField(iq.sourceModule, field))
72  return tt->getField(iq.sourceModule, field);
73  else
74  return UNDEFINED;
75  };
76  };
77 
78  const TrackerTopology* tt = trackerTopologyHandle.operator->();
79 
80  std::vector<std::pair<std::string, TTField>> namedPartitions{
81  {"PXEndcap", {tt, TrackerTopology::PFSide}},
82 
83  {"PXLayer", {tt, TrackerTopology::PBLayer}},
84  {"PXLadder", {tt, TrackerTopology::PBLadder}},
85  {"PXBModule", {tt, TrackerTopology::PBModule}},
86 
87  {"PXBlade", {tt, TrackerTopology::PFBlade}},
88  {"PXDisk", {tt, TrackerTopology::PFDisk}},
89  {"PXPanel", {tt, TrackerTopology::PFPanel}},
90  {"PXFModule", {tt, TrackerTopology::PFModule}},
91  };
92 
93  for (auto& e : namedPartitions) {
94  geomquantities.push_back(intern(e.first));
95  addExtractor(intern(e.first), e.second, UNDEFINED, UNDEFINED);
96  }
97 
98  auto pxbarrel = [](InterestingQuantities const& iq) {
99  return iq.sourceModule.subdetId() == PixelSubdetector::PixelBarrel ? 0 : UNDEFINED;
100  };
101  auto pxforward = [](InterestingQuantities const& iq) {
102  return iq.sourceModule.subdetId() == PixelSubdetector::PixelEndcap ? 0 : UNDEFINED;
103  };
104  auto pxall = [](InterestingQuantities const& iq) { return 0; };
105  addExtractor(intern("PXBarrel"), pxbarrel, 0, 0);
106  addExtractor(intern("PXForward"), pxforward, 0, 0);
107  addExtractor(intern("PXAll"), pxall, 0, 0);
108 
109  // Redefine the disk numbering to use the sign
110  auto pxendcap = extractors[intern("PXEndcap")];
111  auto diskid = intern("PXDisk");
112  auto pxdisk = extractors[diskid];
113  extractors[diskid] = [pxdisk, pxendcap](InterestingQuantities const& iq) {
114  auto disk = pxdisk(iq);
115  if (disk == UNDEFINED)
116  return UNDEFINED;
117  auto endcap = pxendcap(iq);
118  return endcap == 1 ? -disk : disk;
119  };
120 
121  // DetId and module names
122  auto detid = [](InterestingQuantities const& iq) {
123  uint32_t id = iq.sourceModule.rawId();
124  return Value(id);
125  };
126  addExtractor(intern("DetId"), detid, 0, 0 // No sane value possible here.
127  );
128  // these are just aliases with special handling in formatting
129  // the names are created with PixelBarrelName et. al. later
130  addExtractor(intern("PXModuleName"), detid, 0, 0);
131 
132  int phase = iConfig.getParameter<int>("upgradePhase");
133  bool isUpgrade = phase == 1;
134 
135  // Get a Geometry
136  edm::ESHandle<TrackerGeometry> trackerGeometryHandle;
137  iSetup.get<TrackerDigiGeometryRecord>().get(trackerGeometryHandle);
138  assert(trackerGeometryHandle.isValid());
139 
140  // Now traverse the detector and collect whatever we need.
141  auto detids = trackerGeometryHandle->detIds();
142  for (DetId id : detids) {
143  if (id.subdetId() != PixelSubdetector::PixelBarrel && id.subdetId() != PixelSubdetector::PixelEndcap)
144  continue;
145  auto iq = InterestingQuantities{nullptr, id, 0, 0};
146 
147  // prepare pretty names
148  std::string name = "";
149  if (id.subdetId() == PixelSubdetector::PixelBarrel) { // Barrel
150  PixelBarrelName mod(id, tt, isUpgrade);
151  name = mod.name();
152  } else { // assume Endcap
153  PixelEndcapName mod(id, tt, isUpgrade);
154  name = mod.name();
155  }
156  format_value[std::make_pair(intern("PXModuleName"), Value(id.rawId()))] = name;
157 
158  // we record each module 4 times, one for each corner, so we also get ROCs
159  // in booking (at least for the ranges)
160  const PixelGeomDetUnit* detUnit = dynamic_cast<const PixelGeomDetUnit*>(trackerGeometryHandle->idToDetUnit(id));
161  assert(detUnit);
162  const PixelTopology* topo = &detUnit->specificTopology();
163  iq.row = 0;
164  iq.col = 0;
165  all_modules.push_back(iq);
166  iq.row = topo->nrows() - 1;
167  iq.col = 0;
168  all_modules.push_back(iq);
169  iq.row = 0;
170  iq.col = topo->ncolumns() - 1;
171  all_modules.push_back(iq);
172  iq.row = topo->nrows() - 1;
173  iq.col = topo->ncolumns() - 1;
174  all_modules.push_back(iq);
175  }
176 }
bool hasField(const DetId &id, DetIdFields idx) const
T getParameter(std::string const &) const
virtual int nrows() const =0
std::map< std::pair< Column, Value >, std::string > format_value
void addExtractor(ID id, std::function< Value(InterestingQuantities const &iq)> func, Value min=UNDEFINED, Value max=UNDEFINED, Value binwidth=1)
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
const DetIdContainer & detIds() const override
Returm a vector of all GeomDet DetIds (including those of GeomDetUnits)
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.
unsigned int getField(const DetId &id, DetIdFields idx) const
virtual int ncolumns() const =0
std::vector< std::function< Value(InterestingQuantities const &iq)> > extractors
bool isValid() const
Definition: ESHandle.h:44
ID intern(std::string const &id)
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
void GeometryInterface::loadModuleLevel ( edm::EventSetup const &  iSetup,
const edm::ParameterSet iConfig 
)
private

Definition at line 417 of file GeometryInterface.cc.

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

Referenced by load(), and pretty().

417  {
418  // stuff that is within modules. Might require some phase0/phase1/strip switching later
419  addExtractor(
420  intern("row"),
421  [](InterestingQuantities const& iq) { return Value(iq.row); },
422  0,
423  iConfig.getParameter<int>("module_rows") - 1);
424  addExtractor(
425  intern("col"),
426  [](InterestingQuantities const& iq) { return Value(iq.col); },
427  0,
428  iConfig.getParameter<int>("module_cols") - 1);
429 }
T getParameter(std::string const &) const
void addExtractor(ID id, std::function< Value(InterestingQuantities const &iq)> func, Value min=UNDEFINED, Value max=UNDEFINED, Value binwidth=1)
ID intern(std::string const &id)
void GeometryInterface::loadTimebased ( edm::EventSetup const &  iSetup,
const edm::ParameterSet iConfig 
)
private

Definition at line 366 of file GeometryInterface.cc.

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

Referenced by load(), and pretty().

366  {
367  // extractors for quantities that are roughly time-based. We cannot book plots based on these; they have to
368  // be grouped away in step1.
369  addExtractor(
370  intern("Lumisection"),
371  [](InterestingQuantities const& iq) {
372  if (!iq.sourceEvent)
373  return UNDEFINED;
374  return Value(iq.sourceEvent->luminosityBlock());
375  },
376  1,
377  iConfig.getParameter<int>("max_lumisection"));
378 
379  int onlineblock = iConfig.getParameter<int>("onlineblock");
380  int n_onlineblocks = iConfig.getParameter<int>("n_onlineblocks");
381  addExtractor(
382  intern("OnlineBlock"),
383  [onlineblock](InterestingQuantities const& iq) {
384  if (!iq.sourceEvent)
385  return UNDEFINED;
386  return Value(onlineblock + iq.sourceEvent->luminosityBlock() / onlineblock);
387  },
388  // note: this range is not visible anywhere (if the RenderPlugin does its job),
389  // but the strange range allows the RenderPlugin to know the block size.
390  onlineblock,
391  onlineblock + n_onlineblocks - 1);
392 
393  int lumiblock = iConfig.getParameter<int>("lumiblock");
394  addExtractor(
395  intern("LumiBlock"),
396  [lumiblock](InterestingQuantities const& iq) {
397  if (!iq.sourceEvent)
398  return UNDEFINED;
399  // The '-1' is for making 1-10 the same block rather than 0-9
400  // The '+0.5' makes the block span an integer range rather n.5-m.5
401  return Value(((iq.sourceEvent->luminosityBlock() - 1) / lumiblock) + 0.5);
402  },
403  -0.5,
404  iConfig.getParameter<int>("max_lumisection") / lumiblock);
405 
406  addExtractor(
407  intern("BX"),
408  [](InterestingQuantities const& iq) {
409  if (!iq.sourceEvent)
410  return UNDEFINED;
411  return Value(iq.sourceEvent->bunchCrossing());
412  },
413  1,
414  iConfig.getParameter<int>("max_bunchcrossing"));
415 }
T getParameter(std::string const &) const
void addExtractor(ID id, std::function< Value(InterestingQuantities const &iq)> func, Value min=UNDEFINED, Value max=UNDEFINED, Value binwidth=1)
static const Value UNDEFINED
ID intern(std::string const &id)
Value GeometryInterface::maxValue ( ID  id)
inline

Definition at line 89 of file GeometryInterface.h.

References triggerObjects_cff::id, and max_value.

Referenced by HistogramManager::book().

89 { return max_value[id]; };
std::map< ID, Value > max_value
Value GeometryInterface::minValue ( ID  id)
inline

Definition at line 90 of file GeometryInterface.h.

References triggerObjects_cff::id, and min_value.

Referenced by HistogramManager::book().

90 { return min_value[id]; };
std::map< ID, Value > min_value
std::string GeometryInterface::pretty ( Column  col)
inline
std::string GeometryInterface::unintern ( ID  id)
inline

Definition at line 106 of file GeometryInterface.h.

References MillePedeFileConverter_cfg::e, and ids.

Referenced by extract(), and pretty().

106  {
107  for (auto& e : ids)
108  if (e.second == id)
109  return e.first;
110  return "INVALID";
111  }
std::map< std::string, ID > ids

Member Data Documentation

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

Definition at line 152 of file GeometryInterface.h.

Referenced by allModules(), and loadFromTopology().

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

Definition at line 135 of file GeometryInterface.h.

Referenced by binWidth().

std::vector<std::function<Value(InterestingQuantities const& iq)> > GeometryInterface::extractors
private
std::map<std::pair<Column, Value>, std::string> GeometryInterface::format_value
private

Definition at line 139 of file GeometryInterface.h.

Referenced by formatValue(), and loadFromTopology().

const edm::ParameterSet GeometryInterface::iConfig
private

Definition at line 124 of file GeometryInterface.h.

Referenced by load(), and pretty().

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

Definition at line 155 of file GeometryInterface.h.

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

bool GeometryInterface::is_loaded = false
private

Definition at line 126 of file GeometryInterface.h.

Referenced by load(), and loaded().

ID GeometryInterface::max_id = 0
private

Definition at line 156 of file GeometryInterface.h.

Referenced by intern().

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

Definition at line 133 of file GeometryInterface.h.

Referenced by load(), and maxValue().

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

Definition at line 134 of file GeometryInterface.h.

Referenced by load(), and minValue().

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