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 Types | Private Attributes | Static Private Attributes
GenMuonRadiationAlgorithm Class Reference

#include <GenMuonRadiationAlgorithm.h>

Public Member Functions

reco::Candidate::LorentzVector compFSR (const reco::Candidate::LorentzVector &, int, const reco::Candidate::LorentzVector &, int &)
 
 GenMuonRadiationAlgorithm (const edm::ParameterSet &)
 
 ~GenMuonRadiationAlgorithm ()
 

Private Types

enum  { kPYTHIA, kPHOTOS }
 

Private Attributes

double beamEnergy_
 
int mode_
 
gen::PhotosInterfacephotos_
 
myPythia6ServiceWithCallbackpythia_
 
int verbosity_
 

Static Private Attributes

static bool photos_isInitialized_ = false
 
static bool pythia_isInitialized_ = false
 

Detailed Description

Auxiliary class to correct for muon –> muon + photon final state radiation (FSR) in selected Z –> mu+ mu- events. The FSR is estimated on event-by-event basis via a Monte Carlo technique: for each reconstructed muon, PHOTOS is used to obtain a random amount of radiated photon energy. The radiated photon energy is then added to the energy of the reconstructed muon and the energy of generator level tau leptons is set to the sum.

NOTE: FSR increases with the energy of the muon. So, in principle the energy of muon + photon (energy of muon before FSR), not the energy of the reconstructed muon (energy of muon after FSR) would need to be used as input to PHOTOS. As the amount of radiated photon energy is typically small (< 1 GeV on average), taking the energy of the reconstructed muon is a good approximation.

Author
Christian Veelken, LLR
Version
Revision:
1.6
Id:
GenMuonRadiationAlgorithm.h,v 1.6 2013/01/27 13:53:44 veelken Exp

Definition at line 34 of file GenMuonRadiationAlgorithm.h.

Member Enumeration Documentation

anonymous enum
private

Constructor & Destructor Documentation

GenMuonRadiationAlgorithm::GenMuonRadiationAlgorithm ( const edm::ParameterSet cfg)
explicit

Definition at line 164 of file GenMuonRadiationAlgorithm.cc.

References decayRandomEngine, edm::hlt::Exception, edm::ParameterSet::exists(), edm::RandomNumberGenerator::getEngine(), edm::ParameterSet::getParameter(), edm::Service< T >::isAvailable(), kPHOTOS, kPYTHIA, mode_, photos_, pythia_, AlCaHLTBitMon_QueryRunRegistry::string, and verbosity_.

165  : beamEnergy_(cfg.getParameter<double>("beamEnergy")),
166  photos_(0),
167  pythia_(0)
168 {
170  if ( !rng.isAvailable() )
171  throw cms::Exception("Configuration")
172  << "The RandomNumberProducer module requires the RandomNumberGeneratorService\n"
173  << "which appears to be absent. Please add that service to your configuration\n"
174  << "or remove the modules that require it.\n";
175 
176  // this is a global variable defined in GeneratorInterface/ExternalDecays/src/ExternalDecayDriver.cc
177  decayRandomEngine = &rng->getEngine();
178 
179  std::string mode_string = cfg.getParameter<std::string>("mode");
180  if ( mode_string == "pythia" ) mode_ = kPYTHIA;
181  else if ( mode_string == "photos" ) mode_ = kPHOTOS;
182  else throw cms::Exception("Configuration")
183  << " Invalid Configuration Parameter 'mode' = " << mode_string << " !!\n";
184 
185  if ( mode_ == kPYTHIA ) pythia_ = new myPythia6ServiceWithCallback(cfg);
186  if ( mode_ == kPHOTOS ) photos_ = new gen::PhotosInterface(cfg.getParameter<edm::ParameterSet>("PhotosOptions"));
187 
188  verbosity_ = ( cfg.exists("verbosity") ) ?
189  cfg.getParameter<int>("verbosity") : 0;
190 }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
bool isAvailable() const
Definition: Service.h:46
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...
myPythia6ServiceWithCallback * pythia_
CLHEP::HepRandomEngine * decayRandomEngine
GenMuonRadiationAlgorithm::~GenMuonRadiationAlgorithm ( )

Definition at line 192 of file GenMuonRadiationAlgorithm.cc.

References photos_, and pythia_.

193 {
194  delete photos_;
195  call_pystat(1);
196  delete pythia_;
197 }
myPythia6ServiceWithCallback * pythia_

Member Function Documentation

reco::Candidate::LorentzVector GenMuonRadiationAlgorithm::compFSR ( const reco::Candidate::LorentzVector muonP4,
int  muonCharge,
const reco::Candidate::LorentzVector otherP4,
int &  errorFlag 
)

Definition at line 234 of file GenMuonRadiationAlgorithm.cc.

References gen::PhotosInterface::apply(), beamEnergy_, call_pyedit(), gen::call_pygive(), gen::call_pylist(), conv, gather_cfg::cout, configurableAnalysis::GenParticle, gen::PhotosInterface::init(), kPHOTOS, kPYTHIA, mode_, photos_, photos_isInitialized_, protonMass, pythia_, pythia_isInitialized_, repairBarcodes(), myPythia6ServiceWithCallback::setEvent(), gen::Pythia6Service::setGeneralParams(), mathSSE::sqrt(), Clusterizer1DCommons::square(), and verbosity_.

Referenced by GenMuonRadCorrAnalyzer::analyze(), and ParticleReplacerZtautau::produce().

236 {
237  if ( verbosity_ ) {
238  std::cout << "<GenMuonRadiationAlgorithm::compMuonFSR>:" << std::endl;
239  std::cout << " muon: En = " << muonP4.E() << ", Pt = " << muonP4.pt() << ", eta = " << muonP4.eta() << ", phi = " << muonP4.phi() << ", charge = " << muonCharge << std::endl;
240  std::cout << " other: En = " << otherP4.E() << ", Pt = " << otherP4.pt() << ", eta = " << otherP4.eta() << ", phi = " << otherP4.phi() << std::endl;
241  }
242 
243  reco::Candidate::LorentzVector muonP4_limited = getP4_limited(muonP4, muonP4.mass());
244  int muonPdgId = -13*muonCharge;
245  reco::Candidate::LorentzVector otherP4_limited = getP4_limited(otherP4, otherP4.mass());
246  int otherPdgId = +13*muonCharge;
247  reco::Candidate::LorentzVector zP4 = muonP4_limited + otherP4_limited;
248  int zPdgId = 23;
249  if ( verbosity_ ) {
250  std::cout << "muon(limited): En = " << muonP4_limited.E() << ", Pt = " << muonP4_limited.pt() << ", eta = " << muonP4_limited.eta() << ", phi = " << muonP4_limited.phi() << std::endl;
251  std::cout << "other: En = " << otherP4_limited.E() << ", Pt = " << otherP4_limited.pt() << ", eta = " << otherP4_limited.eta() << ", phi = " << otherP4_limited.phi() << std::endl;
252  std::cout << "Z: En = " << zP4.E() << ", Pt = " << zP4.pt() << ", eta = " << zP4.eta() << ", phi = " << zP4.phi() << std::endl;
253  }
254 
255  HepMC::GenEvent* genEvt_beforeFSR = new HepMC::GenEvent();
256  HepMC::GenVertex* genVtx_in = new HepMC::GenVertex(HepMC::FourVector(0.,0.,0.,0.));
257  double protonEn = beamEnergy_;
258  double protonPz = sqrt(square(protonEn) - square(protonMass));
259  genVtx_in->add_particle_in(new HepMC::GenParticle(HepMC::FourVector(0., 0., +protonPz, protonEn), 2212, 3));
260  genVtx_in->add_particle_in(new HepMC::GenParticle(HepMC::FourVector(0., 0., -protonPz, protonEn), 2212, 3));
261  genEvt_beforeFSR->add_vertex(genVtx_in);
262  reco::Candidate::LorentzVector ppP4_scattered(-zP4.px(), -zP4.py(), -zP4.pz(), 2.*beamEnergy_ - zP4.E());
263  double protonEn_rf = 0.5*ppP4_scattered.mass();
264  double protonP_rf = sqrt(square(protonEn_rf) - square(protonMass));
265  reco::Candidate::LorentzVector proton1P4_scattered_rf(0., 0., +protonP_rf, protonEn_rf);
266  reco::Candidate::LorentzVector proton2P4_scattered_rf(0., 0., -protonP_rf, protonEn_rf);
267  reco::Candidate::LorentzVector proton1P4_scattered = boostToLab(ppP4_scattered, proton1P4_scattered_rf);
268  reco::Candidate::LorentzVector proton2P4_scattered = boostToLab(ppP4_scattered, proton2P4_scattered_rf);
269  genVtx_in->add_particle_out(new HepMC::GenParticle(HepMC::FourVector(proton1P4_scattered.px(), proton1P4_scattered.py(), proton1P4_scattered.pz(), proton1P4_scattered.E()), 2212, 1));
270  genVtx_in->add_particle_out(new HepMC::GenParticle(HepMC::FourVector(proton2P4_scattered.px(), proton2P4_scattered.py(), proton2P4_scattered.pz(), proton2P4_scattered.E()), 2212, 1));
271  HepMC::GenVertex* genVtx_out = new HepMC::GenVertex(HepMC::FourVector(0.,0.,0.,0.));
272  HepMC::GenParticle* genZ = new HepMC::GenParticle((HepMC::FourVector)zP4, zPdgId, 2, HepMC::Flow(), HepMC::Polarization(0,0));
273  genVtx_in->add_particle_out(genZ);
274  genVtx_out->add_particle_in(genZ);
275  HepMC::GenParticle* genMuon = new HepMC::GenParticle((HepMC::FourVector)muonP4_limited, muonPdgId, 1, HepMC::Flow(), HepMC::Polarization(0,0));
276  genVtx_out->add_particle_out(genMuon);
277  HepMC::GenParticle* genOther = new HepMC::GenParticle((HepMC::FourVector)otherP4_limited, otherPdgId, 1, HepMC::Flow(), HepMC::Polarization(0,0));
278  genVtx_out->add_particle_out(genOther);
279  genEvt_beforeFSR->add_vertex(genVtx_out);
280  if ( verbosity_ ) {
281  std::cout << "genEvt (beforeFSR):" << std::endl;
282  genEvt_beforeFSR->print(std::cout);
283  }
284 
285  repairBarcodes(genEvt_beforeFSR);
286 
287  HepMC::GenEvent* genEvt_afterFSR = 0;
288 
289  if ( mode_ == kPYTHIA ) {
290  gen::Pythia6Service::InstanceWrapper pythia6InstanceGuard(pythia_);
291 
292  if ( !pythia_isInitialized_ ) {
294  //pythia_->setCSAParams();
295  //pythia_->setSLHAParams();
296  gen::call_pygive("MSTU(12) = 12345");
297  call_pyinit("USER", "", "", 0.);
298  pythia_isInitialized_ = true;
299  }
300 
301  pythia_->setEvent(genEvt_beforeFSR);
302  if ( verbosity_ ) {
303  std::cout << "HEPEUP (beforeFSR):" << std::endl;
304  call_pylist(7);
305  std::cout.flush();
306  }
307  call_pyevnt();
308  call_pyedit(0); // CV: remove comment lines (confuses conversion to HepMC::Event)
309  if ( verbosity_ ) {
310  std::cout << "PYJETS (afterFSR):" << std::endl;
311  call_pylist(1);
312  std::cout.flush();
313  }
314  call_pyhepc(1);
315  if ( verbosity_ ) {
316  std::cout << "HepMC (afterFSR):" << std::endl;
317  call_pylist(5);
318  std::cout.flush();
319  }
320 
321  HepMC::IO_HEPEVT conv;
322  conv.set_print_inconsistency_errors(false);
323  genEvt_afterFSR = conv.read_next_event();
324  } else if ( mode_ == kPHOTOS ) {
325 
326  if ( !photos_isInitialized_ ) {
327  photos_->init();
328  photos_isInitialized_ = true;
329  }
330 
331  HepMC::IO_HEPEVT conv;
332  conv.write_event(genEvt_beforeFSR);
333  genEvt_afterFSR = photos_->apply(genEvt_beforeFSR);
334  } else assert(0);
335 
336  if ( verbosity_ ) {
337  std::cout << "genEvt (afterFSR):" << std::endl;
338  genEvt_afterFSR->print(std::cout);
339  }
340 
341  // find lowest energy muon
342  // (= muon after FSR)
343  reco::Candidate::LorentzVector muonP4afterFSR = muonP4;
344  for ( HepMC::GenEvent::particle_iterator genParticle = genEvt_afterFSR->particles_begin();
345  genParticle != genEvt_afterFSR->particles_end(); ++genParticle ) {
346  if ( (*genParticle)->pdg_id() == muonPdgId && (*genParticle)->momentum().e() < muonP4afterFSR.E() ) {
347  muonP4afterFSR.SetPxPyPzE(
348  (*genParticle)->momentum().px(),
349  (*genParticle)->momentum().py(),
350  (*genParticle)->momentum().pz(),
351  (*genParticle)->momentum().e());
352  }
353  }
354  reco::Candidate::LorentzVector sumPhotonP4 = muonP4 - muonP4afterFSR;
355  if ( verbosity_ ) {
356  std::cout << "sumPhotons: En = " << sumPhotonP4.E() << ", Pt = " << sumPhotonP4.pt() << ", eta = " << sumPhotonP4.eta() << ", phi = " << sumPhotonP4.phi() << std::endl;
357  }
358 
359  delete genEvt_beforeFSR;
360  if ( genEvt_afterFSR != genEvt_beforeFSR ) delete genEvt_afterFSR;
361 
362  return sumPhotonP4;
363 }
static HepMC::IO_HEPEVT conv
const double protonMass
Definition: V0Fitter.cc:40
bool call_pygive(const std::string &line)
void call_pylist(int mode)
T sqrt(T t)
Definition: SSEVec.h:48
void call_pyedit(int mode)
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:41
void repairBarcodes(HepMC::GenEvent *)
myPythia6ServiceWithCallback * pythia_
double square(const double a)
void setEvent(const HepMC::GenEvent *genEvt)
tuple cout
Definition: gather_cfg.py:121
HepMC::GenEvent * apply(HepMC::GenEvent *)

Member Data Documentation

double GenMuonRadiationAlgorithm::beamEnergy_
private

Definition at line 43 of file GenMuonRadiationAlgorithm.h.

Referenced by compFSR().

int GenMuonRadiationAlgorithm::mode_
private

Definition at line 46 of file GenMuonRadiationAlgorithm.h.

Referenced by compFSR(), and GenMuonRadiationAlgorithm().

gen::PhotosInterface* GenMuonRadiationAlgorithm::photos_
private
bool GenMuonRadiationAlgorithm::photos_isInitialized_ = false
staticprivate

Definition at line 49 of file GenMuonRadiationAlgorithm.h.

Referenced by compFSR().

myPythia6ServiceWithCallback* GenMuonRadiationAlgorithm::pythia_
private
bool GenMuonRadiationAlgorithm::pythia_isInitialized_ = false
staticprivate

Definition at line 52 of file GenMuonRadiationAlgorithm.h.

Referenced by compFSR().

int GenMuonRadiationAlgorithm::verbosity_
private

Definition at line 54 of file GenMuonRadiationAlgorithm.h.

Referenced by compFSR(), and GenMuonRadiationAlgorithm().