|
[Rivet-svn] r3514 - in branches/2011-07-aida2yoda: . bin data/plotinfo include/Rivet pyext src/Analyses src/Core src/Projectionsblackhole at projects.hepforge.org blackhole at projects.hepforge.orgTue Dec 6 15:57:48 GMT 2011
Author: hoeth Date: Tue Dec 6 15:57:47 2011 New Revision: 3514 Log: merge r3494-3500 from trunk Modified: branches/2011-07-aida2yoda/ChangeLog branches/2011-07-aida2yoda/bin/rivet branches/2011-07-aida2yoda/data/plotinfo/MC_GENERIC.plot branches/2011-07-aida2yoda/include/Rivet/Analysis.hh branches/2011-07-aida2yoda/include/Rivet/Jet.hh branches/2011-07-aida2yoda/pyext/lighthisto.py branches/2011-07-aida2yoda/src/Analyses/CDF_2001_S4751469.cc branches/2011-07-aida2yoda/src/Core/Jet.cc branches/2011-07-aida2yoda/src/Projections/FastJets.cc Modified: branches/2011-07-aida2yoda/ChangeLog ============================================================================== --- branches/2011-07-aida2yoda/ChangeLog Tue Dec 6 15:49:59 2011 (r3513) +++ branches/2011-07-aida2yoda/ChangeLog Tue Dec 6 15:57:47 2011 (r3514) @@ -1,3 +1,21 @@ +2011-11-23 Andy Buckley <andy.buckley at cern.ch> + + * Bumping version to 1.8.0alpha0 since the Jet interface changes + are quite a major break with backward compatibility (although the + vast majority of analyses should be unaffected). + + * Removing crufty legacy stuff from the Jet class -- there is + never any ambiguity between whether Particle or FourMomentum + objects are the constituents now, and the jet 4-momentum is set + explicitly by the jet alg so that e.g. there is no mismatch if the + FastJet pt recombination scheme is used. + + * Adding default do-nothing implementations of Analysis::init() + and Analysis::finalize(), since it is possible for analysis + implementations to not need to do anything in these methods, and + forcing analysis authors to write do-nothing boilerplate code is + not "the Rivet way"! + 2011-11-19 Andy Buckley <andy.buckley at cern.ch> * Adding variant constructors to FastJets with a more natural Modified: branches/2011-07-aida2yoda/bin/rivet ============================================================================== --- branches/2011-07-aida2yoda/bin/rivet Tue Dec 6 15:49:59 2011 (r3513) +++ branches/2011-07-aida2yoda/bin/rivet Tue Dec 6 15:57:47 2011 (r3514) @@ -411,8 +411,8 @@ RUNNAME = opts.RUN_NAME or "" ah = rivet.AnalysisHandler(RUNNAME) ah.setIgnoreBeams(opts.IGNORE_BEAMS) -#if opts.ALL_ANALYSES: -# opts.ANALYSES = all_analyses +# if opts.ALL_ANALYSES: +# opts.ANALYSES = all_analyses for a in opts.ANALYSES: a_up = a.upper() ## Print warning message and exit if not a valid analysis name Modified: branches/2011-07-aida2yoda/data/plotinfo/MC_GENERIC.plot ============================================================================== --- branches/2011-07-aida2yoda/data/plotinfo/MC_GENERIC.plot Tue Dec 6 15:49:59 2011 (r3513) +++ branches/2011-07-aida2yoda/data/plotinfo/MC_GENERIC.plot Tue Dec 6 15:57:47 2011 (r3514) @@ -77,7 +77,7 @@ # BEGIN PLOT /MC_GENERIC/MultCh Title=Charged multiplicity of events -XLabel=$N_text{ch}$ +XLabel=$N_\text{ch}$ YLabel=$1/\sigma \; \mathrm{d}\sigma/\mathrm{d}N_\text{ch}$ LogY=0 # END PLOT Modified: branches/2011-07-aida2yoda/include/Rivet/Analysis.hh ============================================================================== --- branches/2011-07-aida2yoda/include/Rivet/Analysis.hh Tue Dec 6 15:49:59 2011 (r3513) +++ branches/2011-07-aida2yoda/include/Rivet/Analysis.hh Tue Dec 6 15:57:47 2011 (r3514) @@ -79,7 +79,7 @@ /// Initialize this analysis object. A concrete class should here /// book all necessary histograms. An overridden function must make /// sure it first calls the base class function. - virtual void init() = 0; + virtual void init() { } /// Analyze one event. A concrete class should here apply the /// necessary projections on the \a event and fill the relevant @@ -92,7 +92,7 @@ /// histograms to a file is, however, done by the Rivet class. An /// overridden function must make sure it first calls the base class /// function. - virtual void finalize() = 0; + virtual void finalize() { } //@} Modified: branches/2011-07-aida2yoda/include/Rivet/Jet.hh ============================================================================== --- branches/2011-07-aida2yoda/include/Rivet/Jet.hh Tue Dec 6 15:49:59 2011 (r3513) +++ branches/2011-07-aida2yoda/include/Rivet/Jet.hh Tue Dec 6 15:57:47 2011 (r3514) @@ -8,72 +8,77 @@ namespace Rivet { - /// @brief A minimal class representing a jet of particles. + /// @brief Representation of a clustered jet of particles. class Jet : public ParticleBase { public: - /// Constructor. - Jet(); + /// @name Constructors + //@{ - /// Define a Jet::iterator via a typedef. - typedef vector<FourMomentum>::iterator iterator; + Jet() : ParticleBase() { clear(); } - /// Define a Jet::const_iterator via a typedef. - typedef vector<FourMomentum>::const_iterator const_iterator; - - /// Get a begin iterator over the particle/track four-momenta in this jet. - iterator begin() { - return _particles.begin(); - } - - /// Get an end iterator over the particle/track four-momenta in this jet. - iterator end() { - return _particles.end(); + /// Set all the jet data, with full particle information. + Jet(const vector<Particle>& particles, const FourMomentum& pjet) + : ParticleBase() { + setState(particles, pjet); } - /// Get a const begin iterator over the particle/track four-momenta in this jet. - const_iterator begin() const { - return _particles.begin(); - } + // /// Set all the jet data, without particle ID information. + // Jet(const vector<FourMomentum>& momenta, const FourMomentum& pjet) + // : ParticleBase() { + // setState(momenta, pjet); + // } + + //@} + + + /// @name Access jet constituents + //@{ + + /// Number of particles in this jet. + size_t size() const { return _particles.size(); } + + // /// Define a Jet::iterator via a typedef. + // typedef vector<FourMomentum>::iterator iterator; + + // /// Define a Jet::const_iterator via a typedef. + // typedef vector<FourMomentum>::const_iterator const_iterator; + + // /// Get a begin iterator over the particle/track four-momenta in this jet. + // iterator begin() { + // return _momenta.begin(); + // } + + // /// Get an end iterator over the particle/track four-momenta in this jet. + // iterator end() { + // return _momenta.end(); + // } + + // /// Get a const begin iterator over the particle/track four-momenta in this jet. + // const_iterator begin() const { + // return _momenta.begin(); + // } + + // /// Get a const end iterator over the particle/track four-momenta in this jet. + // const_iterator end() const { + // return _momenta.end(); + // } + + // /// Get the track momenta in this jet. + // vector<FourMomentum>& momenta() { + // return _momenta; + // } + + // /// Get the track momenta in this jet (const version). + // const vector<FourMomentum>& momenta() const { + // return _momenta; + // } - /// Get a const end iterator over the particle/track four-momenta in this jet. - const_iterator end() const { - return _particles.end(); - } + /// Get the particles in this jet. + vector<Particle>& particles() { return _particles; } - /// Get the track momenta in this jet. - vector<FourMomentum>& momenta() { - return _particles; - } - - /// Get the track momenta in this jet (const version). - const vector<FourMomentum>& momenta() const { - return _particles; - } - - /// Get the Rivet::Particles (full information) in this jet - vector<Particle>& particles() { - return _fullParticles; - } - - /// Get the Rivet::Particles (full information) in this jet (const version) - const vector<Particle>& particles() const { - return _fullParticles; - } - - /// Number of particles (tracks) in this jet. - size_t size() const { - return _particles.size(); - } - - /// Set the particles/tracks collection. - Jet& setParticles(const vector<FourMomentum>& particles); - - /// Add a particle/track to this jet. - Jet& addParticle(const FourMomentum& particle); - - /// Add a particle/track to this jet. - Jet& addParticle(const Particle& particle); + /// Get the particles in this jet (const version) + const vector<Particle>& particles() const { return _particles; } /// Check whether this jet contains a particular particle. bool containsParticle(const Particle& particle) const; @@ -90,35 +95,23 @@ /// Check whether this jet contains a bottom-flavoured hadron (or decay products from one). bool containsBottom() const; - /// Reset this jet as empty. - Jet& clear(); + //@} - /// Get the average \f$ \eta \f$ for this jet, with the average weighted - /// by the \f$ p_T \f$ values of the constituent tracks. (caches) - double ptWeightedEta() const; - - /// Get the average \f$ \phi \f$ for this jet, with the average weighted - /// by the \f$ p_T \f$ values of the constituent tracks. (caches) - double ptWeightedPhi() const; - /// Get the unweighted average \f$ \eta \f$ for this jet. (caches) - double eta() const; - - /// Get the unweighted average \f$ \phi \f$ for this jet. (caches) - double phi() const; - - /// Get equivalent single momentum four-vector. (caches) - const FourMomentum& momentum() const; - - // /// Get equivalent single momentum four-vector. (caches) - // FourMomentum& momentum(); + /// @name Access the effective jet 4-vector properties + //@{ + /// Get equivalent single momentum four-vector. + const FourMomentum& momentum() const { return _momentum; } + /// Get the unweighted average \f$ \eta \f$ for this jet. (caches) + double eta() const { return momentum().eta(); } - public: + /// Get the unweighted average \f$ \phi \f$ for this jet. (caches) + double phi() const { return momentum().phi(); } /// Get the total energy of this jet. - double totalEnergy() const; + double totalEnergy() const { return momentum().E(); } /// Get the energy carried in this jet by neutral particles. double neutralEnergy() const; @@ -127,44 +120,55 @@ double hadronicEnergy() const; /// Get the sum of the \f$ p_T \f$ values of the constituent tracks. (caches) - double ptSum() const; + double ptSum() const { return momentum().pT(); } /// Get the sum of the \f$ E_T \f$ values of the constituent tracks. (caches) - double EtSum() const; + double EtSum() const { return momentum().Et(); } + //@} - private: - /// @brief Clear the internal cached values. - /// Const because cache variables are mutable. - void _resetCaches() const; - - /// @brief Calculate cached equivalent momentum vector. - /// Const because cache variables are mutable. - void _calcMomVector() const; - - /// Internal caching method to calculate the average \f$ \eta \f$ and - /// \f$ \phi \f$ for this jet, weighted by the \f$ p_T \f$ values of the - /// constituent tracks. - /// Const because cache variables are mutable. - void _calcPtAvgs() const; + /// @name Set the jet constituents and properties + //@{ + /// Set all the jet data, with full particle information. + Jet& setState(const vector<Particle>& particles, const FourMomentum& pjet); - private: + // /// Set all the jet data, without particle ID information. + // Jet& setState(const vector<FourMomentum>& momenta, const FourMomentum& pjet); + + /// Set the effective 4-momentum of the jet. + Jet& setMomentum(const FourMomentum& momentum); + + /// Set the particles collection with full particle information. + Jet& setParticles(const vector<Particle>& particles); - /// The particle tracks. - std::vector<FourMomentum> _particles; + // /// Set the particles collection with momentum information only. + // Jet& setParticles(const vector<FourMomentum>& momenta); + + // /// Add a particle/track to this jet. + // Jet& addParticle(const FourMomentum& particle); + + // /// Add a particle/track to this jet. + // Jet& addParticle(const Particle& particle); + + /// Reset this jet as empty. + Jet& clear(); + + //@} + + + private: /// Full particle information including tracks, ID etc - ParticleVector _fullParticles; + ParticleVector _particles; + + // /// The particle momenta. + // /// @todo Eliminate this to ensure consistency. + // std::vector<FourMomentum> _momenta; - /// Cached values of the \f$ p_T \f$-weighted \f$ \bar{\phi} \f$ and \f$ \bar{\eta} \f$. - mutable double _ptWeightedPhi, _ptWeightedEta; - mutable bool _okPtWeightedPhi, _okPtWeightedEta; - - /// Cached effective jet 4-vector - mutable FourMomentum _momentum; - mutable bool _okMomentum; + /// Effective jet 4-vector + FourMomentum _momentum; }; Modified: branches/2011-07-aida2yoda/pyext/lighthisto.py ============================================================================== --- branches/2011-07-aida2yoda/pyext/lighthisto.py Tue Dec 6 15:49:59 2011 (r3513) +++ branches/2011-07-aida2yoda/pyext/lighthisto.py Tue Dec 6 15:57:47 2011 (r3514) @@ -381,6 +381,11 @@ new.addBin(Bin(float(linearray[0]), float(linearray[1]), float(linearray[2]), float(linearray[3]), float(linearray[4]))) + elif len(linearray) == 6: + new.addBin(Bin(float(linearray[0]), float(linearray[1]), + float(linearray[4]), + float(linearray[5]),float(linearray[5]),None, + float(linearray[2]), float(linearray[3]))) else: sys.stderr.write("Unknown line format in '%s'\n" % line) ## Apply special annotations as histo obj attributes @@ -486,14 +491,28 @@ def asAIDA(self): "Return this bin as AIDA formatted string." ind = self.aidaindent - return (ind + "<dataPoint>\n" - + ind - + ' <measurement errorPlus="%e" value="%e" errorMinus="%e"/>\n' % ( - .5*(self.xhigh - self.xlow), self.getBinCenter(), .5*(self.xhigh - self.xlow)) - + ind - + ' <measurement errorPlus="%e" value="%e" errorMinus="%e"/>\n' % ( - self.errplus, self.val, self.errminus) - + ind + "</dataPoint>\n") + if self.ylow==None or self.yhigh==None: + out = (ind + "<dataPoint>\n" + + ind + + ' <measurement errorPlus="%e" value="%e" errorMinus="%e"/>\n' % ( + .5*(self.xhigh - self.xlow), self.getBinCenter(), .5*(self.xhigh - self.xlow)) + + ind + + ' <measurement errorPlus="%e" value="%e" errorMinus="%e"/>\n' % ( + self.errplus, self.val, self.errminus) + + ind + "</dataPoint>\n") + else : + out = (ind + "<dataPoint>\n" + + ind + + ' <measurement errorPlus="%e" value="%e" errorMinus="%e"/>\n' % ( + .5*(self.xhigh - self.xlow), float(.5*(self.xhigh + self.xlow)), .5*(self.xhigh - self.xlow)) + + ind + + ' <measurement errorPlus="%e" value="%e" errorMinus="%e"/>\n' % ( + .5*(self.yhigh - self.ylow), float(.5*(self.yhigh + self.ylow)), .5*(self.yhigh - self.ylow)) + + ind + + ' <measurement errorPlus="%e" value="%e" errorMinus="%e"/>\n' % ( + self.errplus, self.val, self.errminus) + + ind + "</dataPoint>\n") + return out def __cmp__(self, other): """Sort by mean x value (yeah, I know...)""" Modified: branches/2011-07-aida2yoda/src/Analyses/CDF_2001_S4751469.cc ============================================================================== --- branches/2011-07-aida2yoda/src/Analyses/CDF_2001_S4751469.cc Tue Dec 6 15:49:59 2011 (r3513) +++ branches/2011-07-aida2yoda/src/Analyses/CDF_2001_S4751469.cc Tue Dec 6 15:57:47 2011 (r3514) @@ -100,7 +100,7 @@ } Jet leadingJet = jets.front(); - const double phiLead = leadingJet.ptWeightedPhi(); + const double phiLead = leadingJet.phi(); const double ptLead = leadingJet.ptSum(); // Cut on highest pT jet: combined 0.5 GeV < pT(lead) < 50 GeV @@ -209,7 +209,7 @@ // Log some event details about Nch MSG_DEBUG("N [twd, away, trans] = [" << ptLead << "; " - << numToward << ", " << numTrans << ", " << numAway << "]"); + << numToward << ", " << numTrans << ", " << numAway << "]"); // Update the N_track profile histograms _numTowardMB->fill(ptLead/GeV, numToward, weight); Modified: branches/2011-07-aida2yoda/src/Core/Jet.cc ============================================================================== --- branches/2011-07-aida2yoda/src/Core/Jet.cc Tue Dec 6 15:49:59 2011 (r3513) +++ branches/2011-07-aida2yoda/src/Core/Jet.cc Tue Dec 6 15:57:47 2011 (r3514) @@ -7,34 +7,53 @@ namespace Rivet { - Jet::Jet() - : ParticleBase() - { - clear(); + Jet& Jet::setState(const vector<Particle>& particles, const FourMomentum& pjet) { + setParticles(particles); + setMomentum(pjet); + return *this; } - Jet& Jet::setParticles(const vector<FourMomentum>& particles) { - _particles = particles; - _resetCaches(); - return *this; - } + // Jet& Jet::setState(const vector<FourMomentum>& momenta, const FourMomentum& pjet) { + // setParticles(momenta); + // setMomentum(pjet); + // return *this; + // } - Jet& Jet::addParticle(const FourMomentum& particle) { - _particles.push_back(particle); - _resetCaches(); + Jet& Jet::setMomentum(const FourMomentum& momentum) { + _momentum = momentum; return *this; } - Jet& Jet::addParticle(const Particle& particle) { - _fullParticles.push_back(particle); - _particles.push_back(particle.momentum()); - _resetCaches(); - return *this; - } - + Jet& Jet::setParticles(const vector<Particle>& particles) { + _particles = particles; + // foreach (const Particle& p, particles) { + // _momenta.push_back(p.momentum()); + // } + return *this; + } + + + // Jet& Jet::setParticles(const vector<FourMomentum>& momenta) { + // _momenta = momenta; + // return *this; + // } + + + // Jet& Jet::addParticle(const FourMomentum& particle) { + // _momenta.push_back(particle); + // return *this; + // } + + + // Jet& Jet::addParticle(const Particle& particle) { + // _particles.push_back(particle); + // _momenta.push_back(particle.momentum()); + // return *this; + // } + bool Jet::containsParticle(const Particle& particle) const { const int barcode = particle.genParticle().barcode(); @@ -66,11 +85,6 @@ /// @todo Jet::containsMatch(Matcher m) { ... if m(pid) return true; ... } - double Jet::totalEnergy() const { - return momentum().E(); - } - - double Jet::neutralEnergy() const { double e_neutral = 0.0; foreach (const Particle& p, particles()) { @@ -130,91 +144,11 @@ Jet& Jet::clear() { + //_momenta.clear(); _particles.clear(); - _fullParticles.clear(); - _resetCaches(); + _momentum = FourMomentum(); return *this; } - double Jet::ptWeightedEta() const { - _calcPtAvgs(); - assert(_okPtWeightedEta); - return _ptWeightedEta; - } - - - double Jet::ptWeightedPhi() const { - _calcPtAvgs(); - assert(_okPtWeightedPhi); - return _ptWeightedPhi; - } - - - double Jet::eta() const { - return momentum().eta(); - - } - - - double Jet::phi() const { - return momentum().phi(); - } - - - const FourMomentum& Jet::momentum() const { - _calcMomVector(); - return _momentum; - } - - - // FourMomentum& Jet::momentum() { - // _calcMomVector(); - // return _momentum; - // } - - - double Jet::ptSum() const { - return momentum().pT(); - } - - - double Jet::EtSum() const { - return momentum().Et(); - } - - - void Jet::_resetCaches() const { - _okPtWeightedPhi = false; - _okPtWeightedEta = false; - _okMomentum = false; - } - - - void Jet::_calcMomVector() const { - if (!_okMomentum) { - _momentum = accumulate(begin(), end(), FourMomentum()); - _okMomentum = true; - } - } - - - void Jet::_calcPtAvgs() const { - if (!_okPtWeightedEta || !_okPtWeightedPhi) { - double ptwetasum(0.0), ptwdphisum(0.0), ptsum(0.0); - double phi0 = phi(); - foreach (const FourMomentum& p, momenta()) { - double pt = p.pT(); - ptsum += pt; - ptwetasum += pt * p.pseudorapidity(); - ptwdphisum += pt * mapAngleMPiToPi(phi0 - p.azimuthalAngle()); - } - _ptWeightedEta = ptwetasum/ptsum; - _okPtWeightedEta = true; - _ptWeightedPhi = mapAngleMPiToPi(phi0 + ptwdphisum/ptsum); - _okPtWeightedPhi = true; - } - } - - } Modified: branches/2011-07-aida2yoda/src/Projections/FastJets.cc ============================================================================== --- branches/2011-07-aida2yoda/src/Projections/FastJets.cc Tue Dec 6 15:49:59 2011 (r3513) +++ branches/2011-07-aida2yoda/src/Projections/FastJets.cc Tue Dec 6 15:57:47 2011 (r3514) @@ -117,16 +117,20 @@ Jets FastJets::_pseudojetsToJets(const PseudoJets& pjets) const { Jets rtn; foreach (const fastjet::PseudoJet& pj, pjets) { - Jet j; assert(clusterSeq()); const PseudoJets parts = clusterSeq()->constituents(pj); + vector<Particle> constituents; + constituents.reserve(parts.size()); foreach (const fastjet::PseudoJet& p, parts) { map<int, Particle>::const_iterator found = _particles.find(p.user_index()); assert(found != _particles.end()); - j.addParticle(found->second); + constituents.push_back(found->second); } + FourMomentum pjet(pj.E(), pj.px(), pj.py(), pj.pz()); + Jet j(constituents, pjet); rtn.push_back(j); } + /// @todo Cache? return rtn; }
More information about the Rivet-svn mailing list |