27 declareProperty(
"EgammaCalibAndSmearingTool",
m_energyRescaler = ToolHandle<CP::IEgammaCalibrationAndSmearingTool>(
"CP::EgammaCalibrationAndSmearingTool"));
28 declareProperty(
"MuonCalibrationAndSmearingTool",
m_mu_resolSFTool = ToolHandle<CP::IMuonCalibrationAndSmearingTool>(
"CP::MuonCalibrationAndSmearingTool"));
41 ATH_MSG_ERROR (
"initialize: unable to retrieve EgammaCalibrationAndSmearingTool");
42 return StatusCode::FAILURE;
46 ATH_MSG_ERROR (
"initialize: unable to retrieve MuonCalibrationAndSmearingTool");
47 return StatusCode::FAILURE;
51 return StatusCode::SUCCESS;
61 return StatusCode::FAILURE;
67 return StatusCode::SUCCESS;
85 const TLorentzVector& fsr4Vec,
89 ATH_MSG_DEBUG (
"addFSRParticle: *** 4vecFsr: " << fsr4Vec.Pt() <<
"/" << fsr4Vec.Eta() <<
"/" << fsr4Vec.Phi());
101 e_res =
m_energyRescaler->resolution( fsr4Vec.E(), fsr4Vec.Eta(), cl_etaCalo, phType)*fsr4Vec.E();
104 ATH_MSG_ERROR(
"addFSRParticle: - cannot find EgammaCalibrationAndSmearingTool. ");
105 ATH_MSG_ERROR(
"addFSRParticle: - please set property 'EgammaCalibAndSmearingToolName' with the name of your EgammaCalibrationAndSmearingTool - default is 'EgammaCalibrationAndSmearingTool'. ");
109 photonCovarianceMatrix.setZero();
110 photonCovarianceMatrix(
d0,
d0) = 0.000001;
111 photonCovarianceMatrix(
z0,
z0) = 0.000001;
112 photonCovarianceMatrix(
phi0,
phi0) = 0.000001;
113 photonCovarianceMatrix(
theta,
theta) = 0.000001;
115 photonCovarianceMatrix(
d0,
z0) = 0;
116 photonCovarianceMatrix(
d0,
phi0) = 0;
117 photonCovarianceMatrix(
d0,
theta) = 0;
118 photonCovarianceMatrix(
d0,
qOverP) = 0;
119 photonCovarianceMatrix(
z0,
phi0) = 0;
120 photonCovarianceMatrix(
z0,
theta) = 0;
121 photonCovarianceMatrix(
z0,
qOverP) = 0;
126 ATH_MSG_DEBUG (
"addFSRParticle: FSR calib type,e, e_res " << phType <<
" " << fsr4Vec.E() <<
" " << e_res);
129 for (
int ii = 0; ii < 5; ii++)
130 for (
int jj = ii + 1; jj < 5; jj++)
131 photonCovarianceMatrix(jj, ii) = photonCovarianceMatrix(ii, jj);
139 input.addConstituent_FourVector_d0z0PhiThetaP(fsr4Vec, photonCovarianceMatrix, covarXYZ, isOK);
155 TLorentzVector mu4vec;
158 static const SG::AuxElement::ConstAccessor<float> muonSpectrometerPt (
"MuonSpectrometerPt");
159 static const SG::AuxElement::ConstAccessor<float> innerDetectorPt (
"InnerDetectorPt");
163 const xAOD::TrackParticle* track = mu.trackParticle(xAOD::Muon::TrackParticleType::Primary);
164 bool set4vec =
false;
165 if (((
isMS_MCMT == muonType) || (
isID_MCMT == muonType)) && xAOD::Muon::MuonType::Combined == mu.muonType()) {
167 track = mu.trackParticle(xAOD::Muon::MuonSpectrometerTrackParticle);
168 if (!muonSpectrometerPt.isAvailable(mu))
169 ATH_MSG_ERROR(
"addParticle: - could not get muonSpectrometerPt from muon. Please applyCorrection with the MuonCalibAndSmearTool");
171 ATH_MSG_ERROR(
"addParticle: - Combined muon is missing MS track particle. Using combined track particle");
172 track = mu.trackParticle(xAOD::Muon::TrackParticleType::Primary);
174 mu4vec.SetPtEtaPhiM(muonSpectrometerPt(mu), track->eta(), track->phi(), mu.m());
179 track = mu.trackParticle(xAOD::Muon::InnerDetectorTrackParticle);
180 if (!innerDetectorPt.isAvailable(mu))
181 ATH_MSG_ERROR(
"addParticle: - could not get innerDetectorPt from muon. Please applyCorrection with the MuonCalibAndSmearTool");
182 mu4vec.SetPtEtaPhiM(innerDetectorPt(mu), track->eta(), track->phi(), mu.m());
188 if (!set4vec) mu4vec.SetPtEtaPhiM(mu.pt(), mu.eta(), mu.phi(), mu.m());
191 ATH_MSG_ERROR(
"addParticle: - could not get track particle for muon");
195 ATH_MSG_DEBUG (
"addParticle: *** 4vecMu: " << mu4vec.Pt() <<
"/" << mu4vec.Eta() <<
"/" << mu4vec.Phi());
244 covmatrix(
d0,
d0) = track->definingParametersCovMatrix()(
d0,
d0);
245 covmatrix(
z0,
z0) = track->definingParametersCovMatrix()(
z0,
z0);
249 covmatrix(
d0,
z0) = track->definingParametersCovMatrix()(
d0,
z0);
250 covmatrix(
d0,
phi0) = track->definingParametersCovMatrix()(
d0,
phi0);
251 covmatrix(
d0,
theta) = track->definingParametersCovMatrix()(
d0,
theta);
252 covmatrix(
d0,
qOverP) = track->definingParametersCovMatrix()(
d0,
qOverP)*muSF;
253 covmatrix(
z0,
phi0) = track->definingParametersCovMatrix()(
z0,
phi0);
254 covmatrix(
z0,
theta) = track->definingParametersCovMatrix()(
z0,
theta);
255 covmatrix(
z0,
qOverP) = track->definingParametersCovMatrix()(
z0,
qOverP)*muSF;
262 <<
" " << track->definingParametersCovMatrix()(
d0,
d0)
263 <<
" " << track->definingParametersCovMatrix()(
z0,
z0)
264 <<
" " << track->definingParametersCovMatrix()(
phi0,
phi0)
265 <<
" " << track->definingParametersCovMatrix()(
theta,
theta)
266 <<
" " << track->definingParametersCovMatrix()(
qOverP,
qOverP)*muSF*muSF
267 <<
" " << track->definingParametersCovMatrix()(
d0,
z0)
268 <<
" " << track->definingParametersCovMatrix()(
d0,
phi0)
269 <<
" " << track->definingParametersCovMatrix()(
d0,
theta)
270 <<
" " << track->definingParametersCovMatrix()(
d0,
qOverP)*muSF
271 <<
" " << track->definingParametersCovMatrix()(
z0,
phi0)
272 <<
" " << track->definingParametersCovMatrix()(
z0,
theta)
273 <<
" " << track->definingParametersCovMatrix()(
z0,
qOverP)*muSF
274 <<
" " << track->definingParametersCovMatrix()(
phi0,
theta)
275 <<
" " << track->definingParametersCovMatrix()(
phi0,
qOverP)*muSF
276 <<
" " << track->definingParametersCovMatrix()(
theta,
qOverP)*muSF);
278 for (
int ii = 0; ii < 5; ii++)
279 for (
int jj = ii+1; jj < 5; jj++)
280 covmatrix(jj,ii) = covmatrix(ii,jj);
285 double P = mu4vec.P();
292 jacobian0(4,4) = -
P*
P;
294 AmgMatrix(5,5) newmatrix = jacobian0.transpose() * covmatrix * jacobian0;
304 input.addConstituent_FourVector_d0z0PhiThetaP(mu4vec, newmatrix, covarXYZ, isOK);
315 float el_E_res = elEnergyRes;
326 ATH_MSG_ERROR(
"addParticle: - ERROR could not get track particle for electron");
330 ATH_MSG_DEBUG (
"addParticle: *** 4vecEl: " << el.pt() <<
"/" << el.eta() <<
"/" << el.phi());
334 covmatrix(
d0,
d0) = track->definingParametersCovMatrix()(
d0,
d0);
335 covmatrix(
z0,
z0) = track->definingParametersCovMatrix()(
z0,
z0);
339 covmatrix(
d0,
z0) = track->definingParametersCovMatrix()(
d0,
z0);
340 covmatrix(
d0,
phi0) = track->definingParametersCovMatrix()(
d0,
phi0);
341 covmatrix(
d0,
theta) = track->definingParametersCovMatrix()(
d0,
theta);
343 covmatrix(
z0,
phi0) = track->definingParametersCovMatrix()(
z0,
phi0);
344 covmatrix(
z0,
theta) = track->definingParametersCovMatrix()(
z0,
theta);
351 <<
" " << el_E_res <<
" " << el.e()
352 <<
" " << track->definingParametersCovMatrix()(
d0,
d0)
353 <<
" " << track->definingParametersCovMatrix()(
z0,
z0)
354 <<
" " << track->definingParametersCovMatrix()(
phi0,
phi0)
355 <<
" " << track->definingParametersCovMatrix()(
theta,
theta)
356 <<
" " << track->definingParametersCovMatrix()(
d0,
z0)
357 <<
" " << track->definingParametersCovMatrix()(
d0,
phi0)
358 <<
" " << track->definingParametersCovMatrix()(
d0,
theta)
359 <<
" " << track->definingParametersCovMatrix()(
z0,
phi0)
360 <<
" " << track->definingParametersCovMatrix()(
z0,
theta)
361 <<
" " << track->definingParametersCovMatrix()(
phi0,
theta));
365 for(
int ii=0;ii<5;ii++)
366 for(
int jj=ii+1;jj<5;jj++)
367 covmatrix(jj,ii) = covmatrix(ii,jj);
375 input.addConstituent_FourVector_d0z0PhiThetaP(el.p4(), covmatrix, covarXYZ, isOK);
379 ATH_MSG_VERBOSE(
"addParticle: - el\n" << input.getCovarianceCartesian(input.getNConstituents()-1));
393 ATH_MSG_ERROR(
"massFitInterface: Found number of input particles less than 2");
411 for (
unsigned int iobj = 0; iobj <
m_nobj; iobj++)
420 m_covarianceInit(i + 3*iobj, j + 3*iobj) = (theInput.getCovarianceCartesian(iobj))(i + 2, j + 2);
423 for(
unsigned int i=0;i<dimension;i++)
426 for(
unsigned int j=0;j<dimension;j++)
438 const int columns =
m_nobj;
440 p =
new double *[rows] ;
441 for(
int i = 0 ; i < rows ; i++ )
442 p[i] =
new double[columns];
444 for(
unsigned int iobj=0; iobj<
m_nobj; iobj++)
450 p[3][iobj] += p[i][iobj]*p[i][iobj];
452 p[3][iobj] = sqrt(p[3][iobj]);
458 for(
unsigned int ij=0;ij<
m_nobj;ij++)
465 for(
int i = 0 ; i < rows ; i++ )
469 double initMass = Etot * Etot - Xtot * Xtot - Ytot * Ytot - Ztot * Ztot;
470 initMass = sqrt(initMass);
472 double sig = MassResol;
473 double xLeft = initMass;
481 if (dLinitL * dLinitR < 0.) {
482 while (xRight - xLeft > 1.) {
483 double xM = (xRight + xLeft) / 2.;
485 if (dL * dLinitL < 0.) {
493 return (xLeft + xRight) / 2.;
495 if (dLinitL > dLinitR)
507 const int columns =
m_nobj;
509 p =
new double *[rows] ;
510 for(
int i = 0 ; i < rows ; i++ )
511 p[i] =
new double[columns];
513 for(
unsigned int iobj=0; iobj<
m_nobj; iobj++) {
515 for(
int i=0;i<3;i++) {
517 p[3][iobj] += p[i][iobj]*p[i][iobj];
519 p[3][iobj] = sqrt(p[3][iobj]);
525 for(
unsigned int ij=0;ij<
m_nobj;ij++) {
532 double initMass = etot * etot - xtot * xtot - ytot * ytot - ztot * ztot;
533 initMass = sqrt(initMass);
536 jacobianMass.setZero();
537 for(
unsigned int ii=0;ii<
m_nobj;ii++) {
538 jacobianMass(3*ii + 0, 0) = (2.*(etot) * p[0][ii] / p[3][ii] - 2.* xtot);
539 jacobianMass(3*ii + 1, 0) = (2.*(etot) * p[1][ii] / p[3][ii] - 2.* ytot);
540 jacobianMass(3*ii + 2, 0) = (2.*(etot) * p[2][ii] / p[3][ii] - 2.* ztot);
549 double sig = sigm(0, 0);
553 double MassResol = sig;
554 double maxmass = initMass;
558 double max = -(maxmass - initMass) * (maxmass - initMass) / 2. / MassResol / MassResol
561 for (
int i = 1; i < 401; i++) {
562 double ytest = initMass + (
m_conMass - initMass) / 400 * i;
564 double val = -(ytest - initMass) * (ytest - initMass) / 2. / MassResol / MassResol
575 for(
int i = 0 ; i < rows ; i++ )
591 ATH_MSG_WARNING(
"ConstraintFit::massFitRun()(cont) Following H->4l group decision (Feb 1, 2013), this event will not be fit");
592 ATH_MSG_WARNING(
"ConstraintFit::massFitRun()(cont) To bypass this behaviour set the ingore flag");
594 std::vector<TLorentzVector> particleList;
595 for(
unsigned int i=0;i<
m_nobj;i++)
597 TLorentzVector particle;
602 particleList.push_back(particle);
607 for(
unsigned int iobj=0;iobj<
m_nobj;iobj++)
608 for(
int ii=0;ii<5;ii++)
609 for(
int jj=0;jj<5;jj++)
610 covOut(ii+5*iobj,jj+5*iobj) =
m_theInput.getCovarianceCartesian(iobj)(ii,jj);
616 covard0z0PhiThetaP.setZero();
619 output.setFitOutput(particleList, covOut, covard0z0PhiThetaP);
645 std::vector<TLorentzVector> particleList;
646 for(
unsigned int i=0;i<
m_nobj;i++) {
647 TLorentzVector particle;
652 particleList.push_back(particle);
659 for(
unsigned int iobj=0;iobj<
m_nobj;iobj++)
660 for(
int ii=0;ii<2;ii++)
661 for(
int jj=0;jj<2;jj++)
662 covOut(ii+5*iobj,jj+5*iobj) =
m_theInput.getCovarianceCartesian(iobj)(ii,jj);
663 for(
unsigned int iobj=0;iobj<
m_nobj;iobj++)
664 for(
int ii=2;ii<5;ii++)
665 for(
int jj=2;jj<5;jj++)
673 for(
unsigned int iobj1=0;iobj1<
m_nobj;iobj1++) {
674 for(
unsigned int iobj2=0;iobj2<
m_nobj;iobj2++) {
675 if(iobj1 == iobj2)
continue;
676 for(
int ii=2;ii<5;ii++)
677 for(
int jj=2;jj<5;jj++)
687 covard0z0PhiThetaP.setZero();
690 output.setFitOutput(particleList, covOut, covard0z0PhiThetaP);
701 for(
unsigned int iobj = 0; iobj <
m_nobj; iobj++) {
702 aa +=
m_theInput.getConstituentFourVector(iobj);
704 double massInit = aa.M();
712 for(
unsigned int iobj = 0; iobj <
m_nobj; iobj++) {
713 for(
int ii = 0; ii < 5; ii++) {
714 for(
int jj = 0; jj < 5; jj++) {
715 covOut(ii+5*iobj, jj+5*iobj) =
m_theInput.getCovarianceCartesian(iobj)(ii, jj);
726 std::vector<double> resolInit;
727 std::vector<double> resolFinal;
728 std::vector<double> resolFinalnew;
729 resolInit.reserve(
m_nobj);
730 resolFinal.reserve(
m_nobj);
731 resolFinalnew.reserve(
m_nobj);
732 double sumResolInit=0.;
734 for(
unsigned int iobj = 0; iobj <
m_nobj; iobj++) {
738 resolInit.push_back((
m_theInput.getConstituentCovariance(iobj))(4,4));
744 output.getConstituentCovarianced0z0PhiThetaP(iobj, tmpMtx);
745 resolFinal.push_back(tmpMtx(4,4));
750 sumResolInit += resolInit[iobj];
757 for(
unsigned int iobj=0;iobj<
m_nobj;iobj++) {
758 resolFinalnew.push_back( resolFinal[iobj] + constraintWidthSquare *
759 resolInit[iobj]*resolInit[iobj]
760 /sumResolInit/sumResolInit );
761 covOut(4+5*iobj,4+5*iobj) = covOut(4+5*iobj,4+5*iobj)*resolFinalnew[iobj]/resolFinal[iobj];
762 covOut(3+5*iobj,3+5*iobj) = covOut(3+5*iobj,3+5*iobj)*resolFinalnew[iobj]/resolFinal[iobj];
763 covOut(2+5*iobj,2+5*iobj) = covOut(2+5*iobj,2+5*iobj)*resolFinalnew[iobj]/resolFinal[iobj];
777 output.setFitOutput(particleList, covOut, covard0z0PhiThetaP);
790 const int columns =
m_nobj;
793 p =
new double *[rows] ;
794 for(
int i = 0 ; i < rows ; i++ )
795 p[i] =
new double[columns];
797 for(
unsigned int iobj=0; iobj<
m_nobj; iobj++) {
801 p[i][iobj] = p0(i+3*iobj, 0);
802 p[3][iobj] += p[i][iobj]*p[i][iobj];
804 p[3][iobj] = sqrt(p[3][iobj]);
811 for(
unsigned int ij=0;ij<
m_nobj;ij++)
818 double XYZtot[3] = {Xtot, Ytot, Ztot};
819 std::vector<double> constraintD;
820 for(
unsigned int ij=0;ij<
m_nobj;ij++)
821 for(
int ik=0;ik<3;ik++)
822 constraintD.push_back((2.*(Etot) * p[ik][ij] / p[3][ij] - 2.* XYZtot[ik]));
824 double constraintd = Etot * Etot - Xtot * Xtot - Ytot * Ytot - Ztot * Ztot;
825 constraintd = constraintd - mass * mass;
828 for(
unsigned int ij=0;ij<3*
m_nobj;ij++)
829 D(0, ij) = constraintD.at(ij);
831 d(0, 0) = constraintd;
836 DVDinverse=DVD.inverse();
841 Amg::MatrixX Vp(var - var * D.transpose() * VD * D * var);
842 for(
unsigned int ij=0;ij<3*
m_nobj;ij++) {
843 p0(ij, 0) = test(ij, 0);
845 for(
unsigned int jk = 0; jk < 3 *
m_nobj; jk++)
848 double constraintValue = d(0, 0);
850 for(
int i = 0 ; i < rows ; i++ )
853 return constraintValue;
863 int maxIterations = 20;
865 double constraintValue = -1.e10;
867 <<
" Iterations " << iIter
870 <<
" Iteration " << iIter);
878 double maxDiff = 5.e15;
881 diff(i, 0) =
diff(i, 0) / p_old(i, 0);
882 if (maxDiff >
diff(i, 0))
883 maxDiff =
diff(i, 0);
885 if ((maxDiff < 1.e-4 && fabs(constraintValue) < 5.e-5) || maxIterations <= iIter)
888 <<
" Iterations " << iIter
891 <<
" \n Iteration " << iIter <<
" doIter " << doIter);
896 <<
" Iterations " << iIter
899 <<
" Iteration " << iIter);
911 unsigned int nPart = nPartFirst + nPartSecond;
912 std::vector<TLorentzVector> particles(nPart);
913 std::vector<
AmgMatrix(3,3)> covariances(nPart);
914 for (
unsigned int iobj = 0; iobj < firstInput.
getNConstituents(); ++iobj) {
915 covariances[iobj].setZero();
919 for (
unsigned int iobj = 0; iobj < secondInput.
getNConstituents(); ++iobj) {
920 covariances[iobj + nPartFirst].setZero();
935 unsigned int nPart = nPartFirst + nPartSecond;
936 std::vector<TLorentzVector> particles(nPart);
937 std::vector<
AmgMatrix(3,3)> covariances(nPart);
939 covariances[iobj].setZero();
943 for (
unsigned int iobj = 0; iobj < extraInput.
getNConstituents(); ++iobj) {
944 covariances[iobj + nPartFirst].setZero();
960 unsigned int nPart = nPartFirst + nPartSecond;
961 std::vector<TLorentzVector> particles(nPart);
962 std::vector<
AmgMatrix(3,3)> covariances(nPart);
964 covariances[iobj].setZero();
968 for (
unsigned int iobj = 0; iobj < secondFitOutput.
getNConstituents(); ++iobj) {
969 covariances[iobj + nPartFirst].setZero();
978 const std::vector<
AmgMatrix(3,3)>& covariances)
982 if (particles.size() != covariances.size()) {
983 ATH_MSG_ERROR(
"getMassError: Number of particles is not equal to the number of covariance matrices");
987 ATH_MSG_DEBUG (
"getMassError: 1 " << particles.size() <<
"/" << covariances.size());
990 TLorentzVector combv;
991 for (
auto lv : particles ) combv += lv;
992 double invmass = combv.M();
998 jacobianNPtoM.setZero();
999 jacobianNPtoM(0,0) = -1.*combv.Px()/invmass;
1000 jacobianNPtoM(0,1) = -1.*combv.Py()/invmass;
1001 jacobianNPtoM(0,2) = -1.*combv.Pz()/invmass;
1002 jacobianNPtoM(0,3) = combv.E()/invmass;
1007 for (
auto lv : particles ) {
1013 const AmgMatrix(3,3)& covPhiThetaP = covariances[iobj];
1015 ATH_MSG_VERBOSE (
"getMassError: 1.3 covPhiThetaP\n " << covPhiThetaP);
1017 double theta = lv.Theta();
1018 double phi = lv.Phi();
1023 ATH_MSG_VERBOSE (
"getMassError: 2.1 iobj " << iobj <<
"covPhiThetaP\n" << covPhiThetaP);
1027 jacobian1.setZero();
1028 jacobian1(0,0) = 1.;
1029 jacobian1(1,1) = -1*(1./sin(
theta));
1030 jacobian1(2,2) = 1.;
1031 AmgMatrix(3,3) covPhiEtaP = jacobian1 * covPhiThetaP * jacobian1.transpose();
1039 covEEtaPhiM.setZero();
1040 for(
int i = 0; i < 3; i++) {
1041 for(
int j = 0; j < 3; j++) {
1042 covEEtaPhiM(i,j) = covEEtaPhiM(j,i) = covPhiEtaP(2-i,2-j);
1050 jacobian2.setZero();
1051 jacobian2(0,0) = e/p * sin(
theta)*cos(
phi);
1052 jacobian2(1,0) = e/p * sin(
theta)*sin(
phi);
1053 jacobian2(2,0) = e/p * cos(
theta);
1060 jacobian2(0,2) = -p * sin(
theta) * sin(
phi);
1061 jacobian2(1,2) = p * sin(
theta) * cos(
phi);
1063 jacobian2(0,3) = -m/p * sin(
theta)*cos(
phi);
1064 jacobian2(1,3) = -m/p * sin(
theta)*sin(
phi);
1065 jacobian2(2,3) = -m/p * cos(
theta);
1067 AmgMatrix(4,4) covPxPyPzE = jacobian2 * covEEtaPhiM * jacobian2.transpose();
1074 Amg::MatrixX em = jacobianNPtoM * covPxPyPzE * jacobianNPtoM.transpose();
1075 masserror += em(0,0);
1082 if (masserror < 0.) {
1083 ATH_MSG_WARNING(
"getMassError: Mass covariance element less than zero! Returning 1E11 ...");
1086 return sqrt(masserror);
1097 ATH_MSG_WARNING(
"ZMassConstraint::ConstraintFit::doSanityChecksOnCovariance:: Fractional uncertainty on P = "
1098 << sqrt(covar(
qP,
qP))/
vector.P() <<
" is > 1 ...this is not ok...");
1104 ATH_MSG_WARNING(
"ZMassConstraint::ConstraintFit::doSanityChecksOnCovariance:: Uncertainty on Theta = "
1105 << covar(
theta,
theta) <<
" is > 10^-2 ...this is not ok");
1109 ATH_MSG_WARNING(
"ZMassConstraint::ConstraintFit::doSanityChecksOnCovariance:: Uncertainty on Phi = "
1110 << covar(
phi0,
phi0) <<
" is > 10^-2 ...this is not ok");
1113 for(
int i=0;i<5;i++) {
1114 for(
int j=0;j<5;j++) {
1116 if(fabs(covar(i,j))/sqrt(covar(i,i))/sqrt(covar(j,j)) > 1.) {
1117 ATH_MSG_WARNING(
"ZMassConstraint::ConstraintFit::doSanityChecksOnCovariance:: Off-diagonal term "
1118 << i <<
" " << j <<
" is > 1 - doesn't look ok");
1129 const AmgMatrix(5,5)& covard0z0PhiThetaP,
1133 double phi = fourVec.Phi();
1134 double theta = fourVec.Theta();
1135 double P = fourVec.P();
1141 jacobian(2,2) = -
P * TMath::Sin(
theta) * TMath::Sin(
phi);
1142 jacobian(2,3) =
P * TMath::Sin(
theta) * TMath::Cos(
phi);
1143 jacobian(3,2) =
P * TMath::Cos(
theta) * TMath::Cos(
phi);
1144 jacobian(3,3) =
P * TMath::Cos(
theta) * TMath::Sin(
phi);
1145 jacobian(3,4) = -
P * TMath::Sin(
theta);
1146 jacobian(4,2) = TMath::Sin(
theta) * TMath::Cos(
phi);
1147 jacobian(4,3) = TMath::Sin(
theta) * TMath::Sin(
phi);
1148 jacobian(4,4) = TMath::Cos(
theta);
1150 covarXYZ = jacobian.transpose() * covard0z0PhiThetaP * jacobian;
1163 unsigned int matrixSize = 5 * particleList.size();
1167 for(
unsigned int ii = 0; ii < particleList.size(); ii++) {
1168 double phi = particleList.at(ii).Phi();
1169 double theta = particleList.at(ii).Theta();
1170 double P = particleList.at(ii).P();
1171 Jacobian( 5*ii, 5*ii) = 1.;
1172 Jacobian(1 + 5*ii, 1 + 5*ii) = 1.;
1174 Jacobian(2 + 5*ii, 2 + 5*ii) = -
P * TMath::Sin(
theta) * TMath::Sin(
phi);
1175 Jacobian(2 + 5*ii, 3 + 5*ii) =
P * TMath::Sin(
theta) * TMath::Cos(
phi);
1176 Jacobian(3 + 5*ii, 2 + 5*ii) =
P * TMath::Cos(
theta) * TMath::Cos(
phi);
1177 Jacobian(3 + 5*ii, 3 + 5*ii) =
P * TMath::Cos(
theta) * TMath::Sin(
phi);
1178 Jacobian(3 + 5*ii, 4 + 5*ii) = -
P * TMath::Sin(
theta);
1179 Jacobian(4 + 5*ii, 2 + 5*ii) = TMath::Sin(
theta) * TMath::Cos(
phi);
1180 Jacobian(4 + 5*ii, 3 + 5*ii) = TMath::Sin(
theta) * TMath::Sin(
phi);
1181 Jacobian(4 + 5*ii, 4 + 5*ii) = TMath::Cos(
theta);
1185 Jacobianinverse=Jacobian.inverse();
1186 covard0z0PhiThetaP = Jacobianinverse.transpose() * covarXYZ * Jacobianinverse;
1192 double eta_calo = 0;
1195 ATH_MSG_ERROR(
"retrieve_eta_calo - unable to cast to Egamma");
1203 eta_calo = etaCaloAcc(cluster);
1206 ATH_MSG_ERROR(
"retrieve_eta_calo - etaCalo not available as auxilliary variable");
1208 eta_calo = cluster.
eta();
Scalar phi() const
phi method
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define AmgMatrix(rows, cols)
void diff(const Jet &rJet1, const Jet &rJet2, std::map< std::string, double > varDiff)
Difference between jets - Non-Class function required by trigger.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Helper class to provide constant type-safe access to aux data.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
const TLorentzVector & getConstituentFourVector(int index) const
Access to individual particle 4-vec.
Amg::MatrixX getConstituentCovariancePhiThetaP(int index) const
Access to individual covariance PhiThetaP (3,3).
unsigned int getNConstituents() const
Number of particles.
Amg::MatrixX m_parametersInit
StatusCode doMassFit(const ConstraintFitInput &input, ConstraintFitOutput &output)
Perform the constrained mass fit.
void addFSRParticle(const xAOD::IParticle &part, const TLorentzVector &fsr4Vec, ConstraintFitInput &input)
Add in FSR photon to input, (energy resolution is obtain in method).
unsigned int m_parameters
double getMassError(const ConstraintFitInput &firstInput, const ConstraintFitInput &secondInput=ConstraintFitInput())
Calculate the mass error without fit - use just the inputs.
int massFitInterface(const ConstraintFitInput &theInput)
void massFitRun(ConstraintFitOutput &output, double zresol=-1.)
void convertCovd0z0PhiThetaPToXYZ(const TLorentzVector &fourVec, const AmgMatrix(5, 5)&covard0z0PhiThetaP, AmgMatrix(5, 5)&covarXYZ) const
float retrieve_eta_calo(const xAOD::IParticle &part) const
ConstraintFitInput m_theInput
ConstraintFit(const std::string &name)
Create a proper constructor for Athena.
StatusCode initialize()
Initialize constraint fit.
Amg::MatrixX m_covarianceInit
bool doSanityChecksOnCovariance(const TLorentzVector &vector, const AmgMatrix(5, 5)&covar) const
void addParticle(const xAOD::Muon &part, ConstraintFitInput &input, MassConstraintMuonType muonType=isCombMCMT)
Add muon to input, must provide the resolution Scale Factor.
double likelihoodMass2(void)
ToolHandle< CP::IEgammaCalibrationAndSmearingTool > m_energyRescaler
double massFitCalculation(const Amg::MatrixX &var, double mass, Amg::MatrixX &p0)
void convertCovXYZTod0z0PhiThetaP(const std::vector< TLorentzVector > &particleList, const Amg::MatrixX &covarXYZ, Amg::MatrixX &covard0z0PhiThetaP) const
double massFit(const Amg::MatrixX &, const Amg::MatrixX &var, double mass, Amg::MatrixX &pOut, Amg::MatrixX &)
std::vector< double > m_objmass
Amg::MatrixX m_parametersFinal
Amg::MatrixX m_covarianceFinal
double likelihoodMass(double)
ToolHandle< CP::IMuonCalibrationAndSmearingTool > m_mu_resolSFTool
bool retrieveMoment(MomentType type, double &value) const
Retrieve individual moment.
virtual double eta() const
The pseudorapidity ( ) of the particle.
@ ETACALOFRAME
Eta in the calo frame (for egamma).
const xAOD::CaloCluster * caloCluster(size_t index=0) const
Pointer to the xAOD::CaloCluster/s that define the electron candidate.
Class providing the definition of the 4-vector interface.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
@ Photon
The object is a photon.
bool isConvertedPhoton(const xAOD::Egamma *eg, bool excludeTRT=false)
is the object a converted photon
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Egamma_v1 Egamma
Definition of the current "egamma version".
Muon_v1 Muon
Reference the current persistent version:
Photon_v1 Photon
Definition of the current "egamma version".
Electron_v1 Electron
Definition of the current "egamma version".