JetShape.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Tools/Logging.hh"
00003 #include "Rivet/Projections/JetShape.hh"
00004 
00005 namespace Rivet {
00006 
00007 
00008   /// Constructor.
00009   JetShape::JetShape(const VetoedFinalState& vfsp,
00010                      const vector<FourMomentum>& jetaxes,
00011                      double rmin, double rmax, double interval,
00012                      double r1minPsi, DeltaRScheme distscheme)
00013     : _jetaxes(jetaxes),
00014       _rmin(rmin), _rmax(rmax), _interval(interval),
00015       _r1minPsi(r1minPsi), _distscheme(distscheme)
00016   {
00017     setName("JetShape");
00018     _nbins = int(round((rmax-rmin)/interval));
00019     addProjection(vfsp, "FS");
00020   }
00021 
00022 
00023   int JetShape::compare(const Projection& p) const {
00024     PCmp fscmp = mkNamedPCmp(p, "FS");
00025     if (fscmp == EQUIVALENT) return EQUIVALENT;
00026     const JetShape& other = dynamic_cast<const JetShape&>(p);
00027     return cmp(&_jetaxes, &other._jetaxes);
00028   }
00029 
00030 
00031   void JetShape::clear() {
00032     // Reset vectors for each event
00033     _diffjetshapes.clear();
00034     _intjetshapes.clear();
00035     for (size_t i = 0; i < _jetaxes.size(); ++i) {
00036       const vector<double> tmp(_nbins, 0.0);
00037       _diffjetshapes.push_back(tmp);
00038       _intjetshapes.push_back(tmp);
00039     }
00040     _PsiSlot.clear();
00041     _PsiSlot.resize(_jetaxes.size(), 0.0);
00042   }
00043 
00044 
00045   void JetShape::project(const Event& e) {
00046     // Reset for new event
00047     clear();
00048 
00049     if (!_jetaxes.empty()) {
00050       const VetoedFinalState& vfs = applyProjection<VetoedFinalState>(e, "FS");
00051       foreach (const Particle& p, vfs.particles()) {
00052         double drad_min = TWOPI;
00053         size_t i_drad_min = 0;
00054      
00055         // Identify "best match" jet axis for this particle
00056         for (size_t j = 0; j < _jetaxes.size(); ++j) {
00057           const double drad = deltaR(_jetaxes[j], p.momentum(), _distscheme);
00058           if (drad < drad_min) {
00059             i_drad_min = j;
00060             drad_min = drad;
00061           }
00062         }
00063 
00064         // Fill diff & int jet shape histos for closest jet axis
00065         /// @todo Actually use histograms here, rather than doing the binning by hand
00066         /// @todo Calculate int jet shape from diff jet shape histo (YODA)
00067         for (size_t i = 0; i < _nbins; ++i) {
00068           if (drad_min < _rmin + (i+1)*_interval) {
00069             _intjetshapes[i_drad_min][i] += p.momentum().pT();
00070             if (drad_min > _rmin + i*_interval) {
00071               _diffjetshapes[i_drad_min][i] += p.momentum().pT()/_interval;
00072             }
00073           }
00074         }
00075 
00076         // Sum pT of closest match jet axes for dr < _r1minPsi
00077         /// @todo Calculate int [0.0, 0.3] jet shape from diff jet shape histo (YODA)
00078         if (drad_min < _r1minPsi) {
00079           _PsiSlot[i_drad_min] += p.momentum().pT();
00080         }
00081 
00082       }
00083   
00084    
00085       // Normalize to total pT
00086       for (size_t j = 0; j < _jetaxes.size(); j++) {
00087         const double psimax = _intjetshapes[j][_nbins-1];
00088         if (psimax > 0.0) {
00089           _PsiSlot[j] /= psimax;
00090           for (size_t i = 0; i < _nbins; ++i) {
00091             _diffjetshapes[j][i] /= psimax;
00092             _intjetshapes[j][i] /= psimax;
00093           }
00094         }
00095       }
00096 
00097    
00098     }
00099   }
00100 
00101 
00102 }