CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

BetaBoostEvtVtxGenerator Class Reference

Inheritance diagram for BetaBoostEvtVtxGenerator:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

void Alpha (double m=0)
 angle between crossing plane and horizontal plane
void Beta (double m=0)
 BetaBoostEvtVtxGenerator (const edm::ParameterSet &p)
double BetaFunction (double z, double z0)
 beta function
void betastar (double m=0)
 set beta_star
void emittance (double m=0)
 emittance (no the normalized)
CLHEP::HepRandomEngine & getEngine ()
virtual TMatrixD * GetInvLorentzBoost ()
virtual HepMC::FourVector * newVertex ()
 return a new event vertex
void Phi (double m=0)
 set half crossing angle
virtual void produce (edm::Event &, const edm::EventSetup &)
void sigmaZ (double s=1.0)
 set resolution in Z in cm
void X0 (double m=0)
 set mean in X in cm
void Y0 (double m=0)
 set mean in Y in cm
void Z0 (double m=0)
 set mean in Z in cm
virtual ~BetaBoostEvtVtxGenerator ()

Private Member Functions

 BetaBoostEvtVtxGenerator (const BetaBoostEvtVtxGenerator &p)
BetaBoostEvtVtxGeneratoroperator= (const BetaBoostEvtVtxGenerator &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
double phi_
edm::InputTag sourceLabel
bool verbosity_

Detailed Description

Definition at line 50 of file BetaBoostEvtVtxGenerator.cc.


Constructor & Destructor Documentation

BetaBoostEvtVtxGenerator::BetaBoostEvtVtxGenerator ( const edm::ParameterSet p)

Definition at line 116 of file BetaBoostEvtVtxGenerator.cc.

References alpha_, beta_, Exception, fbetastar, femittance, fEngine, fRandom, fSigmaZ, fTimeOffset, fX0, fY0, fZ0, getEngine(), edm::ParameterSet::getParameter(), edm::Service< T >::isAvailable(), and phi_.

                                                                            :
  fVertex(0), boost_(0), fTimeOffset(0), fEngine(0),
  sourceLabel(p.getParameter<edm::InputTag>("src")),
  verbosity_(p.getUntrackedParameter<bool>("verbosity",false))
{ 
  
  edm::Service<edm::RandomNumberGenerator> rng;

  if ( ! rng.isAvailable()) {
    
    throw cms::Exception("Configuration")
      << "The BaseEvtVtxGenerator requires the RandomNumberGeneratorService\n"
      "which is not present in the configuration file.  You must add the service\n"
      "in the configuration file or remove the modules that require it.";
  }

  CLHEP::HepRandomEngine& engine = rng->getEngine();
  fEngine = &engine;
  fRandom = new CLHEP::RandGaussQ(getEngine());

  fX0 =        p.getParameter<double>("X0")*cm;
  fY0 =        p.getParameter<double>("Y0")*cm;
  fZ0 =        p.getParameter<double>("Z0")*cm;
  fSigmaZ =    p.getParameter<double>("SigmaZ")*cm;
  alpha_ =     p.getParameter<double>("Alpha")*radian;
  phi_ =       p.getParameter<double>("Phi")*radian;
  fbetastar =  p.getParameter<double>("BetaStar")*cm;
  femittance = p.getParameter<double>("Emittance")*cm; // this is not the normalized emittance
  fTimeOffset = p.getParameter<double>("TimeOffset")*ns*c_light; // HepMC time units are mm
  beta_=p.getParameter<double>("Beta"); 
  if (fSigmaZ <= 0) {
    throw cms::Exception("Configuration")
      << "Error in BetaBoostEvtVtxGenerator: "
      << "Illegal resolution in Z (SigmaZ is negative)";
  }

  produces<bool>(); 
  
}
BetaBoostEvtVtxGenerator::~BetaBoostEvtVtxGenerator ( ) [virtual]

Definition at line 156 of file BetaBoostEvtVtxGenerator.cc.

References boost_, fRandom, and fVertex.

{
  delete fVertex ;
  if (boost_ != 0 ) delete boost_;
  delete fRandom; 
}
BetaBoostEvtVtxGenerator::BetaBoostEvtVtxGenerator ( const BetaBoostEvtVtxGenerator p) [private]

Copy constructor


Member Function Documentation

void BetaBoostEvtVtxGenerator::Alpha ( double  m = 0) [inline]

angle between crossing plane and horizontal plane

Definition at line 75 of file BetaBoostEvtVtxGenerator.cc.

References m.

{ alpha_=m; }
void BetaBoostEvtVtxGenerator::Beta ( double  m = 0) [inline]

Definition at line 76 of file BetaBoostEvtVtxGenerator.cc.

References m.

{ beta_=m; }
double BetaBoostEvtVtxGenerator::BetaFunction ( double  z,
double  z0 
)

beta function

Definition at line 196 of file BetaBoostEvtVtxGenerator.cc.

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

Referenced by newVertex().

{
  return sqrt(femittance*(fbetastar+(((z-z0)*(z-z0))/fbetastar)));

}
void BetaBoostEvtVtxGenerator::betastar ( double  m = 0) [inline]

set beta_star

Definition at line 79 of file BetaBoostEvtVtxGenerator.cc.

References m.

{ fbetastar=m; }
void BetaBoostEvtVtxGenerator::emittance ( double  m = 0) [inline]

emittance (no the normalized)

Definition at line 81 of file BetaBoostEvtVtxGenerator.cc.

References m.

CLHEP::HepRandomEngine & BetaBoostEvtVtxGenerator::getEngine ( )

Definition at line 163 of file BetaBoostEvtVtxGenerator.cc.

References fEngine.

Referenced by BetaBoostEvtVtxGenerator().

                                                         {
  return *fEngine;
}
TMatrixD * BetaBoostEvtVtxGenerator::GetInvLorentzBoost ( ) [virtual]

Definition at line 215 of file BetaBoostEvtVtxGenerator.cc.

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

Referenced by produce().

                                                       {

  //alpha_ = 0;
  //phi_ = 142.e-6;
  //    if (boost_ != 0 ) return boost_;
        
  //boost_.ResizeTo(4,4);
  //boost_ = new TMatrixD(4,4);
  TMatrixD tmpboost(4,4);
  TMatrixD tmpboostZ(4,4);
  TMatrixD tmpboostXYZ(4,4);

  //if ( (alpha_ == 0) && (phi_==0) ) { boost_->Zero(); return boost_; }
        
  // Lorentz boost to frame where the collision is head-on
  // phi is the half crossing angle in the plane ZS
  // alpha is the angle to the S axis from the X axis in the XY plane
        
  tmpboost(0,0) = 1./cos(phi_);
  tmpboost(0,1) = - cos(alpha_)*sin(phi_);
  tmpboost(0,2) = - tan(phi_)*sin(phi_);
  tmpboost(0,3) = - sin(alpha_)*sin(phi_);
  tmpboost(1,0) = - cos(alpha_)*tan(phi_);
  tmpboost(1,1) = 1.;
  tmpboost(1,2) = cos(alpha_)*tan(phi_);
  tmpboost(1,3) = 0.;
  tmpboost(2,0) = 0.;
  tmpboost(2,1) = - cos(alpha_)*sin(phi_);
  tmpboost(2,2) = cos(phi_);
  tmpboost(2,3) = - sin(alpha_)*sin(phi_);
  tmpboost(3,0) = - sin(alpha_)*tan(phi_);
  tmpboost(3,1) = 0.;
  tmpboost(3,2) = sin(alpha_)*tan(phi_);
  tmpboost(3,3) = 1.;
  //cout<<"beta "<<beta_;
  double gama=1.0/sqrt(1-beta_*beta_);
  tmpboostZ(0,0)=gama;
  tmpboostZ(0,1)=0.;
  tmpboostZ(0,2)=-1.0*beta_*gama;
  tmpboostZ(0,3)=0.;
  tmpboostZ(1,0)=0.;
  tmpboostZ(1,1) = 1.;
  tmpboostZ(1,2)=0.;
  tmpboostZ(1,3)=0.;
  tmpboostZ(2,0)=-1.0*beta_*gama;
  tmpboostZ(2,1) = 0.;
  tmpboostZ(2,2)=gama;
  tmpboostZ(2,3) = 0.;
  tmpboostZ(3,0)=0.;
  tmpboostZ(3,1)=0.;
  tmpboostZ(3,2)=0.;
  tmpboostZ(3,3) = 1.;

  tmpboostXYZ=tmpboostZ*tmpboost;
  tmpboostXYZ.Invert();



  boost_ = new TMatrixD(tmpboostXYZ);
  if ( verbosity_ ) { boost_->Print(); }
        
  return boost_;
}
HepMC::FourVector * BetaBoostEvtVtxGenerator::newVertex ( ) [virtual]

return a new event vertex

Definition at line 169 of file BetaBoostEvtVtxGenerator.cc.

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

Referenced by produce().

                                                     {

        
  double X,Y,Z;
        
  double tmp_sigz = fRandom->fire(0., fSigmaZ);
  Z = tmp_sigz + fZ0;

  double tmp_sigx = BetaFunction(Z,fZ0); 
  // need sqrt(2) for beamspot width relative to single beam width
  tmp_sigx /= sqrt(2.0);
  X = fRandom->fire(0.,tmp_sigx) + fX0; // + Z*fdxdz ;

  double tmp_sigy = BetaFunction(Z,fZ0);
  // need sqrt(2) for beamspot width relative to single beam width
  tmp_sigy /= sqrt(2.0);
  Y = fRandom->fire(0.,tmp_sigy) + fY0; // + Z*fdydz;

  double tmp_sigt = fRandom->fire(0., fSigmaZ);
  double T = tmp_sigt + fTimeOffset; 

  if ( fVertex == 0 ) fVertex = new HepMC::FourVector();
  fVertex->set(X,Y,Z,T);
                
  return fVertex;
}
BetaBoostEvtVtxGenerator& BetaBoostEvtVtxGenerator::operator= ( const BetaBoostEvtVtxGenerator rhs) [private]

Copy assignment operator

void BetaBoostEvtVtxGenerator::Phi ( double  m = 0) [inline]

set half crossing angle

Definition at line 73 of file BetaBoostEvtVtxGenerator.cc.

References m.

{ phi_=m; }
void BetaBoostEvtVtxGenerator::produce ( edm::Event evt,
const edm::EventSetup  
) [virtual]

Implements edm::EDProducer.

Definition at line 279 of file BetaBoostEvtVtxGenerator.cc.

References edm::Event::getByLabel(), GetInvLorentzBoost(), newVertex(), edm::Event::put(), and sourceLabel.

{
  
  
  Handle<HepMCProduct> HepMCEvt ;    
  evt.getByLabel( sourceLabel, HepMCEvt ) ;
  
  // generate new vertex & apply the shift 
  //
  HepMCEvt->applyVtxGen( newVertex() ) ;
 
  //HepMCEvt->LorentzBoost( 0., 142.e-6 );
  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 ) ;       
  return ;
}
void BetaBoostEvtVtxGenerator::sigmaZ ( double  s = 1.0)

set resolution in Z in cm

Definition at line 203 of file BetaBoostEvtVtxGenerator.cc.

References Exception, fSigmaZ, and alignCSCRings::s.

{ 
  if (s>=0 ) {
    fSigmaZ=s; 
  }
  else {
    throw cms::Exception("LogicError")
      << "Error in BetaBoostEvtVtxGenerator::sigmaZ: "
      << "Illegal resolution in Z (negative)";
  }
}
void BetaBoostEvtVtxGenerator::X0 ( double  m = 0) [inline]

set mean in X in cm

Definition at line 66 of file BetaBoostEvtVtxGenerator.cc.

References m.

{ fX0=m; }
void BetaBoostEvtVtxGenerator::Y0 ( double  m = 0) [inline]

set mean in Y in cm

Definition at line 68 of file BetaBoostEvtVtxGenerator.cc.

References m.

{ fY0=m; }
void BetaBoostEvtVtxGenerator::Z0 ( double  m = 0) [inline]

set mean in Z in cm

Definition at line 70 of file BetaBoostEvtVtxGenerator.cc.

References m.

{ fZ0=m; }

Member Data Documentation

Definition at line 93 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and GetInvLorentzBoost().

Definition at line 95 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and GetInvLorentzBoost().

TMatrixD* BetaBoostEvtVtxGenerator::boost_ [private]

Definition at line 103 of file BetaBoostEvtVtxGenerator.cc.

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

Definition at line 100 of file BetaBoostEvtVtxGenerator.cc.

Definition at line 99 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and BetaFunction().

Definition at line 99 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and BetaFunction().

CLHEP::HepRandomEngine* BetaBoostEvtVtxGenerator::fEngine [private]

Definition at line 106 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and getEngine().

CLHEP::RandGaussQ* BetaBoostEvtVtxGenerator::fRandom [private]

Definition at line 97 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), newVertex(), and sigmaZ().

Definition at line 104 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and newVertex().

HepMC::FourVector* BetaBoostEvtVtxGenerator::fVertex [private]

Definition at line 102 of file BetaBoostEvtVtxGenerator.cc.

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

Definition at line 96 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and newVertex().

Definition at line 96 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and newVertex().

Definition at line 96 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and newVertex().

Definition at line 93 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and GetInvLorentzBoost().

Definition at line 107 of file BetaBoostEvtVtxGenerator.cc.

Referenced by produce().

Definition at line 111 of file BetaBoostEvtVtxGenerator.cc.

Referenced by GetInvLorentzBoost().