00001
00002 #include "Rivet/Tools/Logging.hh"
00003 #include "Rivet/Projections/JetShape.hh"
00004 #include "Rivet/Cmp.hh"
00005 #include "HepPDT/ParticleID.hh"
00006
00007 using namespace inline_maths;
00008
00009
00010 namespace Rivet {
00011
00012 int JetShape::compare(const Projection& p) const {
00013 const JetShape& other = dynamic_cast<const JetShape&>(p);
00014 return
00015 pcmp(*_vfsproj, *other._vfsproj)
00016 && (*_jetaxes == *other._jetaxes);
00017 }
00018
00019
00020 void JetShape::project(const Event& e) {
00021 Log& log = getLog();
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 const VetoedFinalState& vfs = e.applyProjection(*_vfsproj);
00037
00038
00039
00040 for (unsigned int i=0; i<_diffjetshapes->size(); ++i) {
00041 _diffjetshapes[i].clear();
00042 }
00043 _diffjetshapes->clear();
00044
00045 for (unsigned int i=0; i<_jetaxes->size(); ++i) {
00046 vector<double> diffjetshape(_nbins,0.);
00047 _diffjetshapes->push_back(diffjetshape);
00048 }
00049
00050 for (unsigned int i=0; i<_intjetshapes->size(); ++i) {
00051 _intjetshapes[i].clear();
00052 }
00053 _intjetshapes->clear();
00054
00055 for (unsigned int i=0; i<_jetaxes->size(); ++i) {
00056 vector<double> intjetshape(_nbins,0.);
00057 _intjetshapes->push_back(intjetshape);
00058 }
00059
00060 _oneminPsishape->clear();
00061 _oneminPsishape->resize(_jetaxes->size(),0.);
00062
00063
00064
00065 double y1, y2, eta1, eta2, phi1, phi2, drad, dradmin;
00066 int dradminind;
00067 for (ParticleVector::const_iterator p = vfs.particles().begin(); p != vfs.particles().end(); ++p) {
00068
00069 for (unsigned int j=0; j<_jetaxes->size(); j++) {
00070 y1 = _jetaxes->at(j).rapidity();
00071 y2 = p->getMomentum().rapidity();
00072 eta1 = _jetaxes->at(j).pseudoRapidity();
00073 eta2 = p->getMomentum().eta();
00074 phi1 = _jetaxes->at(j).phi();
00075 phi2 = p->getMomentum().phi();
00076
00077 if (_distscheme==snowmass)
00078 drad = delta_rad(eta1, phi1, eta2, phi2);
00079 else
00080 drad = delta_rad(y1, phi1, y2, phi2);
00081
00082 if (j==0 || drad<dradmin) {
00083 dradminind=j;
00084 dradmin=drad;
00085 }
00086 }
00087
00088 for (int i=0; i<_nbins; ++i) {
00089 if (dradmin<_rmin+(i+1)*_interval) {
00090 (*_intjetshapes)[dradminind][i] += p->getMomentum().perp();
00091 if (dradmin>_rmin+i*_interval)
00092 (*_diffjetshapes)[dradminind][i] += p->getMomentum().perp()/_interval;
00093 }
00094 }
00095 if (dradmin<_r1minPsi/_rmax)
00096 (*_oneminPsishape)[dradminind] += p->getMomentum().perp();
00097
00098 }
00099
00100
00101
00102 for (unsigned int j=0; j<_jetaxes->size(); j++) {
00103 if ((*_intjetshapes)[j][_nbins-1] > 0.) {
00104 (*_oneminPsishape)[j] = 1.-(*_oneminPsishape)[j]/(*_intjetshapes)[j][_nbins-1];
00105 for (int i=0; i<_nbins; ++i) {
00106 (*_diffjetshapes)[j][i] /= (*_intjetshapes)[j][_nbins-1];
00107 (*_intjetshapes)[j][i] /= (*_intjetshapes)[j][_nbins-1];
00108 }
00109 }
00110 }
00111
00112 log << Log::DEBUG << "Done" << endl;
00113 }
00114
00115
00116 }