20 bool madeFromCff=iConfig.
exists(
"errorMatrixValuesPSet");
29 std::vector<double> xBins;
30 double * xBinsArray = 0;
34 std::vector<double> yBins;
35 double * yBinsArray =0;
50 xBins = iConfig.
getParameter<std::vector<double> >(
"PtBins");
53 xBinsArray = &(xBins.front());
54 minPt = xBins.front();
55 maxPt = xBins.back();}
62 yBins = iConfig.
getParameter<std::vector<double> >(
"EtaBins");
63 if (yBins.size()==0){
edm::LogError(
theCategory)<<
"NEta=0 and no entries in the vector. I will do aseg fault soon.";}
64 NEta = yBins.size()-1;
65 yBinsArray = &(yBins.front());
66 minPt = yBins.front();
67 maxPt = yBins.back();}
71 if (
get.str() ==
"-Pi")
73 else if(
get.str() ==
"Pi")
77 if (
get.str() ==
"-Pi")
79 else if(
get.str() ==
"Pi")
83 else if (madeFromCff){
85 xBins = errorMatrixValuesPSet.
getParameter<std::vector<double> >(
"xAxis");
87 xBinsArray = &(xBins.front());
88 minPt = xBins.front();
91 yBins = errorMatrixValuesPSet.
getParameter<std::vector<double> >(
"yAxis");
92 NEta = yBins.size()-1;
93 yBinsArray = &(yBins.front());
94 minPt = yBins.front();
97 std::vector<double> zBins = errorMatrixValuesPSet.
getParameter<std::vector<double> >(
"zAxis");
101 minPhi=zBins.front();
112 theD =
new TFile(fullpath.c_str());
113 theD->SetWritable(
false);
115 static unsigned int neverTheSame=0;
116 std::stringstream
dirName(
"MuonErrorMatrixDirectory");
117 dirName<<neverTheSame++;
118 edm::LogInfo(
theCategory)<<
"using an error matrix object from configuration file. putting memory histograms to: "<<dirName.str();
120 theD =
new TDirectory(dirName.str().c_str(),
"transient directory to host MuonErrorMatrix TProfile3D");
121 theD->SetWritable(
false);
126 theD =
new TFile(fileName.c_str(),
"recreate");
129 if (a==
use && !madeFromCff ){gROOT->cd();}
132 for (
int i=0;
i!=5;
i++){
for (
int j=
i;
j!=5;
j++){
133 TString pfname(Form(
"pf3_V%1d%1d",
i+1,
j+1));
135 if (a==
use && !madeFromCff ){
138 pf = (TProfile3D *)
theD->Get(pfname);
147 if (
i==
j){pftitle=
"#sigma_{"+
vars[
i]+
"}";}
148 else{pftitle=
"#rho("+
vars[
i]+
","+
vars[
j]+
")";}
150 pf =
new TProfile3D(pfname,pftitle,NPt,minPt,maxPt,NEta,minEta,maxEta,NPhi,minPhi,maxPhi,
"S");
151 pf->SetXTitle(
"muon p_{T} [GeV]");
152 pf->SetYTitle(
"muon |#eta|");
153 pf->SetZTitle(
"muon #varphi");
157 pf->GetXaxis()->Set(NPt,xBinsArray);}
159 pf->GetYaxis()->Set(NEta,yBinsArray);}
165 unsigned int iX=pf->GetNbinsX();
166 unsigned int iY=pf->GetNbinsY();
167 unsigned int iZ=pf->GetNbinsZ();
168 unsigned int continuous_i=0;
169 for(
unsigned int ix=1;ix<=iX;++ix){
170 for(
unsigned int iy=1;iy<=iY;++iy){
171 for(
unsigned int iz=1;iz<=iZ;++iz){
173 <<
"\n pt (x)= "<<pf->GetXaxis()->GetBinCenter(ix)
174 <<
"\n eta (y)= "<<pf->GetYaxis()->GetBinCenter(iy)
175 <<
"\n phi (z)= "<<pf->GetZaxis()->GetBinCenter(iz)
176 <<
"\n value= "<<values[continuous_i];
177 pf->Fill(pf->GetXaxis()->GetBinCenter(ix),
178 pf->GetYaxis()->GetBinCenter(iy),
179 pf->GetZaxis()->GetBinCenter(iz),
180 values[continuous_i++]);
184 if (tAction ==
"scale")
186 else if (tAction ==
"assign")
206 for (
int i=0;
i!=15;
i++){
208 <<
" "<<
theData[
i]->GetTitle()<<std::endl;}}
219 if (
theD->IsWritable()){
233 for (
int i=0;
i!=5;
i++){
for (
int j=
i;
j!=5;
j++){
234 V(
i,
j) =
Value(momentum,
i,
j,convolute);}}
242 double pT = momentum.
perp();
243 double eta = fabs(momentum.
eta());
244 double phi = momentum.
phi();
253 for (
int i=0;
i!=5;
i++){
for (
int j=
i;
j!=5;
j++){
257 for (
int i=0;
i!=5;
i++){
for (
int j=
i;
j!=5;
j++){
260 V(
i,
j) = values[
i][
j];
265 V(
i,
j) = values[
i][
i] * values[
j][
j] * values[
i][
j];
290 int result = axis->FindBin(value);
291 if (result <= 0) result=1;
292 else if (result > axis->GetNbins() ) result = axis->GetNbins();
298 TProfile3D * ij =
Index(i,j);
301 double pT = momentum.
perp();
302 double eta = fabs(momentum.
eta());
303 double phi = momentum.
phi();
305 int iBin_x=
findBin(ij->GetXaxis(),pT);
318 int iBin_i_x =
findBin(ii->GetXaxis(),pT);
321 int iBin_j_x =
findBin(jj->GetXaxis(),pT);
325 double corr = ij->GetBinContent(iBin_x,iBin_y,iBin_z);
326 double sigma_1 = (ii->GetBinContent(iBin_i_x,iBin_i_y,iBin_i_z));
327 double sigma_2 = (jj->GetBinContent(iBin_j_x,iBin_j_y,iBin_j_z));
330 result=corr*sigma_1*sigma_2;
332 <<
"\nrho["<<i<<
","<<j<<
"]: "<<corr<<
" ["<< iBin_x<<
", "<<iBin_y<<
", "<<iBin_z<<
"]"
333 <<
"\nsigma["<<i<<
","<<i<<
"]: "<< sigma_1
334 <<
"\nsigma["<<j<<
","<<j<<
"]: "<< sigma_2
335 <<
"Covariance["<<i<<
","<<j<<
"] is: "<<
result;
341 result=ij->GetBinContent(iBin_x,iBin_y,iBin_z);
348 result=ij->GetBinContent(iBin_x,iBin_y,iBin_z);
355 TProfile3D * ij =
Index(i,j);
357 double pT = momentum.
perp();
358 double eta = fabs(momentum.
eta());
359 double phi = momentum.
phi();
361 int iBin_x= ij->GetXaxis()->FindBin(pT);
362 int iBin_y= ij->GetYaxis()->FindBin(eta);
363 int iBin_z= ij->GetZaxis()->FindBin(phi);
364 result=ij->GetBinError(iBin_x,iBin_y,iBin_z);
379 return sqrt(result);}
381 double si = curv(i,i);
382 double sj = curv(j,j);
385 edm::LogError(
"MuonErrorMatrix")<<
"invalid term in the error matrix.\n si: "
386 <<si<<
" sj: "<<sj<<
". result will be corrupted\n"<<curv;
393 return result = curv(i,j)/(si*sj);}
405 for(
int i = 0;
i!=5;
i++){
for(
int j =
i;
j!=5;
j++){
406 revised_matrix(
i,
j)*=scale_matrix(
i,
j);
416 for(
int i = 0;
i!=5;
i++){
for(
int j =
i;
j!=5;
j++){
417 if (denom_matrix(
i,
j)==0)
return false;
418 num_matrix(
i,
j)/=denom_matrix(
i,
j);
425 for(
int i = 0;
i!=5;
i++){
for(
int j =
i;
j!=5;
j++){
435 for(
int i = 0;
i!=5;
i++){
for(
int j =
i;
j!=5;
j++){
456 for(
int i = 0;
i!=5;
i++){
for(
int j =
i;
j!=5;
j++){
461 simpleTerms(
i,
j) *= simpleValues(
i,
j);
466 simpleTerms(
i,
j) = simpleValues(
i,
j);
497 for(
int i = 0;
i!=5;
i++){
for(
int j =
i;
j!=5;
j++){
502 simpleTerms(
i,
j) *= simpleValues(
i,
j);
507 simpleTerms(
i,
j) = simpleValues(
i,
j);
T getParameter(std::string const &) const
void adjust(FreeTrajectoryState &state)
adjust the error matrix on the state
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 ...
const GlobalTrajectoryParameters & parameters() const
static const TString vars[5]
names of the variables of the 5x5 error matrix
const CurvilinearTrajectoryError & curvilinearError() const
double Value(GlobalVector &momentum, int i, int j, bool convolute=true)
internal method that retreives the value of the parametrization for term i,j
Geom::Phi< T > phi() const
bool exists(std::string const ¶meterName) const
checks if a parameter exists
CurvilinearTrajectoryError get(GlobalVector momentum, bool convolute=true)
main method to be used. Retrieve a 5x5 symetrical matrix according to parametrization of error or sca...
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
~MuonErrorMatrix()
destructor
static double Term(const AlgebraicSymMatrix55 &curv, int i, int j)
provide the numerical value used. sigma or correlation factor
const CurvilinearTrajectoryError & curvilinearError() const
action
enum type to define if the class is used as a tool or to be created
static std::string const input
const SurfaceType & surface() const
void complicatedTerm(const AlgebraicSymMatrix55 &input, AlgebraicSymMatrix55 &output)
convert sigma/rho -> sigma2/COV
TermAction theTermAction[15]
SurfaceSide surfaceSide() const
Position relative to material, defined relative to momentum vector.
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.
GlobalVector momentum() const
TProfile3D * theData_fast[5][5]
const GlobalTrajectoryParameters & globalParameters() const
void simpleTerm(const AlgebraicSymMatrix55 &input, AlgebraicSymMatrix55 &output)
convert sigma2/COV -> sigma/rho
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]
const AlgebraicSymMatrix55 & matrix() const
GlobalVector globalMomentum() const
TDirectory * theD
the attached root file, where the parametrization is saved
CurvilinearTrajectoryError getFast(GlobalVector momentum)
std::string fullPath() const
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