HepEx0505013.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Tools/Logging.hh"
00003 #include "Rivet/Analyses/HepEx0505013.hh"
00004 #include "Rivet/RivetAIDA.hh"
00005 
00006 
00007 namespace Rivet {
00008   
00009   // Book histograms
00010   void HepEx0505013::init() {
00011     // Using histogram auto-booking is preferable if there are comparison datasets in HepData.
00012     // Since this is just a demo analysis, there is no associate paper!
00013     string hist_title[18][2];
00014     //string hist_name[18][2];
00015     
00016     for (int i=0; i<18; ++i) { //18 pT bins, one histogram each
00017       stringstream lStream; 
00018       lStream << i;
00019       hist_title[i][0] = "Differential Jet Shape Rho, Pt bin " + lStream.str();
00020       //_histRho_pT[i]  = bookHistogram1D(i+1, 1, 1, hist_title[i][0]);
00021       _histRho_pT[i] = bookHistogram1D(hist_title[i][0], hist_title[i][0], 7, 0., 1.);
00022       hist_title[i][1] = "Integral Jet Shape Psi, Pt bin " + lStream.str();
00023       //_histPsi_pT[i]  = bookHistogram1D(i+1, 1, 1, hist_title[i][1]);
00024       _histPsi_pT[i] = bookHistogram1D(hist_title[i][1], hist_title[i][1], 7, 0., 1.);
00025     }
00026     
00027     string hist_title_oneminPsi = "One minus Psi(0.3 over R)";
00028     //_histOneMinPsi = bookHistogram1D(19, 1, 1, hist_title_oneminPsi);
00029     _histOneMinPsi = bookHistogram1D(hist_title_oneminPsi, hist_title_oneminPsi, _pTbins);
00030     
00031   }
00032   
00033   
00034   // Do the analysis
00035   void HepEx0505013::analyze(const Event& event) {
00036     Log log = getLog();
00037     log << Log::DEBUG << "Starting analyzing" << endl;
00038     
00039     // Analyse and print some info  
00040     #ifdef HAVE_FASTJET
00041     const FastJets& jetpro = event.applyProjection(_jetsproj);
00042     #else
00043     const D0ILConeJets& jetpro = event.applyProjection(_jetsproj);
00044     ////const KtJets& jetpro = event.applyProjection(_jetsproj);    
00045     #endif
00046     
00047     log << Log::DEBUG << "Jet multiplicity before any pT cut = " << jetpro.getNJets() << endl;
00048     
00049     
00050     // Find vertex and check  that its z-component is < 60 cm from the nominal IP
00051     //const PVertex& pv = event.applyProjection(_vertexproj);
00052     /// @todo SEGV: either the HepMC event record is not filled properly or the F77-Wrapper functions are faulty
00053     /// @todo z- value assumed to be in mm, PYTHIA convention: dangerous!
00054     //if (fabs(pv.getPrimaryVertex().position().z()) < 600.0) {
00055 
00056 
00057     /// @todo Remove compile-time flags like this when possible.
00058     #ifdef HAVE_FASTJET
00059     typedef vector<fastjet::PseudoJet> Jets;
00060     const Jets& jets = jetpro.getJetsPt();
00061     #else
00062     typedef list<LorentzVector> Jets;
00063     const Jets& jets = jetpro.getLorentzJets();
00064     ////const vector<KtJet::KtLorentzVector>& jets = jetpro.getJets();
00065     #endif
00066     
00067     log << Log::DEBUG << "jetlist size = " << jets.size() << endl;
00068     
00069     int Njet = 0;
00070     bool jetcutpass = false;
00071     
00072     for (Jets::const_iterator jt = jets.begin(); jt != jets.end(); ++jt) {
00073       ////for (vector<KtJet::KtLorentzVector>::const_iterator jt = jets.begin(); jt != jets.end(); ++jt) {
00074       
00075       log << Log::DEBUG << "List item pT = " << jt->perp() << " E=" << jt->e() << " pz=" << jt->pz() << endl;
00076       if (jt->perp()>37. && fabs(jt->rapidity())>0.1 && fabs(jt->rapidity())<0.7) jetcutpass = true;
00077       ++Njet;
00078       log << Log::DEBUG << "Jet pT =" << jt->perp() << " y=" << jt->rapidity() << " phi=" << jt->phi() << endl; 
00079     }
00080     
00081     if (jetcutpass) {
00082       
00083       const TotalVisibleMomentum& caloMissEt = event.applyProjection(_calmetproj);
00084       log << Log::DEBUG << "CaloMissEt.getMomentum().perp() = " << caloMissEt.getMomentum().perp() << endl;
00085       
00086       if (caloMissEt.getMomentum().perp()/sqrt(caloMissEt.getSET()) < 3.5) {
00087         
00088         LorentzVector jetaxis;
00089         _jetaxes.clear();
00090         //cout << "Jets: N=" << jetpro.getNJets() << endl;
00091         for (Jets::const_iterator jt = jets.begin(); jt != jets.end(); ++jt) {
00092           ////for (vector<KtJet::KtLorentzVector>::const_iterator jt = jets.begin(); jt != jets.end(); ++jt) {
00093           if (fabs(jt->rapidity())<1.1) { //only Central Calorimeter jets
00094             jetaxis.setPx(jt->px());
00095             jetaxis.setPy(jt->py());
00096             jetaxis.setPz(jt->pz());
00097             jetaxis.setE(jt->e());
00098             //cout << "jet: px=" << jt->px() << " py=" << jt->py() << " pz=" << jt->pz() 
00099             // << " E=" << jt->e() << endl;
00100             _jetaxes.push_back(jetaxis);
00101           }
00102         }
00103         if (_jetaxes.size()>0) { //determine jet shapes
00104           
00105           const JetShape& jetShape = event.applyProjection(_jetshapeproj);
00106           
00107           //fill histograms
00108           for (unsigned int jind=0; jind<_jetaxes.size(); ++jind) {
00109             for (int ipT=0; ipT<18; ++ipT) {
00110               if (_jetaxes[jind].perp() > _pTbins[ipT] && _jetaxes[jind].perp() <= _pTbins[ipT+1]) {
00111                 _ShapeWeights[ipT] += event.weight(); 
00112                 for (int rbin=0; rbin<_jetshapeproj.getNbins(); ++rbin) {
00113                   double rad = _jetshapeproj.getRmin() +(rbin+0.5)*_jetshapeproj.getInterval();
00114                   _histRho_pT[ipT]->fill(rad/_Rjet, double(_diffjetshapes[jind][rbin]) * event.weight());
00115                   _histPsi_pT[ipT]->fill(rad/_Rjet, double(_intjetshapes[jind][rbin]) * event.weight());
00116                 }
00117                 _histOneMinPsi->fill((_pTbins[ipT]+_pTbins[ipT+1])/2., 
00118                                      _oneminPsishape[jind] * event.weight());
00119               }
00120             }
00121           }
00122         }
00123       }
00124     }
00125     
00126     
00127     
00128     // Finished
00129     log << Log::DEBUG << "Finished analyzing" << endl;
00130   }
00131   
00132   
00133   // Finalize
00134   void HepEx0505013::finalize() { 
00135     
00136     vector<double> OneMinPsiBins(18, 0.);
00137     
00138     for (int i=0; i<18; ++i) { //18 pT bins, one histogram each
00139       
00140       if (_ShapeWeights[i] > 0.) {
00141         //divide each histogram, each bin by sum of event weights _EventWeights
00142         _histRho_pT[i]->scale(1./_ShapeWeights[i]);
00143         _histPsi_pT[i]->scale(1./_ShapeWeights[i]); 
00144         OneMinPsiBins[i] = _histOneMinPsi->binHeight(i)/_ShapeWeights[i];
00145       }
00146       else OneMinPsiBins[i] = 0.; 
00147     }
00148     
00149     _histOneMinPsi->reset();
00150     for (int i=0; i<18; ++i) { //refill the reset histogram with normalized bins
00151       _histOneMinPsi->fill((_pTbins[i]+_pTbins[i+1])/2., OneMinPsiBins[i]);
00152     }
00153   }
00154   
00155   
00156 }