CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
MixBoostEvtVtxGenerator Class Reference
Inheritance diagram for MixBoostEvtVtxGenerator:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

void Alpha (double m=0)
 angle between crossing plane and horizontal plane More...
 
void Beta (double m=0)
 
double BetaFunction (double z, double z0)
 beta function More...
 
void betastar (double m=0)
 set beta_star More...
 
void emittance (double m=0)
 emittance (no the normalized) More...
 
virtual TMatrixD * GetInvLorentzBoost ()
 
virtual HepMC::FourVector * getRecVertex (edm::Event &)
 
virtual HepMC::FourVector * getVertex (edm::Event &)
 
 MixBoostEvtVtxGenerator (const edm::ParameterSet &p)
 
void Phi (double m=0)
 set half crossing angle More...
 
virtual void produce (edm::Event &, const edm::EventSetup &) override
 return a new event vertex More...
 
void sigmaZ (double s=1.0)
 set resolution in Z in cm More...
 
void X0 (double m=0)
 set mean in X in cm More...
 
void Y0 (double m=0)
 set mean in Y in cm More...
 
void Z0 (double m=0)
 set mean in Z in cm More...
 
virtual ~MixBoostEvtVtxGenerator ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

 MixBoostEvtVtxGenerator (const MixBoostEvtVtxGenerator &p)
 
MixBoostEvtVtxGeneratoroperator= (const MixBoostEvtVtxGenerator &rhs)
 

Private Attributes

double alpha_
 
double beta_
 
TMatrixD * boost_
 
double falpha
 
double fbetastar
 
double femittance
 
double fSigmaZ
 
double fTimeOffset
 
HepMC::FourVector * fVertex
 
double fX0
 
double fY0
 
double fZ0
 
edm::EDGetTokenT< CrossingFrame< HepMCProduct > > mixLabel
 
double phi_
 
edm::EDGetTokenT< HepMCProductsignalLabel
 
bool useRecVertex
 
edm::EDGetTokenT< reco::VertexCollectionvtxLabel
 
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
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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::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 50 of file MixBoostEvtVtxGenerator.cc.

Constructor & Destructor Documentation

MixBoostEvtVtxGenerator::MixBoostEvtVtxGenerator ( const edm::ParameterSet p)

Definition at line 112 of file MixBoostEvtVtxGenerator.cc.

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

112  :
113  fVertex(0), boost_(0), fTimeOffset(0),
114  vtxLabel(mayConsume<reco::VertexCollection>(pset.getParameter<edm::InputTag>("vtxLabel"))),
115  signalLabel(consumes<HepMCProduct>(pset.getParameter<edm::InputTag>("signalLabel"))),
116  mixLabel(consumes<CrossingFrame<HepMCProduct> >(pset.getParameter<edm::InputTag>("mixLabel"))),
117  useRecVertex(pset.exists("useRecVertex")?pset.getParameter<bool>("useRecVertex"):false)
118 {
119  beta_ = pset.getParameter<double>("Beta");
120  alpha_ = 0;
121  phi_ = 0;
122  if(pset.exists("Alpha")){
123  alpha_ = pset.getParameter<double>("Alpha")*radian;
124  phi_ = pset.getParameter<double>("Phi")*radian;
125  }
126 
127  vtxOffset.resize(3);
128  if(pset.exists("vtxOffset")) vtxOffset=pset.getParameter< std::vector<double> >("vtxOffset");
129 
130  produces<edm::HepMCProduct>();
131 
132 }
edm::EDGetTokenT< HepMCProduct > signalLabel
std::vector< double > vtxOffset
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< reco::VertexCollection > vtxLabel
edm::EDGetTokenT< CrossingFrame< HepMCProduct > > mixLabel
MixBoostEvtVtxGenerator::~MixBoostEvtVtxGenerator ( )
virtual

Definition at line 134 of file MixBoostEvtVtxGenerator.cc.

References boost_, and fVertex.

135 {
136  if (fVertex != 0) delete fVertex ;
137  if (boost_ != 0 ) delete boost_;
138 }
MixBoostEvtVtxGenerator::MixBoostEvtVtxGenerator ( const MixBoostEvtVtxGenerator p)
private

Copy constructor

Member Function Documentation

void MixBoostEvtVtxGenerator::Alpha ( double  m = 0)
inline

angle between crossing plane and horizontal plane

Definition at line 74 of file MixBoostEvtVtxGenerator.cc.

References funct::m.

void MixBoostEvtVtxGenerator::Beta ( double  m = 0)
inline

Definition at line 75 of file MixBoostEvtVtxGenerator.cc.

References funct::m.

double MixBoostEvtVtxGenerator::BetaFunction ( double  z,
double  z0 
)

beta function

Definition at line 141 of file MixBoostEvtVtxGenerator.cc.

References fbetastar, femittance, and mathSSE::sqrt().

142 {
143  return sqrt(femittance*(fbetastar+(((z-z0)*(z-z0))/fbetastar)));
144 
145 }
T sqrt(T t)
Definition: SSEVec.h:18
void MixBoostEvtVtxGenerator::betastar ( double  m = 0)
inline

set beta_star

Definition at line 78 of file MixBoostEvtVtxGenerator.cc.

References funct::m.

void MixBoostEvtVtxGenerator::emittance ( double  m = 0)
inline

emittance (no the normalized)

Definition at line 80 of file MixBoostEvtVtxGenerator.cc.

References funct::m.

TMatrixD * MixBoostEvtVtxGenerator::GetInvLorentzBoost ( )
virtual

Definition at line 160 of file MixBoostEvtVtxGenerator.cc.

References alpha_, beta_, boost_, funct::cos(), phi_, funct::sin(), mathSSE::sqrt(), and funct::tan().

Referenced by produce().

160  {
161 
162  //alpha_ = 0;
163  //phi_ = 142.e-6;
164 // if (boost_ != 0 ) return boost_;
165 
166  //boost_.ResizeTo(4,4);
167  //boost_ = new TMatrixD(4,4);
168  TMatrixD tmpboost(4,4);
169  TMatrixD tmpboostZ(4,4);
170  TMatrixD tmpboostXYZ(4,4);
171 
172  //if ( (alpha_ == 0) && (phi_==0) ) { boost_->Zero(); return boost_; }
173 
174  // Lorentz boost to frame where the collision is head-on
175  // phi is the half crossing angle in the plane ZS
176  // alpha is the angle to the S axis from the X axis in the XY plane
177 
178  tmpboost(0,0) = 1./cos(phi_);
179  tmpboost(0,1) = - cos(alpha_)*sin(phi_);
180  tmpboost(0,2) = - tan(phi_)*sin(phi_);
181  tmpboost(0,3) = - sin(alpha_)*sin(phi_);
182  tmpboost(1,0) = - cos(alpha_)*tan(phi_);
183  tmpboost(1,1) = 1.;
184  tmpboost(1,2) = cos(alpha_)*tan(phi_);
185  tmpboost(1,3) = 0.;
186  tmpboost(2,0) = 0.;
187  tmpboost(2,1) = - cos(alpha_)*sin(phi_);
188  tmpboost(2,2) = cos(phi_);
189  tmpboost(2,3) = - sin(alpha_)*sin(phi_);
190  tmpboost(3,0) = - sin(alpha_)*tan(phi_);
191  tmpboost(3,1) = 0.;
192  tmpboost(3,2) = sin(alpha_)*tan(phi_);
193  tmpboost(3,3) = 1.;
194  //cout<<"beta "<<beta_;
195  double gama=1.0/sqrt(1-beta_*beta_);
196  tmpboostZ(0,0)=gama;
197  tmpboostZ(0,1)=0.;
198  tmpboostZ(0,2)=-1.0*beta_*gama;
199  tmpboostZ(0,3)=0.;
200  tmpboostZ(1,0)=0.;
201  tmpboostZ(1,1) = 1.;
202  tmpboostZ(1,2)=0.;
203  tmpboostZ(1,3)=0.;
204  tmpboostZ(2,0)=-1.0*beta_*gama;
205  tmpboostZ(2,1) = 0.;
206  tmpboostZ(2,2)=gama;
207  tmpboostZ(2,3) = 0.;
208  tmpboostZ(3,0)=0.;
209  tmpboostZ(3,1)=0.;
210  tmpboostZ(3,2)=0.;
211  tmpboostZ(3,3) = 1.;
212 
213  tmpboostXYZ=tmpboostZ*tmpboost;
214  tmpboostXYZ.Invert();
215 
216  //cout<<"Boosting with beta : "<<beta_<<endl;
217 
218  boost_ = new TMatrixD(tmpboostXYZ);
219  boost_->Print();
220 
221  return boost_;
222 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T sqrt(T t)
Definition: SSEVec.h:18
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
HepMC::FourVector * MixBoostEvtVtxGenerator::getRecVertex ( edm::Event evt)
virtual

Definition at line 266 of file MixBoostEvtVtxGenerator.cc.

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

Referenced by produce().

266  {
267 
268 
270  evt.getByToken(vtxLabel,input);
271 
272  double aX,aY,aZ;
273 
274  aX = input->begin()->position().x() + vtxOffset[0];
275  aY = input->begin()->position().y() + vtxOffset[1];
276  aZ = input->begin()->position().z() + vtxOffset[2];
277 
278  if(!fVertex) fVertex = new HepMC::FourVector();
279  fVertex->set(10.0*aX,10.0*aY,10.0*aZ,0.0); // HepMC positions in mm (RECO in cm)
280 
281  return fVertex;
282 
283 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
std::vector< double > vtxOffset
static std::string const input
Definition: EdmProvDump.cc:44
edm::EDGetTokenT< reco::VertexCollection > vtxLabel
HepMC::FourVector * MixBoostEvtVtxGenerator::getVertex ( edm::Event evt)
virtual

Definition at line 224 of file MixBoostEvtVtxGenerator.cc.

References HiRecoJets_cff::bkg, gather_cfg::cout, Exception, fVertex, edm::Event::getByToken(), ecalTB2006H4_GenSimDigiReco_cfg::mix, mixLabel, edm::Handle< T >::product(), and EnergyCorrector::pt.

Referenced by produce().

224  {
225 
226  const HepMC::GenEvent* inev = 0;
227 
229  evt.getByToken(mixLabel,cf);
231 
232  const HepMCProduct& bkg = mix.getObject(1);
233  if(!(bkg.isVtxGenApplied())){
234  throw cms::Exception("MatchVtx")<<"Input background does not have smeared vertex!"<<endl;
235  }else{
236  inev = bkg.GetEvent();
237  }
238 
239  HepMC::GenVertex* genvtx = inev->signal_process_vertex();
240  if(!genvtx){
241  cout<<"No Signal Process Vertex!"<<endl;
242  HepMC::GenEvent::particle_const_iterator pt=inev->particles_begin();
243  HepMC::GenEvent::particle_const_iterator ptend=inev->particles_end();
244  while(!genvtx || ( genvtx->particles_in_size() == 1 && pt != ptend ) ){
245  if(!genvtx) cout<<"No Gen Vertex!"<<endl;
246  if(pt == ptend) cout<<"End reached!"<<endl;
247  genvtx = (*pt)->production_vertex();
248  ++pt;
249  }
250  }
251  double aX,aY,aZ,aT;
252 
253  aX = genvtx->position().x();
254  aY = genvtx->position().y();
255  aZ = genvtx->position().z();
256  aT = genvtx->position().t();
257 
258  if(!fVertex) fVertex = new HepMC::FourVector();
259  fVertex->set(aX,aY,aZ,aT);
260 
261  return fVertex;
262 
263 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
edm::EDGetTokenT< CrossingFrame< HepMCProduct > > mixLabel
T const * product() const
Definition: Handle.h:81
MixBoostEvtVtxGenerator& MixBoostEvtVtxGenerator::operator= ( const MixBoostEvtVtxGenerator rhs)
private

Copy assignment operator

void MixBoostEvtVtxGenerator::Phi ( double  m = 0)
inline

set half crossing angle

Definition at line 72 of file MixBoostEvtVtxGenerator.cc.

References funct::m.

void MixBoostEvtVtxGenerator::produce ( edm::Event evt,
const edm::EventSetup  
)
overridevirtual

return a new event vertex

Definition at line 286 of file MixBoostEvtVtxGenerator.cc.

References DEFINE_FWK_MODULE, edm::Event::getByToken(), edm::HepMCProduct::GetEvent(), GetInvLorentzBoost(), getRecVertex(), getVertex(), eostools::move(), edm::Event::put(), reco::return(), signalLabel, and useRecVertex.

287 {
288  Handle<HepMCProduct> HepUnsmearedMCEvt;
289  evt.getByToken(signalLabel, HepUnsmearedMCEvt);
290 
291  // Copy the HepMC::GenEvent
292  HepMC::GenEvent* genevt = new HepMC::GenEvent(*HepUnsmearedMCEvt->GetEvent());
293  std::unique_ptr<edm::HepMCProduct> HepMCEvt(new edm::HepMCProduct(genevt));
294  // generate new vertex & apply the shift
295  //
296 
297  HepMCEvt->boostToLab( GetInvLorentzBoost(), "vertex" );
298  HepMCEvt->boostToLab( GetInvLorentzBoost(), "momentum" );
299 
300  HepMCEvt->applyVtxGen( useRecVertex ? getRecVertex(evt) : getVertex(evt) ) ;
301 
302  evt.put(std::move(HepMCEvt));
303  return ;
304 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
edm::EDGetTokenT< HepMCProduct > signalLabel
virtual TMatrixD * GetInvLorentzBoost()
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:38
return(e1-e2)*(e1-e2)+dp *dp
virtual HepMC::FourVector * getRecVertex(edm::Event &)
virtual HepMC::FourVector * getVertex(edm::Event &)
def move(src, dest)
Definition: eostools.py:510
void MixBoostEvtVtxGenerator::sigmaZ ( double  s = 1.0)

set resolution in Z in cm

Definition at line 148 of file MixBoostEvtVtxGenerator.cc.

References Exception, fSigmaZ, and alignCSCRings::s.

149 {
150  if (s>=0 ) {
151  fSigmaZ=s;
152  }
153  else {
154  throw cms::Exception("LogicError")
155  << "Error in MixBoostEvtVtxGenerator::sigmaZ: "
156  << "Illegal resolution in Z (negative)";
157  }
158 }
void MixBoostEvtVtxGenerator::X0 ( double  m = 0)
inline

set mean in X in cm

Definition at line 65 of file MixBoostEvtVtxGenerator.cc.

References funct::m.

void MixBoostEvtVtxGenerator::Y0 ( double  m = 0)
inline

set mean in Y in cm

Definition at line 67 of file MixBoostEvtVtxGenerator.cc.

References funct::m.

void MixBoostEvtVtxGenerator::Z0 ( double  m = 0)
inline

set mean in Z in cm

Definition at line 69 of file MixBoostEvtVtxGenerator.cc.

References funct::m.

Member Data Documentation

double MixBoostEvtVtxGenerator::alpha_
private

Definition at line 91 of file MixBoostEvtVtxGenerator.cc.

Referenced by GetInvLorentzBoost(), and MixBoostEvtVtxGenerator().

double MixBoostEvtVtxGenerator::beta_
private

Definition at line 93 of file MixBoostEvtVtxGenerator.cc.

Referenced by GetInvLorentzBoost(), and MixBoostEvtVtxGenerator().

TMatrixD* MixBoostEvtVtxGenerator::boost_
private

Definition at line 101 of file MixBoostEvtVtxGenerator.cc.

Referenced by GetInvLorentzBoost(), and ~MixBoostEvtVtxGenerator().

double MixBoostEvtVtxGenerator::falpha
private

Definition at line 98 of file MixBoostEvtVtxGenerator.cc.

double MixBoostEvtVtxGenerator::fbetastar
private

Definition at line 97 of file MixBoostEvtVtxGenerator.cc.

Referenced by BetaFunction().

double MixBoostEvtVtxGenerator::femittance
private

Definition at line 97 of file MixBoostEvtVtxGenerator.cc.

Referenced by BetaFunction().

double MixBoostEvtVtxGenerator::fSigmaZ
private

Definition at line 95 of file MixBoostEvtVtxGenerator.cc.

Referenced by sigmaZ().

double MixBoostEvtVtxGenerator::fTimeOffset
private

Definition at line 102 of file MixBoostEvtVtxGenerator.cc.

HepMC::FourVector* MixBoostEvtVtxGenerator::fVertex
private

Definition at line 100 of file MixBoostEvtVtxGenerator.cc.

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

double MixBoostEvtVtxGenerator::fX0
private

Definition at line 94 of file MixBoostEvtVtxGenerator.cc.

double MixBoostEvtVtxGenerator::fY0
private

Definition at line 94 of file MixBoostEvtVtxGenerator.cc.

double MixBoostEvtVtxGenerator::fZ0
private

Definition at line 94 of file MixBoostEvtVtxGenerator.cc.

edm::EDGetTokenT<CrossingFrame<HepMCProduct> > MixBoostEvtVtxGenerator::mixLabel
private

Definition at line 106 of file MixBoostEvtVtxGenerator.cc.

Referenced by getVertex().

double MixBoostEvtVtxGenerator::phi_
private

Definition at line 91 of file MixBoostEvtVtxGenerator.cc.

Referenced by GetInvLorentzBoost(), and MixBoostEvtVtxGenerator().

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

Definition at line 105 of file MixBoostEvtVtxGenerator.cc.

Referenced by produce().

bool MixBoostEvtVtxGenerator::useRecVertex
private

Definition at line 107 of file MixBoostEvtVtxGenerator.cc.

Referenced by produce().

edm::EDGetTokenT<reco::VertexCollection> MixBoostEvtVtxGenerator::vtxLabel
private

Definition at line 104 of file MixBoostEvtVtxGenerator.cc.

Referenced by getRecVertex().

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

Definition at line 108 of file MixBoostEvtVtxGenerator.cc.

Referenced by getRecVertex(), and MixBoostEvtVtxGenerator().