31 #include <TDecompSVD.h>
33 #include "RestFrames/MinMassesSqInvJigsaw.hh"
38 MinMassesSqInvJigsaw::MinMassesSqInvJigsaw(
const std::string& sname,
39 const std::string& stitle,
41 InvisibleJigsaw(sname, stitle, N_vis_inv_pair, N_vis_inv_pair),
42 m_Npair(N_vis_inv_pair) {}
44 MinMassesSqInvJigsaw::MinMassesSqInvJigsaw()
45 : InvisibleJigsaw(), m_Npair(0) {}
47 MinMassesSqInvJigsaw::~MinMassesSqInvJigsaw() {}
49 MinMassesSqInvJigsaw& MinMassesSqInvJigsaw::Empty(){
50 return MinMassesSqInvJigsaw::m_Empty;
53 double MinMassesSqInvJigsaw::GetMinimumMass()
const {
60 return std::max(0.,GetChildState(0).GetMinimumMass());
62 TLorentzVector PvisTOT(0.,0.,0.,0.);
64 for(
int i = 0; i < m_Npair; i++){
65 m_Pvis.push_back(GetDependancyStates(i+m_Npair).GetFourVector());
71 TVector3 Boost = PvisTOT.BoostVector();
72 for(
int i = 0; i < m_Npair; i++){
73 m_Pvis[i].Boost(-Boost);
74 Minv = std::max(0.,GetChildState(i).GetMinimumMass());
75 ECM += sqrt(m_Pvis[i].P()*m_Pvis[i].P() + Minv*Minv);
81 bool MinMassesSqInvJigsaw::AnalyzeEvent(){
83 return SetSpirit(
false);
88 TLorentzVector INV = GetParentState().GetFourVector();
89 double Minv = INV.M();
91 TLorentzVector VIS(0.,0.,0.,0.);
93 for(
int i = 0; i < m_Npair; i++){
94 m_Pvis.push_back(GetDependancyStates(i).GetFourVector());
99 TVector3 BoostCM = (VIS+INV).BoostVector();
102 for(
int i = 0; i < m_Npair; i++)
103 m_Pvis[i].Boost(-BoostCM);
106 TVector3 BoostVIS = VIS.BoostVector();
109 for(
int i = 0; i < m_Npair; i++){
110 m_Minv.push_back(std::max(0.,GetChildState(i).GetMinimumMass()));
111 m_Pinv.push_back(m_Pvis[i]);
112 m_Pinv[i].Boost(-BoostVIS);
113 m_Pinv[i].SetVectM(m_Pinv[i].Vect(), m_Minv[i]);
117 TVector3 BoostINV = INV.BoostVector();
118 for(
int i = 0; i < m_Npair; i++)
119 m_Pvis[i].Boost(-BoostINV);
122 TVector3 Vdiff = (m_Pvis[0].Vect()-m_Pvis[1].Vect()).Unit();
123 double pinv = GetP(Minv, m_Minv[0], m_Minv[1]);
124 m_Pinv[0].SetVectM( pinv*Vdiff, m_Minv[0]);
125 m_Pinv[1].SetVectM(-pinv*Vdiff, m_Minv[1]);
127 ApplyOptimalRotation();
129 double k = GetPScale(Minv);
130 for(
int i = 0; i < m_Npair; i++)
131 m_Pinv[i].SetVectM(k*m_Pinv[i].Vect(), m_Minv[i]);
135 for(
int i = 0; i < m_Npair; i++){
136 m_Pinv[i].Boost(BoostINV);
137 m_Pinv[i].Boost(BoostCM);
138 GetChildState(i).SetFourVector(m_Pinv[i]);
141 return SetSpirit(
true);
145 double MinMassesSqInvJigsaw::GetPScale(
double Minv){
146 std::vector<double> Pinv2;
150 for(
int i = 0; i < m_Npair; i++){
151 Pinv2.push_back(m_Pinv[i].P()*m_Pinv[i].P());
152 Ek += sqrt(m_Minv[i]*m_Minv[i]+Pinv2[i]);
155 if(fk > Minv || Ek <= 0.)
return 0.;
161 while(fabs(dk2) >= 1e-10 && count < 100){
164 for(
int i = 0; i < m_Npair; i++){
165 Ek = sqrt(m_Minv[i]*m_Minv[i]+k2*Pinv2[i]);
167 dfk += Ek > 0 ? Pinv2[i]/Ek : 0.;
174 return sqrt(std::max(0.,k2));
178 void MinMassesSqInvJigsaw::ApplyOptimalRotation(){
180 TVector3 Z(0.,0.,0.);
183 while(Z.Mag() <= 0. && index < m_Npair){
184 Z = m_Pinv[index].Vect().Cross(m_Pvis[index].Vect());
187 if(Z.Mag() <= 0.)
return;
191 for(
int i = 0; i < m_Npair; i++){
192 if(Z.Dot(m_Pvis[i].Vect().Unit()) > 1e-8){
196 if(Z.Dot(m_Pinv[i].Vect().Unit()) > 1e-8){
204 TVector3 X(0.,0.,0.);
205 for(
int i = 0; i < m_Npair; i++)
206 X += m_Pvis[i].Vect() - m_Pinv[i].Vect();
207 if(X.Mag() <= 0)
return;
210 TVector3 Y = Z.Cross(X).Unit();
214 for(
int i = 0; i < m_Npair; i++){
215 num += m_Pvis[i].Vect().Dot(Y)*
216 (m_Pvis[i].Vect().Dot(X)-m_Pinv[i].Vect().Dot(X));
217 den += m_Pvis[i].Vect().Dot(m_Pinv[i].Vect());
220 double theta = atan2(num,den);
221 for(
int i = 0; i < m_Npair; i++)
222 m_Pinv[i].Rotate(theta, -Z);
230 for(
int i = 0; i < 3; i++)
231 for(
int j = 0; j < 3; j++)
234 for(
int p = 0; p < m_Npair; p++){
235 H(0,0) += m_Pinv[p].Px()*m_Pvis[p].Px();
236 H(1,0) += m_Pinv[p].Px()*m_Pvis[p].Py();
237 H(2,0) += m_Pinv[p].Px()*m_Pvis[p].Pz();
238 H(0,1) += m_Pinv[p].Py()*m_Pvis[p].Px();
239 H(1,1) += m_Pinv[p].Py()*m_Pvis[p].Py();
240 H(2,1) += m_Pinv[p].Py()*m_Pvis[p].Pz();
241 H(0,2) += m_Pinv[p].Pz()*m_Pvis[p].Px();
242 H(1,2) += m_Pinv[p].Pz()*m_Pvis[p].Py();
243 H(2,2) += m_Pinv[p].Pz()*m_Pvis[p].Pz();
248 TMatrixD UT(TMatrixD::kTransposed,SVD.GetU());
249 TMatrixD R(SVD.GetV(),TMatrixD::kMult,UT);
252 for(
int p = 0; p < m_Npair; p++){
253 V = m_Pinv[p].Vect();
254 V.SetXYZ(R(0,0)*V.Px()+R(1,0)*V.Py()+R(2,0)*V.Pz(),
255 R(0,1)*V.Px()+R(1,1)*V.Py()+R(2,1)*V.Pz(),
256 R(0,2)*V.Px()+R(1,2)*V.Py()+R(2,2)*V.Pz());
257 m_Pinv[p].SetVectM(V, m_Pinv[p].M());
263 MinMassesSqInvJigsaw MinMassesSqInvJigsaw::m_Empty;