CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/GeneratorInterface/RivetInterface/src/CMS_2012_I1102908.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Analysis.hh"
00003 #include "Rivet/Tools/Logging.hh"
00004 #include "Rivet/Tools/BinnedHistogram.hh"
00005 #include "Rivet/Projections/FinalState.hh"
00006 #include "Rivet/Projections/FastJets.hh"
00007 #include "Rivet/RivetAIDA.hh"
00008 
00009 #include "LWH/HistogramFactory.h"
00010 #include "LWH/Histogram1D.h"
00011 
00012 
00013 // exclusive events are a subset of inclusive events
00014 // so we need special error estimation treatment
00015 void divide_set_by_subset_with_binomial_errors(AIDA::IDataPointSet* h, const AIDA::IHistogram1D & hist1, const AIDA::IHistogram1D & hist2);
00016 
00017 
00018 #include <sstream>
00019 
00020 
00021 namespace Rivet {
00022 
00023  
00024    // CMS Measurement of inclusive and exclusive dijet production
00025    // ratio at large rapidity intervals
00026 
00027   
00028 class CMS_2012_I1102908 : public Analysis {
00029 public:
00030   
00031   CMS_2012_I1102908() : Analysis("CMS_2012_I1102908") {    
00032     setBeams(PROTON, PROTON);
00033     setNeedsCrossSection(false); /* we don't need cross section for dijet ratio */
00034   }
00035   
00036   
00037   // ======================================================== init
00038   
00039   void init() {
00040 
00041     FinalState fs;
00042     FastJets akt(fs, FastJets::ANTIKT, 0.5);
00043     addProjection(akt, "antikT");
00044 
00045     // dijet ratio
00046     _hist_dijet_ratio = bookDataPointSet(1,1,1);
00047     // MN dijet ratio
00048     _hist_MN_dijet_ratio = bookDataPointSet(2,1,1);
00049     // exclusive dijets
00050     _hist_DeltaY_exclusive = bookHistogram1D("DeltaY_exclusive", binEdges(1, 1, 1));
00051     // inclusive dijets
00052     _hist_DeltaY_inclusive = bookHistogram1D("DeltaY_inclusive", binEdges(1, 1, 1));
00053     // Mueller-Navelet dijets
00054     _hist_DeltaY_MN = bookHistogram1D("DeltaY_MN", binEdges(1, 1, 1));
00055     
00056   }
00057   
00058   // ======================================================== analyze
00059   
00060   
00061   void analyze(const Event & event) {
00062     const double weight = event.weight();
00063         
00064     // Jets with  pT > 35.0, -4.7 < y < 4.7
00065     JetAlg const &jet_alg = applyProjection<JetAlg>(event, "antikT");
00066     const Jets& jets = jet_alg.jets(35.0/GeV, Rivet::MAXDOUBLE, -4.7, 4.7, RAPIDITY);
00067     
00068     // veto event if number of jets less than 2
00069     if(jets.size() < 2) return;
00070     
00071     // loop over jet pairs
00072     double deltaY_MN = 0.0;
00073     for(Jets::const_iterator jet1 = jets.begin(); jet1 != jets.end(); ++jet1) {
00074       for(Jets::const_iterator jet2 = jet1 + 1; jet2 != jets.end(); ++jet2) {
00075         const double y1 = jet1->momentum().rapidity(), y2 = jet2->momentum().rapidity();
00076         const double deltaY = fabs(y1 - y2);
00077         
00078         // exclusive case:
00079         if(jets.size()==2) {
00080           _hist_DeltaY_exclusive->fill(deltaY, weight);
00081         }
00082         
00083         // inclusive case:
00084         _hist_DeltaY_inclusive->fill(deltaY, weight);
00085         
00086         // Mueller-Navelet:
00087         if(deltaY > deltaY_MN) {
00088           deltaY_MN = deltaY;
00089         }
00090       }
00091     }
00092     _hist_DeltaY_MN->fill(deltaY_MN, weight);
00093   }
00094   
00095   // ======================================================== finalize 
00096   
00097   
00098   void finalize() {
00099     // computing the ratio
00100     divide_set_by_subset_with_binomial_errors(_hist_dijet_ratio, *_hist_DeltaY_inclusive, *_hist_DeltaY_exclusive);
00101     divide_set_by_subset_with_binomial_errors(_hist_MN_dijet_ratio, *_hist_DeltaY_MN, *_hist_DeltaY_exclusive);
00102     // removing unnecessary histograms
00103     histogramFactory().destroy(_hist_DeltaY_inclusive);
00104     histogramFactory().destroy(_hist_DeltaY_exclusive);
00105     histogramFactory().destroy(_hist_DeltaY_MN);
00106   }
00107   
00108 private:
00109     
00111 
00112   AIDA::IHistogram1D *  _hist_DeltaY_inclusive;
00113   AIDA::IHistogram1D *  _hist_DeltaY_exclusive;
00114   AIDA::IHistogram1D *  _hist_DeltaY_MN;
00115   AIDA::IDataPointSet * _hist_dijet_ratio;
00116   AIDA::IDataPointSet * _hist_MN_dijet_ratio;
00118 
00119 }; 
00120   
00121   // This global object acts as a hook for the plugin system
00122   // DECLARE_RIVET_PLUGIN(CMS_2012_I1102908);
00123   AnalysisBuilder<CMS_2012_I1102908> plugin_CMS_2012_I1102908;
00124 }
00125 
00126 
00127 // adapted from HistogramFactory::divide
00128 // in order to change treatment of errors
00129 void divide_set_by_subset_with_binomial_errors(AIDA::IDataPointSet* h,
00130                                                const AIDA::IHistogram1D & hist1, const AIDA::IHistogram1D & hist2) {
00131   using namespace AIDA;
00132   using namespace Rivet;
00133   using namespace LWH;
00134   const LWH::Histogram1D& h1 = dynamic_cast<const LWH::Histogram1D &>(hist1);
00135   const LWH::Histogram1D& h2 = dynamic_cast<const LWH::Histogram1D &>(hist2);
00136   for (int i = 0; i < h1.axis().bins(); ++i) {
00137     AIDA::IDataPoint* point = h->point(i);
00138     double yval(0), yerr(0);
00139     if ( h1.binHeight(i) == 0 || h2.binHeight(i) == 0 ) {
00141       yval = 0.0;
00142       yerr = 0.0;
00143     } else {
00144       const double b1 = h2.binHeight(i), // subset
00145         b2 = h1.binHeight(i), // super-set
00146         w = b1/b2;
00147       double e1 = pow(h2.binError(i),2);
00148       double e2 = pow(h1.binError(i),2);
00149       // see https://root.cern.ch/root/html/src/TH1.cxx.html#2592:
00150       double w_error = 0;
00151       if(b1 < b2) w_error = sqrt( ((1.-2.*w)*e1*e1 + w*w*e2*e2 )/(b2*b2) ); 
00152       // taking the inverse:
00153       yval = 1/w;
00154       if(w!=0) {
00155         yerr = w_error/pow(w,2);
00156       } else {
00157         yerr = 0;
00158       }
00159     }
00160     IMeasurement* y = point->coordinate(1);
00161     y->setValue(yval);
00162     y->setErrorPlus(yerr/2);
00163     y->setErrorMinus(yerr/2);
00164   }  
00165 }