CMS 3D CMS Logo

Public Types | Public Member Functions | Private Attributes

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

#include <HadronizerFilter.h>

Inheritance diagram for edm::HadronizerFilter< 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)
 HadronizerFilter (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 ~HadronizerFilter ()

Private Attributes

Decayerdecayer_
Hadronizer hadronizer_

Detailed Description

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

Definition at line 40 of file HadronizerFilter.h.


Member Typedef Documentation

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

Definition at line 44 of file HadronizerFilter.h.

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

Definition at line 43 of file HadronizerFilter.h.


Constructor & Destructor Documentation

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

Definition at line 75 of file HadronizerFilter.h.

References edm::HadronizerFilter< 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:
    //   * LHEGeneratorInfo
    //   * LHEEvent
    //   * HepMCProduct
    // But I can not find the LHEGeneratorInfo class; it might need to
    // be invented.

    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::HadronizerFilter< HAD, DEC >::~HadronizerFilter ( ) [virtual]

Definition at line 102 of file HadronizerFilter.h.

  { if (decayer_) delete decayer_; }

Member Function Documentation

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

Reimplemented from edm::EDFilter.

Definition at line 249 of file HadronizerFilter.h.

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

  {
   
    if (! hadronizer_.initializeForExternalPartons())
      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()
            << " for internal parton generation\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::HadronizerFilter< HAD, DEC >::beginRun ( Run run,
EventSetup const &  es 
) [virtual]

Reimplemented from edm::EDFilter.

Definition at line 179 of file HadronizerFilter.h.

References edm::Run::getByLabel().

  {
    
/*
    // init post-generation tools
    // we do it here to mimic the order as it was with beginJob
    //
    if ( decayer_ ) decayer_->init(es);
*/    
    
    // this is run-specific
    
    // get LHE stuff and pass to hadronizer!

    edm::Handle<LHERunInfoProduct> product;
    run.getByLabel("source", product);

    hadronizer_.setLHERunInfo( new lhef::LHERunInfo(*product) ) ;
   
/*
    if (! hadronizer_.initializeForExternalPartons())
      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::HadronizerFilter< HAD, DEC >::endJob ( void  ) [virtual]

Reimplemented from edm::EDFilter.

Definition at line 174 of file HadronizerFilter.h.

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

Reimplemented from edm::EDFilter.

Definition at line 281 of file HadronizerFilter.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::HadronizerFilter< HAD, DEC >::endRun ( Run r,
EventSetup const &   
) [virtual]

Reimplemented from edm::EDFilter.

Definition at line 221 of file HadronizerFilter.h.

References lhef::LHERunInfo::XSec::error, edm::Run::put(), GenRunInfoProduct::setInternalXSec(), lhef::LHERunInfo::statistics(), lhef::LHERunInfo::XSec::value, and lhef::LHERunInfo::xsec().

  {
    // Retrieve the LHE run info summary and transfer determined
    // cross-section into the generator run info

    const lhef::LHERunInfo* lheRunInfo = hadronizer_.getLHERunInfo().get();
    lhef::LHERunInfo::XSec xsec = lheRunInfo->xsec();

    GenRunInfoProduct& genRunInfo = hadronizer_.getGenRunInfo();
    genRunInfo.setInternalXSec( GenRunInfoProduct::XSec(xsec.value, xsec.error) );

    // 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();
    lheRunInfo->statistics();

    std::auto_ptr<GenRunInfoProduct> griproduct( new GenRunInfoProduct(genRunInfo) );
    r.put(griproduct);
    
    return true;
  }
template<class HAD , class DEC >
bool edm::HadronizerFilter< HAD, DEC >::filter ( Event e,
EventSetup const &  es 
) [virtual]

Implements edm::EDFilter.

Definition at line 107 of file HadronizerFilter.h.

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

  {
    hadronizer_.setEDMEvent(ev);

    // get LHE stuff and pass to hadronizer!
    //
    edm::Handle<LHEEventProduct> product;
    ev.getByLabel("source", product);

    lhef::LHEEvent *lheEvent =
                new lhef::LHEEvent(hadronizer_.getLHERunInfo(), *product);
    hadronizer_.setLHEEvent( lheEvent );
    
    // hadronizer_.generatePartons();
    if ( !hadronizer_.hadronize() ) 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 packges
    //
    hadronizer_.resetEvent( event.release() );
    if ( !hadronizer_.residualDecay() ) return false;

    hadronizer_.finalizeEvent();

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

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

    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::HadronizerFilter< HAD, DEC >::respondToCloseInputFile ( FileBlock const &  fb) [virtual]

Reimplemented from edm::EDFilter.

Definition at line 297 of file HadronizerFilter.h.

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

Reimplemented from edm::EDFilter.

Definition at line 307 of file HadronizerFilter.h.

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

Reimplemented from edm::EDFilter.

Definition at line 292 of file HadronizerFilter.h.

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

Reimplemented from edm::EDFilter.

Definition at line 302 of file HadronizerFilter.h.

  { }

Member Data Documentation

template<class HAD , class DEC >
Decayer* edm::HadronizerFilter< HAD, DEC >::decayer_ [private]
template<class HAD , class DEC >
Hadronizer edm::HadronizerFilter< HAD, DEC >::hadronizer_ [private]

Definition at line 64 of file HadronizerFilter.h.