Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:17

0001 //
0002 // Original Author:  Fedor Ratnikov Nov 9, 2007
0003 // $Id: JetCorrectorParameters.h,v 1.15 2012/03/01 18:24:52 srappocc Exp $
0004 //
0005 // Generic parameters for Jet corrections
0006 //
0007 #ifndef JetCorrectorParametersHelper_h
0008 #define JetCorrectorParametersHelper_h
0009 
0010 #include "CondFormats/JetMETObjects/interface/JetCorrectorParameters.h"
0011 #include "CondFormats/JetMETObjects/interface/Utilities.h"
0012 
0013 #include <string>
0014 #include <vector>
0015 #include <tuple>
0016 #include <algorithm>
0017 #include <functional>
0018 #include <iostream>
0019 #include "FWCore/Utilities/interface/Exception.h"
0020 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0021 
0022 //---------- JetCorrectorParametersHelper class ----------------
0023 //-- The helper is used to find the correct Record to access ---
0024 class JetCorrectorParametersHelper {
0025 public:
0026   //-------- Member functions ----------
0027   unsigned size() const { return mIndexMap.size(); }
0028   void initTransientMaps();
0029   void init(const JetCorrectorParameters::Definitions& mDefinitions,
0030             const std::vector<JetCorrectorParameters::Record>& mRecords);
0031   void checkMiddleBinUniformity(const std::vector<JetCorrectorParameters::Record>& mRecords) const;
0032   void binIndexChecks(unsigned N, const std::vector<float>& fX) const;
0033   bool binBoundChecks(unsigned dim, const float& value, const float& min, const float& max) const;
0034   int binIndexN(const std::vector<float>& fX, const std::vector<JetCorrectorParameters::Record>& mRecords) const;
0035 
0036   using tuple_type = typename generate_tuple_type<float, JetCorrectorParameters::MAX_SIZE_DIMENSIONALITY>::type;
0037   using tuple_type_Nm1 = typename generate_tuple_type<float, JetCorrectorParameters::MAX_SIZE_DIMENSIONALITY - 1>::type;
0038 
0039 private:
0040   //-------- Member variables ----------
0041   // Stores the lower and upper bounds of the bins for each binned dimension
0042   std::vector<std::vector<float> > mBinBoundaries;
0043   // Maps a set of lower bounds for N binned dimensions to the index in mRecords
0044   std::unordered_map<tuple_type, size_t> mIndexMap;
0045   // Maps a set of lower bounds for the first N-1 dimensions to the range of lower bound indices mBinBoundaries for the N dimension
0046   std::unordered_map<tuple_type_Nm1, std::pair<size_t, size_t> > mMap;
0047   // The number of binned dimensions as given by the JetCorrectorParameters::Definitions class
0048   unsigned SIZE;
0049 };
0050 
0051 #endif