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 137 of file CovarianceParameterization.cc.

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

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 78 of file CovarianceParameterization.cc.

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

References GetRecoTauVFromDQM_MC_cff::cl, fileToRead_, printsummarytable::folder, dqm-mbProfile::format, edm::FileInPath::fullPath(), mps_fire::i, createfilelist::int, dqmiolumiharvest::j, dqmdumpme::k, crabWrapper::key, loadedVersion_, GetRecoTauVFromDQM_MC_cff::next, AlCaHLTBitMon_ParallelJobs::p, readFile(), schemas, str, 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 147 of file CovarianceParameterization.cc.

148  {
149  int hitNumberToUse = nHits;
150  if (hitNumberToUse < 2)
151  hitNumberToUse = 2;
152  if (hitNumberToUse > 32)
153  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);
157  int min_idx = i;
158  int max_idx = j;
159 
160  if (i > j) {
161  min_idx = j;
162  max_idx = i;
163  }
164 
165  int indexOfTheHitogramInTheList = ((9 - min_idx) * min_idx) / 2 + max_idx;
166 
167  double meanValue = 0.;
168  if (pixelHits > 0) {
169  meanValue = sign * cov_elements_pixelHit[indexOfTheHitogramInTheList]->GetBinContent(ptBin, etaBin, hitBin);
170  } else {
171  meanValue = sign * cov_elements_noPixelHit[indexOfTheHitogramInTheList]->GetBinContent(ptBin, etaBin, hitBin);
172  }
173  return meanValue;
174 }

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 176 of file CovarianceParameterization.cc.

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

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 125 of file CovarianceParameterization.cc.

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

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 192 of file CovarianceParameterization.cc.

194  {
195  if (i > j)
196  std::swap(i, j);
197  float ref = meanValue(i, j, 1., pt, eta, nHits, pixelHits, cii, cjj);
198  if (ref == 0) {
199  schema = 0;
200  }
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)
204  return 1e-9;
205  else
206  return (*schemas.find(schema)).second(i, j).unpack(packed, ref);
207 }

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:355
CovarianceParameterization::readFile
void readFile(TFile &)
Definition: CovarianceParameterization.cc:125
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:215
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:147
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
dqm-mbProfile.format
format
Definition: dqm-mbProfile.py:16
str
#define str(s)
Definition: TestProcessor.cc:48
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:137
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