Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-10-08 05:11:43

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     if (m_verbosity && m_isDebugEnabled) {
0493       LogTrace("L1GlobalTrigger") << (positionPair ? "    Second" : "\n  First") << " object from pair " << pairIndex
0494                                   << ": initial phi index " << initialIndex
0495                                   << " >= " << ((*(m_pairPhiConvVec.at(pairIndex))).size()) << " Conversion failed."
0496                                   << std::endl;
0497     }
0498   } else {
0499     if (m_verbosity && m_isDebugEnabled) {
0500       LogTrace("L1GlobalTrigger") << (positionPair ? "    Second" : "\n  First") << " object from pair " << pairIndex
0501                                   << ": initial phi index " << initialIndex << " within scale size "
0502                                   << ((*(m_pairPhiConvVec.at(pairIndex))).size()) << std::endl;
0503     }
0504   }
0505 
0506   // convert the index
0507   switch (positionPair) {
0508     case 0: {
0509       if (m_pairConvertPhiFirstGtObject.at(pairIndex)) {
0510         newIndex = (*(m_pairPhiConvVec.at(pairIndex))).at(initialIndex);
0511 
0512         if (newIndex != badIndex) {
0513           conversionStatus = true;
0514 
0515           if (m_verbosity && m_isDebugEnabled) {
0516             LogTrace("L1GlobalTrigger") << (positionPair ? "    Second" : "\n  First") << " object from pair "
0517                                         << pairIndex << ": initial phi index " << initialIndex << " converted to "
0518                                         << newIndex << std::endl;
0519           }
0520 
0521         } else {
0522           conversionStatus = false;
0523 
0524           if (m_verbosity && m_isDebugEnabled) {
0525             LogTrace("L1GlobalTrigger") << (positionPair ? "    Second" : "\n  First") << " object from pair "
0526                                         << pairIndex << ": converted phi index " << newIndex << "is equal to badIndex "
0527                                         << badIndex << " Conversion failed." << std::endl;
0528           }
0529         }
0530 
0531       } else {
0532         newIndex = initialIndex;
0533         conversionStatus = true;
0534 
0535         if (m_verbosity && m_isDebugEnabled) {
0536           LogTrace("L1GlobalTrigger") << (positionPair ? "    Second" : "\n  First") << " object from pair "
0537                                       << pairIndex << ": initial phi index " << initialIndex
0538                                       << " not requested to be converted, return index " << newIndex << std::endl;
0539         }
0540       }
0541     }
0542 
0543     break;
0544     case 1: {
0545       if (m_pairConvertPhiFirstGtObject.at(pairIndex)) {
0546         newIndex = initialIndex;
0547         conversionStatus = true;
0548 
0549         if (m_verbosity && m_isDebugEnabled) {
0550           LogTrace("L1GlobalTrigger") << (positionPair ? "    Second" : "\n  First") << " object from pair "
0551                                       << pairIndex << ": initial phi index " << initialIndex
0552                                       << " not requested to be converted, return index, return index " << newIndex
0553                                       << std::endl;
0554         }
0555       } else {
0556         newIndex = (*(m_pairPhiConvVec.at(pairIndex))).at(initialIndex);
0557 
0558         if (newIndex != badIndex) {
0559           conversionStatus = true;
0560 
0561           if (m_verbosity && m_isDebugEnabled) {
0562             LogTrace("L1GlobalTrigger") << (positionPair ? "    Second" : "\n  First") << " object from pair "
0563                                         << pairIndex << ": initial phi index " << initialIndex << " converted to "
0564                                         << newIndex << std::endl;
0565           }
0566 
0567         } else {
0568           conversionStatus = false;
0569 
0570           if (m_verbosity && m_isDebugEnabled) {
0571             LogTrace("L1GlobalTrigger") << (positionPair ? "    Second" : "\n  First") << " object from pair "
0572                                         << pairIndex << ": converted phi index " << newIndex << "is equal to badIndex "
0573                                         << badIndex << " Conversion failed." << std::endl;
0574           }
0575         }
0576       }
0577 
0578     }
0579 
0580     break;
0581     default: {
0582       // should not happen (programming error)
0583       throw cms::Exception("FailModule") << "\n  Wrong position in the object pair " << positionPair
0584                                          << "\n  Programming error - position must be either 0 or 1..." << std::endl;
0585 
0586     } break;
0587   }
0588 
0589   //
0590   convertedIndex = newIndex;
0591   return conversionStatus;
0592 }
0593 
0594 const bool L1GtEtaPhiConversions::convertEtaIndex(const L1GtObject &gtObject,
0595                                                   const unsigned int initialIndex,
0596                                                   unsigned int &convertedIndex) const {
0597   unsigned int newIndex = badIndex;
0598   bool conversionStatus = false;
0599 
0600   switch (gtObject) {
0601     case Mu: {
0602       // check if initial index is within the scale size
0603       // could be outside the scale size if there are hardware errors
0604       // or wrong scale conversions
0605       if (initialIndex >= m_lutEtaMuToCommonCalo.size()) {
0606         conversionStatus = false;
0607 
0608         if (m_verbosity && m_isDebugEnabled) {
0609           LogTrace("L1GlobalTrigger") << "    L1 GT object " << (l1GtObjectEnumToString(gtObject))
0610                                       << " has initial eta index " << initialIndex
0611                                       << " >= " << (m_lutEtaMuToCommonCalo.size()) << " scale size. Conversion failed."
0612                                       << std::endl;
0613         }
0614       } else {
0615         // convert the index
0616         newIndex = m_lutEtaMuToCommonCalo[initialIndex];
0617 
0618         if (newIndex != badIndex) {
0619           conversionStatus = true;
0620 
0621           if (m_verbosity && m_isDebugEnabled) {
0622             LogTrace("L1GlobalTrigger") << "    L1 GT object " << (l1GtObjectEnumToString(gtObject))
0623                                         << " initial eta index " << initialIndex << " (within scale size "
0624                                         << (m_lutEtaMuToCommonCalo.size()) << ") converted to " << newIndex
0625                                         << std::endl;
0626           }
0627 
0628         } else {
0629           conversionStatus = false;
0630 
0631           if (m_verbosity && m_isDebugEnabled) {
0632             LogTrace("L1GlobalTrigger") << "    L1 GT object " << (l1GtObjectEnumToString(gtObject))
0633                                         << " initial eta index " << initialIndex << " (within scale size "
0634                                         << (m_lutEtaMuToCommonCalo.size()) << ") converted to badIndex" << newIndex
0635                                         << " Conversion failed." << std::endl;
0636           }
0637         }
0638       }
0639 
0640     } break;
0641 
0642     case NoIsoEG:
0643     case IsoEG:
0644     case CenJet:
0645     case TauJet: {
0646       // check if initial index is within the scale size
0647       // could be outside the scale size if there are hardware errors
0648       // or wrong scale conversions
0649       if (initialIndex >= m_lutEtaCentralToCommonCalo.size()) {
0650         conversionStatus = false;
0651 
0652         if (m_verbosity && m_isDebugEnabled) {
0653           LogTrace("L1GlobalTrigger") << "    L1 GT object " << (l1GtObjectEnumToString(gtObject))
0654                                       << " has initial eta index " << initialIndex
0655                                       << " >= " << (m_lutEtaCentralToCommonCalo.size())
0656                                       << " scale size. Conversion failed." << std::endl;
0657         }
0658       } else {
0659         // convert the index
0660         newIndex = m_lutEtaCentralToCommonCalo[initialIndex];
0661 
0662         if (newIndex != badIndex) {
0663           conversionStatus = true;
0664 
0665           if (m_verbosity && m_isDebugEnabled) {
0666             LogTrace("L1GlobalTrigger") << "    L1 GT object " << (l1GtObjectEnumToString(gtObject))
0667                                         << " initial eta index " << initialIndex << " (within scale size "
0668                                         << (m_lutEtaMuToCommonCalo.size()) << ") converted to " << newIndex
0669                                         << std::endl;
0670           }
0671 
0672         } else {
0673           conversionStatus = false;
0674 
0675           if (m_verbosity && m_isDebugEnabled) {
0676             LogTrace("L1GlobalTrigger") << "    L1 GT object " << (l1GtObjectEnumToString(gtObject))
0677                                         << " initial eta index " << initialIndex << " (within scale size "
0678                                         << (m_lutEtaCentralToCommonCalo.size()) << ") converted to badIndex" << newIndex
0679                                         << " Conversion failed." << std::endl;
0680           }
0681         }
0682       }
0683 
0684     } break;
0685 
0686     case ForJet: {
0687       // check if initial index is within the scale size
0688       // could be outside the scale size if there are hardware errors
0689       // or wrong scale conversions
0690       if (initialIndex >= m_lutEtaForJetToCommonCalo.size()) {
0691         conversionStatus = false;
0692 
0693         if (m_verbosity && m_isDebugEnabled) {
0694           LogTrace("L1GlobalTrigger") << "    L1 GT object " << (l1GtObjectEnumToString(gtObject))
0695                                       << " has initial eta index " << initialIndex
0696                                       << " >= " << (m_lutEtaForJetToCommonCalo.size())
0697                                       << " scale size. Conversion failed." << std::endl;
0698         }
0699       } else {
0700         // convert the index
0701         newIndex = m_lutEtaForJetToCommonCalo[initialIndex];
0702 
0703         if (newIndex != badIndex) {
0704           conversionStatus = true;
0705 
0706           if (m_verbosity && m_isDebugEnabled) {
0707             LogTrace("L1GlobalTrigger") << "    L1 GT object " << (l1GtObjectEnumToString(gtObject))
0708                                         << " initial eta index " << initialIndex << " (within scale size "
0709                                         << (m_lutEtaMuToCommonCalo.size()) << ") converted to " << newIndex
0710                                         << std::endl;
0711           }
0712 
0713         } else {
0714           conversionStatus = false;
0715 
0716           if (m_verbosity && m_isDebugEnabled) {
0717             LogTrace("L1GlobalTrigger") << "    L1 GT object " << (l1GtObjectEnumToString(gtObject))
0718                                         << " initial eta index " << initialIndex << " (within scale size "
0719                                         << (m_lutEtaForJetToCommonCalo.size()) << ") converted to badIndex" << newIndex
0720                                         << " Conversion failed." << std::endl;
0721           }
0722         }
0723       }
0724     } break;
0725 
0726     case ETM:
0727     case ETT:
0728     case HTT:
0729     case HTM:
0730     case JetCounts:
0731     case HfBitCounts:
0732     case HfRingEtSums:
0733     case TechTrig:
0734     case Castor:
0735     case BPTX:
0736     case GtExternal:
0737     case ObjNull: {
0738       // no conversions needed, there is no eta quantity for these objects
0739       conversionStatus = false;
0740     } break;
0741 
0742     default: {
0743       edm::LogInfo("L1GtObject") << "\n  '" << (l1GtObjectEnumToString(gtObject))
0744                                  << "' is not a recognized L1GtObject. "
0745                                  << "\n Conversion failed. " << std::endl;
0746       conversionStatus = false;
0747     } break;
0748   }
0749 
0750   //
0751   convertedIndex = newIndex;
0752 
0753   return conversionStatus;
0754 }
0755 
0756 const unsigned int L1GtEtaPhiConversions::gtObjectNrBinsPhi(const L1GtObject &gtObject) const {
0757   switch (gtObject) {
0758     case Mu: {
0759       return m_nrBinsPhiMu;
0760     } break;
0761 
0762     case NoIsoEG:
0763     case IsoEG:
0764     case CenJet:
0765     case ForJet:
0766     case TauJet: {
0767       return m_nrBinsPhiJetEg;
0768     } break;
0769 
0770     case ETM: {
0771       return m_nrBinsPhiEtm;
0772     } break;
0773 
0774     case ETT:
0775     case HTT: {
0776       return 0;
0777     } break;
0778 
0779     case HTM: {
0780       return m_nrBinsPhiHtm;
0781     } break;
0782 
0783     case JetCounts:
0784     case HfBitCounts:
0785     case HfRingEtSums:
0786     case TechTrig:
0787     case Castor:
0788     case BPTX:
0789     case GtExternal:
0790     case ObjNull: {
0791       return 0;
0792     } break;
0793 
0794     default: {
0795       edm::LogInfo("L1GtObject") << "\n  '" << (l1GtObjectEnumToString(gtObject))
0796                                  << "' is not a recognized L1GtObject. "
0797                                  << "\n Return 0 bins.";
0798       return 0;
0799     } break;
0800   }
0801 }
0802 
0803 const unsigned int L1GtEtaPhiConversions::gtObjectNrBinsPhi(const L1GtObject &obj0, const L1GtObject &obj1) const {
0804   std::pair<L1GtObject, L1GtObject> gtObjPair;
0805   gtObjPair = std::make_pair(obj0, obj1);
0806 
0807   // LogTrace("L1GlobalTrigger") << "\nCompute gtObjectNrBinsPhi ["
0808   //        << (l1GtObjectEnumToString(obj0)) << ", "
0809   //        << (l1GtObjectEnumToString(obj1)) << "]\n" << std::endl;
0810 
0811   int iPair = 0;
0812   for (std::vector<std::pair<L1GtObject, L1GtObject>>::const_iterator cIter = m_gtObjectPairVec.begin();
0813        cIter != m_gtObjectPairVec.end();
0814        ++cIter) {
0815     if (*cIter == gtObjPair) {
0816       LogTrace("L1GlobalTrigger") << "\n  gtObjectNrBinsPhi [" << l1GtObjectEnumToString(obj0) << ", "
0817                                   << l1GtObjectEnumToString(obj1) << "] = " << (*(m_pairNrPhiBinsVec.at(iPair)))
0818                                   << std::endl;
0819 
0820       return *(m_pairNrPhiBinsVec.at(iPair));
0821     }
0822 
0823     iPair++;
0824   }
0825 
0826   return 0;
0827 }
0828 
0829 const unsigned int L1GtEtaPhiConversions::gtObjectNrBinsPhi(const unsigned int pairIndex) const {
0830   if (m_verbosity && m_isDebugEnabled) {
0831     LogTrace("L1GlobalTrigger") << "\n  gtObjectNrBinsPhi for L1 GT object pair index " << pairIndex << " = "
0832                                 << (*(m_pairNrPhiBinsVec.at(pairIndex))) << std::endl;
0833   }
0834 
0835   return *(m_pairNrPhiBinsVec.at(pairIndex));
0836 }
0837 
0838 // perform all conversions
0839 void L1GtEtaPhiConversions::convertL1Scales(const L1CaloGeometry *l1CaloGeometry,
0840                                             const L1MuTriggerScales *l1MuTriggerScales,
0841                                             const int ifCaloEtaNumberBits,
0842                                             const int ifMuEtaNumberBits) {
0843   // no bullet-proof method, depends on binning ...
0844   // decide "by hand / by eyes" which object converts to which object
0845 
0846   // update the scales used
0847   m_l1CaloGeometry = l1CaloGeometry;
0848   m_l1MuTriggerScales = l1MuTriggerScales;
0849 
0850   // number of bins for all phi scales used
0851 
0852   m_nrBinsPhiMu = 144;  // FIXME ask Ivan for size() ...
0853   // m_nrBinsPhiMu = m_l1MuTriggerScales->getPhiScale()->size();
0854 
0855   m_nrBinsPhiJetEg = m_l1CaloGeometry->numberGctEmJetPhiBins();
0856   m_nrBinsPhiEtm = m_l1CaloGeometry->numberGctEtSumPhiBins();
0857   m_nrBinsPhiHtm = m_l1CaloGeometry->numberGctHtSumPhiBins();
0858 
0859   //
0860   // convert phi scale for muon (finer) to phi scale for (*Jet, EG) / ETM / HTM
0861   // (coarser)
0862   //
0863 
0864   m_lutPhiMuToJetEg.clear();
0865   m_lutPhiMuToJetEg.resize(m_nrBinsPhiMu, badIndex);
0866 
0867   m_lutPhiMuToEtm.clear();
0868   m_lutPhiMuToEtm.resize(m_nrBinsPhiMu, badIndex);
0869 
0870   m_lutPhiMuToHtm.clear();
0871   m_lutPhiMuToHtm.resize(m_nrBinsPhiMu, badIndex);
0872 
0873   for (unsigned int phiMuInd = 0; phiMuInd < m_nrBinsPhiMu; ++phiMuInd) {
0874     double phiMuLowEdge = m_l1MuTriggerScales->getPhiScale()->getLowEdge(phiMuInd);
0875     double phiMuHighEdge = m_l1MuTriggerScales->getPhiScale()->getHighEdge(phiMuInd);
0876 
0877     // to avoid precision problems, add a small quantity to phiMuLowEdge
0878     double phiMuLowEdgeSmallShiftRight = phiMuLowEdge + (phiMuHighEdge - phiMuLowEdge) / 100.;
0879 
0880     // phi Mu -> (*Jet, EG)
0881 
0882     unsigned int nrBins = m_nrBinsPhiJetEg;
0883 
0884     for (unsigned int iBin = nrBins;; --iBin) {
0885       double phiLowEdge = m_l1CaloGeometry->emJetPhiBinLowEdge(iBin);
0886       double phiHighEdge = m_l1CaloGeometry->emJetPhiBinHighEdge(iBin);
0887 
0888       if (phiMuLowEdgeSmallShiftRight >= phiLowEdge) {
0889         m_lutPhiMuToJetEg[phiMuInd] = iBin % nrBins;
0890 
0891         LogTrace("L1GlobalTrigger") << " phiMuIndex \t" << phiMuInd << " [ " << phiMuLowEdge << " \t, " << phiMuHighEdge
0892                                     << "] \t==>\t phiMuJetEG \t" << m_lutPhiMuToJetEg[phiMuInd] << " [ " << phiLowEdge
0893                                     << "\t, " << phiHighEdge << " ]" << std::endl;
0894 
0895         break;
0896       }
0897     }
0898 
0899     // phi Mu -> ETM
0900 
0901     nrBins = m_nrBinsPhiEtm;
0902 
0903     for (unsigned int iBin = nrBins;; --iBin) {
0904       double phiLowEdge = m_l1CaloGeometry->etSumPhiBinLowEdge(iBin);
0905       double phiHighEdge = m_l1CaloGeometry->etSumPhiBinHighEdge(iBin);
0906 
0907       if (phiMuLowEdgeSmallShiftRight >= phiLowEdge) {
0908         m_lutPhiMuToEtm[phiMuInd] = iBin % nrBins;
0909 
0910         LogTrace("L1GlobalTrigger") << " phiMuIndex \t" << phiMuInd << " [ " << phiMuLowEdge << " \t, " << phiMuHighEdge
0911                                     << "] \t==>\t phiMuToEtm \t" << m_lutPhiMuToEtm[phiMuInd] << " [ " << phiLowEdge
0912                                     << "\t, " << phiHighEdge << " ]" << std::endl;
0913 
0914         break;
0915       }
0916     }
0917 
0918     // phi Mu -> HTM
0919 
0920     nrBins = m_nrBinsPhiHtm;
0921 
0922     for (unsigned int iBin = nrBins;; --iBin) {
0923       double phiLowEdge = m_l1CaloGeometry->htSumPhiBinLowEdge(iBin);
0924       double phiHighEdge = m_l1CaloGeometry->htSumPhiBinHighEdge(iBin);
0925 
0926       if (phiMuLowEdgeSmallShiftRight >= phiLowEdge) {
0927         m_lutPhiMuToHtm[phiMuInd] = iBin % nrBins;
0928 
0929         LogTrace("L1GlobalTrigger") << " phiMuIndex \t" << phiMuInd << " [ " << phiMuLowEdge << " \t, " << phiMuHighEdge
0930                                     << "] \t==>\t phiMuToHtm \t" << m_lutPhiMuToHtm[phiMuInd] << " [ " << phiLowEdge
0931                                     << "\t, " << phiHighEdge << " ]" << std::endl;
0932 
0933         break;
0934       }
0935     }
0936 
0937     LogTrace("L1GlobalTrigger") << std::endl;
0938   }
0939 
0940   if (m_verbosity && m_isDebugEnabled) {
0941     LogTrace("L1GlobalTrigger") << "Mu phi conversions" << std::endl;
0942     for (unsigned int iBin = 0; iBin < m_nrBinsPhiMu; ++iBin) {
0943       LogTrace("L1GlobalTrigger") << "  Mu phiIndex \t" << iBin << "\t converted to index:"
0944                                   << "\t Jet-EG \t" << m_lutPhiMuToJetEg.at(iBin) << "\t ETM \t"
0945                                   << m_lutPhiMuToEtm.at(iBin) << "\t HTM \t" << m_lutPhiMuToHtm.at(iBin) << std::endl;
0946     }
0947     LogTrace("L1GlobalTrigger") << std::endl;
0948   }
0949 
0950   //
0951   // convert phi scale for ETM to phi scale for (*Jet, EG) / HTM (coarser)
0952   //
0953 
0954   m_lutPhiEtmToJetEg.clear();
0955   m_lutPhiEtmToJetEg.resize(m_nrBinsPhiEtm, badIndex);
0956 
0957   m_lutPhiEtmToHtm.clear();
0958   m_lutPhiEtmToHtm.resize(m_nrBinsPhiEtm, badIndex);
0959 
0960   for (unsigned int phiEtmInd = 0; phiEtmInd < m_nrBinsPhiEtm; ++phiEtmInd) {
0961     double phiEtmLowEdge = m_l1CaloGeometry->etSumPhiBinLowEdge(phiEtmInd);
0962     double phiEtmHighEdge = m_l1CaloGeometry->etSumPhiBinHighEdge(phiEtmInd);
0963 
0964     // to avoid precision problems, add a small quantity to phiEtmLowEdge
0965     double phiEtmLowEdgeSmallShiftRight = phiEtmLowEdge + (phiEtmHighEdge - phiEtmLowEdge) / 100.;
0966 
0967     // phi ETM -> (*Jet, EG)
0968 
0969     unsigned int nrBins = m_nrBinsPhiJetEg;
0970 
0971     for (unsigned int iBin = nrBins;; --iBin) {
0972       double phiLowEdge = m_l1CaloGeometry->emJetPhiBinLowEdge(iBin);
0973       double phiHighEdge = m_l1CaloGeometry->emJetPhiBinHighEdge(iBin);
0974 
0975       if (phiEtmLowEdgeSmallShiftRight >= phiLowEdge) {
0976         m_lutPhiEtmToJetEg[phiEtmInd] = iBin % nrBins;
0977 
0978         LogTrace("L1GlobalTrigger") << " phiEtmIndex \t" << phiEtmInd << " [ " << phiEtmLowEdge << " \t, "
0979                                     << phiEtmHighEdge << "] \t==>\t phiEtmJetEG \t" << m_lutPhiEtmToJetEg[phiEtmInd]
0980                                     << " [ " << phiLowEdge << "\t, " << phiHighEdge << " ]" << std::endl;
0981 
0982         break;
0983       }
0984     }
0985 
0986     // phi ETM -> HTM
0987 
0988     nrBins = m_nrBinsPhiHtm;
0989 
0990     for (unsigned int iBin = nrBins;; --iBin) {
0991       double phiLowEdge = m_l1CaloGeometry->htSumPhiBinLowEdge(iBin);
0992       double phiHighEdge = m_l1CaloGeometry->htSumPhiBinHighEdge(iBin);
0993 
0994       if (phiEtmLowEdgeSmallShiftRight >= phiLowEdge) {
0995         m_lutPhiEtmToHtm[phiEtmInd] = iBin % nrBins;
0996 
0997         LogTrace("L1GlobalTrigger") << " phiEtmIndex \t" << phiEtmInd << " [ " << phiEtmLowEdge << " \t, "
0998                                     << phiEtmHighEdge << "] \t==>\t phiEtmToHtm \t" << m_lutPhiEtmToHtm[phiEtmInd]
0999                                     << " [ " << phiLowEdge << "\t, " << phiHighEdge << " ]" << std::endl;
1000 
1001         break;
1002       }
1003     }
1004 
1005     LogTrace("L1GlobalTrigger") << std::endl;
1006   }
1007 
1008   //
1009   // convert phi scale for HTM to phi scale for (*Jet, EG)
1010   //
1011 
1012   m_lutPhiHtmToJetEg.clear();
1013   m_lutPhiHtmToJetEg.resize(m_nrBinsPhiHtm, badIndex);
1014 
1015   for (unsigned int phiHtmInd = 0; phiHtmInd < m_nrBinsPhiHtm; ++phiHtmInd) {
1016     double phiHtmLowEdge = m_l1CaloGeometry->htSumPhiBinLowEdge(phiHtmInd);
1017     double phiHtmHighEdge = m_l1CaloGeometry->htSumPhiBinHighEdge(phiHtmInd);
1018 
1019     // to avoid precision problems, add a small quantity to phiHtmLowEdge
1020     double phiHtmLowEdgeSmallShiftRight = phiHtmLowEdge + (phiHtmHighEdge - phiHtmLowEdge) / 100.;
1021 
1022     unsigned int nrBins = m_nrBinsPhiJetEg;
1023 
1024     for (unsigned int iBin = nrBins;; --iBin) {
1025       double phiLowEdge = m_l1CaloGeometry->emJetPhiBinLowEdge(iBin);
1026       double phiHighEdge = m_l1CaloGeometry->emJetPhiBinHighEdge(iBin);
1027 
1028       if (phiHtmLowEdgeSmallShiftRight >= phiLowEdge) {
1029         m_lutPhiHtmToJetEg[phiHtmInd] = iBin % nrBins;
1030 
1031         LogTrace("L1GlobalTrigger") << " phiHtmIndex \t" << phiHtmInd << " [ " << phiHtmLowEdge << " \t, "
1032                                     << phiHtmHighEdge << "] \t==>\t phiHtmJetEG \t" << m_lutPhiHtmToJetEg[phiHtmInd]
1033                                     << " [ " << phiLowEdge << "\t, " << phiHighEdge << " ]" << std::endl;
1034 
1035         break;
1036       }
1037     }
1038   }
1039 
1040   //
1041   // convert phi scale for (*Jet, EG) to (*Jet, EG)
1042   // dummy - return the same index as the input index
1043 
1044   m_lutPhiJetEgToJetEg.clear();
1045   m_lutPhiJetEgToJetEg.resize(m_nrBinsPhiJetEg, badIndex);
1046 
1047   for (unsigned int phiInd = 0; phiInd < m_nrBinsPhiJetEg; ++phiInd) {
1048     m_lutPhiJetEgToJetEg[phiInd] = phiInd;
1049   }
1050 
1051   //
1052   // eta conversions
1053   //
1054 
1055   // all objects are converted to a common central / forward calorimeter eta
1056   // scale, built by setting together the forward scale and the central scale
1057   //
1058   // eta is signed,  MSB is the sign for all objects - must be taken into
1059   // account in conversion - the common scale is, from 0 to m_nrBinsEtaCommon:
1060   //
1061   // [ForJet negative bins][Central Jet/IsoEG/NoIsoEG negative bins][Central
1062   // Jet/IsoEG/NoIsoEG positive bins][ForJet positive bins]
1063   //
1064 
1065   unsigned int nrGctCentralEtaBinsPerHalf = m_l1CaloGeometry->numberGctCentralEtaBinsPerHalf();
1066 
1067   unsigned int nrGctForwardEtaBinsPerHalf = m_l1CaloGeometry->numberGctForwardEtaBinsPerHalf();
1068 
1069   unsigned int nrGctTotalEtaBinsPerHalf = nrGctCentralEtaBinsPerHalf + nrGctForwardEtaBinsPerHalf;
1070 
1071   m_nrBinsEtaCommon = 2 * nrGctTotalEtaBinsPerHalf;
1072 
1073   //
1074   // convert eta scale for CenJet/TauJet & IsoEG/NoIsoEG to a common
1075   // central / forward calorimeter eta scale
1076   //
1077   // get the sign and the index absolute value
1078 
1079   LogTrace("L1GlobalTrigger") << " \nEta conversion: CenJet/TauJet & "
1080                                  "IsoEG/NoIsoEG to a common calorimeter scale\n"
1081                               << std::endl;
1082 
1083   m_lutEtaCentralToCommonCalo.clear();
1084   m_lutEtaCentralToCommonCalo.resize((nrGctCentralEtaBinsPerHalf | (1 << (ifCaloEtaNumberBits - 1))), badIndex);
1085 
1086   for (unsigned int etaInd = 0; etaInd < nrGctCentralEtaBinsPerHalf; ++etaInd) {
1087     // for positive values, the index is etaInd
1088     unsigned int globalIndex = m_l1CaloGeometry->globalEtaIndex(m_l1CaloGeometry->etaBinCenter(etaInd, true));
1089     m_lutEtaCentralToCommonCalo[etaInd] = globalIndex;
1090 
1091     LogTrace("L1GlobalTrigger") << " etaIndex " << etaInd << "\t [hex: " << std::hex << etaInd << "] " << std::dec
1092                                 << " ==> etaIndexGlobal " << globalIndex << std::endl;
1093 
1094     // for negative values, one adds (binary) 1 as MSB to the index
1095     unsigned int etaIndNeg = etaInd | (1 << (ifCaloEtaNumberBits - 1));
1096     globalIndex = m_l1CaloGeometry->globalEtaIndex(m_l1CaloGeometry->etaBinCenter(etaIndNeg, true));
1097     m_lutEtaCentralToCommonCalo[etaIndNeg] = globalIndex;
1098 
1099     LogTrace("L1GlobalTrigger") << " etaIndex " << etaIndNeg << "\t [hex: " << std::hex << etaIndNeg << "] " << std::dec
1100                                 << " ==> etaIndexGlobal " << globalIndex << std::endl;
1101   }
1102 
1103   //
1104   // convert eta scale for ForJet to a common
1105   // central / forward calorimeter eta scale
1106   //
1107 
1108   LogTrace("L1GlobalTrigger") << " \nEta conversion: ForJet to a common calorimeter scale\n" << std::endl;
1109 
1110   m_lutEtaForJetToCommonCalo.clear();
1111   m_lutEtaForJetToCommonCalo.resize((nrGctForwardEtaBinsPerHalf | (1 << (ifCaloEtaNumberBits - 1))), badIndex);
1112 
1113   for (unsigned int etaInd = 0; etaInd < nrGctForwardEtaBinsPerHalf; ++etaInd) {
1114     // for positive values, the index is etaInd
1115     unsigned int globalIndex = m_l1CaloGeometry->globalEtaIndex(m_l1CaloGeometry->etaBinCenter(etaInd, false));
1116     m_lutEtaForJetToCommonCalo[etaInd] = globalIndex;
1117 
1118     LogTrace("L1GlobalTrigger") << " etaIndex " << etaInd << "\t [hex: " << std::hex << etaInd << "] " << std::dec
1119                                 << " ==> etaIndexGlobal " << globalIndex << std::endl;
1120 
1121     // for negative values, one adds (binary) 1 as MSB to the index
1122     unsigned int etaIndNeg = etaInd | (1 << (ifCaloEtaNumberBits - 1));
1123     globalIndex = m_l1CaloGeometry->globalEtaIndex(m_l1CaloGeometry->etaBinCenter(etaIndNeg, false));
1124     m_lutEtaForJetToCommonCalo[etaIndNeg] = globalIndex;
1125 
1126     LogTrace("L1GlobalTrigger") << " etaIndex " << etaIndNeg << "\t [hex: " << std::hex << etaIndNeg << "] " << std::dec
1127                                 << " ==> etaIndexGlobal " << globalIndex << std::endl;
1128   }
1129 
1130   //
1131   // convert eta scale for Mu to a common
1132   // central / forward calorimeter eta scale
1133   //
1134 
1135   LogDebug("L1GlobalTrigger") << " \nEta conversion: Mu to a common calorimeter scale\n" << std::endl;
1136 
1137   // eta scale defined for positive values - need to be symmetrized
1138   unsigned int nrBinsEtaMuPerHalf = m_l1MuTriggerScales->getGMTEtaScale()->getNBins();
1139   LogTrace("L1GlobalTrigger") << " \nnrBinsEtaMuPerHalf = " << nrBinsEtaMuPerHalf << "\n" << std::endl;
1140 
1141   m_lutEtaMuToCommonCalo.clear();
1142   m_lutEtaMuToCommonCalo.resize((nrBinsEtaMuPerHalf | (1 << (ifMuEtaNumberBits - 1))), badIndex);
1143 
1144   for (unsigned int etaMuInd = 0; etaMuInd < nrBinsEtaMuPerHalf; ++etaMuInd) {
1145     double etaMuLowEdge = m_l1MuTriggerScales->getGMTEtaScale()->getValue(etaMuInd);
1146     double etaMuHighEdge = m_l1MuTriggerScales->getGMTEtaScale()->getValue(etaMuInd + 1);
1147 
1148     // to avoid precision problems, add a small quantity to etaMuLowEdge
1149     double etaMuLowEdgeSmallShiftRight = etaMuLowEdge + (etaMuHighEdge - etaMuLowEdge) / 100.;
1150 
1151     // positive values
1152     for (unsigned int iBin = m_nrBinsEtaCommon;; --iBin) {
1153       double etaLowEdge = m_l1CaloGeometry->globalEtaBinLowEdge(iBin);
1154 
1155       double etaHighEdge = 0.0;
1156       if (iBin == m_nrBinsEtaCommon) {
1157         etaHighEdge = etaLowEdge;
1158       } else {
1159         etaHighEdge = m_l1CaloGeometry->globalEtaBinLowEdge(iBin + 1);
1160       }
1161 
1162       if (etaMuLowEdgeSmallShiftRight >= etaLowEdge) {
1163         m_lutEtaMuToCommonCalo[etaMuInd] = iBin % m_nrBinsEtaCommon;
1164 
1165         LogTrace("L1GlobalTrigger") << " etaMuIndex \t" << etaMuInd << "\t [ " << etaMuLowEdge << ", \t"
1166                                     << etaMuHighEdge << "] ==> etaMuJetEG \t" << m_lutEtaMuToCommonCalo[etaMuInd]
1167                                     << "\t [ " << etaLowEdge << ", \t" << etaHighEdge << " ]" << std::endl;
1168 
1169         break;
1170       }
1171     }
1172 
1173     // for negative values, one adds (binary) 1 as MSB to the index
1174     unsigned int etaMuIndNeg = etaMuInd | (1 << (ifMuEtaNumberBits - 1));
1175     m_lutEtaMuToCommonCalo[etaMuIndNeg] =
1176         m_lutEtaMuToCommonCalo[0] - (m_lutEtaMuToCommonCalo[etaMuInd] - m_lutEtaMuToCommonCalo[0] + 1);
1177 
1178     LogTrace("L1GlobalTrigger") << " etaMuIndexNeg \t" << etaMuIndNeg << "\t [ " << (-1.0 * etaMuLowEdge) << ", \t"
1179                                 << (-1.0 * etaMuHighEdge) << "] ==> etaMuJetEG \t"
1180                                 << m_lutEtaMuToCommonCalo[etaMuIndNeg] << "\t [ "
1181                                 << m_l1CaloGeometry->globalEtaBinLowEdge(m_lutEtaMuToCommonCalo[etaMuIndNeg]) << ", \t"
1182                                 << m_l1CaloGeometry->globalEtaBinLowEdge(m_lutEtaMuToCommonCalo[etaMuIndNeg] + 1)
1183                                 << " ]" << std::endl;
1184   }
1185 
1186   if (m_verbosity && m_isDebugEnabled) {
1187     LogTrace("L1GlobalTrigger") << std::endl;
1188     LogTrace("L1GlobalTrigger") << std::endl;
1189   }
1190 }
1191 
1192 // print all the performed conversions
1193 void L1GtEtaPhiConversions::print(std::ostream &myCout) const {
1194   // force a page break before each group
1195   myCout << "<p style=\"page-break-before: always\">&nbsp;</p>";
1196 
1197   myCout << "\n---++Conversion tables for phi and eta variables of the trigger "
1198             "objects used in correlation conditions \n"
1199          << std::endl;
1200 
1201   //
1202   // phi conversions
1203   //
1204 
1205   // phi Mu -> (*Jet, EG)
1206 
1207   myCout << "\n---+++Phi conversion for muons to jets and e-gamma common phi "
1208             "scale \n"
1209          << std::endl;
1210 
1211   size_t lutPhiMuToJetEgSize = m_lutPhiMuToJetEg.size();
1212   myCout << "Size of look-up table = " << lutPhiMuToJetEgSize << "\n" << std::endl;
1213 
1214   myCout << "|  *Initial Phi Hardware Index*  "
1215          << "||  *Initial Phi Range*  ||"
1216          << "  *Converted Phi Hardware Index*  "
1217          << "||  *Converted Phi Range*  ||"
1218          << "\n"
1219          << "|  *hex*  |  *dec*  | ^|^|  *hex*  |  *dec*  |^|^|" << std::endl;
1220 
1221   for (unsigned int indexToConv = 0; indexToConv < lutPhiMuToJetEgSize; ++indexToConv) {
1222     double lowEdgeToConv = m_l1MuTriggerScales->getPhiScale()->getLowEdge(indexToConv);
1223     double highEdgeToConv = m_l1MuTriggerScales->getPhiScale()->getHighEdge(indexToConv);
1224 
1225     unsigned int convIndex = m_lutPhiMuToJetEg[indexToConv];
1226 
1227     double convLowEdge = 0.;
1228     double convHighEdge = 0.;
1229 
1230     if (convIndex != badIndex) {
1231       convLowEdge = m_l1CaloGeometry->emJetPhiBinLowEdge(convIndex);
1232       convHighEdge = m_l1CaloGeometry->emJetPhiBinHighEdge(convIndex);
1233     } else {
1234       // badIndex means a bad initialIndex
1235       lowEdgeToConv = 0.;
1236       highEdgeToConv = 0.;
1237     }
1238 
1239     myCout << "|  0x" << std::setw(3) << std::hex << std::left << indexToConv << "  |  " << std::dec << std::setw(3)
1240            << std::left << indexToConv << "  |[ " << std::setw(10) << std::left << (rad2deg(lowEdgeToConv)) << ",  |"
1241            << std::setw(10) << std::left << (rad2deg(highEdgeToConv)) << " )  |  0x" << std::setw(6) << std::hex
1242            << std::left << convIndex << " |  " << std::dec << std::setw(6) << convIndex << "  |[ " << std::setw(10)
1243            << std::left << (rad2deg(convLowEdge)) << ",  |" << std::setw(10) << std::left << (rad2deg(convHighEdge))
1244            << " )  |" << std::right << std::endl;
1245   }
1246 
1247   // phi Mu -> ETM
1248 
1249   // force a page break before each group
1250   myCout << "<p style=\"page-break-before: always\">&nbsp;</p>";
1251 
1252   myCout << "\n---+++Phi conversion for muons to ETM phi scale \n" << std::endl;
1253 
1254   size_t lutPhiMuToEtmSize = m_lutPhiMuToEtm.size();
1255   myCout << "Size of look-up table = " << lutPhiMuToEtmSize << "\n" << std::endl;
1256 
1257   myCout << "|  *Initial Phi Hardware Index*  "
1258          << "||  *Initial Phi Range*  ||"
1259          << "  *Converted Phi Hardware Index*  "
1260          << "||  *Converted Phi Range*  ||"
1261          << "\n"
1262          << "|  *hex*  |  *dec*  | ^|^|  *hex*  |  *dec*  |^|^|" << std::endl;
1263 
1264   for (unsigned int indexToConv = 0; indexToConv < lutPhiMuToEtmSize; ++indexToConv) {
1265     double lowEdgeToConv = m_l1MuTriggerScales->getPhiScale()->getLowEdge(indexToConv);
1266     double highEdgeToConv = m_l1MuTriggerScales->getPhiScale()->getHighEdge(indexToConv);
1267 
1268     unsigned int convIndex = m_lutPhiMuToEtm[indexToConv];
1269 
1270     double convLowEdge = 0.;
1271     double convHighEdge = 0.;
1272 
1273     if (convIndex != badIndex) {
1274       convLowEdge = m_l1CaloGeometry->etSumPhiBinLowEdge(convIndex);
1275       convHighEdge = m_l1CaloGeometry->etSumPhiBinHighEdge(convIndex);
1276     } else {
1277       // badIndex means a bad initialIndex
1278       lowEdgeToConv = 0.;
1279       highEdgeToConv = 0.;
1280     }
1281 
1282     myCout << "|  0x" << std::setw(3) << std::hex << std::left << indexToConv << "  |  " << std::dec << std::setw(3)
1283            << std::left << indexToConv << "  |[ " << std::setw(10) << std::left << (rad2deg(lowEdgeToConv)) << ",  |"
1284            << std::setw(10) << std::left << (rad2deg(highEdgeToConv)) << " )  |  0x" << std::setw(6) << std::hex
1285            << std::left << convIndex << " |  " << std::dec << std::setw(6) << convIndex << "  |[ " << std::setw(10)
1286            << std::left << (rad2deg(convLowEdge)) << ",  |" << std::setw(10) << std::left << (rad2deg(convHighEdge))
1287            << " )  |" << std::right << std::endl;
1288   }
1289 
1290   // phi Mu -> HTM
1291 
1292   // force a page break before each group
1293   myCout << "<p style=\"page-break-before: always\">&nbsp;</p>";
1294 
1295   myCout << "\n---+++Phi conversion for muons to HTM phi scale \n" << std::endl;
1296 
1297   size_t lutPhiMuToHtmSize = m_lutPhiMuToHtm.size();
1298   myCout << "Size of look-up table = " << lutPhiMuToHtmSize << "\n" << std::endl;
1299 
1300   myCout << "|  *Initial Phi Hardware Index*  "
1301          << "||  *Initial Phi Range*  ||"
1302          << "  *Converted Phi Hardware Index*  "
1303          << "||  *Converted Phi Range*  ||"
1304          << "\n"
1305          << "|  *hex*  |  *dec*  | ^|^|  *hex*  |  *dec*  |^|^|" << std::endl;
1306 
1307   for (unsigned int indexToConv = 0; indexToConv < lutPhiMuToHtmSize; ++indexToConv) {
1308     double lowEdgeToConv = m_l1MuTriggerScales->getPhiScale()->getLowEdge(indexToConv);
1309     double highEdgeToConv = m_l1MuTriggerScales->getPhiScale()->getHighEdge(indexToConv);
1310 
1311     unsigned int convIndex = m_lutPhiMuToHtm[indexToConv];
1312 
1313     double convLowEdge = 0.;
1314     double convHighEdge = 0.;
1315 
1316     if (convIndex != badIndex) {
1317       convLowEdge = m_l1CaloGeometry->htSumPhiBinLowEdge(convIndex);
1318       convHighEdge = m_l1CaloGeometry->htSumPhiBinHighEdge(convIndex);
1319     } else {
1320       // badIndex means a bad initialIndex
1321       lowEdgeToConv = 0.;
1322       highEdgeToConv = 0.;
1323     }
1324 
1325     myCout << "|  0x" << std::setw(3) << std::hex << std::left << indexToConv << "  |  " << std::dec << std::setw(3)
1326            << std::left << indexToConv << "  |[ " << std::setw(10) << std::left << (rad2deg(lowEdgeToConv)) << ",  |"
1327            << std::setw(10) << std::left << (rad2deg(highEdgeToConv)) << " )  |  0x" << std::setw(6) << std::hex
1328            << std::left << convIndex << " |  " << std::dec << std::setw(6) << convIndex << "  |[ " << std::setw(10)
1329            << std::left << (rad2deg(convLowEdge)) << ",  |" << std::setw(10) << std::left << (rad2deg(convHighEdge))
1330            << " )  |" << std::right << std::endl;
1331   }
1332 
1333   // phi ETM -> (*Jet, EG)
1334 
1335   // force a page break before each group
1336   myCout << "<p style=\"page-break-before: always\">&nbsp;</p>";
1337 
1338   myCout << "\n---+++Phi conversion for ETM to jets and e-gamma scale common "
1339             "phi scale \n"
1340          << std::endl;
1341 
1342   size_t lutPhiEtmToJetEgSize = m_lutPhiEtmToJetEg.size();
1343   myCout << "Size of look-up table = " << lutPhiEtmToJetEgSize << "\n" << std::endl;
1344 
1345   myCout << "|  *Initial Phi Hardware Index*  "
1346          << "||  *Initial Phi Range*  ||"
1347          << "  *Converted Phi Hardware Index*  "
1348          << "||  *Converted Phi Range*  ||"
1349          << "\n"
1350          << "|  *hex*  |  *dec*  | ^|^|  *hex*  |  *dec*  |^|^|" << std::endl;
1351 
1352   for (unsigned int indexToConv = 0; indexToConv < lutPhiEtmToJetEgSize; ++indexToConv) {
1353     double lowEdgeToConv = m_l1CaloGeometry->etSumPhiBinLowEdge(indexToConv);
1354     double highEdgeToConv = m_l1CaloGeometry->etSumPhiBinHighEdge(indexToConv);
1355 
1356     unsigned int convIndex = m_lutPhiEtmToJetEg[indexToConv];
1357 
1358     double convLowEdge = 0.;
1359     double convHighEdge = 0.;
1360 
1361     if (convIndex != badIndex) {
1362       convLowEdge = m_l1CaloGeometry->emJetPhiBinLowEdge(convIndex);
1363       convHighEdge = m_l1CaloGeometry->emJetPhiBinHighEdge(convIndex);
1364     } else {
1365       // badIndex means a bad initialIndex
1366       lowEdgeToConv = 0.;
1367       highEdgeToConv = 0.;
1368     }
1369 
1370     myCout << "|  0x" << std::setw(3) << std::hex << std::left << indexToConv << "  |  " << std::dec << std::setw(3)
1371            << std::left << indexToConv << "  |[ " << std::setw(10) << std::left << (rad2deg(lowEdgeToConv)) << ",  |"
1372            << std::setw(10) << std::left << (rad2deg(highEdgeToConv)) << " )  |  0x" << std::setw(6) << std::hex
1373            << std::left << convIndex << " |  " << std::dec << std::setw(6) << convIndex << "  |[ " << std::setw(10)
1374            << std::left << (rad2deg(convLowEdge)) << ",  |" << std::setw(10) << std::left << (rad2deg(convHighEdge))
1375            << " )  |" << std::right << std::endl;
1376   }
1377 
1378   // phi ETM -> HTM
1379 
1380   // force a page break before each group
1381   myCout << "<p style=\"page-break-before: always\">&nbsp;</p>";
1382 
1383   myCout << "\n---+++Phi conversion for ETM to HTM phi scale \n" << std::endl;
1384 
1385   size_t lutPhiEtmToHtmSize = m_lutPhiEtmToHtm.size();
1386   myCout << "Size of look-up table = " << lutPhiEtmToHtmSize << "\n" << std::endl;
1387 
1388   myCout << "|  *Initial Phi Hardware Index*  "
1389          << "||  *Initial Phi Range*  ||"
1390          << "  *Converted Phi Hardware Index*  "
1391          << "||  *Converted Phi Range*  ||"
1392          << "\n"
1393          << "|  *hex*  |  *dec*  | ^|^|  *hex*  |  *dec*  |^|^|" << std::endl;
1394 
1395   for (unsigned int indexToConv = 0; indexToConv < lutPhiEtmToHtmSize; ++indexToConv) {
1396     double lowEdgeToConv = m_l1CaloGeometry->etSumPhiBinLowEdge(indexToConv);
1397     double highEdgeToConv = m_l1CaloGeometry->etSumPhiBinHighEdge(indexToConv);
1398 
1399     unsigned int convIndex = m_lutPhiEtmToHtm[indexToConv];
1400 
1401     double convLowEdge = 0.;
1402     double convHighEdge = 0.;
1403 
1404     if (convIndex != badIndex) {
1405       convLowEdge = m_l1CaloGeometry->htSumPhiBinLowEdge(convIndex);
1406       convHighEdge = m_l1CaloGeometry->htSumPhiBinHighEdge(convIndex);
1407     } else {
1408       // badIndex means a bad initialIndex
1409       lowEdgeToConv = 0.;
1410       highEdgeToConv = 0.;
1411     }
1412 
1413     myCout << "|  0x" << std::setw(3) << std::hex << std::left << indexToConv << "  |  " << std::dec << std::setw(3)
1414            << std::left << indexToConv << "  |[ " << std::setw(10) << std::left << (rad2deg(lowEdgeToConv)) << ",  |"
1415            << std::setw(10) << std::left << (rad2deg(highEdgeToConv)) << " )  |  0x" << std::setw(6) << std::hex
1416            << std::left << convIndex << " |  " << std::dec << std::setw(6) << convIndex << "  |[ " << std::setw(10)
1417            << std::left << (rad2deg(convLowEdge)) << ",  |" << std::setw(10) << std::left << (rad2deg(convHighEdge))
1418            << " )  |" << std::right << std::endl;
1419   }
1420 
1421   // phi HTM -> (*Jet, EG)
1422 
1423   // force a page break before each group
1424   myCout << "<p style=\"page-break-before: always\">&nbsp;</p>";
1425 
1426   myCout << "\n---+++Phi conversion for HTM to jets and e-gamma scale common "
1427             "phi scale \n"
1428          << std::endl;
1429 
1430   size_t lutPhiHtmToJetEgSize = m_lutPhiHtmToJetEg.size();
1431   myCout << "Size of look-up table = " << lutPhiHtmToJetEgSize << "\n" << std::endl;
1432 
1433   myCout << "|  *Initial Phi Hardware Index*  "
1434          << "||  *Initial Phi Range*  ||"
1435          << "  *Converted Phi Hardware Index*  "
1436          << "||  *Converted Phi Range*  ||"
1437          << "\n"
1438          << "|  *hex*  |  *dec*  | ^|^|  *hex*  |  *dec*  |^|^|" << std::endl;
1439 
1440   for (unsigned int indexToConv = 0; indexToConv < lutPhiHtmToJetEgSize; ++indexToConv) {
1441     double lowEdgeToConv = m_l1CaloGeometry->htSumPhiBinLowEdge(indexToConv);
1442     double highEdgeToConv = m_l1CaloGeometry->htSumPhiBinHighEdge(indexToConv);
1443 
1444     unsigned int convIndex = m_lutPhiHtmToJetEg[indexToConv];
1445 
1446     double convLowEdge = 0.;
1447     double convHighEdge = 0.;
1448 
1449     if (convIndex != badIndex) {
1450       convLowEdge = m_l1CaloGeometry->emJetPhiBinLowEdge(convIndex);
1451       convHighEdge = m_l1CaloGeometry->emJetPhiBinHighEdge(convIndex);
1452     } else {
1453       // badIndex means a bad initialIndex
1454       lowEdgeToConv = 0.;
1455       highEdgeToConv = 0.;
1456     }
1457 
1458     myCout << "|  0x" << std::setw(3) << std::hex << std::left << indexToConv << "  |  " << std::dec << std::setw(3)
1459            << std::left << indexToConv << "  |[ " << std::setw(10) << std::left << (rad2deg(lowEdgeToConv)) << ",  |"
1460            << std::setw(10) << std::left << (rad2deg(highEdgeToConv)) << " )  |  0x" << std::setw(6) << std::hex
1461            << std::left << convIndex << " |  " << std::dec << std::setw(6) << convIndex << "  |[ " << std::setw(10)
1462            << std::left << (rad2deg(convLowEdge)) << ",  |" << std::setw(10) << std::left << (rad2deg(convHighEdge))
1463            << " )  |" << std::right << std::endl;
1464   }
1465 
1466   //
1467   // eta conversions
1468   //
1469 
1470   // CenJet/TauJet & IsoEG/NoIsoEG to a common central / forward calorimeter eta
1471   // scale
1472 
1473   // force a page break before each group
1474   myCout << "<p style=\"page-break-before: always\">&nbsp;</p>";
1475 
1476   myCout << "\n---+++Eta conversion for central and tau jets and e-gamma "
1477             "objects to a common central and forward calorimeter eta scale \n"
1478          << std::endl;
1479 
1480   size_t lutEtaCentralToCommonCaloSize = m_lutEtaCentralToCommonCalo.size();
1481   myCout << "Size of look-up table = " << lutEtaCentralToCommonCaloSize << "\n" << std::endl;
1482 
1483   myCout << "|  *Initial Eta Hardware Index*  "
1484          << "||  *Initial Eta Range*  ||"
1485          << "  *Converted Eta Hardware Index*  "
1486          << "||  *Converted Eta Range*  ||"
1487          << "\n"
1488          << "|  *hex*  |  *dec*  | ^|^|  *hex*  |  *dec*  |^|^|" << std::endl;
1489 
1490   for (unsigned int indexToConv = 0; indexToConv < lutEtaCentralToCommonCaloSize; ++indexToConv) {
1491     double lowEdgeToConv = m_l1CaloGeometry->globalEtaBinLowEdge(
1492         m_l1CaloGeometry->globalEtaIndex(m_l1CaloGeometry->etaBinCenter(indexToConv, true)));
1493     double highEdgeToConv = m_l1CaloGeometry->globalEtaBinLowEdge(
1494         m_l1CaloGeometry->globalEtaIndex(m_l1CaloGeometry->etaBinCenter(indexToConv, true)) + 1);
1495 
1496     unsigned int convIndex = m_lutEtaCentralToCommonCalo[indexToConv];
1497 
1498     double convLowEdge = 0.;
1499     double convHighEdge = 0.;
1500 
1501     if (convIndex != badIndex) {
1502       convLowEdge = m_l1CaloGeometry->globalEtaBinLowEdge(convIndex);
1503       convHighEdge = m_l1CaloGeometry->globalEtaBinLowEdge(convIndex + 1);
1504     } else {
1505       // badIndex means a bad initialIndex
1506       lowEdgeToConv = 0.;
1507       highEdgeToConv = 0.;
1508     }
1509 
1510     myCout << "|  0x" << std::setw(3) << std::hex << std::left << indexToConv << "  |  " << std::dec << std::setw(3)
1511            << std::left << indexToConv << "  |[ " << std::setw(10) << std::left << lowEdgeToConv << ",  |"
1512            << std::setw(10) << std::left << highEdgeToConv << " )  |  0x" << std::setw(6) << std::hex << std::left
1513            << convIndex << " |  " << std::dec << std::setw(6) << convIndex << "  |[ " << std::setw(10) << std::left
1514            << convLowEdge << ",  |" << std::setw(10) << std::left << convHighEdge << " )  |" << std::right << std::endl;
1515   }
1516 
1517   // ForJet to a common central / forward calorimeter eta scale
1518 
1519   // force a page break before each group
1520   myCout << "<p style=\"page-break-before: always\">&nbsp;</p>";
1521 
1522   myCout << "\n---+++Eta conversion for forward jets to a common central and "
1523             "forward calorimeter eta scale \n"
1524          << std::endl;
1525 
1526   size_t lutEtaForJetToCommonCaloSize = m_lutEtaForJetToCommonCalo.size();
1527   myCout << "Size of look-up table = " << lutEtaForJetToCommonCaloSize << "\n" << std::endl;
1528 
1529   myCout << "|  *Initial Eta Hardware Index*  "
1530          << "||  *Initial Eta Range*  ||"
1531          << "  *Converted Eta Hardware Index*  "
1532          << "||  *Converted Eta Range*  ||"
1533          << "\n"
1534          << "|  *hex*  |  *dec*  | ^|^|  *hex*  |  *dec*  |^|^|" << std::endl;
1535 
1536   for (unsigned int indexToConv = 0; indexToConv < lutEtaForJetToCommonCaloSize; ++indexToConv) {
1537     double lowEdgeToConv = m_l1CaloGeometry->globalEtaBinLowEdge(
1538         m_l1CaloGeometry->globalEtaIndex(m_l1CaloGeometry->etaBinCenter(indexToConv, false)));
1539     double highEdgeToConv = m_l1CaloGeometry->globalEtaBinLowEdge(
1540         m_l1CaloGeometry->globalEtaIndex(m_l1CaloGeometry->etaBinCenter(indexToConv, false)) + 1);
1541 
1542     unsigned int convIndex = m_lutEtaForJetToCommonCalo[indexToConv];
1543 
1544     double convLowEdge = 0.;
1545     double convHighEdge = 0.;
1546 
1547     if (convIndex != badIndex) {
1548       convLowEdge = m_l1CaloGeometry->globalEtaBinLowEdge(convIndex);
1549       convHighEdge = m_l1CaloGeometry->globalEtaBinLowEdge(convIndex + 1);
1550     } else {
1551       // badIndex means a bad initialIndex
1552       lowEdgeToConv = 0.;
1553       highEdgeToConv = 0.;
1554     }
1555 
1556     myCout << "|  0x" << std::setw(3) << std::hex << std::left << indexToConv << "  |  " << std::dec << std::setw(3)
1557            << std::left << indexToConv << "  |[ " << std::setw(10) << std::left << lowEdgeToConv << ",  |"
1558            << std::setw(10) << std::left << highEdgeToConv << " )  |  0x" << std::setw(6) << std::hex << std::left
1559            << convIndex << " |  " << std::dec << std::setw(6) << convIndex << "  |[ " << std::setw(10) << std::left
1560            << convLowEdge << ",  |" << std::setw(10) << std::left << convHighEdge << " )  |" << std::right << std::endl;
1561   }
1562 
1563   // Mu to a common central / forward calorimeter eta scale
1564 
1565   // force a page break before each group
1566   myCout << "<p style=\"page-break-before: always\">&nbsp;</p>";
1567 
1568   myCout << "\n---+++Eta conversion for muons to a common central and forward "
1569             "calorimeter eta scale \n"
1570          << std::endl;
1571 
1572   size_t lutEtaMuToCommonCaloSize = m_lutEtaMuToCommonCalo.size();
1573   myCout << "Size of look-up table = " << lutEtaMuToCommonCaloSize << "\n" << std::endl;
1574 
1575   unsigned int nrBinsEtaMuPerHalf = m_l1MuTriggerScales->getGMTEtaScale()->getNBins();
1576 
1577   myCout << "|  *Initial Eta Hardware Index*  "
1578          << "||  *Initial Eta Range*  ||"
1579          << "  *Converted Eta Hardware Index*  "
1580          << "||  *Converted Eta Range*  ||"
1581          << "\n"
1582          << "|  *hex*  |  *dec*  | ^|^|  *hex*  |  *dec*  |^|^|" << std::endl;
1583 
1584   for (unsigned int indexToConv = 0; indexToConv < lutEtaMuToCommonCaloSize; ++indexToConv) {
1585     // Mu scale defined for positive values only, need to be symmetrized
1586     unsigned int iBinOffset = 0;
1587     double etaSign = 1.;
1588 
1589     if (indexToConv > nrBinsEtaMuPerHalf) {
1590       iBinOffset = nrBinsEtaMuPerHalf + 1;
1591       etaSign = -1.;
1592     }
1593 
1594     double lowEdgeToConv = etaSign * m_l1MuTriggerScales->getGMTEtaScale()->getValue(indexToConv - iBinOffset);
1595     double highEdgeToConv = etaSign * m_l1MuTriggerScales->getGMTEtaScale()->getValue(indexToConv + 1 - iBinOffset);
1596 
1597     unsigned int convIndex = m_lutEtaMuToCommonCalo[indexToConv];
1598 
1599     double convLowEdge = 0.;
1600     double convHighEdge = 0.;
1601 
1602     if (convIndex != badIndex) {
1603       convLowEdge = m_l1CaloGeometry->globalEtaBinLowEdge(convIndex);
1604       convHighEdge = m_l1CaloGeometry->globalEtaBinLowEdge(convIndex + 1);
1605     } else {
1606       // badIndex means a bad initialIndex
1607       lowEdgeToConv = 0.;
1608       highEdgeToConv = 0.;
1609     }
1610 
1611     myCout << "|  0x" << std::setw(3) << std::hex << std::left << indexToConv << "  |  " << std::dec << std::setw(3)
1612            << std::left << indexToConv << "  |[ " << std::setw(10) << std::left << lowEdgeToConv << ",  |"
1613            << std::setw(10) << std::left << highEdgeToConv << " )  |  0x" << std::setw(6) << std::hex << std::left
1614            << convIndex << " |  " << std::dec << std::setw(6) << convIndex << "  |[ " << std::setw(10) << std::left
1615            << convLowEdge << ",  |" << std::setw(10) << std::left << convHighEdge << " )  |" << std::right << std::endl;
1616   }
1617 }
1618 
1619 // convert phi from rad (-pi, pi] to deg (0, 360)
1620 const double L1GtEtaPhiConversions::rad2deg(const double &phiRad) const {
1621   if (phiRad < 0.) {
1622     return (phiRad * PiConversion) + 360.;
1623   } else {
1624     return (phiRad * PiConversion);
1625   }
1626 }
1627 
1628 // static members
1629 
1630 const unsigned int L1GtEtaPhiConversions::badIndex = 999999;
1631 const double L1GtEtaPhiConversions::PiConversion = 180. / acos(-1.);