CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

MCVerticesWeight Class Reference

#include <Validation/RecoVertex/MCVerticesWeight.cc>

Inheritance diagram for MCVerticesWeight:
edm::EDFilter edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

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

Private Member Functions

virtual void beginJob ()
virtual void endJob ()
virtual bool filter (edm::Event &, const edm::EventSetup &)

Private Attributes

edm::InputTag m_mctruthcollection
edm::InputTag m_pileupcollection
const VertexWeighter m_weighter

Detailed Description

Description:

Implementation: <Notes on="" implementation>="">

Definition at line 49 of file MCVerticesWeight.cc.


Constructor & Destructor Documentation

MCVerticesWeight::MCVerticesWeight ( const edm::ParameterSet iConfig) [explicit]

Definition at line 78 of file MCVerticesWeight.cc.

                                                                :
  m_pileupcollection(iConfig.getParameter<edm::InputTag>("pileupSummaryCollection")),
  m_mctruthcollection(iConfig.getParameter<edm::InputTag>("mcTruthCollection")),
  m_weighter(iConfig.getParameter<edm::ParameterSet>("weighterConfig"))
{

  produces<double>();

}
MCVerticesWeight::~MCVerticesWeight ( )

Definition at line 88 of file MCVerticesWeight.cc.

{
 
   // do anything here that needs to be done at desctruction time
   // (e.g. close files, deallocate resources etc.)

}

Member Function Documentation

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

Reimplemented from edm::EDFilter.

Definition at line 168 of file MCVerticesWeight.cc.

{
}
void MCVerticesWeight::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDFilter.

Definition at line 174 of file MCVerticesWeight.cc.

                         {
}
bool MCVerticesWeight::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDFilter.

Definition at line 103 of file MCVerticesWeight.cc.

References edm::Event::getByLabel(), m_mctruthcollection, m_pileupcollection, m_weighter, edm::Event::put(), VertexWeighter::weight(), and histoStyle::weight.

{
  using namespace edm;
  
  bool selected = true;
  
  double computed_weight(1);

  Handle<std::vector<PileupSummaryInfo> > pileupinfos;
   iEvent.getByLabel(m_pileupcollection,pileupinfos);


  // look for the intime PileupSummaryInfo

   std::vector<PileupSummaryInfo>::const_iterator pileupinfo;
   for(pileupinfo = pileupinfos->begin(); pileupinfo != pileupinfos->end() ; ++pileupinfo) {
     if(pileupinfo->getBunchCrossing()==0) break;
   } 
   
   //
   if(pileupinfo->getBunchCrossing()!=0) {
     edm::LogError("NoInTimePileUpInfo") << "Cannot find the in-time pileup info " << pileupinfo->getBunchCrossing();
   }
   else {
     
     //     pileupinfo->getPU_NumInteractions();
     
     const std::vector<float>& zpositions = pileupinfo->getPU_zpositions();
     
     //     for(std::vector<float>::const_iterator zpos = zpositions.begin() ; zpos != zpositions.end() ; ++zpos) {
       
     //     }
     
     // main interaction part
     
     Handle< HepMCProduct > EvtHandle ;
     iEvent.getByLabel(m_mctruthcollection, EvtHandle ) ;
     
     const HepMC::GenEvent* Evt = EvtHandle->GetEvent();
     
     // get the first vertex
     
     double zmain = 0.0;
     if(Evt->vertices_begin() != Evt->vertices_end()) {
       zmain = (*Evt->vertices_begin())->point3d().z()/10.;
     }
     
     //
    
     
     computed_weight = m_weighter.weight(zpositions,zmain);
     
   }
   
   std::auto_ptr<double> weight(new double(computed_weight));
   
   iEvent.put(weight);
   
   //
   
  return selected;
}

Member Data Documentation

Definition at line 62 of file MCVerticesWeight.cc.

Referenced by filter().

Definition at line 61 of file MCVerticesWeight.cc.

Referenced by filter().

Definition at line 63 of file MCVerticesWeight.cc.

Referenced by filter().