00001
00002 #include "Rivet/Tools/Logging.hh"
00003 #include "Rivet/Projections/JetShape.hh"
00004
00005 namespace Rivet {
00006
00007
00008
00009 JetShape::JetShape(const JetAlg& jetalg,
00010 double rmin, double rmax, size_t nbins,
00011 double ptmin, double ptmax,
00012 double absrapmin, double absrapmax,
00013 RapScheme rapscheme)
00014 : _rapscheme(rapscheme)
00015 {
00016 setName("JetShape");
00017 _binedges = linspace(rmin, rmax, nbins);
00018 _ptcuts = make_pair(ptmin, ptmax);
00019 _rapcuts = make_pair(absrapmin, absrapmax);
00020 addProjection(jetalg, "Jets");
00021 }
00022
00023
00024
00025 JetShape::JetShape(const JetAlg& jetalg,
00026 vector<double> binedges,
00027 double ptmin, double ptmax,
00028 double absrapmin, double absrapmax,
00029 RapScheme rapscheme)
00030 : _binedges(binedges), _rapscheme(rapscheme)
00031 {
00032 setName("JetShape");
00033 _ptcuts = make_pair(ptmin, ptmax);
00034 _rapcuts = make_pair(absrapmin, absrapmax);
00035 addProjection(jetalg, "Jets");
00036 }
00037
00038
00039 int JetShape::compare(const Projection& p) const {
00040 const int jcmp = mkNamedPCmp(p, "Jets");
00041 if (jcmp != EQUIVALENT) return jcmp;
00042 const JetShape& other = pcast<JetShape>(p);
00043 const int ptcmp = cmp(ptMin(), other.ptMin()) || cmp(ptMax(), other.ptMax());
00044 if (ptcmp != EQUIVALENT) return ptcmp;
00045 const int rapcmp = cmp(_rapcuts.first, other._rapcuts.first) || cmp(_rapcuts.second, other._rapcuts.second);
00046 if (rapcmp != EQUIVALENT) return rapcmp;
00047 int bincmp = cmp(numBins(), other.numBins());
00048 if (bincmp != EQUIVALENT) return bincmp;
00049 for (size_t i = 0; i < _binedges.size(); ++i) {
00050 bincmp = cmp(_binedges[i], other._binedges[i]);
00051 if (bincmp != EQUIVALENT) return bincmp;
00052 }
00053 return EQUIVALENT;
00054 }
00055
00056
00057 void JetShape::clear() {
00058 _diffjetshapes.clear();
00059 }
00060
00061
00062 void JetShape::calc(const Jets& jets) {
00063 clear();
00064
00065 foreach (const Jet& j, jets) {
00066
00067 FourMomentum pj = j.momentum();
00068 if (!inRange(pj.pT(), _ptcuts)) continue;
00069
00070 if (_rapscheme == PSEUDORAPIDITY && !inRange(fabs(pj.eta()), _rapcuts)) continue;
00071 if (_rapscheme == RAPIDITY && !inRange(fabs(pj.rapidity()), _rapcuts)) continue;
00072
00073
00074 vector<double> bins(numBins(), 0.0);
00075 foreach (const Particle& p, j.particles()) {
00076 const double dR = deltaR(pj, p.momentum(), _rapscheme);
00077 const int dRindex = index_between(dR, _binedges);
00078 if (dRindex == -1) continue;
00079 bins[dRindex] += p.momentum().pT();
00080 }
00081
00082
00083 _diffjetshapes += bins;
00084 }
00085
00086
00087 foreach (vector<double>& binsref, _diffjetshapes) {
00088 double integral = 0.0;
00089 for (size_t i = 0; i < numBins(); ++i) {
00090 integral += binsref[i];
00091 }
00092 if (integral > 0) {
00093 for (size_t i = 0; i < numBins(); ++i) {
00094 binsref[i] /= integral;
00095 }
00096 } else {
00097
00098 MSG_DEBUG("No pT contributions in jet Delta(r) range: weird!");
00099 }
00100 }
00101
00102 }
00103
00104
00105 void JetShape::project(const Event& e) {
00106 const Jets jets = applyProjection<JetAlg>(e, "Jets").jets(_ptcuts.first, _ptcuts.second,
00107 -_rapcuts.second, _rapcuts.second, _rapscheme);
00108 calc(jets);
00109 }
00110
00111
00112 }