14 : doNose_(conf.getParameter<
bool>(
"doNose")),
15 minEta_(conf.getParameter<double>(
"minEta")),
16 maxEta_(conf.getParameter<double>(
"maxEta")),
17 minPhi_(conf.getParameter<double>(
"minPhi")),
18 maxPhi_(conf.getParameter<double>(
"maxPhi")),
19 nBinsEta_(conf.getParameter<
int>(
"nBinsEta")),
20 nBinsPhi_(conf.getParameter<
int>(
"nBinsPhi")),
21 binsEta_(conf.getParameter<
std::
vector<double> >(
"binsEta")),
22 binsPhi_(conf.getParameter<
std::
vector<double> >(
"binsPhi")),
23 splitModuleSum_(conf.getParameter<
bool>(
"splitModuleSum")) {
26 <<
"HGCalTriggerTowerGeometryHelper nBinsEta for the tower map not consistent with binsEta size" << std::endl;
31 <<
"HGCalTriggerTowerGeometryHelper nBinsPhi for the tower map not consistent with binsPhi size" << std::endl;
36 for (
unsigned int bin1 = 0; bin1 !=
nBinsEta_ + 1; bin1++) {
43 for (
unsigned int bin2 = 0; bin2 !=
nBinsPhi_ + 1; bin2++) {
49 for (
unsigned int bin1 = 0; bin1 !=
nBinsEta_; bin1++) {
50 for (
unsigned int bin2 = 0; bin2 !=
nBinsPhi_; bin2++) {
63 if (!l1tTriggerTowerMappingStream.is_open()) {
64 throw cms::Exception(
"MissingDataFile") <<
"Cannot open HGCalTriggerGeometry L1TTriggerTowerMapping file\n";
67 unsigned trigger_cell_id = 0;
68 unsigned short iEta = 0;
69 unsigned short iPhi = 0;
71 for (; l1tTriggerTowerMappingStream >> trigger_cell_id >>
iEta >> iPhi;) {
74 <<
"HGCalTriggerTowerGeometryHelper warning inconsistent mapping TC : " << trigger_cell_id
75 <<
" to TT iEta: " <<
iEta <<
" iPhi: " << iPhi <<
" when max #bins eta: " <<
nBinsEta_ 81 l1tTriggerTowerMappingStream.close();
91 if (!moduleTowerMappingStream.is_open()) {
92 throw cms::Exception(
"MissingDataFile") <<
"Cannot open HGCalTowerMapProducer moduleTowerMapping file\n";
96 std::getline(moduleTowerMappingStream,
line);
97 std::getline(moduleTowerMappingStream,
line);
98 std::stringstream
ss(
line);
102 std::getline(moduleTowerMappingStream,
line);
103 std::getline(moduleTowerMappingStream,
line);
104 const int minNumOfWordsPerRow = 5;
105 const int numOfWordsPerTower = 3;
107 int numOfWordsInThisRow = 0;
110 numOfWordsInThisRow++;
113 if (numOfWordsInThisRow < minNumOfWordsPerRow) {
115 <<
"HGCalTriggerTowerGeometryHelper warning: Incorrect/incomplete values for module ID in the mapping " 117 <<
"The incorrect line is:" <<
line << std::endl;
124 std::stringstream
ss(
line);
125 ss >> subdet >>
layer >> moduleU >> moduleV >> numTowers;
126 if (numOfWordsInThisRow != (numTowers * numOfWordsPerTower + minNumOfWordsPerRow)) {
128 <<
"HGCalTriggerTowerGeometryHelper warning: Incorrect/incomplete values for module ID or tower " 129 "share/eta/phi in the mapping file.\n" 130 <<
"The incorrect line is:" <<
line << std::endl;
133 std::vector<unsigned>
towers;
134 for (
int itr_tower = 0; itr_tower < numTowers; itr_tower++) {
138 ss >> iEta_raw >> iPhi_raw >> towerShare;
140 if ((towerShare > splitDivisor) || (towerShare < 1)) {
142 <<
"HGCalTriggerTowerGeometryHelper warning: invalid tower share in the mapping file.\n" 143 <<
"Tower share must be a positive integer and less than splitDivisor. The incorrect values found for " 146 <<
"subdet=" << subdet <<
", l=" <<
layer <<
", u=" << moduleU <<
", v=" << moduleV << std::endl;
152 moduleTowerMappingStream.close();
157 unsigned packed_modID = 0;
169 unsigned packed_towerIDandShare = 0;
170 unsigned iEtaAbs =
std::abs(iEta_raw);
171 unsigned iEtaSign = std::signbit(iEta_raw);
172 unsigned iPhiAbs =
std::abs(iPhi_raw);
173 unsigned iPhiSign = std::signbit(iPhi_raw);
179 return packed_towerIDandShare;
185 int& towerShare)
const {
189 iEta_raw = (iEtaSign) ? -1 * iEta_raw : iEta_raw;
193 iPhi_raw = (iPhiSign) ? -1 * iPhi_raw : iPhi_raw;
214 unsigned int bin_eta = 0;
223 <<
" did not manage to map eta " <<
eta <<
" to any Trigger Tower\n";
226 bin_eta = bin_eta_l -
binsEta_.begin() - 1;
230 unsigned int bin_phi = 0;
238 <<
" did not manage to map phi " <<
phi <<
" to any Trigger Tower\n";
241 bin_phi = bin_phi_l -
binsPhi_.begin() - 1;
249 std::unordered_map<unsigned short, float> towerIDandShares = {};
250 unsigned int trigger_cell_id = thecell.
detId();
256 towerIDandShares.insert({tower_id_itr->second, 1.0});
257 return towerIDandShares;
260 return towerIDandShares;
265 std::unordered_map<unsigned short, float> towerIDandShares = {};
268 return towerIDandShares;
272 int moduleV = detid.moduleV();
273 int layer = detid.layer();
274 int sector = detid.sector();
275 int zside = detid.zside();
278 if (detid.isHScintillator()) {
281 }
else if (detid.isEE()) {
284 }
else if (detid.isHSilicon()) {
289 return towerIDandShares;
302 int towerShare = -999;
303 for (
auto towerIDandShare : module_id_itr->second) {
305 iEta = offsetEta + iEta_raw;
310 towerIDandShares.insert(
313 return towerIDandShares;
316 return towerIDandShares;
int moduleU() const
get the module U
T getParameter(std::string const &) const
static const int kHGCalTriggerSubdetMask
std::string fullPath() const
const std::vector< l1t::HGCalTowerCoord > & getTowerCoordinates() const
static const int towerShareMask
Geom::Phi< T > phi() const
static const int coord1Shift
static const int towerShareShift
static const int kHGCalModuleVOffset
static const int kHGCalLayerMask
Log< level::Error, false > LogError
std::unordered_map< unsigned, std::vector< unsigned > > modules_to_trigger_towers_
static const int kHGCalModuleUOffset
HGCalTriggerTools triggerTools_
std::vector< double > binsPhi_
unsigned towerId(DetId const &, EcalElectronicsMapping const *)
std::vector< l1t::HGCalTowerCoord > tower_coords_
Abs< T >::type abs(const T &t)
static const int sign2Shift
std::vector< double > binsEta_
unsigned packTowerIDandShare(int towerEta, int towerPhi, int towerShare) const
const GlobalPoint & position() const
std::unordered_map< unsigned short, float > getTriggerTower(const l1t::HGCalTriggerCell &) const
static const int kHGCalModuleUMask
static const int coord2Shift
static const int signMask
const GlobalPoint & position() const
void reverseXaxis(int &towerPhi) const
int moveToCorrectSector(int towerPhi_raw, int sector) const
static const int coordMask
static const int kHGCalModuleVMask
std::unordered_map< unsigned, short > cells_to_trigger_towers_
unsigned short rawId() const
HGCalTriggerTowerGeometryHelper(const edm::ParameterSet &conf)
unsigned packLayerSubdetWaferId(int subdet, int layer, int moduleU, int moduleV) const
void unpackTowerIDandShare(unsigned towerIDandShare, int &towerEta_raw, int &towerPhi_raw, int &towerShare) const
static const int kHGCalLayerOffset
static const int sign1Shift
unsigned short getTriggerTowerFromEtaPhi(const float &eta, const float &phi) const
static const int kHGCalTriggerSubdetOffset