CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/GeneratorInterface/RivetInterface/src/CMS_2010_S8547297.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Analysis.hh"
00003 #include "Rivet/RivetAIDA.hh"
00004 #include "Rivet/Projections/ChargedFinalState.hh"
00005 #include "Rivet/Projections/Beam.hh"
00006 
00007 namespace Rivet {
00008 
00009 
00010   class CMS_2010_S8547297 : public Analysis {
00011   public:
00012 
00013     CMS_2010_S8547297() : Analysis("CMS_2010_S8547297") {
00014        setBeams(PROTON, PROTON);
00015        setNeedsCrossSection(false);
00016     }
00017 
00018 //AK =====================================================INIT
00019     void init() {
00020       ChargedFinalState cfs(-2.5, 2.5, 0.0*GeV);
00021       addProjection(cfs, "CFS");
00022       addProjection(Beam(), "Beam");
00023 
00024       _Nevt_after_cuts = 0;
00025       
00026       if(fuzzyEquals(sqrtS(), 900*GeV, 1E-3)){
00027         _h_dNch_dpT[0] = bookHistogram1D(1, 1, 1);
00028         _h_dNch_dpT[1] = bookHistogram1D(1, 1, 2);
00029         _h_dNch_dpT[2] = bookHistogram1D(1, 1, 3);
00030         _h_dNch_dpT[3] = bookHistogram1D(1, 1, 4);
00031 
00032         _h_dNch_dpT[4] = bookHistogram1D(2, 1, 1);
00033         _h_dNch_dpT[5] = bookHistogram1D(2, 1, 2);
00034         _h_dNch_dpT[6] = bookHistogram1D(2, 1, 3);
00035         _h_dNch_dpT[7] = bookHistogram1D(2, 1, 4);
00036 
00037         _h_dNch_dpT[8] = bookHistogram1D(3, 1, 1);
00038         _h_dNch_dpT[9] = bookHistogram1D(3, 1, 2);
00039         _h_dNch_dpT[10] = bookHistogram1D(3, 1, 3);
00040         _h_dNch_dpT[11] = bookHistogram1D(3, 1, 4);
00041 
00042         _h_dNch_dpT_all = bookHistogram1D(7, 1, 1);
00043 
00044         _h_dNch_dEta = bookHistogram1D(8, 1, 1);
00045       } else if (fuzzyEquals(sqrtS(), 2360*GeV, 1E-3)){
00046         _h_dNch_dpT[0] = bookHistogram1D(4, 1, 1);
00047         _h_dNch_dpT[1] = bookHistogram1D(4, 1, 2);
00048         _h_dNch_dpT[2] = bookHistogram1D(4, 1, 3);
00049         _h_dNch_dpT[3] = bookHistogram1D(4, 1, 4);
00050 
00051         _h_dNch_dpT[4] = bookHistogram1D(5, 1, 1);
00052         _h_dNch_dpT[5] = bookHistogram1D(5, 1, 2);
00053         _h_dNch_dpT[6] = bookHistogram1D(5, 1, 3);
00054         _h_dNch_dpT[7] = bookHistogram1D(5, 1, 4);
00055 
00056         _h_dNch_dpT[8] = bookHistogram1D(6, 1, 1);
00057         _h_dNch_dpT[9] = bookHistogram1D(6, 1, 2);
00058         _h_dNch_dpT[10] = bookHistogram1D(6, 1, 3);
00059         _h_dNch_dpT[11] = bookHistogram1D(6, 1, 4);
00060 
00061         _h_dNch_dpT_all = bookHistogram1D(7, 1, 2);
00062 
00063         _h_dNch_dEta = bookHistogram1D(8, 1, 2);
00064       }
00065       return;
00066     }
00067 
00068 //AK =====================================================ANALYZE
00069     void analyze(const Event& event) {
00070 
00071       if (!fuzzyEquals(sqrtS(), 900*GeV, 1E-3) && !fuzzyEquals(sqrtS(), 2360*GeV, 1E-3) ){
00072         return;
00073       }
00074 
00075       const double weight = event.weight();
00076 
00077       //charge particles
00078       const ChargedFinalState& charged = applyProjection<ChargedFinalState>(event, "CFS");
00079       
00080       _Nevt_after_cuts += weight;
00081  
00082       foreach (const Particle& p, charged.particles()) {
00083         const double pT = p.momentum().pT();            
00084         const double eta = p.momentum().eta();
00085         
00086         // The data is actually a duplicated folded distribution.  This should mimic it.
00087         _h_dNch_dEta->fill(eta, 0.5*weight);
00088         _h_dNch_dEta->fill(-eta, 0.5*weight);
00089         if (fabs(eta)<2.4 && pT>0.1) {
00090           if (pT<4.0) {
00091             _h_dNch_dpT_all->fill(pT, weight/pT);
00092             if (pT<2.0) {
00093               int ietabin = fabs(eta)/0.2;
00094               _h_dNch_dpT[ietabin]->fill(pT, weight);
00095             }
00096           }
00097         }
00098       }
00099       return;
00100     }
00101     
00102 //AK =====================================================FINALIZE
00103     void finalize() {
00104 
00105       if (!fuzzyEquals(sqrtS(), 900*GeV, 1E-3) && !fuzzyEquals(sqrtS(), 2360*GeV, 1E-3) ){
00106         return;
00107       }
00108 
00109       const double normfac = 1.0/_Nevt_after_cuts; // Normalizing to unit eta is automatic
00110       // The pT distributions in bins of eta must be normalized to unit eta.  This is a factor of 2
00111       // for the |eta| times 0.2 (eta range).
00112       // The pT distributions over all eta are normalized to unit eta (2.0*2.4) and by 1/2*pi*pT. 
00113       // The 1/pT part is taken care of in the filling.  The 1/2pi is taken care of here.
00114       const double normpT = normfac/(2.0*0.2);
00115       const double normpTall = normfac/(2.0*3.141592654*2.0*2.4);
00116 
00117       for (int ietabin=0; ietabin < 12; ietabin++){
00118         scale(_h_dNch_dpT[ietabin], normpT);
00119       }
00120       scale(_h_dNch_dpT_all, normpTall);
00121       scale(_h_dNch_dEta, normfac);
00122       return;
00123     }
00124 
00125 
00126 //AK =====================================================DECLARATIONS
00127   private:
00128 
00129     AIDA::IHistogram1D* _h_dNch_dpT[12];
00130     AIDA::IHistogram1D* _h_dNch_dpT_all;
00131 
00132     AIDA::IHistogram1D* _h_dNch_dEta;
00133         
00134     double _Nevt_after_cuts;
00135 
00136 
00137    };
00138 
00139 
00140   // This global object acts as a hook for the plugin system
00141   AnalysisBuilder<CMS_2010_S8547297> plugin_CMS_2010_S8547297;
00142 
00143 }
00144