CMS 3D CMS Logo

CovarianceParameterization.h
Go to the documentation of this file.
1 #ifndef _DataFormats_PatCandidates_CovarianceParameterization_h_
2 #define _DataFormats_PatCandidates_CovarianceParameterization_h_
3 #include <TFile.h>
4 #include <TH3D.h>
5 #include <iostream>
6 #include <unordered_map>
7 #include <array>
8 #include <TKey.h>
10 public:
11  enum Method { float16 = 0, reduceMantissa = 1, logPack = 2, tanLogPack = 3, zero = 4, one = 5 };
12  enum Target { realValue = 0, ratioToRef = 1, differenceToRef = 2 };
14  CompressionElement(Method m, Target t, int bitsUsed, std::vector<float> p)
15  : method(m), target(t), bits(bitsUsed), params(p) {}
18  int bits;
19  std::vector<float> params;
20  uint16_t pack(float value, float ref = 0.) const;
21  float unpack(uint16_t packed, float ref = 0.) const;
22 };
23 
25 public:
26  static int index(int i, int j) {
27  if (i >= j)
28  return j + i * (i + 1) / 2;
29  else
30  return i + j * (j + 1) / 2;
31  }
34  std::array<CompressionElement, 15> elements;
35  CompressionElement &operator()(int i, int j) { return elements[index(i, j)]; }
36  const CompressionElement &operator()(int i, int j) const { return elements[index(i, j)]; }
37  };
39  bool isValid() const { return loadedVersion_ != -1; }
40  int loadedVersion() const { return loadedVersion_; }
41  void load(int version);
42  float meanValue(
43  int i, int j, int sign, float pt, float eta, int nHits, int pixelHits, float cii = 1., float cjj = 1.) const;
44  float pack(float value,
45  int schema,
46  int i,
47  int j,
48  float pt,
49  float eta,
50  int nHits,
51  int pixelHits,
52  float cii = 1.,
53  float cjj = 1.) const;
54  float unpack(uint16_t packed,
55  int schema,
56  int i,
57  int j,
58  float pt,
59  float eta,
60  int nHits,
61  int pixelHits,
62  float cii = 1.,
63  float cjj = 1.) const;
64 
65 private:
66  void readFile(TFile &);
67  void addTheHistogram(
68  std::vector<TH3D *> *HistoVector, std::string StringToAddInTheName, int i, int j, TFile &fileToRead);
70  TFile *fileToRead_;
71  std::unordered_map<uint16_t, CompressionSchema> schemas;
72  std::vector<TH3D *> cov_elements_pixelHit;
73  std::vector<TH3D *> cov_elements_noPixelHit;
74 };
75 
76 #endif
CompressionElement(Method m, Target t, int bitsUsed, std::vector< float > p)
std::vector< float > params
float unpack(uint16_t packed, float ref=0.) const
float meanValue(int i, int j, int sign, float pt, float eta, int nHits, int pixelHits, float cii=1., float cjj=1.) const
float unpack(uint16_t packed, int schema, int i, int j, float pt, float eta, int nHits, int pixelHits, float cii=1., float cjj=1.) const
uint16_t pack(float value, float ref=0.) const
float pack(float value, int schema, int i, int j, float pt, float eta, int nHits, int pixelHits, float cii=1., float cjj=1.) const
Definition: value.py:1
std::vector< TH3D * > cov_elements_pixelHit
void addTheHistogram(std::vector< TH3D *> *HistoVector, std::string StringToAddInTheName, int i, int j, TFile &fileToRead)
TupleMultiplicity< TrackerTraits > const *__restrict__ uint32_t nHits
std::unordered_map< uint16_t, CompressionSchema > schemas
const CompressionElement & operator()(int i, int j) const
std::vector< TH3D * > cov_elements_noPixelHit