20 virtual void reset()
override final;
75 bool validCellId(
unsigned subdet,
unsigned cell_id)
const;
80 unsigned packWaferCellId(
unsigned subdet,
unsigned wafer,
unsigned cell)
const;
81 unsigned packIetaIphi(
unsigned ieta,
unsigned iphi)
const;
82 void unpackWaferCellId(
unsigned wafer_cell,
unsigned& wafer,
unsigned& cell)
const;
83 void unpackIetaIphi(
unsigned ieta_iphi,
unsigned& ieta,
unsigned& iphi)
const;
96 std::vector<unsigned> tmp_vector = conf.
getParameter<std::vector<unsigned>>(
"DisconnectedModules");
135 unsigned wafer_trigger_cell = 0;
136 unsigned trigger_cell = 0;
142 unsigned ieta = cell_det_id.
ietaAbs();
143 unsigned iphi = cell_det_id.
iphi();
144 layer = cell_det_id.
depth();
146 zside = cell_det_id.
zside();
151 <<
"HGCalTriggerGeometry: Hcal cell ieta=" << ieta <<
", iphi="<<iphi<<
" is not mapped to any trigger cell. The trigger cell mapping should be modified.\n";
154 wafer_trigger_cell = 0;
162 layer = cell_det_id.
layer();
163 zside = cell_det_id.
zside();
164 unsigned wafer = cell_det_id.
wafer();
165 unsigned cell = cell_det_id.
cell();
170 <<
"HGCalTriggerGeometry: HGCal cell " << cell <<
" in wafer "<<wafer<<
" is not mapped to any trigger cell. The trigger cell mapping should be modified.\n";
173 wafer_trigger_cell = 0;
191 HGCalDetId trigger_cell_det_id(trigger_cell_id);
197 module = trigger_cell_det_id.
wafer();
206 <<trigger_cell_det_id
207 <<
"HGCalTriggerGeometry: Wafer " << trigger_cell_det_id.
wafer() <<
" is not mapped to any trigger module. The module mapping should be modified. See https://twiki.cern.ch/twiki/bin/viewauth/CMS/HGCALTriggerPrimitivesSimulation#Trigger_geometry for details.\n";
209 module = module_itr->second;
218 HGCalDetId trigger_cell_det_id(trigger_cell_id);
223 unsigned subdet = trigger_cell_det_id.
subdetId();
224 unsigned trigger_wafer = trigger_cell_det_id.
wafer();
225 unsigned trigger_cell = trigger_cell_det_id.
cell();
227 for(
auto tc_c_itr=cell_range.first; tc_c_itr!=cell_range.second; tc_c_itr++)
233 if(
validCellId(subdet, cell_det_id)) cell_det_ids.emplace(cell_det_id);
239 unsigned subdet = trigger_cell_det_id.
subdetId();
240 unsigned trigger_wafer = trigger_cell_det_id.
wafer();
241 unsigned trigger_cell = trigger_cell_det_id.
cell();
243 for(
auto tc_c_itr=cell_range.first; tc_c_itr!=cell_range.second; tc_c_itr++)
250 if(
validCellId(subdet, cell_det_id)) cell_det_ids.emplace(cell_det_id);
262 for(
auto trigger_cell_id : trigger_cells)
265 cell_det_ids.insert(cells.begin(), cells.end());
276 for(
auto trigger_cell_id : trigger_cells)
279 cell_det_ids.insert(cells.begin(), cells.end());
298 if(
validTriggerCell(trigger_cell_id)) trigger_cell_det_ids.emplace(trigger_cell_id.rawId());
307 for(
auto wafer_itr=wafer_itrs.first; wafer_itr!=wafer_itrs.second; wafer_itr++)
309 unsigned wafer = wafer_itr->second;
314 if(
validTriggerCell(trigger_cell_id)) trigger_cell_det_ids.emplace(trigger_cell_id.rawId());
318 return trigger_cell_det_ids;
335 if(
validTriggerCell(trigger_cell_id)) trigger_cell_det_ids.emplace(trigger_cell_id.rawId());
344 for(
auto wafer_itr=wafer_itrs.first; wafer_itr!=wafer_itrs.second; wafer_itr++)
346 unsigned wafer = wafer_itr->second;
351 if(
validTriggerCell(trigger_cell_id)) trigger_cell_det_ids.emplace(trigger_cell_id.rawId());
355 return trigger_cell_det_ids;
364 HGCalDetId trigger_cell_det_id(trigger_cell_id);
368 unsigned trigger_cell = trigger_cell_det_id.
cell();
372 auto neighbors_itr = neighbors_map.find(trigger_cell_key);
373 if(neighbors_itr==neighbors_map.end())
376 <<
"HGCalTriggerGeometry: Neighbors are not defined for trigger cell " << trigger_cell <<
" in module " 377 << module <<
". The trigger cell neighbor mapping should be modified. \n";
379 const auto& neighbors = neighbors_itr->second;
381 neighbor_detids.reserve(neighbors.size());
382 for(
const auto& module_tc : neighbors)
387 neighbor_detids.emplace(neighbor_det_id.rawId());
390 return neighbor_detids;
405 for(
const auto& cell : cell_ids)
414 for(
const auto& cell : cell_ids)
420 return GlobalPoint( triggerCellVector/cell_ids.size() );
435 for(
const auto& cell : cell_ids)
444 for(
const auto& cell : cell_ids)
450 return GlobalPoint( moduleVector/cell_ids.size() );
461 if(!l1tModulesMappingStream.is_open())
464 <<
"Cannot open HGCalTriggerGeometry L1TModulesMapping file\n";
466 short trigger_wafer = 0;
468 for(; l1tModulesMappingStream>>trigger_wafer>>
module; )
475 if(!l1tModulesMappingStream.eof())
edm::LogWarning(
"HGCalTriggerGeometry") <<
"Error reading L1TModulesMapping '"<<trigger_wafer<<
" "<<module<<
"' \n";
476 l1tModulesMappingStream.close();
479 if(!l1tCellsMappingStream.is_open())
482 <<
"Cannot open HGCalTriggerGeometry L1TCellsMapping file\n";
488 short trigger_cell = 0;
489 for(; l1tCellsMappingStream>>subdet>>wafer>>cell>>trigger_wafer>>trigger_cell; )
492 unsigned trigger_cell_key =
packWaferCellId(subdet,trigger_wafer,trigger_cell);
498 if(trigger_cell+1 > itr_insert.first->second) itr_insert.first->second = trigger_cell+1;
500 if(!l1tCellsMappingStream.eof())
edm::LogWarning(
"HGCalTriggerGeometry") <<
"Error reading L1TCellsMapping '"<<subdet<<
" "<<wafer<<
" "<<cell<<
" "<<trigger_wafer<<
" "<<trigger_cell<<
"' \n";
501 l1tCellsMappingStream.close();
504 if(!l1tCellsBHMappingStream.is_open())
507 <<
"Cannot open HGCalTriggerGeometry L1TCellsBHMapping file\n";
513 for(; l1tCellsBHMappingStream>>ieta>>iphi>>trigger_wafer>>trigger_cell; )
522 if(trigger_cell+1 > itr_insert.first->second) itr_insert.first->second = trigger_cell+1;
524 if(!l1tCellsBHMappingStream.eof())
edm::LogWarning(
"HGCalTriggerGeometry") <<
"Error reading L1TCellsBHMapping '"<<ieta<<
" "<<iphi<<
" "<<trigger_wafer<<
" "<<trigger_cell<<
"' \n";
525 l1tCellsBHMappingStream.close();
534 std::ifstream l1tCellNeighborsMappingStream(file.
fullPath());
535 if(!l1tCellNeighborsMappingStream.is_open())
538 <<
"Cannot open HGCalTriggerGeometry L1TCellNeighborsMapping file\n";
540 for(std::array<char,512>
buffer; l1tCellNeighborsMappingStream.getline(&
buffer[0], 512); )
548 std::regex key_regex(
"\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*\\)");
549 std::vector<std::string> key_tokens {
550 std::sregex_token_iterator(line.begin(), line.end(), key_regex), {}
552 if(key_tokens.size()<1)
555 <<
"Syntax error in the L1TCellNeighborsMapping:\n" 556 <<
" Cannot find the trigger cell key in line:\n" 557 <<
" '"<<&
buffer[0]<<
"'\n";
559 std::regex digits_regex(
"\\d{1,3}");
560 std::vector<std::string> module_tc {
561 std::sregex_token_iterator(key_tokens[0].
begin(), key_tokens[0].
end(), digits_regex), {}
564 int module = std::stoi(module_tc[0]);
565 int trigger_cell = std::stoi(module_tc[1]);
571 std::regex neighbors_regex(
"\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*\\)");
572 std::vector<std::string> neighbors_tokens {
573 std::sregex_token_iterator(line.begin(), line.end(), neighbors_regex), {}
575 if(neighbors_tokens.size()<2)
578 <<
"Syntax error in the L1TCellNeighborsMapping:\n" 579 <<
" Cannot find any neighbor in line:\n" 580 <<
" '"<<&
buffer[0]<<
"'\n";
582 auto itr_insert = neighbors_map.emplace(map_key, std::set<std::pair<short,short>>());
584 for(
unsigned i=1;
i<neighbors_tokens.size();
i++)
586 const auto& neighbor = neighbors_tokens[
i];
587 std::vector<std::string> pair_neighbor {
588 std::sregex_token_iterator(neighbor.begin(), neighbor.end(), digits_regex), {}
590 short neighbor_module(std::stoi(pair_neighbor[0]));
591 short neighbor_cell(std::stoi(pair_neighbor[1]));
592 itr_insert.first->second.emplace(neighbor_module, neighbor_cell);
595 if(!l1tCellNeighborsMappingStream.eof())
edm::LogWarning(
"HGCalTriggerGeometry") <<
"Error reading L1TCellNeighborsMapping'\n";
596 l1tCellNeighborsMappingStream.close();
607 for(
unsigned layer=1; layer<=n_layers_ee; layer++)
611 unsigned wafer = wafer_module.first;
615 std::set<unsigned> trigger_cell_ids;
620 for(
unsigned trigger_cell : trigger_cell_ids)
637 unsigned packed_value = 0;
638 const int kSubdetMask = 0x7;
650 unsigned packed_value = 0;
695 HGCalDetId trigger_cell_det_id(trigger_cell_id);
696 unsigned subdet = trigger_cell_det_id.
subdetId();
699 for(
const auto cell_id : cells)
735 unsigned packed_value = 0;
767 "HGCalTriggerGeometryHexLayerBasedImp1");
const HGCalGeometry & eeGeometry() const
std::unordered_set< unsigned > disconnected_modules_
T getParameter(std::string const &) const
std::unordered_map< int, std::set< std::pair< short, short > > > trigger_cell_neighbors_
virtual unsigned getTriggerCellFromCell(const unsigned) const override final
HGCalTriggerGeometryHexLayerBasedImp1(const edm::ParameterSet &conf)
std::unordered_multimap< unsigned, unsigned > module_to_wafers_
virtual geom_ordered_set getOrderedTriggerCellsFromModule(const unsigned) const override final
void fillInvalidTriggerCells()
edm::FileInPath l1tCellNeighborsBHMapping_
const HGCalGeometry & fhGeometry() const
bool valid(const DetId &id) const override
bool is_valid(const Digi &d)
int zside() const
get the z-side of the cell (1/-1)
std::unordered_multimap< unsigned, unsigned > trigger_cells_to_cells_
virtual geom_set getTriggerCellsFromModule(const unsigned) const override final
std::unordered_map< unsigned, unsigned short > number_trigger_cells_in_wafers_bh_
const HGCalTopology & eeTopology() const
int detIdWaferType(unsigned subdet, short wafer) const
virtual void reset() override final
Global3DPoint GlobalPoint
std::unordered_map< int, std::set< std::pair< short, short > > > trigger_cell_neighbors_bh_
virtual geom_ordered_set getOrderedCellsFromModule(const unsigned) const override final
edm::FileInPath l1tCellsBHMapping_
static const int kHGCalWaferTypeOffset
virtual geom_set getNeighborsFromTriggerCell(const unsigned) const override final
GlobalPoint getPosition(const DetId &id) const
unsigned packIetaIphi(unsigned ieta, unsigned iphi) const
std::unordered_map< unsigned, unsigned > cells_to_trigger_cells_
edm::FileInPath l1tModulesMapping_
virtual void initialize(const edm::ESHandle< CaloGeometry > &) override final
bool validCellId(unsigned subdet, unsigned cell_id) const
virtual unsigned getModuleFromCell(const unsigned) const override final
void fillNeighborMaps(const edm::FileInPath &, std::unordered_map< int, std::set< std::pair< short, short >>> &)
std::unordered_map< unsigned, unsigned short > number_trigger_cells_in_wafers_
uint32_t rawId() const
get the raw id
void unpackWaferCellId(unsigned wafer_cell, unsigned &wafer, unsigned &cell) const
static const int kHGCalCellOffset
static const int kHGCalCellMask
int depth() const
get the tower depth
unsigned int layers(bool reco) const
int zside() const
get the z-side of the cell (1/-1)
const HcalTopology & bhTopology() const
void unpackIetaIphi(unsigned ieta_iphi, unsigned &ieta, unsigned &iphi) const
unsigned packWaferCellId(unsigned subdet, unsigned wafer, unsigned cell) const
std::unordered_map< unsigned, unsigned > cells_to_trigger_cells_bh_
std::unordered_set< unsigned > invalid_triggercells_
unsigned packTriggerCell(unsigned, unsigned) const
int wafer() const
get the wafer #
virtual bool validTriggerCell(const unsigned) const override final
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
GlobalPoint getPosition(const DetId &id) const
edm::FileInPath l1tCellNeighborsMapping_
void setCaloGeometry(const edm::ESHandle< CaloGeometry > &geom)
int ietaAbs() const
get the absolute value of the cell ieta
virtual geom_set getCellsFromTriggerCell(const unsigned) const override final
int iphi() const
get the cell iphi
static const int kHcalPhiMask2
std::unordered_map< unsigned, unsigned > wafer_to_module_
int cell() const
get the absolute value of the cell #'s in x and y
const HGCalDDDConstants & dddConstants() const
static const int kHGCalWaferOffset
std::unordered_multimap< unsigned, unsigned > trigger_cells_to_cells_bh_
std::set< unsigned > geom_ordered_set
bool validTriggerCellFromCells(const unsigned) const
virtual bool disconnectedModule(const unsigned) const override final
virtual GlobalPoint getTriggerCellPosition(const unsigned) const override final
static const int kHcalEtaOffset2
std::unordered_set< unsigned > geom_set
static const int kHcalEtaMask2
std::string fullPath() const
virtual GlobalPoint getModulePosition(const unsigned) const override final
edm::FileInPath l1tCellsMapping_
int waferType() const
get the wafer type
#define DEFINE_EDM_PLUGIN(factory, type, name)
bool valid(const DetId &id) const override
Is this a valid cell id.
virtual unsigned getModuleFromTriggerCell(const unsigned) const override final
virtual geom_set getCellsFromModule(const unsigned) const override final
const BasicVectorType & basicVector() const
int waferTypeT(int wafer) const
const HGCalTopology & fhTopology() const
int layer() const
get the layer #
const HcalGeometry & bhGeometry() const
static const int kHGCalWaferMask