CMS 3D CMS Logo

Public Member Functions | Private Types | Private Attributes

Pythia8Hadronizer Class Reference

Inheritance diagram for Pythia8Hadronizer:
gen::BaseHadronizer gen::Py8InterfaceBase

List of all members.

Public Member Functions

const char * classname () const
void finalizeEvent ()
bool generatePartonsAndHadronize ()
bool hadronize ()
bool initializeForExternalPartons ()
bool initializeForInternalPartons ()
 Pythia8Hadronizer (const edm::ParameterSet &params)
virtual bool residualDecay ()
void statistics ()
 ~Pythia8Hadronizer ()

Private Types

enum  { PP, PPbar, ElectronPositron }

Private Attributes

double comEnergy
 Center-of-Mass energy.
int EV1_emittedMode
int EV1_maxVetoCount
bool EV1_MPIvetoOn
int EV1_nFinal
int EV1_pTdefMode
int EV1_pTempMode
int EV1_pThardMode
bool EV1_vetoOn
double fBeam1PZ
double fBeam2PZ
EmissionVetoHookfEmissionVetoHook
EmissionVetoHook1fEmissionVetoHook1
int fInitialState
JetMatchingHookfJetMatchingHook
UserHooks * fReweightUserHook
std::auto_ptr< LHAupLesHoucheslhaUP
string LHEInputFileName

Detailed Description

Definition at line 48 of file Pythia8Hadronizer.cc.


Member Enumeration Documentation

anonymous enum [private]
Enumerator:
PP 
PPbar 
ElectronPositron 

Definition at line 77 of file Pythia8Hadronizer.cc.


Constructor & Destructor Documentation

Pythia8Hadronizer::Pythia8Hadronizer ( const edm::ParameterSet params)

Definition at line 108 of file Pythia8Hadronizer.cc.

References gen::ParameterCollector::begin(), edm::errors::Configuration, gather_cfg::cout, ElectronPositron, gen::ParameterCollector::end(), EV1_emittedMode, EV1_maxVetoCount, EV1_MPIvetoOn, EV1_nFinal, EV1_pTdefMode, EV1_pTempMode, EV1_pThardMode, EV1_vetoOn, Exception, edm::ParameterSet::exists(), python::connectstrParser::f1, fEmissionVetoHook, fEmissionVetoHook1, fInitialState, fJetMatchingHook, gen::Py8InterfaceBase::fMasterGen, gen::Py8InterfaceBase::fParameters, fReweightUserHook, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), geometryCSVtoXML::line, PP, PPbar, and AlCaHLTBitMon_QueryRunRegistry::string.

                                                                  :
  BaseHadronizer(params), Py8InterfaceBase(params),
  comEnergy(params.getParameter<double>("comEnergy")),
  LHEInputFileName(params.getUntrackedParameter<string>("LHEInputFileName","")),
  fInitialState(PP),
  fReweightUserHook(0),
  fJetMatchingHook(0),
  fEmissionVetoHook(0),fEmissionVetoHook1(0)
{

  // J.Y.: the following 3 parameters are hacked "for a reason"
  //
  if ( params.exists( "PPbarInitialState" ) )
  {
    if ( fInitialState == PP )
    {
      fInitialState = PPbar;
      edm::LogInfo("GeneratorInterface|Pythia6Interface")
      << "Pythia6 will be initialized for PROTON-ANTIPROTON INITIAL STATE. "
      << "This is a user-request change from the DEFAULT PROTON-PROTON initial state." << std::endl;
      std::cout << "Pythia6 will be initialized for PROTON-ANTIPROTON INITIAL STATE." << std::endl;
      std::cout << "This is a user-request change from the DEFAULT PROTON-PROTON initial state." << std::endl;
    }
    else
    {   
      // probably need to throw on attempt to override ?
    }
  }   
  else if ( params.exists( "ElectronPositronInitialState" ) )
  {
    if ( fInitialState == PP )
    {
      fInitialState = ElectronPositron;
      edm::LogInfo("GeneratorInterface|Pythia6Interface")
      << "Pythia6 will be initialized for ELECTRON-POSITRON INITIAL STATE. "
      << "This is a user-request change from the DEFAULT PROTON-PROTON initial state." << std::endl;
      std::cout << "Pythia6 will be initialized for ELECTRON-POSITRON INITIAL STATE." << std::endl; 
      std::cout << "This is a user-request change from the DEFAULT PROTON-PROTON initial state." << std::endl;
    }
    else
    {   
       // probably need to throw on attempt to override ?
    }
  }
  else if ( params.exists( "ElectronProtonInitialState" ) || params.exists( "PositronProtonInitialState" ) )
  {
    // throw on unknown initial state !
    throw edm::Exception(edm::errors::Configuration,"Pythia8Interface")
      <<" UNKNOWN INITIAL STATE. \n The allowed initial states are: PP, PPbar, ElectronPositron \n";
  }
    
  if( params.exists( "SLHAFileForPythia8" ) ) {
    std::string slhafilenameshort = params.getParameter<string>("SLHAFileForPythia8");
    edm::FileInPath f1( slhafilenameshort );
    std::string slhafilename = f1.fullPath();
    std::string pythiacommandslha = std::string("SLHA:file = ") + slhafilename;
    fMasterGen->readString(pythiacommandslha);
    for ( ParameterCollector::const_iterator line = fParameters.begin();
          line != fParameters.end(); ++line ) {
      if (line->find("SLHA:file") != std::string::npos)
        throw cms::Exception("PythiaError") << "Attempted to set SLHA file name twice, "
        << "using Pythia8 card SLHA:file and Pythia8Interface card SLHAFileForPythia8"
        << std::endl;
     }  
  }

  // Reweight user hook
  //
  if( params.exists( "reweightGen" ) )
    fReweightUserHook = new PtHatReweightUserHook();

  if( params.exists( "useUserHook" ) )
    throw edm::Exception(edm::errors::Configuration,"Pythia8Interface")
      <<" Obsolete parameter: useUserHook \n Please use the actual one instead \n";

  // PS matching prototype
  //
  if ( params.exists("jetMatching") )
  {
    edm::ParameterSet jmParams =
      params.getUntrackedParameter<edm::ParameterSet>("jetMatching");
      std::string scheme = jmParams.getParameter<std::string>("scheme");
      if ( scheme == "Madgraph" || scheme == "MadgraphFastJet" )
      {
         fJetMatchingHook = new JetMatchingHook( jmParams, &fMasterGen->info );
      }
  }

  // Emission vetos
  //
  if ( params.exists("emissionVeto") )
  {   
    fEmissionVetoHook = new EmissionVetoHook(0);
  }

  if ( params.exists("emissionVeto1") )
  {
    EV1_nFinal = -1;
    if(params.exists("EV1_nFinal")) EV1_nFinal = params.getParameter<int>("EV1_nFinal");
    EV1_vetoOn = true;
    if(params.exists("EV1_vetoOn")) EV1_vetoOn = params.getParameter<bool>("EV1_vetoOn");
    EV1_maxVetoCount = 10;
    if(params.exists("EV1_maxVetoCount")) EV1_maxVetoCount = params.getParameter<int>("EV1_maxVetoCount");
    EV1_pThardMode = 1;
    if(params.exists("EV1_pThardMode")) EV1_pThardMode = params.getParameter<int>("EV1_pThardMode");
    EV1_pTempMode = 0;
    if(params.exists("EV1_pTempMode")) EV1_pTempMode = params.getParameter<int>("EV1_pTempMode");
    if(EV1_pTempMode > 2 || EV1_pTempMode < 0)
      throw edm::Exception(edm::errors::Configuration,"Pythia8Interface")
        <<" Wrong value for EV1_pTempMode code\n";
    EV1_emittedMode = 0;
    if(params.exists("EV1_emittedMode")) EV1_emittedMode = params.getParameter<int>("EV1_emittedMode");
    EV1_pTdefMode = 1;
    if(params.exists("EV1_pTdefMode")) EV1_pTdefMode = params.getParameter<int>("EV1_pTdefMode");
    EV1_MPIvetoOn = false;
    if(params.exists("EV1_MPIvetoOn")) EV1_MPIvetoOn = params.getParameter<bool>("EV1_MPIvetoOn");
    fEmissionVetoHook1 = new EmissionVetoHook1(EV1_nFinal, EV1_vetoOn, 
                               EV1_maxVetoCount, EV1_pThardMode, EV1_pTempMode,
                               EV1_emittedMode, EV1_pTdefMode, EV1_MPIvetoOn, 0);
  }

  int NHooks=0;
  if(fReweightUserHook) NHooks++;
  if(fJetMatchingHook) NHooks++;
  if(fEmissionVetoHook) NHooks++;
  if(fEmissionVetoHook1) NHooks++;
  if(NHooks > 1)
    throw edm::Exception(edm::errors::Configuration,"Pythia8Interface")
      <<" Too many User Hooks. \n Please choose one from: reweightGen, jetMatching, emissionVeto \n";

  if(fReweightUserHook) fMasterGen->setUserHooksPtr(fReweightUserHook);
  if(fJetMatchingHook) fMasterGen->setUserHooksPtr(fJetMatchingHook);
  if(fEmissionVetoHook || fEmissionVetoHook1) {
    cout << "Turning on Emission Veto Hook";
    if(fEmissionVetoHook1) cout << " 1";
    cout << endl;
    int nversion = (int)(1000.*(fMasterGen->settings.parm("Pythia:versionNumber") - 8.));
    if(nversion < 157) {
      cout << "obsolete pythia8 version for this Emission Veto code" << endl;
      cout << "Please update pythia8 version using the instructions here:" << endl;
      cout << "https://twiki.cern.ch/twiki/bin/view/CMS/Pythia8Interface" << endl;
      cout << "or try to use tag V00-01-28 of this interface" << endl;
      throw edm::Exception(edm::errors::Configuration,"Pythia8Interface")
        <<" Obsolete pythia8 version for this Emission Veto code\n";
    }
    if(fEmissionVetoHook) fMasterGen->setUserHooksPtr(fEmissionVetoHook);
    if(fEmissionVetoHook1) fMasterGen->setUserHooksPtr(fEmissionVetoHook1);
  }
}
Pythia8Hadronizer::~Pythia8Hadronizer ( )

Definition at line 259 of file Pythia8Hadronizer.cc.

References fEmissionVetoHook, and fEmissionVetoHook1.

{
// do we need to delete UserHooks/JetMatchingHook here ???

  if(fEmissionVetoHook) {delete fEmissionVetoHook; fEmissionVetoHook=0;}
  if(fEmissionVetoHook1) {delete fEmissionVetoHook1; fEmissionVetoHook1=0;}
}

Member Function Documentation

const char* Pythia8Hadronizer::classname ( ) const [inline, virtual]

Implements gen::Py8InterfaceBase.

Definition at line 67 of file Pythia8Hadronizer.cc.

{ return "Pythia8Hadronizer"; }
void Pythia8Hadronizer::finalizeEvent ( ) [virtual]

Implements gen::Py8InterfaceBase.

Definition at line 497 of file Pythia8Hadronizer.cc.

References gather_cfg::cout, gen::BaseHadronizer::event(), gen::BaseHadronizer::eventInfo(), gen::Py8InterfaceBase::fMasterGen, gen::BaseHadronizer::lheEvent(), gen::Py8InterfaceBase::maxEventsToPrint, gen::Py8InterfaceBase::pythiaHepMCVerbosity, and gen::Py8InterfaceBase::pythiaPylistVerbosity.

{
  bool lhe = lheEvent() != 0;

  // now create the GenEventInfo product from the GenEvent and fill
  // the missing pieces
  eventInfo().reset( new GenEventInfoProduct( event().get() ) );

  // in pythia pthat is used to subdivide samples into different bins
  // in LHE mode the binning is done by the external ME generator
  // which is likely not pthat, so only filling it for Py6 internal mode
  if (!lhe) {
    eventInfo()->setBinningValues(std::vector<double>(1, fMasterGen->info.pTHat()));
  }

  //******** Verbosity ********

  if (maxEventsToPrint > 0 &&
      (pythiaPylistVerbosity || pythiaHepMCVerbosity)) {
    maxEventsToPrint--;
    if (pythiaPylistVerbosity) {
      fMasterGen->info.list(std::cout); 
      fMasterGen->event.list(std::cout);
    } 

    if (pythiaHepMCVerbosity) {
      std::cout << "Event process = "
                << fMasterGen->info.code() << "\n"
                << "----------------------" << std::endl;
      event()->print();
    }
  }
}
bool Pythia8Hadronizer::generatePartonsAndHadronize ( ) [virtual]

Implements gen::Py8InterfaceBase.

Definition at line 381 of file Pythia8Hadronizer.cc.

References gen::BaseHadronizer::event(), gen::Py8InterfaceBase::fMasterGen, and gen::Py8InterfaceBase::toHepMC.

{

  if (!fMasterGen->next()) return false;

  event().reset(new HepMC::GenEvent);
  return toHepMC.fill_next_event( *(fMasterGen.get()), event().get());

}
bool Pythia8Hadronizer::hadronize ( )
bool Pythia8Hadronizer::initializeForExternalPartons ( )

Definition at line 311 of file Pythia8Hadronizer.cc.

References gather_cfg::cout, gen::Py8InterfaceBase::fDecayer, fJetMatchingHook, gen::Py8InterfaceBase::fMasterGen, JetMatchingHook::init(), lhaUP, LHEInputFileName, gen::BaseHadronizer::lheRunInfo(), and gen::Py8InterfaceBase::pythiaPylistVerbosity.

{

  std::cout << "Initializing for external partons" << std::endl;

  // pythiaEvent = &pythia->event;
    
  if(LHEInputFileName != string()) {

    cout << endl;
    cout << "LHE Input File Name = " << LHEInputFileName << endl;
    cout << endl;
    fMasterGen->init(LHEInputFileName);

  } else {

    lhaUP.reset(new LHAupLesHouches());
    lhaUP->loadRunInfo(lheRunInfo());
    
    if ( fJetMatchingHook )
    {
       fJetMatchingHook->init ( lheRunInfo() );
    }
    
    fMasterGen->init(lhaUP.get());

  }
  
  if ( pythiaPylistVerbosity > 10 )
  {
    if ( pythiaPylistVerbosity == 11 || pythiaPylistVerbosity == 13 )
           fMasterGen->settings.listAll();
    if ( pythiaPylistVerbosity == 12 || pythiaPylistVerbosity == 13 )
           fMasterGen->particleData.listAll();
  }

  // init decayer
  fDecayer->readString("ProcessLevel:all = off"); // trick
  fDecayer->readString("Standalone:allowResDec=on");
  // pythia->readString("ProcessLevel::resonanceDecays=on");
  fDecayer->init();

  return true;
}
bool Pythia8Hadronizer::initializeForInternalPartons ( ) [virtual]

Implements gen::Py8InterfaceBase.

Definition at line 267 of file Pythia8Hadronizer.cc.

References comEnergy, edm::errors::Configuration, ElectronPositron, Exception, gen::Py8InterfaceBase::fDecayer, fInitialState, gen::Py8InterfaceBase::fMasterGen, PP, PPbar, and gen::Py8InterfaceBase::pythiaPylistVerbosity.

{

  // pythiaEvent = &pythia->event;

  if ( fInitialState == PP ) // default
  {
    fMasterGen->init(2212, 2212, comEnergy);
  }
  else if ( fInitialState == PPbar )
  {
    fMasterGen->init(2212, -2212, comEnergy);
  }
  else if ( fInitialState == ElectronPositron )
  {
    fMasterGen->init(11, -11, comEnergy);
  }    
  else 
  {
    // throw on unknown initial state !
    throw edm::Exception(edm::errors::Configuration,"Pythia8Interface")
      <<" UNKNOWN INITIAL STATE. \n The allowed initial states are: PP, PPbar, ElectronPositron \n";
  }

  fMasterGen->settings.listChanged();

  if ( pythiaPylistVerbosity > 10 )
  {
    if ( pythiaPylistVerbosity == 11 || pythiaPylistVerbosity == 13 )
           fMasterGen->settings.listAll();
    if ( pythiaPylistVerbosity == 12 || pythiaPylistVerbosity == 13 )
           fMasterGen->particleData.listAll();
  }

  // init decayer
  fDecayer->readString("ProcessLevel:all = off"); // trick
  fDecayer->readString("Standalone:allowResDec=on");
  // pythia->readString("ProcessLevel::resonanceDecays=on");
  fDecayer->init();

  return true;
}
bool Pythia8Hadronizer::residualDecay ( ) [virtual]

Definition at line 421 of file Pythia8Hadronizer.cc.

References gen::BaseHadronizer::event(), gen::Py8InterfaceBase::fDecayer, gen::Py8InterfaceBase::fMasterGen, and configurableAnalysis::GenParticle.

{

  Event* pythiaEvent = &(fMasterGen->event);

  int NPartsBeforeDecays = pythiaEvent->size();
  int NPartsAfterDecays = event().get()->particles_size();
  int NewBarcode = NPartsAfterDecays;

  for ( int ipart=NPartsAfterDecays; ipart>NPartsBeforeDecays; ipart-- )
  {

    HepMC::GenParticle* part = event().get()->barcode_to_particle( ipart );

    if ( part->status() == 1 )
    {
      fDecayer->event.reset();
      Particle py8part(  part->pdg_id(), 93, 0, 0, 0, 0, 0, 0,
                         part->momentum().x(),
                         part->momentum().y(), 
                         part->momentum().z(),
                         part->momentum().t(),
                         part->generated_mass() );
      HepMC::GenVertex* ProdVtx = part->production_vertex();
      py8part.vProd( ProdVtx->position().x(), ProdVtx->position().y(),
                     ProdVtx->position().z(), ProdVtx->position().t() );
      py8part.tau( (fDecayer->particleData).tau0( part->pdg_id() ) );
      fDecayer->event.append( py8part );
      int nentries = fDecayer->event.size();
      if ( !fDecayer->event[nentries-1].mayDecay() ) continue;
      fDecayer->next();
      int nentries1 = fDecayer->event.size();
      // fDecayer->event.list(std::cout);
      if ( nentries1 <= nentries ) continue; //same number of particles, no decays...
     
      part->set_status(2);
      
      Particle& py8daughter = fDecayer->event[nentries]; // the 1st daughter
      HepMC::GenVertex* DecVtx = new HepMC::GenVertex( HepMC::FourVector(py8daughter.xProd(),
                                                       py8daughter.yProd(),
                                                       py8daughter.zProd(),
                                                       py8daughter.tProd()) );
      
      DecVtx->add_particle_in( part ); // this will cleanup end_vertex if exists, replace with the new one
                                       // I presume (vtx) barcode will be given automatically
      
      HepMC::FourVector pmom( py8daughter.px(), py8daughter.py(), py8daughter.pz(), py8daughter.e() );

      HepMC::GenParticle* daughter =
                        new HepMC::GenParticle( pmom, py8daughter.id(), 1 );
  
      NewBarcode++;
      daughter->suggest_barcode( NewBarcode );
      DecVtx->add_particle_out( daughter );
      
      for ( int ipart1=nentries+1; ipart1<nentries1; ipart1++ )
      {
        py8daughter = fDecayer->event[ipart1];
        HepMC::FourVector pmomN( py8daughter.px(), py8daughter.py(), py8daughter.pz(), py8daughter.e() );
        HepMC::GenParticle* daughterN =
                        new HepMC::GenParticle( pmomN, py8daughter.id(), 1 );
        NewBarcode++;
        daughterN->suggest_barcode( NewBarcode );
        DecVtx->add_particle_out( daughterN );
      }

      event().get()->add_vertex( DecVtx );
      // fCurrentEventState->add_vertex( DecVtx );
      
    } 
 }   
 return true;
 
}     
void Pythia8Hadronizer::statistics ( ) [virtual]

Reimplemented from gen::Py8InterfaceBase.

Definition at line 371 of file Pythia8Hadronizer.cc.

References gen::Py8InterfaceBase::fMasterGen, gen::BaseHadronizer::runInfo(), and GenRunInfoProduct::setInternalXSec().

{
  fMasterGen->statistics();

  double xsec = fMasterGen->info.sigmaGen(); // cross section in mb
  xsec *= 1.0e9; // translate to pb (CMS/Gen "convention" as of May 2009)
  runInfo().setInternalXSec(xsec);
}

Member Data Documentation

double Pythia8Hadronizer::comEnergy [private]

Center-of-Mass energy.

Definition at line 72 of file Pythia8Hadronizer.cc.

Referenced by initializeForInternalPartons().

Definition at line 101 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

Definition at line 98 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

Definition at line 103 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

Definition at line 96 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

Definition at line 102 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

Definition at line 100 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

Definition at line 99 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

Definition at line 97 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

double Pythia8Hadronizer::fBeam1PZ [private]

Definition at line 80 of file Pythia8Hadronizer.cc.

double Pythia8Hadronizer::fBeam2PZ [private]

Definition at line 81 of file Pythia8Hadronizer.cc.

Definition at line 93 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer(), and ~Pythia8Hadronizer().

Definition at line 94 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer(), and ~Pythia8Hadronizer().

Definition at line 78 of file Pythia8Hadronizer.cc.

Referenced by initializeForInternalPartons(), and Pythia8Hadronizer().

Definition at line 89 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), initializeForExternalPartons(), and Pythia8Hadronizer().

Definition at line 85 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

std::auto_ptr<LHAupLesHouches> Pythia8Hadronizer::lhaUP [private]

Definition at line 75 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and initializeForExternalPartons().

Definition at line 74 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and initializeForExternalPartons().