[Rivet-svn] r3255 - in trunk: . include/Rivet/Projections src/Projections

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Mon Jul 25 17:54:58 BST 2011


Author: buckley
Date: Mon Jul 25 17:54:58 2011
New Revision: 3255

Log:
Adding a useTransverseMass flag method and implementation to InvMassFinalState, and using it in the WFinder, after feedback from Gavin Hesketh. This was the neatest way I could do it :S Some other tidying up happened along the way.

Modified:
   trunk/ChangeLog
   trunk/include/Rivet/Projections/InvMassFinalState.hh
   trunk/include/Rivet/Projections/WFinder.hh
   trunk/src/Projections/InvMassFinalState.cc
   trunk/src/Projections/WFinder.cc

Modified: trunk/ChangeLog
==============================================================================
--- trunk/ChangeLog	Mon Jul 25 17:52:49 2011	(r3254)
+++ trunk/ChangeLog	Mon Jul 25 17:54:58 2011	(r3255)
@@ -1,3 +1,13 @@
+2011-07-25  Andy Buckley  <andy at insectnation.org>
+
+	* Adding a useTransverseMass flag method and implementation to
+	InvMassFinalState, and using it in the WFinder, after feedback
+	from Gavin Hesketh. This was the neatest way I could do it :S Some
+	other tidying up happened along the way.
+
+	* Adding transverse mass massT and massT2 methods and functions
+	for FourMomentum.
+
 2011-07-22  Frank Siegert  <frank.siegert at cern.ch>
 
 	* Added ATLAS_2011_S9120807

Modified: trunk/include/Rivet/Projections/InvMassFinalState.hh
==============================================================================
--- trunk/include/Rivet/Projections/InvMassFinalState.hh	Mon Jul 25 17:52:49 2011	(r3254)
+++ trunk/include/Rivet/Projections/InvMassFinalState.hh	Mon Jul 25 17:54:58 2011	(r3255)
@@ -11,7 +11,7 @@
   class InvMassFinalState : public FinalState {
   public:
 
-    // Constructor for a single inv-mass pair
+    /// Constructor for a single inv-mass pair.
     InvMassFinalState(const FinalState& fsp,
                       const std::pair<PdgId, PdgId>& idpair, // pair of decay products
                       double minmass, // min inv mass
@@ -19,6 +19,7 @@
                       double masstarget=-1.0);
 
 
+    /// Constructor for multiple inv-mass pairs.
     InvMassFinalState(const FinalState& fsp,
                       const std::vector<std::pair<PdgId, PdgId> >& idpairs,  // vector of pairs of decay products
                       double minmass, // min inv mass
@@ -34,10 +35,16 @@
 
   public:
 
-    /// Constituent pairs
+    /// Constituent pairs.
     const std::vector<std::pair<Particle, Particle> >& particlePairs() const;
 
 
+    /// Choose whether to use the full inv mass or just the transverse mass.
+    void useTransverseMass(bool usetrans=true) {
+      _useTransverseMass = usetrans;
+    }
+
+
   protected:
 
     /// Apply the projection on the supplied event.
@@ -49,21 +56,23 @@
 
   private:
 
-    /// IDs of the decay products
+    /// IDs of the decay products.
     std::vector<PdgIdPair> _decayids;
 
-    /// Constituent pairs
+    /// Constituent pairs.
     std::vector<std::pair<Particle, Particle> > _particlePairs;
 
-    /// Min inv mass
+    /// Min inv mass.
     double _minmass;
 
-    /// Max inv mass
+    /// Max inv mass.
     double _maxmass;
 
-    /// Target mass if only one pair should be returned
+    /// Target mass if only one pair should be returned.
     double _masstarget;
 
+    /// Flag to decide whether to use the full inv mass or just the transverse mass.
+    bool _useTransverseMass;
   };
 
 

Modified: trunk/include/Rivet/Projections/WFinder.hh
==============================================================================
--- trunk/include/Rivet/Projections/WFinder.hh	Mon Jul 25 17:52:49 2011	(r3254)
+++ trunk/include/Rivet/Projections/WFinder.hh	Mon Jul 25 17:54:58 2011	(r3255)
@@ -32,7 +32,7 @@
     //         double dRmax, bool clusterPhotons, bool excludePhotonsFromRFS);
 
 
-    /// Constructor taking single eta/pT bounds and type of the charged lepton, mass
+    /// Constructor taking single eta/pT bounds and type of the charged lepton, transverse mass
     /// window, and maximum dR of photons around the charged lepton to take into account
     /// for W reconstruction.
     WFinder(double etaMin, double etaMax,
@@ -43,7 +43,7 @@
             double dRmax, bool clusterPhotons=true, bool excludePhotonsFromRFS=false);
 
 
-    /// Constructor taking multiple eta/pT bounds and type of the charged lepton, mass
+    /// Constructor taking multiple eta/pT bounds and type of the charged lepton, transverse mass
     /// window, and maximum dR of photons around the charged lepton to take into account
     /// for W reconstruction.
     WFinder(const std::vector<std::pair<double, double> >& etaRanges,
@@ -85,7 +85,9 @@
   public:
 
     /// Clear the projection
-    void clear();
+    void clear() {
+      _theParticles.clear();
+    }
 
 
   private:

Modified: trunk/src/Projections/InvMassFinalState.cc
==============================================================================
--- trunk/src/Projections/InvMassFinalState.cc	Mon Jul 25 17:52:49 2011	(r3254)
+++ trunk/src/Projections/InvMassFinalState.cc	Mon Jul 25 17:54:58 2011	(r3255)
@@ -41,7 +41,9 @@
     fscmp = FinalState::compare(other);
     if (fscmp != EQUIVALENT) return fscmp;
 
-    // Then compare the mass limits
+    // Compare the mass limits
+    int masstypecmp = cmp(_useTransverseMass, other._useTransverseMass);
+    if (masstypecmp != EQUIVALENT) return masstypecmp;
     int massllimcmp = cmp(_minmass, other._minmass);
     if (massllimcmp != EQUIVALENT) return massllimcmp;
     int masshlimcmp = cmp(_maxmass, other._maxmass);
@@ -92,27 +94,32 @@
     closestPair.first = 1e30;
     foreach (const Particle* i1, type1) {
       foreach (const Particle* i2, type2) {
-	// check this is actually a pair 
-	// (if more than one pair in vector particles can be unrelated)
-	bool found = false;
-	foreach (const PdgIdPair& ipair, _decayids) {
-	  if (i1->pdgId() == ipair.first &&
-	      i2->pdgId() == ipair.second) {
-	    found=true;
-	    break;
-	  }
-	}
-	if(!found) continue;
+        // check this is actually a pair
+        // (if more than one pair in vector particles can be unrelated)
+        bool found = false;
+        foreach (const PdgIdPair& ipair, _decayids) {
+          if (i1->pdgId() == ipair.first && i2->pdgId() == ipair.second) {
+            found = true;
+            break;
+          }
+        }
+        if (!found) continue;
 
         FourMomentum v4 = i1->momentum() + i2->momentum();
         if (v4.mass2() < 0) {
-          getLog() << Log::DEBUG << "Constructed negative inv mass2: skipping!" << endl;
+          MSG_DEBUG("Constructed negative inv mass2: skipping!");
           continue;
         }
-        if (v4.mass() > _minmass && v4.mass() < _maxmass) {
-          getLog() << Log::DEBUG << "Selecting particles with IDs "
-                   << i1->pdgId() << " & " << i2->pdgId()
-                   << " and mass = " << v4.mass()/GeV << " GeV" << endl;
+        bool passedMassCut = false;
+        if (_useTransverseMass) {
+          passedMassCut = inRange(v4.mass(), _minmass, _maxmass);
+        } else {
+          passedMassCut = inRange(v4.massT(), _minmass, _maxmass);
+        }
+
+        if (passedMassCut) {
+          MSG_DEBUG("Selecting particles with IDs " << i1->pdgId() << " & " << i2->pdgId()
+                    << " and mass = " << v4.mass()/GeV << " GeV");
           // Store accepted particles, avoiding duplicates
           if (find(tmp.begin(), tmp.end(), i1) == tmp.end()) {
             tmp.push_back(i1);
@@ -134,7 +141,7 @@
         }
       }
     }
-    if (_masstarget>0.0&&closestPair.first<1e30) {
+    if (_masstarget > 0.0 && closestPair.first < 1e30) {
       _theParticles.clear();
       _particlePairs.clear();
       _theParticles += closestPair.second.first;
@@ -142,12 +149,10 @@
       _particlePairs += closestPair.second;
     }
 
-    getLog() << Log::DEBUG << "Selected " << _theParticles.size() << " particles "
-             << "(" << _particlePairs.size() << " pairs)" << endl;
+    MSG_DEBUG("Selected " << _theParticles.size() << " particles " << "(" << _particlePairs.size() << " pairs)");
     if (getLog().isActive(Log::TRACE)) {
       foreach (const Particle& p, _theParticles) {
-        getLog() << Log::TRACE << "ID: " << p.pdgId()
-                 << ", barcode: " << p.genParticle().barcode() << endl;
+        MSG_TRACE("ID: " << p.pdgId() << ", barcode: " << p.genParticle().barcode());
       }
     }
   }

Modified: trunk/src/Projections/WFinder.cc
==============================================================================
--- trunk/src/Projections/WFinder.cc	Mon Jul 25 17:52:49 2011	(r3254)
+++ trunk/src/Projections/WFinder.cc	Mon Jul 25 17:54:58 2011	(r3255)
@@ -41,13 +41,10 @@
                       PdgId pid,
                       double m2_min, double m2_max,
                       double missingET,
-                      double dRmax, bool clusterPhotons, bool excludePhotonsFromRFS) 
+                      double dRmax, bool clusterPhotons, bool excludePhotonsFromRFS)
   {
     setName("WFinder");
 
-
-
-
     // Check that the arguments are legal
     assert(abs(pid) == ELECTRON || abs(pid) == MUON);
     PdgId nu_pid = abs(pid) + 1;
@@ -57,7 +54,7 @@
     IdentifiedFinalState fs_nu;
     fs_nu.acceptNeutrinos();
 
-    // lepton clusters
+    // Lepton clusters
     FinalState fs;
     IdentifiedFinalState bareleptons(fs);
     bareleptons.acceptIdPair(pid);
@@ -66,7 +63,6 @@
                            etaRanges, pTmin);
     addProjection(leptons, "LeptonClusters");
 
-
     // Make a merged final state projection for charged and neutral leptons
     MergedFinalState mergedFS(leptons, fs_nu);
 
@@ -75,6 +71,7 @@
     l_nu_ids += make_pair(abs(pid), -abs(nu_pid));
     l_nu_ids += make_pair(-abs(pid), abs(nu_pid));
     InvMassFinalState imfs(mergedFS, l_nu_ids, m2_min, m2_max, 80.403);
+    imfs.useTransverseMass();
     addProjection(imfs, "IMFS");
 
     // Add MissingMomentum proj to calc MET
@@ -95,12 +92,15 @@
 
 
   const FinalState& WFinder::remainingFinalState() const {
+    /// @todo This must already have been applied to be useful
     return getProjection<FinalState>("RFS");
   }
 
 
   Particle WFinder::constituentLepton() const {
+    /// @todo Is this safe? This isn't applying the rest of the selection cuts
     const InvMassFinalState& imfs = getProjection<InvMassFinalState>("IMFS");
+    /// @todo Is this really meant to be _impossible_?
     assert(imfs.particles().size()==2);
 
     Particle p1,p2;
@@ -116,7 +116,9 @@
 
 
   Particle WFinder::constituentNeutrino() const {
+    /// @todo Is this safe? This isn't applying the rest of the selection cuts
     const InvMassFinalState& imfs = getProjection<InvMassFinalState>("IMFS");
+    /// @todo Is this really meant to be _impossible_?
     assert(imfs.particles().size()==2);
 
     Particle p1,p2;
@@ -131,23 +133,14 @@
   }
 
 
-  const FinalState& WFinder::originalLeptonFinalState() const
-  {
+  const FinalState& WFinder::originalLeptonFinalState() const {
     const LeptonClusters& leptons=getProjection<LeptonClusters>("LeptonClusters");
     return leptons.constituentsFinalState();
   }
 
 
   int WFinder::compare(const Projection& p) const {
-    PCmp cmp = mkNamedPCmp(p, "IMFS");
-    if (cmp != EQUIVALENT) return cmp;
-
-    return EQUIVALENT;
-  }
-
-
-  void WFinder::clear() {
-    _theParticles.clear();
+    return mkNamedPCmp(p, "IMFS");
   }
 
 
@@ -155,9 +148,11 @@
     clear();
 
     const InvMassFinalState& imfs = applyProjection<InvMassFinalState>(e, "IMFS");
-    applyProjection<FinalState>(e, "RFS");
     if (imfs.particles().size() != 2) return;
 
+    /// Apply the RFS here so that it can be acquired later via the remainingFinalState method
+    applyProjection<FinalState>(e, "RFS");
+
     Particle p1,p2;
     p1 = imfs.particles()[0];
     p2 = imfs.particles()[1];


More information about the Rivet-svn mailing list