CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/GeneratorInterface/RivetInterface/src/CMS_2012_I1193338.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/FinalState.hh"
00006 
00007 namespace Rivet {
00008 
00009 
00010   class CMS_2012_I1193338 : public Analysis {
00011   public:
00012 
00013     CMS_2012_I1193338()
00014       : Analysis("CMS_2012_I1193338")
00015     {    }
00016 
00017   public:
00018 
00019     void init() {
00020 
00021       addProjection(ChargedFinalState(-2.4, 2.4, 0.2*GeV), "CFS");
00022       addProjection(FinalState(),"FS");
00023 
00024       _hist_sigma = bookHistogram1D(1, 1, 1);
00025         
00026     }
00027 
00028     void analyze(const Event& event) {
00029 
00030     const double weight = event.weight();
00031 
00032     const ChargedFinalState& cfs = applyProjection<ChargedFinalState>(event, "CFS");
00033     if (cfs.size() > 1) {_hist_sigma->fill(1.5, weight);}
00034     if (cfs.size() > 2) {_hist_sigma->fill(2.5, weight);}
00035     if (cfs.size() > 3) {_hist_sigma->fill(3.5, weight);}
00036 
00037     const FinalState& fs = applyProjection<FinalState>(event, "FS");
00038     if (fs.size() < 2) vetoEvent; // need at least two particles to calculate gaps
00039 
00040     // Calculate gap sizes and midpoints
00041     const ParticleVector particlesByEta = fs.particlesByEta(); // sorted from minus to plus
00042     const size_t num_particles = particlesByEta.size();
00043 
00044     vector<double> gaps;
00045     vector<double> midpoints;
00046     for (size_t ip = 1; ip < num_particles; ++ip) {
00047       const Particle& p1 = particlesByEta[ip-1];
00048       const Particle& p2 = particlesByEta[ip];
00049       const double gap = p2.momentum().eta() - p1.momentum().eta();
00050       const double mid = (p2.momentum().eta() + p1.momentum().eta()) / 2.;
00051       assert(gap >= 0);
00052       gaps.push_back(gap);
00053       midpoints.push_back(mid);
00054     }
00055 
00056     // Find the midpoint of the largest gap to separate X and Y systems
00057     int imid = std::distance(gaps.begin(), max_element(gaps.begin(), gaps.end()));
00058     double gapcenter = midpoints[imid];
00059 
00060     FourMomentum MxFourVector(0.,0.,0.,0.);
00061     FourMomentum MyFourVector(0.,0.,0.,0.);
00062 
00063     foreach(const Particle& p, fs.particlesByEta()) {
00064         if (p.momentum().eta() > gapcenter) {
00065                 MxFourVector += p.momentum();
00066         } else {
00067                 MyFourVector += p.momentum();
00068         }
00069     }
00070 
00071     double Mx2 = MxFourVector.mass2();
00072     double My2 = MyFourVector.mass2();
00073 
00074     const double M2 = (Mx2 > My2 ? Mx2 : My2);
00075     const double xi = M2/(sqrtS()/GeV * sqrtS()/GeV);
00076 
00077     if (xi < 5*10e-6) vetoEvent;
00078 
00079     _hist_sigma->fill(0.5, weight);
00080 
00081     }
00082 
00083     void finalize() {
00084 
00085       scale(_hist_sigma, crossSection()/millibarn/sumOfWeights());
00086 
00087     }
00088 
00089   private:
00090 
00091     AIDA::IHistogram1D *_hist_sigma;
00092 
00093   };
00094 
00095 
00096   DECLARE_RIVET_PLUGIN(CMS_2012_I1193338);
00097 
00098 }