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, hcalTTPDigis_cfi::id, hpstanc_transforms::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 hcalTTPDigis_cfi::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, hcalTTPDigis_cfi::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, hcalTTPDigis_cfi::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 432 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().

432  {
433  auto it = format_value.find(std::make_pair(col, val));
434  if (it != format_value.end()) return it->second;
435 
436  // non-number output names (_pO etc.) are hardwired here.
438  std::string value = "_" + std::to_string(int(val));
439  if (val == 0) value = ""; // hide Barrel_0 etc.
440  if (name == "PXDisk" && val > 0) // +/- sign for disk num
441  value = "_+" + std::to_string(int(val));
442  // pretty (legacy?) names for Shells and HalfCylinders
443  std::map<int, std::string> shellname{
444  {11, "_mI"}, {12, "_mO"}, {21, "_pI"}, {22, "_pO"}};
445  if (name == "HalfCylinder" || name == "Shell") value = shellname[int(val)];
446  if (val == UNDEFINED) value = "_UNDEFINED";
447  return format_value[std::make_pair(col, val)] = name+value;
448 }
std::map< std::pair< Column, Value >, std::string > format_value
std::string pretty(Column col)
Definition: value.py:1
static const Value UNDEFINED
col
Definition: cuy.py:1008
ID GeometryInterface::intern ( std::string const &  id)
inline

Definition at line 100 of file GeometryInterface.h.

References extractors, hcalTTPDigis_cfi::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 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 388 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().

388  {
389  auto cablingMapLabel = iConfig.getParameter<std::string>("CablingMapLabel");
391  iSetup.get<SiPixelFedCablingMapRcd>().get(cablingMapLabel, theCablingMap);
392 
393  std::shared_ptr<SiPixelFrameReverter> siPixelFrameReverter =
394  // I think passing the bare pointer here is safe, but who knows...
395  std::make_shared<SiPixelFrameReverter>(iSetup, theCablingMap.operator->());
396 
397  addExtractor(intern("FED"),
398  [siPixelFrameReverter] (InterestingQuantities const& iq) {
399  if (iq.sourceModule == 0xFFFFFFFF)
400  return Value(iq.col); // hijacked for the raw data plugin
401  return Value(siPixelFrameReverter->findFedId(iq.sourceModule.rawId()));
402  }
403  );
404 
405  // TODO: ranges should be set manually below, since booking probably cannot
406  // infer them correctly (no ROC-level granularity)
407  // PERF: this is slow. Prefer SiPixelCordinates versions here.
408  addExtractor(intern("LinkInFed"),
409  [siPixelFrameReverter] (InterestingQuantities const& iq) {
410  if (iq.sourceModule == 0xFFFFFFFF)
411  return Value(iq.row); // hijacked for the raw data plugin
412  sipixelobjects::GlobalPixel gp = {iq.row, iq.col};
413  return Value(siPixelFrameReverter->findLinkInFed(iq.sourceModule.rawId(), gp));
414  }
415  );
416  // not sure if this is useful anywhere.
417  addExtractor(intern("RocInLink"),
418  [siPixelFrameReverter] (InterestingQuantities const& iq) {
419  sipixelobjects::GlobalPixel gp = {iq.row, iq.col};
420  return Value(siPixelFrameReverter->findRocInLink(iq.sourceModule.rawId(), gp));
421  }
422  );
423  // This might be equivalent to our ROC numbering.
424  addExtractor(intern("RocInDet"),
425  [siPixelFrameReverter] (InterestingQuantities const& iq) {
426  sipixelobjects::GlobalPixel gp = {iq.row, iq.col};
427  return Value(siPixelFrameReverter->findRocInDet(iq.sourceModule.rawId(), gp));
428  }
429  );
430 }
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(), 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  // Pixel Map axis.
244  // TODO: automatic range and binning for phase0 are incorrect.
245  // Should be set manually here.
246  addExtractor(intern("SignedModuleCoord"), // BPIX x
247  [coord, from_coord] (InterestingQuantities const& iq) {
248  return from_coord(coord->signed_module_coord(iq.sourceModule(),
249  std::make_pair(int(iq.row), int(iq.col))));
250  }, UNDEFINED, UNDEFINED, 1.0/8.0
251  );
252  addExtractor(intern("SignedLadderCoord"), // BPIX y
253  [coord, from_coord] (InterestingQuantities const& iq) {
254  return from_coord(coord->signed_ladder_coord(iq.sourceModule(),
255  std::make_pair(int(iq.row), int(iq.col))));
256  }, UNDEFINED, UNDEFINED, 1.0/2.0
257  );
258  addExtractor(intern("SignedDiskCoord"), // FPIX x (per-ring)
259  [coord, from_coord] (InterestingQuantities const& iq) {
260  return from_coord(coord->signed_disk_coord(iq.sourceModule(),
261  std::make_pair(int(iq.row), int(iq.col))));
262  }, UNDEFINED, UNDEFINED, 1.0/8.0
263  );
264  addExtractor(intern("SignedDiskRingCoord"), // FPIX x (FPIX-as-one-plot)
265  [coord, from_coord] (InterestingQuantities const& iq) {
266  return from_coord(coord->signed_disk_ring_coord(iq.sourceModule(),
267  std::make_pair(int(iq.row), int(iq.col))));
268  }, UNDEFINED, UNDEFINED, 1.0/16.0
269  );
270  addExtractor(intern("SignedBladePanelCoord"), // FPIX y
271  [coord, from_coord, phase] (InterestingQuantities const& iq) {
272  if (phase == 0) {
273  return from_coord(coord->signed_blade_coord(
274  iq.sourceModule(), std::make_pair(int(iq.row), int(iq.col))));
275  } else if (phase == 1) {
276  return from_coord(coord->signed_blade_panel_coord(
277  iq.sourceModule(), std::make_pair(int(iq.row), int(iq.col))));
278  } else {
279  return UNDEFINED; // TODO: phase2
280  }
281  }, UNDEFINED, UNDEFINED, phase == 1 ? 0.25 : 0.2
282  );
283  addExtractor(intern("SignedShiftedBladePanelCoord"), // FPIX-as-one y
284  [coord, from_coord, phase] (InterestingQuantities const& iq) {
285  if (phase == 0) {
286  return from_coord(coord->signed_blade_coord(
287  iq.sourceModule(), std::make_pair(int(iq.row), int(iq.col))));
288  } else if (phase == 1) {
289  return from_coord(coord->signed_shifted_blade_panel_coord(
290  iq.sourceModule(), std::make_pair(int(iq.row), int(iq.col))));
291  } else {
292  return UNDEFINED; // TODO: phase2
293  }
294  }, UNDEFINED, UNDEFINED, phase == 1 ? 0.25 : 0.1 // half-roc for phase0
295  );
296  addExtractor(intern("SignedBladePanel"), // per-module FPIX y
297  [coord, from_coord] (InterestingQuantities const& iq) {
298  return from_coord(coord->signed_blade_panel_coord(iq.sourceModule(), std::make_pair(int(iq.row), int(iq.col))));
299  }, UNDEFINED, UNDEFINED, 1.0/2.0
300  );
301 
302  addExtractor(intern("SignedBladePanel"),
303  [coord, from_coord] (InterestingQuantities const& iq) {
304  return from_coord(coord->signed_blade_panel_coord(iq.sourceModule(), std::make_pair(int(iq.row), int(iq.col))));
305  }, UNDEFINED, UNDEFINED, 1.0/2.0
306  );
307 
308  // more readout-related things.
309  addExtractor(intern("ROC"),
310  [coord, from_coord] (InterestingQuantities const& iq) {
311  return from_coord(coord->roc(iq.sourceModule(),
312  std::make_pair(int(iq.row), int(iq.col))));
313  }
314  );
315  addExtractor(intern("Sector"),
316  [coord, from_coord] (InterestingQuantities const& iq) {
317  return from_coord(coord->sector(iq.sourceModule()));
318  }
319  );
320  addExtractor(intern("Channel"),
321  [coord, from_coord] (InterestingQuantities const& iq) {
322  return from_coord(coord->channel(iq.sourceModule(), std::make_pair(int(iq.row), int(iq.col))));
323  }
324  );
325 
326 }
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(), hcalTTPDigis_cfi::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, 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
const TrackerGeomDet * idToDetUnit(DetId) const
Return the pointer to the GeomDetUnit corresponding to a given DetId.
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)
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
const DetIdContainer & detIds() const
Returm a vector of all GeomDet DetIds (including those of GeomDetUnits)
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 371 of file GeometryInterface.cc.

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

Referenced by load(), and pretty().

371  {
372  // stuff that is within modules. Might require some phase0/phase1/strip switching later
373  addExtractor(intern("row"),
374  [] (InterestingQuantities const& iq) {
375  return Value(iq.row);
376  },
377  0, iConfig.getParameter<int>("module_rows") - 1
378  );
379  addExtractor(intern("col"),
380  [] (InterestingQuantities const& iq) {
381  return Value(iq.col);
382  },
383  0, iConfig.getParameter<int>("module_cols") - 1
384  );
385 
386 }
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 328 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().

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