CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
lhef::JetMatchingMadgraph Class Reference
Inheritance diagram for lhef::JetMatchingMadgraph:
lhef::JetMatching

Public Member Functions

 JetMatchingMadgraph (const edm::ParameterSet &params)
 
template<>
std::string parseParameter (const std::string &value)
 
template<>
bool parseParameter (const std::string &value_)
 
template<>
std::string parseParameter (const std::string &value)
 
template<>
bool parseParameter (const std::string &value_)
 
 ~JetMatchingMadgraph ()
 
- Public Member Functions inherited from lhef::JetMatching
const std::vector
< JetPartonMatch > & 
getMatchSummary () const
 
 JetMatching (const edm::ParameterSet &params)
 
virtual ~JetMatching ()
 

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
 

Additional Inherited Members

- Public Types inherited from lhef::JetMatching
typedef
edmplugin::PluginFactory
< JetMatching *(const
edm::ParameterSet &)> 
Factory
 
- Static Public Member Functions inherited from lhef::JetMatching
static std::auto_ptr< JetMatchingcreate (const edm::ParameterSet &params)
 
- Protected Attributes inherited from lhef::JetMatching
std::vector< JetPartonMatchmatchSummary
 

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, edm::hlt::Exception, exclusive, edm::ParameterSet::getParameter(), lhef::MEMAIN::iexcfile, lhef::MEMAIN::ktsche, lhef::MEMAIN::maxjets, lhef::memain_, lhef::MEMAIN::minjets, alignBH_cfg::mode, lhef::MEMAIN::qcut, lhef::MEMAIN::rclmax, and soup.

141  :
142  JetMatching(params),
143  runInitialized(false)
144 {
145  std::string mode = params.getParameter<std::string>("mode");
146  if (mode == "inclusive") {
147  soup = false;
148  exclusive = false;
149  } else if (mode == "exclusive") {
150  soup = false;
151  exclusive = true;
152  } else if (mode == "auto")
153  soup = true;
154  else
155  throw cms::Exception("Generator|LHEInterface")
156  << "Madgraph jet matching scheme requires \"mode\" "
157  "parameter to be set to either \"inclusive\", "
158  "\"exclusive\" or \"auto\"." << std::endl;
159 
160  memain_.etcjet = 0.;
161  memain_.rclmax = 0.0;
162  memain_.clfact = 0.0;
163  memain_.iexcfile = 0;
164  memain_.ktsche = 0;
165  memain_.etaclmax = params.getParameter<double>("etaclmax");
166  memain_.qcut = params.getParameter<double>("qcut");
167  memain_.minjets = params.getParameter<int>("minjets");
168  memain_.maxjets = params.getParameter<int>("maxjets");
169 }
T getParameter(std::string const &) const
struct lhef::MEMAIN memain_
JetMatching(const edm::ParameterSet &params)
Definition: JetMatching.cc:21
JetMatchingMadgraph::~JetMatchingMadgraph ( )

Definition at line 171 of file JetMatchingMadgraph.cc.

172 {
173 }

Member Function Documentation

void JetMatchingMadgraph::beforeHadronisation ( const boost::shared_ptr< LHEEvent > &  event)
privatevirtual

Reimplemented from lhef::JetMatching.

Definition at line 244 of file JetMatchingMadgraph.cc.

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

246 {
247  if (!runInitialized)
248  throw cms::Exception("Generator|LHEInterface")
249  << "Run not initialized in JetMatchingMadgraph"
250  << std::endl;
251 
252  if (uppriv_.ickkw) {
253  std::vector<std::string> comments = event->getComments();
254  if (comments.size() == 1) {
255  std::istringstream ss(comments[0].substr(1));
256  for(int i = 0; i < 1000; i++) {
257  double pt;
258  ss >> pt;
259  if (!ss.good())
260  break;
261  pypart_.ptpart[i] = pt;
262  }
263  } else {
264  edm::LogWarning("Generator|LHEInterface")
265  << "Expected exactly one comment line per "
266  "event containing MadGraph parton scale "
267  "information."
268  << std::endl;
269 
270  const HEPEUP *hepeup = event->getHEPEUP();
271  for(int i = 2; i < hepeup->NUP; i++) {
272  double mt2 =
273  hepeup->PUP[i][0] * hepeup->PUP[i][0] +
274  hepeup->PUP[i][1] * hepeup->PUP[i][1] +
275  hepeup->PUP[i][4] * hepeup->PUP[i][4];
276  pypart_.ptpart[i - 2] = std::sqrt(mt2);
277  }
278  }
279  }
280 
281  mgevnt_();
282  eventInitialized = true;
283 }
int i
Definition: DBlmapReader.cc:9
struct lhef::UPPRIV uppriv_
void mgevnt_(void)
struct lhef::PYPART pypart_
T sqrt(T t)
Definition: SSEVec.h:46
std::vector< FiveVector > PUP
Definition: LesHouches.h:248
double ptpart[1000]
std::set< std::string > JetMatchingMadgraph::capabilities ( ) const
privatevirtual

Reimplemented from lhef::JetMatching.

Definition at line 175 of file JetMatchingMadgraph.cc.

References query::result.

176 {
177  std::set<std::string> result;
178  result.insert("psFinalState");
179  result.insert("hepevt");
180  result.insert("pythia6");
181  return result;
182 }
tuple result
Definition: query.py:137
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.

129 {
130  std::map<std::string, std::string>::const_iterator pos =
131  mgParams.find(var);
132  if (pos == mgParams.end())
133  return defValue;
134  return parseParameter<T>(pos->second);
135 }
std::map< std::string, std::string > mgParams
void JetMatchingMadgraph::init ( const boost::shared_ptr< LHERunInfo > &  runInfo)
privatevirtual

Reimplemented from lhef::JetMatching.

Definition at line 186 of file JetMatchingMadgraph.cc.

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

187 {
188  // read MadGraph run card
189 
190  std::map<std::string, std::string> parameters;
191 
192  std::vector<std::string> header = runInfo->findHeader("MGRunCard");
193  if (header.empty())
194  throw cms::Exception("Generator|LHEInterface")
195  << "In order to use MadGraph jet matching, "
196  "the input file has to contain the corresponding "
197  "MadGraph headers." << std::endl;
198 
199  mgParams.clear();
200  for(std::vector<std::string>::const_iterator iter = header.begin();
201  iter != header.end(); ++iter) {
202  std::string line = *iter;
203  if (line.empty() || line[0] == '#')
204  continue;
205 
206  std::string::size_type pos = line.find('!');
207  if (pos != std::string::npos)
208  line.resize(pos);
209 
210  pos = line.find('=');
211  if (pos == std::string::npos)
212  continue;
213 
214  std::string var =
215  boost::algorithm::trim_copy(line.substr(pos + 1));
216  std::string value =
217  boost::algorithm::trim_copy(line.substr(0, pos));
218 
219  mgParams[var] = value;
220  }
221 
222  // set variables in common block
223 
224  std::vector<Param> params;
225  std::vector<Param> values;
226  for(std::map<std::string, std::string>::const_iterator iter =
227  mgParams.begin(); iter != mgParams.end(); ++iter) {
228  params.push_back(" " + iter->first);
229  values.push_back(iter->second);
230 
231  }
232 
233  // set MG matching parameters
234 
235  uppriv_.ickkw = getParameter<int>("ickkw", 0);
236 
237  // run Fortran initialization code
238 
239  int nparam = params.size();
240  mginit_(&nparam, &params.front(), &values.front());
241  runInitialized = true;
242 }
dictionary parameters
Definition: Parameters.py:2
struct lhef::UPPRIV uppriv_
uint16_t size_type
void mginit_(int *npara, Param *params, Param *values)
std::map< std::string, std::string > mgParams
double JetMatchingMadgraph::match ( const HepMC::GenEvent *  partonLevel,
const HepMC::GenEvent *  finalState,
bool  showeredFinalState 
)
privatevirtual

Implements lhef::JetMatching.

Definition at line 285 of file JetMatchingMadgraph.cc.

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

288 {
289  if (!showeredFinalState)
290  throw cms::Exception("Generator|LHEInterface")
291  << "MadGraph matching expected parton shower "
292  "final state." << std::endl;
293 
294  if (!runInitialized)
295  throw cms::Exception("Generator|LHEInterface")
296  << "Run not initialized in JetMatchingMadgraph"
297  << std::endl;
298 
299  if (!eventInitialized)
300  throw cms::Exception("Generator|LHEInterface")
301  << "Event not initialized in JetMatchingMadgraph"
302  << std::endl;
303 
304  if (soup)
306  else
308 
309  int veto = 0;
310  mgveto_(&veto);
311  eventInitialized = false;
312 
313  return veto ? 0.0 : 1.0;
314 }
struct lhef::MEMAEV memaev_
struct lhef::MEMAIN memain_
void mgveto_(int *veto)
template<typename T >
T lhef::JetMatchingMadgraph::parseParameter ( const std::string &  value)
staticprivate

Definition at line 97 of file JetMatchingMadgraph.cc.

References query::result.

98 {
99  std::istringstream ss(value);
100  T result;
101  ss >> result;
102  return result;
103 }
tuple result
Definition: query.py:137
long double T
template<>
std::string lhef::JetMatchingMadgraph::parseParameter ( const std::string &  value)

Definition at line 86 of file JetMatchingMadgraph.cc.

References query::result.

87 {
88  std::string result;
89  if (!result.empty() && result[0] == '\'')
90  result = result.substr(1);
91  if (!result.empty() && result[result.length() - 1] == '\'')
92  result.resize(result.length() - 1);
93  return result;
94 }
tuple result
Definition: query.py:137
template<>
bool lhef::JetMatchingMadgraph::parseParameter ( const std::string &  value_)

Definition at line 97 of file JetMatchingMadgraph.cc.

References create_public_pileup_plots::transform, and relativeConstraints::value.

98 {
99  std::string value(value_);
100  std::transform(value.begin(), value.end(),
101  value.begin(), (int(*)(int))std::toupper);
102  return value == "T" || value == "Y" || value=="True" ||
103  value == "1" || value == ".TRUE.";
104 }
template<>
std::string lhef::JetMatchingMadgraph::parseParameter ( const std::string &  value)

Definition at line 106 of file JetMatchingMadgraph.cc.

References query::result.

107 {
108  std::string result;
109  if (!result.empty() && result[0] == '\'')
110  result = result.substr(1);
111  if (!result.empty() && result[result.length() - 1] == '\'')
112  result.resize(result.length() - 1);
113  return result;
114 }
tuple result
Definition: query.py:137
template<>
bool lhef::JetMatchingMadgraph::parseParameter ( const std::string &  value_)

Definition at line 117 of file JetMatchingMadgraph.cc.

References create_public_pileup_plots::transform, and relativeConstraints::value.

118 {
119  std::string value(value_);
120  std::transform(value.begin(), value.end(),
121  value.begin(), (int(*)(int))std::toupper);
122  return value == "T" || value == "Y" ||
123  value == "1" || value == ".TRUE.";
124 }

Member Data Documentation

bool lhef::JetMatchingMadgraph::eventInitialized
private

Definition at line 91 of file JetMatchingMadgraph.cc.

Referenced by beforeHadronisation(), and match().

bool lhef::JetMatchingMadgraph::exclusive
private

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().

bool lhef::JetMatchingMadgraph::runInitialized
private

Definition at line 90 of file JetMatchingMadgraph.cc.

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

bool lhef::JetMatchingMadgraph::soup
private

Definition at line 92 of file JetMatchingMadgraph.cc.

Referenced by JetMatchingMadgraph(), and match().