38 MinMassesCombJigsaw::MinMassesCombJigsaw(
const std::string& sname,
39 const std::string& stitle) :
40 CombinatoricJigsaw(sname, stitle, 2, 2) {}
42 MinMassesCombJigsaw::MinMassesCombJigsaw() : CombinatoricJigsaw() {}
44 MinMassesCombJigsaw::~MinMassesCombJigsaw() {}
46 MinMassesCombJigsaw& MinMassesCombJigsaw::Empty(){
47 return MinMassesCombJigsaw::m_Empty;
50 void MinMassesCombJigsaw::AddFrame(
const RestFrame& frame,
int i){
52 if(!GetGroup())
return;
54 ConstRestFrameList frames =
55 frame.GetListVisibleFrames()+
56 frame.GetListInvisibleFrames();
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);
65 void MinMassesCombJigsaw::AddFrames(
const ConstRestFrameList& frames,
int i){
66 int N = frames.GetN();
67 for(
int f = 0; f < N; f++)
68 AddFrame(frames[f],i);
71 bool MinMassesCombJigsaw::AnalyzeEvent(){
72 if(!IsSoundMind() || !GetGroup())
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) &&
84 GetDependancyFrames(0) == GetChildFrames(0) &&
85 GetDependancyFrames(1) == GetChildFrames(1);
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.);
115 for(
int i = 0; i < Ninput; i++) TOT += inputs[i];
116 TVector3 boost = TOT.BoostVector();
117 if(boost.Mag() >= 1.)
118 boost = (1.-1.e-8)/boost.Mag()*boost;
119 for(
int i = 0; i < Ninput; i++) inputs[i].Boost(-boost);
123 for(
int i = 0; i < 2; i++) ip_max[i] = -1;
124 for(
int i = 0; i < 2; i++) jp_max[i] = -1;
125 double metric_max = -1.;
128 for(ip[0] = 0; ip[0] < Ninput-1; ip[0]++){
129 for(ip[1] = ip[0]+1; ip[1] < Ninput; ip[1]++){
130 TVector3 nRef = inputs[ip[0]].Vect().Cross(inputs[ip[1]].Vect());
132 TLorentzVector hem[2];
133 for(
int i = 0; i < 2; i++){
135 hem[i].SetPxPyPzE(0.,0.,0.,0.);
138 for(
int i = 0; i < Ninput; i++){
139 if((i == ip[0]) || (i ==ip[1]))
continue;
140 int ihem = int(inputs[i].Vect().Dot(nRef) > 0.);
142 hem[ihem] += inputs[i];
145 for(jp[0] = 0; jp[0] < 2; jp[0]++){
146 for(jp[1] = 0; jp[1] < 2; jp[1]++){
147 if(jp[0] == jp[1] && Nhem[!jp[0]] == 0)
continue;
148 TLorentzVector hem_probes[2];
149 for(
int i = 0; i < 2; i++) hem_probes[i] = hem[i];
150 for(
int i = 0; i < 2; i++) hem_probes[jp[i]] += inputs[ip[i]];
151 double metric = hem_probes[0].P() + hem_probes[1].P();
152 if(metric > metric_max){
154 for(
int i = 0; i < 2; i++) ip_max[i] = ip[i];
155 for(
int i = 0; i < 2; i++) jp_max[i] = jp[i];
166 for(
int i = 0; i < 2; i++) GetChildState(i).ClearElements();
167 for(
int i = 0; i < 2; i++){
168 GetChildState(jp_max[i]).AddElement(GetInputState(ip_max[i]));
170 TVector3 nRef = inputs[ip_max[0]].Vect().Cross(inputs[ip_max[1]].Vect());
171 for(
int i = 0; i < Ninput; i++){
172 if((i == ip_max[0]) || (i == ip_max[1]))
continue;
173 int ihem = int(inputs[i].Vect().Dot(nRef) > 0.);
174 GetChildState(ihem).AddElement(GetInputState(i));
176 if(GetChildState(1).GetFourVector().M() > GetChildState(1).GetFourVector().M()){
177 std::vector<VisibleStateList> flip;
178 for(
int i = 0; i < 2; i++) flip.push_back(GetChildState(i).GetElements());
179 for(
int i = 0; i < 2; i++) GetChildState(i).ClearElements();
180 for(
int i = 0; i < 2; i++) GetChildState(i).AddElements(flip[(i+1)%2]);
183 ExecuteDependancyJigsaws();
185 return SetSpirit(
true);
188 bool MinMassesCombJigsaw::EvaluateMetric(
double& metric)
const {
189 TLorentzVector P1 = GetDependancyStates(0).GetFourVector();
190 TLorentzVector P2 = GetDependancyStates(1).GetFourVector();
192 double P = GetP((P1+P2).M(), P1.M(), P2.M());
201 MinMassesCombJigsaw MinMassesCombJigsaw::m_Empty;