CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Attributes | Private Attributes
MixEvtVtxGenerator Class Reference
Inheritance diagram for MixEvtVtxGenerator:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

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 ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Protected Attributes

TMatrixD * boost_
 
HepMC::FourVector * fVertex
 

Private Attributes

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

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

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.

63  : fVertex(0), boost_(0),
64  signalLabel(pset.getParameter<edm::InputTag>("signalLabel")),
65  hiLabel(pset.getParameter<edm::InputTag>("heavyIonLabel")),
66  useRecVertex(pset.exists("useRecVertex")?pset.getParameter<bool>("useRecVertex"):false)
67 
68 {
69  produces<bool>("matchedVertex");
70  vtxOffset.resize(3);
71  if(pset.exists("vtxOffset")) vtxOffset=pset.getParameter< std::vector<double> >("vtxOffset");
72 }
T getParameter(std::string const &) const
std::vector< double > vtxOffset
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::InputTag signalLabel
HepMC::FourVector * fVertex
MixEvtVtxGenerator::~MixEvtVtxGenerator ( )
virtual

Definition at line 74 of file MixEvtVtxGenerator.cc.

References boost_, and fVertex.

75 {
76  delete fVertex ;
77  if (boost_ != 0 ) delete boost_;
78  // no need since now it's done in HepMCProduct
79  // delete fEvt ;
80 }
HepMC::FourVector * fVertex

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, LaserDQM_cfg::input, and vtxOffset.

Referenced by produce().

115  {
116 
118  evt.getByLabel(hiLabel,input);
119 
120  double aX,aY,aZ;
121 
122  aX = input->begin()->position().x() + vtxOffset[0];
123  aY = input->begin()->position().y() + vtxOffset[1];
124  aZ = input->begin()->position().z() + vtxOffset[2];
125 
126  /*
127  std::cout << "reco::Vertex = " << input->begin()->position().x()
128  << ", " << input->begin()->position().y()
129  << ", " << input->begin()->position().z()
130  << std::endl;
131 
132  std::cout << "offset = " << vtxOffset[0]
133  << ", " << vtxOffset[1]
134  << ", " << vtxOffset[2]
135  << std::endl;
136 
137  std::cout << "embedded GEN vertex = " << aX
138  << ", " << aY << ", " << aZ << std::endl;
139  */
140 
141  if(!fVertex) fVertex = new HepMC::FourVector();
142  fVertex->set(10.0*aX,10.0*aY,10.0*aZ,0.0); // HepMC positions in mm (RECO in cm)
143 
144  return fVertex;
145 
146 }
std::vector< double > vtxOffset
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
HepMC::FourVector * 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, and LaserDQM_cfg::input.

Referenced by produce().

82  {
83 
85  evt.getByLabel(hiLabel,input);
86 
87  const HepMC::GenEvent* inev = input->GetEvent();
88  HepMC::GenVertex* genvtx = inev->signal_process_vertex();
89  if(!genvtx){
90  cout<<"No Signal Process Vertex!"<<endl;
91  HepMC::GenEvent::particle_const_iterator pt=inev->particles_begin();
92  HepMC::GenEvent::particle_const_iterator ptend=inev->particles_end();
93  while(!genvtx || ( genvtx->particles_in_size() == 1 && pt != ptend ) ){
94  if(!genvtx) cout<<"No Gen Vertex!"<<endl;
95  if(pt == ptend) cout<<"End reached!"<<endl;
96  genvtx = (*pt)->production_vertex();
97  ++pt;
98  }
99  }
100  double aX,aY,aZ,aT;
101 
102  aX = genvtx->position().x();
103  aY = genvtx->position().y();
104  aZ = genvtx->position().z();
105  aT = genvtx->position().t();
106 
107  if(!fVertex) fVertex = new HepMC::FourVector();
108  fVertex->set(aX,aY,aZ,aT);
109 
110  return fVertex;
111 
112 }
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
HepMC::FourVector * fVertex
tuple cout
Definition: gather_cfg.py:121
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(), hitfit::return, signalLabel, and useRecVertex.

149 {
150 
151 
152  Handle<HepMCProduct> HepMCEvt ;
153 
154  evt.getByLabel( signalLabel, HepMCEvt ) ;
155 
156  // generate new vertex & apply the shift
157  //
158 
159  HepMCEvt->applyVtxGen( useRecVertex ? getRecVertex(evt) : getVertex(evt) ) ;
160 
161  // HepMCEvt->boostToLab( GetInvLorentzBoost(), "vertex" );
162  // HepMCEvt->boostToLab( GetInvLorentzBoost(), "momentum" );
163 
164  // OK, create a (pseudo)product and put in into edm::Event
165  //
166  auto_ptr<bool> NewProduct(new bool(true)) ;
167  evt.put( NewProduct ,"matchedVertex") ;
168 
169  return ;
170 
171 }
virtual HepMC::FourVector * getRecVertex(edm::Event &)
virtual HepMC::FourVector * getVertex(edm::Event &)
edm::InputTag signalLabel
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356

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().

edm::InputTag MixEvtVtxGenerator::hiLabel
private

Definition at line 56 of file MixEvtVtxGenerator.cc.

Referenced by getRecVertex(), and getVertex().

edm::InputTag MixEvtVtxGenerator::signalLabel
private

Definition at line 55 of file MixEvtVtxGenerator.cc.

Referenced by produce().

bool MixEvtVtxGenerator::useRecVertex
private

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().