CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

LHECOMWeightProducer Class Reference

Inheritance diagram for LHECOMWeightProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 LHECOMWeightProducer (const edm::ParameterSet &)
 ~LHECOMWeightProducer ()

Private Member Functions

virtual void beginJob ()
virtual void beginRun (edm::Run &run, const edm::EventSetup &es)
virtual void endJob ()
virtual void produce (edm::Event &, const edm::EventSetup &)

Private Attributes

std::string _label
double _newECMS
double _origECMS
int _pdfmember
int _pdfset
edm::InputTag lheTag_

Detailed Description

Definition at line 23 of file LHECOMWeightProducer.cc.


Constructor & Destructor Documentation

LHECOMWeightProducer::LHECOMWeightProducer ( const edm::ParameterSet pset) [explicit]

Definition at line 56 of file LHECOMWeightProducer.cc.

References _label, and _newECMS.

                                                                      :
 lheTag_(pset.getParameter<edm::InputTag> ("lheSrc")),
 _newECMS(pset.getParameter< double > ("NewECMS"))
{
  std::stringstream labelStr;
  labelStr << "com" << "To" << _newECMS;
  _label = labelStr.str();
  produces<GenEventInfoProduct>(_label);
} 
LHECOMWeightProducer::~LHECOMWeightProducer ( )

Definition at line 67 of file LHECOMWeightProducer.cc.

{}

Member Function Documentation

void LHECOMWeightProducer::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 86 of file LHECOMWeightProducer.cc.

                                    {
  //LHAPDF::initPDFSet(1,pdfSetName_);
}
void LHECOMWeightProducer::beginRun ( edm::Run run,
const edm::EventSetup es 
) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 70 of file LHECOMWeightProducer.cc.

References _newECMS, _origECMS, _pdfmember, _pdfset, Exception, edm::Run::getByLabel(), LHAPDF::initPDFSet(), and lheTag_.

                                                                       {
  using namespace edm;
  Handle<LHERunInfoProduct> lheRun;
  run.getByLabel(lheTag_, lheRun);
  //assumes the same pdf is used for both beams
  _pdfset    = lheRun->heprup().PDFSUP.first;
  _pdfmember = lheRun->heprup().PDFGUP.first;
  _origECMS  = lheRun->heprup().EBMUP.first + lheRun->heprup().EBMUP.second;
  edm::LogInfo("LHECOMWeightProducer") << "PDFSET: " << _pdfset << "; member: " << _pdfmember << "; COM energy: " << _origECMS;
  if ( _newECMS > _origECMS )
      throw cms::Exception("LHECOMWeightProducer") << "You cannot reweight COM energy to a higher than original energy ";
  LHAPDF::initPDFSet(1,_pdfset, _pdfmember);
}
void LHECOMWeightProducer::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 91 of file LHECOMWeightProducer.cc.

{}
void LHECOMWeightProducer::produce ( edm::Event iEvent,
const edm::EventSetup  
) [private, virtual]

Implements edm::EDProducer.

Definition at line 94 of file LHECOMWeightProducer.cc.

References _label, _newECMS, _origECMS, _pdfmember, _pdfset, gather_cfg::cout, edm::Event::getByLabel(), info, edm::EventBase::isRealData(), lheTag_, LogTrace, edm::Event::put(), LHAPDF::usePDFMember(), CommonMethods::weight(), and LHAPDF::xfx().

                                                                         {

      using namespace std;
      bool verbose = false;

      if (iEvent.isRealData()) return;

      edm::Handle<LHEEventProduct> lheevent;
      iEvent.getByLabel(lheTag_, lheevent);

      float Q = lheevent->hepeup().SCALUP;

      int id1        = lheevent->hepeup().IDUP[0];
      double x1      = fabs(lheevent->hepeup().PUP[0][2]/(_origECMS/2));
      double x1prime = fabs(lheevent->hepeup().PUP[0][2]/(_newECMS/2));

      int id2        = lheevent->hepeup().IDUP[1];
      double x2      = fabs(lheevent->hepeup().PUP[1][2]/(_origECMS/2));
      double x2prime = fabs(lheevent->hepeup().PUP[1][2]/(_newECMS/2));

      LogTrace("LHECOMWeightProducer") << "*******LHECOMWeightProducer*******\n" << 
                                          " Q  : " << Q << "\n" <<
                                          " id1: " << id1 << "\n" <<
                                          " x1 : " << x1  << "\n" <<
                                          " x1': " << x1prime << "\n" <<
                                          " id2: " << id2 << "\n" <<
                                          " x2 : " << x2  << "\n" <<
                                          " x2': " << x2prime ;
      //gluon is 0 in the LHAPDF numbering
      if (id1 == 21)
        id1 = 0;
      if (id2 == 21)
        id2 = 0;

      // Put PDF weights in the event
      if (verbose)
        cout << " Set : " << _pdfset << "  member : " << _pdfmember << endl;
     
      LHAPDF::usePDFMember(1,_pdfmember);
      double oldpdf1 = LHAPDF::xfx(1, x1, Q, id1)/x1;
      double oldpdf2 = LHAPDF::xfx(1, x2, Q, id2)/x2;
      double newpdf1 = LHAPDF::xfx(1, x1prime, Q, id1)/x1prime;
      double newpdf2 = LHAPDF::xfx(1, x2prime, Q, id2)/x2prime;
      LogTrace("LHECOMWeightProducer") <<
          "     xfx1 : " << oldpdf1 << "\n" <<
          "     xfx2 : " << oldpdf2 << "\n" <<
          "     xfx1': " << newpdf1 << "\n" <<
          "     xfx2': " << newpdf2 << "\n" <<
          "     weight:" << (newpdf1/oldpdf1)*(newpdf2/oldpdf2);
      double weight = (newpdf1/oldpdf1)*(newpdf2/oldpdf2);
      std::vector<double> weights;
      weights.push_back(weight);
      std::auto_ptr<GenEventInfoProduct> info(new GenEventInfoProduct());
      info->setWeights(weights);
      iEvent.put(info, _label);
}

Member Data Documentation

std::string LHECOMWeightProducer::_label [private]

Definition at line 39 of file LHECOMWeightProducer.cc.

Referenced by LHECOMWeightProducer(), and produce().

Definition at line 38 of file LHECOMWeightProducer.cc.

Referenced by beginRun(), LHECOMWeightProducer(), and produce().

Definition at line 37 of file LHECOMWeightProducer.cc.

Referenced by beginRun(), and produce().

Definition at line 36 of file LHECOMWeightProducer.cc.

Referenced by beginRun(), and produce().

Definition at line 35 of file LHECOMWeightProducer.cc.

Referenced by beginRun(), and produce().

Definition at line 34 of file LHECOMWeightProducer.cc.

Referenced by beginRun(), and produce().