CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
EmbeddingLHEProducer Class Reference

#include <test/EmbeddingLHEProducer/plugins/EmbeddingLHEProducer.cc>

Inheritance diagram for EmbeddingLHEProducer:
edm::one::EDProducer< edm::BeginRunProducer, edm::EndRunProducer > edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 EmbeddingLHEProducer (const edm::ParameterSet &)
 
 ~EmbeddingLHEProducer () override
 
- Public Member Functions inherited from edm::one::EDProducer< edm::BeginRunProducer, edm::EndRunProducer >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void assign_4vector (TLorentzVector &Lepton, const pat::Muon *muon, std::string FSRmode)
 
void beginJob () override
 
void beginRunProduce (edm::Run &run, edm::EventSetup const &es) override
 
void endJob () override
 
void endRunProduce (edm::Run &, edm::EventSetup const &) override
 
void fill_lhe_from_mumu (TLorentzVector &positiveLepton, TLorentzVector &negativeLepton, lhef::HEPEUP &outlhe, CLHEP::HepRandomEngine *engine)
 
void fill_lhe_with_particle (lhef::HEPEUP &outlhe, TLorentzVector &particle, int pdgid, double spin, double ctau)
 
const reco::Candidatefind_original_muon (const reco::Candidate *muon)
 
LHERunInfoProduct::Header give_slha ()
 
void InitialRecoCorrection (TLorentzVector &positiveLepton, TLorentzVector &negativeLepton)
 
void mirror (TLorentzVector &positiveLepton, TLorentzVector &negativeLepton)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
void rotate180 (TLorentzVector &positiveLepton, TLorentzVector &negativeLepton)
 
void transform_mumu_to_tautau (TLorentzVector &positiveLepton, TLorentzVector &negativeLepton)
 

Private Attributes

const int embeddingParticles [3] {11, 13, 15}
 
std::ofstream file
 
bool InitialRecoCorrection_
 
bool mirror_
 
edm::EDGetTokenT< edm::View< pat::Muon > > muonsCollection_
 
int particleToEmbed_
 
bool rotate180_
 
std::string studyFSRmode_
 
edm::EDGetTokenT< reco::VertexCollectionvertexCollection_
 
bool write_lheout
 

Static Private Attributes

static constexpr double elMass_ = 0.00051
 
static constexpr double muonMass_ = 0.1057
 
static constexpr double tauMass_ = 1.77682
 

Additional Inherited Members

- Public Types inherited from edm::one::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 63 of file EmbeddingLHEProducer.cc.

Constructor & Destructor Documentation

◆ EmbeddingLHEProducer()

EmbeddingLHEProducer::EmbeddingLHEProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 114 of file EmbeddingLHEProducer.cc.

References embeddingParticles, Exception, file, spr::find(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), InitialRecoCorrection_, edm::Service< T >::isAvailable(), mirror_, muonsCollection_, MillePedeFileConverter_cfg::out, particleToEmbed_, rotate180_, AlCaHLTBitMon_QueryRunRegistry::string, studyFSRmode_, pileupReCalc_HLTpaths::trunc, vertexCollection_, and write_lheout.

114  {
115  // register your products
116  produces<LHEEventProduct>();
117  produces<LHERunInfoProduct, edm::Transition::BeginRun>();
118  produces<math::XYZTLorentzVectorD>("vertexPosition");
119 
120  muonsCollection_ = consumes<edm::View<pat::Muon>>(iConfig.getParameter<edm::InputTag>("src"));
121  vertexCollection_ = consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertices"));
122  particleToEmbed_ = iConfig.getParameter<int>("particleToEmbed");
123  mirror_ = iConfig.getParameter<bool>("mirror");
124  InitialRecoCorrection_ = iConfig.getParameter<bool>("InitialRecoCorrection");
125  rotate180_ = iConfig.getParameter<bool>("rotate180");
126  studyFSRmode_ = iConfig.getUntrackedParameter<std::string>("studyFSRmode", "");
127 
128  write_lheout = false;
129  std::string lhe_ouputfile = iConfig.getUntrackedParameter<std::string>("lhe_outputfilename", "");
130  if (!lhe_ouputfile.empty()) {
131  write_lheout = true;
132  file.open(lhe_ouputfile, std::fstream::out | std::fstream::trunc);
133  }
134 
135  // check if particle can be embedded
136  if (std::find(std::begin(embeddingParticles), std::end(embeddingParticles), particleToEmbed_) ==
137  std::end(embeddingParticles)) {
138  throw cms::Exception("Configuration") << "The given particle to embed is not in the list of allowed particles.";
139  }
140 
142  if (!rng.isAvailable()) {
143  throw cms::Exception("Configuration") << "The EmbeddingLHEProducer requires the RandomNumberGeneratorService\n"
144  "which is not present in the configuration file. \n"
145  "You must add the service\n"
146  "in the configuration file or remove the modules that require it.";
147  }
148 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< edm::View< pat::Muon > > muonsCollection_
edm::EDGetTokenT< reco::VertexCollection > vertexCollection_
bool isAvailable() const
Definition: Service.h:40

◆ ~EmbeddingLHEProducer()

EmbeddingLHEProducer::~EmbeddingLHEProducer ( )
override

Definition at line 150 of file EmbeddingLHEProducer.cc.

150 {}

Member Function Documentation

◆ assign_4vector()

void EmbeddingLHEProducer::assign_4vector ( TLorentzVector &  Lepton,
const pat::Muon muon,
std::string  FSRmode 
)
private

Definition at line 352 of file EmbeddingLHEProducer.cc.

References find_original_muon(), reco::Candidate::p4(), and reco::LeafCandidate::p4().

Referenced by produce().

352  {
353  if ("afterFSR" == FSRmode && muon->genParticle() != nullptr) {
354  const reco::GenParticle *afterFSRMuon = muon->genParticle();
355  Lepton.SetPxPyPzE(
356  afterFSRMuon->p4().px(), afterFSRMuon->p4().py(), afterFSRMuon->p4().pz(), afterFSRMuon->p4().e());
357  } else if ("beforeFSR" == FSRmode && muon->genParticle() != nullptr) {
358  const reco::Candidate *beforeFSRMuon = find_original_muon(muon->genParticle());
359  Lepton.SetPxPyPzE(
360  beforeFSRMuon->p4().px(), beforeFSRMuon->p4().py(), beforeFSRMuon->p4().pz(), beforeFSRMuon->p4().e());
361  } else {
362  Lepton.SetPxPyPzE(muon->p4().px(), muon->p4().py(), muon->p4().pz(), muon->p4().e());
363  }
364  return;
365 }
const LorentzVector & p4() const final
four-momentum Lorentz vector
const reco::Candidate * find_original_muon(const reco::Candidate *muon)
Definition: Lepton.py:1
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector

◆ beginJob()

void EmbeddingLHEProducer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDProducerBase.

Definition at line 212 of file EmbeddingLHEProducer.cc.

212 {}

◆ beginRunProduce()

void EmbeddingLHEProducer::beginRunProduce ( edm::Run run,
edm::EventSetup const &  es 
)
overrideprivate

Definition at line 219 of file EmbeddingLHEProducer.cc.

References filterCSVwithJSON::copy, file, give_slha(), lhef::HEPRUP::IDWTUP, lhe2HepMCConverter_cff::LHERunInfoProduct, lhef::HEPRUP::LPRUP, eostools::move(), lhef::HEPRUP::resize(), writedatasetfile::run, submitPVValidationJobs::runInfo, write_lheout, lhef::HEPRUP::XERRUP, lhef::HEPRUP::XMAXUP, and lhef::HEPRUP::XSECUP.

219  {
220  // fill HEPRUP common block and store in edm::Run
221  lhef::HEPRUP heprup;
222 
223  // set number of processes: 1 for Z to tau tau
224  heprup.resize(1);
225 
226  // master switch for event weight iterpretation (same as in officially produced DYJets LHE files)
227  heprup.IDWTUP = 3;
228 
229  // Information for first process (Z to tau tau), for now only placeholder:
230  heprup.XSECUP[0] = 1.;
231  heprup.XERRUP[0] = 0;
232  heprup.XMAXUP[0] = 1;
233  heprup.LPRUP[0] = 1;
234 
235  std::unique_ptr<LHERunInfoProduct> runInfo(new LHERunInfoProduct(heprup));
236  runInfo->addHeader(give_slha());
237 
238  if (write_lheout)
239  std::copy(runInfo->begin(), runInfo->end(), std::ostream_iterator<std::string>(file));
240  run.put(std::move(runInfo));
241 }
void resize(int nrup)
Definition: LesHouches.h:44
LHERunInfoProduct::Header give_slha()
std::vector< double > XERRUP
Definition: LesHouches.h:118
std::vector< double > XMAXUP
Definition: LesHouches.h:123
std::vector< double > XSECUP
Definition: LesHouches.h:112
def move(src, dest)
Definition: eostools.py:511
std::vector< int > LPRUP
Definition: LesHouches.h:128

◆ endJob()

void EmbeddingLHEProducer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDProducerBase.

Definition at line 215 of file EmbeddingLHEProducer.cc.

215 {}

◆ endRunProduce()

void EmbeddingLHEProducer::endRunProduce ( edm::Run run,
edm::EventSetup const &  es 
)
overrideprivate

Definition at line 243 of file EmbeddingLHEProducer.cc.

References LHERunInfoProduct::endOfFile(), file, and write_lheout.

243  {
244  if (write_lheout) {
246  file.close();
247  }
248 }
static const std::string & endOfFile()

◆ fill_lhe_from_mumu()

void EmbeddingLHEProducer::fill_lhe_from_mumu ( TLorentzVector &  positiveLepton,
TLorentzVector &  negativeLepton,
lhef::HEPEUP outlhe,
CLHEP::HepRandomEngine *  engine 
)
private

Definition at line 250 of file EmbeddingLHEProducer.cc.

References ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), fill_lhe_with_particle(), particleToEmbed_, and beamSpotPI::Z.

Referenced by produce().

253  {
254  TLorentzVector Z = positiveLepton + negativeLepton;
255  int leptonPDGID = particleToEmbed_;
256 
257  static constexpr double tau_ctau0 = 8.71100e-02; // mm (for Pythia)
258  double tau_ctau_p = tau_ctau0 * CLHEP::RandExponential::shoot(engine);
259  double tau_ctau_n = tau_ctau0 * CLHEP::RandExponential::shoot(engine);
260 
261  fill_lhe_with_particle(outlhe, Z, 23, 9.0, 0);
262  fill_lhe_with_particle(outlhe, positiveLepton, -leptonPDGID, 1.0, tau_ctau_p);
263  fill_lhe_with_particle(outlhe, negativeLepton, leptonPDGID, -1.0, tau_ctau_n);
264 
265  return;
266 }
void fill_lhe_with_particle(lhef::HEPEUP &outlhe, TLorentzVector &particle, int pdgid, double spin, double ctau)

◆ fill_lhe_with_particle()

void EmbeddingLHEProducer::fill_lhe_with_particle ( lhef::HEPEUP outlhe,
TLorentzVector &  particle,
int  pdgid,
double  spin,
double  ctau 
)
private

Definition at line 268 of file EmbeddingLHEProducer.cc.

References funct::abs(), embeddingParticles, spr::find(), lhef::HEPEUP::ICOLUP, lhef::HEPEUP::IDUP, lhef::HEPEUP::ISTUP, lhef::HEPEUP::MOTHUP, lhef::HEPEUP::NUP, EgammaValidation_cff::pdgid, lhef::HEPEUP::PUP, lhef::HEPEUP::resize(), lhef::HEPEUP::SPINUP, and lhef::HEPEUP::VTIMUP.

Referenced by fill_lhe_from_mumu().

269  {
270  // Pay attention to different index conventions:
271  // 'particleindex' follows usual C++ index conventions starting at 0 for a list.
272  // 'motherindex' follows the LHE index conventions: 0 is for 'not defined', so the listing starts at 1.
273  // That means: LHE index 1 == C++ index 0.
274  int particleindex = outlhe.NUP;
275  outlhe.resize(outlhe.NUP + 1);
276 
277  outlhe.PUP[particleindex][0] = particle.Px();
278  outlhe.PUP[particleindex][1] = particle.Py();
279  outlhe.PUP[particleindex][2] = particle.Pz();
280  outlhe.PUP[particleindex][3] = particle.E();
281  outlhe.PUP[particleindex][4] = particle.M();
282  outlhe.IDUP[particleindex] = pdgid;
283  outlhe.SPINUP[particleindex] = spin;
284  outlhe.VTIMUP[particleindex] = ctau;
285 
286  outlhe.ICOLUP[particleindex].first = 0;
287  outlhe.ICOLUP[particleindex].second = 0;
288 
289  if (std::abs(pdgid) == 23) {
290  outlhe.MOTHUP[particleindex].first = 0; // No Mother
291  outlhe.MOTHUP[particleindex].second = 0;
292  outlhe.ISTUP[particleindex] = 2; // status
293  }
294 
295  if (std::find(std::begin(embeddingParticles), std::end(embeddingParticles), std::abs(pdgid)) !=
296  std::end(embeddingParticles)) {
297  outlhe.MOTHUP[particleindex].first = 1; // Mother is the Z (first partile)
298  outlhe.MOTHUP[particleindex].second = 1; // Mother is the Z (first partile)
299 
300  outlhe.ISTUP[particleindex] = 1; // status
301  }
302 
303  return;
304 }
std::vector< std::pair< int, int > > ICOLUP
Definition: LesHouches.h:240
std::vector< double > VTIMUP
Definition: LesHouches.h:252
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
void resize(int nup)
Definition: LesHouches.h:161
std::vector< FiveVector > PUP
Definition: LesHouches.h:246
std::vector< double > SPINUP
Definition: LesHouches.h:259
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< int > ISTUP
Definition: LesHouches.h:228
std::vector< std::pair< int, int > > MOTHUP
Definition: LesHouches.h:234
std::vector< int > IDUP
Definition: LesHouches.h:223

◆ fillDescriptions()

void EmbeddingLHEProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 562 of file EmbeddingLHEProducer.cc.

References edm::ConfigurationDescriptions::addDefault(), and submitPVResolutionJobs::desc.

562  {
563  // The following says we do not know what parameters are allowed so do no validation
564  // Please change this to state exactly what you do use, even if it is no parameters
566  desc.setUnknown();
567  descriptions.addDefault(desc);
568 }
void addDefault(ParameterSetDescription const &psetDescription)

◆ find_original_muon()

const reco::Candidate * EmbeddingLHEProducer::find_original_muon ( const reco::Candidate muon)
private

Definition at line 367 of file EmbeddingLHEProducer.cc.

References HLT_2024v14_cff::muon.

Referenced by assign_4vector().

367  {
368  if (muon->mother(0) == nullptr)
369  return muon;
370  if (muon->pdgId() == muon->mother(0)->pdgId())
371  return find_original_muon(muon->mother(0));
372  else
373  return muon;
374 }
const reco::Candidate * find_original_muon(const reco::Candidate *muon)

◆ give_slha()

LHERunInfoProduct::Header EmbeddingLHEProducer::give_slha ( )
private

Definition at line 466 of file EmbeddingLHEProducer.cc.

References LHERunInfoProduct::Header::addLine().

Referenced by beginRunProduce().

466  {
467  LHERunInfoProduct::Header slhah("slha");
468 
469  slhah.addLine("######################################################################\n");
470  slhah.addLine("## PARAM_CARD AUTOMATICALY GENERATED BY MG5 FOLLOWING UFO MODEL ####\n");
471  slhah.addLine("######################################################################\n");
472  slhah.addLine("## ##\n");
473  slhah.addLine("## Width set on Auto will be computed following the information ##\n");
474  slhah.addLine("## present in the decay.py files of the model. ##\n");
475  slhah.addLine("## See arXiv:1402.1178 for more details. ##\n");
476  slhah.addLine("## ##\n");
477  slhah.addLine("######################################################################\n");
478  slhah.addLine("\n");
479  slhah.addLine("###################################\n");
480  slhah.addLine("## INFORMATION FOR MASS\n");
481  slhah.addLine("###################################\n");
482  slhah.addLine("Block mass \n");
483  slhah.addLine(" 6 1.730000e+02 # MT \n");
484  slhah.addLine(" 15 1.777000e+00 # MTA \n");
485  slhah.addLine(" 23 9.118800e+01 # MZ \n");
486  slhah.addLine(" 25 1.250000e+02 # MH \n");
487  slhah.addLine("## Dependent parameters, given by model restrictions.\n");
488  slhah.addLine("## Those values should be edited following the \n");
489  slhah.addLine("## analytical expression. MG5 ignores those values \n");
490  slhah.addLine("## but they are important for interfacing the output of MG5\n");
491  slhah.addLine("## to external program such as Pythia.\n");
492  slhah.addLine(" 1 0.000000 # d : 0.0 \n");
493  slhah.addLine(" 2 0.000000 # u : 0.0 \n");
494  slhah.addLine(" 3 0.000000 # s : 0.0 \n");
495  slhah.addLine(" 4 0.000000 # c : 0.0 \n");
496  slhah.addLine(" 5 0.000000 # b : 0.0 \n");
497  slhah.addLine(" 11 0.000000 # e- : 0.0 \n");
498  slhah.addLine(" 12 0.000000 # ve : 0.0 \n");
499  slhah.addLine(" 13 0.000000 # mu- : 0.0 \n");
500  slhah.addLine(" 14 0.000000 # vm : 0.0 \n");
501  slhah.addLine(" 16 0.000000 # vt : 0.0 \n");
502  slhah.addLine(" 21 0.000000 # g : 0.0 \n");
503  slhah.addLine(" 22 0.000000 # a : 0.0 \n");
504  slhah.addLine(
505  " 24 80.419002 # w+ : cmath.sqrt(MZ__exp__2/2. + cmath.sqrt(MZ__exp__4/4. - "
506  "(aEW*cmath.pi*MZ__exp__2)/(Gf*sqrt__2))) \n");
507  slhah.addLine("\n");
508  slhah.addLine("###################################\n");
509  slhah.addLine("## INFORMATION FOR SMINPUTS\n");
510  slhah.addLine("###################################\n");
511  slhah.addLine("Block sminputs \n");
512  slhah.addLine(" 1 1.325070e+02 # aEWM1 \n");
513  slhah.addLine(" 2 1.166390e-05 # Gf \n");
514  slhah.addLine(" 3 1.180000e-01 # aS \n");
515  slhah.addLine("\n");
516  slhah.addLine("###################################\n");
517  slhah.addLine("## INFORMATION FOR WOLFENSTEIN\n");
518  slhah.addLine("###################################\n");
519  slhah.addLine("Block wolfenstein \n");
520  slhah.addLine(" 1 2.253000e-01 # lamWS \n");
521  slhah.addLine(" 2 8.080000e-01 # AWS \n");
522  slhah.addLine(" 3 1.320000e-01 # rhoWS \n");
523  slhah.addLine(" 4 3.410000e-01 # etaWS \n");
524  slhah.addLine("\n");
525  slhah.addLine("###################################\n");
526  slhah.addLine("## INFORMATION FOR YUKAWA\n");
527  slhah.addLine("###################################\n");
528  slhah.addLine("Block yukawa \n");
529  slhah.addLine(" 6 1.730000e+02 # ymt \n");
530  slhah.addLine(" 15 1.777000e+00 # ymtau \n");
531  slhah.addLine("\n");
532  slhah.addLine("###################################\n");
533  slhah.addLine("## INFORMATION FOR DECAY\n");
534  slhah.addLine("###################################\n");
535  slhah.addLine("DECAY 6 1.491500e+00 # WT \n");
536  slhah.addLine("DECAY 15 2.270000e-12 # WTau \n");
537  slhah.addLine("DECAY 23 2.441404e+00 # WZ \n");
538  slhah.addLine("DECAY 24 2.047600e+00 # WW \n");
539  slhah.addLine("DECAY 25 6.382339e-03 # WH \n");
540  slhah.addLine("## Dependent parameters, given by model restrictions.\n");
541  slhah.addLine("## Those values should be edited following the \n");
542  slhah.addLine("## analytical expression. MG5 ignores those values \n");
543  slhah.addLine("## but they are important for interfacing the output of MG5\n");
544  slhah.addLine("## to external program such as Pythia.\n");
545  slhah.addLine("DECAY 1 0.000000 # d : 0.0 \n");
546  slhah.addLine("DECAY 2 0.000000 # u : 0.0 \n");
547  slhah.addLine("DECAY 3 0.000000 # s : 0.0 \n");
548  slhah.addLine("DECAY 4 0.000000 # c : 0.0 \n");
549  slhah.addLine("DECAY 5 0.000000 # b : 0.0 \n");
550  slhah.addLine("DECAY 11 0.000000 # e- : 0.0 \n");
551  slhah.addLine("DECAY 12 0.000000 # ve : 0.0 \n");
552  slhah.addLine("DECAY 13 0.000000 # mu- : 0.0 \n");
553  slhah.addLine("DECAY 14 0.000000 # vm : 0.0 \n");
554  slhah.addLine("DECAY 16 0.000000 # vt : 0.0 \n");
555  slhah.addLine("DECAY 21 0.000000 # g : 0.0 \n");
556  slhah.addLine("DECAY 22 0.000000 # a : 0.0\n");
557 
558  return slhah;
559 }

◆ InitialRecoCorrection()

void EmbeddingLHEProducer::InitialRecoCorrection ( TLorentzVector &  positiveLepton,
TLorentzVector &  negativeLepton 
)
private

Definition at line 406 of file EmbeddingLHEProducer.cc.

References ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), JetChargeProducer_cfi::exp, InitialRecoCorrection_, muonMass_, funct::pow(), mathSSE::sqrt(), and beamSpotPI::Z.

Referenced by produce().

406  {
408  return;
409  edm::LogInfo("TauEmbedding") << "Applying initial reconstruction correction";
410  TLorentzVector Z = positiveLepton + negativeLepton;
411  edm::LogInfo("TauEmbedding") << "MuMinus before. Pt: " << negativeLepton.Pt() << " Mass: " << negativeLepton.M();
412  float diLeptonMass = (positiveLepton + negativeLepton).M();
413  if (diLeptonMass > 60. && diLeptonMass < 122.) {
414  static constexpr float zmass = 91.1876;
415  float correction_deviation =
416  5.; // to ensure only a correction that drops corresponding to a Gaussian with mean zmass and std. dev. 5 GeV
417  double EmbeddingCorrection =
418  1.138; // value derived by function fitting to fold embedded mass spectrum back to original selection when using mu -> mu embedding
419  EmbeddingCorrection /=
420  (EmbeddingCorrection -
421  (EmbeddingCorrection - 1.) * exp(-pow((diLeptonMass - zmass), 2.) / (2. * pow(correction_deviation, 2.))));
422  EmbeddingCorrection = ((diLeptonMass + (EmbeddingCorrection - 1.) * zmass) / (diLeptonMass * EmbeddingCorrection));
423  double correctedpositiveLeptonEnergy =
424  std::sqrt((pow(muonMass_, 2) / pow(EmbeddingCorrection, 2)) + pow(positiveLepton.Px(), 2) +
425  pow(positiveLepton.Py(), 2) + pow(positiveLepton.Pz(), 2));
426  double correctednegativeLeptonEnergy =
427  std::sqrt((pow(muonMass_, 2) / pow(EmbeddingCorrection, 2)) + pow(negativeLepton.Px(), 2) +
428  pow(negativeLepton.Py(), 2) + pow(negativeLepton.Pz(), 2));
429  positiveLepton.SetE(correctedpositiveLeptonEnergy);
430  negativeLepton.SetE(correctednegativeLeptonEnergy);
431  positiveLepton *= EmbeddingCorrection;
432  negativeLepton *= EmbeddingCorrection;
433  edm::LogInfo("TauEmbedding") << "MuMinus after. Pt: " << negativeLepton.Pt() << " Mass: " << negativeLepton.M();
434  }
435  return;
436 }
T sqrt(T t)
Definition: SSEVec.h:23
Log< level::Info, false > LogInfo
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
static constexpr double muonMass_

◆ mirror()

void EmbeddingLHEProducer::mirror ( TLorentzVector &  positiveLepton,
TLorentzVector &  negativeLepton 
)
private

Definition at line 438 of file EmbeddingLHEProducer.cc.

References EcalCondDBWriter_cfi::beam, mirror_, and beamSpotPI::Z.

Referenced by produce().

438  {
439  if (!mirror_)
440  return;
441  edm::LogInfo("TauEmbedding") << "Applying mirroring";
442  TLorentzVector Z = positiveLepton + negativeLepton;
443 
444  edm::LogInfo("TauEmbedding") << "MuMinus before. Pt: " << negativeLepton.Pt() << " Eta: " << negativeLepton.Eta()
445  << " Phi: " << negativeLepton.Phi() << " Mass: " << negativeLepton.M();
446 
447  TVector3 Z3 = Z.Vect();
448  TVector3 positiveLepton3 = positiveLepton.Vect();
449  TVector3 negativeLepton3 = negativeLepton.Vect();
450 
451  TVector3 beam(0., 0., 1.);
452  TVector3 perpToZandBeam = Z3.Cross(beam).Unit();
453 
454  positiveLepton3 -= 2 * positiveLepton3.Dot(perpToZandBeam) * perpToZandBeam;
455  negativeLepton3 -= 2 * negativeLepton3.Dot(perpToZandBeam) * perpToZandBeam;
456 
457  positiveLepton.SetVect(positiveLepton3);
458  negativeLepton.SetVect(negativeLepton3);
459 
460  edm::LogInfo("TauEmbedding") << "MuMinus after. Pt: " << negativeLepton.Pt() << " Eta: " << negativeLepton.Eta()
461  << " Phi: " << negativeLepton.Phi() << " Mass: " << negativeLepton.M();
462 
463  return;
464 }
Log< level::Info, false > LogInfo

◆ produce()

void EmbeddingLHEProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::one::EDProducerBase.

Definition at line 157 of file EmbeddingLHEProducer.cc.

References lhef::HEPEUP::AQCDUP, lhef::HEPEUP::AQEDUP, assign_4vector(), edm::View< T >::begin(), filterCSVwithJSON::copy, edm::View< T >::end(), file, fill_lhe_from_mumu(), edm::RandomNumberGenerator::getEngine(), lhef::HEPEUP::IDPRUP, iEvent, InitialRecoCorrection(), lhe2HepMCConverter_cff::LHEEventProduct, mirror(), eostools::move(), HLT_2024v14_cff::muon, muonsCollection_, rotate180(), lhef::HEPEUP::SCALUP, studyFSRmode_, transform_mumu_to_tautau(), vertexCollection_, write_lheout, and lhef::HEPEUP::XWGTUP.

157  {
158  using namespace edm;
159 
161  CLHEP::HepRandomEngine *engine = &rng->getEngine(iEvent.streamID());
162 
164  iEvent.getByToken(muonsCollection_, muonHandle);
165  edm::View<pat::Muon> coll_muons = *muonHandle;
166 
167  Handle<std::vector<reco::Vertex>> coll_vertices;
168  iEvent.getByToken(vertexCollection_, coll_vertices);
169 
170  TLorentzVector positiveLepton, negativeLepton;
171  bool mu_plus_found = false;
172  bool mu_minus_found = false;
173  lhef::HEPEUP hepeup;
174  hepeup.IDPRUP = 0;
175  hepeup.XWGTUP = 1;
176  hepeup.SCALUP = -1;
177  hepeup.AQEDUP = -1;
178  hepeup.AQCDUP = -1;
179  // Assuming Pt-Order
180  for (edm::View<pat::Muon>::const_iterator muon = coll_muons.begin(); muon != coll_muons.end(); ++muon) {
181  if (muon->charge() == 1 && !mu_plus_found) {
182  assign_4vector(positiveLepton, &(*muon), studyFSRmode_);
183  mu_plus_found = true;
184  } else if (muon->charge() == -1 && !mu_minus_found) {
185  assign_4vector(negativeLepton, &(*muon), studyFSRmode_);
186  mu_minus_found = true;
187  } else if (mu_minus_found && mu_plus_found)
188  break;
189  }
191  positiveLepton,
192  negativeLepton); // corrects Z mass peak to take into account smearing happening due to first muon reconstruction in the selection step
193  mirror(positiveLepton, negativeLepton); // if no mirror, function does nothing.
194  rotate180(positiveLepton, negativeLepton); // if no rotate180, function does nothing
195  transform_mumu_to_tautau(positiveLepton, negativeLepton); // if MuonEmbedding, function does nothing.
196  fill_lhe_from_mumu(positiveLepton, negativeLepton, hepeup, engine);
197 
198  double originalXWGTUP_ = 1.;
199  std::unique_ptr<LHEEventProduct> product(new LHEEventProduct(hepeup, originalXWGTUP_));
200 
201  if (write_lheout)
202  std::copy(product->begin(), product->end(), std::ostream_iterator<std::string>(file));
203 
204  iEvent.put(std::move(product));
205  // Saving vertex position
206  std::unique_ptr<math::XYZTLorentzVectorD> vertex_position(
207  new math::XYZTLorentzVectorD(coll_vertices->at(0).x(), coll_vertices->at(0).y(), coll_vertices->at(0).z(), 0.0));
208  iEvent.put(std::move(vertex_position), "vertexPosition");
209 }
void mirror(TLorentzVector &positiveLepton, TLorentzVector &negativeLepton)
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:14
void InitialRecoCorrection(TLorentzVector &positiveLepton, TLorentzVector &negativeLepton)
void transform_mumu_to_tautau(TLorentzVector &positiveLepton, TLorentzVector &negativeLepton)
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
int iEvent
Definition: GenABIO.cc:224
void assign_4vector(TLorentzVector &Lepton, const pat::Muon *muon, std::string FSRmode)
double AQCDUP
Definition: LesHouches.h:218
void rotate180(TLorentzVector &positiveLepton, TLorentzVector &negativeLepton)
edm::EDGetTokenT< edm::View< pat::Muon > > muonsCollection_
HLT enums.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:88
edm::EDGetTokenT< reco::VertexCollection > vertexCollection_
double AQEDUP
Definition: LesHouches.h:213
void fill_lhe_from_mumu(TLorentzVector &positiveLepton, TLorentzVector &negativeLepton, lhef::HEPEUP &outlhe, CLHEP::HepRandomEngine *engine)
const_iterator begin() const
double XWGTUP
Definition: LesHouches.h:194
const_iterator end() const
def move(src, dest)
Definition: eostools.py:511
double SCALUP
Definition: LesHouches.h:208

◆ rotate180()

void EmbeddingLHEProducer::rotate180 ( TLorentzVector &  positiveLepton,
TLorentzVector &  negativeLepton 
)
private

Definition at line 376 of file EmbeddingLHEProducer.cc.

References rotate180_, and beamSpotPI::Z.

Referenced by produce().

376  {
377  if (!rotate180_)
378  return;
379  edm::LogInfo("TauEmbedding") << "Applying 180<C2><B0> rotation";
380  // By construction, the 3-momenta of mu-, mu+ and Z are in one plane.
381  // That means, one vector for perpendicular projection can be used for both leptons.
382  TLorentzVector Z = positiveLepton + negativeLepton;
383 
384  edm::LogInfo("TauEmbedding") << "MuMinus before. Pt: " << negativeLepton.Pt() << " Eta: " << negativeLepton.Eta()
385  << " Phi: " << negativeLepton.Phi() << " Mass: " << negativeLepton.M();
386 
387  TVector3 Z3 = Z.Vect();
388  TVector3 positiveLepton3 = positiveLepton.Vect();
389  TVector3 negativeLepton3 = negativeLepton.Vect();
390 
391  TVector3 p3_perp = positiveLepton3 - positiveLepton3.Dot(Z3) / Z3.Dot(Z3) * Z3;
392  p3_perp = p3_perp.Unit();
393 
394  positiveLepton3 -= 2 * positiveLepton3.Dot(p3_perp) * p3_perp;
395  negativeLepton3 -= 2 * negativeLepton3.Dot(p3_perp) * p3_perp;
396 
397  positiveLepton.SetVect(positiveLepton3);
398  negativeLepton.SetVect(negativeLepton3);
399 
400  edm::LogInfo("TauEmbedding") << "MuMinus after. Pt: " << negativeLepton.Pt() << " Eta: " << negativeLepton.Eta()
401  << " Phi: " << negativeLepton.Phi() << " Mass: " << negativeLepton.M();
402 
403  return;
404 }
Log< level::Info, false > LogInfo

◆ transform_mumu_to_tautau()

void EmbeddingLHEProducer::transform_mumu_to_tautau ( TLorentzVector &  positiveLepton,
TLorentzVector &  negativeLepton 
)
private

Definition at line 306 of file EmbeddingLHEProducer.cc.

References elMass_, particleToEmbed_, l1tEGammaCrystalsEmulatorProducer_cfi::scale, mathSSE::sqrt(), tauMass_, and beamSpotPI::Z.

Referenced by produce().

306  {
307  // No corrections applied for muon embedding
308  double lep_mass;
309  if (particleToEmbed_ == 11) {
310  lep_mass = elMass_;
311  } else if (particleToEmbed_ == 15) {
312  lep_mass = tauMass_;
313  } else {
314  return;
315  }
316 
317  TLorentzVector Z = positiveLepton + negativeLepton;
318 
319  TVector3 boost_from_Z_to_LAB = Z.BoostVector();
320  TVector3 boost_from_LAB_to_Z = -Z.BoostVector();
321  // Boosting the two leptons to Z restframe, then both are back to back. This means, same 3-momentum squared
322  positiveLepton.Boost(boost_from_LAB_to_Z);
323  negativeLepton.Boost(boost_from_LAB_to_Z);
324 
325  // Energy of tau = 0.5*Z-mass
326  double lep_mass_squared = lep_mass * lep_mass;
327  double lep_energy_squared = 0.25 * Z.M2();
328  double lep_3momentum_squared = lep_energy_squared - lep_mass_squared;
329  if (lep_3momentum_squared < 0) {
330  edm::LogWarning("TauEmbedding") << "3-Momentum squared is negative";
331  return;
332  }
333 
334  // Computing scale, applying it on the 3-momenta and building new 4 momenta of the taus
335  double scale = std::sqrt(lep_3momentum_squared / positiveLepton.Vect().Mag2());
336  positiveLepton.SetPxPyPzE(scale * positiveLepton.Px(),
337  scale * positiveLepton.Py(),
338  scale * positiveLepton.Pz(),
339  std::sqrt(lep_energy_squared));
340  negativeLepton.SetPxPyPzE(scale * negativeLepton.Px(),
341  scale * negativeLepton.Py(),
342  scale * negativeLepton.Pz(),
343  std::sqrt(lep_energy_squared));
344 
345  // Boosting the new taus back to LAB frame
346  positiveLepton.Boost(boost_from_Z_to_LAB);
347  negativeLepton.Boost(boost_from_Z_to_LAB);
348 
349  return;
350 }
T sqrt(T t)
Definition: SSEVec.h:23
static constexpr double tauMass_
static constexpr double elMass_
Log< level::Warning, false > LogWarning

Member Data Documentation

◆ elMass_

constexpr double EmbeddingLHEProducer::elMass_ = 0.00051
staticprivate

Definition at line 99 of file EmbeddingLHEProducer.cc.

Referenced by transform_mumu_to_tautau().

◆ embeddingParticles

const int EmbeddingLHEProducer::embeddingParticles[3] {11, 13, 15}
private

Definition at line 100 of file EmbeddingLHEProducer.cc.

Referenced by EmbeddingLHEProducer(), and fill_lhe_with_particle().

◆ file

std::ofstream EmbeddingLHEProducer::file
private

◆ InitialRecoCorrection_

bool EmbeddingLHEProducer::InitialRecoCorrection_
private

Definition at line 96 of file EmbeddingLHEProducer.cc.

Referenced by EmbeddingLHEProducer(), and InitialRecoCorrection().

◆ mirror_

bool EmbeddingLHEProducer::mirror_
private

Definition at line 96 of file EmbeddingLHEProducer.cc.

Referenced by EmbeddingLHEProducer(), and mirror().

◆ muonMass_

constexpr double EmbeddingLHEProducer::muonMass_ = 0.1057
staticprivate

Definition at line 98 of file EmbeddingLHEProducer.cc.

Referenced by InitialRecoCorrection().

◆ muonsCollection_

edm::EDGetTokenT<edm::View<pat::Muon> > EmbeddingLHEProducer::muonsCollection_
private

Definition at line 93 of file EmbeddingLHEProducer.cc.

Referenced by EmbeddingLHEProducer(), and produce().

◆ particleToEmbed_

int EmbeddingLHEProducer::particleToEmbed_
private

◆ rotate180_

bool EmbeddingLHEProducer::rotate180_
private

Definition at line 96 of file EmbeddingLHEProducer.cc.

Referenced by EmbeddingLHEProducer(), and rotate180().

◆ studyFSRmode_

std::string EmbeddingLHEProducer::studyFSRmode_
private

Definition at line 108 of file EmbeddingLHEProducer.cc.

Referenced by EmbeddingLHEProducer(), and produce().

◆ tauMass_

constexpr double EmbeddingLHEProducer::tauMass_ = 1.77682
staticprivate

Definition at line 97 of file EmbeddingLHEProducer.cc.

Referenced by transform_mumu_to_tautau().

◆ vertexCollection_

edm::EDGetTokenT<reco::VertexCollection> EmbeddingLHEProducer::vertexCollection_
private

Definition at line 94 of file EmbeddingLHEProducer.cc.

Referenced by EmbeddingLHEProducer(), and produce().

◆ write_lheout

bool EmbeddingLHEProducer::write_lheout
private