diff --git a/include/Rivet/Tools/Cmp.fhh b/include/Rivet/Tools/Cmp.fhh --- a/include/Rivet/Tools/Cmp.fhh +++ b/include/Rivet/Tools/Cmp.fhh @@ -1,18 +1,18 @@ // -*- C++ -*- #ifndef RIVET_Cmp_FHH #define RIVET_Cmp_FHH namespace Rivet { // Forward-declare the Cmp template class template class Cmp; enum class CmpState { - UNDEF, LT, EQ, GT + UNDEF, LT, EQ, GT, NEQ }; } #endif diff --git a/src/Core/Projection.cc b/src/Core/Projection.cc --- a/src/Core/Projection.cc +++ b/src/Core/Projection.cc @@ -1,60 +1,62 @@ // -*- C++ -*- #include "Rivet/Event.hh" #include "Rivet/Projection.hh" #include "Rivet/Tools/Logging.hh" #include "Rivet/Tools/BeamConstraint.hh" #include "Rivet/Tools/Cmp.hh" namespace Rivet { Projection::Projection() : _name("BaseProjection") { addPdgIdPair(PID::ANY, PID::ANY); } Projection:: ~Projection() = default; Projection& Projection::operator = (const Projection&) { return *this; } bool Projection::before(const Projection& p) const { const std::type_info& thisid = typeid(*this); const std::type_info& otherid = typeid(p); if (thisid == otherid) { - const bool cmp = compare(p) == CmpState::LT; + const CmpState cmpst = compare(p); + // const bool cmp = (cmpst == CmpState::LT || cmpst == CmpState::NEQ || cmpst == CmpState::UNDEF); + const bool cmp = (cmpst != CmpState::GT); MSG_TRACE("Comparing projections of same RTTI type: " << this << " < " << &p << " = " << cmp); return cmp; } else { const bool cmp = thisid.before(otherid); MSG_TRACE("Ordering projections of different RTTI type: " << this << " < " << &p << " = " << cmp); return cmp; } } const set Projection::beamPairs() const { set ret = _beamPairs; set projs = getProjections(); for (set::const_iterator ip = projs.begin(); ip != projs.end(); ++ip) { ConstProjectionPtr p = *ip; getLog() << Log::TRACE << "Proj addr = " << p << '\n'; if (p) ret = intersection(ret, p->beamPairs()); } return ret; } Cmp Projection::mkNamedPCmp(const Projection& otherparent, const string& pname) const { return pcmp(*this, otherparent, pname); } Cmp Projection::mkPCmp(const Projection& otherparent, const string& pname) const { return pcmp(*this, otherparent, pname); } } diff --git a/src/Projections/FinalState.cc b/src/Projections/FinalState.cc --- a/src/Projections/FinalState.cc +++ b/src/Projections/FinalState.cc @@ -1,83 +1,83 @@ // -*- C++ -*- #include "Rivet/Projections/FinalState.hh" namespace Rivet { FinalState::FinalState(const Cut& c) : ParticleFinder(c) { setName("FinalState"); const bool isopen = (c == Cuts::open()); MSG_TRACE("Check for open FS conditions: " << std::boolalpha << isopen); if (!isopen) declare(FinalState(), "OpenFS"); } FinalState::FinalState(const FinalState& fsp, const Cut& c) : ParticleFinder(c) { setName("FinalState"); MSG_TRACE("Registering base FSP as 'PrevFS'"); declare(fsp, "PrevFS"); } CmpState FinalState::compare(const Projection& p) const { const FinalState& other = dynamic_cast(p); // First check if there is a PrevFS and it it matches if (hasProjection("PrevFS") != other.hasProjection("PrevFS")) return CmpState::UNDEF; if (hasProjection("PrevFS")) { const PCmp prevcmp = mkPCmp(other, "PrevFS"); if (prevcmp != CmpState::EQ) return prevcmp; } // Then check the extra cuts const bool cutcmp = _cuts == other._cuts; MSG_TRACE(_cuts << " VS " << other._cuts << " -> EQ == " << std::boolalpha << cutcmp); - if (!cutcmp) return CmpState::UNDEF; + if (!cutcmp) return CmpState::NEQ; // Checks all passed: these FSes are equivalent return CmpState::EQ; } void FinalState::project(const Event& e) { _theParticles.clear(); // Handle "open FS" special case, which should not/cannot recurse if (_cuts == Cuts::OPEN) { MSG_TRACE("Open FS processing: should only see this once per event (" << e.genEvent()->event_number() << ")"); for (const GenParticle* p : Rivet::particles(e.genEvent())) { if (p->status() == 1) { //MSG_TRACE("FS GV = " << p->production_vertex()); _theParticles.push_back(Particle(*p)); } } MSG_TRACE("Number of open-FS selected particles = " << _theParticles.size()); return; } // Base the calculation on PrevFS if available, otherwise OpenFS /// @todo In general, we'd like to calculate a restrictive FS based on the most restricted superset FS. const Particles& allstable = applyProjection(e, (hasProjection("PrevFS") ? "PrevFS" : "OpenFS")).particles(); MSG_TRACE("Beginning Cuts selection"); for (const Particle& p : allstable) { const bool passed = accept(p); MSG_TRACE("Choosing: ID = " << p.pid() << ", pT = " << p.pT()/GeV << " GeV" << ", eta = " << p.eta() << ": result = " << std::boolalpha << passed); if (passed) _theParticles.push_back(p); } MSG_TRACE("Number of final-state particles = " << _theParticles.size()); } /// Decide if a particle is to be accepted or not. bool FinalState::accept(const Particle& p) const { // Not having status == 1 should never happen! assert(p.genParticle() == NULL || p.genParticle()->status() == 1); return _cuts->accept(p); } }