CMS 3D CMS Logo

Public Types | Public Member Functions | Private Attributes

edm::GeneratorFilter< HAD, DEC > Class Template Reference

#include <GeneratorFilter.h>

Inheritance diagram for edm::GeneratorFilter< HAD, DEC >:
edm::EDFilter edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Types

typedef DEC Decayer
typedef HAD Hadronizer

Public Member Functions

virtual bool beginLuminosityBlock (LuminosityBlock &, EventSetup const &)
virtual bool beginRun (Run &, EventSetup const &)
virtual void endJob ()
virtual bool endLuminosityBlock (LuminosityBlock &, EventSetup const &)
virtual bool endRun (Run &, EventSetup const &)
virtual bool filter (Event &e, EventSetup const &es)
 GeneratorFilter (ParameterSet const &ps)
virtual void respondToCloseInputFile (FileBlock const &fb)
virtual void respondToCloseOutputFiles (FileBlock const &fb)
virtual void respondToOpenInputFile (FileBlock const &fb)
virtual void respondToOpenOutputFiles (FileBlock const &fb)
virtual ~GeneratorFilter ()

Private Attributes

Decayerdecayer_
Hadronizer hadronizer_

Detailed Description

template<class HAD, class DEC>
class edm::GeneratorFilter< HAD, DEC >

Definition at line 33 of file GeneratorFilter.h.


Member Typedef Documentation

template<class HAD , class DEC >
typedef DEC edm::GeneratorFilter< HAD, DEC >::Decayer

Definition at line 37 of file GeneratorFilter.h.

template<class HAD , class DEC >
typedef HAD edm::GeneratorFilter< HAD, DEC >::Hadronizer

Definition at line 36 of file GeneratorFilter.h.


Constructor & Destructor Documentation

template<class HAD , class DEC >
edm::GeneratorFilter< HAD, DEC >::GeneratorFilter ( ParameterSet const &  ps) [explicit]

Definition at line 68 of file GeneratorFilter.h.

References edm::GeneratorFilter< HAD, DEC >::decayer_, edm::ParameterSet::exists(), and edm::ParameterSet::getParameter().

                                                                  :
    EDFilter(),
    hadronizer_(ps),
    decayer_(0)
  {
    // TODO:
    // Put the list of types produced by the filters here.
    // The current design calls for:
    //   * GenRunInfoProduct
    //   * HepMCProduct
    //
    // other maybe added as needs be
    //
    
    if ( ps.exists("ExternalDecays") )
    {
       //decayer_ = new gen::ExternalDecayDriver(ps.getParameter<ParameterSet>("ExternalDecays"));
       ParameterSet ps1 = ps.getParameter<ParameterSet>("ExternalDecays");
       decayer_ = new Decayer(ps1);
    }

    produces<edm::HepMCProduct>();
    produces<GenEventInfoProduct>();
    produces<GenRunInfoProduct, edm::InRun>();
  }
template<class HAD , class DEC >
edm::GeneratorFilter< HAD, DEC >::~GeneratorFilter ( ) [virtual]

Definition at line 95 of file GeneratorFilter.h.

  { if ( decayer_ ) delete decayer_;}

Member Function Documentation

template<class HAD , class DEC >
bool edm::GeneratorFilter< HAD, DEC >::beginLuminosityBlock ( LuminosityBlock ,
EventSetup const &  es 
) [virtual]

Reimplemented from edm::EDFilter.

Definition at line 224 of file GeneratorFilter.h.

References edm::errors::Configuration, and Exception.

  {

    if ( !hadronizer_.initializeForInternalPartons() )
       throw edm::Exception(errors::Configuration) 
         << "Failed to initialize hadronizer "
         << hadronizer_.classname()
         << " for internal parton generation\n";
    
    if ( decayer_ )
    {
       decayer_->init(es);
       if ( !hadronizer_.declareStableParticles( decayer_->operatesOnParticles() ) )
          throw edm::Exception(errors::Configuration)
            << "Failed to declare stable particles in hadronizer "
            << hadronizer_.classname()
            << "\n";
       if ( !hadronizer_.declareSpecialSettings( decayer_->specialSettings() ) )
          throw edm::Exception(errors::Configuration)
            << "Failed to declare special settings in hadronizer "
            << hadronizer_.classname()
            << "\n";
    }

    return true;

  }
template<class HAD , class DEC >
bool edm::GeneratorFilter< HAD, DEC >::beginRun ( Run ,
EventSetup const &  es 
) [virtual]

Reimplemented from edm::EDFilter.

Definition at line 169 of file GeneratorFilter.h.

  {

/*
     // we init external decay tools first, to mimic how it was in beginRun
     // in principle, in a big picture it shouldn't matter but in practice 
     // the output is not identical if we change the order - the reason is
     // that RANMAR is overriden with PYR, thus the order of calls shifts
     // the state of the random engine
     //
     if ( decayer_ ) decayer_->init(es);

    // Create the LHEGeneratorInfo product describing the run
    // conditions here, and insert it into the Run object.

    if ( !hadronizer_.initializeForInternalPartons() )
       throw edm::Exception(errors::Configuration) 
         << "Failed to initialize hadronizer "
         << hadronizer_.classname()
         << " for internal parton generation\n";
    
    if ( decayer_ )
    {
       if ( !hadronizer_.declareStableParticles( decayer_->operatesOnParticles() ) )
          throw edm::Exception(errors::Configuration)
            << "Failed to declare stable particles in hadronizer "
            << hadronizer_.classname()
            << "\n";
    }
*/
    
    return true;
  }
template<class HAD , class DEC >
void edm::GeneratorFilter< HAD, DEC >::endJob ( void  ) [virtual]

Reimplemented from edm::EDFilter.

Definition at line 164 of file GeneratorFilter.h.

  { }
template<class HAD , class DEC >
bool edm::GeneratorFilter< HAD, DEC >::endLuminosityBlock ( LuminosityBlock ,
EventSetup const &   
) [virtual]

Reimplemented from edm::EDFilter.

Definition at line 254 of file GeneratorFilter.h.

  {
    // If relevant, record the integration luminosity of this
    // luminosity block here.  To do so, we would need a standard
    // function to invoke on the contained hadronizer that would
    // report the integrated luminosity.
    return true;
  }
template<class HAD , class DEC >
bool edm::GeneratorFilter< HAD, DEC >::endRun ( Run r,
EventSetup const &   
) [virtual]

Reimplemented from edm::EDFilter.

Definition at line 205 of file GeneratorFilter.h.

References edm::Run::put().

  {
    // If relevant, record the integrated luminosity for this run
    // here.  To do so, we would need a standard function to invoke on
    // the contained hadronizer that would report the integrated
    // luminosity.

    hadronizer_.statistics();
    
    if ( decayer_ ) decayer_->statistics();
    
    std::auto_ptr<GenRunInfoProduct> griproduct(new GenRunInfoProduct(hadronizer_.getGenRunInfo()));
    r.put(griproduct);

    return true;
  }
template<class HAD , class DEC >
bool edm::GeneratorFilter< HAD, DEC >::filter ( Event e,
EventSetup const &  es 
) [virtual]

Implements edm::EDFilter.

Definition at line 100 of file GeneratorFilter.h.

References edm::EventID::event(), event(), edm::EventBase::id(), and edm::Event::put().

  {
    hadronizer_.setEDMEvent(ev);

    if ( !hadronizer_.generatePartonsAndHadronize() ) return false;

    //  this is "fake" stuff
    // in principle, decays are done as part of full event generation,
    // except for particles that are marked as to be kept stable
    // but we currently keep in it the design, because we might want
    // to use such feature for other applications
    //
    if ( !hadronizer_.decay() ) return false;
    
    std::auto_ptr<HepMC::GenEvent> event(hadronizer_.getGenEvent());
    if ( !event.get() ) return false; 

    // The external decay driver is being added to the system,
    // it should be called here
    //
    if ( decayer_ ) 
    {
      event.reset( decayer_->decay( event.get() ) );
    }
    if ( !event.get() ) return false;

    // check and perform if there're any unstable particles after 
    // running external decay packages
    //
    // fisrt of all, put back modified event tree (after external decay)
    //
    hadronizer_.resetEvent( event.release() );
    //
    // now run residual decays
    //
    if ( !hadronizer_.residualDecay() ) return false;

    hadronizer_.finalizeEvent();

    event.reset( hadronizer_.getGenEvent() );
    if ( !event.get() ) return false;

    event->set_event_number( ev.id().event() );

    //
    // tutto bene - finally, form up EDM products !
    //
    std::auto_ptr<GenEventInfoProduct> genEventInfo(hadronizer_.getGenEventInfo());
    if (!genEventInfo.get())
    { 
      // create GenEventInfoProduct from HepMC event in case hadronizer didn't provide one
      genEventInfo.reset(new GenEventInfoProduct(event.get()));
    }
    ev.put(genEventInfo);

    std::auto_ptr<HepMCProduct> bare_product(new HepMCProduct());
    bare_product->addHepMCData( event.release() );
    ev.put(bare_product);

    return true;
  }
template<class HAD , class DEC >
void edm::GeneratorFilter< HAD, DEC >::respondToCloseInputFile ( FileBlock const &  fb) [virtual]

Reimplemented from edm::EDFilter.

Definition at line 270 of file GeneratorFilter.h.

  { }
template<class HAD , class DEC >
void edm::GeneratorFilter< HAD, DEC >::respondToCloseOutputFiles ( FileBlock const &  fb) [virtual]

Reimplemented from edm::EDFilter.

Definition at line 280 of file GeneratorFilter.h.

  { }
template<class HAD , class DEC >
void edm::GeneratorFilter< HAD, DEC >::respondToOpenInputFile ( FileBlock const &  fb) [virtual]

Reimplemented from edm::EDFilter.

Definition at line 265 of file GeneratorFilter.h.

  { }
template<class HAD , class DEC >
void edm::GeneratorFilter< HAD, DEC >::respondToOpenOutputFiles ( FileBlock const &  fb) [virtual]

Reimplemented from edm::EDFilter.

Definition at line 275 of file GeneratorFilter.h.

  { }

Member Data Documentation

template<class HAD , class DEC >
Decayer* edm::GeneratorFilter< HAD, DEC >::decayer_ [private]

Definition at line 59 of file GeneratorFilter.h.

Referenced by edm::GeneratorFilter< HAD, DEC >::GeneratorFilter().

template<class HAD , class DEC >
Hadronizer edm::GeneratorFilter< HAD, DEC >::hadronizer_ [private]

Definition at line 57 of file GeneratorFilter.h.