#include "PHASIC++/Selectors/Selector.H" #include "ATOOLS/Math/Algebra_Interpreter.H" #include namespace PHASIC { class Decay_Selector: public Selector_Base, public ATOOLS::Tag_Replacer { private: std::vector > m_ids; ATOOLS::Vec4D_Vector m_p; double m_min, m_max; ATOOLS::Algebra_Interpreter m_calc; public: Decay_Selector(const Selector_Key &key); bool Trigger(ATOOLS::Selector_List &p); void BuildCuts(Cut_Data *) {} std::string ReplaceTags(std::string &expr) const; ATOOLS::Term *ReplaceTags(ATOOLS::Term *term) const; void AssignId(ATOOLS::Term *term); }; class Decay2_Selector: public Selector_Base, public ATOOLS::Tag_Replacer { private: std::vector > m_ids[2]; ATOOLS::Vec4D_Vector m_p[2]; double m_min, m_max; ATOOLS::Algebra_Interpreter m_calc; public: Decay2_Selector(const Selector_Key &key); bool Trigger(ATOOLS::Selector_List &p); void BuildCuts(Cut_Data *) {} std::string ReplaceTags(std::string &expr) const; ATOOLS::Term *ReplaceTags(ATOOLS::Term *term) const; void AssignId(ATOOLS::Term *term); }; class DecayMass_Selector: public Selector_Base { private: std::vector > m_ids; double m_min, m_max; public: DecayMass_Selector(const Selector_Key &key); bool Trigger(ATOOLS::Selector_List &p); void BuildCuts(Cut_Data *); }; } #include "PHASIC++/Process/Process_Base.H" #include "PHASIC++/Main/Process_Integrator.H" #include "ATOOLS/Org/Run_Parameter.H" #include "ATOOLS/Org/Message.H" #include "ATOOLS/Org/Exception.H" #include "ATOOLS/Org/MyStrStream.H" using namespace PHASIC; using namespace ATOOLS; Decay_Selector::Decay_Selector(const Selector_Key &key): Selector_Base("Decay_Selector",key.p_proc) { Scoped_Settings s{ key.m_settings }; s.SetInterpreterEnabled(false); const auto parameters = s.SetDefault({}).GetVector(); if (parameters[0].size() < 7 || parameters.size() != 4) THROW(critical_error, "Invalid syntax"); std::string tag(parameters[0].substr(6)); tag.erase(tag.length()-1,1); DEBUG_FUNC(tag); const auto kf = s.Interprete(parameters[1]); Flavour fl = Flavour((kf_code)std::abs(kf),kf<0); DecayInfo_Vector decs(p_proc->Info().m_fi.GetDecayInfos()); for (size_t i(0);im_fl==fl) { m_ids.push_back(ID(decs[i]->m_id)); if (m_ids.size()>1 && m_ids.front().size()!=m_ids.back().size()) THROW(fatal_error,"Varying multiplicity"); msg_Debugging()<<"adding "<(parameters[2]); m_max = s.Interprete(parameters[3]); msg_Debugging()<<"m_min = "<Get()); msg_Debugging()< "<m_max) return !m_sel_log->Hit(1); } return !m_sel_log->Hit(0); } std::string Decay_Selector::ReplaceTags(std::string &expr) const { return m_calc.ReplaceTags(expr); } Term *Decay_Selector::ReplaceTags(Term *term) const { term->Set(m_p[term->Id()]); return term; } void Decay_Selector::AssignId(Term *term) { term->SetId(ToType (term->Tag().substr (2,term->Tag().length()-3))); } DECLARE_GETTER(Decay_Selector,"Decay",Selector_Base,Selector_Key); Selector_Base *ATOOLS::Getter:: operator()(const Selector_Key &key) const { Decay_Selector *msel(new Decay_Selector(key)); return msel; } void ATOOLS::Getter:: PrintInfo(std::ostream &str,const size_t width) const { str<<"[Decay, kf, min, max]"; } Decay2_Selector::Decay2_Selector(const Selector_Key &key): Selector_Base("Decay2_Selector",key.p_proc) { Scoped_Settings s{ key.m_settings }; s.SetInterpreterEnabled(false); const auto parameters = s.SetDefault({}).GetVector(); if (parameters[0].size() < 7 || parameters.size() != 5) THROW(critical_error, "Invalid syntax"); std::string tag(parameters[0].substr(7)); tag.erase(tag.length()-1,1); DEBUG_FUNC(tag); const auto kf1 = s.Interprete(parameters[1]); const auto kf2 = s.Interprete(parameters[2]); Flavour fl1 = Flavour((kf_code)std::abs(kf1),kf1<0); Flavour fl2 = Flavour((kf_code)std::abs(kf2),kf2<0); DecayInfo_Vector decs(p_proc->Info().m_fi.GetDecayInfos()); for (size_t i(0);im_fl==fl1) { m_ids[0].push_back(ID(decs[i]->m_id)); if (m_ids[0].size()>1 && m_ids[0].front().size()!=m_ids[0].back().size()) THROW(fatal_error,"Varying multiplicity"); msg_Debugging()<<"adding "<m_fl==fl2) { m_ids[1].push_back(ID(decs[i]->m_id)); if (m_ids[1].size()>1 && m_ids[1].front().size()!=m_ids[1].back().size()) THROW(fatal_error,"Varying multiplicity"); msg_Debugging()<<"adding "<(parameters[3]); m_max = s.Interprete(parameters[4]); msg_Debugging()<<"m_min = "<Get()); msg_Debugging()< "<m_max) return !m_sel_log->Hit(1); } } return !m_sel_log->Hit(0); } std::string Decay2_Selector::ReplaceTags(std::string &expr) const { return m_calc.ReplaceTags(expr); } Term *Decay2_Selector::ReplaceTags(Term *term) const { if (term->Id()>=200) term->Set(m_p[1][term->Id()-200]); else if (term->Id()>=100) term->Set(m_p[0][term->Id()-100]); return term; } void Decay2_Selector::AssignId(Term *term) { if (term->Tag().find("p1")==0) { term->SetId(100+ToType (term->Tag().substr (3,term->Tag().length()-4))); } else if (term->Tag().find("p2")==0) { term->SetId(200+ToType (term->Tag().substr (3,term->Tag().length()-4))); } } DECLARE_GETTER(Decay2_Selector,"Decay2",Selector_Base,Selector_Key); Selector_Base *ATOOLS::Getter:: operator()(const Selector_Key &key) const { Decay2_Selector *msel(new Decay2_Selector(key)); return msel; } void ATOOLS::Getter:: PrintInfo(std::ostream &str,const size_t width) const { str<<"[Decay2, kf1, kf2, min, max]"; } DecayMass_Selector::DecayMass_Selector(const Selector_Key &key): Selector_Base("DecayMass_Selector",key.p_proc) { Scoped_Settings s{ key.m_settings }; const auto parameters = s.SetDefault({}).GetVector(); assert(parameters[0] == "DecayMass"); if (parameters.size() != 4) THROW(critical_error, "Invalid syntax"); const auto kf = s.Interprete(parameters[1]); Flavour fl = Flavour((kf_code)abs(kf),kf<0); DecayInfo_Vector decs(p_proc->Info().m_fi.GetDecayInfos()); for (size_t i(0);im_fl==fl) { m_ids.push_back(ID(decs[i]->m_id)); if (m_ids.size()>1 && m_ids.front().size()!=m_ids.back().size()) THROW(fatal_error,"Varying multiplicity"); msg_Debugging()<<"adding "<(parameters[2]); m_max = s.Interprete(parameters[3]); msg_Debugging()<<"m_min = "< "<m_max) return !m_sel_log->Hit(1); } return !m_sel_log->Hit(0); } void DecayMass_Selector::BuildCuts(Cut_Data *cuts) { for (size_t j(0);jscut[m_ids[j][0]][m_ids[j][1]]= cuts->scut[m_ids[j][1]][m_ids[j][0]]= Max(cuts->scut[m_ids[j][0]][m_ids[j][1]],sqr(m_min)); } size_t id(ID(m_ids[j])); double scut(cuts->Getscut(id)); cuts->Setscut(id,Max(scut,sqr(m_min))); } } DECLARE_GETTER(DecayMass_Selector,"DecayMass",Selector_Base,Selector_Key); Selector_Base *ATOOLS::Getter:: operator()(const Selector_Key &key) const { DecayMass_Selector *msel(new DecayMass_Selector(key)); return msel; } void ATOOLS::Getter:: PrintInfo(std::ostream &str,const size_t width) const { str<<"[DecayMass, kf, min, max]"; }