PRD65092002.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // Field & Stuart underlying event analysis at CDF.
00004 // Phys.Rev.D65:092002,2002 // no hep-ex code
00005 // FNAL-PUB 01/211-E
00006 
00007 #include "Rivet/Rivet.hh"
00008 #include "Rivet/Tools/Logging.hh"
00009 #include "Rivet/Analyses/PRD65092002.hh"
00010 using namespace Rivet;
00011 
00012 #include "Rivet/RivetAIDA.hh"
00013 using namespace AIDA;
00014 
00015 #include "HepPDT/ParticleID.hh"
00016 using namespace HepMC;
00017 
00018 
00019 /////////////////////////////////////////////////
00020 
00021 
00022 // Book histograms
00023 void PRD65092002::init() {
00024   // Book mini histos (for the profile histo effect) and storage histos
00025   _dataToward.reserve(_numBins);
00026   _dataAway.reserve(_numBins);
00027   _dataTrans.reserve(_numBins);
00028 
00029   // Data point sets
00030   /// @todo Should really use proper profile histograms.
00031   _dpsToward = bookDataPointSet("PtSumToward", "pT sum toward total", 50, 0.0, 50.0);
00032   _dpsTrans = bookDataPointSet("PtSumTransverse", "pT sum transverse total", 50, 0.0, 50.0);
00033   _dpsAway = bookDataPointSet("PtSumAway", "pT sum away total", 50, 0.0, 50.0);
00034 
00035   // Book mini-histos
00036   for (size_t bin = 0; bin < _numBins; ++bin) {
00037     _dataToward[bin] = MiniHisto();
00038     _dataAway[bin] = MiniHisto();
00039     _dataTrans[bin] = MiniHisto();
00040   }
00041 
00042 }
00043 
00044 
00045 // Do the analysis
00046 void PRD65092002::analyze(const Event& event) {
00047   Log log = getLog();
00048 
00049   // Analyse, with pT > 0.5 GeV AND |eta| < 1
00050   const TrackJet& tj = event.applyProjection(_trackjetproj);
00051 
00052   // Get jets, sorted by pT
00053   const TrackJet::Jets jets = tj.getJets();
00054   if (jets.size()==0) { return; }
00055 
00056   TrackJet::Jet leadingJet = jets[0];
00057   const double phiLead = leadingJet.getPtWeightedPhi();
00058   const double ptLead = leadingJet.getPtSum();
00059 
00060   // Cut on highest pT jet: combined 0.5 GeV < pT(lead) < 50 GeV
00061   if (ptLead < 0.5) return;
00062   if (ptLead > 50.0) return;
00063   const size_t nBin = size_t(floor(ptLead));
00064   
00065   // Run over tracks in non-leading jets
00066   double ptSumToward(0.0), ptSumAway(0.0), ptSumTrans(0.0);
00067   for (TrackJet::Jets::const_iterator j = jets.begin()+1; j != jets.end(); ++j) {
00068     for (TrackJet::Jet::const_iterator p = j->begin(); p != j->end(); ++p) {
00069       // Calculate delta phi from leading jet
00070       double deltaPhi = fabs(p->phi() - phiLead);
00071       if (deltaPhi > PI) deltaPhi -= PI;
00072       assert(deltaPhi >= 0);
00073       assert(deltaPhi <= PI);
00074 
00075       // Get a pT sum value for each region (1 number for each region per event)
00076       if (deltaPhi < PI/3.0) {
00077         ptSumToward += pT(*p);
00078       } else if (deltaPhi < 2*PI/3.0) {
00079         ptSumTrans += pT(*p);
00080       } else {
00081         ptSumAway += pT(*p);
00082       }
00083 
00084     }
00085   }
00086 
00087   // Log some event details
00088   log << Log::DEBUG 
00089       << "pT [lead; twd, away, trans] = ["
00090       << ptLead << "; " 
00091       << ptSumToward << ", " 
00092       << ptSumAway << ", " 
00093       << ptSumTrans << "]" 
00094       << ", nbin = " << nBin
00095       << endl;
00096 
00097   // Update the proto-profile histograms
00098   if (nBin>_numBins) {
00099     log << Log::ERROR << "nBin out of range: " << nBin << endl;
00100   } else {
00101     _dataToward[nBin] += ptSumToward;
00102     _dataAway[nBin] += ptSumAway;
00103     _dataTrans[nBin] += ptSumTrans;
00104   }
00105 }
00106 
00107 
00108 // Create the profile histograms
00109 void PRD65092002::finalize() {
00110   for (size_t bin = 0; bin < _numBins; ++bin) {
00111 
00112     const double nToward = _dataToward[bin].numEntries;
00113     if (nToward) {
00114       const double avgPt = _dataToward[bin].sumPt/nToward;
00115       const double avgPt2 = _dataToward[bin].sumPtSq/nToward;
00116       const double err = sqrt(avgPt2 - avgPt*avgPt);
00117       IMeasurement* meas = _dpsToward->point(bin)->coordinate(1);
00118       meas->setValue(avgPt);
00119       meas->setErrorPlus(err);
00120       meas->setErrorMinus(err);
00121     }
00122 
00123     const double nTrans = _dataTrans[bin].numEntries;
00124     if (nTrans) {
00125       const double avgPt = _dataTrans[bin].sumPt/nTrans;
00126       const double avgPt2 = _dataTrans[bin].sumPtSq/nTrans;
00127       const double err = sqrt(avgPt2 - avgPt*avgPt);
00128       IMeasurement* meas = _dpsTrans->point(bin)->coordinate(1);
00129       meas->setValue(avgPt);
00130       meas->setErrorPlus(err);
00131       meas->setErrorMinus(err);
00132     }
00133 
00134     const double nAway = _dataAway[bin].numEntries;
00135     if (nAway) {
00136       const double avgPt = _dataAway[bin].sumPt/nAway;
00137       const double avgPt2 = _dataAway[bin].sumPtSq/nAway;
00138       const double err = sqrt(avgPt2 - avgPt*avgPt);
00139       IMeasurement* meas = _dpsAway->point(bin)->coordinate(1);
00140       meas->setValue(avgPt);
00141       meas->setErrorPlus(err);
00142       meas->setErrorMinus(err);
00143     }
00144 
00145   }
00146 
00147 }