Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:20:01

0001 /**
0002  * \class L1GtEtaPhiConversions
0003  *
0004  *
0005  * Description: convert eta and phi between various L1 trigger objects.
0006  *
0007  * Implementation:
0008  *    <TODO: enter implementation details>
0009  *
0010  * \author: Vasile Mihai Ghete   - HEPHY Vienna
0011  *
0012  *
0013  */
0014 
0015 // this class header
0016 #include "L1Trigger/GlobalTrigger/interface/L1GtEtaPhiConversions.h"
0017 
0018 // system include files
0019 #include <iomanip>
0020 #include <iostream>
0021 
0022 // user include files
0023 
0024 //   base class
0025 
0026 //
0027 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerObjectMapFwd.h"
0028 
0029 #include "CondFormats/L1TObjects/interface/L1CaloGeometry.h"
0030 #include "CondFormats/L1TObjects/interface/L1MuTriggerScales.h"
0031 
0032 #include "FWCore/MessageLogger/interface/MessageDrop.h"
0033 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0034 
0035 #include "FWCore/Utilities/interface/Exception.h"
0036 
0037 // constructor
0038 L1GtEtaPhiConversions::L1GtEtaPhiConversions()
0039     : m_nrBinsPhiMu(0),
0040       m_nrBinsPhiJetEg(0),
0041       m_nrBinsPhiEtm(0),
0042       m_nrBinsPhiHtm(0),
0043       m_nrBinsEtaCommon(0),
0044       m_verbosity(0),
0045       m_isDebugEnabled(edm::isDebugEnabled()) {
0046   // prepare the pairs of L1GtObjects, reserve (by hand) memory for vectors
0047   // the index of the pair in m_gtObjectPairVec is used to extract
0048   // the information from the other vectors, so the push_back must be done
0049   // coherently
0050 
0051   std::pair<L1GtObject, L1GtObject> gtObjPair;
0052   m_gtObjectPairVec.reserve(56);
0053   m_pairConvertPhiFirstGtObject.reserve(56);
0054   m_pairNrPhiBinsVec.reserve(56);
0055   m_pairPhiConvVec.reserve(56);
0056 
0057   // Mu -> Jet & EG & ETM & HTM
0058   //
0059   gtObjPair = std::make_pair(Mu, CenJet);
0060   m_gtObjectPairVec.push_back(gtObjPair);
0061   m_pairConvertPhiFirstGtObject.push_back(true);
0062   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0063   m_pairPhiConvVec.push_back(&m_lutPhiMuToJetEg);
0064 
0065   gtObjPair = std::make_pair(CenJet, Mu);
0066   m_gtObjectPairVec.push_back(gtObjPair);
0067   m_pairConvertPhiFirstGtObject.push_back(false);
0068   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0069   m_pairPhiConvVec.push_back(&m_lutPhiMuToJetEg);
0070 
0071   //
0072   gtObjPair = std::make_pair(Mu, ForJet);
0073   m_gtObjectPairVec.push_back(gtObjPair);
0074   m_pairConvertPhiFirstGtObject.push_back(true);
0075   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0076   m_pairPhiConvVec.push_back(&m_lutPhiMuToJetEg);
0077 
0078   gtObjPair = std::make_pair(ForJet, Mu);
0079   m_gtObjectPairVec.push_back(gtObjPair);
0080   m_pairConvertPhiFirstGtObject.push_back(false);
0081   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0082   m_pairPhiConvVec.push_back(&m_lutPhiMuToJetEg);
0083 
0084   //
0085   gtObjPair = std::make_pair(Mu, TauJet);
0086   m_gtObjectPairVec.push_back(gtObjPair);
0087   m_pairConvertPhiFirstGtObject.push_back(true);
0088   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0089   m_pairPhiConvVec.push_back(&m_lutPhiMuToJetEg);
0090 
0091   gtObjPair = std::make_pair(TauJet, Mu);
0092   m_gtObjectPairVec.push_back(gtObjPair);
0093   m_pairConvertPhiFirstGtObject.push_back(false);
0094   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0095   m_pairPhiConvVec.push_back(&m_lutPhiMuToJetEg);
0096 
0097   //
0098   gtObjPair = std::make_pair(Mu, NoIsoEG);
0099   m_gtObjectPairVec.push_back(gtObjPair);
0100   m_pairConvertPhiFirstGtObject.push_back(true);
0101   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0102   m_pairPhiConvVec.push_back(&m_lutPhiMuToJetEg);
0103 
0104   gtObjPair = std::make_pair(NoIsoEG, Mu);
0105   m_gtObjectPairVec.push_back(gtObjPair);
0106   m_pairConvertPhiFirstGtObject.push_back(false);
0107   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0108   m_pairPhiConvVec.push_back(&m_lutPhiMuToJetEg);
0109 
0110   //
0111   gtObjPair = std::make_pair(Mu, IsoEG);
0112   m_gtObjectPairVec.push_back(gtObjPair);
0113   m_pairConvertPhiFirstGtObject.push_back(true);
0114   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0115   m_pairPhiConvVec.push_back(&m_lutPhiMuToJetEg);
0116 
0117   gtObjPair = std::make_pair(IsoEG, Mu);
0118   m_gtObjectPairVec.push_back(gtObjPair);
0119   m_pairConvertPhiFirstGtObject.push_back(false);
0120   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0121   m_pairPhiConvVec.push_back(&m_lutPhiMuToJetEg);
0122 
0123   //
0124   gtObjPair = std::make_pair(Mu, ETM);
0125   m_gtObjectPairVec.push_back(gtObjPair);
0126   m_pairConvertPhiFirstGtObject.push_back(true);
0127   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiEtm);
0128   m_pairPhiConvVec.push_back(&m_lutPhiMuToEtm);
0129 
0130   gtObjPair = std::make_pair(ETM, Mu);
0131   m_gtObjectPairVec.push_back(gtObjPair);
0132   m_pairConvertPhiFirstGtObject.push_back(false);
0133   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiEtm);
0134   m_pairPhiConvVec.push_back(&m_lutPhiMuToEtm);
0135 
0136   //
0137   gtObjPair = std::make_pair(Mu, HTM);
0138   m_gtObjectPairVec.push_back(gtObjPair);
0139   m_pairConvertPhiFirstGtObject.push_back(true);
0140   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiHtm);
0141   m_pairPhiConvVec.push_back(&m_lutPhiMuToHtm);
0142 
0143   gtObjPair = std::make_pair(HTM, Mu);
0144   m_gtObjectPairVec.push_back(gtObjPair);
0145   m_pairConvertPhiFirstGtObject.push_back(false);
0146   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiHtm);
0147   m_pairPhiConvVec.push_back(&m_lutPhiMuToHtm);
0148 
0149   // ETM -> Jet & EG
0150   //
0151   gtObjPair = std::make_pair(ETM, CenJet);
0152   m_gtObjectPairVec.push_back(gtObjPair);
0153   m_pairConvertPhiFirstGtObject.push_back(true);
0154   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0155   m_pairPhiConvVec.push_back(&m_lutPhiEtmToJetEg);
0156 
0157   gtObjPair = std::make_pair(CenJet, ETM);
0158   m_gtObjectPairVec.push_back(gtObjPair);
0159   m_pairConvertPhiFirstGtObject.push_back(false);
0160   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0161   m_pairPhiConvVec.push_back(&m_lutPhiEtmToJetEg);
0162 
0163   //
0164   gtObjPair = std::make_pair(ETM, ForJet);
0165   m_gtObjectPairVec.push_back(gtObjPair);
0166   m_pairConvertPhiFirstGtObject.push_back(true);
0167   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0168   m_pairPhiConvVec.push_back(&m_lutPhiEtmToJetEg);
0169 
0170   gtObjPair = std::make_pair(ForJet, ETM);
0171   m_gtObjectPairVec.push_back(gtObjPair);
0172   m_pairConvertPhiFirstGtObject.push_back(false);
0173   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0174   m_pairPhiConvVec.push_back(&m_lutPhiEtmToJetEg);
0175 
0176   //
0177   gtObjPair = std::make_pair(ETM, TauJet);
0178   m_gtObjectPairVec.push_back(gtObjPair);
0179   m_pairConvertPhiFirstGtObject.push_back(true);
0180   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0181   m_pairPhiConvVec.push_back(&m_lutPhiEtmToJetEg);
0182 
0183   gtObjPair = std::make_pair(TauJet, ETM);
0184   m_gtObjectPairVec.push_back(gtObjPair);
0185   m_pairConvertPhiFirstGtObject.push_back(false);
0186   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0187   m_pairPhiConvVec.push_back(&m_lutPhiEtmToJetEg);
0188 
0189   //
0190   gtObjPair = std::make_pair(ETM, NoIsoEG);
0191   m_gtObjectPairVec.push_back(gtObjPair);
0192   m_pairConvertPhiFirstGtObject.push_back(true);
0193   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0194   m_pairPhiConvVec.push_back(&m_lutPhiEtmToJetEg);
0195 
0196   gtObjPair = std::make_pair(NoIsoEG, ETM);
0197   m_gtObjectPairVec.push_back(gtObjPair);
0198   m_pairConvertPhiFirstGtObject.push_back(false);
0199   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0200   m_pairPhiConvVec.push_back(&m_lutPhiEtmToJetEg);
0201 
0202   //
0203   gtObjPair = std::make_pair(ETM, IsoEG);
0204   m_gtObjectPairVec.push_back(gtObjPair);
0205   m_pairConvertPhiFirstGtObject.push_back(true);
0206   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0207   m_pairPhiConvVec.push_back(&m_lutPhiEtmToJetEg);
0208 
0209   gtObjPair = std::make_pair(IsoEG, ETM);
0210   m_gtObjectPairVec.push_back(gtObjPair);
0211   m_pairConvertPhiFirstGtObject.push_back(false);
0212   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0213   m_pairPhiConvVec.push_back(&m_lutPhiEtmToJetEg);
0214 
0215   // HTM -> Jet & EG
0216   //
0217   gtObjPair = std::make_pair(HTM, CenJet);
0218   m_gtObjectPairVec.push_back(gtObjPair);
0219   m_pairConvertPhiFirstGtObject.push_back(true);
0220   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0221   m_pairPhiConvVec.push_back(&m_lutPhiHtmToJetEg);
0222 
0223   gtObjPair = std::make_pair(CenJet, HTM);
0224   m_gtObjectPairVec.push_back(gtObjPair);
0225   m_pairConvertPhiFirstGtObject.push_back(false);
0226   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0227   m_pairPhiConvVec.push_back(&m_lutPhiHtmToJetEg);
0228 
0229   //
0230   gtObjPair = std::make_pair(HTM, ForJet);
0231   m_gtObjectPairVec.push_back(gtObjPair);
0232   m_pairConvertPhiFirstGtObject.push_back(true);
0233   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0234   m_pairPhiConvVec.push_back(&m_lutPhiHtmToJetEg);
0235 
0236   gtObjPair = std::make_pair(ForJet, HTM);
0237   m_gtObjectPairVec.push_back(gtObjPair);
0238   m_pairConvertPhiFirstGtObject.push_back(false);
0239   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0240   m_pairPhiConvVec.push_back(&m_lutPhiHtmToJetEg);
0241 
0242   //
0243   gtObjPair = std::make_pair(HTM, TauJet);
0244   m_gtObjectPairVec.push_back(gtObjPair);
0245   m_pairConvertPhiFirstGtObject.push_back(true);
0246   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0247   m_pairPhiConvVec.push_back(&m_lutPhiHtmToJetEg);
0248 
0249   gtObjPair = std::make_pair(TauJet, HTM);
0250   m_gtObjectPairVec.push_back(gtObjPair);
0251   m_pairConvertPhiFirstGtObject.push_back(false);
0252   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0253   m_pairPhiConvVec.push_back(&m_lutPhiHtmToJetEg);
0254 
0255   //
0256   gtObjPair = std::make_pair(HTM, NoIsoEG);
0257   m_gtObjectPairVec.push_back(gtObjPair);
0258   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0259   m_pairConvertPhiFirstGtObject.push_back(true);
0260   m_pairPhiConvVec.push_back(&m_lutPhiHtmToJetEg);
0261 
0262   gtObjPair = std::make_pair(NoIsoEG, HTM);
0263   m_gtObjectPairVec.push_back(gtObjPair);
0264   m_pairConvertPhiFirstGtObject.push_back(false);
0265   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0266   m_pairPhiConvVec.push_back(&m_lutPhiHtmToJetEg);
0267 
0268   //
0269   gtObjPair = std::make_pair(HTM, IsoEG);
0270   m_gtObjectPairVec.push_back(gtObjPair);
0271   m_pairConvertPhiFirstGtObject.push_back(true);
0272   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0273   m_pairPhiConvVec.push_back(&m_lutPhiHtmToJetEg);
0274 
0275   gtObjPair = std::make_pair(IsoEG, HTM);
0276   m_gtObjectPairVec.push_back(gtObjPair);
0277   m_pairConvertPhiFirstGtObject.push_back(false);
0278   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0279   m_pairPhiConvVec.push_back(&m_lutPhiHtmToJetEg);
0280 
0281   // ETM -> HTM
0282   //
0283   gtObjPair = std::make_pair(ETM, HTM);
0284   m_gtObjectPairVec.push_back(gtObjPair);
0285   m_pairConvertPhiFirstGtObject.push_back(true);
0286   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiHtm);
0287   m_pairPhiConvVec.push_back(&m_lutPhiEtmToHtm);
0288 
0289   gtObjPair = std::make_pair(HTM, ETM);
0290   m_gtObjectPairVec.push_back(gtObjPair);
0291   m_pairConvertPhiFirstGtObject.push_back(false);
0292   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiHtm);
0293   m_pairPhiConvVec.push_back(&m_lutPhiEtmToHtm);
0294 
0295   // Jet & EG -> Jet & EG
0296   //
0297   gtObjPair = std::make_pair(CenJet, ForJet);
0298   m_gtObjectPairVec.push_back(gtObjPair);
0299   m_pairConvertPhiFirstGtObject.push_back(true);
0300   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0301   m_pairPhiConvVec.push_back(&m_lutPhiJetEgToJetEg);
0302 
0303   gtObjPair = std::make_pair(ForJet, CenJet);
0304   m_gtObjectPairVec.push_back(gtObjPair);
0305   m_pairConvertPhiFirstGtObject.push_back(false);
0306   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0307   m_pairPhiConvVec.push_back(&m_lutPhiJetEgToJetEg);
0308 
0309   //
0310   gtObjPair = std::make_pair(CenJet, TauJet);
0311   m_gtObjectPairVec.push_back(gtObjPair);
0312   m_pairConvertPhiFirstGtObject.push_back(true);
0313   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0314   m_pairPhiConvVec.push_back(&m_lutPhiJetEgToJetEg);
0315 
0316   gtObjPair = std::make_pair(TauJet, CenJet);
0317   m_gtObjectPairVec.push_back(gtObjPair);
0318   m_pairConvertPhiFirstGtObject.push_back(false);
0319   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0320   m_pairPhiConvVec.push_back(&m_lutPhiJetEgToJetEg);
0321 
0322   //
0323   gtObjPair = std::make_pair(CenJet, NoIsoEG);
0324   m_gtObjectPairVec.push_back(gtObjPair);
0325   m_pairConvertPhiFirstGtObject.push_back(true);
0326   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0327   m_pairPhiConvVec.push_back(&m_lutPhiJetEgToJetEg);
0328 
0329   gtObjPair = std::make_pair(NoIsoEG, CenJet);
0330   m_gtObjectPairVec.push_back(gtObjPair);
0331   m_pairConvertPhiFirstGtObject.push_back(false);
0332   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0333   m_pairPhiConvVec.push_back(&m_lutPhiJetEgToJetEg);
0334 
0335   //
0336   gtObjPair = std::make_pair(CenJet, IsoEG);
0337   m_gtObjectPairVec.push_back(gtObjPair);
0338   m_pairConvertPhiFirstGtObject.push_back(true);
0339   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0340   m_pairPhiConvVec.push_back(&m_lutPhiJetEgToJetEg);
0341 
0342   gtObjPair = std::make_pair(IsoEG, CenJet);
0343   m_gtObjectPairVec.push_back(gtObjPair);
0344   m_pairConvertPhiFirstGtObject.push_back(false);
0345   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0346   m_pairPhiConvVec.push_back(&m_lutPhiJetEgToJetEg);
0347 
0348   //
0349   gtObjPair = std::make_pair(ForJet, TauJet);
0350   m_gtObjectPairVec.push_back(gtObjPair);
0351   m_pairConvertPhiFirstGtObject.push_back(true);
0352   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0353   m_pairPhiConvVec.push_back(&m_lutPhiJetEgToJetEg);
0354 
0355   gtObjPair = std::make_pair(TauJet, ForJet);
0356   m_gtObjectPairVec.push_back(gtObjPair);
0357   m_pairConvertPhiFirstGtObject.push_back(false);
0358   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0359   m_pairPhiConvVec.push_back(&m_lutPhiJetEgToJetEg);
0360 
0361   //
0362   gtObjPair = std::make_pair(ForJet, NoIsoEG);
0363   m_gtObjectPairVec.push_back(gtObjPair);
0364   m_pairConvertPhiFirstGtObject.push_back(true);
0365   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0366   m_pairPhiConvVec.push_back(&m_lutPhiJetEgToJetEg);
0367 
0368   gtObjPair = std::make_pair(NoIsoEG, ForJet);
0369   m_gtObjectPairVec.push_back(gtObjPair);
0370   m_pairConvertPhiFirstGtObject.push_back(false);
0371   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0372   m_pairPhiConvVec.push_back(&m_lutPhiJetEgToJetEg);
0373 
0374   //
0375   gtObjPair = std::make_pair(ForJet, IsoEG);
0376   m_gtObjectPairVec.push_back(gtObjPair);
0377   m_pairConvertPhiFirstGtObject.push_back(true);
0378   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0379   m_pairPhiConvVec.push_back(&m_lutPhiJetEgToJetEg);
0380 
0381   gtObjPair = std::make_pair(IsoEG, ForJet);
0382   m_gtObjectPairVec.push_back(gtObjPair);
0383   m_pairConvertPhiFirstGtObject.push_back(false);
0384   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0385   m_pairPhiConvVec.push_back(&m_lutPhiJetEgToJetEg);
0386 
0387   //
0388   gtObjPair = std::make_pair(TauJet, NoIsoEG);
0389   m_gtObjectPairVec.push_back(gtObjPair);
0390   m_pairConvertPhiFirstGtObject.push_back(true);
0391   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0392   m_pairPhiConvVec.push_back(&m_lutPhiJetEgToJetEg);
0393 
0394   gtObjPair = std::make_pair(NoIsoEG, TauJet);
0395   m_gtObjectPairVec.push_back(gtObjPair);
0396   m_pairConvertPhiFirstGtObject.push_back(false);
0397   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0398   m_pairPhiConvVec.push_back(&m_lutPhiJetEgToJetEg);
0399 
0400   //
0401   gtObjPair = std::make_pair(TauJet, IsoEG);
0402   m_gtObjectPairVec.push_back(gtObjPair);
0403   m_pairConvertPhiFirstGtObject.push_back(true);
0404   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0405   m_pairPhiConvVec.push_back(&m_lutPhiJetEgToJetEg);
0406 
0407   gtObjPair = std::make_pair(IsoEG, TauJet);
0408   m_gtObjectPairVec.push_back(gtObjPair);
0409   m_pairConvertPhiFirstGtObject.push_back(false);
0410   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0411   m_pairPhiConvVec.push_back(&m_lutPhiJetEgToJetEg);
0412 
0413   //
0414   gtObjPair = std::make_pair(NoIsoEG, IsoEG);
0415   m_gtObjectPairVec.push_back(gtObjPair);
0416   m_pairConvertPhiFirstGtObject.push_back(true);
0417   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0418   m_pairPhiConvVec.push_back(&m_lutPhiJetEgToJetEg);
0419 
0420   gtObjPair = std::make_pair(IsoEG, NoIsoEG);
0421   m_gtObjectPairVec.push_back(gtObjPair);
0422   m_pairConvertPhiFirstGtObject.push_back(false);
0423   m_pairNrPhiBinsVec.push_back(&m_nrBinsPhiJetEg);
0424   m_pairPhiConvVec.push_back(&m_lutPhiJetEgToJetEg);
0425 
0426   // m_verbosity can not be used here, as L1GtEtaPhiConversions is called
0427   // in L1GlobalTriggerGTL constructor,  where m_verbosity is not yet set
0428   if (m_isDebugEnabled) {
0429     LogTrace("L1GlobalTrigger") << "\nm_gtObjectPairVec size: " << (m_gtObjectPairVec.size()) << std::endl;
0430 
0431     unsigned int iPair = 0;
0432 
0433     for (std::vector<std::pair<L1GtObject, L1GtObject>>::const_iterator cIter = m_gtObjectPairVec.begin();
0434          cIter != m_gtObjectPairVec.end();
0435          ++cIter) {
0436       LogTrace("L1GlobalTrigger") << "m_gtObjectPairVec vector element [" << l1GtObjectEnumToString((*cIter).first)
0437                                   << ", " << l1GtObjectEnumToString((*cIter).second) << "], \t\tpair index =  " << iPair
0438                                   << std::endl;
0439 
0440       iPair++;
0441     }
0442   }
0443 }
0444 
0445 // destructor
0446 L1GtEtaPhiConversions::~L1GtEtaPhiConversions() {
0447   // do nothing
0448 }
0449 
0450 // methods
0451 
0452 const unsigned int L1GtEtaPhiConversions::gtObjectPairIndex(const L1GtObject &obj0, const L1GtObject &obj1) const {
0453   std::pair<L1GtObject, L1GtObject> gtObjPair;
0454   gtObjPair = std::make_pair(obj0, obj1);
0455 
0456   // LogTrace("L1GlobalTrigger") << "\nCompute index for pair ["
0457   //        << (l1GtObjectEnumToString(obj0)) << ", "
0458   //        << (l1GtObjectEnumToString(obj1)) << "]\n" << std::endl;
0459 
0460   unsigned int iPair = 0;
0461   for (std::vector<std::pair<L1GtObject, L1GtObject>>::const_iterator cIter = m_gtObjectPairVec.begin();
0462        cIter != m_gtObjectPairVec.end();
0463        ++cIter) {
0464     if (*cIter == gtObjPair) {
0465       LogTrace("L1GlobalTrigger") << "\n  Index for pair [" << l1GtObjectEnumToString(obj0) << ", "
0466                                   << l1GtObjectEnumToString(obj1) << "] = " << iPair << std::endl;
0467 
0468       return iPair;
0469     }
0470 
0471     iPair++;
0472   }
0473 
0474   // if the pair was not found, return index outside vector size
0475   // it should never happen, except due to programming error
0476   // by using .at one gets an exception when using index outside vector size,
0477   // due to the programming error...
0478   return m_gtObjectPairVec.size();
0479 }
0480 
0481 const bool L1GtEtaPhiConversions::convertPhiIndex(const unsigned int pairIndex,
0482                                                   const unsigned int positionPair,
0483                                                   const unsigned int initialIndex,
0484                                                   unsigned int &convertedIndex) const {
0485   unsigned int newIndex = badIndex;
0486   bool conversionStatus = false;
0487 
0488   // check if initial index is within the scale size
0489   // could be outside the scale size if there are hardware errors
0490   // or wrong scale conversions
0491   if (initialIndex >= (*(m_pairPhiConvVec.at(pairIndex))).size()) {
0492     conversionStatus = false;
0493 
0494     if (m_verbosity && m_isDebugEnabled) {
0495       LogTrace("L1GlobalTrigger") << (positionPair ? "    Second" : "\n  First") << " object from pair " << pairIndex
0496                                   << ": initial phi index " << initialIndex
0497                                   << " >= " << ((*(m_pairPhiConvVec.at(pairIndex))).size()) << " Conversion failed."
0498                                   << std::endl;
0499     }
0500   } else {
0501     if (m_verbosity && m_isDebugEnabled) {
0502       LogTrace("L1GlobalTrigger") << (positionPair ? "    Second" : "\n  First") << " object from pair " << pairIndex
0503                                   << ": initial phi index " << initialIndex << " within scale size "
0504                                   << ((*(m_pairPhiConvVec.at(pairIndex))).size()) << std::endl;
0505     }
0506   }
0507 
0508   // convert the index
0509   switch (positionPair) {
0510     case 0: {
0511       if (m_pairConvertPhiFirstGtObject.at(pairIndex)) {
0512         newIndex = (*(m_pairPhiConvVec.at(pairIndex))).at(initialIndex);
0513 
0514         if (newIndex != badIndex) {
0515           conversionStatus = true;
0516 
0517           if (m_verbosity && m_isDebugEnabled) {
0518             LogTrace("L1GlobalTrigger") << (positionPair ? "    Second" : "\n  First") << " object from pair "
0519                                         << pairIndex << ": initial phi index " << initialIndex << " converted to "
0520                                         << newIndex << std::endl;
0521           }
0522 
0523         } else {
0524           conversionStatus = false;
0525 
0526           if (m_verbosity && m_isDebugEnabled) {
0527             LogTrace("L1GlobalTrigger") << (positionPair ? "    Second" : "\n  First") << " object from pair "
0528                                         << pairIndex << ": converted phi index " << newIndex << "is equal to badIndex "
0529                                         << badIndex << " Conversion failed." << std::endl;
0530           }
0531         }
0532 
0533       } else {
0534         newIndex = initialIndex;
0535         conversionStatus = true;
0536 
0537         if (m_verbosity && m_isDebugEnabled) {
0538           LogTrace("L1GlobalTrigger") << (positionPair ? "    Second" : "\n  First") << " object from pair "
0539                                       << pairIndex << ": initial phi index " << initialIndex
0540                                       << " not requested to be converted, return index " << newIndex << std::endl;
0541         }
0542       }
0543     }
0544 
0545     break;
0546     case 1: {
0547       if (m_pairConvertPhiFirstGtObject.at(pairIndex)) {
0548         newIndex = initialIndex;
0549         conversionStatus = true;
0550 
0551         if (m_verbosity && m_isDebugEnabled) {
0552           LogTrace("L1GlobalTrigger") << (positionPair ? "    Second" : "\n  First") << " object from pair "
0553                                       << pairIndex << ": initial phi index " << initialIndex
0554                                       << " not requested to be converted, return index, return index " << newIndex
0555                                       << std::endl;
0556         }
0557       } else {
0558         newIndex = (*(m_pairPhiConvVec.at(pairIndex))).at(initialIndex);
0559 
0560         if (newIndex != badIndex) {
0561           conversionStatus = true;
0562 
0563           if (m_verbosity && m_isDebugEnabled) {
0564             LogTrace("L1GlobalTrigger") << (positionPair ? "    Second" : "\n  First") << " object from pair "
0565                                         << pairIndex << ": initial phi index " << initialIndex << " converted to "
0566                                         << newIndex << std::endl;
0567           }
0568 
0569         } else {
0570           conversionStatus = false;
0571 
0572           if (m_verbosity && m_isDebugEnabled) {
0573             LogTrace("L1GlobalTrigger") << (positionPair ? "    Second" : "\n  First") << " object from pair "
0574                                         << pairIndex << ": converted phi index " << newIndex << "is equal to badIndex "
0575                                         << badIndex << " Conversion failed." << std::endl;
0576           }
0577         }
0578       }
0579 
0580     }
0581 
0582     break;
0583     default: {
0584       // should not happen (programming error)
0585       throw cms::Exception("FailModule") << "\n  Wrong position in the object pair " << positionPair
0586                                          << "\n  Programming error - position must be either 0 or 1..." << std::endl;
0587 
0588     } break;
0589   }
0590 
0591   //
0592   convertedIndex = newIndex;
0593   return conversionStatus;
0594 }
0595 
0596 const bool L1GtEtaPhiConversions::convertEtaIndex(const L1GtObject &gtObject,
0597                                                   const unsigned int initialIndex,
0598                                                   unsigned int &convertedIndex) const {
0599   unsigned int newIndex = badIndex;
0600   bool conversionStatus = false;
0601 
0602   switch (gtObject) {
0603     case Mu: {
0604       // check if initial index is within the scale size
0605       // could be outside the scale size if there are hardware errors
0606       // or wrong scale conversions
0607       if (initialIndex >= m_lutEtaMuToCommonCalo.size()) {
0608         conversionStatus = false;
0609 
0610         if (m_verbosity && m_isDebugEnabled) {
0611           LogTrace("L1GlobalTrigger") << "    L1 GT object " << (l1GtObjectEnumToString(gtObject))
0612                                       << " has initial eta index " << initialIndex
0613                                       << " >= " << (m_lutEtaMuToCommonCalo.size()) << " scale size. Conversion failed."
0614                                       << std::endl;
0615         }
0616       } else {
0617         // convert the index
0618         newIndex = m_lutEtaMuToCommonCalo[initialIndex];
0619 
0620         if (newIndex != badIndex) {
0621           conversionStatus = true;
0622 
0623           if (m_verbosity && m_isDebugEnabled) {
0624             LogTrace("L1GlobalTrigger") << "    L1 GT object " << (l1GtObjectEnumToString(gtObject))
0625                                         << " initial eta index " << initialIndex << " (within scale size "
0626                                         << (m_lutEtaMuToCommonCalo.size()) << ") converted to " << newIndex
0627                                         << std::endl;
0628           }
0629 
0630         } else {
0631           conversionStatus = false;
0632 
0633           if (m_verbosity && m_isDebugEnabled) {
0634             LogTrace("L1GlobalTrigger") << "    L1 GT object " << (l1GtObjectEnumToString(gtObject))
0635                                         << " initial eta index " << initialIndex << " (within scale size "
0636                                         << (m_lutEtaMuToCommonCalo.size()) << ") converted to badIndex" << newIndex
0637                                         << " Conversion failed." << std::endl;
0638           }
0639         }
0640       }
0641 
0642     } break;
0643 
0644     case NoIsoEG:
0645     case IsoEG:
0646     case CenJet:
0647     case TauJet: {
0648       // check if initial index is within the scale size
0649       // could be outside the scale size if there are hardware errors
0650       // or wrong scale conversions
0651       if (initialIndex >= m_lutEtaCentralToCommonCalo.size()) {
0652         conversionStatus = false;
0653 
0654         if (m_verbosity && m_isDebugEnabled) {
0655           LogTrace("L1GlobalTrigger") << "    L1 GT object " << (l1GtObjectEnumToString(gtObject))
0656                                       << " has initial eta index " << initialIndex
0657                                       << " >= " << (m_lutEtaCentralToCommonCalo.size())
0658                                       << " scale size. Conversion failed." << std::endl;
0659         }
0660       } else {
0661         // convert the index
0662         newIndex = m_lutEtaCentralToCommonCalo[initialIndex];
0663 
0664         if (newIndex != badIndex) {
0665           conversionStatus = true;
0666 
0667           if (m_verbosity && m_isDebugEnabled) {
0668             LogTrace("L1GlobalTrigger") << "    L1 GT object " << (l1GtObjectEnumToString(gtObject))
0669                                         << " initial eta index " << initialIndex << " (within scale size "
0670                                         << (m_lutEtaMuToCommonCalo.size()) << ") converted to " << newIndex
0671                                         << std::endl;
0672           }
0673 
0674         } else {
0675           conversionStatus = false;
0676 
0677           if (m_verbosity && m_isDebugEnabled) {
0678             LogTrace("L1GlobalTrigger") << "    L1 GT object " << (l1GtObjectEnumToString(gtObject))
0679                                         << " initial eta index " << initialIndex << " (within scale size "
0680                                         << (m_lutEtaCentralToCommonCalo.size()) << ") converted to badIndex" << newIndex
0681                                         << " Conversion failed." << std::endl;
0682           }
0683         }
0684       }
0685 
0686     } break;
0687 
0688     case ForJet: {
0689       // check if initial index is within the scale size
0690       // could be outside the scale size if there are hardware errors
0691       // or wrong scale conversions
0692       if (initialIndex >= m_lutEtaForJetToCommonCalo.size()) {
0693         conversionStatus = false;
0694 
0695         if (m_verbosity && m_isDebugEnabled) {
0696           LogTrace("L1GlobalTrigger") << "    L1 GT object " << (l1GtObjectEnumToString(gtObject))
0697                                       << " has initial eta index " << initialIndex
0698                                       << " >= " << (m_lutEtaForJetToCommonCalo.size())
0699                                       << " scale size. Conversion failed." << std::endl;
0700         }
0701       } else {
0702         // convert the index
0703         newIndex = m_lutEtaForJetToCommonCalo[initialIndex];
0704 
0705         if (newIndex != badIndex) {
0706           conversionStatus = true;
0707 
0708           if (m_verbosity && m_isDebugEnabled) {
0709             LogTrace("L1GlobalTrigger") << "    L1 GT object " << (l1GtObjectEnumToString(gtObject))
0710                                         << " initial eta index " << initialIndex << " (within scale size "
0711                                         << (m_lutEtaMuToCommonCalo.size()) << ") converted to " << newIndex
0712                                         << std::endl;
0713           }
0714 
0715         } else {
0716           conversionStatus = false;
0717 
0718           if (m_verbosity && m_isDebugEnabled) {
0719             LogTrace("L1GlobalTrigger") << "    L1 GT object " << (l1GtObjectEnumToString(gtObject))
0720                                         << " initial eta index " << initialIndex << " (within scale size "
0721                                         << (m_lutEtaForJetToCommonCalo.size()) << ") converted to badIndex" << newIndex
0722                                         << " Conversion failed." << std::endl;
0723           }
0724         }
0725       }
0726     } break;
0727 
0728     case ETM:
0729     case ETT:
0730     case HTT:
0731     case HTM:
0732     case JetCounts:
0733     case HfBitCounts:
0734     case HfRingEtSums:
0735     case TechTrig:
0736     case Castor:
0737     case BPTX:
0738     case GtExternal:
0739     case ObjNull: {
0740       // no conversions needed, there is no eta quantity for these objects
0741       conversionStatus = false;
0742     } break;
0743 
0744     default: {
0745       edm::LogInfo("L1GtObject") << "\n  '" << (l1GtObjectEnumToString(gtObject))
0746                                  << "' is not a recognized L1GtObject. "
0747                                  << "\n Conversion failed. " << std::endl;
0748       conversionStatus = false;
0749     } break;
0750   }
0751 
0752   //
0753   convertedIndex = newIndex;
0754 
0755   return conversionStatus;
0756 }
0757 
0758 const unsigned int L1GtEtaPhiConversions::gtObjectNrBinsPhi(const L1GtObject &gtObject) const {
0759   switch (gtObject) {
0760     case Mu: {
0761       return m_nrBinsPhiMu;
0762     } break;
0763 
0764     case NoIsoEG:
0765     case IsoEG:
0766     case CenJet:
0767     case ForJet:
0768     case TauJet: {
0769       return m_nrBinsPhiJetEg;
0770     } break;
0771 
0772     case ETM: {
0773       return m_nrBinsPhiEtm;
0774     } break;
0775 
0776     case ETT:
0777     case HTT: {
0778       return 0;
0779     } break;
0780 
0781     case HTM: {
0782       return m_nrBinsPhiHtm;
0783     } break;
0784 
0785     case JetCounts:
0786     case HfBitCounts:
0787     case HfRingEtSums:
0788     case TechTrig:
0789     case Castor:
0790     case BPTX:
0791     case GtExternal:
0792     case ObjNull: {
0793       return 0;
0794     } break;
0795 
0796     default: {
0797       edm::LogInfo("L1GtObject") << "\n  '" << (l1GtObjectEnumToString(gtObject))
0798                                  << "' is not a recognized L1GtObject. "
0799                                  << "\n Return 0 bins.";
0800       return 0;
0801     } break;
0802   }
0803 }
0804 
0805 const unsigned int L1GtEtaPhiConversions::gtObjectNrBinsPhi(const L1GtObject &obj0, const L1GtObject &obj1) const {
0806   std::pair<L1GtObject, L1GtObject> gtObjPair;
0807   gtObjPair = std::make_pair(obj0, obj1);
0808 
0809   // LogTrace("L1GlobalTrigger") << "\nCompute gtObjectNrBinsPhi ["
0810   //        << (l1GtObjectEnumToString(obj0)) << ", "
0811   //        << (l1GtObjectEnumToString(obj1)) << "]\n" << std::endl;
0812 
0813   int iPair = 0;
0814   for (std::vector<std::pair<L1GtObject, L1GtObject>>::const_iterator cIter = m_gtObjectPairVec.begin();
0815        cIter != m_gtObjectPairVec.end();
0816        ++cIter) {
0817     if (*cIter == gtObjPair) {
0818       LogTrace("L1GlobalTrigger") << "\n  gtObjectNrBinsPhi [" << l1GtObjectEnumToString(obj0) << ", "
0819                                   << l1GtObjectEnumToString(obj1) << "] = " << (*(m_pairNrPhiBinsVec.at(iPair)))
0820                                   << std::endl;
0821 
0822       return *(m_pairNrPhiBinsVec.at(iPair));
0823     }
0824 
0825     iPair++;
0826   }
0827 
0828   return 0;
0829 }
0830 
0831 const unsigned int L1GtEtaPhiConversions::gtObjectNrBinsPhi(const unsigned int pairIndex) const {
0832   if (m_verbosity && m_isDebugEnabled) {
0833     LogTrace("L1GlobalTrigger") << "\n  gtObjectNrBinsPhi for L1 GT object pair index " << pairIndex << " = "
0834                                 << (*(m_pairNrPhiBinsVec.at(pairIndex))) << std::endl;
0835   }
0836 
0837   return *(m_pairNrPhiBinsVec.at(pairIndex));
0838 }
0839 
0840 // perform all conversions
0841 void L1GtEtaPhiConversions::convertL1Scales(const L1CaloGeometry *l1CaloGeometry,
0842                                             const L1MuTriggerScales *l1MuTriggerScales,
0843                                             const int ifCaloEtaNumberBits,
0844                                             const int ifMuEtaNumberBits) {
0845   // no bullet-proof method, depends on binning ...
0846   // decide "by hand / by eyes" which object converts to which object
0847 
0848   // update the scales used
0849   m_l1CaloGeometry = l1CaloGeometry;
0850   m_l1MuTriggerScales = l1MuTriggerScales;
0851 
0852   // number of bins for all phi scales used
0853 
0854   m_nrBinsPhiMu = 144;  // FIXME ask Ivan for size() ...
0855   // m_nrBinsPhiMu = m_l1MuTriggerScales->getPhiScale()->size();
0856 
0857   m_nrBinsPhiJetEg = m_l1CaloGeometry->numberGctEmJetPhiBins();
0858   m_nrBinsPhiEtm = m_l1CaloGeometry->numberGctEtSumPhiBins();
0859   m_nrBinsPhiHtm = m_l1CaloGeometry->numberGctHtSumPhiBins();
0860 
0861   //
0862   // convert phi scale for muon (finer) to phi scale for (*Jet, EG) / ETM / HTM
0863   // (coarser)
0864   //
0865 
0866   m_lutPhiMuToJetEg.clear();
0867   m_lutPhiMuToJetEg.resize(m_nrBinsPhiMu, badIndex);
0868 
0869   m_lutPhiMuToEtm.clear();
0870   m_lutPhiMuToEtm.resize(m_nrBinsPhiMu, badIndex);
0871 
0872   m_lutPhiMuToHtm.clear();
0873   m_lutPhiMuToHtm.resize(m_nrBinsPhiMu, badIndex);
0874 
0875   for (unsigned int phiMuInd = 0; phiMuInd < m_nrBinsPhiMu; ++phiMuInd) {
0876     double phiMuLowEdge = m_l1MuTriggerScales->getPhiScale()->getLowEdge(phiMuInd);
0877     double phiMuHighEdge = m_l1MuTriggerScales->getPhiScale()->getHighEdge(phiMuInd);
0878 
0879     // to avoid precision problems, add a small quantity to phiMuLowEdge
0880     double phiMuLowEdgeSmallShiftRight = phiMuLowEdge + (phiMuHighEdge - phiMuLowEdge) / 100.;
0881 
0882     // phi Mu -> (*Jet, EG)
0883 
0884     unsigned int nrBins = m_nrBinsPhiJetEg;
0885 
0886     for (unsigned int iBin = nrBins;; --iBin) {
0887       double phiLowEdge = m_l1CaloGeometry->emJetPhiBinLowEdge(iBin);
0888       double phiHighEdge = m_l1CaloGeometry->emJetPhiBinHighEdge(iBin);
0889 
0890       if (phiMuLowEdgeSmallShiftRight >= phiLowEdge) {
0891         m_lutPhiMuToJetEg[phiMuInd] = iBin % nrBins;
0892 
0893         LogTrace("L1GlobalTrigger") << " phiMuIndex \t" << phiMuInd << " [ " << phiMuLowEdge << " \t, " << phiMuHighEdge
0894                                     << "] \t==>\t phiMuJetEG \t" << m_lutPhiMuToJetEg[phiMuInd] << " [ " << phiLowEdge
0895                                     << "\t, " << phiHighEdge << " ]" << std::endl;
0896 
0897         break;
0898       }
0899     }
0900 
0901     // phi Mu -> ETM
0902 
0903     nrBins = m_nrBinsPhiEtm;
0904 
0905     for (unsigned int iBin = nrBins;; --iBin) {
0906       double phiLowEdge = m_l1CaloGeometry->etSumPhiBinLowEdge(iBin);
0907       double phiHighEdge = m_l1CaloGeometry->etSumPhiBinHighEdge(iBin);
0908 
0909       if (phiMuLowEdgeSmallShiftRight >= phiLowEdge) {
0910         m_lutPhiMuToEtm[phiMuInd] = iBin % nrBins;
0911 
0912         LogTrace("L1GlobalTrigger") << " phiMuIndex \t" << phiMuInd << " [ " << phiMuLowEdge << " \t, " << phiMuHighEdge
0913                                     << "] \t==>\t phiMuToEtm \t" << m_lutPhiMuToEtm[phiMuInd] << " [ " << phiLowEdge
0914                                     << "\t, " << phiHighEdge << " ]" << std::endl;
0915 
0916         break;
0917       }
0918     }
0919 
0920     // phi Mu -> HTM
0921 
0922     nrBins = m_nrBinsPhiHtm;
0923 
0924     for (unsigned int iBin = nrBins;; --iBin) {
0925       double phiLowEdge = m_l1CaloGeometry->htSumPhiBinLowEdge(iBin);
0926       double phiHighEdge = m_l1CaloGeometry->htSumPhiBinHighEdge(iBin);
0927 
0928       if (phiMuLowEdgeSmallShiftRight >= phiLowEdge) {
0929         m_lutPhiMuToHtm[phiMuInd] = iBin % nrBins;
0930 
0931         LogTrace("L1GlobalTrigger") << " phiMuIndex \t" << phiMuInd << " [ " << phiMuLowEdge << " \t, " << phiMuHighEdge
0932                                     << "] \t==>\t phiMuToHtm \t" << m_lutPhiMuToHtm[phiMuInd] << " [ " << phiLowEdge
0933                                     << "\t, " << phiHighEdge << " ]" << std::endl;
0934 
0935         break;
0936       }
0937     }
0938 
0939     LogTrace("L1GlobalTrigger") << std::endl;
0940   }
0941 
0942   if (m_verbosity && m_isDebugEnabled) {
0943     LogTrace("L1GlobalTrigger") << "Mu phi conversions" << std::endl;
0944     for (unsigned int iBin = 0; iBin < m_nrBinsPhiMu; ++iBin) {
0945       LogTrace("L1GlobalTrigger") << "  Mu phiIndex \t" << iBin << "\t converted to index:"
0946                                   << "\t Jet-EG \t" << m_lutPhiMuToJetEg.at(iBin) << "\t ETM \t"
0947                                   << m_lutPhiMuToEtm.at(iBin) << "\t HTM \t" << m_lutPhiMuToHtm.at(iBin) << std::endl;
0948     }
0949     LogTrace("L1GlobalTrigger") << std::endl;
0950   }
0951 
0952   //
0953   // convert phi scale for ETM to phi scale for (*Jet, EG) / HTM (coarser)
0954   //
0955 
0956   m_lutPhiEtmToJetEg.clear();
0957   m_lutPhiEtmToJetEg.resize(m_nrBinsPhiEtm, badIndex);
0958 
0959   m_lutPhiEtmToHtm.clear();
0960   m_lutPhiEtmToHtm.resize(m_nrBinsPhiEtm, badIndex);
0961 
0962   for (unsigned int phiEtmInd = 0; phiEtmInd < m_nrBinsPhiEtm; ++phiEtmInd) {
0963     double phiEtmLowEdge = m_l1CaloGeometry->etSumPhiBinLowEdge(phiEtmInd);
0964     double phiEtmHighEdge = m_l1CaloGeometry->etSumPhiBinHighEdge(phiEtmInd);
0965 
0966     // to avoid precision problems, add a small quantity to phiEtmLowEdge
0967     double phiEtmLowEdgeSmallShiftRight = phiEtmLowEdge + (phiEtmHighEdge - phiEtmLowEdge) / 100.;
0968 
0969     // phi ETM -> (*Jet, EG)
0970 
0971     unsigned int nrBins = m_nrBinsPhiJetEg;
0972 
0973     for (unsigned int iBin = nrBins;; --iBin) {
0974       double phiLowEdge = m_l1CaloGeometry->emJetPhiBinLowEdge(iBin);
0975       double phiHighEdge = m_l1CaloGeometry->emJetPhiBinHighEdge(iBin);
0976 
0977       if (phiEtmLowEdgeSmallShiftRight >= phiLowEdge) {
0978         m_lutPhiEtmToJetEg[phiEtmInd] = iBin % nrBins;
0979 
0980         LogTrace("L1GlobalTrigger") << " phiEtmIndex \t" << phiEtmInd << " [ " << phiEtmLowEdge << " \t, "
0981                                     << phiEtmHighEdge << "] \t==>\t phiEtmJetEG \t" << m_lutPhiEtmToJetEg[phiEtmInd]
0982                                     << " [ " << phiLowEdge << "\t, " << phiHighEdge << " ]" << std::endl;
0983 
0984         break;
0985       }
0986     }
0987 
0988     // phi ETM -> HTM
0989 
0990     nrBins = m_nrBinsPhiHtm;
0991 
0992     for (unsigned int iBin = nrBins;; --iBin) {
0993       double phiLowEdge = m_l1CaloGeometry->htSumPhiBinLowEdge(iBin);
0994       double phiHighEdge = m_l1CaloGeometry->htSumPhiBinHighEdge(iBin);
0995 
0996       if (phiEtmLowEdgeSmallShiftRight >= phiLowEdge) {
0997         m_lutPhiEtmToHtm[phiEtmInd] = iBin % nrBins;
0998 
0999         LogTrace("L1GlobalTrigger") << " phiEtmIndex \t" << phiEtmInd << " [ " << phiEtmLowEdge << " \t, "
1000                                     << phiEtmHighEdge << "] \t==>\t phiEtmToHtm \t" << m_lutPhiEtmToHtm[phiEtmInd]
1001                                     << " [ " << phiLowEdge << "\t, " << phiHighEdge << " ]" << std::endl;
1002 
1003         break;
1004       }
1005     }
1006 
1007     LogTrace("L1GlobalTrigger") << std::endl;
1008   }
1009 
1010   //
1011   // convert phi scale for HTM to phi scale for (*Jet, EG)
1012   //
1013 
1014   m_lutPhiHtmToJetEg.clear();
1015   m_lutPhiHtmToJetEg.resize(m_nrBinsPhiHtm, badIndex);
1016 
1017   for (unsigned int phiHtmInd = 0; phiHtmInd < m_nrBinsPhiHtm; ++phiHtmInd) {
1018     double phiHtmLowEdge = m_l1CaloGeometry->htSumPhiBinLowEdge(phiHtmInd);
1019     double phiHtmHighEdge = m_l1CaloGeometry->htSumPhiBinHighEdge(phiHtmInd);
1020 
1021     // to avoid precision problems, add a small quantity to phiHtmLowEdge
1022     double phiHtmLowEdgeSmallShiftRight = phiHtmLowEdge + (phiHtmHighEdge - phiHtmLowEdge) / 100.;
1023 
1024     unsigned int nrBins = m_nrBinsPhiJetEg;
1025 
1026     for (unsigned int iBin = nrBins;; --iBin) {
1027       double phiLowEdge = m_l1CaloGeometry->emJetPhiBinLowEdge(iBin);
1028       double phiHighEdge = m_l1CaloGeometry->emJetPhiBinHighEdge(iBin);
1029 
1030       if (phiHtmLowEdgeSmallShiftRight >= phiLowEdge) {
1031         m_lutPhiHtmToJetEg[phiHtmInd] = iBin % nrBins;
1032 
1033         LogTrace("L1GlobalTrigger") << " phiHtmIndex \t" << phiHtmInd << " [ " << phiHtmLowEdge << " \t, "
1034                                     << phiHtmHighEdge << "] \t==>\t phiHtmJetEG \t" << m_lutPhiHtmToJetEg[phiHtmInd]
1035                                     << " [ " << phiLowEdge << "\t, " << phiHighEdge << " ]" << std::endl;
1036 
1037         break;
1038       }
1039     }
1040   }
1041 
1042   //
1043   // convert phi scale for (*Jet, EG) to (*Jet, EG)
1044   // dummy - return the same index as the input index
1045 
1046   m_lutPhiJetEgToJetEg.clear();
1047   m_lutPhiJetEgToJetEg.resize(m_nrBinsPhiJetEg, badIndex);
1048 
1049   for (unsigned int phiInd = 0; phiInd < m_nrBinsPhiJetEg; ++phiInd) {
1050     m_lutPhiJetEgToJetEg[phiInd] = phiInd;
1051   }
1052 
1053   //
1054   // eta conversions
1055   //
1056 
1057   // all objects are converted to a common central / forward calorimeter eta
1058   // scale, built by setting together the forward scale and the central scale
1059   //
1060   // eta is signed,  MSB is the sign for all objects - must be taken into
1061   // account in conversion - the common scale is, from 0 to m_nrBinsEtaCommon:
1062   //
1063   // [ForJet negative bins][Central Jet/IsoEG/NoIsoEG negative bins][Central
1064   // Jet/IsoEG/NoIsoEG positive bins][ForJet positive bins]
1065   //
1066 
1067   unsigned int nrGctCentralEtaBinsPerHalf = m_l1CaloGeometry->numberGctCentralEtaBinsPerHalf();
1068 
1069   unsigned int nrGctForwardEtaBinsPerHalf = m_l1CaloGeometry->numberGctForwardEtaBinsPerHalf();
1070 
1071   unsigned int nrGctTotalEtaBinsPerHalf = nrGctCentralEtaBinsPerHalf + nrGctForwardEtaBinsPerHalf;
1072 
1073   m_nrBinsEtaCommon = 2 * nrGctTotalEtaBinsPerHalf;
1074 
1075   //
1076   // convert eta scale for CenJet/TauJet & IsoEG/NoIsoEG to a common
1077   // central / forward calorimeter eta scale
1078   //
1079   // get the sign and the index absolute value
1080 
1081   LogTrace("L1GlobalTrigger") << " \nEta conversion: CenJet/TauJet & "
1082                                  "IsoEG/NoIsoEG to a common calorimeter scale\n"
1083                               << std::endl;
1084 
1085   m_lutEtaCentralToCommonCalo.clear();
1086   m_lutEtaCentralToCommonCalo.resize((nrGctCentralEtaBinsPerHalf | (1 << (ifCaloEtaNumberBits - 1))), badIndex);
1087 
1088   for (unsigned int etaInd = 0; etaInd < nrGctCentralEtaBinsPerHalf; ++etaInd) {
1089     // for positive values, the index is etaInd
1090     unsigned int globalIndex = m_l1CaloGeometry->globalEtaIndex(m_l1CaloGeometry->etaBinCenter(etaInd, true));
1091     m_lutEtaCentralToCommonCalo[etaInd] = globalIndex;
1092 
1093     LogTrace("L1GlobalTrigger") << " etaIndex " << etaInd << "\t [hex: " << std::hex << etaInd << "] " << std::dec
1094                                 << " ==> etaIndexGlobal " << globalIndex << std::endl;
1095 
1096     // for negative values, one adds (binary) 1 as MSB to the index
1097     unsigned int etaIndNeg = etaInd | (1 << (ifCaloEtaNumberBits - 1));
1098     globalIndex = m_l1CaloGeometry->globalEtaIndex(m_l1CaloGeometry->etaBinCenter(etaIndNeg, true));
1099     m_lutEtaCentralToCommonCalo[etaIndNeg] = globalIndex;
1100 
1101     LogTrace("L1GlobalTrigger") << " etaIndex " << etaIndNeg << "\t [hex: " << std::hex << etaIndNeg << "] " << std::dec
1102                                 << " ==> etaIndexGlobal " << globalIndex << std::endl;
1103   }
1104 
1105   //
1106   // convert eta scale for ForJet to a common
1107   // central / forward calorimeter eta scale
1108   //
1109 
1110   LogTrace("L1GlobalTrigger") << " \nEta conversion: ForJet to a common calorimeter scale\n" << std::endl;
1111 
1112   m_lutEtaForJetToCommonCalo.clear();
1113   m_lutEtaForJetToCommonCalo.resize((nrGctForwardEtaBinsPerHalf | (1 << (ifCaloEtaNumberBits - 1))), badIndex);
1114 
1115   for (unsigned int etaInd = 0; etaInd < nrGctForwardEtaBinsPerHalf; ++etaInd) {
1116     // for positive values, the index is etaInd
1117     unsigned int globalIndex = m_l1CaloGeometry->globalEtaIndex(m_l1CaloGeometry->etaBinCenter(etaInd, false));
1118     m_lutEtaForJetToCommonCalo[etaInd] = globalIndex;
1119 
1120     LogTrace("L1GlobalTrigger") << " etaIndex " << etaInd << "\t [hex: " << std::hex << etaInd << "] " << std::dec
1121                                 << " ==> etaIndexGlobal " << globalIndex << std::endl;
1122 
1123     // for negative values, one adds (binary) 1 as MSB to the index
1124     unsigned int etaIndNeg = etaInd | (1 << (ifCaloEtaNumberBits - 1));
1125     globalIndex = m_l1CaloGeometry->globalEtaIndex(m_l1CaloGeometry->etaBinCenter(etaIndNeg, false));
1126     m_lutEtaForJetToCommonCalo[etaIndNeg] = globalIndex;
1127 
1128     LogTrace("L1GlobalTrigger") << " etaIndex " << etaIndNeg << "\t [hex: " << std::hex << etaIndNeg << "] " << std::dec
1129                                 << " ==> etaIndexGlobal " << globalIndex << std::endl;
1130   }
1131 
1132   //
1133   // convert eta scale for Mu to a common
1134   // central / forward calorimeter eta scale
1135   //
1136 
1137   LogDebug("L1GlobalTrigger") << " \nEta conversion: Mu to a common calorimeter scale\n" << std::endl;
1138 
1139   // eta scale defined for positive values - need to be symmetrized
1140   unsigned int nrBinsEtaMuPerHalf = m_l1MuTriggerScales->getGMTEtaScale()->getNBins();
1141   LogTrace("L1GlobalTrigger") << " \nnrBinsEtaMuPerHalf = " << nrBinsEtaMuPerHalf << "\n" << std::endl;
1142 
1143   m_lutEtaMuToCommonCalo.clear();
1144   m_lutEtaMuToCommonCalo.resize((nrBinsEtaMuPerHalf | (1 << (ifMuEtaNumberBits - 1))), badIndex);
1145 
1146   for (unsigned int etaMuInd = 0; etaMuInd < nrBinsEtaMuPerHalf; ++etaMuInd) {
1147     double etaMuLowEdge = m_l1MuTriggerScales->getGMTEtaScale()->getValue(etaMuInd);
1148     double etaMuHighEdge = m_l1MuTriggerScales->getGMTEtaScale()->getValue(etaMuInd + 1);
1149 
1150     // to avoid precision problems, add a small quantity to etaMuLowEdge
1151     double etaMuLowEdgeSmallShiftRight = etaMuLowEdge + (etaMuHighEdge - etaMuLowEdge) / 100.;
1152 
1153     // positive values
1154     for (unsigned int iBin = m_nrBinsEtaCommon;; --iBin) {
1155       double etaLowEdge = m_l1CaloGeometry->globalEtaBinLowEdge(iBin);
1156 
1157       double etaHighEdge = 0.0;
1158       if (iBin == m_nrBinsEtaCommon) {
1159         etaHighEdge = etaLowEdge;
1160       } else {
1161         etaHighEdge = m_l1CaloGeometry->globalEtaBinLowEdge(iBin + 1);
1162       }
1163 
1164       if (etaMuLowEdgeSmallShiftRight >= etaLowEdge) {
1165         m_lutEtaMuToCommonCalo[etaMuInd] = iBin % m_nrBinsEtaCommon;
1166 
1167         LogTrace("L1GlobalTrigger") << " etaMuIndex \t" << etaMuInd << "\t [ " << etaMuLowEdge << ", \t"
1168                                     << etaMuHighEdge << "] ==> etaMuJetEG \t" << m_lutEtaMuToCommonCalo[etaMuInd]
1169                                     << "\t [ " << etaLowEdge << ", \t" << etaHighEdge << " ]" << std::endl;
1170 
1171         break;
1172       }
1173     }
1174 
1175     // for negative values, one adds (binary) 1 as MSB to the index
1176     unsigned int etaMuIndNeg = etaMuInd | (1 << (ifMuEtaNumberBits - 1));
1177     m_lutEtaMuToCommonCalo[etaMuIndNeg] =
1178         m_lutEtaMuToCommonCalo[0] - (m_lutEtaMuToCommonCalo[etaMuInd] - m_lutEtaMuToCommonCalo[0] + 1);
1179 
1180     LogTrace("L1GlobalTrigger") << " etaMuIndexNeg \t" << etaMuIndNeg << "\t [ " << (-1.0 * etaMuLowEdge) << ", \t"
1181                                 << (-1.0 * etaMuHighEdge) << "] ==> etaMuJetEG \t"
1182                                 << m_lutEtaMuToCommonCalo[etaMuIndNeg] << "\t [ "
1183                                 << m_l1CaloGeometry->globalEtaBinLowEdge(m_lutEtaMuToCommonCalo[etaMuIndNeg]) << ", \t"
1184                                 << m_l1CaloGeometry->globalEtaBinLowEdge(m_lutEtaMuToCommonCalo[etaMuIndNeg] + 1)
1185                                 << " ]" << std::endl;
1186   }
1187 
1188   if (m_verbosity && m_isDebugEnabled) {
1189     LogTrace("L1GlobalTrigger") << std::endl;
1190     LogTrace("L1GlobalTrigger") << std::endl;
1191   }
1192 }
1193 
1194 // print all the performed conversions
1195 void L1GtEtaPhiConversions::print(std::ostream &myCout) const {
1196   // force a page break before each group
1197   myCout << "<p style=\"page-break-before: always\">&nbsp;</p>";
1198 
1199   myCout << "\n---++Conversion tables for phi and eta variables of the trigger "
1200             "objects used in correlation conditions \n"
1201          << std::endl;
1202 
1203   //
1204   // phi conversions
1205   //
1206 
1207   // phi Mu -> (*Jet, EG)
1208 
1209   myCout << "\n---+++Phi conversion for muons to jets and e-gamma common phi "
1210             "scale \n"
1211          << std::endl;
1212 
1213   size_t lutPhiMuToJetEgSize = m_lutPhiMuToJetEg.size();
1214   myCout << "Size of look-up table = " << lutPhiMuToJetEgSize << "\n" << std::endl;
1215 
1216   myCout << "|  *Initial Phi Hardware Index*  "
1217          << "||  *Initial Phi Range*  ||"
1218          << "  *Converted Phi Hardware Index*  "
1219          << "||  *Converted Phi Range*  ||"
1220          << "\n"
1221          << "|  *hex*  |  *dec*  | ^|^|  *hex*  |  *dec*  |^|^|" << std::endl;
1222 
1223   for (unsigned int indexToConv = 0; indexToConv < lutPhiMuToJetEgSize; ++indexToConv) {
1224     double lowEdgeToConv = m_l1MuTriggerScales->getPhiScale()->getLowEdge(indexToConv);
1225     double highEdgeToConv = m_l1MuTriggerScales->getPhiScale()->getHighEdge(indexToConv);
1226 
1227     unsigned int convIndex = m_lutPhiMuToJetEg[indexToConv];
1228 
1229     double convLowEdge = 0.;
1230     double convHighEdge = 0.;
1231 
1232     if (convIndex != badIndex) {
1233       convLowEdge = m_l1CaloGeometry->emJetPhiBinLowEdge(convIndex);
1234       convHighEdge = m_l1CaloGeometry->emJetPhiBinHighEdge(convIndex);
1235     } else {
1236       // badIndex means a bad initialIndex
1237       lowEdgeToConv = 0.;
1238       highEdgeToConv = 0.;
1239     }
1240 
1241     myCout << "|  0x" << std::setw(3) << std::hex << std::left << indexToConv << "  |  " << std::dec << std::setw(3)
1242            << std::left << indexToConv << "  |[ " << std::setw(10) << std::left << (rad2deg(lowEdgeToConv)) << ",  |"
1243            << std::setw(10) << std::left << (rad2deg(highEdgeToConv)) << " )  |  0x" << std::setw(6) << std::hex
1244            << std::left << convIndex << " |  " << std::dec << std::setw(6) << convIndex << "  |[ " << std::setw(10)
1245            << std::left << (rad2deg(convLowEdge)) << ",  |" << std::setw(10) << std::left << (rad2deg(convHighEdge))
1246            << " )  |" << std::right << std::endl;
1247   }
1248 
1249   // phi Mu -> ETM
1250 
1251   // force a page break before each group
1252   myCout << "<p style=\"page-break-before: always\">&nbsp;</p>";
1253 
1254   myCout << "\n---+++Phi conversion for muons to ETM phi scale \n" << std::endl;
1255 
1256   size_t lutPhiMuToEtmSize = m_lutPhiMuToEtm.size();
1257   myCout << "Size of look-up table = " << lutPhiMuToEtmSize << "\n" << std::endl;
1258 
1259   myCout << "|  *Initial Phi Hardware Index*  "
1260          << "||  *Initial Phi Range*  ||"
1261          << "  *Converted Phi Hardware Index*  "
1262          << "||  *Converted Phi Range*  ||"
1263          << "\n"
1264          << "|  *hex*  |  *dec*  | ^|^|  *hex*  |  *dec*  |^|^|" << std::endl;
1265 
1266   for (unsigned int indexToConv = 0; indexToConv < lutPhiMuToEtmSize; ++indexToConv) {
1267     double lowEdgeToConv = m_l1MuTriggerScales->getPhiScale()->getLowEdge(indexToConv);
1268     double highEdgeToConv = m_l1MuTriggerScales->getPhiScale()->getHighEdge(indexToConv);
1269 
1270     unsigned int convIndex = m_lutPhiMuToEtm[indexToConv];
1271 
1272     double convLowEdge = 0.;
1273     double convHighEdge = 0.;
1274 
1275     if (convIndex != badIndex) {
1276       convLowEdge = m_l1CaloGeometry->etSumPhiBinLowEdge(convIndex);
1277       convHighEdge = m_l1CaloGeometry->etSumPhiBinHighEdge(convIndex);
1278     } else {
1279       // badIndex means a bad initialIndex
1280       lowEdgeToConv = 0.;
1281       highEdgeToConv = 0.;
1282     }
1283 
1284     myCout << "|  0x" << std::setw(3) << std::hex << std::left << indexToConv << "  |  " << std::dec << std::setw(3)
1285            << std::left << indexToConv << "  |[ " << std::setw(10) << std::left << (rad2deg(lowEdgeToConv)) << ",  |"
1286            << std::setw(10) << std::left << (rad2deg(highEdgeToConv)) << " )  |  0x" << std::setw(6) << std::hex
1287            << std::left << convIndex << " |  " << std::dec << std::setw(6) << convIndex << "  |[ " << std::setw(10)
1288            << std::left << (rad2deg(convLowEdge)) << ",  |" << std::setw(10) << std::left << (rad2deg(convHighEdge))
1289            << " )  |" << std::right << std::endl;
1290   }
1291 
1292   // phi Mu -> HTM
1293 
1294   // force a page break before each group
1295   myCout << "<p style=\"page-break-before: always\">&nbsp;</p>";
1296 
1297   myCout << "\n---+++Phi conversion for muons to HTM phi scale \n" << std::endl;
1298 
1299   size_t lutPhiMuToHtmSize = m_lutPhiMuToHtm.size();
1300   myCout << "Size of look-up table = " << lutPhiMuToHtmSize << "\n" << std::endl;
1301 
1302   myCout << "|  *Initial Phi Hardware Index*  "
1303          << "||  *Initial Phi Range*  ||"
1304          << "  *Converted Phi Hardware Index*  "
1305          << "||  *Converted Phi Range*  ||"
1306          << "\n"
1307          << "|  *hex*  |  *dec*  | ^|^|  *hex*  |  *dec*  |^|^|" << std::endl;
1308 
1309   for (unsigned int indexToConv = 0; indexToConv < lutPhiMuToHtmSize; ++indexToConv) {
1310     double lowEdgeToConv = m_l1MuTriggerScales->getPhiScale()->getLowEdge(indexToConv);
1311     double highEdgeToConv = m_l1MuTriggerScales->getPhiScale()->getHighEdge(indexToConv);
1312 
1313     unsigned int convIndex = m_lutPhiMuToHtm[indexToConv];
1314 
1315     double convLowEdge = 0.;
1316     double convHighEdge = 0.;
1317 
1318     if (convIndex != badIndex) {
1319       convLowEdge = m_l1CaloGeometry->htSumPhiBinLowEdge(convIndex);
1320       convHighEdge = m_l1CaloGeometry->htSumPhiBinHighEdge(convIndex);
1321     } else {
1322       // badIndex means a bad initialIndex
1323       lowEdgeToConv = 0.;
1324       highEdgeToConv = 0.;
1325     }
1326 
1327     myCout << "|  0x" << std::setw(3) << std::hex << std::left << indexToConv << "  |  " << std::dec << std::setw(3)
1328            << std::left << indexToConv << "  |[ " << std::setw(10) << std::left << (rad2deg(lowEdgeToConv)) << ",  |"
1329            << std::setw(10) << std::left << (rad2deg(highEdgeToConv)) << " )  |  0x" << std::setw(6) << std::hex
1330            << std::left << convIndex << " |  " << std::dec << std::setw(6) << convIndex << "  |[ " << std::setw(10)
1331            << std::left << (rad2deg(convLowEdge)) << ",  |" << std::setw(10) << std::left << (rad2deg(convHighEdge))
1332            << " )  |" << std::right << std::endl;
1333   }
1334 
1335   // phi ETM -> (*Jet, EG)
1336 
1337   // force a page break before each group
1338   myCout << "<p style=\"page-break-before: always\">&nbsp;</p>";
1339 
1340   myCout << "\n---+++Phi conversion for ETM to jets and e-gamma scale common "
1341             "phi scale \n"
1342          << std::endl;
1343 
1344   size_t lutPhiEtmToJetEgSize = m_lutPhiEtmToJetEg.size();
1345   myCout << "Size of look-up table = " << lutPhiEtmToJetEgSize << "\n" << std::endl;
1346 
1347   myCout << "|  *Initial Phi Hardware Index*  "
1348          << "||  *Initial Phi Range*  ||"
1349          << "  *Converted Phi Hardware Index*  "
1350          << "||  *Converted Phi Range*  ||"
1351          << "\n"
1352          << "|  *hex*  |  *dec*  | ^|^|  *hex*  |  *dec*  |^|^|" << std::endl;
1353 
1354   for (unsigned int indexToConv = 0; indexToConv < lutPhiEtmToJetEgSize; ++indexToConv) {
1355     double lowEdgeToConv = m_l1CaloGeometry->etSumPhiBinLowEdge(indexToConv);
1356     double highEdgeToConv = m_l1CaloGeometry->etSumPhiBinHighEdge(indexToConv);
1357 
1358     unsigned int convIndex = m_lutPhiEtmToJetEg[indexToConv];
1359 
1360     double convLowEdge = 0.;
1361     double convHighEdge = 0.;
1362 
1363     if (convIndex != badIndex) {
1364       convLowEdge = m_l1CaloGeometry->emJetPhiBinLowEdge(convIndex);
1365       convHighEdge = m_l1CaloGeometry->emJetPhiBinHighEdge(convIndex);
1366     } else {
1367       // badIndex means a bad initialIndex
1368       lowEdgeToConv = 0.;
1369       highEdgeToConv = 0.;
1370     }
1371 
1372     myCout << "|  0x" << std::setw(3) << std::hex << std::left << indexToConv << "  |  " << std::dec << std::setw(3)
1373            << std::left << indexToConv << "  |[ " << std::setw(10) << std::left << (rad2deg(lowEdgeToConv)) << ",  |"
1374            << std::setw(10) << std::left << (rad2deg(highEdgeToConv)) << " )  |  0x" << std::setw(6) << std::hex
1375            << std::left << convIndex << " |  " << std::dec << std::setw(6) << convIndex << "  |[ " << std::setw(10)
1376            << std::left << (rad2deg(convLowEdge)) << ",  |" << std::setw(10) << std::left << (rad2deg(convHighEdge))
1377            << " )  |" << std::right << std::endl;
1378   }
1379 
1380   // phi ETM -> HTM
1381 
1382   // force a page break before each group
1383   myCout << "<p style=\"page-break-before: always\">&nbsp;</p>";
1384 
1385   myCout << "\n---+++Phi conversion for ETM to HTM phi scale \n" << std::endl;
1386 
1387   size_t lutPhiEtmToHtmSize = m_lutPhiEtmToHtm.size();
1388   myCout << "Size of look-up table = " << lutPhiEtmToHtmSize << "\n" << std::endl;
1389 
1390   myCout << "|  *Initial Phi Hardware Index*  "
1391          << "||  *Initial Phi Range*  ||"
1392          << "  *Converted Phi Hardware Index*  "
1393          << "||  *Converted Phi Range*  ||"
1394          << "\n"
1395          << "|  *hex*  |  *dec*  | ^|^|  *hex*  |  *dec*  |^|^|" << std::endl;
1396 
1397   for (unsigned int indexToConv = 0; indexToConv < lutPhiEtmToHtmSize; ++indexToConv) {
1398     double lowEdgeToConv = m_l1CaloGeometry->etSumPhiBinLowEdge(indexToConv);
1399     double highEdgeToConv = m_l1CaloGeometry->etSumPhiBinHighEdge(indexToConv);
1400 
1401     unsigned int convIndex = m_lutPhiEtmToHtm[indexToConv];
1402 
1403     double convLowEdge = 0.;
1404     double convHighEdge = 0.;
1405 
1406     if (convIndex != badIndex) {
1407       convLowEdge = m_l1CaloGeometry->htSumPhiBinLowEdge(convIndex);
1408       convHighEdge = m_l1CaloGeometry->htSumPhiBinHighEdge(convIndex);
1409     } else {
1410       // badIndex means a bad initialIndex
1411       lowEdgeToConv = 0.;
1412       highEdgeToConv = 0.;
1413     }
1414 
1415     myCout << "|  0x" << std::setw(3) << std::hex << std::left << indexToConv << "  |  " << std::dec << std::setw(3)
1416            << std::left << indexToConv << "  |[ " << std::setw(10) << std::left << (rad2deg(lowEdgeToConv)) << ",  |"
1417            << std::setw(10) << std::left << (rad2deg(highEdgeToConv)) << " )  |  0x" << std::setw(6) << std::hex
1418            << std::left << convIndex << " |  " << std::dec << std::setw(6) << convIndex << "  |[ " << std::setw(10)
1419            << std::left << (rad2deg(convLowEdge)) << ",  |" << std::setw(10) << std::left << (rad2deg(convHighEdge))
1420            << " )  |" << std::right << std::endl;
1421   }
1422 
1423   // phi HTM -> (*Jet, EG)
1424 
1425   // force a page break before each group
1426   myCout << "<p style=\"page-break-before: always\">&nbsp;</p>";
1427 
1428   myCout << "\n---+++Phi conversion for HTM to jets and e-gamma scale common "
1429             "phi scale \n"
1430          << std::endl;
1431 
1432   size_t lutPhiHtmToJetEgSize = m_lutPhiHtmToJetEg.size();
1433   myCout << "Size of look-up table = " << lutPhiHtmToJetEgSize << "\n" << std::endl;
1434 
1435   myCout << "|  *Initial Phi Hardware Index*  "
1436          << "||  *Initial Phi Range*  ||"
1437          << "  *Converted Phi Hardware Index*  "
1438          << "||  *Converted Phi Range*  ||"
1439          << "\n"
1440          << "|  *hex*  |  *dec*  | ^|^|  *hex*  |  *dec*  |^|^|" << std::endl;
1441 
1442   for (unsigned int indexToConv = 0; indexToConv < lutPhiHtmToJetEgSize; ++indexToConv) {
1443     double lowEdgeToConv = m_l1CaloGeometry->htSumPhiBinLowEdge(indexToConv);
1444     double highEdgeToConv = m_l1CaloGeometry->htSumPhiBinHighEdge(indexToConv);
1445 
1446     unsigned int convIndex = m_lutPhiHtmToJetEg[indexToConv];
1447 
1448     double convLowEdge = 0.;
1449     double convHighEdge = 0.;
1450 
1451     if (convIndex != badIndex) {
1452       convLowEdge = m_l1CaloGeometry->emJetPhiBinLowEdge(convIndex);
1453       convHighEdge = m_l1CaloGeometry->emJetPhiBinHighEdge(convIndex);
1454     } else {
1455       // badIndex means a bad initialIndex
1456       lowEdgeToConv = 0.;
1457       highEdgeToConv = 0.;
1458     }
1459 
1460     myCout << "|  0x" << std::setw(3) << std::hex << std::left << indexToConv << "  |  " << std::dec << std::setw(3)
1461            << std::left << indexToConv << "  |[ " << std::setw(10) << std::left << (rad2deg(lowEdgeToConv)) << ",  |"
1462            << std::setw(10) << std::left << (rad2deg(highEdgeToConv)) << " )  |  0x" << std::setw(6) << std::hex
1463            << std::left << convIndex << " |  " << std::dec << std::setw(6) << convIndex << "  |[ " << std::setw(10)
1464            << std::left << (rad2deg(convLowEdge)) << ",  |" << std::setw(10) << std::left << (rad2deg(convHighEdge))
1465            << " )  |" << std::right << std::endl;
1466   }
1467 
1468   //
1469   // eta conversions
1470   //
1471 
1472   // CenJet/TauJet & IsoEG/NoIsoEG to a common central / forward calorimeter eta
1473   // scale
1474 
1475   // force a page break before each group
1476   myCout << "<p style=\"page-break-before: always\">&nbsp;</p>";
1477 
1478   myCout << "\n---+++Eta conversion for central and tau jets and e-gamma "
1479             "objects to a common central and forward calorimeter eta scale \n"
1480          << std::endl;
1481 
1482   size_t lutEtaCentralToCommonCaloSize = m_lutEtaCentralToCommonCalo.size();
1483   myCout << "Size of look-up table = " << lutEtaCentralToCommonCaloSize << "\n" << std::endl;
1484 
1485   myCout << "|  *Initial Eta Hardware Index*  "
1486          << "||  *Initial Eta Range*  ||"
1487          << "  *Converted Eta Hardware Index*  "
1488          << "||  *Converted Eta Range*  ||"
1489          << "\n"
1490          << "|  *hex*  |  *dec*  | ^|^|  *hex*  |  *dec*  |^|^|" << std::endl;
1491 
1492   for (unsigned int indexToConv = 0; indexToConv < lutEtaCentralToCommonCaloSize; ++indexToConv) {
1493     double lowEdgeToConv = m_l1CaloGeometry->globalEtaBinLowEdge(
1494         m_l1CaloGeometry->globalEtaIndex(m_l1CaloGeometry->etaBinCenter(indexToConv, true)));
1495     double highEdgeToConv = m_l1CaloGeometry->globalEtaBinLowEdge(
1496         m_l1CaloGeometry->globalEtaIndex(m_l1CaloGeometry->etaBinCenter(indexToConv, true)) + 1);
1497 
1498     unsigned int convIndex = m_lutEtaCentralToCommonCalo[indexToConv];
1499 
1500     double convLowEdge = 0.;
1501     double convHighEdge = 0.;
1502 
1503     if (convIndex != badIndex) {
1504       convLowEdge = m_l1CaloGeometry->globalEtaBinLowEdge(convIndex);
1505       convHighEdge = m_l1CaloGeometry->globalEtaBinLowEdge(convIndex + 1);
1506     } else {
1507       // badIndex means a bad initialIndex
1508       lowEdgeToConv = 0.;
1509       highEdgeToConv = 0.;
1510     }
1511 
1512     myCout << "|  0x" << std::setw(3) << std::hex << std::left << indexToConv << "  |  " << std::dec << std::setw(3)
1513            << std::left << indexToConv << "  |[ " << std::setw(10) << std::left << lowEdgeToConv << ",  |"
1514            << std::setw(10) << std::left << highEdgeToConv << " )  |  0x" << std::setw(6) << std::hex << std::left
1515            << convIndex << " |  " << std::dec << std::setw(6) << convIndex << "  |[ " << std::setw(10) << std::left
1516            << convLowEdge << ",  |" << std::setw(10) << std::left << convHighEdge << " )  |" << std::right << std::endl;
1517   }
1518 
1519   // ForJet to a common central / forward calorimeter eta scale
1520 
1521   // force a page break before each group
1522   myCout << "<p style=\"page-break-before: always\">&nbsp;</p>";
1523 
1524   myCout << "\n---+++Eta conversion for forward jets to a common central and "
1525             "forward calorimeter eta scale \n"
1526          << std::endl;
1527 
1528   size_t lutEtaForJetToCommonCaloSize = m_lutEtaForJetToCommonCalo.size();
1529   myCout << "Size of look-up table = " << lutEtaForJetToCommonCaloSize << "\n" << std::endl;
1530 
1531   myCout << "|  *Initial Eta Hardware Index*  "
1532          << "||  *Initial Eta Range*  ||"
1533          << "  *Converted Eta Hardware Index*  "
1534          << "||  *Converted Eta Range*  ||"
1535          << "\n"
1536          << "|  *hex*  |  *dec*  | ^|^|  *hex*  |  *dec*  |^|^|" << std::endl;
1537 
1538   for (unsigned int indexToConv = 0; indexToConv < lutEtaForJetToCommonCaloSize; ++indexToConv) {
1539     double lowEdgeToConv = m_l1CaloGeometry->globalEtaBinLowEdge(
1540         m_l1CaloGeometry->globalEtaIndex(m_l1CaloGeometry->etaBinCenter(indexToConv, false)));
1541     double highEdgeToConv = m_l1CaloGeometry->globalEtaBinLowEdge(
1542         m_l1CaloGeometry->globalEtaIndex(m_l1CaloGeometry->etaBinCenter(indexToConv, false)) + 1);
1543 
1544     unsigned int convIndex = m_lutEtaForJetToCommonCalo[indexToConv];
1545 
1546     double convLowEdge = 0.;
1547     double convHighEdge = 0.;
1548 
1549     if (convIndex != badIndex) {
1550       convLowEdge = m_l1CaloGeometry->globalEtaBinLowEdge(convIndex);
1551       convHighEdge = m_l1CaloGeometry->globalEtaBinLowEdge(convIndex + 1);
1552     } else {
1553       // badIndex means a bad initialIndex
1554       lowEdgeToConv = 0.;
1555       highEdgeToConv = 0.;
1556     }
1557 
1558     myCout << "|  0x" << std::setw(3) << std::hex << std::left << indexToConv << "  |  " << std::dec << std::setw(3)
1559            << std::left << indexToConv << "  |[ " << std::setw(10) << std::left << lowEdgeToConv << ",  |"
1560            << std::setw(10) << std::left << highEdgeToConv << " )  |  0x" << std::setw(6) << std::hex << std::left
1561            << convIndex << " |  " << std::dec << std::setw(6) << convIndex << "  |[ " << std::setw(10) << std::left
1562            << convLowEdge << ",  |" << std::setw(10) << std::left << convHighEdge << " )  |" << std::right << std::endl;
1563   }
1564 
1565   // Mu to a common central / forward calorimeter eta scale
1566 
1567   // force a page break before each group
1568   myCout << "<p style=\"page-break-before: always\">&nbsp;</p>";
1569 
1570   myCout << "\n---+++Eta conversion for muons to a common central and forward "
1571             "calorimeter eta scale \n"
1572          << std::endl;
1573 
1574   size_t lutEtaMuToCommonCaloSize = m_lutEtaMuToCommonCalo.size();
1575   myCout << "Size of look-up table = " << lutEtaMuToCommonCaloSize << "\n" << std::endl;
1576 
1577   unsigned int nrBinsEtaMuPerHalf = m_l1MuTriggerScales->getGMTEtaScale()->getNBins();
1578 
1579   myCout << "|  *Initial Eta Hardware Index*  "
1580          << "||  *Initial Eta Range*  ||"
1581          << "  *Converted Eta Hardware Index*  "
1582          << "||  *Converted Eta Range*  ||"
1583          << "\n"
1584          << "|  *hex*  |  *dec*  | ^|^|  *hex*  |  *dec*  |^|^|" << std::endl;
1585 
1586   for (unsigned int indexToConv = 0; indexToConv < lutEtaMuToCommonCaloSize; ++indexToConv) {
1587     // Mu scale defined for positive values only, need to be symmetrized
1588     unsigned int iBinOffset = 0;
1589     double etaSign = 1.;
1590 
1591     if (indexToConv > nrBinsEtaMuPerHalf) {
1592       iBinOffset = nrBinsEtaMuPerHalf + 1;
1593       etaSign = -1.;
1594     }
1595 
1596     double lowEdgeToConv = etaSign * m_l1MuTriggerScales->getGMTEtaScale()->getValue(indexToConv - iBinOffset);
1597     double highEdgeToConv = etaSign * m_l1MuTriggerScales->getGMTEtaScale()->getValue(indexToConv + 1 - iBinOffset);
1598 
1599     unsigned int convIndex = m_lutEtaMuToCommonCalo[indexToConv];
1600 
1601     double convLowEdge = 0.;
1602     double convHighEdge = 0.;
1603 
1604     if (convIndex != badIndex) {
1605       convLowEdge = m_l1CaloGeometry->globalEtaBinLowEdge(convIndex);
1606       convHighEdge = m_l1CaloGeometry->globalEtaBinLowEdge(convIndex + 1);
1607     } else {
1608       // badIndex means a bad initialIndex
1609       lowEdgeToConv = 0.;
1610       highEdgeToConv = 0.;
1611     }
1612 
1613     myCout << "|  0x" << std::setw(3) << std::hex << std::left << indexToConv << "  |  " << std::dec << std::setw(3)
1614            << std::left << indexToConv << "  |[ " << std::setw(10) << std::left << lowEdgeToConv << ",  |"
1615            << std::setw(10) << std::left << highEdgeToConv << " )  |  0x" << std::setw(6) << std::hex << std::left
1616            << convIndex << " |  " << std::dec << std::setw(6) << convIndex << "  |[ " << std::setw(10) << std::left
1617            << convLowEdge << ",  |" << std::setw(10) << std::left << convHighEdge << " )  |" << std::right << std::endl;
1618   }
1619 }
1620 
1621 // convert phi from rad (-pi, pi] to deg (0, 360)
1622 const double L1GtEtaPhiConversions::rad2deg(const double &phiRad) const {
1623   if (phiRad < 0.) {
1624     return (phiRad * PiConversion) + 360.;
1625   } else {
1626     return (phiRad * PiConversion);
1627   }
1628 }
1629 
1630 // static members
1631 
1632 const unsigned int L1GtEtaPhiConversions::badIndex = 999999;
1633 const double L1GtEtaPhiConversions::PiConversion = 180. / acos(-1.);