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 | cfLabel |
edm::InputTag | hiLabel |
edm::InputTag | signalLabel |
bool | useCF_ |
bool | useRecVertex |
std::vector< double > | vtxOffset |
Definition at line 36 of file MixEvtVtxGenerator.cc.
MixEvtVtxGenerator::MixEvtVtxGenerator | ( | const edm::ParameterSet & | pset | ) | [explicit] |
Definition at line 66 of file MixEvtVtxGenerator.cc.
References cfLabel, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), useCF_, useRecVertex, 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"); if(useRecVertex) useCF_ = 0; else{ useCF_ = pset.getUntrackedParameter<bool>("useCF",false); cfLabel = pset.getUntrackedParameter<edm::InputTag>("mixLabel",edm::InputTag("mixGen","generator")); } }
MixEvtVtxGenerator::~MixEvtVtxGenerator | ( | ) | [virtual] |
HepMC::FourVector * MixEvtVtxGenerator::getRecVertex | ( | edm::Event & | evt | ) | [virtual] |
Definition at line 151 of file MixEvtVtxGenerator.cc.
References fVertex, edm::Event::getByLabel(), hiLabel, LaserDQM_cfg::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 92 of file MixEvtVtxGenerator.cc.
References cfLabel, gather_cfg::cout, fVertex, edm::Event::getByLabel(), edm::HepMCProduct::GetEvent(), hiLabel, LaserDQM_cfg::input, edm::HepMCProduct::isVtxGenApplied(), reco_application_tbsim_DetSim-Digi_cfg::mix, edm::Handle< T >::product(), and useCF_.
Referenced by produce().
{ HepMC::GenVertex* genvtx = 0; const HepMC::GenEvent* inev = 0; //cout<<" use CF "<<useCF_<<endl; if(useCF_){ Handle<CrossingFrame<HepMCProduct> > cf; evt.getByLabel(cfLabel,cf); MixCollection<HepMCProduct> mix(cf.product()); if(mix.size() < 2){ cout<<"Less than 2 sub-events, mixing seems to have failed!"<<endl; } const HepMCProduct& bkg = mix.getObject(1); if(!(bkg.isVtxGenApplied())){ cout<<"Input does not have smeared vertex!"<<endl; }else{ inev = bkg.GetEvent(); } }else{ //cout<<" hiLabel "<<hiLabel<<endl; Handle<HepMCProduct> input; evt.getByLabel(hiLabel,input); inev = input->GetEvent(); } 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, No Gen Vertex!"<<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(); //cout<<" creating new vertex "<<endl; } //cout<<" setting vertex "<<" aX "<<aX<<" aY "<<aY<<" aZ "<<aZ<<" aT "<<aT<<endl; fVertex->set(aX,aY,aZ,aT); return fVertex; }
void MixEvtVtxGenerator::produce | ( | edm::Event & | evt, |
const edm::EventSetup & | |||
) | [virtual] |
Implements edm::EDProducer.
Definition at line 184 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 ; }
TMatrixD* MixEvtVtxGenerator::boost_ [protected] |
Definition at line 52 of file MixEvtVtxGenerator.cc.
Referenced by ~MixEvtVtxGenerator().
edm::InputTag MixEvtVtxGenerator::cfLabel [private] |
Definition at line 58 of file MixEvtVtxGenerator.cc.
Referenced by getVertex(), and MixEvtVtxGenerator().
HepMC::FourVector* MixEvtVtxGenerator::fVertex [protected] |
Definition at line 51 of file MixEvtVtxGenerator.cc.
Referenced by getRecVertex(), getVertex(), and ~MixEvtVtxGenerator().
edm::InputTag MixEvtVtxGenerator::hiLabel [private] |
Definition at line 57 of file MixEvtVtxGenerator.cc.
Referenced by getRecVertex(), and getVertex().
edm::InputTag MixEvtVtxGenerator::signalLabel [private] |
Definition at line 56 of file MixEvtVtxGenerator.cc.
Referenced by produce().
bool MixEvtVtxGenerator::useCF_ [private] |
Definition at line 62 of file MixEvtVtxGenerator.cc.
Referenced by getVertex(), and MixEvtVtxGenerator().
bool MixEvtVtxGenerator::useRecVertex [private] |
Definition at line 60 of file MixEvtVtxGenerator.cc.
Referenced by MixEvtVtxGenerator(), and produce().
std::vector<double> MixEvtVtxGenerator::vtxOffset [private] |
Definition at line 61 of file MixEvtVtxGenerator.cc.
Referenced by getRecVertex(), and MixEvtVtxGenerator().