CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes
MuonErrorMatrix Class Reference

#include <MuonErrorMatrix.h>

Public Types

enum  action { use, constructor }
 enum type to define if the class is used as a tool or to be created More...
 

Public Member Functions

void adjust (FreeTrajectoryState &state)
 adjust the error matrix on the state More...
 
void adjust (TrajectoryStateOnSurface &state)
 adjust the error matrix on the state More...
 
void close ()
 close the root file attached to the class More...
 
void complicatedTerm (const AlgebraicSymMatrix55 &input, AlgebraicSymMatrix55 &output)
 convert sigma/rho -> sigma2/COV More...
 
int findBin (TAxis *axis, double value)
 method to get the bin index, taking care of under/overlow: first(1)/last(GetNbins())returned More...
 
CurvilinearTrajectoryError get (GlobalVector momentum, bool convolute=true)
 main method to be used. Retrieve a 5x5 symetrical matrix according to parametrization of error or scale factor More...
 
TProfile3D * get (int i, int j)
 actually get access to the TProfile3D used for the parametrization More...
 
CurvilinearTrajectoryError getFast (GlobalVector momentum)
 
unsigned int index (int i, int j)
 
 MuonErrorMatrix (const edm::ParameterSet &pset)
 constructor from a parameter set More...
 
void simpleTerm (const AlgebraicSymMatrix55 &input, AlgebraicSymMatrix55 &output)
 convert sigma2/COV -> sigma/rho More...
 
 ~MuonErrorMatrix ()
 destructor More...
 

Static Public Member Functions

static bool divide (CurvilinearTrajectoryError &num_error, const CurvilinearTrajectoryError &denom_error)
 divide term by term the two matrix More...
 
static void multiply (CurvilinearTrajectoryError &initial_error, const CurvilinearTrajectoryError &scale_error)
 multiply term by term the two matrix More...
 
static double Term (const AlgebraicSymMatrix55 &curv, int i, int j)
 provide the numerical value used. sigma or correlation factor More...
 

Static Public Attributes

static const TString vars [5] = {"#frac{q}{|p|}", "#lambda", "#varphi_{0}", "X_{T}", "Y_{T}"}
 names of the variables of the 5x5 error matrix More...
 

Private Types

enum  TermAction { error, scale, assign }
 decide whether to scale of to assigne terms More...
 

Private Member Functions

TProfile3D * Index (int i, int j)
 internal method to get access to the profiles More...
 
int Pindex (int i, int j)
 internal methods to get the index of a matrix term. More...
 
double Rms (GlobalVector &momentum, int i, int j)
 internal method that retreives the error on the value of the parametrization for term i,j More...
 
double Value (GlobalVector &momentum, int i, int j, bool convolute=true)
 internal method that retreives the value of the parametrization for term i,j More...
 

Private Attributes

std::string theCategory
 log category: "MuonErrorMatrix" More...
 
TDirectory * theD
 the attached root file, where the parametrization is saved More...
 
TProfile3D * theData [15]
 15 TProfile, each holding he parametrization of each term of the 5x5 More...
 
TProfile3D * theData_fast [5][5]
 
TermAction theTermAction [15]
 

Detailed Description

This class holds an error matrix paramertization. Either the error matrix value or scale factors. The implementation uses TProfile3D with pt, eta, phi axis. Error/Scale factor matrix is obtained using get(GlobalVector momentum)

Author
Jean-Roch Vlimant UCSB
Finn Rebassoo UCSB

Definition at line 24 of file MuonErrorMatrix.h.

Member Enumeration Documentation

◆ action

enum type to define if the class is used as a tool or to be created

Enumerator
use 
constructor 

Definition at line 27 of file MuonErrorMatrix.h.

◆ TermAction

decide whether to scale of to assigne terms

Enumerator
error 
scale 
assign 

Definition at line 83 of file MuonErrorMatrix.h.

Constructor & Destructor Documentation

◆ MuonErrorMatrix()

MuonErrorMatrix::MuonErrorMatrix ( const edm::ParameterSet pset)

constructor from a parameter set

Definition at line 17 of file MuonErrorMatrix.cc.

References a, assign, constructor, data, TrackerOfflineValidation_Dqm_cff::dirName, error, HLT_2023v12_cff::errorMatrixValuesPSet, edm::ParameterSet::exists(), beamvalidation::exit(), MillePedeFileConverter_cfg::fileName, reco_skim_cfg_mod::fullpath, edm::ParameterSet::getParameter(), mps_fire::i, dqmiolumiharvest::j, LogDebug, LogTrace, razorScouting_cff::maxEta, HLT_2023v12_cff::maxPhi, PV_cfg::maxPt, EgHLTOffEleSelection_cfi::minEta, HLT_2023v12_cff::minPhi, PV_cfg::minPt, MuonErrorMatrixAnalyzer_cfi::NEta, MuonErrorMatrixAnalyzer_cfi::NPhi, MuonErrorMatrixAnalyzer_cfi::NPt, packedPFCandidateRefMixer_cfi::pf, Pi, Pindex(), scale, str, AlCaHLTBitMon_QueryRunRegistry::string, theCategory, theD, theData, theData_fast, theTermAction, use, contentValuesCheck::values, multiplicitycorr_cfi::xBins, multiplicitycorr_cfi::yBins, and l1tTrackJets_cfi::zBins.

17  : theD(nullptr) {
18  theCategory = "MuonErrorMatrix";
19  std::string action = iConfig.getParameter<std::string>("action");
20 
21  bool madeFromCff = iConfig.exists("errorMatrixValuesPSet");
23 
25  if (!madeFromCff) {
26  fileName = iConfig.getParameter<std::string>("rootFileName");
27  } else {
28  errorMatrixValuesPSet = iConfig.getParameter<edm::ParameterSet>("errorMatrixValuesPSet");
29  }
31 
32  int NPt = 5;
33  std::vector<double> xBins;
34  double *xBinsArray = nullptr;
35  double minPt = 1;
36  double maxPt = 200;
37  int NEta = 5;
38  std::vector<double> yBins;
39  double *yBinsArray = nullptr;
40  double minEta = 0;
41  double maxEta = 2.5;
42  int NPhi = 1;
43  double minPhi = -TMath::Pi();
44  double maxPhi = TMath::Pi();
45 
46  if (action != "use") {
47  a = constructor;
48 
49  NPt = iConfig.getParameter<int>("NPt");
50  if (NPt != 0) {
51  minPt = iConfig.getParameter<double>("minPt");
52  maxPt = iConfig.getParameter<double>("maxPt");
53  } else {
54  xBins = iConfig.getParameter<std::vector<double> >("PtBins");
55  if (xBins.empty()) {
56  edm::LogError(theCategory) << "Npt=0 and no entries in the vector. I will do aseg fault soon.";
57  }
58  NPt = xBins.size() - 1;
59  xBinsArray = &(xBins.front());
60  minPt = xBins.front();
61  maxPt = xBins.back();
62  }
63 
64  NEta = iConfig.getParameter<int>("NEta");
65  if (NEta != 0) {
66  minEta = iConfig.getParameter<double>("minEta");
67  maxEta = iConfig.getParameter<double>("maxEta");
68  } else {
69  yBins = iConfig.getParameter<std::vector<double> >("EtaBins");
70  if (yBins.empty()) {
71  edm::LogError(theCategory) << "NEta=0 and no entries in the vector. I will do aseg fault soon.";
72  }
73  NEta = yBins.size() - 1;
74  yBinsArray = &(yBins.front());
75  minEta = yBins.front();
76  maxEta = yBins.back();
77  }
78 
79  NPhi = iConfig.getParameter<int>("NPhi");
80  std::stringstream get(iConfig.getParameter<std::string>("minPhi"));
81  if (get.str() == "-Pi") {
82  minPhi = -TMath::Pi();
83  } else if (get.str() == "Pi") {
84  minPhi = TMath::Pi();
85  } else {
86  get >> minPhi;
87  }
88  get.str(iConfig.getParameter<std::string>("maxPhi"));
89  if (get.str() == "-Pi") {
90  maxPhi = -TMath::Pi();
91  } else if (get.str() == "Pi") {
92  maxPhi = TMath::Pi();
93  } else {
94  get >> maxPhi;
95  }
96  } //action!=use
97  else if (madeFromCff) {
98  xBins = errorMatrixValuesPSet.getParameter<std::vector<double> >("xAxis");
99  NPt = xBins.size() - 1;
100  xBinsArray = &(xBins.front());
101  minPt = xBins.front();
102  maxPt = xBins.back();
103 
104  yBins = errorMatrixValuesPSet.getParameter<std::vector<double> >("yAxis");
105  NEta = yBins.size() - 1;
106  yBinsArray = &(yBins.front());
107  minEta = yBins.front();
108  maxEta = yBins.back();
109 
110  std::vector<double> zBins = errorMatrixValuesPSet.getParameter<std::vector<double> >("zAxis");
111  NPhi = 1;
112  if (zBins.size() != 2) {
113  edm::LogError(theCategory) << "please specify a zAxis with 2 entries only. more bins not implemented yet.";
114  }
115  minPhi = zBins.front();
116  maxPhi = zBins.back();
117  }
118 
119  if (a == use) {
120  if (!madeFromCff) {
121  edm::LogInfo(theCategory) << "using an error matrix object from: " << fileName;
123  std::string fullpath = data.fullPath();
124  gROOT->cd();
125  theD = new TFile(fullpath.c_str());
126  theD->SetWritable(false);
127  } else {
128  static std::atomic<unsigned int> neverTheSame{0};
129  std::stringstream dirName("MuonErrorMatrixDirectory");
130  dirName << neverTheSame++;
132  << "using an error matrix object from configuration file. putting memory histograms to: " << dirName.str();
133  gROOT->cd();
134  theD = new TDirectory(dirName.str().c_str(), "transient directory to host MuonErrorMatrix TProfile3D");
135  theD->SetWritable(false);
136  }
137  } else {
138  edm::LogInfo(theCategory) << "creating an error matrix object: " << fileName;
139  theD = new TFile(fileName.c_str(), "recreate");
140  }
141 
142  if (a == use && !madeFromCff) {
143  gROOT->cd();
144  } else {
145  theD->cd();
146  }
147 
148  for (int i = 0; i != 5; i++) {
149  for (int j = i; j != 5; j++) {
150  TString pfname(Form("pf3_V%1d%1d", i + 1, j + 1));
151  TProfile3D *pf = nullptr;
152  if (a == use && !madeFromCff) {
153  //read from the rootfile
154  edm::LogVerbatim(theCategory) << "getting " << pfname << " from " << fileName;
155  pf = (TProfile3D *)theD->Get(pfname);
156  theData[Pindex(i, j)] = pf;
157  theData_fast[i][j] = pf;
158  theData_fast[j][i] = pf;
159  } else {
160  // curvilinear coordinate system
161  //need to make some input parameter to be to change the number of bins
162 
163  TString pftitle;
164  if (i == j) {
165  pftitle = "#sigma_{" + vars[i] + "}";
166  } else {
167  pftitle = "#rho(" + vars[i] + "," + vars[j] + ")";
168  }
169  edm::LogVerbatim(theCategory) << "booking " << pfname << " into " << fileName;
170  pf = new TProfile3D(pfname, pftitle, NPt, minPt, maxPt, NEta, minEta, maxEta, NPhi, minPhi, maxPhi, "S");
171  pf->SetXTitle("muon p_{T} [GeV]");
172  pf->SetYTitle("muon |#eta|");
173  pf->SetZTitle("muon #varphi");
174 
175  //set variable size binning
176  if (xBinsArray) {
177  pf->GetXaxis()->Set(NPt, xBinsArray);
178  }
179  if (yBinsArray) {
180  pf->GetYaxis()->Set(NEta, yBinsArray);
181  }
182 
183  if (madeFromCff) {
184  edm::ParameterSet pSet = errorMatrixValuesPSet.getParameter<edm::ParameterSet>(pfname.Data());
185  //set the values from the configuration file itself
186  std::vector<double> values = pSet.getParameter<std::vector<double> >("values");
187  unsigned int iX = pf->GetNbinsX();
188  unsigned int iY = pf->GetNbinsY();
189  unsigned int iZ = pf->GetNbinsZ();
190  unsigned int continuous_i = 0;
191  for (unsigned int ix = 1; ix <= iX; ++ix) {
192  for (unsigned int iy = 1; iy <= iY; ++iy) {
193  for (unsigned int iz = 1; iz <= iZ; ++iz) {
194  LogTrace(theCategory) << "filling profile:"
195  << "\n pt (x)= " << pf->GetXaxis()->GetBinCenter(ix)
196  << "\n eta (y)= " << pf->GetYaxis()->GetBinCenter(iy)
197  << "\n phi (z)= " << pf->GetZaxis()->GetBinCenter(iz)
198  << "\n value= " << values[continuous_i];
199  pf->Fill(pf->GetXaxis()->GetBinCenter(ix),
200  pf->GetYaxis()->GetBinCenter(iy),
201  pf->GetZaxis()->GetBinCenter(iz),
202  values[continuous_i++]);
203  }
204  }
205  }
206  //term action
207  std::string tAction = pSet.getParameter<std::string>("action");
208  if (tAction == "scale")
210  else if (tAction == "assign")
212  else {
213  edm::LogError(theCategory) << " wrong configuration: term action: " << tAction << " is not recognized.";
215  }
216  }
217  }
218 
219  LogDebug(theCategory) << " index " << i << ":" << j << " -> " << Pindex(i, j);
220  theData[Pindex(i, j)] = pf;
221  theData_fast[i][j] = pf;
222  theData_fast[j][i] = pf;
223  if (!pf) {
224  edm::LogError(theCategory) << " profile " << pfname << " in file " << fileName << " is not valid. exiting.";
225  exit(1);
226  }
227  }
228  }
229 
230  //verify it
231  for (int i = 0; i != 15; i++) {
232  if (theData[i]) {
233  edm::LogVerbatim(theCategory) << i << " :" << theData[i]->GetName() << " " << theData[i]->GetTitle() << std::endl;
234  }
235  }
236 }
const double Pi
Log< level::Info, true > LogVerbatim
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
minPt
Definition: PV_cfg.py:223
Log< level::Error, false > LogError
action
enum type to define if the class is used as a tool or to be created
#define LogTrace(id)
TermAction theTermAction[15]
int Pindex(int i, int j)
internal methods to get the index of a matrix term.
TProfile3D * theData_fast[5][5]
Log< level::Info, false > LogInfo
maxPt
Definition: PV_cfg.py:224
NEta
set NEta=0 and the vector of double for variable size binning
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
TDirectory * theD
the attached root file, where the parametrization is saved
double a
Definition: hdecay.h:121
vars
Definition: DeepTauId.cc:166
TProfile3D * theData[15]
15 TProfile, each holding he parametrization of each term of the 5x5
#define str(s)
std::string theCategory
log category: "MuonErrorMatrix"
#define LogDebug(id)
def exit(msg="")

◆ ~MuonErrorMatrix()

MuonErrorMatrix::~MuonErrorMatrix ( )

destructor

Definition at line 256 of file MuonErrorMatrix.cc.

References close().

256 { close(); }
void close()
close the root file attached to the class

Member Function Documentation

◆ adjust() [1/2]

void MuonErrorMatrix::adjust ( FreeTrajectoryState state)

adjust the error matrix on the state

Definition at line 498 of file MuonErrorMatrix.cc.

References assign, complicatedTerm(), error, mps_fire::i, dqmiolumiharvest::j, LogDebug, makeMuonMisalignmentScenario::matrix, Pindex(), scale, simpleTerm(), theCategory, and theTermAction.

Referenced by TSGForRoadSearch::IPfts(), and TSGForRoadSearch::notAtIPtsos().

498  {
499  LogDebug(theCategory + "|Adjust") << "state: \n" << state;
500  AlgebraicSymMatrix55 simpleTerms;
501  simpleTerm(state.curvilinearError(), simpleTerms);
502  //the above contains sigma(i), rho(i,j)
503  LogDebug(theCategory + "|Adjust") << "state sigma(i), rho(i,j): \n" << simpleTerms;
504 
505  AlgebraicSymMatrix55 simpleValues = get(state.momentum(), false).matrix();
506  LogDebug(theCategory + "|Adjust") << "config: (i,i), (i,j): \n" << simpleValues;
507 
508  for (int i = 0; i != 5; i++) {
509  for (int j = i; j != 5; j++) {
510  //check on each term for desired action
511  switch (theTermAction[Pindex(i, j)]) {
512  case scale: {
513  simpleTerms(i, j) *= simpleValues(i, j);
514  break;
515  }
516  case assign: {
517  simpleTerms(i, j) = simpleValues(i, j);
518  break;
519  }
520  case error: {
521  edm::LogError(theCategory + "|Adjust") << " cannot properly adjust for term: " << i << "," << j;
522  }
523  }
524  }
525  }
526  LogDebug(theCategory + "|Adjust") << "updated state sigma(i), rho(i,j): \n" << simpleTerms;
527 
528  AlgebraicSymMatrix55 finalTerms;
529  complicatedTerm(simpleTerms, finalTerms);
530  LogDebug(theCategory + "|Adjust") << "updated state COV(i,j): \n" << finalTerms;
531 
532  CurvilinearTrajectoryError oMat(finalTerms);
533  state = FreeTrajectoryState(state.parameters(), oMat);
534  LogDebug(theCategory + "|Adjust") << "updated state:\n" << state;
535 }
Log< level::Error, false > LogError
void complicatedTerm(const AlgebraicSymMatrix55 &input, AlgebraicSymMatrix55 &output)
convert sigma/rho -> sigma2/COV
TermAction theTermAction[15]
int Pindex(int i, int j)
internal methods to get the index of a matrix term.
void simpleTerm(const AlgebraicSymMatrix55 &input, AlgebraicSymMatrix55 &output)
convert sigma2/COV -> sigma/rho
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
std::string theCategory
log category: "MuonErrorMatrix"
#define LogDebug(id)

◆ adjust() [2/2]

void MuonErrorMatrix::adjust ( TrajectoryStateOnSurface state)

adjust the error matrix on the state

Definition at line 537 of file MuonErrorMatrix.cc.

References assign, complicatedTerm(), error, mps_fire::i, dqmiolumiharvest::j, LogDebug, makeMuonMisalignmentScenario::matrix, Pindex(), scale, simpleTerm(), theCategory, and theTermAction.

537  {
538  AlgebraicSymMatrix55 simpleTerms;
539  simpleTerm(state.curvilinearError(), simpleTerms);
540  LogDebug(theCategory + "|Adjust") << "state sigma(i), rho(i,j): \n" << simpleTerms;
541 
542  AlgebraicSymMatrix55 simpleValues = get(state.globalMomentum(), false).matrix();
543  LogDebug(theCategory + "|Adjust") << "config: (i,i), (i,j):\n" << simpleValues;
544 
545  for (int i = 0; i != 5; i++) {
546  for (int j = i; j != 5; j++) {
547  //check on each term for desired action
548  switch (theTermAction[Pindex(i, j)]) {
549  case scale: {
550  simpleTerms(i, j) *= simpleValues(i, j);
551  break;
552  }
553  case assign: {
554  simpleTerms(i, j) = simpleValues(i, j);
555  break;
556  }
557  case error: {
558  edm::LogError(theCategory + "|Adjust") << " cannot properly adjust for term: " << i << "," << j;
559  }
560  }
561  }
562  }
563  LogDebug(theCategory + "|Adjust") << "updated state sigma(i), rho(i,j): \n" << simpleTerms;
564 
565  AlgebraicSymMatrix55 finalTerms;
566  complicatedTerm(simpleTerms, finalTerms);
567  LogDebug(theCategory + "|Adjust") << "updated state COV(i,j): \n" << finalTerms;
568 
569  CurvilinearTrajectoryError oMat(finalTerms);
570  state =
571  TrajectoryStateOnSurface(state.weight(), state.globalParameters(), oMat, state.surface(), state.surfaceSide());
572  LogDebug(theCategory + "|Adjust") << "updated state:\n" << state;
573 }
Log< level::Error, false > LogError
void complicatedTerm(const AlgebraicSymMatrix55 &input, AlgebraicSymMatrix55 &output)
convert sigma/rho -> sigma2/COV
TermAction theTermAction[15]
int Pindex(int i, int j)
internal methods to get the index of a matrix term.
void simpleTerm(const AlgebraicSymMatrix55 &input, AlgebraicSymMatrix55 &output)
convert sigma2/COV -> sigma/rho
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
std::string theCategory
log category: "MuonErrorMatrix"
#define LogDebug(id)

◆ close()

void MuonErrorMatrix::close ( void  )

close the root file attached to the class

Definition at line 240 of file MuonErrorMatrix.cc.

References mps_fire::i, theD, and theData.

Referenced by esMonitoring.AsyncLineReaderMixin::handle_close(), esMonitoring.FDJsonServer::handle_close(), and ~MuonErrorMatrix().

240  {
241  //close the file
242  if (theD) {
243  theD->cd();
244  //write to it first if constructor
245  if (theD->IsWritable()) {
246  for (int i = 0; i != 15; i++) {
247  if (theData[i]) {
248  theData[i]->Write();
249  }
250  }
251  }
252  theD->Close();
253  }
254 }
TDirectory * theD
the attached root file, where the parametrization is saved
TProfile3D * theData[15]
15 TProfile, each holding he parametrization of each term of the 5x5

◆ complicatedTerm()

void MuonErrorMatrix::complicatedTerm ( const AlgebraicSymMatrix55 input,
AlgebraicSymMatrix55 output 
)

convert sigma/rho -> sigma2/COV

Definition at line 487 of file MuonErrorMatrix.cc.

References mps_fire::i, input, dqmiolumiharvest::j, and convertSQLitetoXML_cfg::output.

Referenced by adjust().

487  {
488  for (int i = 0; i != 5; i++) {
489  for (int j = i; j != 5; j++) {
490  if (i == j)
491  output(i, j) = input(i, j) * input(i, j); //sigma squared
492  else
493  output(i, j) = input(i, j) * input(i, i) * input(j, j); //rho*sigma*sigma
494  }
495  }
496 }
static std::string const input
Definition: EdmProvDump.cc:50

◆ divide()

bool MuonErrorMatrix::divide ( CurvilinearTrajectoryError num_error,
const CurvilinearTrajectoryError denom_error 
)
static

divide term by term the two matrix

Definition at line 459 of file MuonErrorMatrix.cc.

References mps_fire::i, dqmiolumiharvest::j, and CurvilinearTrajectoryError::matrix().

459  {
460  //divide term by term the matrix
461  const AlgebraicSymMatrix55 &denom_matrix = denom_error.matrix();
462  AlgebraicSymMatrix55 num_matrix = num_error.matrix();
463  // the true type of the matrix is such that [i][j] is the same memory object as [j][i]: looping i:0-5, j:0-5 double multiply the terms
464  // need to loop only on i:0-5, j:i-5
465  for (int i = 0; i != 5; i++) {
466  for (int j = i; j != 5; j++) {
467  if (denom_matrix(i, j) == 0)
468  return false;
469  num_matrix(i, j) /= denom_matrix(i, j);
470  }
471  }
472  num_error = CurvilinearTrajectoryError(num_matrix);
473  return true;
474 }
const AlgebraicSymMatrix55 & matrix() const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55

◆ findBin()

int MuonErrorMatrix::findBin ( TAxis *  axis,
double  value 
)

method to get the bin index, taking care of under/overlow: first(1)/last(GetNbins())returned

Definition at line 322 of file MuonErrorMatrix.cc.

References mps_fire::result.

Referenced by getFast(), and Value().

322  {
323  //find the proper bin, protecting against under/over flow
324  int result = axis->FindBin(value);
325  if (result <= 0)
326  result = 1; //protect against under flow
327  else if (result > axis->GetNbins())
328  result = axis->GetNbins();
329  return result;
330 }
Definition: value.py:1

◆ get() [1/2]

CurvilinearTrajectoryError MuonErrorMatrix::get ( GlobalVector  momentum,
bool  convolute = true 
)

main method to be used. Retrieve a 5x5 symetrical matrix according to parametrization of error or scale factor

Definition at line 258 of file MuonErrorMatrix.cc.

References mps_fire::i, dqmiolumiharvest::j, cms::cuda::V, and Value().

Referenced by Options.Options::__getitem__(), betterConfigParser.BetterConfigParser::__updateDict(), submitPVValidationJobs.BetterConfigParser::__updateDict(), betterConfigParser.BetterConfigParser::getCompares(), betterConfigParser.BetterConfigParser::getGeneral(), betterConfigParser.BetterConfigParser::getResultingSection(), and submitPVValidationJobs.BetterConfigParser::getResultingSection().

258  {
260  //retrieves a 55 matrix containing (i,i)^2 and (i,j)*(i,i)*(j,j)
261  for (int i = 0; i != 5; i++) {
262  for (int j = i; j != 5; j++) {
263  V(i, j) = Value(momentum, i, j, convolute);
264  }
265  }
267 }
double Value(GlobalVector &momentum, int i, int j, bool convolute=true)
internal method that retreives the value of the parametrization for term i,j
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t V
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55

◆ get() [2/2]

TProfile3D* MuonErrorMatrix::get ( int  i,
int  j 
)
inline

◆ getFast()

CurvilinearTrajectoryError MuonErrorMatrix::getFast ( GlobalVector  momentum)

Definition at line 269 of file MuonErrorMatrix.cc.

References PVValHelper::eta, PV3DBase< T, PVType, FrameType >::eta(), findBin(), mps_fire::i, dqmiolumiharvest::j, PV3DBase< T, PVType, FrameType >::perp(), phi, PV3DBase< T, PVType, FrameType >::phi(), pv::pT, theData_fast, cms::cuda::V, and contentValuesCheck::values.

269  {
270  //will be faster but make assumptions that could be broken at some point
271  // same bining for all TProfile
273 
274  double pT = momentum.perp();
275  double eta = fabs(momentum.eta());
276  double phi = momentum.phi();
277 
278  //assume all the same axis in X,Y,Z
279  int iBin_x = findBin(theData_fast[0][0]->GetXaxis(), pT);
280  int iBin_y = findBin(theData_fast[0][0]->GetYaxis(), eta);
281  int iBin_z = findBin(theData_fast[0][0]->GetZaxis(), phi);
282 
283  //retreive values
284  double values[5][5]; //sigma_i and rho_ij
285  for (int i = 0; i != 5; i++) {
286  for (int j = i; j != 5; j++) {
287  values[i][j] = theData_fast[i][j]->GetBinContent(iBin_x, iBin_y, iBin_z);
288  }
289  }
290 
291  for (int i = 0; i != 5; i++) {
292  for (int j = i; j != 5; j++) {
293  if (i == j) {
294  //sigma_i * sigma_i
295  V(i, j) = values[i][j];
296  V(i, j) *= V(i, j);
297  } else {
298  //sigma_i * sigma_j * rho_ij
299  V(i, j) = values[i][i] * values[j][j] * values[i][j];
300  }
301  }
302  }
303 
305 }
T perp() const
Definition: PV3DBase.h:69
int findBin(TAxis *axis, double value)
method to get the bin index, taking care of under/overlow: first(1)/last(GetNbins())returned ...
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
T eta() const
Definition: PV3DBase.h:73
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t V
TProfile3D * theData_fast[5][5]
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55

◆ index()

unsigned int MuonErrorMatrix::index ( int  i,
int  j 
)
inline

Definition at line 49 of file MuonErrorMatrix.h.

References mps_fire::i, dqmiolumiharvest::j, and Pindex().

49 { return Pindex(i, j); }
int Pindex(int i, int j)
internal methods to get the index of a matrix term.

◆ Index()

TProfile3D* MuonErrorMatrix::Index ( int  i,
int  j 
)
inlineprivate

internal method to get access to the profiles

Definition at line 92 of file MuonErrorMatrix.h.

References mps_fire::i, dqmiolumiharvest::j, Pindex(), and theData.

Referenced by get(), Rms(), and Value().

92 { return theData[Pindex(i, j)]; }
int Pindex(int i, int j)
internal methods to get the index of a matrix term.
TProfile3D * theData[15]
15 TProfile, each holding he parametrization of each term of the 5x5

◆ multiply()

void MuonErrorMatrix::multiply ( CurvilinearTrajectoryError initial_error,
const CurvilinearTrajectoryError scale_error 
)
static

multiply term by term the two matrix

Definition at line 445 of file MuonErrorMatrix.cc.

References mps_fire::i, dqmiolumiharvest::j, and CurvilinearTrajectoryError::matrix().

Referenced by TSGFromPropagation::adjust(), and FastTSGFromPropagation::adjust().

446  {
447  //scale term by term the matrix
448  const AlgebraicSymMatrix55 &scale_matrix = scale_error.matrix();
449  AlgebraicSymMatrix55 revised_matrix = initial_error.matrix();
450  // the true type of the matrix is such that [i][j] is the same memory object as [j][i]: looping i:0-5, j:0-5 double multiply the terms
451  // need to loop only on i:0-5, j:i-5
452  for (int i = 0; i != 5; i++) {
453  for (int j = i; j != 5; j++) {
454  revised_matrix(i, j) *= scale_matrix(i, j);
455  }
456  }
457  initial_error = CurvilinearTrajectoryError(revised_matrix);
458 }
const AlgebraicSymMatrix55 & matrix() const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55

◆ Pindex()

int MuonErrorMatrix::Pindex ( int  i,
int  j 
)
inlineprivate

internal methods to get the index of a matrix term.

Definition at line 87 of file MuonErrorMatrix.h.

References funct::abs(), mps_fire::i, dqmiolumiharvest::j, and hltrates_dqm_sourceclient-live_cfg::offset.

Referenced by adjust(), index(), Index(), and MuonErrorMatrix().

87  {
88  static const int offset[5] = {0, 5, 5 + 4, 5 + 4 + 3, 5 + 4 + 3 + 2};
89  return offset[i] + abs(j - i);
90  }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ Rms()

double MuonErrorMatrix::Rms ( GlobalVector momentum,
int  i,
int  j 
)
private

internal method that retreives the error on the value of the parametrization for term i,j

Definition at line 396 of file MuonErrorMatrix.cc.

References PVValHelper::eta, PV3DBase< T, PVType, FrameType >::eta(), mps_fire::i, Index(), dqmiolumiharvest::j, LogDebug, PV3DBase< T, PVType, FrameType >::perp(), phi, PV3DBase< T, PVType, FrameType >::phi(), pv::pT, mps_fire::result, and theCategory.

396  {
397  double result = 0;
398  TProfile3D *ij = Index(i, j);
399  if (!ij) {
400  edm::LogError(theCategory) << "cannot get the profile (" << i << ":" << i << ")";
401  return result;
402  }
403  double pT = momentum.perp();
404  double eta = fabs(momentum.eta());
405  double phi = momentum.phi();
406 
407  int iBin_x = ij->GetXaxis()->FindBin(pT);
408  int iBin_y = ij->GetYaxis()->FindBin(eta);
409  int iBin_z = ij->GetZaxis()->FindBin(phi);
410  result = ij->GetBinError(iBin_x, iBin_y, iBin_z);
411 
412  LogDebug(theCategory) << "for: (pT,eta,phi)=(" << pT << ", " << eta << ", " << phi << ") error[" << i << "," << j
413  << "] is: " << result;
414  return result;
415 }
T perp() const
Definition: PV3DBase.h:69
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
T eta() const
Definition: PV3DBase.h:73
Log< level::Error, false > LogError
std::string theCategory
log category: "MuonErrorMatrix"
#define LogDebug(id)
TProfile3D * Index(int i, int j)
internal method to get access to the profiles

◆ simpleTerm()

void MuonErrorMatrix::simpleTerm ( const AlgebraicSymMatrix55 input,
AlgebraicSymMatrix55 output 
)

convert sigma2/COV -> sigma/rho

Definition at line 476 of file MuonErrorMatrix.cc.

References mps_fire::i, input, dqmiolumiharvest::j, convertSQLitetoXML_cfg::output, and mathSSE::sqrt().

Referenced by adjust().

476  {
477  for (int i = 0; i != 5; i++) {
478  for (int j = i; j != 5; j++) {
479  if (i == j)
480  output(i, j) = sqrt(input(i, j)); //sigma
481  else
482  output(i, j) = input(i, j) / sqrt(input(i, i) * input(j, j)); //rho
483  }
484  }
485 }
static std::string const input
Definition: EdmProvDump.cc:50
T sqrt(T t)
Definition: SSEVec.h:19

◆ Term()

double MuonErrorMatrix::Term ( const AlgebraicSymMatrix55 curv,
int  i,
int  j 
)
static

provide the numerical value used. sigma or correlation factor

Definition at line 417 of file MuonErrorMatrix.cc.

References mps_fire::i, dqmiolumiharvest::j, mps_fire::result, and mathSSE::sqrt().

417  {
418  //return sigma or correlation factor
419  double result = 0;
420  if (i == j) {
421  result = curv(i, j);
422  if (result < 0) {
423  //check validity of this guy
424  edm::LogError("MuonErrorMatrix") << "invalid term in the error matrix.\n sii: " << result;
425  return 0;
426  }
427  return sqrt(result);
428  } else {
429  double si = curv(i, i);
430  double sj = curv(j, j);
431  if (si <= 0 || sj <= 0) {
432  //check validity
433  edm::LogError("MuonErrorMatrix") << "invalid term in the error matrix.\n si: " << si << " sj: " << sj
434  << ". result will be corrupted\n"
435  << curv;
436  return 0;
437  }
438  result = curv(i, j) / sqrt(si * sj);
439  return result;
440  }
441  //by default
442  return 0;
443 }
Log< level::Error, false > LogError
T sqrt(T t)
Definition: SSEVec.h:19

◆ Value()

double MuonErrorMatrix::Value ( GlobalVector momentum,
int  i,
int  j,
bool  convolute = true 
)
private

internal method that retreives the value of the parametrization for term i,j

Definition at line 332 of file MuonErrorMatrix.cc.

References alignCSCRings::corr, PVValHelper::eta, PV3DBase< T, PVType, FrameType >::eta(), findBin(), mps_fire::i, cuy::ii, Index(), dqmiolumiharvest::j, findQualityFiles::jj, LogDebug, PV3DBase< T, PVType, FrameType >::perp(), phi, PV3DBase< T, PVType, FrameType >::phi(), pv::pT, mps_fire::result, and theCategory.

Referenced by get().

332  {
333  double result = 0;
334  TProfile3D *ij = Index(i, j);
335  if (!ij) {
336  edm::LogError(theCategory) << "cannot get the profile (" << i << ":" << j << ")";
337  return result;
338  }
339 
340  double pT = momentum.perp();
341  double eta = fabs(momentum.eta());
342  double phi = momentum.phi();
343 
344  int iBin_x = findBin(ij->GetXaxis(), pT);
345  int iBin_y = findBin(ij->GetYaxis(), eta);
346  int iBin_z = findBin(ij->GetZaxis(), phi);
347 
348  if (convolute) {
349  if (i != j) {
350  //return the covariance = correlation*sigma_1 *sigma_2;
351  TProfile3D *ii = Index(i, i);
352  TProfile3D *jj = Index(j, j);
353  if (!ii) {
354  edm::LogError(theCategory) << "cannot get the profile (" << i << ":" << i << ")";
355  return result;
356  }
357  if (!jj) {
358  edm::LogError(theCategory) << "cannot get the profile (" << j << ":" << j << ")";
359  return result;
360  }
361 
362  int iBin_i_x = findBin(ii->GetXaxis(), pT);
363  int iBin_i_y = findBin(ii->GetYaxis(), eta);
364  int iBin_i_z = findBin(ii->GetZaxis(), phi);
365  int iBin_j_x = findBin(jj->GetXaxis(), pT);
366  int iBin_j_y = findBin(jj->GetYaxis(), eta);
367  int iBin_j_z = findBin(jj->GetZaxis(), phi);
368 
369  double corr = ij->GetBinContent(iBin_x, iBin_y, iBin_z);
370  double sigma_1 = (ii->GetBinContent(iBin_i_x, iBin_i_y, iBin_i_z));
371  double sigma_2 = (jj->GetBinContent(iBin_j_x, iBin_j_y, iBin_j_z));
372 
373  result = corr * sigma_1 * sigma_2;
374  LogDebug(theCategory) << "for: (pT,eta,phi)=(" << pT << ", " << eta << ", " << phi << ") nterms are"
375  << "\nrho[" << i << "," << j << "]: " << corr << " [" << iBin_x << ", " << iBin_y << ", "
376  << iBin_z << "]"
377  << "\nsigma[" << i << "," << i << "]: " << sigma_1 << "\nsigma[" << j << "," << j
378  << "]: " << sigma_2 << "Covariance[" << i << "," << j << "] is: " << result;
379  return result;
380  } else {
381  //return the variance = sigma_1 **2
382  // result=ij->GetBinContent(iBin);
383  result = ij->GetBinContent(iBin_x, iBin_y, iBin_z);
384  result *= result;
385  LogDebug(theCategory) << "for: (pT,eta,phi)=(" << pT << ", " << eta << ", " << phi << ") sigma^2[" << i << ","
386  << j << "] is: " << result;
387  return result;
388  }
389  } else {
390  //do not convolute
391  result = ij->GetBinContent(iBin_x, iBin_y, iBin_z);
392  return result;
393  }
394 }
T perp() const
Definition: PV3DBase.h:69
int findBin(TAxis *axis, double value)
method to get the bin index, taking care of under/overlow: first(1)/last(GetNbins())returned ...
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
T eta() const
Definition: PV3DBase.h:73
Log< level::Error, false > LogError
dictionary corr
ii
Definition: cuy.py:589
std::string theCategory
log category: "MuonErrorMatrix"
#define LogDebug(id)
TProfile3D * Index(int i, int j)
internal method to get access to the profiles

Member Data Documentation

◆ theCategory

std::string MuonErrorMatrix::theCategory
private

log category: "MuonErrorMatrix"

Definition at line 74 of file MuonErrorMatrix.h.

Referenced by adjust(), MuonErrorMatrix(), Rms(), and Value().

◆ theD

TDirectory* MuonErrorMatrix::theD
private

the attached root file, where the parametrization is saved

Definition at line 77 of file MuonErrorMatrix.h.

Referenced by close(), and MuonErrorMatrix().

◆ theData

TProfile3D* MuonErrorMatrix::theData[15]
private

15 TProfile, each holding he parametrization of each term of the 5x5

Definition at line 79 of file MuonErrorMatrix.h.

Referenced by close(), Index(), and MuonErrorMatrix().

◆ theData_fast

TProfile3D* MuonErrorMatrix::theData_fast[5][5]
private

Definition at line 80 of file MuonErrorMatrix.h.

Referenced by getFast(), and MuonErrorMatrix().

◆ theTermAction

TermAction MuonErrorMatrix::theTermAction[15]
private

Definition at line 84 of file MuonErrorMatrix.h.

Referenced by adjust(), and MuonErrorMatrix().

◆ vars

const TString MuonErrorMatrix::vars = {"#frac{q}{|p|}", "#lambda", "#varphi_{0}", "X_{T}", "Y_{T}"}
static

names of the variables of the 5x5 error matrix

Definition at line 52 of file MuonErrorMatrix.h.