Heavy Ion Dilepton Generation

Complete: 5

Goal of this page

The aim of this page is to document the dilepton generation used in heavy ion studies of reconstruction efficiency. The page includes the location of the code, how to run it, input and output, and details of the implementation. Two generators have been considered for now: Pythia6PtYDistGun, and Pythia6PtGun.

1/ PtYDistGun

This generator allows one to generate particles which follow a user-specified distribution in pt and rapidity, rather than pseudorapidity. This distribution is provided as a ROOT TGraph. Efficiency studies are best done using a particle generation flat in pt and rapidity. Realistic distributions have been calculated by Ramona Vogt as described in the CERN Yellow report CERN-2004-009, and TGraphs for these are available.

Code and tags

The PtYDistGun lives in the package GeneratorInterface/Pythia6Interface/plugins, and has been included in CMSSW since CMSSW_3_1_0. No extra tags are necessary.

The TGraphs which contain the pt and y distributions live in HeavyIonsAnalysis/Configuration/data:

Configuration files

To generate particles with flat pt and rapidity distributions we use a flat TGraph pbpbFlat.root which is specified in the following cfi file DecayPtYDistGun_cfi.py. The default setting is for generating J/Ψ → μμ following Ramona's distributions. This file has to be copied to the python area of your working directory, which then has to be compiled again so that all python links are actualized. It allows one to define the generation cuts in pt, phi, rapidity and other parameters.

In order to run the generation one can use the following example configuration file PtYDistGun_cfg.py. The default settings from DecayPtYDistGun_cfi.py can be adapted to what one needs by changing only 3 lines. For example

  • for Z with a flat distribution:
process.generator.ParticleID = cms.vint32(23)
process.generator.kinematicsFile = cms.FileInPath('HeavyIonsAnalysis/Configuration/data/jpsipbpbFlat.root')
process.generator.PythiaParameters.parameterSets = cms.vstring('pythiaDefault','pythiaZtoMuons')
  • for J/Ψ with a realistic distribution (i.e. Ramona's):
process.generator.ParticleID = cms.vint32(443)
process.generator.kinematicsFile = cms.FileInPath('HeavyIonsAnalysis/Configuration/data/jpsipbpb.root')
process.generator.PythiaParameters.parameterSets = cms.vstring('pythiaDefault','pythiaJpsiToMuons')
  • for Υ with a realistic distribution (i.e. Ramona's):
process.generator.ParticleID = cms.vint32(553)
process.generator.kinematicsFile = cms.FileInPath('HeavyIonsAnalysis/Configuration/data/upsipbpb.root')
process.generator.PythiaParameters.parameterSets = cms.vstring('pythiaDefault','pythiaUpsilonToMuons')

To generate J/Ψ or Υ with a flat distribution instead, one only needs to change the name of the kinematics file to jpsipbpbFlat.root.

2/ Pythia6PtGun

This generator is a Pythia "particle gun", which generates single particles uniformly within a specified pt and eta range, then decays them.

Code and tags

The code for the Pythia6PtGun lives in GeneratorInterface/Pythia6Interface/plugins. It has been included in CMSSW since CMSSW_3_1_0. No extra tags are necessary.

Configuration files

Configuration files to run the Pythia6PtGun for various predefined cases live in the package UserCode/MitHig/HIProd/Configuration/.

The particle gun production and its decay are specified in the following files:

The particle gun can be used on its own in order to look at the signal only. An example of a configuration file that generates particles up to RAW is : dilepton_PtDisGun_cfg.py. One can produce the related cfg with cmsDriver like this (in CMSSW_3_6_1) : cmsDriver.py my_code/Prod/python/CMS.DecayPtYDistGun_generator_cfi.py -s GEN,SIM,DIGI,L1,DIGI2RAW -n 500 --conditions GlobalTag,MC_36Y_V7A::All --eventcontent FEVTDEBUG --datatier GEN-SIM-RAW --eventcontent=FEVTDEBUG --fileout=rfio:/castor/cern.ch/user/s/silvest/rootfiles/SignalOnly/Z0/root/RECO/Z0_SignalOnly_PPofflineReco_GEN-RAW_CMSSW361.root --processName RAW and then cmsDriver.py hiReco -s RAW2DIGI,RECO -n 500 --conditions GlobalTag,MC_36Y_V7A::All --eventcontent FEVTDEBUG --datatier GEN-SIM-RAW-RECO --eventcontent=FEVTDEBUG --filein=rfio:/castor/cern.ch/user/s/silvest/rootfiles/SignalOnly/Z0/root/RECO/Z0_SignalOnly_PPofflineReco_GEN-RAW_CMSSW361.root --fileout=rfio:/castor/cern.ch/user/s/silvest/rootfiles/SignalOnly/Z0/root/RECO/Z0_SignalOnly_PPofflineReco_RECO_CMSSW361.root --processName RECO (add --scenario HeavyIons to reconstruct with the heavy ion sequence)

Particles can also be embedded in hydjet events. An example of a configuration file that embeds Upsilons into hydjet is : DecayGunUpsilon2MuMu_intoHydjet.py For more information on embedding signals into heavy ion events see SWGuideHeavyIonEvtMixing.

Parameter settings

The settings that are defined in the particle gun cfi definition are detailed here. We take the J/psi as an example.

  • The PyquenDefaultSettings are imported
import FWCore.ParameterSet.Config as cms
from Configuration.Generator.PyquenDefaultSettings_cff import *

  • Particles are produced following Pythia6PtGun producer which requires to set a few parameters, in this example:
generator = cms.EDProducer("Pythia6PtGun",
                           maxEventsToPrint = cms.untracked.int32(0),
                           pythiaHepMCVerbosity = cms.untracked.bool(False),
                           pythiaPylistVerbosity = cms.untracked.int32(0),
                           PGunParameters = cms.PSet(ParticleID = cms.vint32(443),
                                                     MinEta = cms.double(-2.5),
                                                     MaxEta = cms.double(2.5),
                                                     MinPhi = cms.double(-3.14159265359),
                                                     MaxPhi = cms.double(3.14159265359),
                                                     MinPt = cms.double(0),
                                                     MaxPt = cms.double(20),
                                                     AddAntiParticle = cms.bool(False)
  • Finally, the pythia default specifications are called followed by the decay into 2 muons:
                           PythiaParameters = cms.PSet(pyquenPythiaDefaultBlock,
                                                       parameterSets = cms.vstring('pythiaDefault','pythiaJpsiToMuons')


Checks have been done to verify the characteristics of the particle generated with Pythia6PtGun and of their decays. Some example of such checks are summarised in the table below.

J/psi Upsilon
checking_5000jpsipgun_generation_jpsi.gif checking_1000upsilonpgun_generation_upsilon.gif
rapidity_checking_5000jpsipgun_generation_jpsi.gif rapidity_checking_1000upsilonpgun_generation_upsilon.gif
Z muons from the Z decay
checking_zpgun_generation_z.gif checking_zpgun_generation_muons.gif

3/ Update : embedding the pgun

For example ZToMuMu in CMSSW 361: copy DecayPtYDistGun_cfi.py in the python directory of your working area, here called my_code/Prod/python/, compile (scram b) the root, and in the test directory excute

cmsDriver.py my_code/Prod/CMS.DecayPtYDistGun_cfi.py -n -1 -s GEN:hiSignal,SIM,DIGI,L1,DIGI2RAW,HLT:HIon --scenario HeavyIons --himix --conditions GlobalTag,MC_36Y_V7A::All --datatier GEN-SIM-RAW-RECO --eventcontent=FEVTDEBUG --filein=rfio:/castor/cern.ch/user/d/dmoon/cms352/Hydjet_CMS.MinBias_2760_WithQuarkoniaWeakBosons_pt6_RAW/Hydjet_CMS.MinBias_2760GeV_pt6_RAW_e10_8_102.root --fileout=Hydjet_CMS.MinBias_2760GeV_pt6_GEN-SIM-RAW-HLT_EmbeddingZtoMuMu_e10_8_102.root --processName HISIGNAL --python_filename MinBias_2760_WithQuarkoniaWeakBosons_pt6_EmbeddingZtoMuMu_GEN-SIM-L1-DIGI-RAW-HLT.py --no_exec

it will embed the signal from CMS.DecayPtYDistGun_cfi.py into the background file fio:/castor/cern.ch/user/d/dmoon/cms352/Hydjet_CMS.MinBias_2760_WithQuarkoniaWeakBosons_pt6_RAW/Hydjet_CMS.MinBias_2760GeV_pt6_RAW_e10_8_102.root upto RAW.

Then to reconstruct this : cmsDriver.py hiReco -n -1 -s RAW2DIGI,RECO --scenario HeavyIons --conditions GlobalTag,MC_36Y_V7A::All --datatier GEN-SIM-RECO --eventcontent FEVTDEBUG --filein=file:Hydjet_CMS.MinBias_2760GeV_pt6_GEN-SIM-RAW-HLT_EmbeddingZtoMuMu_e10_8_102.root --fileout=Hydjet_CMS.MinBias_2760GeV_pt6_RECO_EmbeddingZtoMuMu_e10_8_102.root --processName HIRECOEMB --python_filename MinBias_2760_WithQuarkoniaWeakBosons_pt6_EmbeddingZtoMuMu_RECO.py --no_exec


Like all CMSSW generators, PtYDistGun and Pythia6PtGun produce an HepMCProduct object containing all the information of the generated event.

Accessing products

Below is a short code fragment that indicates which header files (*.h) need to be included, and demonstrates how to access the generator products from within the analyze function of an EDAnalyzer. You can find a tutorial about how to create an EDAnalyzer at WorkBookWriteFrameworkModule.

#include "FWCore/Framework/interface/MakerMacros.h"

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/ESHandle.h"

#include "FWCore/Framework/interface/EDAnalyzer.h"

#include "FWCore/Framework/interface/Event.h"
#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"

#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "CMS.PhysicsTools/UtilAlgos/interface/TFileService.h"
#include "FWCore/ServiceRegistry/interface/Service.h"


using namespace edm;
using namespace std;
using namespace HepMC;


void DemoAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
  //runs every event
  edm::LogInfo("Generation::analyze()")<<"Start analyzing ***";
  // get a handle on the product
  Handle<HepMCProduct> EvtHandle;
  iEvent.getByLabel("generator","",EvtHandle ) ;

  // get hold of the event
  const HepMC::GenEvent* myEvt = EvtHandle->GetEvent() ;

    // loop over particles
    for( HepMC::GenEvent::particle_const_iterator ip = myEvt->particles_begin(); ip != myEvt->particles_end(); ip++ )
      HepMC::GenParticle* p = *ip;
      if( p )
        eta_ = p->momentum().eta();
        pt_  = p->momentum().perp();
        pdg_ =abs(p->pdg_id());
        mass_=  p->momentum().m();
        energy_ = p->momentum().e();        
        rapidity_ = 0.5*log((p->momentum().e()+p->momentum().pz())/(p->momentum().e()-p->momentum().pz()));
          // if it has no daughter (it's detected by the detectors)
          GenVertex* endvert = (p)->end_vertex(); 
            for ( GenVertex::particles_out_const_iterator ap = endvert->particles_out_const_begin(); ap != endvert->particles_out_const_end(); ++ap ) 
              part_out_  ++; 

Further information

  • Heavy Ions Physics Interest Group (PInG) with track based analyses: DiLeptons
  • Group homepage: HeavyIons


Review status

Reviewer/Editor and Date Comments
CatherineSilvestre - 12 Aug 2009 created page as part of documentation review
CatherineSilvestre - 27 Oct 2009 Added PtYDistGun

Responsible: CatherineSilvestre

Edit | Attach | Watch | Print version | History: r12 < r11 < r10 < r9 < r8 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r12 - 2010-05-31 - CatherineSilvestre
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    CMSPublic All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback