15 const TString
MuonErrorMatrix::vars[5] = {
"#frac{q}{|p|}",
"#lambda",
"#varphi_{0}",
"X_{T}",
"Y_{T}"};
21 bool madeFromCff = iConfig.
exists(
"errorMatrixValuesPSet");
33 std::vector<double>
xBins;
34 double *xBinsArray =
nullptr;
38 std::vector<double>
yBins;
39 double *yBinsArray =
nullptr;
59 xBinsArray = &(
xBins.front());
74 yBinsArray = &(
yBins.front());
81 if (
get.
str() ==
"-Pi") {
83 }
else if (
get.
str() ==
"Pi") {
89 if (
get.
str() ==
"-Pi") {
91 }
else if (
get.
str() ==
"Pi") {
97 else if (madeFromCff) {
100 xBinsArray = &(
xBins.front());
106 yBinsArray = &(
yBins.front());
112 if (
zBins.size() != 2) {
126 theD->SetWritable(
false);
128 static std::atomic<unsigned int> neverTheSame{0};
129 std::stringstream
dirName(
"MuonErrorMatrixDirectory");
132 <<
"using an error matrix object from configuration file. putting memory histograms to: " <<
dirName.str();
134 theD =
new TDirectory(
dirName.str().c_str(),
"transient directory to host MuonErrorMatrix TProfile3D");
135 theD->SetWritable(
false);
142 if (
a ==
use && !madeFromCff) {
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) {
155 pf = (TProfile3D *)
theD->Get(pfname);
165 pftitle =
"#sigma_{" +
vars[
i] +
"}";
167 pftitle =
"#rho(" +
vars[
i] +
"," +
vars[
j] +
")";
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");
177 pf->GetXaxis()->Set(
NPt, xBinsArray);
180 pf->GetYaxis()->Set(
NEta, yBinsArray);
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) {
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),
208 if (tAction ==
"scale")
210 else if (tAction ==
"assign")
231 for (
int i = 0;
i != 15;
i++) {
245 if (
theD->IsWritable()) {
246 for (
int i = 0;
i != 15;
i++) {
261 for (
int i = 0;
i != 5;
i++) {
262 for (
int j =
i;
j != 5;
j++) {
274 double pT = momentum.
perp();
275 double eta = fabs(momentum.
eta());
276 double phi = momentum.
phi();
285 for (
int i = 0;
i != 5;
i++) {
286 for (
int j =
i;
j != 5;
j++) {
291 for (
int i = 0;
i != 5;
i++) {
292 for (
int j =
i;
j != 5;
j++) {
327 else if (
result > axis->GetNbins())
328 result = axis->GetNbins();
340 double pT = momentum.
perp();
341 double eta = fabs(momentum.
eta());
342 double phi = momentum.
phi();
344 int iBin_x =
findBin(ij->GetXaxis(),
pT);
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));
375 <<
"\nrho[" <<
i <<
"," <<
j <<
"]: " <<
corr <<
" [" << iBin_x <<
", " << iBin_y <<
", " 377 <<
"\nsigma[" <<
i <<
"," <<
i <<
"]: " << sigma_1 <<
"\nsigma[" <<
j <<
"," <<
j 378 <<
"]: " << sigma_2 <<
"Covariance[" <<
i <<
"," <<
j <<
"] is: " <<
result;
383 result = ij->GetBinContent(iBin_x, iBin_y, iBin_z);
391 result = ij->GetBinContent(iBin_x, iBin_y, iBin_z);
403 double pT = momentum.
perp();
404 double eta = fabs(momentum.
eta());
405 double phi = momentum.
phi();
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);
429 double si = curv(
i,
i);
430 double sj = curv(
j,
j);
431 if (si <= 0 || sj <= 0) {
433 edm::LogError(
"MuonErrorMatrix") <<
"invalid term in the error matrix.\n si: " << si <<
" sj: " << sj
434 <<
". result will be corrupted\n" 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);
465 for (
int i = 0;
i != 5;
i++) {
466 for (
int j =
i;
j != 5;
j++) {
467 if (denom_matrix(
i,
j) == 0)
469 num_matrix(
i,
j) /= denom_matrix(
i,
j);
477 for (
int i = 0;
i != 5;
i++) {
478 for (
int j =
i;
j != 5;
j++) {
488 for (
int i = 0;
i != 5;
i++) {
489 for (
int j =
i;
j != 5;
j++) {
508 for (
int i = 0;
i != 5;
i++) {
509 for (
int j =
i;
j != 5;
j++) {
513 simpleTerms(
i,
j) *= simpleValues(
i,
j);
517 simpleTerms(
i,
j) = simpleValues(
i,
j);
526 LogDebug(
theCategory +
"|Adjust") <<
"updated state sigma(i), rho(i,j): \n" << simpleTerms;
545 for (
int i = 0;
i != 5;
i++) {
546 for (
int j =
i;
j != 5;
j++) {
550 simpleTerms(
i,
j) *= simpleValues(
i,
j);
554 simpleTerms(
i,
j) = simpleValues(
i,
j);
563 LogDebug(
theCategory +
"|Adjust") <<
"updated state sigma(i), rho(i,j): \n" << simpleTerms;
Log< level::Info, true > LogVerbatim
void adjust(FreeTrajectoryState &state)
adjust the error matrix on the state
T getParameter(std::string const &) const
static bool divide(CurvilinearTrajectoryError &num_error, const CurvilinearTrajectoryError &denom_error)
divide term by term the two matrix
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
static const TString vars[5]
names of the variables of the 5x5 error matrix
bool exists(std::string const ¶meterName) const
checks if a parameter exists
double Value(GlobalVector &momentum, int i, int j, bool convolute=true)
internal method that retreives the value of the parametrization for term i,j
CurvilinearTrajectoryError get(GlobalVector momentum, bool convolute=true)
main method to be used. Retrieve a 5x5 symetrical matrix according to parametrization of error or sca...
~MuonErrorMatrix()
destructor
Log< level::Error, false > LogError
static double Term(const AlgebraicSymMatrix55 &curv, int i, int j)
provide the numerical value used. sigma or correlation factor
action
enum type to define if the class is used as a tool or to be created
static std::string const input
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t V
void complicatedTerm(const AlgebraicSymMatrix55 &input, AlgebraicSymMatrix55 &output)
convert sigma/rho -> sigma2/COV
TermAction theTermAction[15]
MuonErrorMatrix(const edm::ParameterSet &pset)
constructor from a parameter set
static void multiply(CurvilinearTrajectoryError &initial_error, const CurvilinearTrajectoryError &scale_error)
multiply term by term the two matrix
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
void simpleTerm(const AlgebraicSymMatrix55 &input, AlgebraicSymMatrix55 &output)
convert sigma2/COV -> sigma/rho
const AlgebraicSymMatrix55 & matrix() const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
NEta
set NEta=0 and the vector of double for variable size binning
double Rms(GlobalVector &momentum, int i, int j)
internal method that retreives the error on the value of the parametrization for term i...
char data[epos_bytes_allocation]
TDirectory * theD
the attached root file, where the parametrization is saved
CurvilinearTrajectoryError getFast(GlobalVector momentum)
TProfile3D * theData[15]
15 TProfile, each holding he parametrization of each term of the 5x5
std::string theCategory
log category: "MuonErrorMatrix"
void close()
close the root file attached to the class
TProfile3D * Index(int i, int j)
internal method to get access to the profiles