CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/L1Trigger/GlobalTriggerAnalyzer/src/L1GetHistLimits.cc

Go to the documentation of this file.
00001 
00017 // this class header
00018 #include "L1Trigger/GlobalTriggerAnalyzer/interface/L1GetHistLimits.h"
00019 
00020 // system include files
00021 #include <iostream>
00022 #include <iomanip>
00023 #include <string>
00024 
00025 // user include files
00026 #include "L1Trigger/GlobalTriggerAnalyzer/interface/L1PhiConversion.h"
00027 #include "DataFormats/Math/interface/normalizedPhi.h"
00028 
00029 
00030 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctEtMiss.h"
00031 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctEtTotal.h"
00032 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctEtHad.h"
00033 
00034 #include "FWCore/Framework/interface/ESHandle.h"
00035 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00036 
00037 // constructor
00038 L1GetHistLimits::L1GetHistLimits(const edm::EventSetup& evSetup) :
00039     m_evSetup(evSetup) {
00040 
00041     //
00042 
00043 }
00044 
00045 // destructor
00046 L1GetHistLimits::~L1GetHistLimits() {
00047 
00048     // empty
00049 
00050 }
00051 
00052 void L1GetHistLimits::getHistLimits(const L1GtObject& l1GtObject,
00053         const std::string& quantity) {
00054 
00055     m_l1HistLimits.nrBins = 0;
00056     m_l1HistLimits.lowerBinValue = 0;
00057     m_l1HistLimits.upperBinValue = 0;
00058     m_l1HistLimits.binThresholds.clear();
00059 
00060 
00061     // number of objects is independent of the object type
00062     // and hardcoded in the actual version
00063     if (quantity == "NrObjects") {
00064 
00065         m_l1HistLimits.nrBins = 15;
00066         m_l1HistLimits.lowerBinValue = -0.5;
00067         m_l1HistLimits.upperBinValue = 14.5;
00068 
00069         m_l1HistLimits.binThresholds.resize(m_l1HistLimits.nrBins + 1);
00070 
00071         for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
00072             m_l1HistLimits.binThresholds[iBin] = m_l1HistLimits.lowerBinValue
00073                     + iBin * (m_l1HistLimits.upperBinValue
00074                             - m_l1HistLimits.lowerBinValue)
00075                             / m_l1HistLimits.nrBins;
00076 
00077         }
00078 
00079         // set last bin upper edge
00080         m_l1HistLimits.binThresholds[m_l1HistLimits.nrBins]
00081                 = m_l1HistLimits.upperBinValue;
00082 
00083         return;
00084 
00085     }
00086 
00087     switch (l1GtObject) {
00088         case Mu: {
00089 
00090             if (quantity == "PT") {
00091 
00092                 edm::ESHandle<L1MuTriggerPtScale> muPtScale;
00093                 m_evSetup.get<L1MuTriggerPtScaleRcd>().get(muPtScale);
00094 
00095                 m_l1HistLimits.nrBins = muPtScale->getPtScale()->getNBins();
00096                 m_l1HistLimits.lowerBinValue
00097                         = muPtScale->getPtScale()->getScaleMin();
00098                 m_l1HistLimits.upperBinValue
00099                         = muPtScale->getPtScale()->getScaleMax();
00100 
00101                 m_l1HistLimits.binThresholds.resize(m_l1HistLimits.nrBins + 1);
00102 
00103                 for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
00104                     m_l1HistLimits.binThresholds[iBin]
00105                             = muPtScale->getPtScale()->getValue(iBin);
00106 
00107                 }
00108 
00109                 // last limit for muon is set too high (10^6) - resize the last bin
00110 
00111                 float lastBinSize = m_l1HistLimits.upperBinValue
00112                         - m_l1HistLimits.binThresholds[m_l1HistLimits.nrBins - 1];
00113 
00114                 // limit the size of the last bin to maximum 200 GeV
00115                 float maxLaxtBinsize = 200;
00116                 if (lastBinSize >= maxLaxtBinsize) {
00117                     m_l1HistLimits.upperBinValue
00118                             = m_l1HistLimits.binThresholds[m_l1HistLimits.nrBins - 1]
00119                               + 2.* (m_l1HistLimits.binThresholds[m_l1HistLimits.nrBins - 1]
00120                               - m_l1HistLimits.binThresholds[m_l1HistLimits.nrBins - 2]);
00121                     LogDebug("L1GetHistLimits")
00122                             << "\n L1ExtraMuon: PT histogram"
00123                             << "\nm_l1HistLimits.upperBinValue truncated to = "
00124                             << m_l1HistLimits.upperBinValue << std::endl;
00125                 }
00126 
00127                 // set last bin upper edge
00128                 m_l1HistLimits.binThresholds[m_l1HistLimits.nrBins]
00129                         = m_l1HistLimits.upperBinValue;
00130 
00131             } else if (quantity == "eta" || quantity == "phi") {
00132                 edm::ESHandle<L1MuTriggerScales> muScales;
00133                 m_evSetup.get<L1MuTriggerScalesRcd>().get(muScales);
00134 
00135                 if (quantity == "eta") {
00136                     // eta scale defined for positive values - need to be symmetrized
00137                     int histNrBinsHalf = muScales->getGMTEtaScale()->getNBins();
00138                     m_l1HistLimits.lowerBinValue
00139                             = muScales->getGMTEtaScale()->getScaleMin();
00140                     m_l1HistLimits.upperBinValue
00141                             = muScales->getGMTEtaScale()->getScaleMax();
00142 
00143                     m_l1HistLimits.nrBins = 2 * histNrBinsHalf;
00144                     m_l1HistLimits.lowerBinValue
00145                             = -m_l1HistLimits.upperBinValue;
00146 
00147                     m_l1HistLimits.binThresholds.resize(m_l1HistLimits.nrBins + 1);
00148 
00149                     int iBin = 0;
00150                     for (int j = histNrBinsHalf; j > 0; j--, iBin++) {
00151                         m_l1HistLimits.binThresholds[iBin] = (-1)
00152                                 * muScales->getGMTEtaScale()->getValue(j);
00153                     }
00154                     for (int j = 0; j <= histNrBinsHalf; j++, iBin++) {
00155                         m_l1HistLimits.binThresholds[iBin]
00156                                 = muScales->getGMTEtaScale()->getValue(j);
00157                     }
00158 
00159                     // set last bin upper edge
00160                     m_l1HistLimits.binThresholds[m_l1HistLimits.nrBins]
00161                             = m_l1HistLimits.upperBinValue;
00162 
00163                 } else {
00164                     m_l1HistLimits.nrBins = muScales->getPhiScale()->getNBins();
00165                     m_l1HistLimits.lowerBinValue = rad2deg(
00166                             muScales->getPhiScale()->getScaleMin());
00167                     m_l1HistLimits.upperBinValue = rad2deg(
00168                             muScales->getPhiScale()->getScaleMax());
00169 
00170                     m_l1HistLimits.binThresholds.resize(m_l1HistLimits.nrBins
00171                             + 1);
00172 
00173                     for (int iBin = 0; iBin <= m_l1HistLimits.nrBins; iBin++) {
00174                         m_l1HistLimits.binThresholds[iBin] = rad2deg(
00175                                 muScales->getPhiScale()->getValue(iBin));
00176                     }
00177 
00178                     // set last bin upper edge
00179                     m_l1HistLimits.binThresholds[m_l1HistLimits.nrBins]
00180                             = m_l1HistLimits.upperBinValue;
00181 
00182                 }
00183 
00184             }
00185 
00186         }
00187             break;
00188         case NoIsoEG:
00189         case IsoEG: {
00190             // common scales for NoIsoEG and IsoEG
00191             if (quantity == "ET") {
00192                 edm::ESHandle<L1CaloEtScale> emScale;
00193                 m_evSetup.get<L1EmEtScaleRcd>().get(emScale);
00194 
00195                 std::vector<double> emThresholds = emScale->getThresholds();
00196                 m_l1HistLimits.nrBins = emThresholds.size();
00197                 m_l1HistLimits.lowerBinValue = emThresholds.at(0);
00198 
00199                 // FIXME high edge retrieval in the scale definition
00200                 // now, last bin has the same width like the last but one
00201                 m_l1HistLimits.upperBinValue
00202                         = emThresholds[m_l1HistLimits.nrBins - 1]
00203                           + (emThresholds[m_l1HistLimits.nrBins - 1]
00204                            - emThresholds[m_l1HistLimits.nrBins - 2]);
00205 
00206                 m_l1HistLimits.binThresholds.resize(m_l1HistLimits.nrBins + 1);
00207 
00208                 for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
00209                     m_l1HistLimits.binThresholds[iBin]
00210                             = static_cast<float>(emThresholds[iBin]);
00211 
00212                 }
00213 
00214                 // set last bin upper edge
00215                 m_l1HistLimits.binThresholds[m_l1HistLimits.nrBins]
00216                         = m_l1HistLimits.upperBinValue;
00217 
00218             } else if (quantity == "eta" || quantity == "phi") {
00219                 edm::ESHandle<L1CaloGeometry> caloGeomESH;
00220                 m_evSetup.get<L1CaloGeometryRecord>().get(caloGeomESH);
00221                 const L1CaloGeometry* caloGeomScales = caloGeomESH.product();
00222 
00223                 if (quantity == "eta") {
00224                     m_l1HistLimits.nrBins
00225                             = 2 * (caloGeomScales->numberGctCentralEtaBinsPerHalf()
00226                                + caloGeomScales->numberGctForwardEtaBinsPerHalf());
00227                     m_l1HistLimits.lowerBinValue
00228                             = caloGeomScales->globalEtaBinLowEdge(0);
00229                     m_l1HistLimits.upperBinValue
00230                             = caloGeomScales->globalEtaBinHighEdge(
00231                                     m_l1HistLimits.nrBins - 1);
00232 
00233                     m_l1HistLimits.binThresholds.resize(m_l1HistLimits.nrBins + 1);
00234 
00235                     for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
00236                         m_l1HistLimits.binThresholds[iBin]
00237                                 = caloGeomScales->globalEtaBinLowEdge(iBin);
00238                     }
00239 
00240                     // set last bin upper edge
00241                     m_l1HistLimits.binThresholds[m_l1HistLimits.nrBins]
00242                             = m_l1HistLimits.upperBinValue;
00243 
00244 
00245 
00246                 } else {
00247 
00248                     m_l1HistLimits.nrBins
00249                             = caloGeomScales->numberGctEmJetPhiBins();
00250                     m_l1HistLimits.binThresholds.resize(m_l1HistLimits.nrBins
00251                             + 1);
00252 
00253                     for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
00254 
00255                         m_l1HistLimits.binThresholds[iBin] = rad2deg(
00256                                 caloGeomScales->emJetPhiBinLowEdge(iBin));
00257 
00258                         // treat correctly the 10 deg anti-clockwise rotation
00259                         if (rad2deg(caloGeomScales->emJetPhiBinHighEdge(iBin))
00260                                 < m_l1HistLimits.binThresholds[iBin]) {
00261                             m_l1HistLimits.binThresholds[iBin]
00262                                     = m_l1HistLimits.binThresholds[iBin] - 360.;
00263                         }
00264 
00265                     }
00266 
00267                     m_l1HistLimits.lowerBinValue
00268                             = m_l1HistLimits.binThresholds[0];
00269 
00270                     // last bin upper limit
00271                     m_l1HistLimits.upperBinValue = rad2deg(
00272                             caloGeomScales->emJetPhiBinHighEdge(
00273                                     m_l1HistLimits.nrBins - 1));
00274 
00275                     m_l1HistLimits.binThresholds[m_l1HistLimits.nrBins]
00276                             = m_l1HistLimits.upperBinValue;
00277 
00278                 }
00279 
00280             }
00281 
00282         }
00283             break;
00284         case CenJet:
00285         case ForJet:
00286         case TauJet: {
00287             // common scales for all jets
00288             if (quantity == "ET") {
00289                 edm::ESHandle<L1CaloEtScale> jetScale;
00290                 m_evSetup.get<L1JetEtScaleRcd>().get(jetScale);
00291 
00292                 std::vector<double> jetThresholds = jetScale->getThresholds();
00293                 m_l1HistLimits.nrBins = jetThresholds.size();
00294                 m_l1HistLimits.lowerBinValue = jetThresholds.at(0);
00295 
00296                 // FIXME high edge retrieval in the scale definition
00297                 // now, last bin has the same width like the last but one
00298                 m_l1HistLimits.upperBinValue
00299                         = jetThresholds[m_l1HistLimits.nrBins - 1]
00300                           + (jetThresholds[m_l1HistLimits.nrBins - 1]
00301                            - jetThresholds[m_l1HistLimits.nrBins - 2]);
00302 
00303                 m_l1HistLimits.binThresholds.resize(m_l1HistLimits.nrBins + 1);
00304 
00305                 for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
00306                     m_l1HistLimits.binThresholds[iBin]
00307                             = static_cast<float>(jetThresholds[iBin]);
00308 
00309                 }
00310 
00311                 // set last bin upper edge
00312                 m_l1HistLimits.binThresholds[m_l1HistLimits.nrBins]
00313                         = m_l1HistLimits.upperBinValue;
00314 
00315             } else if (quantity == "eta" || quantity == "phi") {
00316                 edm::ESHandle<L1CaloGeometry> caloGeomESH;
00317                 m_evSetup.get<L1CaloGeometryRecord>().get(caloGeomESH);
00318                 const L1CaloGeometry* caloGeomScales = caloGeomESH.product();
00319 
00320                 if (quantity == "eta") {
00321                     m_l1HistLimits.nrBins
00322                             = 2 * (caloGeomScales->numberGctCentralEtaBinsPerHalf()
00323                                + caloGeomScales->numberGctForwardEtaBinsPerHalf());
00324                     m_l1HistLimits.lowerBinValue
00325                             = caloGeomScales->globalEtaBinLowEdge(0);
00326                     m_l1HistLimits.upperBinValue
00327                             = caloGeomScales->globalEtaBinHighEdge(
00328                                     m_l1HistLimits.nrBins - 1);
00329 
00330                     m_l1HistLimits.binThresholds.resize(m_l1HistLimits.nrBins + 1);
00331 
00332                     for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
00333                         m_l1HistLimits.binThresholds[iBin]
00334                                 = caloGeomScales->globalEtaBinLowEdge(iBin);
00335                     }
00336 
00337                     // set last bin upper edge
00338                     m_l1HistLimits.binThresholds[m_l1HistLimits.nrBins]
00339                             = m_l1HistLimits.upperBinValue;
00340 
00341                 } else {
00342 
00343                     m_l1HistLimits.nrBins
00344                             = caloGeomScales->numberGctEmJetPhiBins();
00345                     m_l1HistLimits.binThresholds.resize(m_l1HistLimits.nrBins
00346                             + 1);
00347 
00348                     for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
00349 
00350                         m_l1HistLimits.binThresholds[iBin] = rad2deg(
00351                                 caloGeomScales->emJetPhiBinLowEdge(iBin));
00352 
00353                         // treat correctly the 10 deg anti-clockwise rotation
00354                         if (rad2deg(caloGeomScales->emJetPhiBinHighEdge(iBin))
00355                                 < m_l1HistLimits.binThresholds[iBin]) {
00356                             m_l1HistLimits.binThresholds[iBin]
00357                                     = m_l1HistLimits.binThresholds[iBin] - 360.;
00358                         }
00359 
00360                     }
00361 
00362                     m_l1HistLimits.lowerBinValue
00363                             = m_l1HistLimits.binThresholds[0];
00364 
00365                     // last bin upper limit
00366                     m_l1HistLimits.upperBinValue = rad2deg(
00367                             caloGeomScales->emJetPhiBinHighEdge(
00368                                     m_l1HistLimits.nrBins - 1));
00369 
00370                     m_l1HistLimits.binThresholds[m_l1HistLimits.nrBins]
00371                             = m_l1HistLimits.upperBinValue;
00372 
00373                 }
00374 
00375             }
00376         }
00377             break;
00378         case ETM: {
00379             if (quantity == "ET") {
00380 
00381                 edm::ESHandle<L1CaloEtScale> etMissScale;
00382                 m_evSetup.get<L1JetEtScaleRcd>().get(etMissScale);
00383 
00384                 const double etSumLSB = etMissScale->linearLsb() ;
00385 
00386                 m_l1HistLimits.nrBins = L1GctEtMiss::kEtMissMaxValue;
00387 
00388                 m_l1HistLimits.lowerBinValue = 0;
00389                 m_l1HistLimits.upperBinValue = (m_l1HistLimits.nrBins + 1)
00390                         * etSumLSB;
00391 
00392                 m_l1HistLimits.binThresholds.resize(m_l1HistLimits.nrBins + 1);
00393 
00394                 for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
00395                     m_l1HistLimits.binThresholds[iBin] = iBin * etSumLSB;
00396 
00397                 }
00398 
00399                 // set last bin upper edge
00400                 m_l1HistLimits.binThresholds[m_l1HistLimits.nrBins]
00401                         = m_l1HistLimits.upperBinValue;
00402 
00403             } else if (quantity == "eta" || quantity == "phi") {
00404                 edm::ESHandle<L1CaloGeometry> caloGeomESH;
00405                 m_evSetup.get<L1CaloGeometryRecord>().get(caloGeomESH);
00406                 const L1CaloGeometry* caloGeomScales = caloGeomESH.product();
00407 
00408                 if (quantity == "eta") {
00409 
00410                     // do nothing, eta is not defined for ETM
00411 
00412                 } else {
00413                     m_l1HistLimits.nrBins
00414                             = caloGeomScales->numberGctEtSumPhiBins();
00415                     m_l1HistLimits.lowerBinValue = rad2deg(
00416                             caloGeomScales->etSumPhiBinLowEdge(0));
00417                     m_l1HistLimits.upperBinValue = rad2deg(
00418                             caloGeomScales->etSumPhiBinHighEdge(
00419                                     m_l1HistLimits.nrBins - 1));
00420 
00421                     m_l1HistLimits.binThresholds.resize(m_l1HistLimits.nrBins
00422                             + 1);
00423 
00424                     for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
00425                         m_l1HistLimits.binThresholds[iBin] = rad2deg(
00426                                 caloGeomScales->etSumPhiBinLowEdge(iBin));
00427 
00428                     }
00429 
00430                     // last bin upper limit
00431                     m_l1HistLimits.binThresholds[m_l1HistLimits.nrBins]
00432                             = m_l1HistLimits.upperBinValue;
00433 
00434                 }
00435 
00436             }
00437 
00438         }
00439             break;
00440         case ETT: {
00441             if (quantity == "ET") {
00442 
00443                 edm::ESHandle<L1CaloEtScale> etMissScale;
00444                 m_evSetup.get<L1JetEtScaleRcd>().get(etMissScale);
00445 
00446                 const double etSumLSB = etMissScale->linearLsb() ;
00447 
00448                 m_l1HistLimits.nrBins = L1GctEtTotal::kEtTotalMaxValue;
00449 
00450                 m_l1HistLimits.lowerBinValue = 0;
00451                 m_l1HistLimits.upperBinValue = (m_l1HistLimits.nrBins + 1)
00452                         * etSumLSB;
00453 
00454                 m_l1HistLimits.binThresholds.resize(m_l1HistLimits.nrBins + 1);
00455 
00456                 for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
00457                     m_l1HistLimits.binThresholds[iBin] = iBin * etSumLSB;
00458 
00459                 }
00460 
00461                 // set last bin upper edge
00462                 m_l1HistLimits.binThresholds[m_l1HistLimits.nrBins]
00463                         = m_l1HistLimits.upperBinValue;
00464 
00465             } else if (quantity == "eta" || quantity == "phi") {
00466 
00467                 // do nothing, eta and phi are not defined for ETT
00468 
00469             }
00470 
00471         }
00472             break;
00473         case HTT: {
00474             if (quantity == "ET") {
00475 
00476                 edm::ESHandle< L1GctJetFinderParams > jetFinderParams ;
00477                 m_evSetup.get< L1GctJetFinderParamsRcd >().get( jetFinderParams ) ;
00478                 double htSumLSB = jetFinderParams->getHtLsbGeV();
00479 
00480                 m_l1HistLimits.nrBins = L1GctEtHad::kEtHadMaxValue;
00481 
00482                 m_l1HistLimits.lowerBinValue = 0;
00483                 m_l1HistLimits.upperBinValue = (m_l1HistLimits.nrBins + 1)
00484                         * htSumLSB;
00485 
00486                 m_l1HistLimits.binThresholds.resize(m_l1HistLimits.nrBins + 1);
00487 
00488                 for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
00489                     m_l1HistLimits.binThresholds[iBin] = iBin * htSumLSB;
00490 
00491                 }
00492 
00493                 // set last bin upper edge
00494                 m_l1HistLimits.binThresholds[m_l1HistLimits.nrBins]
00495                         = m_l1HistLimits.upperBinValue;
00496 
00497             } else if (quantity == "eta" || quantity == "phi") {
00498 
00499                 // do nothing, eta and phi are not defined for HTT
00500 
00501             }
00502         }
00503             break;
00504         case HTM: {
00505             if (quantity == "ET") {
00506                 edm::ESHandle<L1CaloEtScale> htMissScale;
00507                 m_evSetup.get<L1HtMissScaleRcd>().get(htMissScale);
00508 
00509                 const std::vector<double>& htThresholds =
00510                         htMissScale->getThresholds();
00511                 m_l1HistLimits.nrBins = htThresholds.size();
00512                 m_l1HistLimits.lowerBinValue = htThresholds[0];
00513 
00514                 // FIXME high edge retrieval in the scale definition
00515                 // now, last bin has the same width like the last but one
00516                 m_l1HistLimits.upperBinValue
00517                         = htThresholds[m_l1HistLimits.nrBins - 1]
00518                           + (htThresholds[m_l1HistLimits.nrBins - 1]
00519                           - htThresholds[m_l1HistLimits.nrBins - 2]);
00520 
00521                 m_l1HistLimits.binThresholds.resize(m_l1HistLimits.nrBins + 1);
00522 
00523                 for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
00524                     m_l1HistLimits.binThresholds[iBin]
00525                             = static_cast<float>(htThresholds[iBin]);
00526 
00527                 }
00528 
00529                 // set last bin upper edge
00530                 m_l1HistLimits.binThresholds[m_l1HistLimits.nrBins]
00531                         = m_l1HistLimits.upperBinValue;
00532 
00533             } else if (quantity == "eta" || quantity == "phi") {
00534                 edm::ESHandle<L1CaloGeometry> caloGeomESH;
00535                 m_evSetup.get<L1CaloGeometryRecord>().get(caloGeomESH);
00536                 const L1CaloGeometry* caloGeomScales = caloGeomESH.product();
00537 
00538                 if (quantity == "eta") {
00539 
00540                     // do nothing, eta is not defined for HTM
00541 
00542                 } else {
00543                     m_l1HistLimits.nrBins
00544                             = caloGeomScales->numberGctHtSumPhiBins();
00545                     m_l1HistLimits.lowerBinValue = rad2deg(
00546                             caloGeomScales->htSumPhiBinLowEdge(0));
00547                     m_l1HistLimits.upperBinValue = rad2deg(
00548                             caloGeomScales->htSumPhiBinHighEdge(
00549                                     m_l1HistLimits.nrBins - 1));
00550 
00551                     m_l1HistLimits.binThresholds.resize(m_l1HistLimits.nrBins
00552                             + 1);
00553 
00554                     for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
00555                         m_l1HistLimits.binThresholds[iBin] = rad2deg(
00556                                 caloGeomScales->htSumPhiBinLowEdge(iBin));
00557 
00558                     }
00559 
00560                     // last bin upper limit
00561                     m_l1HistLimits.binThresholds[m_l1HistLimits.nrBins]
00562                             = m_l1HistLimits.upperBinValue;
00563 
00564                 }
00565 
00566             }
00567         }
00568             break;
00569         case JetCounts: {
00570 
00571         }
00572             break;
00573         case HfBitCounts: {
00574             // there are no scales for HfBitCounts, so one implements a fixed scale
00575             // use same values as GCT for 3 bits
00576             const unsigned int R3BINS = 8;
00577             const float R3MIN = -0.5;
00578             const float R3MAX = 7.5;
00579 
00580             m_l1HistLimits.nrBins
00581                     = R3BINS;
00582             m_l1HistLimits.lowerBinValue
00583                     = R3MIN;
00584             m_l1HistLimits.upperBinValue
00585                     = R3MAX;
00586 
00587             m_l1HistLimits.binThresholds.resize(m_l1HistLimits.nrBins
00588                     + 1);
00589 
00590             for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
00591                 m_l1HistLimits.binThresholds[iBin]
00592                         = R3MIN + iBin*(R3MAX - R3MIN)/R3BINS;
00593 
00594             }
00595 
00596             // last bin upper limit
00597             m_l1HistLimits.binThresholds[m_l1HistLimits.nrBins]
00598                     = m_l1HistLimits.upperBinValue;
00599 
00600 
00601 
00602         }
00603             break;
00604         case HfRingEtSums: {
00605             if (quantity == "ET") {
00606                 edm::ESHandle<L1CaloEtScale> hfRingEtScale;
00607                 m_evSetup.get<L1HfRingEtScaleRcd>().get(hfRingEtScale);
00608 
00609                 const std::vector<double>& hfRingEtThresholds =
00610                         hfRingEtScale->getThresholds();
00611                 m_l1HistLimits.nrBins = hfRingEtThresholds.size();
00612                 m_l1HistLimits.lowerBinValue = hfRingEtThresholds[0];
00613 
00614                 // FIXME high edge retrieval in the scale definition
00615                 // now, last bin has the same width like the last but one
00616                 m_l1HistLimits.upperBinValue
00617                         = hfRingEtThresholds[m_l1HistLimits.nrBins - 1]
00618                           + (hfRingEtThresholds[m_l1HistLimits.nrBins - 1]
00619                           - hfRingEtThresholds[m_l1HistLimits.nrBins - 2]);
00620 
00621                 m_l1HistLimits.binThresholds.resize(m_l1HistLimits.nrBins + 1);
00622 
00623                 for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
00624                     m_l1HistLimits.binThresholds[iBin]
00625                             = static_cast<float>(hfRingEtThresholds[iBin]);
00626 
00627                 }
00628 
00629                 // set last bin upper edge
00630                 m_l1HistLimits.binThresholds[m_l1HistLimits.nrBins]
00631                         = m_l1HistLimits.upperBinValue;
00632 
00633             } else if (quantity == "eta" || quantity == "phi") {
00634 
00635                 // do nothing, eta and phi are not defined for HfRingEtSums
00636             }
00637         }
00638             break;
00639         case TechTrig:
00640         case Castor:
00641         case BPTX:
00642         default: {
00643 
00644             // do nothing, for these cases ET/PT, eta and phi are not defined
00645 
00646         }
00647             break;
00648     }
00649 
00650 }
00651 
00652 const L1GetHistLimits::L1HistLimits& L1GetHistLimits::l1HistLimits(
00653         const L1GtObject& l1GtObject, const std::string& quantity) {
00654 
00655     getHistLimits(l1GtObject, quantity);
00656 
00657     if (edm::isDebugEnabled()) {
00658         LogDebug("L1GetHistLimits") << "\n Histogram limits for L1GtObject "
00659                 << l1GtObject << " and quantity " << quantity
00660                 << "\n  Number of bins:           " << m_l1HistLimits.nrBins
00661                 << "\n  Lower limit of first bin: "
00662                 << m_l1HistLimits.lowerBinValue
00663                 << "\n  Upper limit of last bin:  "
00664                 << m_l1HistLimits.upperBinValue << std::endl;
00665 
00666         int binThreshSize = static_cast<int>(m_l1HistLimits.binThresholds.size());
00667 
00668         if (binThreshSize != (m_l1HistLimits.nrBins + 1)) {
00669 
00670             LogTrace("L1GetHistLimits")
00671                     << "\n Warning: inconsistent nrBins and binThresholds size"
00672                     << "\n   Number of bins nrBins = " << m_l1HistLimits.nrBins
00673                     << "\n   binThresholds size =    " << binThreshSize
00674                     << "\n Please fix the L1GetLimits class.\n\n" << std::endl;
00675 
00676         }
00677 
00678         for (int iBin = 0; iBin < binThreshSize; ++iBin) {
00679             LogTrace("L1GetHistLimits") << " Bin " << std::right
00680                     << std::setw(5) << iBin << ":  "
00681                     << m_l1HistLimits.binThresholds[iBin] << std::endl;
00682 
00683         }
00684     }
00685 
00686     return m_l1HistLimits;
00687 
00688 }
00689 
00690 
00691 const L1GetHistLimits::L1HistLimits& L1GetHistLimits::l1HistLimits(
00692         const L1GtObject& l1GtObject, const std::string& quantity,
00693         const double histMinValue, const double histMaxValue) {
00694 
00695     getHistLimits(l1GtObject, quantity);
00696 
00697     bool foundLowerBinValue = false;
00698     bool foundUpperBinValue = false;
00699 
00700     for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
00701         if (m_l1HistLimits.binThresholds[iBin] <= histMinValue) {
00702             m_l1HistLimits.lowerBinValue = m_l1HistLimits.binThresholds[iBin];
00703             foundLowerBinValue = true;
00704             break;
00705         }
00706     }
00707 
00708     for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
00709         if (m_l1HistLimits.binThresholds[iBin] > histMaxValue) {
00710             m_l1HistLimits.upperBinValue = m_l1HistLimits.binThresholds[iBin];
00711             foundUpperBinValue = true;
00712             break;
00713         }
00714     }
00715 
00716     if (foundLowerBinValue && foundUpperBinValue) {
00717 
00718         int countBins = -1;
00719         std::vector<float> binThresh;
00720         binThresh.reserve(m_l1HistLimits.binThresholds.size());
00721 
00722         for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
00723             if ((m_l1HistLimits.binThresholds[iBin] >= histMinValue)
00724                     && m_l1HistLimits.binThresholds[iBin] < histMaxValue) {
00725                 m_l1HistLimits.upperBinValue
00726                         = m_l1HistLimits.binThresholds[iBin];
00727 
00728                 countBins++;
00729                 binThresh.push_back(m_l1HistLimits.binThresholds[iBin]);
00730 
00731             }
00732         }
00733 
00734         m_l1HistLimits.nrBins = countBins;
00735         m_l1HistLimits.binThresholds.clear();
00736         m_l1HistLimits.binThresholds = binThresh;
00737 
00738         // FIXME last bin untested.
00739 
00740     } else {
00741         m_l1HistLimits.nrBins = 0;
00742         m_l1HistLimits.lowerBinValue = 0;
00743         m_l1HistLimits.upperBinValue = 0;
00744         m_l1HistLimits.binThresholds.clear();
00745 
00746         LogDebug("L1GetHistLimits") << "\n Histogram limits for L1GtObject"
00747                 << l1GtObject << " and quantity " << quantity
00748                 << " within the required range [" << histMinValue << ", "
00749                 << histMaxValue << "] not found."
00750                 << "\n The range is not included in the original histogram range."
00751                 << std::endl;
00752 
00753         return m_l1HistLimits;
00754 
00755     }
00756 
00757     if (edm::isDebugEnabled()) {
00758         LogDebug("L1GetHistLimits") << "\n Histogram limits for L1GtObject"
00759                 << l1GtObject << " and quantity " << quantity
00760                 << "\n  Number of bins:           " << m_l1HistLimits.nrBins
00761                 << "\n  Lower limit of first bin: "
00762                 << m_l1HistLimits.lowerBinValue
00763                 << "\n  Upper limit of last bin:  "
00764                 << m_l1HistLimits.upperBinValue << std::endl;
00765 
00766         int binThreshSize = static_cast<int>(m_l1HistLimits.binThresholds.size());
00767 
00768         if (binThreshSize != (m_l1HistLimits.nrBins + 1)) {
00769 
00770             LogTrace("L1GetHistLimits")
00771                     << "\n Warning: inconsistent nrBins and binThresholds size"
00772                     << "\n   Number of bins nrBins = " << m_l1HistLimits.nrBins
00773                     << "\n   binThresholds size =    " << binThreshSize
00774                     << "\n Please fix the L1GetLimits class.\n\n" << std::endl;
00775 
00776         }
00777 
00778         for (int iBin = 0; iBin < binThreshSize; ++iBin) {
00779             LogTrace("L1GetHistLimits") << " Bin " << std::right
00780                     << std::setw(5) << iBin << ":  "
00781                     << m_l1HistLimits.binThresholds[iBin] << std::endl;
00782 
00783         }
00784     }
00785 
00786 
00787     return m_l1HistLimits;
00788 
00789 }
00790 
00791 
00792 const int L1GetHistLimits::l1HistNrBins(const L1GtObject& l1GtObject,
00793         const std::string& quantity) {
00794 
00795     getHistLimits(l1GtObject, quantity);
00796     return m_l1HistLimits.nrBins;
00797 
00798 }
00799 
00800 const double L1GetHistLimits::l1HistLowerBinValue(const L1GtObject& l1GtObject,
00801         const std::string& quantity) {
00802 
00803     getHistLimits(l1GtObject, quantity);
00804     return m_l1HistLimits.lowerBinValue;
00805 
00806 }
00807 
00808 const double L1GetHistLimits::l1HistUpperBinValue(const L1GtObject& l1GtObject,
00809         const std::string& quantity) {
00810 
00811     getHistLimits(l1GtObject, quantity);
00812     return m_l1HistLimits.upperBinValue;
00813 
00814 }
00815 
00816 const std::vector<float>& L1GetHistLimits::l1HistBinThresholds(
00817         const L1GtObject& l1GtObject, const std::string& quantity) {
00818 
00819     getHistLimits(l1GtObject, quantity);
00820     return m_l1HistLimits.binThresholds;
00821 
00822 }