CMS 3D CMS Logo

HGCalTriggerGeometryImp1.cc
Go to the documentation of this file.
2 
6 
7 #include <fstream>
8 #include <iostream>
9 #include <vector>
10 
12 public:
14 
15  void initialize(const CaloGeometry*) final;
16  void initialize(const HGCalGeometry*, const HGCalGeometry*, const HGCalGeometry*) final;
17  void initialize(const HGCalGeometry*, const HGCalGeometry*, const HGCalGeometry*, const HGCalGeometry*) final;
18 
19 private:
21 
22  void buildMaps();
23 };
24 
25 /*****************************************************************/
28  l1tCellsMapping_(conf.getParameter<edm::FileInPath>("L1TCellsMapping"))
29 /*****************************************************************/
30 {}
31 
32 /*****************************************************************/
34 /*****************************************************************/
35 {
36  // FIXME: !!!Only for HGCEE for the moment!!!
37  edm::LogWarning("HGCalTriggerGeometry") << "WARNING: This HGCal trigger geometry is incomplete.\n"
38  << "WARNING: Only the EE part is covered.\n"
39  << "WARNING: There is no neighbor information.\n";
40  setCaloGeometry(calo_geometry);
41 }
42 
43 /*****************************************************************/
45  const HGCalGeometry* hgc_hsi_geometry,
46  const HGCalGeometry* hgc_hsc_geometry)
47 /*****************************************************************/
48 {
49  throw cms::Exception("BadGeometry")
50  << "HGCalTriggerGeometryImp1 geometry cannot be initialized with the V9 HGCAL geometry";
51 }
52 
53 /*****************************************************************/
55  const HGCalGeometry* hgc_hsi_geometry,
56  const HGCalGeometry* hgc_hsc_geometry,
57  const HGCalGeometry* hgc_nose_geometry)
58 /*****************************************************************/
59 {
60  throw cms::Exception("BadGeometry")
61  << "HGCalTriggerGeometryImp1 geometry cannot be initialized with the V9 HGCAL+NOSE geometry";
62 }
63 
64 /*****************************************************************/
66 /*****************************************************************/
67 {
68  //
69  // read trigger cell mapping file
70  std::ifstream l1tCellsMappingStream(l1tCellsMapping_.fullPath());
71  if (!l1tCellsMappingStream.is_open())
72  edm::LogError("HGCalTriggerGeometry") << "Cannot open L1TCellsMapping file\n";
73  short layer = 0;
74  short subsector = 0;
75  short cell = 0;
76  short module = 0;
77  short triggercell = 0;
78  for (; l1tCellsMappingStream >> layer >> subsector >> cell >> module >> triggercell;) {
79  if (layer > 30 || layer <= 0) {
80  edm::LogWarning("HGCalTriggerGeometry") << "Bad layer index in L1TCellsMapping\n";
81  continue;
82  }
83  // Loop on all sectors
84  // FIXME: Number of sectors in each zside should not be hardcoded
85  for (unsigned z = 0; z <= 1; z++) {
86  int zside = (z == 0 ? -1 : 1);
87  for (unsigned sector = 1; sector <= 18; sector++) {
88  HGCEEDetId detid(HGCEE, zside, layer, sector, subsector, cell);
89  //
90  // Fill cell -> trigger cell mapping
91  HGCTriggerDetId triggerDetid(HGCTrigger, zside, layer, sector, module, triggercell);
92  const auto& ret = cells_to_trigger_cells_.insert(std::make_pair(detid, triggerDetid));
93  if (!ret.second)
94  edm::LogWarning("HGCalTriggerGeometry") << "Duplicate cell in L1TCellsMapping\n";
95  // Fill trigger cell -> module mapping
96  HGCTriggerDetId moduleDetid(HGCTrigger, zside, layer, sector, module, HGCTriggerDetId::UndefinedCell());
98  std::make_pair(triggerDetid, moduleDetid)); // do nothing if trigger cell has already been inserted
99  }
100  }
101  }
102  if (!l1tCellsMappingStream.eof())
103  edm::LogWarning("HGCalTriggerGeometry")
104  << "Error reading L1TCellsMapping'" << layer << " " << cell << " " << triggercell << " " << subsector << "' \n";
105  l1tCellsMappingStream.close();
106  //
107  // Build trigger cells and fill map
109  // make list of cells in trigger cells
110  std::map<unsigned, list_cells> trigger_cells_to_cells;
111  for (const auto& cell_triggercell : cells_to_trigger_cells_) {
112  unsigned cell = cell_triggercell.first;
113  unsigned triggercell = cell_triggercell.second;
114  trigger_cells_to_cells.insert(std::make_pair(triggercell, list_cells()));
115  trigger_cells_to_cells.at(triggercell).insert(cell);
116  }
117  for (const auto& triggercell_cells : trigger_cells_to_cells) {
118  unsigned triggercellId = triggercell_cells.first;
119  list_cells cellIds = triggercell_cells.second;
120  // Position: for the moment, barycenter of the trigger cell.
121  Basic3DVector<float> triggercellVector(0., 0., 0.);
122  for (const auto& cell : cellIds) {
123  HGCTriggerDetId cellId(cell);
124  triggercellVector += eeGeometry()->getPosition(cellId).basicVector();
125  }
126  GlobalPoint triggercellPoint(triggercellVector / cellIds.size());
127  const auto& tc2mItr = trigger_cells_to_modules_.find(triggercellId);
128  unsigned moduleId =
129  (tc2mItr != trigger_cells_to_modules_.end() ? tc2mItr->second
130  : 0); // 0 if the trigger cell doesn't belong to a module
131  // FIXME: empty neighbours
132  std::unique_ptr<const HGCalTriggerGeometry::TriggerCell> triggercellPtr(
133  new HGCalTriggerGeometry::TriggerCell(triggercellId, moduleId, triggercellPoint, list_cells(), cellIds));
134  trigger_cells_.insert(std::make_pair(triggercellId, std::move(triggercellPtr)));
135  }
136  //
137  // Build modules and fill map
138  typedef HGCalTriggerGeometry::Module::list_type list_triggercells;
139  typedef HGCalTriggerGeometry::Module::tc_map_type tc_map_to_cells;
140  // make list of trigger cells in modules
141  std::map<unsigned, list_triggercells> modules_to_trigger_cells;
142  for (const auto& triggercell_module : trigger_cells_to_modules_) {
143  unsigned triggercell = triggercell_module.first;
144  unsigned module = triggercell_module.second;
145  modules_to_trigger_cells.insert(std::make_pair(module, list_triggercells()));
146  modules_to_trigger_cells.at(module).insert(triggercell);
147  }
148  for (const auto& module_triggercell : modules_to_trigger_cells) {
149  unsigned moduleId = module_triggercell.first;
150  list_triggercells triggercellIds = module_triggercell.second;
151  tc_map_to_cells cellsInTriggerCells;
152  // Position: for the moment, barycenter of the module, from trigger cell positions
153  Basic3DVector<float> moduleVector(0., 0., 0.);
154  for (const auto& triggercell : triggercellIds) {
155  const auto& cells_in_tc = trigger_cells_to_cells[triggercell];
156  for (const unsigned cell : cells_in_tc) {
157  cellsInTriggerCells.emplace(triggercell, cell);
158  }
159  moduleVector += trigger_cells_.at(triggercell)->position().basicVector();
160  }
161  GlobalPoint modulePoint(moduleVector / triggercellIds.size());
162  // FIXME: empty neighbours
163  std::unique_ptr<const HGCalTriggerGeometry::Module> modulePtr(new HGCalTriggerGeometry::Module(
164  moduleId, modulePoint, list_triggercells(), triggercellIds, cellsInTriggerCells));
165  modules_.insert(std::make_pair(moduleId, std::move(modulePtr)));
166  }
167 }
168 
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:355
HGCEEDetId.h
HGCalTriggerGeometry::TriggerCell
Definition: HGCalTriggerGeometryGenericMapping.h:31
HGCTriggerDetId.h
HGCalTriggerGeometryImp1::buildMaps
void buildMaps()
Definition: HGCalTriggerGeometryImp1.cc:65
ecaldqm::zside
int zside(DetId const &)
Definition: EcalDQMCommonUtils.cc:189
edm
HLT enums.
Definition: AlignableModifier.h:19
HGCalTriggerGeometryGenericMapping.h
HGCalTriggerGeometryGenericMapping::trigger_cells_to_modules_
geom_map trigger_cells_to_modules_
Definition: HGCalTriggerGeometryGenericMapping.h:139
HGCalTriggerGeometry::Module
Definition: HGCalTriggerGeometryGenericMapping.h:58
FileInPath.h
HGCTriggerDetId
Definition: HGCTriggerDetId.h:8
edm::FileInPath
Definition: FileInPath.h:64
HGCalTriggerGeometry::Module::tc_map_type
std::unordered_multimap< unsigned, unsigned > tc_map_type
Definition: HGCalTriggerGeometryGenericMapping.h:61
CaloGeometry
Definition: CaloGeometry.h:21
DDAxes::z
Point3DBase< float, GlobalTag >
HGCalGeometry
Definition: HGCalGeometry.h:30
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
HGCalTriggerGeometryGenericMapping
Definition: HGCalTriggerGeometryGenericMapping.h:101
HGCalTriggerGeometry::Module::list_type
std::unordered_set< unsigned > list_type
Definition: HGCalTriggerGeometryGenericMapping.h:60
HGCEE
Definition: ForwardSubdetector.h:8
edm::LogWarning
Definition: MessageLogger.h:141
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
edmplugin::PluginFactory
Definition: PluginFactory.h:34
HGCalTriggerGeometryGenericMapping::cells_to_trigger_cells_
geom_map cells_to_trigger_cells_
Definition: HGCalTriggerGeometryGenericMapping.h:138
HGCTriggerDetId::UndefinedCell
const static uint32_t UndefinedCell()
Definition: HGCTriggerDetId.h:32
HGCalTriggerGeometryImp1::l1tCellsMapping_
edm::FileInPath l1tCellsMapping_
Definition: HGCalTriggerGeometryImp1.cc:20
HGCalGeometry::getPosition
GlobalPoint getPosition(const DetId &id) const
Definition: HGCalGeometry.cc:192
HGCalTriggerGeometryGenericMapping::trigger_cells_
trigger_cell_map trigger_cells_
Definition: HGCalTriggerGeometryGenericMapping.h:142
module
Definition: vlib.h:198
PV3DBase::basicVector
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:53
HGCTrigger
Definition: ForwardSubdetector.h:12
HGCalTriggerGeometryBase::eeGeometry
const HGCalGeometry * eeGeometry() const
Definition: HGCalTriggerGeometryBase.h:41
eostools.move
def move(src, dest)
Definition: eostools.py:511
HGCalTriggerGeometryImp1
Definition: HGCalTriggerGeometryImp1.cc:11
Exception
Definition: hltDiff.cc:246
HGCalTriggerGeometryBase::setCaloGeometry
void setCaloGeometry(const CaloGeometry *geom)
Definition: HGCalTriggerGeometryBase.h:106
HGCEEDetId
Definition: HGCEEDetId.h:8
HGCalTriggerGeometry::TriggerCell::list_type
std::unordered_set< unsigned > list_type
Definition: HGCalTriggerGeometryGenericMapping.h:33
HGCalTriggerGeometryImp1::initialize
void initialize(const CaloGeometry *) final
Definition: HGCalTriggerGeometryImp1.cc:33
HGCalTriggerGeometryImp1::HGCalTriggerGeometryImp1
HGCalTriggerGeometryImp1(const edm::ParameterSet &conf)
Definition: HGCalTriggerGeometryImp1.cc:26
HGCalTriggerGeometryGenericMapping::modules_
module_map modules_
Definition: HGCalTriggerGeometryGenericMapping.h:141
Basic3DVector< float >
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:163