CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
HGCalTriggerGeometryHexImp1 Class Reference
Inheritance diagram for HGCalTriggerGeometryHexImp1:
HGCalTriggerGeometryGenericMapping HGCalTriggerGeometryBase

Public Member Functions

 HGCalTriggerGeometryHexImp1 (const edm::ParameterSet &conf)
 
virtual void initialize (const es_info &) override final
 
- Public Member Functions inherited from HGCalTriggerGeometryGenericMapping
virtual geom_set getCellsFromModule (const unsigned cell_det_id) const override final
 
virtual geom_set getCellsFromTriggerCell (const unsigned cell_det_id) const override final
 
virtual unsigned getModuleFromCell (const unsigned cell_det_id) const override final
 
virtual unsigned getModuleFromTriggerCell (const unsigned trigger_cell_det_id) const override final
 
virtual GlobalPoint getModulePosition (const unsigned module_det_id) const override final
 
virtual geom_ordered_set getOrderedCellsFromModule (const unsigned cell_det_id) const override final
 
virtual geom_ordered_set getOrderedTriggerCellsFromModule (const unsigned trigger_cell_det_id) const override final
 
virtual unsigned getTriggerCellFromCell (const unsigned cell_det_id) const override final
 
virtual GlobalPoint getTriggerCellPosition (const unsigned trigger_cell_det_id) const override final
 
virtual geom_set getTriggerCellsFromModule (const unsigned trigger_cell_det_id) const override final
 
 HGCalTriggerGeometryGenericMapping (const edm::ParameterSet &conf)
 
virtual void reset () override final
 
virtual ~HGCalTriggerGeometryGenericMapping ()
 
- Public Member Functions inherited from HGCalTriggerGeometryBase
const std::string & bhSDName () const
 
const std::string & eeSDName () const
 
const std::string & fhSDName () const
 
 HGCalTriggerGeometryBase (const edm::ParameterSet &conf)
 
const std::string & name () const
 
virtual ~HGCalTriggerGeometryBase ()
 

Private Member Functions

void buildTriggerCellsAndModules (const es_info &)
 
void fillMaps (const es_info &)
 

Private Attributes

edm::FileInPath l1tCellsMapping_
 
edm::FileInPath l1tModulesMapping_
 

Additional Inherited Members

- Public Types inherited from HGCalTriggerGeometryGenericMapping
typedef std::unordered_map< unsigned, std::unique_ptr< const HGCalTriggerGeometry::Module > > module_map
 
typedef std::unordered_map< unsigned, std::unique_ptr< const HGCalTriggerGeometry::TriggerCell > > trigger_cell_map
 
- Public Types inherited from HGCalTriggerGeometryBase
typedef std::unordered_map< unsigned, unsigned > geom_map
 
typedef std::set< unsigned > geom_ordered_set
 
typedef std::unordered_set< unsigned > geom_set
 
- Protected Attributes inherited from HGCalTriggerGeometryGenericMapping
geom_map cells_to_trigger_cells_
 
module_map modules_
 
trigger_cell_map trigger_cells_
 
geom_map trigger_cells_to_modules_
 

Detailed Description

Definition at line 12 of file HGCalTriggerGeometryHexImp1.cc.

Constructor & Destructor Documentation

HGCalTriggerGeometryHexImp1::HGCalTriggerGeometryHexImp1 ( const edm::ParameterSet conf)

Definition at line 29 of file HGCalTriggerGeometryHexImp1.cc.

29  :
31  l1tCellsMapping_(conf.getParameter<edm::FileInPath>("L1TCellsMapping")),
32  l1tModulesMapping_(conf.getParameter<edm::FileInPath>("L1TModulesMapping"))
33 /*****************************************************************/
34 {
35 }
T getParameter(std::string const &) const
HGCalTriggerGeometryGenericMapping(const edm::ParameterSet &conf)

Member Function Documentation

void HGCalTriggerGeometryHexImp1::buildTriggerCellsAndModules ( const es_info esInfo)
private

Definition at line 178 of file HGCalTriggerGeometryHexImp1.cc.

References HGCalTriggerGeometryGenericMapping::cells_to_trigger_cells_, DEFINE_EDM_PLUGIN, HGCalTriggerGeometryBase::es_info::geom_ee, HGCalTriggerGeometryBase::es_info::geom_fh, HGCalGeometry::getPosition(), HGCEE, HGCalTriggerGeometryGenericMapping::modules_, DetId::subdetId(), HGCalTriggerGeometryGenericMapping::trigger_cells_, and HGCalTriggerGeometryGenericMapping::trigger_cells_to_modules_.

Referenced by initialize().

180 {
181  //
182  // Build trigger cells and fill map
184  // make list of cells in trigger cells
185  std::unordered_map<unsigned, list_cells> trigger_cells_to_cells;
186  for(const auto& cell_triggerCell : cells_to_trigger_cells_)
187  {
188  unsigned cell = cell_triggerCell.first;
189  unsigned triggerCell = cell_triggerCell.second;
190  auto itr_exist = trigger_cells_to_cells.emplace(triggerCell, list_cells());
191  itr_exist.first->second.emplace(cell);
192  //trigger_cells_to_cells.at(triggerCell).emplace(cell);
193  }
194  for(const auto& triggerCell_cells : trigger_cells_to_cells)
195  {
196  unsigned triggerCellId = triggerCell_cells.first;
197  list_cells cellIds = triggerCell_cells.second;
198  // Position: barycenter of the trigger cell.
199  Basic3DVector<float> triggerCellVector(0.,0.,0.);
200  for(const auto& cell : cellIds)
201  {
202  HGCalDetId cellDetId(cell);
203  triggerCellVector += (cellDetId.subdetId()==ForwardSubdetector::HGCEE ? esInfo.geom_ee->getPosition(cellDetId) : esInfo.geom_fh->getPosition(cellDetId)).basicVector();
204  }
205  GlobalPoint triggerCellPoint( triggerCellVector/cellIds.size() );
206  const auto& triggerCellToModuleItr = trigger_cells_to_modules_.find(triggerCellId);
207  unsigned moduleId = (triggerCellToModuleItr!=trigger_cells_to_modules_.end() ? triggerCellToModuleItr->second : 0); // 0 if the trigger cell doesn't belong to a module
208  //unsigned moduleId = trigger_cells_to_modules_.at(triggercellId);
209  // FIXME: empty neighbours
210  trigger_cells_.emplace(triggerCellId, std::make_unique<const HGCalTriggerGeometry::TriggerCell>(triggerCellId, moduleId, triggerCellPoint, list_cells(), cellIds));
211  }
212  //
213  // Build modules and fill map
214  typedef HGCalTriggerGeometry::Module::list_type list_triggerCells;
215  typedef HGCalTriggerGeometry::Module::tc_map_type tc_map_to_cells;
216  // make list of trigger cells in modules
217  std::unordered_map<unsigned, list_triggerCells> modules_to_trigger_cells;
218  for(const auto& triggerCell_module : trigger_cells_to_modules_)
219  {
220  unsigned triggerCell = triggerCell_module.first;
221  unsigned module = triggerCell_module.second;
222  auto itr_exist = modules_to_trigger_cells.emplace(module, list_triggerCells());
223  itr_exist.first->second.emplace(triggerCell);
224  //modules_to_trigger_cells.at(module).emplace(triggerCell);
225  }
226  for(const auto& module_triggerCell : modules_to_trigger_cells)
227  {
228  unsigned moduleId = module_triggerCell.first;
229  list_triggerCells triggerCellIds = module_triggerCell.second;
230  tc_map_to_cells cellsInTriggerCells;
231  // Position: barycenter of the module, from trigger cell positions
232  Basic3DVector<float> moduleVector(0.,0.,0.);
233  for(const auto& triggerCell : triggerCellIds)
234  {
235  const auto& cells_in_tc = trigger_cells_to_cells.at(triggerCell);
236  for( const unsigned cell : cells_in_tc )
237  {
238  cellsInTriggerCells.emplace(triggerCell,cell);
239  }
240  moduleVector += trigger_cells_.at(triggerCell)->position().basicVector();
241  }
242  GlobalPoint modulePoint( moduleVector/triggerCellIds.size() );
243  // FIXME: empty neighbours
244  modules_.emplace(moduleId, std::make_unique<const HGCalTriggerGeometry::Module>(moduleId, modulePoint, list_triggerCells(), triggerCellIds, cellsInTriggerCells));
245  }
246 }
std::unordered_set< unsigned > list_type
std::unordered_multimap< unsigned, unsigned > tc_map_type
Definition: vlib.h:208
void HGCalTriggerGeometryHexImp1::fillMaps ( const es_info esInfo)
private

Definition at line 53 of file HGCalTriggerGeometryHexImp1.cc.

References EnergyCorrector::c, HGCalTriggerGeometryGenericMapping::cells_to_trigger_cells_, HGCalTopology::dddConstants(), edm::FileInPath::fullPath(), HGCalTriggerGeometryBase::es_info::geom_ee, HGCalTriggerGeometryBase::es_info::geom_fh, HGCalGeometry::getValidGeomDetIds(), HGCalDetId::kHGCalCellMask, l1tCellsMapping_, l1tModulesMapping_, HGCalDetId::layer(), python.rootplot.argparse::module, HGCalDDDConstants::numberCellsHexagon(), PFRecoTauDiscriminationByIsolation_cfi::offset, DetId::subdetId(), HGCalTriggerGeometryBase::es_info::topo_ee, HGCalTriggerGeometryBase::es_info::topo_fh, HGCalTriggerGeometryGenericMapping::trigger_cells_to_modules_, HGCalDetId::wafer(), HGCalDetId::waferType(), HGCalDDDConstants::waferTypeT(), and HGCalDetId::zside().

Referenced by initialize().

55 {
56  //
57  // read module mapping file
58  std::unordered_map<short, short> wafer_to_module_ee;
59  std::unordered_map<short, short> wafer_to_module_fh;
60  std::unordered_map<short, std::map<short,short>> module_to_wafers_ee;
61  std::unordered_map<short, std::map<short,short>> module_to_wafers_fh;
62  std::ifstream l1tModulesMappingStream(l1tModulesMapping_.fullPath());
63  if(!l1tModulesMappingStream.is_open()) edm::LogError("HGCalTriggerGeometry") << "Cannot open L1TModulesMapping file\n";
64  short subdet = 0;
65  short wafer = 0;
66  short module = 0;
67  for(; l1tModulesMappingStream>>subdet>>wafer>>module; )
68  {
69  if(subdet==3)
70  {
71  wafer_to_module_ee.emplace(wafer,module);
72  auto itr_insert = module_to_wafers_ee.emplace(module, std::map<short,short>());
73  itr_insert.first->second.emplace(wafer, 0);
74  }
75  else if(subdet==4)
76  {
77  wafer_to_module_fh.emplace(wafer,module);
78  auto itr_insert = module_to_wafers_fh.emplace(module, std::map<short,short>());
79  itr_insert.first->second.emplace(wafer, 0);
80  }
81  else edm::LogWarning("HGCalTriggerGeometry") << "Unsupported subdetector number ("<<subdet<<") in L1TModulesMapping file\n";
82  }
83  if(!l1tModulesMappingStream.eof()) edm::LogWarning("HGCalTriggerGeometry") << "Error reading L1TModulesMapping '"<<wafer<<" "<<module<<"' \n";
84  l1tModulesMappingStream.close();
85  // read trigger cell mapping file
86  std::map<std::pair<short,short>, short> cells_to_trigger_cells;
87  std::unordered_map<short, short> number_trigger_cells_in_wafers; // the map key is the wafer type
88  std::ifstream l1tCellsMappingStream(l1tCellsMapping_.fullPath());
89  if(!l1tCellsMappingStream.is_open()) edm::LogError("HGCalTriggerGeometry") << "Cannot open L1TCellsMapping file\n";
90  short waferType = 0;
91  short cell = 0;
92  short triggerCell = 0;
93  for(; l1tCellsMappingStream>>waferType>>cell>>triggerCell; )
94  {
95  cells_to_trigger_cells.emplace(std::make_pair((waferType?1:-1),cell), triggerCell);
96  auto itr_insert = number_trigger_cells_in_wafers.emplace((waferType?1:-1), 0);
97  if(triggerCell+1 > itr_insert.first->second) itr_insert.first->second = triggerCell+1;
98  }
99  if(!l1tCellsMappingStream.eof()) edm::LogWarning("HGCalTriggerGeometry") << "Error reading L1TCellsMapping'"<<waferType<<" "<<cell<<" "<<triggerCell<<"' \n";
100  l1tCellsMappingStream.close();
101  // For each wafer compute the trigger cell offset according to the wafer position inside
102  // the module. The first wafer will have an offset equal to 0, the second an offset equal to the
103  // number of trigger cells in the first wafer, etc.
104  short offset = 0;
105  for(auto& module_wafers : module_to_wafers_ee)
106  {
107  offset = 0;
108  for(auto& wafer_offset : module_wafers.second)
109  {
110  wafer_offset.second = offset;
111  int wafer_type = (esInfo.topo_ee->dddConstants().waferTypeT(wafer_offset.first)==1?1:-1);
112  offset += number_trigger_cells_in_wafers.at(wafer_type);
113  }
114  }
115  for(auto& module_wafers : module_to_wafers_fh)
116  {
117  offset = 0;
118  for(auto& wafer_offset : module_wafers.second)
119  {
120  wafer_offset.second = offset;
121  int wafer_type = (esInfo.topo_fh->dddConstants().waferTypeT(wafer_offset.first)==1?1:-1);
122  offset += number_trigger_cells_in_wafers.at(wafer_type);
123  }
124  }
125  //
126  // Loop over HGC cells
127  // EE
128  for(const auto& id : esInfo.geom_ee->getValidGeomDetIds())
129  {
130  if(id.rawId()==0) continue;
131  HGCalDetId waferDetId(id);
132  short module = wafer_to_module_ee[waferDetId.wafer()];
133  short triggercell_offset = module_to_wafers_ee.at(module).at(waferDetId.wafer());
134  int nCells = esInfo.topo_ee->dddConstants().numberCellsHexagon(waferDetId.wafer());
135  for(int c=0;c<nCells;c++)
136  {
137  short triggerCellId = cells_to_trigger_cells[std::make_pair(waferDetId.waferType(),c)];
138  // Fill cell -> trigger cell mapping
139  HGCalDetId cellDetId(ForwardSubdetector(waferDetId.subdetId()), waferDetId.zside(), waferDetId.layer(), waferDetId.waferType(), waferDetId.wafer(), c);
140  // The module id is used instead of the wafer id for the trigger cells
141  // Since there are several wafers per module, an offset is applied on the HGCalDetId::cell field
142  if(triggercell_offset+triggerCellId >= HGCalDetId::kHGCalCellMask) edm::LogError("HGCalTriggerGeometry") << "Trigger cell id requested with a cell field larger than available in HGCalDetId (" << triggercell_offset+triggerCellId << " >= " << HGCalDetId::kHGCalCellMask << ")\n";
143  HGCalDetId triggerCellDetId(ForwardSubdetector(waferDetId.subdetId()), waferDetId.zside(), waferDetId.layer(), waferDetId.waferType(), module, triggercell_offset + triggerCellId);
144  cells_to_trigger_cells_.emplace(cellDetId, triggerCellDetId);
145  // Fill trigger cell -> module mapping
146  HGCalDetId moduleDetId(ForwardSubdetector(waferDetId.subdetId()), waferDetId.zside(), waferDetId.layer(), waferDetId.waferType(), module, HGCalDetId::kHGCalCellMask);
147  trigger_cells_to_modules_.emplace(triggerCellDetId, moduleDetId);
148  }
149  }
150  // FH
151  for(const auto& id : esInfo.geom_fh->getValidGeomDetIds())
152  {
153  if(id.rawId()==0) continue;
154  HGCalDetId waferDetId(id);
155  short module = wafer_to_module_fh[waferDetId.wafer()];
156  short triggercell_offset = module_to_wafers_fh.at(module).at(waferDetId.wafer());
157  int nCells = esInfo.topo_fh->dddConstants().numberCellsHexagon(waferDetId.wafer());
158  for(int c=0;c<nCells;c++)
159  {
160  short triggerCellId = cells_to_trigger_cells[std::make_pair(waferDetId.waferType(),c)];
161  // Fill cell -> trigger cell mapping
162  HGCalDetId cellDetId(ForwardSubdetector(waferDetId.subdetId()), waferDetId.zside(), waferDetId.layer(), waferDetId.waferType(), waferDetId.wafer(), c);
163  // The module id is used instead of the wafer id for the trigger cells
164  // Since there are several wafers per module, an offset is applied on the HGCalDetId::cell field
165  if(triggercell_offset+triggerCellId >= HGCalDetId::kHGCalCellMask) edm::LogError("HGCalTriggerGeometry") << "Trigger cell id requested with a cell field larger than available in HGCalDetId (" << triggercell_offset+triggerCellId << " >= " << HGCalDetId::kHGCalCellMask << ")\n";
166  HGCalDetId triggerCellDetId(ForwardSubdetector(waferDetId.subdetId()), waferDetId.zside(), waferDetId.layer(), waferDetId.waferType(), module, triggercell_offset + triggerCellId);
167  cells_to_trigger_cells_.emplace(cellDetId, triggerCellDetId);
168  // Fill trigger cell -> module mapping
169  HGCalDetId moduleDetId(ForwardSubdetector(waferDetId.subdetId()), waferDetId.zside(), waferDetId.layer(), waferDetId.waferType(), module, HGCalDetId::kHGCalCellMask);
170  trigger_cells_to_modules_.emplace(triggerCellDetId, moduleDetId);
171  }
172  }
173 }
ForwardSubdetector
static const int kHGCalCellMask
Definition: HGCalDetId.h:13
std::string fullPath() const
Definition: FileInPath.cc:184
Definition: vlib.h:208
void HGCalTriggerGeometryHexImp1::initialize ( const es_info esInfo)
finaloverridevirtual

Implements HGCalTriggerGeometryBase.

Definition at line 39 of file HGCalTriggerGeometryHexImp1.cc.

References buildTriggerCellsAndModules(), and fillMaps().

41 {
42  edm::LogWarning("HGCalTriggerGeometry") << "WARNING: This HGCal trigger geometry is incomplete.\n"\
43  << "WARNING: There is no neighbor information.\n";
44 
45  fillMaps(esInfo);
47 
48 }
void buildTriggerCellsAndModules(const es_info &)

Member Data Documentation

edm::FileInPath HGCalTriggerGeometryHexImp1::l1tCellsMapping_
private

Definition at line 20 of file HGCalTriggerGeometryHexImp1.cc.

Referenced by fillMaps().

edm::FileInPath HGCalTriggerGeometryHexImp1::l1tModulesMapping_
private

Definition at line 21 of file HGCalTriggerGeometryHexImp1.cc.

Referenced by fillMaps().