41 GeneratorFrame::GeneratorFrame(
const std::string& sname,
42 const std::string& stitle)
43 : RestFrame(sname, stitle)
46 m_VarMassMCMC =
false;
61 m_dominMassCut =
false;
62 m_domaxMassCut =
false;
65 int today = now.GetDate();
66 int clock = now.GetTime();
67 int key =
GetKey().GetKey();
68 int seed = today+clock+key;
69 m_Random =
new TRandom3(seed);
72 GeneratorFrame::GeneratorFrame()
75 GeneratorFrame::~GeneratorFrame(){
76 if(m_Random)
delete m_Random;
89 return std::max(m_Mass, 0.);
94 if(!frame.IsGenFrame())
return;
95 RestFrame::AddChildFrame(frame);
100 if(!frame.IsGenFrame())
return;
101 RestFrame::SetParentFrame(frame);
105 const RestFrame& frame = RestFrame::GetParentFrame();
107 return static_cast<const GeneratorFrame&>(frame);
113 RestFrame& frame = RestFrame::GetChildFrame(i);
115 return static_cast<GeneratorFrame&>(frame);
120 bool GeneratorFrame::ClearEventRecursive(){
125 int Nf = GetNChildren();
126 for(
int i = 0; i < Nf; i++)
133 bool GeneratorFrame::AnalyzeEventRecursive(){
135 UnSoundMind(RF_FUNCTION);
136 return SetSpirit(
false);
138 if(!GenerateFrame()){
140 m_Log <<
"Unable to generate event for this frame.";
142 return SetSpirit(
false);
145 int Nchild = GetNChildren();
146 for(
int i = 0; i < Nchild; i++)
148 return SetSpirit(
false);
151 return SetSpirit(
true);
154 void GeneratorFrame::SetChildren(
const std::vector<TLorentzVector>& P_children){
155 int N = P_children.size();
156 for(
int i = 0; i < N; i++){
157 TLorentzVector P = P_children[i];
158 TVector3 B_child = P.BoostVector();
165 bool GeneratorFrame::InitializeGenAnalysis(){
166 return SetMind(
true);
169 bool GeneratorFrame::InitializeAnalysisRecursive(){
171 UnSoundBody(RF_FUNCTION);
172 return SetMind(
false);
175 if(!InitializeGenAnalysis())
176 return SetMind(
false);
181 int Nchild = GetNChildren();
182 for(
int i = 0; i < Nchild; i++)
185 m_Log <<
"Unable to recursively initialize analysis for frame:";
187 return SetMind(
false);
190 return SetMind(
true);
193 double GeneratorFrame::GetRandom()
const {
194 return m_Random->Rndm();
197 double GeneratorFrame::GetGaus(
double mu,
double sig)
const {
198 return m_Random->Gaus(mu,sig);
201 bool GeneratorFrame::IterateMCMC(){
205 bool GeneratorFrame::IterateRecursiveMCMC(){
207 UnSoundMind(RF_FUNCTION);
208 return SetMind(
false);
212 return SetMind(
false);
214 int N = GetNChildren();
215 for(
int i = 0; i < N; i++)
217 return SetMind(
false);
219 return SetMind(
true);
222 void GeneratorFrame::SetVariableMassMCMC(
bool var){
227 return m_VarMassMCMC;
230 double GeneratorFrame::GetMinimumMassMCMC()
const {
232 UnSoundBody(RF_FUNCTION);
233 return SetBody(
false);
237 int N = GetNChildren();
238 for(
int i = 0; i < N; i++)
242 mass = std::max(
GetMass(),mass);
247 void GeneratorFrame::GenerateMassMCMC(
double& mass,
double& prob,
253 void GeneratorFrame::SetMassMCMC(
double val){
256 m_Log <<
"Unable to set mass to negative value ";
257 m_Log << val <<
". Setting to zero." << LogEnd;
264 void GeneratorFrame::SetMassMCMC(
double mass,
265 GeneratorFrame& frame)
const {
266 frame.SetMassMCMC(mass);
269 double GeneratorFrame::GetProbMCMC(
double mass)
const {
275 m_Log << LogInfo << std::endl;
276 m_Log <<
"Total events generated: " << m_Ngen << std::endl;
277 m_Log <<
"Events in acceptance: " << m_Npass << std::endl;
278 m_Log <<
"Generator efficiency: ";
279 m_Log << 100.*double(m_Npass)/double(m_Ngen) <<
" %";
280 m_Log << std::endl << LogEnd;
285 m_Log <<
"Acceptance cuts for frame:" << std::endl;
286 if(m_dominMassCut || m_domaxMassCut){
289 m_Log << m_minMassCut <<
" < ";
292 m_Log <<
" < " << m_maxMassCut;
296 m_Log <<
" P > " << m_PCut << std::endl;
299 m_Log <<
" Pt > " << m_PtCut << std::endl;
302 m_Log <<
" |Eta| < " << m_EtaCut << std::endl;
304 m_Log <<
"Acceptance efficiency = ";
305 m_Log << 100.*double(m_Npass)/double(m_Ngen) <<
" %";
306 m_Log << std::endl << LogEnd;
309 int N = GetNChildren();
310 for(
int i = 0; i < N; i++)
314 bool GeneratorFrame::EventInAcceptance()
const {
315 if(!IsSoundSpirit()){
316 UnSoundSpirit(RF_FUNCTION);
317 return SetSpirit(
false);
322 TLorentzVector P = GetFourVector();
324 if(P.P() < (1.-1e-10)*m_PCut)
327 if(P.Pt() < (1.-1e-10)*m_PtCut)
330 if(fabs(P.Eta()) > (1.+1e-10)*m_EtaCut)
333 if(m_Mass < (1.-1e-10)*m_minMassCut)
336 if(m_Mass > (1.+1e-10)*m_maxMassCut)
340 bool evt_pass = pass;
342 int N = GetNChildren();
343 for(
int i = 0; i < N; i++){
345 evt_pass = evt_pass && pass_c;
358 void GeneratorFrame::SetPCut(
double cut){
359 if(cut <= 0.)
return;
365 void GeneratorFrame::SetPtCut(
double cut){
366 if(cut <= 0.)
return;
372 void GeneratorFrame::SetEtaCut(
double cut){
373 m_EtaCut = fabs(cut);
378 void GeneratorFrame::SetMassWindowCut(
double min,
double max){
379 if(min > 0 || max > 0)
385 m_dominMassCut =
true;
390 m_domaxMassCut =
true;
395 void GeneratorFrame::RemovePCut(){
397 m_doCuts = m_doPCut || m_doPtCut || m_doEtaCut ||
398 m_dominMassCut || m_domaxMassCut;
401 void GeneratorFrame::RemovePtCut(){
403 m_doCuts = m_doPCut || m_doPtCut || m_doEtaCut ||
404 m_dominMassCut || m_domaxMassCut;
407 void GeneratorFrame::RemoveEtaCut(){
409 m_doCuts = m_doPCut || m_doPtCut || m_doEtaCut ||
410 m_dominMassCut || m_domaxMassCut;
413 void GeneratorFrame::RemoveMassWindowCut(){
414 m_dominMassCut =
false;
415 m_domaxMassCut =
false;
416 m_doCuts = m_doPCut || m_doPtCut || m_doEtaCut ||
417 m_dominMassCut || m_domaxMassCut;
virtual double GetMass() const
Get the mass of this frame.
virtual GeneratorFrame const & GetParentFrame() const
Returns the parent of this frame.
bool IsVariableMassMCMC() const
Frame is capable having a variable mass? (true/false)
virtual void AddChildFrame(RestFrame &frame)
Add a child RestFrame to this frame.
virtual void SetParentFrame(RestFrame &frame=RestFrame::Empty())
Set the parent frame for this frame.
virtual void Clear()
Clears GeneratorFrame of all connections to other objects.
RFKey GetKey() const
gets object identification key
abstract base class for all Frame objects
static GeneratorFrame & Empty()
Returns empty instance of class.
virtual GeneratorFrame & GetChildFrame(int i=0) const
Get the frame of the i th child.
static VisibleGenFrame & Empty()
Returns empty instance of class.
void PrintGeneratorEfficiency() const
Print generator efficiency information.