5 #include <boost/format.hpp> 7 #include <TParameter.h> 18 toCompress = value / ref;
21 toCompress = value - ref;
42 return *
reinterpret_cast<uint16_t *
>(&
r);
70 return unpacked * ref;
72 return unpacked + ref;
80 (
boost::format(
"DataFormats/PatCandidates/data/CovarianceParameterization_version%d.root") % version).
str());
81 fileToRead_ = TFile::Open(fip.
fullPath().c_str());
82 TFile &fileToRead = *fileToRead_;
84 if (fileToRead.IsOpen()) {
87 TIter
next(((TDirectoryFile *)fileToRead.Get(
"schemas"))->GetListOfKeys());
89 while ((key = (TKey *)
next())) {
90 TClass *
cl = gROOT->GetClass(key->GetClassName());
91 if (!cl->InheritsFrom(
"TDirectoryFile"))
93 std::string schemaNumber = key->ReadObj()->GetName();
94 uint16_t schemaN = std::stoi(schemaNumber);
97 for (
int i = 0;
i < 5;
i++) {
98 for (
int j =
i;
j < 5;
j++) {
103 std::vector<float> vParams;
104 TVector *
p = (TVector *)fileToRead.Get((folder +
"/param").c_str());
105 for (
int k = 0;
k < p->GetNoElements();
k++) {
106 vParams.push_back((*p)[
k]);
112 (
int)((TParameter<int> *)fileToRead.Get(bitString.c_str()))->GetVal(),
116 schemas[schemaN] = schema;
126 for (
int i = 0;
i < 5;
i++) {
127 for (
int j =
i;
j < 5;
j++) {
131 addTheHistogram(&cov_elements_pixelHit, String_first_positive,
i,
j, f);
132 addTheHistogram(&cov_elements_noPixelHit, String_second_positive,
i,
j, f);
138 std::vector<TH3D *> *HistoVector,
std::string StringToAddInTheName,
int i,
int j, TFile &fileToRead) {
139 std::string List_covName[5] = {
"qoverp",
"lambda",
"phi",
"dxy",
"dsz"};
141 std::string histoNameString =
"covariance_" + List_covName[
i] +
"_" + List_covName[
j] + StringToAddInTheName +
143 TH3D *matrixElememtHistogramm = (TH3D *)fileToRead.Get(histoNameString.c_str());
144 HistoVector->push_back(matrixElememtHistogramm);
148 int i,
int j,
int sign,
float pt,
float eta,
int nHits,
int pixelHits,
float cii,
float cjj)
const {
149 int hitNumberToUse = nHits;
150 if (hitNumberToUse < 2)
152 if (hitNumberToUse > 32)
154 int ptBin = cov_elements_pixelHit[0]->GetXaxis()->FindBin(pt);
155 int etaBin = cov_elements_pixelHit[0]->GetYaxis()->FindBin(
std::abs(eta));
156 int hitBin = cov_elements_pixelHit[0]->GetZaxis()->FindBin(hitNumberToUse);
165 int indexOfTheHitogramInTheList = ((9 - min_idx) * min_idx) / 2 + max_idx;
167 double meanValue = 0.;
169 meanValue = sign * cov_elements_pixelHit[indexOfTheHitogramInTheList]->GetBinContent(ptBin, etaBin, hitBin);
171 meanValue = sign * cov_elements_noPixelHit[indexOfTheHitogramInTheList]->GetBinContent(ptBin, etaBin, hitBin);
177 float value,
int schema,
int i,
int j,
float pt,
float eta,
int nHits,
int pixelHits,
float cii,
float cjj)
const {
180 float ref = meanValue(i, j, 1., pt, eta, nHits, pixelHits, cii, cjj);
184 if (schema == 0 && i == j && (i == 2 || i == 0))
185 ref = 1. / (pt *
pt);
190 return (*schemas.find(schema)).
second(i, j).pack(value, ref);
193 uint16_t packed,
int schema,
int i,
int j,
float pt,
float eta,
int nHits,
int pixelHits,
float cii,
float cjj)
197 float ref = meanValue(i, j, 1., pt, eta, nHits, pixelHits, cii, cjj);
201 if (schema == 0 && i == j && (i == 2 || i == 0))
202 ref = 1. / (pt *
pt);
203 if (i == j && (*schemas.find(schema)).
second(i, j).unpack(packed, ref) == 0)
206 return (*schemas.find(schema)).
second(i, j).unpack(packed, ref);
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
void addTheHistogram(std::vector< TH3D * > *HistoVector, std::string StringToAddInTheName, int i, int j, TFile &fileToRead)
double unpack16log(int16_t i, double lmin, double lmax, uint16_t base=32768)
static float float16to32(uint16_t h)
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
U second(std::pair< T, U > const &p)
std::vector< float > params
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
static uint16_t float32to16(float x)
Abs< T >::type abs(const T &t)
uint16_t pack(float value, 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
std::string fullPath() const
float unpack(uint16_t packed, float ref=0.) const
int16_t pack16log(double x, double lmin, double lmax, uint16_t base=32768)
static float reduceMantissaToNbits(const float &f)