test
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...
 
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
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 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
std::vector< ConsumesInfoconsumesInfo () const
 
 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 (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) 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::RandGaussQ * fRandom
 
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::VertexCollection
vtxLabel
 
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 51 of file MixBoostEvtVtxGenerator.cc.

Constructor & Destructor Documentation

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

Definition at line 117 of file MixBoostEvtVtxGenerator.cc.

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

117  :
118  fVertex(0), boost_(0), fTimeOffset(0),
119  vtxLabel(mayConsume<reco::VertexCollection>(pset.getParameter<edm::InputTag>("vtxLabel"))),
120  signalLabel(consumes<HepMCProduct>(pset.getParameter<edm::InputTag>("signalLabel"))),
121  mixLabel(consumes<CrossingFrame<HepMCProduct> >(pset.getParameter<edm::InputTag>("mixLabel"))),
122  useRecVertex(pset.exists("useRecVertex")?pset.getParameter<bool>("useRecVertex"):false)
123 {
124 
125  vtxOffset.resize(3);
126  if(pset.exists("vtxOffset")) vtxOffset=pset.getParameter< std::vector<double> >("vtxOffset");
127 
128  produces<edm::HepMCProduct>();
129 
130 }
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 132 of file MixBoostEvtVtxGenerator.cc.

References boost_, fRandom, and fVertex.

133 {
134  delete fVertex ;
135  if (boost_ != 0 ) delete boost_;
136  delete fRandom;
137 }
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 visualization-live-secondInstance_cfg::m.

void MixBoostEvtVtxGenerator::Beta ( double  m = 0)
inline
double MixBoostEvtVtxGenerator::BetaFunction ( double  z,
double  z0 
)

beta function

Definition at line 168 of file MixBoostEvtVtxGenerator.cc.

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

Referenced by newVertex().

169 {
170  return sqrt(femittance*(fbetastar+(((z-z0)*(z-z0))/fbetastar)));
171 
172 }
T sqrt(T t)
Definition: SSEVec.h:18
void MixBoostEvtVtxGenerator::betastar ( double  m = 0)
inline
void MixBoostEvtVtxGenerator::emittance ( double  m = 0)
inline
TMatrixD * MixBoostEvtVtxGenerator::GetInvLorentzBoost ( )
virtual

Definition at line 187 of file MixBoostEvtVtxGenerator.cc.

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

187  {
188 
189  //alpha_ = 0;
190  //phi_ = 142.e-6;
191 // if (boost_ != 0 ) return boost_;
192 
193  //boost_.ResizeTo(4,4);
194  //boost_ = new TMatrixD(4,4);
195  TMatrixD tmpboost(4,4);
196  TMatrixD tmpboostZ(4,4);
197  TMatrixD tmpboostXYZ(4,4);
198 
199  //if ( (alpha_ == 0) && (phi_==0) ) { boost_->Zero(); return boost_; }
200 
201  // Lorentz boost to frame where the collision is head-on
202  // phi is the half crossing angle in the plane ZS
203  // alpha is the angle to the S axis from the X axis in the XY plane
204 
205  tmpboost(0,0) = 1./cos(phi_);
206  tmpboost(0,1) = - cos(alpha_)*sin(phi_);
207  tmpboost(0,2) = - tan(phi_)*sin(phi_);
208  tmpboost(0,3) = - sin(alpha_)*sin(phi_);
209  tmpboost(1,0) = - cos(alpha_)*tan(phi_);
210  tmpboost(1,1) = 1.;
211  tmpboost(1,2) = cos(alpha_)*tan(phi_);
212  tmpboost(1,3) = 0.;
213  tmpboost(2,0) = 0.;
214  tmpboost(2,1) = - cos(alpha_)*sin(phi_);
215  tmpboost(2,2) = cos(phi_);
216  tmpboost(2,3) = - sin(alpha_)*sin(phi_);
217  tmpboost(3,0) = - sin(alpha_)*tan(phi_);
218  tmpboost(3,1) = 0.;
219  tmpboost(3,2) = sin(alpha_)*tan(phi_);
220  tmpboost(3,3) = 1.;
221  //cout<<"beta "<<beta_;
222  double gama=1.0/sqrt(1-beta_*beta_);
223  tmpboostZ(0,0)=gama;
224  tmpboostZ(0,1)=0.;
225  tmpboostZ(0,2)=-1.0*beta_*gama;
226  tmpboostZ(0,3)=0.;
227  tmpboostZ(1,0)=0.;
228  tmpboostZ(1,1) = 1.;
229  tmpboostZ(1,2)=0.;
230  tmpboostZ(1,3)=0.;
231  tmpboostZ(2,0)=-1.0*beta_*gama;
232  tmpboostZ(2,1) = 0.;
233  tmpboostZ(2,2)=gama;
234  tmpboostZ(2,3) = 0.;
235  tmpboostZ(3,0)=0.;
236  tmpboostZ(3,1)=0.;
237  tmpboostZ(3,2)=0.;
238  tmpboostZ(3,3) = 1.;
239 
240  tmpboostXYZ=tmpboost*tmpboostZ;
241  tmpboost.Invert();
242 
243 
244 
245  boost_ = new TMatrixD(tmpboostXYZ);
246  boost_->Print();
247 
248  return boost_;
249 }
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 293 of file MixBoostEvtVtxGenerator.cc.

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

Referenced by produce().

293  {
294 
295 
297  evt.getByToken(vtxLabel,input);
298 
299  double aX,aY,aZ;
300 
301  aX = input->begin()->position().x() + vtxOffset[0];
302  aY = input->begin()->position().y() + vtxOffset[1];
303  aZ = input->begin()->position().z() + vtxOffset[2];
304 
305  if(!fVertex) fVertex = new HepMC::FourVector();
306  fVertex->set(10.0*aX,10.0*aY,10.0*aZ,0.0); // HepMC positions in mm (RECO in cm)
307 
308  return fVertex;
309 
310 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
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 251 of file MixBoostEvtVtxGenerator.cc.

References gather_cfg::cout, Exception, fVertex, edm::Event::getByToken(), reco_application_tbsim_DetSim-Digi_cfg::mix, mixLabel, edm::Handle< T >::product(), and EnergyCorrector::pt.

Referenced by produce().

251  {
252 
253  const HepMC::GenEvent* inev = 0;
254 
256  evt.getByToken(mixLabel,cf);
258 
259  const HepMCProduct& bkg = mix.getObject(1);
260  if(!(bkg.isVtxGenApplied())){
261  throw cms::Exception("MatchVtx")<<"Input background does not have smeared vertex!"<<endl;
262  }else{
263  inev = bkg.GetEvent();
264  }
265 
266  HepMC::GenVertex* genvtx = inev->signal_process_vertex();
267  if(!genvtx){
268  cout<<"No Signal Process Vertex!"<<endl;
269  HepMC::GenEvent::particle_const_iterator pt=inev->particles_begin();
270  HepMC::GenEvent::particle_const_iterator ptend=inev->particles_end();
271  while(!genvtx || ( genvtx->particles_in_size() == 1 && pt != ptend ) ){
272  if(!genvtx) cout<<"No Gen Vertex!"<<endl;
273  if(pt == ptend) cout<<"End reached!"<<endl;
274  genvtx = (*pt)->production_vertex();
275  ++pt;
276  }
277  }
278  double aX,aY,aZ,aT;
279 
280  aX = genvtx->position().x();
281  aY = genvtx->position().y();
282  aZ = genvtx->position().z();
283  aT = genvtx->position().t();
284 
285  if(!fVertex) fVertex = new HepMC::FourVector();
286  fVertex->set(aX,aY,aZ,aT);
287 
288  return fVertex;
289 
290 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
edm::EDGetTokenT< CrossingFrame< HepMCProduct > > mixLabel
T const * product() const
Definition: Handle.h:81
tuple cout
Definition: gather_cfg.py:145
HepMC::FourVector * MixBoostEvtVtxGenerator::newVertex ( )
virtual

return a new event vertex

Definition at line 141 of file MixBoostEvtVtxGenerator.cc.

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

141  {
142 
143 
144  double X,Y,Z;
145 
146  double tmp_sigz = fRandom->fire(0., fSigmaZ);
147  Z = tmp_sigz + fZ0;
148 
149  double tmp_sigx = BetaFunction(Z,fZ0);
150  // need sqrt(2) for beamspot width relative to single beam width
151  tmp_sigx /= sqrt(2.0);
152  X = fRandom->fire(0.,tmp_sigx) + fX0; // + Z*fdxdz ;
153 
154  double tmp_sigy = BetaFunction(Z,fZ0);
155  // need sqrt(2) for beamspot width relative to single beam width
156  tmp_sigy /= sqrt(2.0);
157  Y = fRandom->fire(0.,tmp_sigy) + fY0; // + Z*fdydz;
158 
159  double tmp_sigt = fRandom->fire(0., fSigmaZ);
160  double T = tmp_sigt + fTimeOffset;
161 
162  if ( fVertex == 0 ) fVertex = new HepMC::FourVector();
163  fVertex->set(X,Y,Z,T);
164 
165  return fVertex;
166 }
const double Z[kNumberCalorimeter]
#define X(str)
Definition: MuonsGrabber.cc:48
T sqrt(T t)
Definition: SSEVec.h:18
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
void MixBoostEvtVtxGenerator::produce ( edm::Event evt,
const edm::EventSetup  
)
overridevirtual

Implements edm::EDProducer.

Definition at line 313 of file MixBoostEvtVtxGenerator.cc.

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

314 {
315  Handle<HepMCProduct> HepUnsmearedMCEvt;
316  evt.getByToken(signalLabel, HepUnsmearedMCEvt);
317 
318  // Copy the HepMC::GenEvent
319  HepMC::GenEvent* genevt = new HepMC::GenEvent(*HepUnsmearedMCEvt->GetEvent());
320  std::unique_ptr<edm::HepMCProduct> HepMCEvt(new edm::HepMCProduct(genevt));
321  // generate new vertex & apply the shift
322  //
323  HepMCEvt->applyVtxGen( useRecVertex ? getRecVertex(evt) : getVertex(evt) ) ;
324 
325  // HepMCEvt->boostToLab( GetInvLorentzBoost(), "vertex" );
326  // HepMCEvt->boostToLab( GetInvLorentzBoost(), "momentum" );
327 
328  evt.put(std::move(HepMCEvt));
329  return ;
330 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
edm::EDGetTokenT< HepMCProduct > signalLabel
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
def move
Definition: eostools.py:510
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 175 of file MixBoostEvtVtxGenerator.cc.

References Exception, fSigmaZ, and alignCSCRings::s.

176 {
177  if (s>=0 ) {
178  fSigmaZ=s;
179  }
180  else {
181  throw cms::Exception("LogicError")
182  << "Error in MixBoostEvtVtxGenerator::sigmaZ: "
183  << "Illegal resolution in Z (negative)";
184  }
185 }
void MixBoostEvtVtxGenerator::X0 ( double  m = 0)
inline
void MixBoostEvtVtxGenerator::Y0 ( double  m = 0)
inline
void MixBoostEvtVtxGenerator::Z0 ( double  m = 0)
inline

Member Data Documentation

double MixBoostEvtVtxGenerator::alpha_
private

Definition at line 94 of file MixBoostEvtVtxGenerator.cc.

Referenced by GetInvLorentzBoost().

double MixBoostEvtVtxGenerator::beta_
private

Definition at line 96 of file MixBoostEvtVtxGenerator.cc.

Referenced by GetInvLorentzBoost().

TMatrixD* MixBoostEvtVtxGenerator::boost_
private

Definition at line 104 of file MixBoostEvtVtxGenerator.cc.

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

double MixBoostEvtVtxGenerator::falpha
private

Definition at line 101 of file MixBoostEvtVtxGenerator.cc.

double MixBoostEvtVtxGenerator::fbetastar
private

Definition at line 100 of file MixBoostEvtVtxGenerator.cc.

Referenced by BetaFunction().

double MixBoostEvtVtxGenerator::femittance
private

Definition at line 100 of file MixBoostEvtVtxGenerator.cc.

Referenced by BetaFunction().

CLHEP::RandGaussQ* MixBoostEvtVtxGenerator::fRandom
private

Definition at line 107 of file MixBoostEvtVtxGenerator.cc.

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

double MixBoostEvtVtxGenerator::fSigmaZ
private

Definition at line 98 of file MixBoostEvtVtxGenerator.cc.

Referenced by newVertex(), and sigmaZ().

double MixBoostEvtVtxGenerator::fTimeOffset
private

Definition at line 105 of file MixBoostEvtVtxGenerator.cc.

Referenced by newVertex().

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

Definition at line 97 of file MixBoostEvtVtxGenerator.cc.

Referenced by newVertex().

double MixBoostEvtVtxGenerator::fY0
private

Definition at line 97 of file MixBoostEvtVtxGenerator.cc.

Referenced by newVertex().

double MixBoostEvtVtxGenerator::fZ0
private

Definition at line 97 of file MixBoostEvtVtxGenerator.cc.

Referenced by newVertex().

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

Definition at line 111 of file MixBoostEvtVtxGenerator.cc.

Referenced by getVertex().

double MixBoostEvtVtxGenerator::phi_
private

Definition at line 94 of file MixBoostEvtVtxGenerator.cc.

Referenced by GetInvLorentzBoost().

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

Definition at line 110 of file MixBoostEvtVtxGenerator.cc.

Referenced by produce().

bool MixBoostEvtVtxGenerator::useRecVertex
private

Definition at line 112 of file MixBoostEvtVtxGenerator.cc.

Referenced by produce().

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

Definition at line 109 of file MixBoostEvtVtxGenerator.cc.

Referenced by getRecVertex().

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

Definition at line 113 of file MixBoostEvtVtxGenerator.cc.

Referenced by getRecVertex(), and MixBoostEvtVtxGenerator().