CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes

lhef::JetMatchingMadgraph Class Reference

Inheritance diagram for lhef::JetMatchingMadgraph:
lhef::JetMatching

List of all members.

Public Member Functions

 JetMatchingMadgraph (const edm::ParameterSet &params)
 ~JetMatchingMadgraph ()

Private Member Functions

void beforeHadronisation (const boost::shared_ptr< LHEEvent > &event)
std::set< std::string > capabilities () const
template<typename T >
T getParameter (const std::string &var, const T &defValue=T()) const
void init (const boost::shared_ptr< LHERunInfo > &runInfo)
double match (const HepMC::GenEvent *partonLevel, const HepMC::GenEvent *finalState, bool showeredFinalState)

Static Private Member Functions

template<typename T >
static T parseParameter (const std::string &value)

Private Attributes

bool eventInitialized
bool exclusive
std::map< std::string,
std::string > 
mgParams
bool runInitialized
bool soup

Detailed Description

Definition at line 68 of file JetMatchingMadgraph.cc.


Constructor & Destructor Documentation

JetMatchingMadgraph::JetMatchingMadgraph ( const edm::ParameterSet params)

Definition at line 141 of file JetMatchingMadgraph.cc.

References lhef::MEMAIN::clfact, lhef::MEMAIN::etaclmax, lhef::MEMAIN::etcjet, Exception, exclusive, edm::ParameterSet::getParameter(), lhef::MEMAIN::iexcfile, lhef::MEMAIN::ktsche, lhef::MEMAIN::maxjets, lhef::memain_, lhef::MEMAIN::minjets, mode, lhef::MEMAIN::qcut, lhef::MEMAIN::rclmax, and soup.

                                                                      :
        JetMatching(params),
        runInitialized(false)
{
        std::string mode = params.getParameter<std::string>("mode");
        if (mode == "inclusive") {
                soup = false;
                exclusive = false;
        } else if (mode == "exclusive") {
                soup = false;
                exclusive = true;
        } else if (mode == "auto")
                soup = true;
        else
                throw cms::Exception("Generator|LHEInterface")
                        << "Madgraph jet matching scheme requires \"mode\" "
                           "parameter to be set to either \"inclusive\", "
                           "\"exclusive\" or \"auto\"." << std::endl;

        memain_.etcjet = 0.;
        memain_.rclmax = 0.0;
        memain_.clfact = 0.0;
        memain_.iexcfile = 0;
        memain_.ktsche = 0;
        memain_.etaclmax = params.getParameter<double>("etaclmax");
        memain_.qcut = params.getParameter<double>("qcut");
        memain_.minjets = params.getParameter<int>("minjets");
        memain_.maxjets = params.getParameter<int>("maxjets");
}
JetMatchingMadgraph::~JetMatchingMadgraph ( )

Definition at line 171 of file JetMatchingMadgraph.cc.

{
}

Member Function Documentation

void JetMatchingMadgraph::beforeHadronisation ( const boost::shared_ptr< LHEEvent > &  event) [private, virtual]

Reimplemented from lhef::JetMatching.

Definition at line 244 of file JetMatchingMadgraph.cc.

References indexGen::comments, eventInitialized, Exception, i, lhef::UPPRIV::ickkw, lhef::mgevnt_(), lhef::HEPEUP::NUP, lhef::PYPART::ptpart, lhef::HEPEUP::PUP, lhef::pypart_, runInitialized, mathSSE::sqrt(), and lhef::uppriv_.

{
        if (!runInitialized)
                throw cms::Exception("Generator|LHEInterface")
                        << "Run not initialized in JetMatchingMadgraph"
                        << std::endl;

        if (uppriv_.ickkw) {
                std::vector<std::string> comments = event->getComments();
                if (comments.size() == 1) {
                        std::istringstream ss(comments[0].substr(1));
                        for(int i = 0; i < 1000; i++) {
                                double pt;
                                ss >> pt;
                                if (!ss.good())
                                        break;
                                pypart_.ptpart[i] = pt;
                        }
                } else {
                        edm::LogWarning("Generator|LHEInterface")
                                << "Expected exactly one comment line per "
                                   "event containing MadGraph parton scale "
                                   "information."
                                << std::endl;

                        const HEPEUP *hepeup = event->getHEPEUP();
                        for(int i = 2; i < hepeup->NUP; i++) {
                                double mt2 =
                                        hepeup->PUP[i][0] * hepeup->PUP[i][0] +
                                        hepeup->PUP[i][1] * hepeup->PUP[i][1] +
                                        hepeup->PUP[i][4] * hepeup->PUP[i][4];
                                pypart_.ptpart[i - 2] = std::sqrt(mt2);
                        }
                }
        }

        mgevnt_();
        eventInitialized = true;
}
std::set< std::string > JetMatchingMadgraph::capabilities ( ) const [private, virtual]

Reimplemented from lhef::JetMatching.

Definition at line 175 of file JetMatchingMadgraph.cc.

References query::result.

{
        std::set<std::string> result;
        result.insert("psFinalState");
        result.insert("hepevt");
        result.insert("pythia6");
        return result;
}
template<typename T >
T lhef::JetMatchingMadgraph::getParameter ( const std::string &  var,
const T defValue = T() 
) const [private]

Definition at line 127 of file JetMatchingMadgraph.cc.

References mgParams, and pos.

{
        std::map<std::string, std::string>::const_iterator pos =
                                                        mgParams.find(var);
        if (pos == mgParams.end())
                return defValue;
        return parseParameter<T>(pos->second);
}
void JetMatchingMadgraph::init ( const boost::shared_ptr< LHERunInfo > &  runInfo) [private, virtual]

Reimplemented from lhef::JetMatching.

Definition at line 186 of file JetMatchingMadgraph.cc.

References lhef::UPPRIV::ickkw, geometryCSVtoXML::line, lhef::mginit_(), mgParams, Parameters::parameters, pos, runInitialized, lhef::uppriv_, relativeConstraints::value, and makeHLTPrescaleTable::values.

{
        // read MadGraph run card

        std::map<std::string, std::string> parameters;

        std::vector<std::string> header = runInfo->findHeader("MGRunCard");
        if (header.empty())
                throw cms::Exception("Generator|LHEInterface")
                        << "In order to use MadGraph jet matching, "
                           "the input file has to contain the corresponding "
                           "MadGraph headers." << std::endl;

        mgParams.clear();
        for(std::vector<std::string>::const_iterator iter = header.begin();
            iter != header.end(); ++iter) {
                std::string line = *iter;
                if (line.empty() || line[0] == '#')
                        continue;

                std::string::size_type pos = line.find('!');
                if (pos != std::string::npos)
                        line.resize(pos);

                pos = line.find('=');
                if (pos == std::string::npos)
                        continue;

                std::string var =
                        boost::algorithm::trim_copy(line.substr(pos + 1));
                std::string value = 
                        boost::algorithm::trim_copy(line.substr(0, pos));

                mgParams[var] = value;
        }

        // set variables in common block

        std::vector<Param> params;
        std::vector<Param> values;
        for(std::map<std::string, std::string>::const_iterator iter =
                        mgParams.begin(); iter != mgParams.end(); ++iter) {
                params.push_back(" " + iter->first);
                values.push_back(iter->second);

        }

        // set MG matching parameters

        uppriv_.ickkw = getParameter<int>("ickkw", 0);

        // run Fortran initialization code

        int nparam = params.size();
        mginit_(&nparam, &params.front(), &values.front());
        runInitialized = true;
}
double JetMatchingMadgraph::match ( const HepMC::GenEvent *  partonLevel,
const HepMC::GenEvent *  finalState,
bool  showeredFinalState 
) [private, virtual]

Implements lhef::JetMatching.

Definition at line 285 of file JetMatchingMadgraph.cc.

References eventInitialized, Exception, exclusive, lhef::MEMAEV::iexc, lhef::MEMAIN::maxjets, lhef::memaev_, lhef::memain_, lhef::mgveto_(), lhef::MEMAEV::nljets, runInitialized, and soup.

{
        if (!showeredFinalState)
                throw cms::Exception("Generator|LHEInterface")
                        << "MadGraph matching expected parton shower "
                           "final state." << std::endl;

        if (!runInitialized)
                throw cms::Exception("Generator|LHEInterface")
                        << "Run not initialized in JetMatchingMadgraph"
                        << std::endl;

        if (!eventInitialized)
                throw cms::Exception("Generator|LHEInterface")
                        << "Event not initialized in JetMatchingMadgraph"
                        << std::endl;

        if (soup)
                memaev_.iexc = (memaev_.nljets < memain_.maxjets);
        else
                memaev_.iexc = exclusive;

        int veto = 0;
        mgveto_(&veto);
        eventInitialized = false;

        return veto ? 0.0 : 1.0;
}
bool lhef::JetMatchingMadgraph::parseParameter ( const std::string &  value) [static, private]

Definition at line 97 of file JetMatchingMadgraph.cc.

References query::result.

{
        std::istringstream ss(value);
        T result;
        ss >> result;
        return result;
}

Member Data Documentation

Definition at line 91 of file JetMatchingMadgraph.cc.

Referenced by beforeHadronisation(), and match().

Definition at line 93 of file JetMatchingMadgraph.cc.

Referenced by JetMatchingMadgraph(), and match().

std::map<std::string, std::string> lhef::JetMatchingMadgraph::mgParams [private]

Definition at line 88 of file JetMatchingMadgraph.cc.

Referenced by getParameter(), and init().

Definition at line 90 of file JetMatchingMadgraph.cc.

Referenced by beforeHadronisation(), init(), and match().

Definition at line 92 of file JetMatchingMadgraph.cc.

Referenced by JetMatchingMadgraph(), and match().