33 namespace RestFrames {
39 const std::string& stitle) :
44 MinMassesCombJigsaw::~MinMassesCombJigsaw() {}
47 return MinMassesCombJigsaw::m_Empty;
57 int N = frames.GetN();
58 for(
int f = 0; f < N; f++){
59 if(
GetGroup().ContainsFrame(frames[f]))
60 AddChildFrame(frames[f], i);
61 AddDependancyFrame(frames[f], i);
66 int N = frames.GetN();
67 for(
int f = 0; f < N; f++)
71 bool MinMassesCombJigsaw::AnalyzeEvent(){
73 return SetSpirit(
false);
75 if(!InitializeCombinatoric()){
77 m_Log <<
"Problem initializing event info" << LogEnd;
78 return SetSpirit(
false);
81 int Ninput = GetNInputStates();
83 bool DO_N3 = (Ninput >= 2) &&
88 (GetNinputForChild(0) <= 1) &&
89 (GetNinputForChild(1) <= 1) &&
90 !IsNinputExclForChild(0) &&
91 !IsNinputExclForChild(1) &&
92 !IsChargeSetForChild(0) &&
93 !IsChargeSetForChild(1) &&
94 !IsChargeSetForObject(0) &&
95 !IsChargeSetForObject(1);
98 if(!CombinatoricJigsaw::LoopCombinatoric()){
100 m_Log <<
"Problem looping over combinatorics" << LogEnd;
101 return SetSpirit(
false);
103 return SetSpirit(
true);
107 std::vector<TLorentzVector> inputs;
108 for(
int i = 0; i < Ninput; i++){
109 inputs.push_back(GetInputState(i).GetFourVector());
110 if(inputs[i].M() < 0.) inputs[i].SetVectM(inputs[i].Vect(),0.);
114 TLorentzVector TOT(0.,0.,0.,0.);
117 for(
int i = 0; i < Ninput; i++){
118 TVector3 p = inputs[i].Vect();
119 p = p - p.Dot(GetTransverseAxis())*GetTransverseAxis();
120 inputs[i].SetVectM(p, inputs[i].M());
124 for(
int i = 0; i < Ninput; i++) TOT += inputs[i];
125 TVector3 boost = TOT.BoostVector();
126 if(boost.Mag() >= 1.)
127 boost = (1.-1.e-8)/boost.Mag()*boost;
128 for(
int i = 0; i < Ninput; i++) inputs[i].Boost(-boost);
132 for(
int i = 0; i < 2; i++) ip_max[i] = -1;
133 for(
int i = 0; i < 2; i++) jp_max[i] = -1;
134 double metric_max = -1.;
137 for(ip[0] = 0; ip[0] < Ninput-1; ip[0]++){
138 for(ip[1] = ip[0]+1; ip[1] < Ninput; ip[1]++){
139 TVector3 nRef = inputs[ip[0]].Vect().Cross(inputs[ip[1]].Vect());
141 TLorentzVector hem[2];
142 for(
int i = 0; i < 2; i++){
144 hem[i].SetPxPyPzE(0.,0.,0.,0.);
147 for(
int i = 0; i < Ninput; i++){
148 if((i == ip[0]) || (i ==ip[1]))
continue;
149 int ihem = int(inputs[i].Vect().Dot(nRef) > 0.);
151 hem[ihem] += inputs[i];
154 for(jp[0] = 0; jp[0] < 2; jp[0]++){
155 for(jp[1] = 0; jp[1] < 2; jp[1]++){
156 if(jp[0] == jp[1] && Nhem[!jp[0]] == 0)
continue;
157 TLorentzVector hem_probes[2];
158 for(
int i = 0; i < 2; i++) hem_probes[i] = hem[i];
159 for(
int i = 0; i < 2; i++) hem_probes[jp[i]] += inputs[ip[i]];
160 double metric = hem_probes[0].P() + hem_probes[1].P();
161 if(metric > metric_max){
163 for(
int i = 0; i < 2; i++) ip_max[i] = ip[i];
164 for(
int i = 0; i < 2; i++) jp_max[i] = jp[i];
176 for(
int i = 0; i < 2; i++){
177 GetChildState(jp_max[i]).
AddElement(GetInputState(ip_max[i]));
179 TVector3 nRef = inputs[ip_max[0]].Vect().Cross(inputs[ip_max[1]].Vect());
180 for(
int i = 0; i < Ninput; i++){
181 if((i == ip_max[0]) || (i == ip_max[1]))
continue;
182 int ihem = int(inputs[i].Vect().Dot(nRef) > 0.);
183 GetChildState(ihem).
AddElement(GetInputState(i));
185 if(GetChildState(1).GetFourVector().M() > GetChildState(1).GetFourVector().M()){
186 std::vector<VisibleStateList> flip;
187 for(
int i = 0; i < 2; i++) flip.push_back(GetChildState(i).GetElements());
189 for(
int i = 0; i < 2; i++) GetChildState(i).
AddElements(flip[(i+1)%2]);
192 ExecuteDependancyJigsaws();
194 return SetSpirit(
true);
197 bool MinMassesCombJigsaw::EvaluateMetric(
double& metric)
const {
199 TLorentzVector P1, P2;
201 P1 = GetDependancyStates(0).GetFourVector();
202 P2 = GetDependancyStates(1).GetFourVector();
204 int N1 = GetDependancyStates(0).GetN();
205 for(
int i = 0; i < N1; i++){
206 TLorentzVector v = GetDependancyStates(0)[i].GetFourVector();
207 TVector3 p = v.Vect() - v.Vect().Dot(GetTransverseAxis())*GetTransverseAxis();
208 v.SetVectM(p, v.M());
211 int N2 = GetDependancyStates(1).GetN();
212 for(
int i = 0; i < N2; i++){
213 TLorentzVector v = GetDependancyStates(1)[i].GetFourVector();
214 TVector3 p = v.Vect() - v.Vect().Dot(GetTransverseAxis())*GetTransverseAxis();
215 v.SetVectM(p, v.M());
220 double P = GetP((P1+P2).M(), P1.M(), P2.M());
229 MinMassesCombJigsaw MinMassesCombJigsaw::m_Empty;