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
< InterestingQuantities
all_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 27 of file GeometryInterface.h.

Member Typedef Documentation

Definition at line 33 of file GeometryInterface.h.

typedef int GeometryInterface::ID

Definition at line 30 of file GeometryInterface.h.

typedef double GeometryInterface::Value

Definition at line 34 of file GeometryInterface.h.

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

Definition at line 39 of file GeometryInterface.h.

Constructor & Destructor Documentation

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

Definition at line 41 of file GeometryInterface.h.

41 : 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 161 of file GeometryInterface.h.

References bin_width, extractors, RecoJets_EventContent_cff::func, bookConverter::max, max_value, min(), and min_value.

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

163  {
164  max_value[id] = max;
165  min_value[id] = min;
166  bin_width[id] = binwidth;
167  extractors[id] = func;
168  }
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 94 of file GeometryInterface.h.

References all_modules.

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

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

Definition at line 100 of file GeometryInterface.h.

References bin_width.

Referenced by HistogramManager::book().

100 { 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 70 of file GeometryInterface.h.

References assert(), cuy::col, extractors, UNDEFINED, unintern(), and SpecificationBuilder_cfi::val().

Referenced by BeautifulSoup.PageElement::_invert(), SiPixelPhase1GeometryDebug::analyze(), HistogramManager::book(), BeautifulSoup.Tag::decompose(), extractColumns(), and HistogramManager::fillInternal().

70  {
71  assert(col != 0 || !"Extracting invalid column.");
72  ID id = col;
73  assert(ID(extractors.size()) > id || !"extractors vector too small!");
74  auto& ex = extractors[id];
75  if (!ex) { // we have never heard about this. This is a typo for sure.
76  edm::LogError("GeometryInterface")
77  << "Undefined column used: " << unintern(id)
78  << ". Check your spelling.\n";
79  } else {
80  auto val = ex(iq);
81  if (val != UNDEFINED) {
82  return std::make_pair(Column{id}, val); // double braces for g++
83  }
84  }
85  return std::make_pair(col, UNDEFINED);
86  }
assert(m_qm.get())
std::string unintern(ID id)
static const Value UNDEFINED
std::vector< std::function< Value(InterestingQuantities const &iq)> > extractors
int col
Definition: cuy.py:1008
Value GeometryInterface::extract ( ID  id,
DetId  did,
edm::Event ev = 0,
int16_t  col = 0,
int16_t  row = 0 
)
inline

Definition at line 88 of file GeometryInterface.h.

References cuy::col, ev, and extractors.

Referenced by BeautifulSoup.PageElement::_invert(), and BeautifulSoup.Tag::decompose().

89  {
90  InterestingQuantities iq = {ev, did, col, row};
91  return extractors[id](iq);
92  }
bool ev
std::vector< std::function< Value(InterestingQuantities const &iq)> > extractors
int col
Definition: cuy.py:1008
void GeometryInterface::extractColumns ( std::vector< Column > const &  names,
InterestingQuantities const &  iq,
Values out 
)
inline

Definition at line 59 of file GeometryInterface.h.

References cuy::col, extract(), and SpecificationBuilder_cfi::val().

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

60  {
61  out.clear();
62  for (Column const& col : names) {
63  auto val = extract(col, iq);
64  out.push_back(val);
65  }
66  }
static const HistoName names[]
std::pair< Column, Value > extract(Column const &col, InterestingQuantities const &iq)
int col
Definition: cuy.py:1008
std::string GeometryInterface::formatValue ( Column  col,
Value  val 
)

Definition at line 389 of file GeometryInterface.cc.

References format_value, mergeVDriftHistosByStation::name, pretty(), AlCaHLTBitMon_QueryRunRegistry::string, UNDEFINED, and relativeConstraints::value.

Referenced by HistogramManager::makePathName().

389  {
390  auto it = format_value.find(std::make_pair(col, val));
391  if (it != format_value.end()) return it->second;
392 
393  // non-number output names (_pO etc.) are hardwired here.
395  std::string value = "_" + std::to_string(int(val));
396  if (val == 0) value = ""; // hide Barrel_0 etc.
397  if (name == "PXDisk" && val > 0) // +/- sign for disk num
398  value = "_+" + std::to_string(int(val));
399  // pretty (legacy?) names for Shells and HalfCylinders
400  std::map<int, std::string> shellname{
401  {11, "_mI"}, {12, "_mO"}, {21, "_pI"}, {22, "_pO"}};
402  if (name == "HalfCylinder" || name == "Shell") value = shellname[int(val)];
403  if (val == UNDEFINED) value = "_UNDEFINED";
404  return format_value[std::make_pair(col, val)] = name+value;
405 }
std::map< std::pair< Column, Value >, std::string > format_value
std::string pretty(Column col)
static const Value UNDEFINED
int col
Definition: cuy.py:1008
ID GeometryInterface::intern ( std::string const &  id)
inline

Definition at line 105 of file GeometryInterface.h.

References extractors, ids, and max_id.

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

105  {
106  auto it = ids.find(id);
107  if (it == ids.end()) {
108  ids[id] = ++max_id;
109  extractors.resize(max_id + 1);
110  }
111  return ids[id];
112  };
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 42 of file GeometryInterface.cc.

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

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

42  {
43  //loadFromAlignment(iSetup, iConfig);
44  loadFromTopology(iSetup, iConfig);
45  loadTimebased(iSetup, iConfig);
46  loadModuleLevel(iSetup, iConfig);
47  loadFEDCabling(iSetup, iConfig);
49  edm::LogInfo log("GeometryInterface");
50  log << "Known colum names:\n";
51  for (auto e : ids) log << "+++ column: " << e.first
52  << " ok " << bool(extractors[e.second]) << " min " << min_value[e.second] << " max " << max_value[e.second] << "\n";
53  is_loaded = true;
54 }
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 43 of file GeometryInterface.h.

References is_loaded.

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

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

Definition at line 346 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().

346  {
347  auto cablingMapLabel = iConfig.getParameter<std::string>("CablingMapLabel");
349  iSetup.get<SiPixelFedCablingMapRcd>().get(cablingMapLabel, theCablingMap);
350 
351  std::shared_ptr<SiPixelFrameReverter> siPixelFrameReverter =
352  // I think passing the bare pointer here is safe, but who knows...
353  std::make_shared<SiPixelFrameReverter>(iSetup, theCablingMap.operator->());
354 
355  addExtractor(intern("FED"),
356  [siPixelFrameReverter] (InterestingQuantities const& iq) {
357  if (iq.sourceModule == 0xFFFFFFFF)
358  return Value(iq.col); // hijacked for the raw data plugin
359  return Value(siPixelFrameReverter->findFedId(iq.sourceModule.rawId()));
360  }
361  );
362 
363  // TODO: ranges should be set manually below, since booking probably cannot
364  // infer them correctly (no ROC-level granularity)
365  addExtractor(intern("LinkInFed"),
366  [siPixelFrameReverter] (InterestingQuantities const& iq) {
367  if (iq.sourceModule == 0xFFFFFFFF)
368  return Value(iq.row); // hijacked for the raw data plugin
369  sipixelobjects::GlobalPixel gp = {iq.row, iq.col};
370  return Value(siPixelFrameReverter->findLinkInFed(iq.sourceModule.rawId(), gp));
371  }
372  );
373  // not sure if this is useful anywhere.
374  addExtractor(intern("RocInLink"),
375  [siPixelFrameReverter] (InterestingQuantities const& iq) {
376  sipixelobjects::GlobalPixel gp = {iq.row, iq.col};
377  return Value(siPixelFrameReverter->findRocInLink(iq.sourceModule.rawId(), gp));
378  }
379  );
380  // This might be equivalent to our ROC numbering.
381  addExtractor(intern("RocInDet"),
382  [siPixelFrameReverter] (InterestingQuantities const& iq) {
383  sipixelobjects::GlobalPixel gp = {iq.row, iq.col};
384  return Value(siPixelFrameReverter->findRocInDet(iq.sourceModule.rawId(), gp));
385  }
386  );
387 }
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(), GeometryInterface::InterestingQuantities::row, GeometryInterface::InterestingQuantities::sourceModule, and UNDEFINED.

Referenced by load().

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  // Pixel Map axis.
244  // TODO: binning should be phase-dependent. Or maybe even per-plot configurable.
245  addExtractor(intern("SignedModuleCoord"),
246  [coord, from_coord] (InterestingQuantities const& iq) {
247  return from_coord(coord->signed_module_coord(iq.sourceModule(),
248  std::make_pair(int(iq.row), int(iq.col))));
249  }, UNDEFINED, UNDEFINED, 1.0/8.0
250  );
251  addExtractor(intern("SignedLadderCoord"),
252  [coord, from_coord] (InterestingQuantities const& iq) {
253  return from_coord(coord->signed_ladder_coord(iq.sourceModule(),
254  std::make_pair(int(iq.row), int(iq.col))));
255  }, UNDEFINED, UNDEFINED, 1.0/2.0
256  );
257  addExtractor(intern("SignedDiskCoord"),
258  [coord, from_coord] (InterestingQuantities const& iq) {
259  return from_coord(coord->signed_disk_coord(iq.sourceModule(),
260  std::make_pair(int(iq.row), int(iq.col))));
261  }, UNDEFINED, UNDEFINED, 1.0/8.0
262  );
263  addExtractor(intern("SignedBladePanelCoord"),
264  [coord, from_coord, phase] (InterestingQuantities const& iq) {
265  if (phase == 0) {
266  return from_coord(coord->signed_blade_coord(
267  iq.sourceModule(), std::make_pair(int(iq.row), int(iq.col))));
268  } else if (phase == 1) {
269  return from_coord(coord->signed_blade_panel_coord(
270  iq.sourceModule(), std::make_pair(int(iq.row), int(iq.col))));
271  } else {
272  // TODO: phase2
273  return UNDEFINED;
274  }
275  }, UNDEFINED, UNDEFINED, phase == 1 ? 0.25 : 0.2
276  );
277 
278  addExtractor(intern("SignedBladePanel"),
279  [coord, from_coord] (InterestingQuantities const& iq) {
280  return from_coord(coord->signed_blade_panel_coord(iq.sourceModule(), std::make_pair(int(iq.row), int(iq.col))));
281  }, UNDEFINED, UNDEFINED, 1.0/2.0
282  );
283 
284  // more readout-related things.
285  addExtractor(intern("ROC"),
286  [coord, from_coord] (InterestingQuantities const& iq) {
287  return from_coord(coord->roc(iq.sourceModule(),
288  std::make_pair(int(iq.row), int(iq.col))));
289  }
290  );
291  addExtractor(intern("Sector"),
292  [coord, from_coord] (InterestingQuantities const& iq) {
293  return from_coord(coord->sector(iq.sourceModule()));
294  }
295  );
296 
297 }
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 56 of file GeometryInterface.cc.

References addExtractor(), all_modules, assert(), alignCSCRings::e, Reference_intrackfit_cff::endcap, extractors, format_value, edm::EventSetup::get(), edm::ParameterSet::getParameter(), intern(), edm::ESHandleBase::isValid(), mod(), PixelEndcapName::name(), PixelBarrelName::name(), mergeVDriftHistosByStation::name, TrackerTopology::PBLadder, TrackerTopology::PBLayer, TrackerTopology::PBModule, TrackerTopology::PFBlade, TrackerTopology::PFDisk, TrackerTopology::PFModule, TrackerTopology::PFPanel, TrackerTopology::PFSide, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, GeometryInterface::InterestingQuantities::sourceModule, AlCaHLTBitMon_QueryRunRegistry::string, groupFilesInBlocks::tt, and UNDEFINED.

Referenced by load().

56  {
57  // Get a Topology
58  edm::ESHandle<TrackerTopology> trackerTopologyHandle;
59  iSetup.get<TrackerTopologyRcd>().get(trackerTopologyHandle);
60  assert(trackerTopologyHandle.isValid());
61 
62  std::vector<ID> geomquantities;
63 
64  struct TTField {
65  const TrackerTopology* tt;
67  Value operator()(InterestingQuantities const& iq) {
68  if (tt->hasField(iq.sourceModule, field))
69  return tt->getField(iq.sourceModule, field);
70  else
71  return UNDEFINED;
72  };
73  };
74 
75  const TrackerTopology* tt = trackerTopologyHandle.operator->();
76 
77 
78  std::vector<std::pair<std::string, TTField>> namedPartitions {
79  {"PXEndcap" , {tt, TrackerTopology::PFSide}},
80 
81  {"PXLayer" , {tt, TrackerTopology::PBLayer}},
82  {"PXLadder" , {tt, TrackerTopology::PBLadder}},
83  {"PXBModule", {tt, TrackerTopology::PBModule}},
84 
85  {"PXBlade" , {tt, TrackerTopology::PFBlade}},
86  {"PXDisk" , {tt, TrackerTopology::PFDisk}},
87  {"PXPanel" , {tt, TrackerTopology::PFPanel}},
88  {"PXFModule", {tt, TrackerTopology::PFModule}},
89  };
90 
91  for (auto& e : namedPartitions) {
92  geomquantities.push_back(intern(e.first));
93  addExtractor(intern(e.first), e.second, UNDEFINED, UNDEFINED);
94  }
95 
96  auto pxbarrel = [] (InterestingQuantities const& iq) { return iq.sourceModule.subdetId() == PixelSubdetector::PixelBarrel ? 0 : UNDEFINED; };
97  auto pxforward = [] (InterestingQuantities const& iq) { return iq.sourceModule.subdetId() == PixelSubdetector::PixelEndcap ? 0 : UNDEFINED; };
98  addExtractor(intern("PXBarrel"), pxbarrel, 0, 0);
99  addExtractor(intern("PXForward"), pxforward, 0, 0);
100 
101  // Redefine the disk numbering to use the sign
102  auto pxendcap = extractors[intern("PXEndcap")];
103  auto diskid = intern("PXDisk");
104  auto pxdisk = extractors[diskid];
105  extractors[diskid] = [pxdisk, pxendcap] (InterestingQuantities const& iq) {
106  auto disk = pxdisk(iq);
107  if (disk == UNDEFINED) return UNDEFINED;
108  auto endcap = pxendcap(iq);
109  return endcap == 1 ? -disk : disk;
110  };
111 
112  // DetId and module names
113  auto detid = [] (InterestingQuantities const& iq) {
114  uint32_t id = iq.sourceModule.rawId();
115  return Value(id);
116  };
117  addExtractor(intern("DetId"), detid,
118  0, 0 // No sane value possible here.
119  );
120  // these are just aliases with special handling in formatting
121  // the names are created with PixelBarrelName et. al. later
122  addExtractor(intern("PXModuleName"), detid, 0, 0);
123 
124  int phase = iConfig.getParameter<int>("upgradePhase");
125  bool isUpgrade = phase == 1;
126 
127  // Get a Geometry
128  edm::ESHandle<TrackerGeometry> trackerGeometryHandle;
129  iSetup.get<TrackerDigiGeometryRecord>().get(trackerGeometryHandle);
130  assert(trackerGeometryHandle.isValid());
131 
132  // some parameters to record the ROCs here
133  auto module_rows = iConfig.getParameter<int>("module_rows") - 1;
134  auto module_cols = iConfig.getParameter<int>("module_cols") - 1;
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  // TODO: add all ROCs?
156  // TODO: Things are more complicated for phase2, and we support that via
157  // SiPixelCoordinates, so we should support it here too.
158  iq.row = 1; iq.col = 1;
159  all_modules.push_back(iq);
160  iq.row = module_rows-1; iq.col = 1;
161  all_modules.push_back(iq);
162  iq.row = 1; iq.col = module_cols-1;
163  all_modules.push_back(iq);
164  iq.row = module_rows-1; iq.col = module_cols-1;
165  all_modules.push_back(iq);
166  }
167 }
T getParameter(std::string const &) const
std::map< std::pair< Column, Value >, std::string > format_value
assert(m_qm.get())
void addExtractor(ID id, std::function< Value(InterestingQuantities const &iq)> func, Value min=UNDEFINED, Value max=UNDEFINED, Value binwidth=1)
std::vector< InterestingQuantities > all_modules
static const Value UNDEFINED
Definition: DetId.h:18
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 329 of file GeometryInterface.cc.

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

Referenced by load().

329  {
330  // stuff that is within modules. Might require some phase0/phase1/strip switching later
331  addExtractor(intern("row"),
332  [] (InterestingQuantities const& iq) {
333  return Value(iq.row);
334  },
335  0, iConfig.getParameter<int>("module_rows") - 1
336  );
337  addExtractor(intern("col"),
338  [] (InterestingQuantities const& iq) {
339  return Value(iq.col);
340  },
341  0, iConfig.getParameter<int>("module_cols") - 1
342  );
343 
344 }
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 299 of file GeometryInterface.cc.

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

Referenced by load().

299  {
300  // extractors for quantities that are roughly time-based. We cannot book plots based on these; they have to
301  // be grouped away in step1.
302  addExtractor(intern("Lumisection"),
303  [] (InterestingQuantities const& iq) {
304  if(!iq.sourceEvent) return UNDEFINED;
305  return Value(iq.sourceEvent->luminosityBlock());
306  },
307  1, iConfig.getParameter<int>("max_lumisection")
308  );
309  int onlineblock = iConfig.getParameter<int>("onlineblock");
310  int n_onlineblocks = iConfig.getParameter<int>("n_onlineblocks");
311  addExtractor(intern("OnlineBlock"),
312  [onlineblock] (InterestingQuantities const& iq) {
313  if(!iq.sourceEvent) return UNDEFINED;
314  return Value(onlineblock + iq.sourceEvent->luminosityBlock() / onlineblock);
315  },
316  // note: this range is not visible anywhere (if the RenderPlugin does its job),
317  // but the strange range allows the RenderPlugin to know the block size.
318  onlineblock, onlineblock+n_onlineblocks-1
319  );
320  addExtractor(intern("BX"),
321  [] (InterestingQuantities const& iq) {
322  if(!iq.sourceEvent) return UNDEFINED;
323  return Value(iq.sourceEvent->bunchCrossing());
324  },
325  1, iConfig.getParameter<int>("max_bunchcrossing")
326  );
327 }
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 98 of file GeometryInterface.h.

References max_value.

Referenced by HistogramManager::book().

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

Definition at line 99 of file GeometryInterface.h.

References min_value.

Referenced by HistogramManager::book().

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

Definition at line 123 of file GeometryInterface.h.

References unintern().

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

123  {
124  return unintern(col);
125  }
std::string unintern(ID id)
int col
Definition: cuy.py:1008
std::string GeometryInterface::unintern ( ID  id)
inline

Definition at line 117 of file GeometryInterface.h.

References alignCSCRings::e, and ids.

Referenced by extract(), and pretty().

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

Member Data Documentation

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

Definition at line 170 of file GeometryInterface.h.

Referenced by allModules(), and loadFromTopology().

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

Definition at line 155 of file GeometryInterface.h.

Referenced by addExtractor(), and 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 159 of file GeometryInterface.h.

Referenced by formatValue(), and loadFromTopology().

const edm::ParameterSet GeometryInterface::iConfig
private

Definition at line 143 of file GeometryInterface.h.

Referenced by load().

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

Definition at line 173 of file GeometryInterface.h.

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

bool GeometryInterface::is_loaded = false
private

Definition at line 145 of file GeometryInterface.h.

Referenced by load(), and loaded().

ID GeometryInterface::max_id = 0
private

Definition at line 174 of file GeometryInterface.h.

Referenced by intern().

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

Definition at line 153 of file GeometryInterface.h.

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

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

Definition at line 154 of file GeometryInterface.h.

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

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