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 25 of file CovarianceParameterization.h.

Constructor & Destructor Documentation

CovarianceParameterization::CovarianceParameterization ( )
inline

Definition at line 34 of file CovarianceParameterization.h.

Member Function Documentation

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

Definition at line 151 of file CovarianceParameterization.cc.

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

151  {
152 
153  std::string List_covName[5] = {"qoverp", "lambda", "phi", "dxy", "dsz"};
154 
155  std::string histoNameString = "covariance_" + List_covName[i] + "_" + List_covName[j] + StringToAddInTheName+"parametrization" ;// + "_entries";
156  TH3D * matrixElememtHistogramm = (TH3D*) fileToRead.Get(histoNameString.c_str());
157  HistoVector->push_back(matrixElememtHistogramm);
158 }
static int CovarianceParameterization::index ( int  i,
int  j 
)
inlinestatic

Definition at line 27 of file CovarianceParameterization.h.

Referenced by BeautifulSoup.PageElement::insert().

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

Definition at line 87 of file CovarianceParameterization.cc.

References GetRecoTauVFromDQM_MC_cff::cl, CompressionElement::CompressionElement(), printsummarytable::folder, cmsPerfStripChart::format, edm::FileInPath::fullPath(), mps_fire::i, createfilelist::int, gen::k, crabWrapper::key, GetRecoTauVFromDQM_MC_cff::next, AlCaHLTBitMon_ParallelJobs::p, dataDML::schema, dqmstorepb::protobuf_DQMServices_2fCore_2fsrc_2fROOTFilePB_2eproto::schemas, harvestTrackValidationPlots::str, AlCaHLTBitMon_QueryRunRegistry::string, and jetIDSelector_cfi::version.

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

References funct::abs(), conversionPostprocessing_cfi::etaBin, mps_fire::i, and electronConversionRejectionValidator::ptBin.

162  {
163  int hitNumberToUse = nHits;
164  if (hitNumberToUse < 2 ) hitNumberToUse = 2;
165  if (hitNumberToUse > 32 ) hitNumberToUse = 32;
166  int ptBin = cov_elements_pixelHit[0]->GetXaxis()->FindBin(pt);
167  int etaBin = cov_elements_pixelHit[0]->GetYaxis()->FindBin(std::abs(eta));
168  int hitBin = cov_elements_pixelHit[0]->GetZaxis()->FindBin(hitNumberToUse);
169  int min_idx = i;
170  int max_idx = j;
171 
172  if (i>j) {
173  min_idx = j;
174  max_idx = i;
175  }
176 
177  int indexOfTheHitogramInTheList = ((9 - min_idx)*min_idx)/2 + max_idx;
178 
179  double meanValue = 0.;
180  if (pixelHits > 0) {
181  meanValue =sign* cov_elements_pixelHit[indexOfTheHitogramInTheList]->GetBinContent(ptBin, etaBin, hitBin);
182  }
183  else {
184  meanValue = sign*cov_elements_noPixelHit[indexOfTheHitogramInTheList]->GetBinContent(ptBin, etaBin, hitBin);
185  }
186  return meanValue;
187 
188 }
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 190 of file CovarianceParameterization.cc.

References EnergyCorrector::pt, dqmstorepb::protobuf_DQMServices_2fCore_2fsrc_2fROOTFilePB_2eproto::schemas, edm::second(), and std::swap().

Referenced by pyrootRender.interactiveRender::draw(), and pat::PackedCandidate::packCovarianceElement().

190  {
191  if(i>j) std::swap(i,j);
192  float ref=meanValue(i,j,1.,pt,eta,nHits,pixelHits,cii,cjj);
193  if(ref==0) {
194  schema=0;
195  }
196  if(schema==0 && i==j && (i==2 || i==0) ) ref=1./(pt*pt);
197 /* //Used for debugging, to be later removed
198  uint16_t p=(*schemas.find(schema)).second(i,j).pack(value,ref);
199  float up=(*schemas.find(schema)).second(i,j).unpack(p,ref);
200  std::cout << "check " << i << " " << j << " " << value << " " << up << " " << p << " " << ref << " " << schema<< std::endl;*/
201  return (*schemas.find(schema)).second(i,j).pack(value,ref);
202 }
U second(std::pair< T, U > const &p)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: value.py:1
std::unordered_map< uint16_t, CompressionSchema > schemas
float meanValue(int i, int j, int sign, float pt, float eta, int nHits, int pixelHits, float cii=1., float cjj=1.) const
void CovarianceParameterization::readFile ( TFile &  f)
private

Definition at line 134 of file CovarianceParameterization.cc.

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

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

134  {
135 
136  for (int i = 0; i < 5; i++) {
137  for (int j = i; j < 5; j++) {
138 
139  std::string String_first_positive = "_pixel_";
140  std::string String_second_positive = "_noPixel_";
141 
142  addTheHistogram(&cov_elements_pixelHit, String_first_positive, i, j,f);
143  addTheHistogram(&cov_elements_noPixelHit, String_second_positive, i, j,f);
144 
145 
146  }
147  }
148 }
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 203 of file CovarianceParameterization.cc.

References MillePedeFileConverter_cfg::e, EnergyCorrector::pt, dqmstorepb::protobuf_DQMServices_2fCore_2fsrc_2fROOTFilePB_2eproto::schemas, edm::second(), and std::swap().

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

203  {
204  if(i>j) std::swap(i,j);
205  float ref=meanValue(i,j,1.,pt,eta,nHits,pixelHits,cii,cjj);
206  if(ref==0) {
207  schema=0;
208  }
209  if(schema==0 && i==j && (i==2 || i==0) ) ref=1./(pt*pt);
210  if(i==j && (*schemas.find(schema)).second(i,j).unpack(packed,ref)==0) return 1e-9;
211  else
212  return (*schemas.find(schema)).second(i,j).unpack(packed,ref);
213 
214 }
U second(std::pair< T, U > const &p)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
std::unordered_map< uint16_t, CompressionSchema > schemas
float meanValue(int i, int j, int sign, float pt, float eta, int nHits, int pixelHits, float cii=1., float cjj=1.) const

Member Data Documentation

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

Definition at line 50 of file CovarianceParameterization.h.

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

Definition at line 49 of file CovarianceParameterization.h.

TFile* CovarianceParameterization::fileToRead_
private

Definition at line 47 of file CovarianceParameterization.h.

int CovarianceParameterization::loadedVersion_
private

Definition at line 46 of file CovarianceParameterization.h.

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

Definition at line 48 of file CovarianceParameterization.h.