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 edm::StreamID &streamID, 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::PhotosInterfaceBasephotos_
 
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 36 of file GenMuonRadiationAlgorithm.h.

Member Enumeration Documentation

anonymous enum
private

Constructor & Destructor Documentation

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

Definition at line 163 of file GenMuonRadiationAlgorithm.cc.

References Exception, edm::ParameterSet::exists(), reco::get(), edm::ParameterSet::getParameter(), kPHOTOS, kPYTHIA, mode_, photos_, pythia_, AlCaHLTBitMon_QueryRunRegistry::string, and verbosity_.

164  : beamEnergy_(cfg.getParameter<double>("beamEnergy")),
165  photos_(0),
166  pythia_(0)
167 {
168  std::string mode_string = cfg.getParameter<std::string>("mode");
169  if ( mode_string == "pythia" ) mode_ = kPYTHIA;
170  else if ( mode_string == "photos" ) mode_ = kPHOTOS;
171  else throw cms::Exception("Configuration")
172  << " Invalid Configuration Parameter 'mode' = " << mode_string << " !!\n";
173 
174  if ( mode_ == kPYTHIA ) pythia_ = new myPythia6ServiceWithCallback(cfg);
175  if ( mode_ == kPHOTOS ){
176  photos_ = (gen::PhotosInterfaceBase*)(PhotosFactory::get()->create("Photos2155", cfg.getParameter<edm::ParameterSet>("PhotosOptions")));
177  //settings?
178  //usesResource(edm::SharedResourceNames::kPhotos);
179  }
180 
181  verbosity_ = ( cfg.exists("verbosity") ) ?
182  cfg.getParameter<int>("verbosity") : 0;
183 }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
gen::PhotosInterfaceBase * photos_
myPythia6ServiceWithCallback * pythia_
T get(const Candidate &c)
Definition: component.h:55
GenMuonRadiationAlgorithm::~GenMuonRadiationAlgorithm ( )

Definition at line 185 of file GenMuonRadiationAlgorithm.cc.

References photos_, and pythia_.

186 {
187  delete photos_;
188  call_pystat(1);
189  delete pythia_;
190 }
gen::PhotosInterfaceBase * photos_
myPythia6ServiceWithCallback * pythia_

Member Function Documentation

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

Definition at line 227 of file GenMuonRadiationAlgorithm.cc.

References gen::PhotosInterfaceBase::apply(), assert(), beamEnergy_, call_pyedit(), gen::call_pygive(), gen::call_pylist(), conv, gather_cfg::cout, decayRandomEngine, GenParticle::GenParticle, edm::RandomNumberGenerator::getEngine(), gen::PhotosInterfaceBase::init(), edm::Service< T >::isAvailable(), kPHOTOS, kPYTHIA, mode_, photos_, photos_isInitialized_, protonMass, pythia_, pythia_isInitialized_, repairBarcodes(), myPythia6ServiceWithCallback::setEvent(), gen::Pythia6Service::setGeneralParams(), gen::PhotosInterfaceBase::setRandomEngine(), mathSSE::sqrt(), Clusterizer1DCommons::square(), and verbosity_.

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

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

Member Data Documentation

double GenMuonRadiationAlgorithm::beamEnergy_
private

Definition at line 45 of file GenMuonRadiationAlgorithm.h.

Referenced by compFSR().

int GenMuonRadiationAlgorithm::mode_
private

Definition at line 48 of file GenMuonRadiationAlgorithm.h.

Referenced by compFSR(), and GenMuonRadiationAlgorithm().

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

Definition at line 51 of file GenMuonRadiationAlgorithm.h.

Referenced by compFSR().

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

Definition at line 54 of file GenMuonRadiationAlgorithm.h.

Referenced by compFSR().

int GenMuonRadiationAlgorithm::verbosity_
private

Definition at line 56 of file GenMuonRadiationAlgorithm.h.

Referenced by compFSR(), and GenMuonRadiationAlgorithm().