CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/GeneratorInterface/LHEInterface/src/BranchingRatios.cc

Go to the documentation of this file.
00001 #include <map>
00002 
00003 #include <boost/shared_ptr.hpp>
00004 
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006 
00007 #include "GeneratorInterface/LHEInterface/interface/LHEEvent.h"
00008 #include "GeneratorInterface/LHEInterface/interface/Hadronisation.h"
00009 #include "GeneratorInterface/LHEInterface/interface/BranchingRatios.h"
00010 
00011 namespace lhef {
00012 
00013 void BranchingRatios::reset()
00014 {
00015         cache.clear();
00016 }
00017 
00018 void BranchingRatios::set(int pdgId, bool both, double value)
00019 {
00020         cache[pdgId] = value;
00021         if (both)
00022                 cache[-pdgId] = value;
00023 }
00024 
00025 double BranchingRatios::getFactor(
00026                         const Hadronisation *hadronisation,
00027                         const boost::shared_ptr<LHEEvent> &event) const
00028 {
00029         double factor = 1.0;
00030         const HEPEUP *hepeup = event->getHEPEUP();
00031         for(int i = 0; i < hepeup->NUP; i++) {
00032                 if (hepeup->ISTUP[i] == 1)
00033                         factor *= get(hepeup->IDUP[i], hadronisation);
00034         }
00035         return factor;
00036 }
00037 
00038 double BranchingRatios::get(int pdgId,
00039                             const Hadronisation *hadronisation) const
00040 {
00041         std::map<int, double>::const_iterator pos = cache.find(pdgId);
00042         if (pos == cache.end()) {
00043                 double val = hadronisation->totalBranchingRatio(pdgId);
00044                 if (val <= 0.0)
00045                         val = 1.0;
00046                 if (val < 0.99)
00047                         edm::LogInfo("Generator|LHEInterface")
00048                                 << "Particle with pdgId " << pdgId
00049                                 << " only partly decayed in hadronizer, "
00050                                    "reducing respective event cross-section "
00051                                    "contribution with a factor of "
00052                                 << val << "." << std::endl;
00053 
00054                 cache.insert(std::make_pair(pdgId, val));
00055                 return val;
00056         } else
00057                 return pos->second;
00058 }
00059 
00060 } // namespace lhef