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 ( )
inline

Member Function Documentation

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.

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

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 }
static int CovarianceParameterization::index ( int  i,
int  j 
)
inlinestatic

Definition at line 26 of file CovarianceParameterization.h.

Referenced by BeautifulSoup.PageElement::insert().

26  {
27  if (i >= j)
28  return j + i * (i + 1) / 2;
29  else
30  return i + j * (j + 1) / 2;
31  }
bool CovarianceParameterization::isValid ( void  ) const
inline
void CovarianceParameterization::load ( int  version)

Definition at line 78 of file CovarianceParameterization.cc.

References GetRecoTauVFromDQM_MC_cff::cl, CompressionElement::CompressionElement(), printsummarytable::folder, dqm-mbProfile::format, edm::FileInPath::fullPath(), mps_fire::i, createfilelist::int, dqmiolumiharvest::j, dqmdumpme::k, crabWrapper::key, GetRecoTauVFromDQM_MC_cff::next, AlCaHLTBitMon_ParallelJobs::p, dtResolutionTest_cfi::readFile, str, AlCaHLTBitMon_QueryRunRegistry::string, and BeamSplash_cfg::version.

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 }
std::unordered_map< uint16_t, CompressionSchema > schemas
#define str(s)
int CovarianceParameterization::loadedVersion ( ) const
inline
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.

References funct::abs(), muonRecoAnalyzer_cfi::etaBin, mps_fire::i, dqmiolumiharvest::j, and muonRecoAnalyzer_cfi::ptBin.

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 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< TH3D * > cov_elements_pixelHit
float meanValue(int i, int j, int sign, float pt, float eta, int nHits, int pixelHits, float cii=1., float cjj=1.) const
std::vector< TH3D * > cov_elements_noPixelHit
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.

References DiDispStaMuonMonitor_cfi::pt, edm::second(), and std::swap().

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

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 }
U second(std::pair< T, U > const &p)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: value.py:1
float meanValue(int i, int j, int sign, float pt, float eta, int nHits, int pixelHits, float cii=1., float cjj=1.) const
std::unordered_map< uint16_t, CompressionSchema > schemas
void CovarianceParameterization::readFile ( TFile &  f)
private

Definition at line 125 of file CovarianceParameterization.cc.

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

Referenced by Vispa.Plugins.EventBrowser.EventBrowserTabController.EventBrowserTabController::navigate(), Vispa.Main.TabController.TabController::open(), and Vispa.Main.TabController.TabController::refresh().

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 }
void addTheHistogram(std::vector< TH3D * > *HistoVector, std::string StringToAddInTheName, int i, int j, TFile &fileToRead)
double f[11][100]
std::vector< TH3D * > cov_elements_pixelHit
std::vector< TH3D * > cov_elements_noPixelHit
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.

References MillePedeFileConverter_cfg::e, DiDispStaMuonMonitor_cfi::pt, edm::second(), and std::swap().

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

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 }
U second(std::pair< T, U > const &p)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
float meanValue(int i, int j, int sign, float pt, float eta, int nHits, int pixelHits, float cii=1., float cjj=1.) const
std::unordered_map< uint16_t, CompressionSchema > schemas

Member Data Documentation

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

Definition at line 73 of file CovarianceParameterization.h.

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

Definition at line 72 of file CovarianceParameterization.h.

TFile* CovarianceParameterization::fileToRead_
private

Definition at line 70 of file CovarianceParameterization.h.

int CovarianceParameterization::loadedVersion_
private

Definition at line 69 of file CovarianceParameterization.h.

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

Definition at line 71 of file CovarianceParameterization.h.