CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/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.1*GeV);
00021       addProjection(cfs, "CFS");
00022       addProjection(Beam(), "Beam");
00023 
00024       FinalState hfs(-5.5, 5.5, 0.1*GeV);
00025       addProjection(hfs, "HFS");
00026         
00027       _Nevt_after_cuts = 0;
00028         
00029       //eta bins
00030       _netabins=12;
00031       for (int ietabin=0; ietabin <= _netabins; ietabin++){     
00032         _etabins[ietabin]=0.2*ietabin;
00033       }
00034       
00035       
00036         //AK 900 GeV - pt spectra in eta bins
00037         _h_dNch_dpT_900[0] = bookHistogram1D(1, 1, 1);
00038         _h_dNch_dpT_900[1] = bookHistogram1D(1, 1, 2);
00039         _h_dNch_dpT_900[2] = bookHistogram1D(1, 1, 3);
00040         _h_dNch_dpT_900[3] = bookHistogram1D(1, 1, 4);
00041         
00042         _h_dNch_dpT_900[4] = bookHistogram1D(2, 1, 1);
00043         _h_dNch_dpT_900[5] = bookHistogram1D(2, 1, 2);
00044         _h_dNch_dpT_900[6] = bookHistogram1D(2, 1, 3);
00045         _h_dNch_dpT_900[7] = bookHistogram1D(2, 1, 4);
00046         
00047         _h_dNch_dpT_900[8] = bookHistogram1D(3, 1, 1);
00048         _h_dNch_dpT_900[9] = bookHistogram1D(3, 1, 2);
00049         _h_dNch_dpT_900[10] = bookHistogram1D(3, 1, 3);
00050         _h_dNch_dpT_900[11] = bookHistogram1D(3, 1, 4);
00051         
00052         //AK 2360 GeV - pt spectra in eta bins
00053         _h_dNch_dpT_2360[0] = bookHistogram1D(4, 1, 1);
00054         _h_dNch_dpT_2360[1] = bookHistogram1D(4, 1, 2);
00055         _h_dNch_dpT_2360[2] = bookHistogram1D(4, 1, 3);
00056         _h_dNch_dpT_2360[3] = bookHistogram1D(4, 1, 4);
00057         
00058         _h_dNch_dpT_2360[4] = bookHistogram1D(5, 1, 1);
00059         _h_dNch_dpT_2360[5] = bookHistogram1D(5, 1, 2);
00060         _h_dNch_dpT_2360[6] = bookHistogram1D(5, 1, 3);
00061         _h_dNch_dpT_2360[7] = bookHistogram1D(5, 1, 4);
00062         
00063         _h_dNch_dpT_2360[8] = bookHistogram1D(6, 1, 1);
00064         _h_dNch_dpT_2360[9] = bookHistogram1D(6, 1, 2);
00065         _h_dNch_dpT_2360[10] = bookHistogram1D(6, 1, 3);
00066         _h_dNch_dpT_2360[11] = bookHistogram1D(6, 1, 4);
00067         
00068         
00069         //Eta spectra
00070         _h_dNch_dEta_900 = bookHistogram1D(8, 1, 1);
00071         _h_dNch_dEta_2360 = bookHistogram1D(8, 1, 2);
00072         
00073     }
00074 
00075 //AK =====================================================ANALYZE
00076     void analyze(const Event& event) {
00077       const double weight = event.weight();
00078 
00079 // This "trigger" is commented out for now - a HF tower is not defined on particle level
00080 // better: turn off Single Diffraction in the MC
00081 //AK       const FinalState& hadronic = applyProjection<FinalState>(event, "HFS");
00082 //AK       double HFEsumplus = 0.0;
00083 //AK       double HFEsumminus = 0.0;
00084 //AK       foreach (const Particle& p, hadronic.particles()) {
00085 //AK         double Ehad = p.momentum().E();            
00086 //AK         double etahad = p.momentum().eta();
00087 //AK       
00088 //AK         if(etahad < 5.2  && etahad > 3.15 )
00089 //AK            HFEsumplus = HFEsumplus + Ehad;
00090 //AK         
00091 //AK         if(etahad > -5.2  && etahad < -3.15 )
00092 //AK            HFEsumminus = HFEsumminus + Ehad;
00093 //AK         
00094 //AK        }
00095 //AK    if (!(HFEsumplus > 3.0 && HFEsumminus > 3.0)) vetoEvent;
00096 
00097 
00098       //charge particles
00099       const ChargedFinalState& charged = applyProjection<ChargedFinalState>(event, "CFS");
00100       if (charged.particles().size()<1) {
00101         vetoEvent;
00102          
00103       } 
00104       
00105       
00106       _Nevt_after_cuts += weight;
00107  
00108       foreach (const Particle& p, charged.particles()) {
00109         double pT = p.momentum().pT();          
00110         double eta = p.momentum().eta();
00111         
00112          if(fuzzyEquals(sqrtS(), 900, 1E-3)){
00113            _h_dNch_dEta_900->fill(eta, weight);         
00114            for (int ietabin=0; ietabin <= (_netabins-1); ietabin++){    
00115               if (fabs(eta) < _etabins[ietabin+1] && fabs(eta) > _etabins[ietabin]){
00116               _h_dNch_dpT_900[ietabin]->fill(pT, weight);         
00117               }
00118             }
00119          }
00120          
00121          if(fuzzyEquals(sqrtS(), 2360, 1E-3)){
00122             _h_dNch_dEta_2360->fill(eta, weight);               
00123             for (int ietabin=0; ietabin <= (_netabins-1); ietabin++){   
00124                if (fabs(eta) < _etabins[ietabin+1] && fabs(eta) > _etabins[ietabin]){
00125                _h_dNch_dpT_2360[ietabin]->fill(pT, weight);       
00126                }
00127             }
00128          }
00129 
00130       }
00131     }
00132     
00133 //AK =====================================================FINALIZE
00134     void finalize() {
00135         double normfac=1.0/_Nevt_after_cuts;  
00136 
00137         getLog() << Log::INFO << "Number of events after event selection: " << _Nevt_after_cuts << endl;        
00138 
00139         if(fuzzyEquals(sqrtS(), 900, 1E-3)){
00140            for (int ietabin=0; ietabin < _netabins; ietabin++){
00141             scale(_h_dNch_dpT_900[ietabin], normfac/(0.2*2.0)); //AK normalize to events and rapidity-bin
00142            }
00143            scale(_h_dNch_dEta_900, normfac);
00144         }
00145 
00146         if(fuzzyEquals(sqrtS(), 2360, 1E-3)){
00147            for (int ietabin=0; ietabin < _netabins; ietabin++){
00148               scale(_h_dNch_dpT_2360[ietabin], normfac/(0.2*2.0)); //AK normalize to events and rapidity-bin
00149            }
00150            scale(_h_dNch_dEta_2360, normfac);
00151         }
00152         
00153     }
00154 
00155 
00156 //AK =====================================================DECLARATIONS
00157   private:
00158 
00159 
00160     AIDA::IHistogram1D* _h_dNch_dpT_900[12];
00161     AIDA::IHistogram1D* _h_dNch_dpT_2360[12];
00162 
00163     AIDA::IHistogram1D* _h_dNch_dEta_900;
00164     AIDA::IHistogram1D* _h_dNch_dEta_2360;
00165         
00166     int _netabins;
00167     double _Nevt_after_cuts;
00168     double _etabins[13];
00169 
00170 
00171    };
00172 
00173 
00174   // This global object acts as a hook for the plugin system
00175   AnalysisBuilder<CMS_2010_S8547297> plugin_CMS_2010_S8547297;
00176 
00177 }
00178