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=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 153 of file GeometryInterface.h.

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

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

155  {
156  max_value[id] = max;
157  min_value[id] = min;
158  bin_width[id] = binwidth;
159  extractors[id] = func;
160  }
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 91 of file GeometryInterface.h.

References all_modules.

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

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

Definition at line 97 of file GeometryInterface.h.

References bin_width, and triggerObjects_cff::id.

Referenced by HistogramManager::book().

97 { 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 65 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().

65  {
66  assert(col != 0 || !"Extracting invalid column.");
67  ID id = col;
68  assert(ID(extractors.size()) > id || !"extractors vector too small!");
69  auto& ex = extractors[id];
70  if (!ex) { // we have never heard about this. This is a typo for sure.
71  edm::LogError("GeometryInterface")
72  << "Undefined column used: " << unintern(id)
73  << ". Check your spelling.\n";
74  } else {
75  auto val = ex(iq);
76  if (val != UNDEFINED) {
77  return std::make_pair(Column{id}, val);
78  }
79  }
80  return std::make_pair(col, UNDEFINED);
81  }
std::string unintern(ID id)
static const Value UNDEFINED
col
Definition: cuy.py:1008
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 83 of file GeometryInterface.h.

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

84  {
85  InterestingQuantities iq = {ev, did, col, row};
86  return extractors[id](iq);
87  }
bool ev
col
Definition: cuy.py:1008
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().

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

Definition at line 444 of file GeometryInterface.cc.

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

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

444  {
445  auto it = format_value.find(std::make_pair(col, val));
446  if (it != format_value.end()) return it->second;
447 
448  // non-number output names (_pO etc.) are hardwired here.
449  std::string name = pretty(col);
450  std::string value = "_" + std::to_string(int(val));
451  if (val == 0) value = ""; // hide Barrel_0 etc.
452  if (name == "PXDisk" && val > 0) // +/- sign for disk num
453  value = "_+" + std::to_string(int(val));
454  // pretty (legacy?) names for Shells and HalfCylinders
455  std::map<int, std::string> shellname{
456  {11, "_mI"}, {12, "_mO"}, {21, "_pI"}, {22, "_pO"}};
457  if (name == "HalfCylinder" || name == "Shell") value = shellname[int(val)];
458  if (val == UNDEFINED) value = "_UNDEFINED";
459  return format_value[std::make_pair(col, val)] = name+value;
460 }
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 100 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().

100  {
101  auto it = ids.find(id);
102  if (it == ids.end()) {
103  ids[id] = ++max_id;
104  extractors.resize(max_id + 1);
105  }
106  return ids[id];
107  };
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(), cmsBatch::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) log << "+++ column: " << e.first
54  << " ok " << bool(extractors[e.second]) << " min " << min_value[e.second] << " max " << max_value[e.second] << "\n";
55  is_loaded = true;
56 }
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 400 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().

400  {
401  auto cablingMapLabel = iConfig.getParameter<std::string>("CablingMapLabel");
403  iSetup.get<SiPixelFedCablingMapRcd>().get(cablingMapLabel, theCablingMap);
404 
405  std::shared_ptr<SiPixelFrameReverter> siPixelFrameReverter =
406  // I think passing the bare pointer here is safe, but who knows...
407  std::make_shared<SiPixelFrameReverter>(iSetup, theCablingMap.operator->());
408 
409  addExtractor(intern("FED"),
410  [siPixelFrameReverter] (InterestingQuantities const& iq) {
411  if (iq.sourceModule == 0xFFFFFFFF)
412  return Value(iq.col); // hijacked for the raw data plugin
413  return Value(siPixelFrameReverter->findFedId(iq.sourceModule.rawId()));
414  }
415  );
416 
417  // TODO: ranges should be set manually below, since booking probably cannot
418  // infer them correctly (no ROC-level granularity)
419  // PERF: this is slow. Prefer SiPixelCordinates versions here.
420  addExtractor(intern("LinkInFed"),
421  [siPixelFrameReverter] (InterestingQuantities const& iq) {
422  if (iq.sourceModule == 0xFFFFFFFF)
423  return Value(iq.row); // hijacked for the raw data plugin
424  sipixelobjects::GlobalPixel gp = {iq.row, iq.col};
425  return Value(siPixelFrameReverter->findLinkInFed(iq.sourceModule.rawId(), gp));
426  }
427  );
428  // not sure if this is useful anywhere.
429  addExtractor(intern("RocInLink"),
430  [siPixelFrameReverter] (InterestingQuantities const& iq) {
431  sipixelobjects::GlobalPixel gp = {iq.row, iq.col};
432  return Value(siPixelFrameReverter->findRocInLink(iq.sourceModule.rawId(), gp));
433  }
434  );
435  // This might be equivalent to our ROC numbering.
436  addExtractor(intern("RocInDet"),
437  [siPixelFrameReverter] (InterestingQuantities const& iq) {
438  sipixelobjects::GlobalPixel gp = {iq.row, iq.col};
439  return Value(siPixelFrameReverter->findRocInDet(iq.sourceModule.rawId(), gp));
440  }
441  );
442 }
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 169 of file GeometryInterface.cc.

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

Referenced by load(), and pretty().

169  {
170  // TODO: SiPixelCoordinates has a large overlap with theis GeometryInterface
171  // in general.
172  // Rough convention is to use own code for things that are easy and fast to
173  // determine, and use SiPixelCoordinates for complicated things.
174  // SiPixelCoordinates uses lookup maps for everything, so it is faster than
175  // most other code, but still slow on DQM scales.
176  int phase = iConfig.getParameter<int>("upgradePhase");
177 
178  // this shared pointer is kept alive by the references in the lambdas that follow.
179  // That is a bit less obvious than keeping it as a member but more correct.
180  auto coord = std::make_shared<SiPixelCoordinates>(phase);
181 
182  // note that we should reeinit for each event. But this probably won't explode
183  // thanks to the massive memoization in SiPixelCoordinates which is completely
184  // initialized while booking.
185  coord->init(iSetup);
186 
187  // SiPixelCoordinates uses a different convention for UNDEFINED:
188  auto from_coord = [](double in) { return (in == -9999.0) ? UNDEFINED : Value(in); };
189 
190  // Rings are a concept that cannot be derived from bitmasks.
191  addExtractor(intern("PXRing"),
192  [coord, from_coord] (InterestingQuantities const& iq) {
193  return from_coord(coord->ring(iq.sourceModule));
194  }
195  );
196 
197  // Quadrant names.
198  auto pxbarrel = extractors[intern("PXBarrel")];
199  addExtractor(intern("HalfCylinder"),
200  [coord, pxbarrel] (InterestingQuantities const& iq) {
201  if (pxbarrel(iq) != UNDEFINED) return UNDEFINED;
202  int quadrant = coord->quadrant(iq.sourceModule);
203  switch (quadrant) {
204  case 1: return Value(12); // mO
205  case 2: return Value(11); // mI
206  case 3: return Value(22); // pO
207  case 4: return Value(21); // pI
208  default: return UNDEFINED;
209  }
210  }, 0, 0 // N/A
211  );
212  addExtractor(intern("Shell"),
213  [coord, pxbarrel] (InterestingQuantities const& iq) {
214  if (pxbarrel(iq) == UNDEFINED) return UNDEFINED;
215  int quadrant = coord->quadrant(iq.sourceModule);
216  switch (quadrant) {
217  case 1: return Value(12); // mO
218  case 2: return Value(11); // mI
219  case 3: return Value(22); // pO
220  case 4: return Value(21); // pI
221  default: return UNDEFINED;
222  }
223  }, 0, 0 // N/A
224  );
225 
226  // Online Numbering.
227  addExtractor(intern("SignedLadder"),
228  [coord, from_coord] (InterestingQuantities const& iq) {
229  return from_coord(coord->signed_ladder(iq.sourceModule()));
230  }
231  );
232  addExtractor(intern("SignedModule"),
233  [coord, from_coord] (InterestingQuantities const& iq) {
234  return from_coord(coord->signed_module(iq.sourceModule()));
235  }
236  );
237  addExtractor(intern("SignedBlade"),
238  [coord, from_coord] (InterestingQuantities const& iq) {
239  return from_coord(coord->signed_blade(iq.sourceModule()));
240  }
241  );
242 
243  // Flipped and Outer ladders
244  addExtractor(intern("OuterLadder"),
245  [coord, from_coord] (InterestingQuantities const& iq) {
246  return from_coord(coord->outer(iq.sourceModule()));
247  }
248  );
249  addExtractor(intern("FlippedLadder"),
250  [coord, from_coord] (InterestingQuantities const& iq) {
251  return from_coord(coord->flipped(iq.sourceModule()));
252  }
253  );
254 
255  // Pixel Map axis.
256  // TODO: automatic range and binning for phase0 are incorrect.
257  // Should be set manually here.
258  addExtractor(intern("SignedModuleCoord"), // BPIX x
259  [coord, from_coord] (InterestingQuantities const& iq) {
260  return from_coord(coord->signed_module_coord(iq.sourceModule(),
261  std::make_pair(int(iq.row), int(iq.col))));
262  }, UNDEFINED, UNDEFINED, 1.0/8.0
263  );
264  addExtractor(intern("SignedLadderCoord"), // BPIX y
265  [coord, from_coord] (InterestingQuantities const& iq) {
266  return from_coord(coord->signed_ladder_coord(iq.sourceModule(),
267  std::make_pair(int(iq.row), int(iq.col))));
268  }, UNDEFINED, UNDEFINED, 1.0/2.0
269  );
270  addExtractor(intern("SignedDiskCoord"), // FPIX x (per-ring)
271  [coord, from_coord] (InterestingQuantities const& iq) {
272  return from_coord(coord->signed_disk_coord(iq.sourceModule(),
273  std::make_pair(int(iq.row), int(iq.col))));
274  }, UNDEFINED, UNDEFINED, 1.0/8.0
275  );
276  addExtractor(intern("SignedDiskRingCoord"), // FPIX x (FPIX-as-one-plot)
277  [coord, from_coord] (InterestingQuantities const& iq) {
278  return from_coord(coord->signed_disk_ring_coord(iq.sourceModule(),
279  std::make_pair(int(iq.row), int(iq.col))));
280  }, UNDEFINED, UNDEFINED, 1.0/16.0
281  );
282  addExtractor(intern("SignedBladePanelCoord"), // FPIX y
283  [coord, from_coord, phase] (InterestingQuantities const& iq) {
284  if (phase == 0) {
285  return from_coord(coord->signed_blade_coord(
286  iq.sourceModule(), std::make_pair(int(iq.row), int(iq.col))));
287  } else if (phase == 1) {
288  return from_coord(coord->signed_blade_panel_coord(
289  iq.sourceModule(), std::make_pair(int(iq.row), int(iq.col))));
290  } else {
291  return UNDEFINED; // TODO: phase2
292  }
293  }, UNDEFINED, UNDEFINED, phase == 1 ? 0.25 : 0.2
294  );
295  addExtractor(intern("SignedShiftedBladePanelCoord"), // FPIX-as-one y
296  [coord, from_coord, phase] (InterestingQuantities const& iq) {
297  if (phase == 0) {
298  return from_coord(coord->signed_blade_coord(
299  iq.sourceModule(), std::make_pair(int(iq.row), int(iq.col))));
300  } else if (phase == 1) {
301  return from_coord(coord->signed_shifted_blade_panel_coord(
302  iq.sourceModule(), std::make_pair(int(iq.row), int(iq.col))));
303  } else {
304  return UNDEFINED; // TODO: phase2
305  }
306  }, UNDEFINED, UNDEFINED, phase == 1 ? 0.25 : 0.1 // half-roc for phase0
307  );
308  addExtractor(intern("SignedBladePanel"), // per-module FPIX y
309  [coord, from_coord] (InterestingQuantities const& iq) {
310  return from_coord(coord->signed_blade_panel_coord(iq.sourceModule(), std::make_pair(int(iq.row), int(iq.col))));
311  }, UNDEFINED, UNDEFINED, 1.0/2.0
312  );
313 
314  addExtractor(intern("SignedBladePanel"),
315  [coord, from_coord] (InterestingQuantities const& iq) {
316  return from_coord(coord->signed_blade_panel_coord(iq.sourceModule(), std::make_pair(int(iq.row), int(iq.col))));
317  }, UNDEFINED, UNDEFINED, 1.0/2.0
318  );
319 
320  // more readout-related things.
321  addExtractor(intern("ROC"),
322  [coord, from_coord] (InterestingQuantities const& iq) {
323  return from_coord(coord->roc(iq.sourceModule(),
324  std::make_pair(int(iq.row), int(iq.col))));
325  }
326  );
327  addExtractor(intern("Sector"),
328  [coord, from_coord] (InterestingQuantities const& iq) {
329  return from_coord(coord->sector(iq.sourceModule()));
330  }
331  );
332  addExtractor(intern("Channel"),
333  [coord, from_coord] (InterestingQuantities const& iq) {
334  return from_coord(coord->channel(iq.sourceModule(), std::make_pair(int(iq.row), int(iq.col))));
335  }
336  );
337 
338 }
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
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 58 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(), edm::ESHandleBase::isValid(), mod(), PixelEndcapName::name(), PixelBarrelName::name(), dataset::name, PixelTopology::ncolumns(), PixelTopology::nrows(), TrackerTopology::PBLadder, TrackerTopology::PBLayer, TrackerTopology::PBModule, TrackerTopology::PFBlade, TrackerTopology::PFDisk, TrackerTopology::PFModule, TrackerTopology::PFPanel, TrackerTopology::PFSide, hcalRecAlgoESProd_cfi::phase, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, GeometryInterface::InterestingQuantities::sourceModule, PixelGeomDetUnit::specificTopology(), AlCaHLTBitMon_QueryRunRegistry::string, groupFilesInBlocks::tt, and UNDEFINED.

Referenced by load(), and pretty().

58  {
59  // Get a Topology
60  edm::ESHandle<TrackerTopology> trackerTopologyHandle;
61  iSetup.get<TrackerTopologyRcd>().get(trackerTopologyHandle);
62  assert(trackerTopologyHandle.isValid());
63 
64  std::vector<ID> geomquantities;
65 
66  struct TTField {
67  const TrackerTopology* tt;
69  Value operator()(InterestingQuantities const& iq) {
70  if (tt->hasField(iq.sourceModule, field))
71  return tt->getField(iq.sourceModule, field);
72  else
73  return UNDEFINED;
74  };
75  };
76 
77  const TrackerTopology* tt = trackerTopologyHandle.operator->();
78 
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) { return iq.sourceModule.subdetId() == PixelSubdetector::PixelBarrel ? 0 : UNDEFINED; };
99  auto pxforward = [] (InterestingQuantities const& iq) { return iq.sourceModule.subdetId() == PixelSubdetector::PixelEndcap ? 0 : UNDEFINED; };
100  auto pxall = [] (InterestingQuantities const& iq) { return 0 ; };
101  addExtractor(intern("PXBarrel"), pxbarrel, 0, 0);
102  addExtractor(intern("PXForward"), pxforward, 0, 0);
103  addExtractor(intern("PXAll"), pxall, 0, 0);
104 
105  // Redefine the disk numbering to use the sign
106  auto pxendcap = extractors[intern("PXEndcap")];
107  auto diskid = intern("PXDisk");
108  auto pxdisk = extractors[diskid];
109  extractors[diskid] = [pxdisk, pxendcap] (InterestingQuantities const& iq) {
110  auto disk = pxdisk(iq);
111  if (disk == UNDEFINED) return UNDEFINED;
112  auto endcap = pxendcap(iq);
113  return endcap == 1 ? -disk : disk;
114  };
115 
116  // DetId and module names
117  auto detid = [] (InterestingQuantities const& iq) {
118  uint32_t id = iq.sourceModule.rawId();
119  return Value(id);
120  };
121  addExtractor(intern("DetId"), detid,
122  0, 0 // No sane value possible here.
123  );
124  // these are just aliases with special handling in formatting
125  // the names are created with PixelBarrelName et. al. later
126  addExtractor(intern("PXModuleName"), detid, 0, 0);
127 
128  int phase = iConfig.getParameter<int>("upgradePhase");
129  bool isUpgrade = phase == 1;
130 
131  // Get a Geometry
132  edm::ESHandle<TrackerGeometry> trackerGeometryHandle;
133  iSetup.get<TrackerDigiGeometryRecord>().get(trackerGeometryHandle);
134  assert(trackerGeometryHandle.isValid());
135 
136  // Now traverse the detector and collect whatever we need.
137  auto detids = trackerGeometryHandle->detIds();
138  for (DetId id : detids) {
139  if (id.subdetId() != PixelSubdetector::PixelBarrel && id.subdetId() != PixelSubdetector::PixelEndcap) continue;
140  auto iq = InterestingQuantities{nullptr, id, 0, 0};
141 
142  // prepare pretty names
143  std::string name = "";
144  if (id.subdetId() == PixelSubdetector::PixelBarrel) { // Barrel
145  PixelBarrelName mod(id, tt, isUpgrade);
146  name = mod.name();
147  } else { // assume Endcap
148  PixelEndcapName mod(id, tt, isUpgrade);
149  name = mod.name();
150  }
151  format_value[std::make_pair(intern("PXModuleName"), Value(id.rawId()))] = name;
152 
153  // we record each module 4 times, one for each corner, so we also get ROCs
154  // in booking (at least for the ranges)
155  const PixelGeomDetUnit* detUnit = dynamic_cast<const PixelGeomDetUnit*>(trackerGeometryHandle->idToDetUnit(id));
156  assert(detUnit);
157  const PixelTopology* topo = &detUnit->specificTopology();
158  iq.row = 0; iq.col = 0;
159  all_modules.push_back(iq);
160  iq.row = topo->nrows()-1; iq.col = 0;
161  all_modules.push_back(iq);
162  iq.row = 0; iq.col = topo->ncolumns()-1;
163  all_modules.push_back(iq);
164  iq.row = topo->nrows()-1; iq.col = topo->ncolumns()-1;
165  all_modules.push_back(iq);
166  }
167 }
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:18
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:47
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 383 of file GeometryInterface.cc.

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

Referenced by load(), and pretty().

383  {
384  // stuff that is within modules. Might require some phase0/phase1/strip switching later
385  addExtractor(intern("row"),
386  [] (InterestingQuantities const& iq) {
387  return Value(iq.row);
388  },
389  0, iConfig.getParameter<int>("module_rows") - 1
390  );
391  addExtractor(intern("col"),
392  [] (InterestingQuantities const& iq) {
393  return Value(iq.col);
394  },
395  0, iConfig.getParameter<int>("module_cols") - 1
396  );
397 
398 }
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 340 of file GeometryInterface.cc.

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

Referenced by load(), and pretty().

340  {
341  // extractors for quantities that are roughly time-based. We cannot book plots based on these; they have to
342  // be grouped away in step1.
343  addExtractor(intern("Lumisection"),
344  [] (InterestingQuantities const& iq) {
345  if(!iq.sourceEvent) return UNDEFINED;
346  return Value(iq.sourceEvent->luminosityBlock());
347  },
348  1, iConfig.getParameter<int>("max_lumisection")
349  );
350 
351  int onlineblock = iConfig.getParameter<int>("onlineblock");
352  int n_onlineblocks = iConfig.getParameter<int>("n_onlineblocks");
353  addExtractor(intern("OnlineBlock"),
354  [onlineblock] (InterestingQuantities const& iq) {
355  if(!iq.sourceEvent) return UNDEFINED;
356  return Value(onlineblock + iq.sourceEvent->luminosityBlock() / onlineblock);
357  },
358  // note: this range is not visible anywhere (if the RenderPlugin does its job),
359  // but the strange range allows the RenderPlugin to know the block size.
360  onlineblock, onlineblock+n_onlineblocks-1
361  );
362 
363  int lumiblock = iConfig.getParameter<int>("lumiblock");
364  addExtractor(intern("LumiBlock"),
365  [lumiblock] (InterestingQuantities const& iq) {
366  if(!iq.sourceEvent) return UNDEFINED;
367  // The '-1' is for making 1-10 the same block rather than 0-9
368  // The '+0.5' makes the block span an integer range rather n.5-m.5
369  return Value( ((iq.sourceEvent->luminosityBlock()-1)/lumiblock) + 0.5 );
370  },
371  -0.5, iConfig.getParameter<int>("max_lumisection")/lumiblock
372  );
373 
374  addExtractor(intern("BX"),
375  [] (InterestingQuantities const& iq) {
376  if(!iq.sourceEvent) return UNDEFINED;
377  return Value(iq.sourceEvent->bunchCrossing());
378  },
379  1, iConfig.getParameter<int>("max_bunchcrossing")
380  );
381 }
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 95 of file GeometryInterface.h.

References triggerObjects_cff::id, and max_value.

Referenced by HistogramManager::book().

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

Definition at line 96 of file GeometryInterface.h.

References triggerObjects_cff::id, and min_value.

Referenced by HistogramManager::book().

96 { 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 112 of file GeometryInterface.h.

References MillePedeFileConverter_cfg::e, and ids.

Referenced by extract(), and pretty().

112  {
113  for (auto& e : ids)
114  if (e.second == id) return e.first;
115  return "INVALID";
116  }
std::map< std::string, ID > ids

Member Data Documentation

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

Definition at line 162 of file GeometryInterface.h.

Referenced by allModules(), and loadFromTopology().

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

Definition at line 147 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 151 of file GeometryInterface.h.

Referenced by formatValue(), and loadFromTopology().

const edm::ParameterSet GeometryInterface::iConfig
private

Definition at line 136 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 165 of file GeometryInterface.h.

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

bool GeometryInterface::is_loaded = false
private

Definition at line 138 of file GeometryInterface.h.

Referenced by load(), and loaded().

ID GeometryInterface::max_id = 0
private

Definition at line 166 of file GeometryInterface.h.

Referenced by intern().

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

Definition at line 145 of file GeometryInterface.h.

Referenced by load(), and maxValue().

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

Definition at line 146 of file GeometryInterface.h.

Referenced by load(), and minValue().

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