CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
CovarianceParameterization Class Reference

#include <CovarianceParameterization.h>

Classes

struct  CompressionSchema
 

Public Member Functions

 CovarianceParameterization ()
 
bool isValid () const
 
void load (int version)
 
int loadedVersion () 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 pack (float value, int schema, int i, int j, 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
 

Static Public Member Functions

static int index (int i, int j)
 

Private Member Functions

void addTheHistogram (std::vector< TH3D * > *HistoVector, std::string StringToAddInTheName, int i, int j, TFile &fileToRead)
 
void readFile (TFile &)
 

Private Attributes

std::vector< TH3D * > cov_elements_noPixelHit
 
std::vector< TH3D * > cov_elements_pixelHit
 
TFile * fileToRead_
 
int loadedVersion_
 
std::unordered_map< uint16_t, CompressionSchemaschemas
 

Detailed Description

Definition at line 24 of file CovarianceParameterization.h.

Constructor & Destructor Documentation

◆ CovarianceParameterization()

CovarianceParameterization::CovarianceParameterization ( )
inline

Definition at line 38 of file CovarianceParameterization.h.

38 : loadedVersion_(-1) {}

Member Function Documentation

◆ addTheHistogram()

void CovarianceParameterization::addTheHistogram ( std::vector< TH3D * > *  HistoVector,
std::string  StringToAddInTheName,
int  i,
int  j,
TFile &  fileToRead 
)
private

Definition at line 141 of file CovarianceParameterization.cc.

142  {
143  std::string List_covName[5] = {"qoverp", "lambda", "phi", "dxy", "dsz"};
144 
145  std::string histoNameString = "covariance_" + List_covName[i] + "_" + List_covName[j] + StringToAddInTheName +
146  "parametrization"; // + "_entries";
147  TH3D *matrixElememtHistogramm = (TH3D *)fileToRead.Get(histoNameString.c_str());
148  HistoVector->push_back(matrixElememtHistogramm);
149 }

References mps_fire::i, dqmiolumiharvest::j, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by readFile().

◆ index()

static int CovarianceParameterization::index ( int  i,
int  j 
)
inlinestatic

Definition at line 26 of file CovarianceParameterization.h.

26  {
27  if (i >= j)
28  return j + i * (i + 1) / 2;
29  else
30  return i + j * (j + 1) / 2;
31  }

References mps_fire::i, and dqmiolumiharvest::j.

Referenced by BeautifulSoup.PageElement::insert(), and CovarianceParameterization::CompressionSchema::operator()().

◆ isValid()

bool CovarianceParameterization::isValid ( void  ) const
inline

◆ load()

void CovarianceParameterization::load ( int  version)

Definition at line 81 of file CovarianceParameterization.cc.

81  {
82  edm::FileInPath fip(
83  fmt::sprintf("DataFormats/PatCandidates/data/CovarianceParameterization_version%d.root", version));
84  fileToRead_ = TFile::Open(fip.fullPath().c_str());
85  TFile &fileToRead = *fileToRead_;
86  //Read files from here fip.fullPath().c_str();
87  if (fileToRead.IsOpen()) {
88  readFile(fileToRead);
89 
90  TIter next(((TDirectoryFile *)fileToRead.Get("schemas"))->GetListOfKeys());
91  TKey *key;
92  while ((key = (TKey *)next())) {
93  TClass *cl = gROOT->GetClass(key->GetClassName());
94  if (!cl->InheritsFrom("TDirectoryFile"))
95  continue;
96  std::string schemaNumber = key->ReadObj()->GetName();
97  uint16_t schemaN = std::stoi(schemaNumber);
98  //for (int folderNumber = 0; folderNumber < 6 ; folderNumber++) {
99  CompressionSchema schema;
100  for (int i = 0; i < 5; i++) {
101  for (int j = i; j < 5; j++) { //FILLING ONLY THE SCHEMA OF SOME ELEMENTS
102  std::string folder = "schemas/" + schemaNumber + "/" + char(48 + i) + char(48 + j);
103  std::string methodString = folder + "/method";
104  std::string targetString = folder + "/target";
105  std::string bitString = folder + "/bit";
106  std::vector<float> vParams;
107  TVector *p = (TVector *)fileToRead.Get((folder + "/param").c_str());
108  vParams.reserve(p->GetNoElements());
109  for (int k = 0; k < p->GetNoElements(); k++) {
110  vParams.push_back((*p)[k]);
111  }
112 
113  schema(i, j) = CompressionElement(
114  (CompressionElement::Method)((TParameter<int> *)fileToRead.Get(methodString.c_str()))->GetVal(),
115  (CompressionElement::Target)((TParameter<int> *)fileToRead.Get(targetString.c_str()))->GetVal(),
116  (int)((TParameter<int> *)fileToRead.Get(bitString.c_str()))->GetVal(),
117  vParams);
118  }
119  }
120  schemas[schemaN] = schema;
121  }
122 
124  } else {
125  loadedVersion_ = -1;
126  }
127 }

References GetRecoTauVFromDQM_MC_cff::cl, fileToRead_, printsummarytable::folder, edm::FileInPath::fullPath(), mps_fire::i, createfilelist::int, dqmiolumiharvest::j, dqmdumpme::k, crabWrapper::key, loadedVersion_, GetRecoTauVFromDQM_MC_cff::next, AlCaHLTBitMon_ParallelJobs::p, readFile(), schemas, AlCaHLTBitMon_QueryRunRegistry::string, and BeamSplash_cfg::version.

Referenced by pat::PackedCandidate::covarianceParameterization().

◆ loadedVersion()

int CovarianceParameterization::loadedVersion ( ) const
inline

Definition at line 40 of file CovarianceParameterization.h.

40 { return loadedVersion_; }

References loadedVersion_.

Referenced by pat::PackedCandidate::covarianceParameterization().

◆ meanValue()

float CovarianceParameterization::meanValue ( int  i,
int  j,
int  sign,
float  pt,
float  eta,
int  nHits,
int  pixelHits,
float  cii = 1.,
float  cjj = 1. 
) const

Definition at line 151 of file CovarianceParameterization.cc.

152  {
153  int hitNumberToUse = nHits;
154  if (hitNumberToUse < 2)
155  hitNumberToUse = 2;
156  if (hitNumberToUse > 32)
157  hitNumberToUse = 32;
158  int ptBin = cov_elements_pixelHit[0]->GetXaxis()->FindBin(pt);
159  int etaBin = cov_elements_pixelHit[0]->GetYaxis()->FindBin(std::abs(eta));
160  int hitBin = cov_elements_pixelHit[0]->GetZaxis()->FindBin(hitNumberToUse);
161  int min_idx = i;
162  int max_idx = j;
163 
164  if (i > j) {
165  min_idx = j;
166  max_idx = i;
167  }
168 
169  int indexOfTheHitogramInTheList = ((9 - min_idx) * min_idx) / 2 + max_idx;
170 
171  double meanValue = 0.;
172  if (pixelHits > 0) {
173  meanValue = sign * cov_elements_pixelHit[indexOfTheHitogramInTheList]->GetBinContent(ptBin, etaBin, hitBin);
174  } else {
175  meanValue = sign * cov_elements_noPixelHit[indexOfTheHitogramInTheList]->GetBinContent(ptBin, etaBin, hitBin);
176  }
177  return meanValue;
178 }

References funct::abs(), cov_elements_noPixelHit, cov_elements_pixelHit, PVValHelper::eta, etaBin(), mps_fire::i, dqmiolumiharvest::j, DiDispStaMuonMonitor_cfi::pt, muonRecoAnalyzer_cfi::ptBin, and Validation_hcalonly_cfi::sign.

Referenced by pack(), and unpack().

◆ pack()

float CovarianceParameterization::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 at line 180 of file CovarianceParameterization.cc.

181  {
182  if (i > j)
183  std::swap(i, j);
184  float ref = meanValue(i, j, 1., pt, eta, nHits, pixelHits, cii, cjj);
185  if (ref == 0) {
186  schema = 0;
187  }
188  if (schema == 0 && i == j && (i == 2 || i == 0))
189  ref = 1. / (pt * pt);
190  /* //Used for debugging, to be later removed
191  uint16_t p=(*schemas.find(schema)).second(i,j).pack(value,ref);
192  float up=(*schemas.find(schema)).second(i,j).unpack(p,ref);
193  std::cout << "check " << i << " " << j << " " << value << " " << up << " " << p << " " << ref << " " << schema<< std::endl;*/
194  return (*schemas.find(schema)).second(i, j).pack(value, ref);
195 }

References PVValHelper::eta, mps_fire::i, dqmiolumiharvest::j, meanValue(), DiDispStaMuonMonitor_cfi::pt, schemas, edm::second(), and std::swap().

Referenced by pat::PackedCandidate::packCovarianceElement().

◆ readFile()

void CovarianceParameterization::readFile ( TFile &  f)
private

Definition at line 129 of file CovarianceParameterization.cc.

129  {
130  for (int i = 0; i < 5; i++) {
131  for (int j = i; j < 5; j++) {
132  std::string String_first_positive = "_pixel_";
133  std::string String_second_positive = "_noPixel_";
134 
135  addTheHistogram(&cov_elements_pixelHit, String_first_positive, i, j, f);
136  addTheHistogram(&cov_elements_noPixelHit, String_second_positive, i, j, f);
137  }
138  }
139 }

References addTheHistogram(), cov_elements_noPixelHit, cov_elements_pixelHit, f, mps_fire::i, dqmiolumiharvest::j, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by load().

◆ unpack()

float CovarianceParameterization::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

Definition at line 196 of file CovarianceParameterization.cc.

198  {
199  if (i > j)
200  std::swap(i, j);
201  float ref = meanValue(i, j, 1., pt, eta, nHits, pixelHits, cii, cjj);
202  if (ref == 0) {
203  schema = 0;
204  }
205  if (schema == 0 && i == j && (i == 2 || i == 0))
206  ref = 1. / (pt * pt);
207  if (i == j && (*schemas.find(schema)).second(i, j).unpack(packed, ref) == 0)
208  return 1e-9;
209  else
210  return (*schemas.find(schema)).second(i, j).unpack(packed, ref);
211 }

References MillePedeFileConverter_cfg::e, PVValHelper::eta, mps_fire::i, dqmiolumiharvest::j, meanValue(), DiDispStaMuonMonitor_cfi::pt, schemas, edm::second(), and std::swap().

Referenced by pat::PackedCandidate::unpackCovarianceElement().

Member Data Documentation

◆ cov_elements_noPixelHit

std::vector<TH3D *> CovarianceParameterization::cov_elements_noPixelHit
private

Definition at line 73 of file CovarianceParameterization.h.

Referenced by meanValue(), and readFile().

◆ cov_elements_pixelHit

std::vector<TH3D *> CovarianceParameterization::cov_elements_pixelHit
private

Definition at line 72 of file CovarianceParameterization.h.

Referenced by meanValue(), and readFile().

◆ fileToRead_

TFile* CovarianceParameterization::fileToRead_
private

Definition at line 70 of file CovarianceParameterization.h.

Referenced by load().

◆ loadedVersion_

int CovarianceParameterization::loadedVersion_
private

Definition at line 69 of file CovarianceParameterization.h.

Referenced by isValid(), load(), and loadedVersion().

◆ schemas

std::unordered_map<uint16_t, CompressionSchema> CovarianceParameterization::schemas
private

Definition at line 71 of file CovarianceParameterization.h.

Referenced by load(), pack(), and unpack().

mps_fire.i
i
Definition: mps_fire.py:428
CovarianceParameterization::readFile
void readFile(TFile &)
Definition: CovarianceParameterization.cc:129
etaBin
int etaBin(const l1t::HGCalMulticluster *cl)
Definition: L1EGammaEEProducer.cc:19
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
printsummarytable.folder
folder
Definition: printsummarytable.py:7
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
Validation_hcalonly_cfi.sign
sign
Definition: Validation_hcalonly_cfi.py:32
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
CompressionElement::Method
Method
Definition: CovarianceParameterization.h:11
muonRecoAnalyzer_cfi.ptBin
ptBin
Definition: muonRecoAnalyzer_cfi.py:45
CovarianceParameterization::loadedVersion_
int loadedVersion_
Definition: CovarianceParameterization.h:69
GetRecoTauVFromDQM_MC_cff.cl
cl
Definition: GetRecoTauVFromDQM_MC_cff.py:38
edm::FileInPath
Definition: FileInPath.h:64
CovarianceParameterization::meanValue
float meanValue(int i, int j, int sign, float pt, float eta, int nHits, int pixelHits, float cii=1., float cjj=1.) const
Definition: CovarianceParameterization.cc:151
CovarianceParameterization::cov_elements_pixelHit
std::vector< TH3D * > cov_elements_pixelHit
Definition: CovarianceParameterization.h:72
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
PVValHelper::eta
Definition: PVValidationHelpers.h:69
CovarianceParameterization::schemas
std::unordered_map< uint16_t, CompressionSchema > schemas
Definition: CovarianceParameterization.h:71
CovarianceParameterization::cov_elements_noPixelHit
std::vector< TH3D * > cov_elements_noPixelHit
Definition: CovarianceParameterization.h:73
CompressionElement
Definition: CovarianceParameterization.h:9
dqmdumpme.k
k
Definition: dqmdumpme.py:60
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
CompressionElement::Target
Target
Definition: CovarianceParameterization.h:12
CovarianceParameterization::addTheHistogram
void addTheHistogram(std::vector< TH3D * > *HistoVector, std::string StringToAddInTheName, int i, int j, TFile &fileToRead)
Definition: CovarianceParameterization.cc:141
createfilelist.int
int
Definition: createfilelist.py:10
value
Definition: value.py:1
CovarianceParameterization::fileToRead_
TFile * fileToRead_
Definition: CovarianceParameterization.h:70
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
crabWrapper.key
key
Definition: crabWrapper.py:19
BeamSplash_cfg.version
version
Definition: BeamSplash_cfg.py:45
GetRecoTauVFromDQM_MC_cff.next
next
Definition: GetRecoTauVFromDQM_MC_cff.py:31
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37