CMS 3D CMS Logo

Public Member Functions | Protected Attributes | Private Attributes

MixEvtVtxGenerator Class Reference

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

List of all members.

Public Member Functions

virtual HepMC::FourVector * getRecVertex (edm::Event &)
virtual HepMC::FourVector * getVertex (edm::Event &)
 MixEvtVtxGenerator (const edm::ParameterSet &)
virtual void produce (edm::Event &, const edm::EventSetup &)
virtual ~MixEvtVtxGenerator ()

Protected Attributes

TMatrixD * boost_
HepMC::FourVector * fVertex

Private Attributes

edm::InputTag hiLabel
edm::InputTag signalLabel
bool useRecVertex
std::vector< double > vtxOffset

Detailed Description

Definition at line 35 of file MixEvtVtxGenerator.cc.


Constructor & Destructor Documentation

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

Definition at line 62 of file MixEvtVtxGenerator.cc.

References edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), and vtxOffset.

        : fVertex(0), boost_(0),
          signalLabel(pset.getParameter<edm::InputTag>("signalLabel")),
          hiLabel(pset.getParameter<edm::InputTag>("heavyIonLabel")),
          useRecVertex(pset.exists("useRecVertex")?pset.getParameter<bool>("useRecVertex"):false)
          
{   
   produces<bool>("matchedVertex"); 
   vtxOffset.resize(3);
   if(pset.exists("vtxOffset")) vtxOffset=pset.getParameter< std::vector<double> >("vtxOffset");
}
MixEvtVtxGenerator::~MixEvtVtxGenerator ( ) [virtual]

Definition at line 74 of file MixEvtVtxGenerator.cc.

References boost_, and fVertex.

{
   delete fVertex ;
   if (boost_ != 0 ) delete boost_;
   // no need since now it's done in HepMCProduct
   // delete fEvt ;
}

Member Function Documentation

HepMC::FourVector * MixEvtVtxGenerator::getRecVertex ( edm::Event evt) [virtual]

Definition at line 115 of file MixEvtVtxGenerator.cc.

References fVertex, edm::Event::getByLabel(), hiLabel, collect_tpl::input, and vtxOffset.

Referenced by produce().

                                                            {

  Handle<reco::VertexCollection> input;
  evt.getByLabel(hiLabel,input);

  double aX,aY,aZ;

  aX = input->begin()->position().x() + vtxOffset[0];
  aY = input->begin()->position().y() + vtxOffset[1];
  aZ = input->begin()->position().z() + vtxOffset[2];

  /*
  std::cout << "reco::Vertex = " << input->begin()->position().x()
            << ", " << input->begin()->position().y()
            << ", " << input->begin()->position().z()
            << std::endl;

  std::cout << "offset = " << vtxOffset[0]
            << ", " << vtxOffset[1]
            << ", " << vtxOffset[2]
            << std::endl;

  std::cout << "embedded GEN vertex = " << aX
            << ", " << aY << ", " << aZ << std::endl;
  */
  
  if(!fVertex) fVertex = new HepMC::FourVector();
  fVertex->set(10.0*aX,10.0*aY,10.0*aZ,0.0); // HepMC positions in mm (RECO in cm)
  
  return fVertex;

}
HepMC::FourVector * MixEvtVtxGenerator::getVertex ( edm::Event evt) [virtual]

Definition at line 82 of file MixEvtVtxGenerator.cc.

References gather_cfg::cout, fVertex, edm::Event::getByLabel(), hiLabel, collect_tpl::input, and ExpressReco_HICollisions_FallBack::pt.

Referenced by produce().

                                                         {

  Handle<HepMCProduct> input;
  evt.getByLabel(hiLabel,input);

  const HepMC::GenEvent* inev = input->GetEvent();
  HepMC::GenVertex* genvtx = inev->signal_process_vertex();
  if(!genvtx){
    cout<<"No Signal Process Vertex!"<<endl;
    HepMC::GenEvent::particle_const_iterator pt=inev->particles_begin();
    HepMC::GenEvent::particle_const_iterator ptend=inev->particles_end();
    while(!genvtx || ( genvtx->particles_in_size() == 1 && pt != ptend ) ){
      if(!genvtx) cout<<"No Gen Vertex!"<<endl;
      if(pt == ptend) cout<<"End reached!"<<endl;
      genvtx = (*pt)->production_vertex();
      ++pt;
    }
  }
  double aX,aY,aZ,aT;

  aX = genvtx->position().x();
  aY = genvtx->position().y();
  aZ = genvtx->position().z();
  aT = genvtx->position().t();
  
  if(!fVertex) fVertex = new HepMC::FourVector();
  fVertex->set(aX,aY,aZ,aT);
  
  return fVertex;

}
void MixEvtVtxGenerator::produce ( edm::Event evt,
const edm::EventSetup  
) [virtual]

Implements edm::EDProducer.

Definition at line 148 of file MixEvtVtxGenerator.cc.

References edm::Event::getByLabel(), getRecVertex(), getVertex(), edm::Event::put(), signalLabel, and useRecVertex.

{
   
   
   Handle<HepMCProduct> HepMCEvt ;
   
   evt.getByLabel( signalLabel, HepMCEvt ) ;
   
   // generate new vertex & apply the shift 
   //

   HepMCEvt->applyVtxGen( useRecVertex ? getRecVertex(evt) : getVertex(evt) ) ;

   //   HepMCEvt->boostToLab( GetInvLorentzBoost(), "vertex" );
   //   HepMCEvt->boostToLab( GetInvLorentzBoost(), "momentum" );
   
   // OK, create a (pseudo)product and put in into edm::Event
   //
   auto_ptr<bool> NewProduct(new bool(true)) ;      
   evt.put( NewProduct ,"matchedVertex") ;
      
   return ;

}

Member Data Documentation

TMatrixD* MixEvtVtxGenerator::boost_ [protected]

Definition at line 51 of file MixEvtVtxGenerator.cc.

Referenced by ~MixEvtVtxGenerator().

HepMC::FourVector* MixEvtVtxGenerator::fVertex [protected]

Definition at line 50 of file MixEvtVtxGenerator.cc.

Referenced by getRecVertex(), getVertex(), and ~MixEvtVtxGenerator().

Definition at line 56 of file MixEvtVtxGenerator.cc.

Referenced by getRecVertex(), and getVertex().

Definition at line 55 of file MixEvtVtxGenerator.cc.

Referenced by produce().

Definition at line 57 of file MixEvtVtxGenerator.cc.

Referenced by produce().

std::vector<double> MixEvtVtxGenerator::vtxOffset [private]

Definition at line 58 of file MixEvtVtxGenerator.cc.

Referenced by getRecVertex(), and MixEvtVtxGenerator().