CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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...
 
CLHEP::HepRandomEngine & getEngine ()
 
virtual TMatrixD * GetInvLorentzBoost ()
 
virtual HepMC::FourVector * getRecVertex (edm::Event &)
 
virtual HepMC::FourVector * getVertex (edm::Event &)
 
 MixBoostEvtVtxGenerator (const edm::ParameterSet &p)
 
virtual HepMC::FourVector * newVertex ()
 return a new event vertex More...
 
void Phi (double m=0)
 set half crossing angle More...
 
virtual void produce (edm::Event &, const edm::EventSetup &) override
 
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
 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
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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
 
CLHEP::HepRandomEngine * fEngine
 
CLHEP::RandGaussQ * fRandom
 
double fSigmaZ
 
double fTimeOffset
 
HepMC::FourVector * fVertex
 
double fX0
 
double fY0
 
double fZ0
 
edm::InputTag hiLabel
 
double phi_
 
edm::InputTag signalLabel
 
edm::InputTag sourceLabel
 
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 51 of file MixBoostEvtVtxGenerator.cc.

Constructor & Destructor Documentation

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

Definition at line 121 of file MixBoostEvtVtxGenerator.cc.

References edm::hlt::Exception, edm::ParameterSet::exists(), fEngine, edm::RandomNumberGenerator::getEngine(), edm::ParameterSet::getParameter(), edm::Service< T >::isAvailable(), and vtxOffset.

121  :
122  fVertex(0), boost_(0), fTimeOffset(0), fEngine(0),
123  signalLabel(pset.getParameter<edm::InputTag>("signalLabel")),
124  hiLabel(pset.getParameter<edm::InputTag>("heavyIonLabel")),
125  useRecVertex(pset.exists("useRecVertex")?pset.getParameter<bool>("useRecVertex"):false)
126 {
127 
128  vtxOffset.resize(3);
129  if(pset.exists("vtxOffset")) vtxOffset=pset.getParameter< std::vector<double> >("vtxOffset");
131 
132  if ( ! rng.isAvailable()) {
133 
134  throw cms::Exception("Configuration")
135  << "The BaseEvtVtxGenerator requires the RandomNumberGeneratorService\n"
136  "which is not present in the configuration file. You must add the service\n"
137  "in the configuration file or remove the modules that require it.";
138  }
139 
140  CLHEP::HepRandomEngine& engine = rng->getEngine();
141  fEngine = &engine;
142 
143  produces<bool>("matchedVertex");
144 
145 }
CLHEP::HepRandomEngine * fEngine
std::vector< double > vtxOffset
bool isAvailable() const
Definition: Service.h:46
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...
MixBoostEvtVtxGenerator::~MixBoostEvtVtxGenerator ( )
virtual

Definition at line 147 of file MixBoostEvtVtxGenerator.cc.

References boost_, fRandom, and fVertex.

148 {
149  delete fVertex ;
150  if (boost_ != 0 ) delete boost_;
151  delete fRandom;
152 }
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 77 of file MixBoostEvtVtxGenerator.cc.

References m.

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

Definition at line 78 of file MixBoostEvtVtxGenerator.cc.

References m.

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

beta function

Definition at line 187 of file MixBoostEvtVtxGenerator.cc.

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

Referenced by newVertex().

188 {
189  return sqrt(femittance*(fbetastar+(((z-z0)*(z-z0))/fbetastar)));
190 
191 }
float float float z
T sqrt(T t)
Definition: SSEVec.h:48
void MixBoostEvtVtxGenerator::betastar ( double  m = 0)
inline

set beta_star

Definition at line 81 of file MixBoostEvtVtxGenerator.cc.

References m.

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

emittance (no the normalized)

Definition at line 83 of file MixBoostEvtVtxGenerator.cc.

References m.

CLHEP::HepRandomEngine & MixBoostEvtVtxGenerator::getEngine ( )

Definition at line 154 of file MixBoostEvtVtxGenerator.cc.

References fEngine.

154  {
155  return *fEngine;
156 }
CLHEP::HepRandomEngine * fEngine
TMatrixD * MixBoostEvtVtxGenerator::GetInvLorentzBoost ( )
virtual

Definition at line 206 of file MixBoostEvtVtxGenerator.cc.

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

206  {
207 
208  //alpha_ = 0;
209  //phi_ = 142.e-6;
210 // if (boost_ != 0 ) return boost_;
211 
212  //boost_.ResizeTo(4,4);
213  //boost_ = new TMatrixD(4,4);
214  TMatrixD tmpboost(4,4);
215  TMatrixD tmpboostZ(4,4);
216  TMatrixD tmpboostXYZ(4,4);
217 
218  //if ( (alpha_ == 0) && (phi_==0) ) { boost_->Zero(); return boost_; }
219 
220  // Lorentz boost to frame where the collision is head-on
221  // phi is the half crossing angle in the plane ZS
222  // alpha is the angle to the S axis from the X axis in the XY plane
223 
224  tmpboost(0,0) = 1./cos(phi_);
225  tmpboost(0,1) = - cos(alpha_)*sin(phi_);
226  tmpboost(0,2) = - tan(phi_)*sin(phi_);
227  tmpboost(0,3) = - sin(alpha_)*sin(phi_);
228  tmpboost(1,0) = - cos(alpha_)*tan(phi_);
229  tmpboost(1,1) = 1.;
230  tmpboost(1,2) = cos(alpha_)*tan(phi_);
231  tmpboost(1,3) = 0.;
232  tmpboost(2,0) = 0.;
233  tmpboost(2,1) = - cos(alpha_)*sin(phi_);
234  tmpboost(2,2) = cos(phi_);
235  tmpboost(2,3) = - sin(alpha_)*sin(phi_);
236  tmpboost(3,0) = - sin(alpha_)*tan(phi_);
237  tmpboost(3,1) = 0.;
238  tmpboost(3,2) = sin(alpha_)*tan(phi_);
239  tmpboost(3,3) = 1.;
240  //cout<<"beta "<<beta_;
241  double gama=1.0/sqrt(1-beta_*beta_);
242  tmpboostZ(0,0)=gama;
243  tmpboostZ(0,1)=0.;
244  tmpboostZ(0,2)=-1.0*beta_*gama;
245  tmpboostZ(0,3)=0.;
246  tmpboostZ(1,0)=0.;
247  tmpboostZ(1,1) = 1.;
248  tmpboostZ(1,2)=0.;
249  tmpboostZ(1,3)=0.;
250  tmpboostZ(2,0)=-1.0*beta_*gama;
251  tmpboostZ(2,1) = 0.;
252  tmpboostZ(2,2)=gama;
253  tmpboostZ(2,3) = 0.;
254  tmpboostZ(3,0)=0.;
255  tmpboostZ(3,1)=0.;
256  tmpboostZ(3,2)=0.;
257  tmpboostZ(3,3) = 1.;
258 
259  tmpboostXYZ=tmpboost*tmpboostZ;
260  tmpboost.Invert();
261 
262 
263 
264  boost_ = new TMatrixD(tmpboostXYZ);
265  boost_->Print();
266 
267  return boost_;
268 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T sqrt(T t)
Definition: SSEVec.h:48
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 303 of file MixBoostEvtVtxGenerator.cc.

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

Referenced by produce().

303  {
304 
306  evt.getByLabel(hiLabel,input);
307 
308  double aX,aY,aZ;
309 
310  aX = input->begin()->position().x() + vtxOffset[0];
311  aY = input->begin()->position().y() + vtxOffset[1];
312  aZ = input->begin()->position().z() + vtxOffset[2];
313 
314  if(!fVertex) fVertex = new HepMC::FourVector();
315  fVertex->set(10.0*aX,10.0*aY,10.0*aZ,0.0); // HepMC positions in mm (RECO in cm)
316 
317  return fVertex;
318 
319 }
std::vector< double > vtxOffset
static std::string const input
Definition: EdmProvDump.cc:44
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
HepMC::FourVector * MixBoostEvtVtxGenerator::getVertex ( edm::Event evt)
virtual

Definition at line 270 of file MixBoostEvtVtxGenerator.cc.

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

Referenced by produce().

270  {
271 
273  evt.getByLabel(hiLabel,input);
274 
275  const HepMC::GenEvent* inev = input->GetEvent();
276  HepMC::GenVertex* genvtx = inev->signal_process_vertex();
277  if(!genvtx){
278  cout<<"No Signal Process Vertex!"<<endl;
279  HepMC::GenEvent::particle_const_iterator pt=inev->particles_begin();
280  HepMC::GenEvent::particle_const_iterator ptend=inev->particles_end();
281  while(!genvtx || ( genvtx->particles_in_size() == 1 && pt != ptend ) ){
282  if(!genvtx) cout<<"No Gen Vertex!"<<endl;
283  if(pt == ptend) cout<<"End reached!"<<endl;
284  genvtx = (*pt)->production_vertex();
285  ++pt;
286  }
287  }
288  double aX,aY,aZ,aT;
289 
290  aX = genvtx->position().x();
291  aY = genvtx->position().y();
292  aZ = genvtx->position().z();
293  aT = genvtx->position().t();
294 
295  if(!fVertex) fVertex = new HepMC::FourVector();
296  fVertex->set(aX,aY,aZ,aT);
297 
298  return fVertex;
299 
300 }
static std::string const input
Definition: EdmProvDump.cc:44
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
tuple cout
Definition: gather_cfg.py:121
HepMC::FourVector * MixBoostEvtVtxGenerator::newVertex ( )
virtual

return a new event vertex

Definition at line 160 of file MixBoostEvtVtxGenerator.cc.

References BetaFunction(), fRandom, fSigmaZ, fTimeOffset, fVertex, fX0, fY0, fZ0, mathSSE::sqrt(), X, and Gflash::Z.

160  {
161 
162 
163  double X,Y,Z;
164 
165  double tmp_sigz = fRandom->fire(0., fSigmaZ);
166  Z = tmp_sigz + fZ0;
167 
168  double tmp_sigx = BetaFunction(Z,fZ0);
169  // need sqrt(2) for beamspot width relative to single beam width
170  tmp_sigx /= sqrt(2.0);
171  X = fRandom->fire(0.,tmp_sigx) + fX0; // + Z*fdxdz ;
172 
173  double tmp_sigy = BetaFunction(Z,fZ0);
174  // need sqrt(2) for beamspot width relative to single beam width
175  tmp_sigy /= sqrt(2.0);
176  Y = fRandom->fire(0.,tmp_sigy) + fY0; // + Z*fdydz;
177 
178  double tmp_sigt = fRandom->fire(0., fSigmaZ);
179  double T = tmp_sigt + fTimeOffset;
180 
181  if ( fVertex == 0 ) fVertex = new HepMC::FourVector();
182  fVertex->set(X,Y,Z,T);
183 
184  return fVertex;
185 }
const double Z[kNumberCalorimeter]
#define X(str)
Definition: MuonsGrabber.cc:48
T sqrt(T t)
Definition: SSEVec.h:48
long double T
double BetaFunction(double z, double z0)
beta function
MixBoostEvtVtxGenerator& MixBoostEvtVtxGenerator::operator= ( const MixBoostEvtVtxGenerator rhs)
private

Copy assignment operator

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

set half crossing angle

Definition at line 75 of file MixBoostEvtVtxGenerator.cc.

References m.

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

Implements edm::EDProducer.

Definition at line 322 of file MixBoostEvtVtxGenerator.cc.

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

323 {
324 
325 
326  Handle<HepMCProduct> HepMCEvt ;
327 
328  evt.getByLabel( signalLabel, HepMCEvt ) ;
329 
330  // generate new vertex & apply the shift
331  //
332 
333  HepMCEvt->applyVtxGen( useRecVertex ? getRecVertex(evt) : getVertex(evt) ) ;
334 
335  // HepMCEvt->boostToLab( GetInvLorentzBoost(), "vertex" );
336  // HepMCEvt->boostToLab( GetInvLorentzBoost(), "momentum" );
337 
338  // OK, create a (pseudo)product and put in into edm::Event
339  //
340  auto_ptr<bool> NewProduct(new bool(true)) ;
341  evt.put( NewProduct ,"matchedVertex") ;
342 
343  return ;
344 
345 }
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
return(e1-e2)*(e1-e2)+dp *dp
virtual HepMC::FourVector * getRecVertex(edm::Event &)
virtual HepMC::FourVector * getVertex(edm::Event &)
void MixBoostEvtVtxGenerator::sigmaZ ( double  s = 1.0)

set resolution in Z in cm

Definition at line 194 of file MixBoostEvtVtxGenerator.cc.

References edm::hlt::Exception, fSigmaZ, and alignCSCRings::s.

195 {
196  if (s>=0 ) {
197  fSigmaZ=s;
198  }
199  else {
200  throw cms::Exception("LogicError")
201  << "Error in MixBoostEvtVtxGenerator::sigmaZ: "
202  << "Illegal resolution in Z (negative)";
203  }
204 }
void MixBoostEvtVtxGenerator::X0 ( double  m = 0)
inline

set mean in X in cm

Definition at line 68 of file MixBoostEvtVtxGenerator.cc.

References m.

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

set mean in Y in cm

Definition at line 70 of file MixBoostEvtVtxGenerator.cc.

References m.

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

set mean in Z in cm

Definition at line 72 of file MixBoostEvtVtxGenerator.cc.

References m.

Member Data Documentation

double MixBoostEvtVtxGenerator::alpha_
private

Definition at line 95 of file MixBoostEvtVtxGenerator.cc.

Referenced by GetInvLorentzBoost().

double MixBoostEvtVtxGenerator::beta_
private

Definition at line 97 of file MixBoostEvtVtxGenerator.cc.

Referenced by GetInvLorentzBoost().

TMatrixD* MixBoostEvtVtxGenerator::boost_
private

Definition at line 105 of file MixBoostEvtVtxGenerator.cc.

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

double MixBoostEvtVtxGenerator::falpha
private

Definition at line 102 of file MixBoostEvtVtxGenerator.cc.

double MixBoostEvtVtxGenerator::fbetastar
private

Definition at line 101 of file MixBoostEvtVtxGenerator.cc.

Referenced by BetaFunction().

double MixBoostEvtVtxGenerator::femittance
private

Definition at line 101 of file MixBoostEvtVtxGenerator.cc.

Referenced by BetaFunction().

CLHEP::HepRandomEngine* MixBoostEvtVtxGenerator::fEngine
private

Definition at line 108 of file MixBoostEvtVtxGenerator.cc.

Referenced by getEngine(), and MixBoostEvtVtxGenerator().

CLHEP::RandGaussQ* MixBoostEvtVtxGenerator::fRandom
private

Definition at line 111 of file MixBoostEvtVtxGenerator.cc.

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

double MixBoostEvtVtxGenerator::fSigmaZ
private

Definition at line 99 of file MixBoostEvtVtxGenerator.cc.

Referenced by newVertex(), and sigmaZ().

double MixBoostEvtVtxGenerator::fTimeOffset
private

Definition at line 106 of file MixBoostEvtVtxGenerator.cc.

Referenced by newVertex().

HepMC::FourVector* MixBoostEvtVtxGenerator::fVertex
private
double MixBoostEvtVtxGenerator::fX0
private

Definition at line 98 of file MixBoostEvtVtxGenerator.cc.

Referenced by newVertex().

double MixBoostEvtVtxGenerator::fY0
private

Definition at line 98 of file MixBoostEvtVtxGenerator.cc.

Referenced by newVertex().

double MixBoostEvtVtxGenerator::fZ0
private

Definition at line 98 of file MixBoostEvtVtxGenerator.cc.

Referenced by newVertex().

edm::InputTag MixBoostEvtVtxGenerator::hiLabel
private

Definition at line 114 of file MixBoostEvtVtxGenerator.cc.

Referenced by getRecVertex(), and getVertex().

double MixBoostEvtVtxGenerator::phi_
private

Definition at line 95 of file MixBoostEvtVtxGenerator.cc.

Referenced by GetInvLorentzBoost().

edm::InputTag MixBoostEvtVtxGenerator::signalLabel
private

Definition at line 113 of file MixBoostEvtVtxGenerator.cc.

Referenced by produce().

edm::InputTag MixBoostEvtVtxGenerator::sourceLabel
private

Definition at line 109 of file MixBoostEvtVtxGenerator.cc.

bool MixBoostEvtVtxGenerator::useRecVertex
private

Definition at line 115 of file MixBoostEvtVtxGenerator.cc.

Referenced by produce().

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

Definition at line 116 of file MixBoostEvtVtxGenerator.cc.

Referenced by getRecVertex(), and MixBoostEvtVtxGenerator().