H1_1995_S3167097.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Analysis.hh"
00003 #include "Rivet/RivetAIDA.hh"
00004 #include "Rivet/Projections/FinalStateHCM.hh"
00005 #include "Rivet/Projections/CentralEtHCM.hh"
00006 
00007 namespace Rivet {
00008 
00009 
00010   /// @brief Measures energy flow in DIS? To be checked!
00011   /// @todo Check this analysis!
00012   /// @author Leif Lonnblad
00013   class H1_1995_S3167097 : public Analysis {
00014   public:
00015 
00016     /// Constructor
00017     H1_1995_S3167097() : Analysis("H1_1995_S3167097")
00018     {
00019       setBeams(ELECTRON, PROTON);
00020     }
00021  
00022  
00023     /// @name Analysis methods
00024     //@{
00025 
00026     void init() {
00027       const DISKinematics& diskin = addProjection(DISKinematics(), "Kinematics");
00028       const FinalStateHCM& fshcm = addProjection(FinalStateHCM(diskin), "FS");
00029       addProjection(CentralEtHCM(fshcm), "Y1HCM");
00030 
00031       _hEtFlow = vector<AIDA::IHistogram1D *>(_nbin);
00032       _hEtFlowStat = vector<AIDA::IHistogram1D *>(_nbin);
00033       _nev = vector<double>(_nbin);
00034       /// @todo Automate this sort of thing so that the analysis code is more readable.
00035       for (size_t i = 0; i < _nbin; ++i) {
00036         string istr(1, char('1' + i));
00037         _hEtFlow[i] = bookHistogram1D(istr, _nb, _xmin, _xmax);
00038         _hEtFlowStat[i] = bookHistogram1D(istr, _nb, _xmin, _xmax);
00039       }
00040       _hAvEt = bookHistogram1D("21tmp", _nbin, 1.0, 10.0);
00041       _hAvX  = bookHistogram1D("22tmp", _nbin, 1.0, 10.0);
00042       _hAvQ2 = bookHistogram1D("23tmp", _nbin, 1.0, 10.0);
00043       _hN    = bookHistogram1D("24", _nbin, 1.0, 10.0);
00044     }
00045  
00046  
00047     /// Calculate the bin number from the DISKinematics projection
00048     int _getbin(const DISKinematics& dk) {
00049       if ( dk.Q2() > 5.0*GeV2 && dk.Q2() <= 10.0*GeV2 ) {
00050         if ( dk.x() > 0.0001 && dk.x() <= 0.0002 )
00051           return 0;
00052         else if ( dk.x() > 0.0002 && dk.x() <= 0.0005 && dk.Q2() > 6.0*GeV2 )
00053           return 1;
00054       }
00055       else if ( dk.Q2() > 10.0*GeV2 && dk.Q2() <= 20.0*GeV2 ){
00056         if ( dk.x() > 0.0002 && dk.x() <= 0.0005 )
00057           return 2;
00058         else if ( dk.x() > 0.0005 && dk.x() <= 0.0008 )
00059           return 3;
00060         else if ( dk.x() > 0.0008 && dk.x() <= 0.0015 )
00061           return 4;
00062         else if ( dk.x() > 0.0015 && dk.x() <= 0.0040 )
00063           return 5;
00064       }
00065       else if ( dk.Q2() > 20.0*GeV2 && dk.Q2() <= 50.0*GeV2 ){
00066         if ( dk.x() > 0.0005 && dk.x() <= 0.0014 )
00067           return 6;
00068         else if ( dk.x() > 0.0014 && dk.x() <= 0.0030 )
00069           return 7;
00070         else if ( dk.x() > 0.0030 && dk.x() <= 0.0100 )
00071           return 8;
00072       }
00073       return -1;
00074     }
00075  
00076  
00077     void analyze(const Event& event) {
00078       const FinalStateHCM& fs = applyProjection<FinalStateHCM>(event, "FS");
00079       const DISKinematics& dk = applyProjection<DISKinematics>(event, "Kinematics");
00080       const CentralEtHCM y1 = applyProjection<CentralEtHCM>(event, "Y1HCM");
00081    
00082       const int ibin = _getbin(dk);
00083       if (ibin < 0) vetoEvent;
00084       const double weight = event.weight();
00085    
00086       for (size_t i = 0, N = fs.particles().size(); i < N; ++i) {
00087         const double rap = fs.particles()[i].momentum().rapidity();
00088         const double et = fs.particles()[i].momentum().Et();
00089         _hEtFlow[ibin]->fill(rap, weight * et/GeV);
00090         _hEtFlowStat[ibin]->fill(rap, weight * et/GeV);
00091       }
00092    
00093       _nev[ibin] += weight;
00094       _hAvEt->fill(ibin + 1.5, weight * y1.sumEt()/GeV);
00095       _hAvX->fill(ibin + 1.5, weight * dk.x());
00096       _hAvQ2->fill(ibin + 1.5, weight * dk.Q2()/GeV2);
00097       _hN->fill(ibin + 1.5, weight);
00098     }
00099  
00100  
00101     void finalize() {
00102       for (size_t ibin = 0; ibin < _nbin; ++ibin) {
00103         _hEtFlow[ibin]->scale(1.0/(_nev[ibin]*double(_nb)/(_xmax-_xmin)));
00104         _hEtFlowStat[ibin]->scale(1.0/(_nev[ibin]*double(_nb)/(_xmax-_xmin)));
00105       }
00106    
00107       /// @todo Automate this sort of thing so that the analysis code is more readable.
00108       AIDA::IDataPointSet* h = 0;
00109       h = histogramFactory().divide("/H1_1995_S3167097/21", *_hAvEt, *_hN);
00110       h->setTitle(_hAvEt->title());
00111       histogramFactory().destroy(_hAvEt);
00112    
00113       h = histogramFactory().divide("/H1_1995_S3167097/22", *_hAvX, *_hN);
00114       h->setTitle(_hAvX->title());
00115       histogramFactory().destroy(_hAvX);
00116    
00117       h = histogramFactory().divide("/H1_1995_S3167097/23", *_hAvQ2, *_hN);
00118       h->setTitle(_hAvQ2->title());
00119       histogramFactory().destroy(_hAvQ2);
00120     }
00121  
00122     //@}
00123 
00124  
00125   private:
00126 
00127     /// Some integer constants used.
00128     /// @todo Remove statics!
00129     static const size_t _nb = 24, _nbin = 9;
00130  
00131     /// Some double constants used.
00132     /// @todo Remove statics!
00133     static const double _xmin, _xmax;
00134 
00135     /// Histograms for the \f$ E_T \f$ flows
00136     vector<AIDA::IHistogram1D*> _hEtFlow, _hEtFlowStat;
00137 
00138     /// Histograms for averages in different kinematical bins.
00139     AIDA::IHistogram1D *_hAvEt, *_hAvX, *_hAvQ2, *_hN;
00140 
00141     /// Helper vector;
00142     vector<double> _nev;
00143   };
00144 
00145 
00146   // Init statics
00147   const double H1_1995_S3167097::_xmin = -6.0;
00148   const double H1_1995_S3167097::_xmax = 6.0;
00149 
00150 
00151   // This global object acts as a hook for the plugin system
00152   AnalysisBuilder<H1_1995_S3167097> plugin_H1_1995_S3167097;
00153 
00154 }