32 namespace RestFrames {
38 const std::string& stitle) :
51 m_FailTolerance = 1000;
54 LabGenFrame::~LabGenFrame() {}
69 m_Log <<
"Unable to set transverse momentum ";
70 m_Log <<
"to negative value: " << val <<
"*mass";
81 m_Log <<
"Unable to set transverse momentum ";
82 m_Log <<
"to negative value: " << val;
95 while(val > acos(-1.)*2.) val -= acos(-1.)*2.;
96 while(val < 0.) val += acos(-1.)*2.;
100 void LabGenFrame::ResetGenFrame(){
106 m_Log << LogVerbose <<
"Initializing this tree for analysis..." << LogEnd;
109 UnSoundBody(RF_FUNCTION);
110 return SetMind(
false);
114 m_Log << LogWarning <<
"...Unable to recursively initialize analysis" << LogEnd;
115 return SetMind(
false);
118 for(
int i = 0; i < m_NBurnInMCMC; i++)
119 if(!IterateRecursiveMCMC()){
120 m_Log << LogWarning <<
"...Unable to recursively initialize analysis" << LogEnd;
121 return SetMind(
false);
124 m_Log << LogVerbose <<
"...Done" << LogEnd;
125 return SetMind(
true);
130 m_NBurnInMCMC = std::max(0,N);
135 m_NDiscardMCMC = std::max(1,N);
139 m_FailTolerance = Nfail;
142 bool LabGenFrame::InitializeGenAnalysis(){
144 UnSoundBody(RF_FUNCTION);
145 return SetMind(
false);
149 if(child.IsVariableMassMCMC()){
150 double ChildMass, ChildProb;
151 child.GenerateMassMCMC(ChildMass, ChildProb, m_MaxM);
152 m_ChildMassMCMC = ChildMass;
153 m_ChildProbMCMC = ChildProb;
154 SetMassMCMC(ChildMass, child);
156 m_ChildMassMCMC = child.GetMass();
157 m_ChildProbMCMC = 1.;
160 return SetMind(
true);
163 bool LabGenFrame::IterateMCMC(){
165 if(child.IsVariableMassMCMC()){
166 double ChildMass, ChildProb = 0.;
167 child.GenerateMassMCMC(ChildMass, ChildProb, m_MaxM);
170 child.GetProbMCMC(m_ChildMassMCMC)/m_ChildProbMCMC;
173 child.GetProbMCMC(ChildMass)/ChildProb;
176 m_ChildMassMCMC = ChildMass;
177 m_ChildProbMCMC = ChildProb;
178 SetMassMCMC(ChildMass, child);
180 SetMassMCMC(m_ChildMassMCMC, child);
184 return SetMind(
true);
187 bool LabGenFrame::GenerateFrame(){
193 if(m_Phi < 0.) m_Phi = 2.*acos(-1.)*
GetRandom();
196 P.SetPxPyPzE(m_PToM*M*cos(m_Phi), m_PToM*M*sin(m_Phi), m_PL,
197 sqrt(m_PL*m_PL + M*M*(1. + m_PToM*m_PToM)));
199 P.SetPxPyPzE(m_PT*cos(m_Phi), m_PT*sin(m_Phi), m_PL,
200 sqrt(m_PT*m_PT + m_PL*m_PL + M*M));
203 std::vector<TLorentzVector> ChildVector;
204 ChildVector.push_back(P);
205 SetChildren(ChildVector);
207 return SetSpirit(
true);
222 for(
int i = 0; i < m_NDiscardMCMC; i++)
223 if(!IterateRecursiveMCMC())
224 return SetSpirit(
false);
227 return SetSpirit(
false);
230 pass = EventInAcceptance();
234 if(tries > m_FailTolerance &&
235 m_FailTolerance > 0){
237 m_Log <<
"Failed to generate event in ";
238 m_Log <<
"acceptance in " << tries;
239 m_Log <<
" tries. Giving up." << LogEnd;
240 return SetSpirit(
false);
245 return SetSpirit(
true);