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::EDConsumerBase 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 &) override
 
virtual ~MixEvtVtxGenerator ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Protected Attributes

TMatrixD * boost_
 
HepMC::FourVector * fVertex
 

Private Attributes

edm::EDGetTokenT
< CrossingFrame< HepMCProduct > > 
cfLabel
 
edm::EDGetTokenT
< reco::VertexCollection
hiLabel
 
edm::EDGetTokenT< HepMCProductsignalLabel
 
bool useCF_
 
bool useRecVertex
 
std::vector< double > vtxOffset
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- 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::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 34 of file MixEvtVtxGenerator.cc.

Constructor & Destructor Documentation

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

Definition at line 64 of file MixEvtVtxGenerator.cc.

References cfLabel, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), hiLabel, signalLabel, useCF_, useRecVertex, and vtxOffset.

65  : fVertex(0), boost_(0),
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 
73  if(useRecVertex) useCF_ = 0;
74  else{
75  useCF_ = pset.getUntrackedParameter<bool>("useCF",false);
76  cfLabel = consumes<CrossingFrame<HepMCProduct> >(pset.getUntrackedParameter<edm::InputTag>("mixLabel",edm::InputTag("mixGen","generator")));
77  }
78  signalLabel = consumes<HepMCProduct>(pset.getParameter<edm::InputTag>("signalLabel"));
79  hiLabel = consumes<reco::VertexCollection>(pset.getParameter<edm::InputTag>("heavyIonLabel"));
80 
81 
82 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< double > vtxOffset
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::EDGetTokenT< CrossingFrame< HepMCProduct > > cfLabel
edm::EDGetTokenT< reco::VertexCollection > hiLabel
edm::EDGetTokenT< HepMCProduct > signalLabel
HepMC::FourVector * fVertex
MixEvtVtxGenerator::~MixEvtVtxGenerator ( )
virtual

Definition at line 84 of file MixEvtVtxGenerator.cc.

References boost_, and fVertex.

85 {
86  delete fVertex ;
87  if (boost_ != 0 ) delete boost_;
88  // no need since now it's done in HepMCProduct
89  // delete fEvt ;
90 }
HepMC::FourVector * fVertex

Member Function Documentation

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

Definition at line 151 of file MixEvtVtxGenerator.cc.

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

Referenced by produce().

151  {
152 
154  evt.getByToken(hiLabel,input);
155 
156  double aX,aY,aZ;
157 
158  aX = input->begin()->position().x() + vtxOffset[0];
159  aY = input->begin()->position().y() + vtxOffset[1];
160  aZ = input->begin()->position().z() + vtxOffset[2];
161 
162  /*
163  std::cout << "reco::Vertex = " << input->begin()->position().x()
164  << ", " << input->begin()->position().y()
165  << ", " << input->begin()->position().z()
166  << std::endl;
167 
168  std::cout << "offset = " << vtxOffset[0]
169  << ", " << vtxOffset[1]
170  << ", " << vtxOffset[2]
171  << std::endl;
172 
173  std::cout << "embedded GEN vertex = " << aX
174  << ", " << aY << ", " << aZ << std::endl;
175 
176  */
177  if(!fVertex) fVertex = new HepMC::FourVector();
178  fVertex->set(10.0*aX,10.0*aY,10.0*aZ,0.0); // HepMC positions in mm (RECO in cm)
179 
180  return fVertex;
181 
182 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
std::vector< double > vtxOffset
static std::string const input
Definition: EdmProvDump.cc:44
edm::EDGetTokenT< reco::VertexCollection > hiLabel
HepMC::FourVector * 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::getByToken(), edm::HepMCProduct::GetEvent(), input, edm::HepMCProduct::isVtxGenApplied(), reco_application_tbsim_DetSim-Digi_cfg::mix, edm::Handle< T >::product(), RecoTauCleanerPlugins::pt, signalLabel, and useCF_.

Referenced by produce().

92  {
93 
94  HepMC::GenVertex* genvtx = 0;
95  const HepMC::GenEvent* inev = 0;
96 
97  //cout<<" use CF "<<useCF_<<endl;
98 
99  if(useCF_){
101  evt.getByToken(cfLabel,cf);
103  if(mix.size() < 2){
104  cout<<"Less than 2 sub-events, mixing seems to have failed!"<<endl;
105  }
106  const HepMCProduct& bkg = mix.getObject(1);
107  if(!(bkg.isVtxGenApplied())){
108  cout<<"Input does not have smeared vertex!"<<endl;
109  }else{
110  inev = bkg.GetEvent();
111  }
112  }else{
113  //cout<<" hiLabel "<<hiLabel<<endl;
115  evt.getByToken(signalLabel,input);
116  inev = input->GetEvent();
117  }
118 
119  genvtx = inev->signal_process_vertex();
120  if(!genvtx){
121  //cout<<"No Signal Process Vertex!"<<endl;
122  HepMC::GenEvent::particle_const_iterator pt=inev->particles_begin();
123  HepMC::GenEvent::particle_const_iterator ptend=inev->particles_end();
124  while(!genvtx || ( genvtx->particles_in_size() == 1 && pt != ptend ) ){
125  //if(!genvtx) cout<<"No Gen Vertex!"<<endl;
126  if(pt == ptend) cout<<"End reached, No Gen Vertex!"<<endl;
127  genvtx = (*pt)->production_vertex();
128  ++pt;
129  }
130  }
131  double aX,aY,aZ,aT;
132 
133  aX = genvtx->position().x();
134  aY = genvtx->position().y();
135  aZ = genvtx->position().z();
136  aT = genvtx->position().t();
137 
138  if(!fVertex){
139  fVertex = new HepMC::FourVector();
140  //cout<<" creating new vertex "<<endl;
141  }
142  //cout<<" setting vertex "<<" aX "<<aX<<" aY "<<aY<<" aZ "<<aZ<<" aT "<<aT<<endl;
143  fVertex->set(aX,aY,aZ,aT);
144 
145 
146  return fVertex;
147 
148 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
static std::string const input
Definition: EdmProvDump.cc:44
edm::EDGetTokenT< CrossingFrame< HepMCProduct > > cfLabel
edm::EDGetTokenT< HepMCProduct > signalLabel
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:35
HepMC::FourVector * fVertex
bool isVtxGenApplied() const
Definition: HepMCProduct.h:37
T const * product() const
Definition: Handle.h:81
tuple cout
Definition: gather_cfg.py:121
void MixEvtVtxGenerator::produce ( edm::Event evt,
const edm::EventSetup  
)
overridevirtual

Implements edm::EDProducer.

Definition at line 184 of file MixEvtVtxGenerator.cc.

References edm::Event::getByToken(), getRecVertex(), getVertex(), edm::Event::put(), reco::return(), signalLabel, and useRecVertex.

185 {
186 
187 
188  Handle<HepMCProduct> HepMCEvt ;
189 
190  evt.getByToken( signalLabel, HepMCEvt ) ;
191 
192  // generate new vertex & apply the shift
193  //
194 
195  HepMCEvt->applyVtxGen( useRecVertex ? getRecVertex(evt) : getVertex(evt) ) ;
196 
197  // HepMCEvt->boostToLab( GetInvLorentzBoost(), "vertex" );
198  // HepMCEvt->boostToLab( GetInvLorentzBoost(), "momentum" );
199 
200  // OK, create a (pseudo)product and put in into edm::Event
201  //
202  auto_ptr<bool> NewProduct(new bool(true)) ;
203  evt.put( NewProduct ,"matchedVertex") ;
204 
205  return ;
206 
207 }
virtual HepMC::FourVector * getRecVertex(edm::Event &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
virtual HepMC::FourVector * getVertex(edm::Event &)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
edm::EDGetTokenT< HepMCProduct > signalLabel
return(e1-e2)*(e1-e2)+dp *dp

Member Data Documentation

TMatrixD* MixEvtVtxGenerator::boost_
protected

Definition at line 50 of file MixEvtVtxGenerator.cc.

Referenced by ~MixEvtVtxGenerator().

edm::EDGetTokenT<CrossingFrame<HepMCProduct> > MixEvtVtxGenerator::cfLabel
private

Definition at line 56 of file MixEvtVtxGenerator.cc.

Referenced by getVertex(), and MixEvtVtxGenerator().

HepMC::FourVector* MixEvtVtxGenerator::fVertex
protected

Definition at line 49 of file MixEvtVtxGenerator.cc.

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

edm::EDGetTokenT<reco::VertexCollection> MixEvtVtxGenerator::hiLabel
private

Definition at line 54 of file MixEvtVtxGenerator.cc.

Referenced by getRecVertex(), and MixEvtVtxGenerator().

edm::EDGetTokenT<HepMCProduct> MixEvtVtxGenerator::signalLabel
private

Definition at line 55 of file MixEvtVtxGenerator.cc.

Referenced by getVertex(), MixEvtVtxGenerator(), and produce().

bool MixEvtVtxGenerator::useCF_
private

Definition at line 60 of file MixEvtVtxGenerator.cc.

Referenced by getVertex(), and MixEvtVtxGenerator().

bool MixEvtVtxGenerator::useRecVertex
private

Definition at line 58 of file MixEvtVtxGenerator.cc.

Referenced by MixEvtVtxGenerator(), and produce().

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

Definition at line 59 of file MixEvtVtxGenerator.cc.

Referenced by getRecVertex(), and MixEvtVtxGenerator().