CMS 3D CMS Logo

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

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Analysis.hh"
00003 #include "Rivet/RivetAIDA.hh"
00004 #include "Rivet/Projections/FinalState.hh"
00005 #include "Rivet/Projections/ZFinder.hh"
00006 #include "Rivet/Projections/FinalState.hh"
00007 #include "Rivet/Projections/ChargedFinalState.hh"
00008 #include "Rivet/ParticleName.hh"
00009 
00010 namespace Rivet {
00011 
00012 
00013   class CMS_2012_I1107658 : public Analysis {
00014   public:
00015 
00017     CMS_2012_I1107658()
00018       : Analysis("CMS_2012_I1107658")
00019     {
00021       setNeedsCrossSection(false);
00022     }
00023 
00024     void init() {
00025 
00026        ZFinder zfinder(-MAXRAPIDITY, MAXRAPIDITY, 0.0*GeV, MUON,4.0*GeV, 140.0*GeV, 0.2, false, false);
00027        addProjection(zfinder, "ZFinder");
00028 
00029        ChargedFinalState cfs(-2.0, 2.0, 500*MeV); // For charged particles
00030        addProjection(cfs, "CFS");
00031        
00032       _hist_profile_Nchg_towards_pTmumu = bookProfile1D(1, 1, 1);
00033       _hist_profile_Nchg_transverse_pTmumu = bookProfile1D(2, 1, 1);
00034       _hist_profile_Nchg_away_pTmumu = bookProfile1D(3, 1, 1);
00035       _hist_profile_pTsum_towards_pTmumu = bookProfile1D(4, 1, 1);
00036       _hist_profile_pTsum_transverse_pTmumu = bookProfile1D(5, 1, 1);
00037       _hist_profile_pTsum_away_pTmumu = bookProfile1D(6, 1, 1);
00038       _hist_profile_avgpT_towards_pTmumu = bookDataPointSet(7,1,1); 
00039       _hist_profile_avgpT_transverse_pTmumu = bookDataPointSet(8,1,1);
00040       _hist_profile_avgpT_away_pTmumu = bookDataPointSet(9,1,1);
00041       _hist_profile_Nchg_towards_plus_transverse_Mmumu = bookProfile1D(10, 1, 1);
00042       _hist_profile_pTsum_towards_plus_transverse_Mmumu = bookProfile1D(11, 1, 1);
00043       _hist_profile_avgpT_towards_plus_transverse_Mmumu = bookDataPointSet(12,1,1);
00044       _hist_Nchg_towards_zmass_81_101  = bookHistogram1D(13, 1, 1);
00045       _hist_Nchg_transverse_zmass_81_101  = bookHistogram1D(14, 1, 1);
00046       _hist_Nchg_away_zmass_81_101  = bookHistogram1D(15, 1, 1); 
00047       _hist_pT_towards_zmass_81_101  = bookHistogram1D(16, 1, 1);
00048       _hist_pT_transverse_zmass_81_101  = bookHistogram1D(17, 1, 1);
00049       _hist_pT_away_zmass_81_101  = bookHistogram1D(18, 1, 1);
00050       _hist_Nchg_transverse_zpt_5  = bookHistogram1D(19, 1, 1);
00051       _hist_pT_transverse_zpt_5  = bookHistogram1D(20, 1, 1);
00052     
00053     }
00054 
00055 
00057     void analyze(const Event& event) {
00058        const double weight = event.weight();
00059        const ZFinder& zfinder = applyProjection<ZFinder>(event, "ZFinder");
00060    
00061        if (zfinder.particles().size() != 2) vetoEvent;
00062 
00063        Particle lepton0 = zfinder.particles().at(0);
00064        Particle lepton1 = zfinder.particles().at(1);
00065 
00066        if (lepton0.pdgId() != -lepton1.pdgId()) vetoEvent; 
00067 
00068        double pt0 = lepton0.momentum().pT()/GeV;
00069        double pt1 = lepton1.momentum().pT()/GeV;
00070        double eta0 = lepton0.momentum().eta();
00071        double eta1 = lepton1.momentum().eta();  
00072 
00073        if(pt0 > 20. && pt1 > 20 && fabs(eta1) < 2.4 && fabs(eta0) < 2.4){
00074 
00075         double _Zpt = zfinder.bosons()[0].momentum().pT()/GeV;
00076         double _Zphi = zfinder.bosons()[0].momentum().phi(); 
00077         double _Zmass = zfinder.bosons()[0].momentum().mass()/GeV;
00078 
00079         ParticleVector particles =
00080           applyProjection<ChargedFinalState>(event, "CFS").particlesByPt();
00081 
00082         double _nTowards(0.0), _ptSumTowards(0.0), _nTransverse(0.0), 
00083                _ptSumTransverse(0.0),  _nAway(0.0), _ptSumAway(0.0);
00084 
00085         foreach (const Particle& p, particles) {
00086           if(fabs(p.pdgId()) !=13){
00087             double _dphi = fabs(deltaPhi(_Zphi, p.momentum().phi()));
00088             double _eta = fabs(p.momentum().eta());
00089        
00091             if ( PI/3.0 > _dphi && _eta < 2. ) {
00092                 _nTowards += 1.0;
00093                 _ptSumTowards += p.momentum().perp();
00094                 double _pT = p.momentum().perp();
00095                 if(_Zmass < 101. && _Zmass > 81.)_hist_pT_towards_zmass_81_101->fill(_pT,weight);
00096             }
00097        
00099             if ( PI/3.0 < _dphi && _dphi < 2.*PI/3.0 && _eta < 2. ) {
00100                 _nTransverse += 1.0;
00101                 _ptSumTransverse += p.momentum().perp();
00102                 double _pT = p.momentum().perp();
00103                 if(_Zmass < 101. && _Zmass > 81.)_hist_pT_transverse_zmass_81_101->fill(_pT,weight);
00104                 if(_Zpt < 5.)_hist_pT_transverse_zpt_5->fill(_pT,weight);
00105             }
00106 
00108             if ( 2.*PI/3.0 < _dphi && _eta < 2. ) {
00109                 _nAway += 1.0;
00110                 _ptSumAway += p.momentum().perp(); 
00111                 double _pT = p.momentum().perp();
00112                 if(_Zmass < 101. && _Zmass > 81.)_hist_pT_away_zmass_81_101->fill(_pT,weight);
00113             }
00114  
00115           }// not muons
00116         }//Loop over particles
00117 
00118 
00119         if(_Zmass < 101. && _Zmass > 81.){         
00120           _hist_profile_Nchg_towards_pTmumu->fill(_Zpt/GeV, _nTowards/(((8. * PI)/3.)), weight);
00121           _hist_profile_Nchg_transverse_pTmumu->fill(_Zpt/GeV, _nTransverse/(((8. * PI)/3.)), weight);
00122           _hist_profile_Nchg_away_pTmumu->fill(_Zpt/GeV, _nAway/(((8. * PI)/3.)), weight); 
00123           _hist_profile_pTsum_towards_pTmumu->fill(_Zpt/GeV, _ptSumTowards/(((8. * PI)/3.)), weight);
00124           _hist_profile_pTsum_transverse_pTmumu->fill(_Zpt/GeV, _ptSumTransverse/(((8. * PI)/3.)), weight);
00125           _hist_profile_pTsum_away_pTmumu->fill(_Zpt/GeV, _ptSumAway/(((8. * PI)/3.)), weight);
00126           _hist_Nchg_towards_zmass_81_101->fill(_nTowards,weight);
00127           _hist_Nchg_transverse_zmass_81_101->fill(_nTransverse,weight);
00128           _hist_Nchg_away_zmass_81_101->fill(_nAway,weight);
00129         }//for events around Z resonance, activity as function of pT_mumu  
00130 
00131         if(_Zpt < 5.){
00132           _hist_profile_Nchg_towards_plus_transverse_Mmumu->fill(_Zmass/GeV, (_nTowards + _nTransverse)/(16.*PI/3.),weight);
00133           _hist_profile_pTsum_towards_plus_transverse_Mmumu->fill(_Zmass/GeV, (_ptSumTowards + _ptSumTransverse)/(16.*PI/3.),weight);     
00134           _hist_Nchg_transverse_zpt_5->fill(_nTransverse,weight);         
00135         }//for events with small recoilm activity as function of M_mumu  
00136 
00137       }//cut on leptons
00138 
00139     }
00140 
00141 
00143     void finalize() {
00144 
00145       vector<double> yval_avgpt_towards, yerr_avgpt_towards, yval_avgpt_transverse, 
00146                      yerr_avgpt_transverse, yval_avgpt_away, yerr_avgpt_away, 
00147                      yval_avgpt_tt, yerr_avgpt_tt;
00148     
00149       for (size_t i = 0;  i < 20; ++i) {        
00150         double yval_tmp = _hist_profile_pTsum_towards_pTmumu->binHeight(i) / 
00151                           _hist_profile_Nchg_towards_pTmumu->binHeight(i);
00152         yval_avgpt_towards.push_back(yval_tmp);
00153         
00154         double yerr_tmp = sqrt( _hist_profile_pTsum_towards_pTmumu->binError(i) * _hist_profile_pTsum_towards_pTmumu->binError(i)/
00155                                 (_hist_profile_pTsum_towards_pTmumu->binHeight(i) * _hist_profile_pTsum_towards_pTmumu->binHeight(i)) +
00156                                 _hist_profile_Nchg_towards_pTmumu->binError(i) * _hist_profile_Nchg_towards_pTmumu->binError(i)/
00157                                 (_hist_profile_Nchg_towards_pTmumu->binHeight(i) * _hist_profile_Nchg_towards_pTmumu->binHeight(i))) *
00158                                  yval_tmp;
00159         yerr_avgpt_towards.push_back(yerr_tmp);       
00160        
00161         yval_tmp = _hist_profile_pTsum_transverse_pTmumu->binHeight(i) / _hist_profile_Nchg_transverse_pTmumu->binHeight(i);
00162         yval_avgpt_transverse.push_back(yval_tmp);
00163         
00164         yerr_tmp = sqrt(_hist_profile_pTsum_transverse_pTmumu->binError(i) * _hist_profile_pTsum_transverse_pTmumu->binError(i)/
00165                         (_hist_profile_pTsum_transverse_pTmumu->binHeight(i) * _hist_profile_pTsum_transverse_pTmumu->binHeight(i)) +
00166                         _hist_profile_Nchg_transverse_pTmumu->binError(i) * _hist_profile_Nchg_transverse_pTmumu->binError(i)/
00167                         (_hist_profile_Nchg_transverse_pTmumu->binHeight(i) * _hist_profile_Nchg_transverse_pTmumu->binHeight(i))) * 
00168                         yval_tmp;
00169         yerr_avgpt_transverse.push_back(yerr_tmp);
00170              
00171         yval_tmp = _hist_profile_pTsum_away_pTmumu->binHeight(i) / _hist_profile_Nchg_away_pTmumu->binHeight(i);
00172         yval_avgpt_away.push_back(yval_tmp);
00173         yerr_tmp = sqrt(_hist_profile_pTsum_away_pTmumu->binError(i) * _hist_profile_pTsum_away_pTmumu->binError(i)/
00174                         (_hist_profile_pTsum_away_pTmumu->binHeight(i) * _hist_profile_pTsum_away_pTmumu->binHeight(i)) +
00175                         _hist_profile_Nchg_away_pTmumu->binError(i) * _hist_profile_Nchg_away_pTmumu->binError(i)/
00176                         (_hist_profile_Nchg_away_pTmumu->binHeight(i) * _hist_profile_Nchg_away_pTmumu->binHeight(i))) * 
00177                         yval_tmp;
00178         yerr_avgpt_away.push_back(yerr_tmp); 
00179       }
00180 
00181       for (size_t i = 0;  i < 10; ++i) {
00182         
00183         double yval_tmp = _hist_profile_pTsum_towards_plus_transverse_Mmumu->binHeight(i) / 
00184                           _hist_profile_Nchg_towards_plus_transverse_Mmumu->binHeight(i);
00185         yval_avgpt_tt.push_back(yval_tmp);
00186                   
00187         double yerr_tmp = sqrt(_hist_profile_pTsum_towards_plus_transverse_Mmumu->binError(i) * _hist_profile_pTsum_towards_plus_transverse_Mmumu->binError(i)/
00188                                (_hist_profile_pTsum_towards_plus_transverse_Mmumu->binHeight(i) * _hist_profile_pTsum_towards_plus_transverse_Mmumu->binHeight(i)) + 
00189                                _hist_profile_Nchg_towards_plus_transverse_Mmumu->binError(i) * _hist_profile_Nchg_towards_plus_transverse_Mmumu->binError(i)/
00190                                (_hist_profile_Nchg_towards_plus_transverse_Mmumu->binHeight(i) * _hist_profile_Nchg_towards_plus_transverse_Mmumu->binHeight(i))) * 
00191                                yval_tmp;        
00192         yerr_avgpt_tt.push_back(yerr_tmp);       
00193       }
00194    
00195       _hist_profile_avgpT_towards_pTmumu->setCoordinate(1, yval_avgpt_towards, yerr_avgpt_towards); 
00196       _hist_profile_avgpT_transverse_pTmumu->setCoordinate(1, yval_avgpt_transverse, yerr_avgpt_transverse);
00197       _hist_profile_avgpT_away_pTmumu->setCoordinate(1, yval_avgpt_away, yerr_avgpt_away);
00198       _hist_profile_avgpT_towards_plus_transverse_Mmumu->setCoordinate(1, yval_avgpt_tt, yerr_avgpt_tt);
00199 
00200       scale(_hist_pT_towards_zmass_81_101,1.0/integral(_hist_Nchg_towards_zmass_81_101));
00201       scale(_hist_pT_transverse_zmass_81_101,1.0/integral(_hist_Nchg_transverse_zmass_81_101));
00202       scale(_hist_pT_away_zmass_81_101,1.0/integral(_hist_Nchg_away_zmass_81_101));      
00203       scale(_hist_pT_transverse_zpt_5,1.0/integral(_hist_Nchg_transverse_zpt_5));
00204       scale(_hist_Nchg_towards_zmass_81_101,1.0/integral(_hist_Nchg_towards_zmass_81_101));
00205       scale(_hist_Nchg_transverse_zmass_81_101,1.0/integral(_hist_Nchg_transverse_zmass_81_101));
00206       scale(_hist_Nchg_away_zmass_81_101,1.0/integral(_hist_Nchg_away_zmass_81_101));
00207       scale(_hist_Nchg_transverse_zpt_5,1.0/integral(_hist_Nchg_transverse_zpt_5));
00208 
00209     }
00210 
00211 
00212   private:
00213 
00214     AIDA::IProfile1D *_hist_profile_Nchg_towards_pTmumu;
00215     AIDA::IProfile1D *_hist_profile_Nchg_transverse_pTmumu;
00216     AIDA::IProfile1D *_hist_profile_Nchg_away_pTmumu;
00217     AIDA::IProfile1D *_hist_profile_pTsum_towards_pTmumu;
00218     AIDA::IProfile1D *_hist_profile_pTsum_transverse_pTmumu;
00219     AIDA::IProfile1D *_hist_profile_pTsum_away_pTmumu;
00220     AIDA::IDataPointSet* _hist_profile_avgpT_towards_pTmumu;
00221     AIDA::IDataPointSet* _hist_profile_avgpT_transverse_pTmumu;
00222     AIDA::IDataPointSet* _hist_profile_avgpT_away_pTmumu;
00223     AIDA::IProfile1D *_hist_profile_Nchg_towards_plus_transverse_Mmumu;
00224     AIDA::IProfile1D *_hist_profile_pTsum_towards_plus_transverse_Mmumu;   
00225     AIDA::IDataPointSet*_hist_profile_avgpT_towards_plus_transverse_Mmumu;
00226     AIDA::IHistogram1D *_hist_Nchg_towards_zmass_81_101;
00227     AIDA::IHistogram1D *_hist_Nchg_transverse_zmass_81_101; 
00228     AIDA::IHistogram1D *_hist_Nchg_away_zmass_81_101;
00229 
00230     AIDA::IHistogram1D *_hist_pT_towards_zmass_81_101;
00231     AIDA::IHistogram1D *_hist_pT_transverse_zmass_81_101;
00232     AIDA::IHistogram1D *_hist_pT_away_zmass_81_101;
00233 
00234     AIDA::IHistogram1D *_hist_Nchg_transverse_zpt_5;
00235     AIDA::IHistogram1D *_hist_pT_transverse_zpt_5;
00237 
00238 
00239   };
00240 
00241 
00242 
00243   // This global object acts as a hook for the plugin system
00244   AnalysisBuilder<CMS_2012_I1107658> plugin_CMS_2012_I1107658;
00245 
00246 
00247 }