CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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

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.

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 ( 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, edm::ParameterSet::exists(), beamvalidation::exit(), MillePedeFileConverter_cfg::fileName, edm::FileInPath::fullPath(), das_client::fullpath(), edm::ParameterSet::getParameter(), mps_fire::i, dqmiolumiharvest::j, LogDebug, LogTrace, maxEta, HLT_FULL_cff::maxPhi, HLT_FULL_cff::minPhi, HLT_FULL_cff::minPt, Pi, Pindex(), scale, str, AlCaHLTBitMon_QueryRunRegistry::string, theCategory, theD, theData, theData_fast, theTermAction, use, and makeHLTPrescaleTable::values.

17  : theD(nullptr) {
18  theCategory = "MuonErrorMatrix";
19  std::string action = iConfig.getParameter<std::string>("action");
20 
21  bool madeFromCff = iConfig.exists("errorMatrixValuesPSet");
22  edm::ParameterSet 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;
122  edm::FileInPath data(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
double maxEta
Log< level::Error, false > LogError
def fullpath
Definition: das_client.py:267
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
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
TDirectory * theD
the attached root file, where the parametrization is saved
double a
Definition: hdecay.h:119
vars
Definition: DeepTauId.cc:164
TProfile3D * theData[15]
15 TProfile, each holding he parametrization of each term of the 5x5
#define str(s)
std::string theCategory
log category: &quot;MuonErrorMatrix&quot;
#define LogDebug(id)
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

void MuonErrorMatrix::adjust ( FreeTrajectoryState state)

adjust the error matrix on the state

Definition at line 498 of file MuonErrorMatrix.cc.

References assign, complicatedTerm(), FreeTrajectoryState::curvilinearError(), error, mps_fire::i, dqmiolumiharvest::j, LogDebug, makeMuonMisalignmentScenario::matrix, FreeTrajectoryState::momentum(), FreeTrajectoryState::parameters(), 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 }
const GlobalTrajectoryParameters & parameters() const
Log< level::Error, false > LogError
const CurvilinearTrajectoryError & curvilinearError() const
void complicatedTerm(const AlgebraicSymMatrix55 &input, AlgebraicSymMatrix55 &output)
convert sigma/rho -&gt; sigma2/COV
TermAction theTermAction[15]
int Pindex(int i, int j)
internal methods to get the index of a matrix term.
GlobalVector momentum() const
void simpleTerm(const AlgebraicSymMatrix55 &input, AlgebraicSymMatrix55 &output)
convert sigma2/COV -&gt; sigma/rho
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
std::string theCategory
log category: &quot;MuonErrorMatrix&quot;
#define LogDebug(id)
void MuonErrorMatrix::adjust ( TrajectoryStateOnSurface state)

adjust the error matrix on the state

Definition at line 537 of file MuonErrorMatrix.cc.

References assign, complicatedTerm(), TrajectoryStateOnSurface::curvilinearError(), error, TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalParameters(), mps_fire::i, dqmiolumiharvest::j, LogDebug, makeMuonMisalignmentScenario::matrix, Pindex(), scale, simpleTerm(), TrajectoryStateOnSurface::surface(), TrajectoryStateOnSurface::surfaceSide(), theCategory, theTermAction, and TrajectoryStateOnSurface::weight().

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 }
const CurvilinearTrajectoryError & curvilinearError() const
Log< level::Error, false > LogError
const SurfaceType & surface() const
void complicatedTerm(const AlgebraicSymMatrix55 &input, AlgebraicSymMatrix55 &output)
convert sigma/rho -&gt; sigma2/COV
TermAction theTermAction[15]
SurfaceSide surfaceSide() const
Position relative to material, defined relative to momentum vector.
int Pindex(int i, int j)
internal methods to get the index of a matrix term.
const GlobalTrajectoryParameters & globalParameters() const
void simpleTerm(const AlgebraicSymMatrix55 &input, AlgebraicSymMatrix55 &output)
convert sigma2/COV -&gt; sigma/rho
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
GlobalVector globalMomentum() const
std::string theCategory
log category: &quot;MuonErrorMatrix&quot;
#define LogDebug(id)
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
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:47
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 }
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
const AlgebraicSymMatrix55 & matrix() const
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 }
tuple result
Definition: mps_fire.py:311
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(), MuonErrorMatrixAdjuster::fix_cov_matrix(), 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  }
266  return CurvilinearTrajectoryError(V);
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
TProfile3D* MuonErrorMatrix::get ( int  i,
int  j 
)
inline
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(), PVValHelper::pT, theData_fast, cms::cuda::V, and makeHLTPrescaleTable::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 
304  return CurvilinearTrajectoryError(V);
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
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
T eta() const
Definition: PV3DBase.h:73
unsigned int MuonErrorMatrix::index ( int  i,
int  j 
)
inline

Definition at line 49 of file MuonErrorMatrix.h.

References Pindex().

Referenced by BeautifulSoup.PageElement::_invert().

49 { return Pindex(i, j); }
int Pindex(int i, int j)
internal methods to get the index of a matrix term.
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 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
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 }
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
const AlgebraicSymMatrix55 & matrix() const
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, 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
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(), Index(), LogDebug, PV3DBase< T, PVType, FrameType >::perp(), phi, PV3DBase< T, PVType, FrameType >::phi(), PVValHelper::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
Log< level::Error, false > LogError
tuple result
Definition: mps_fire.py:311
T eta() const
Definition: PV3DBase.h:73
std::string theCategory
log category: &quot;MuonErrorMatrix&quot;
#define LogDebug(id)
TProfile3D * Index(int i, int j)
internal method to get access to the profiles
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:47
T sqrt(T t)
Definition: SSEVec.h:19
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::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
tuple result
Definition: mps_fire.py:311
T sqrt(T t)
Definition: SSEVec.h:19
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(), cuy::ii, Index(), findQualityFiles::jj, LogDebug, PV3DBase< T, PVType, FrameType >::perp(), phi, PV3DBase< T, PVType, FrameType >::phi(), PVValHelper::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
Log< level::Error, false > LogError
int ii
Definition: cuy.py:589
tuple result
Definition: mps_fire.py:311
T eta() const
Definition: PV3DBase.h:73
std::string theCategory
log category: &quot;MuonErrorMatrix&quot;
#define LogDebug(id)
TProfile3D * Index(int i, int j)
internal method to get access to the profiles

Member Data Documentation

std::string MuonErrorMatrix::theCategory
private

log category: "MuonErrorMatrix"

Definition at line 74 of file MuonErrorMatrix.h.

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

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

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

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

Definition at line 80 of file MuonErrorMatrix.h.

Referenced by getFast(), and MuonErrorMatrix().

TermAction MuonErrorMatrix::theTermAction[15]
private

Definition at line 84 of file MuonErrorMatrix.h.

Referenced by adjust(), and MuonErrorMatrix().

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.