9 #include "HepMC/PythiaWrapper.h"
10 #include "HepMC/IO_HEPEVT.h"
17 particleOrigin_(iConfig.getParameter<std::
string>(
"particleOrigin")),
18 forceTauPolarization_(iConfig.getParameter<std::
string>(
"forceTauPolarization")),
19 forceTauDecay_(iConfig.getParameter<std::
string>(
"forceTauDecay")),
20 generatorMode_(iConfig.getParameter<std::
string>(
"generatorMode")),
21 gunParticle_(iConfig.getParameter<int>(
"gunParticle")),
22 forceTauPlusHelicity_(iConfig.getParameter<int>(
"forceTauPlusHelicity")),
23 forceTauMinusHelicity_(iConfig.getParameter<int>(
"forceTauMinusHelicity"))
30 edm::LogInfo(
"MuonReplacement") <<
"[ParticleReplacer::ParticleReplacer] "
33 edm::LogInfo(
"MuonReplacement") <<
"[ParticleReplacer::ParticleReplacer] "
36 edm::LogInfo(
"MuonReplacement") <<
"[ParticleReplacer::ParticleReplacer] "
39 edm::LogInfo(
"MuonReplacement") <<
"[ParticleReplacer::ParticleReplacer] "
42 std::memset(
pol1_, 0, 4*
sizeof(
float));
43 std::memset(
pol2_, 0, 4*
sizeof(
float));
46 throw cms::Exception(
"Configuration") <<
"Generator mode other than Tauola is not supported" << std::endl;
48 throw cms::Exception(
"UnimplementedFeature") <<
"ParticleReplacerParticleGun is not usable yet." << std::endl;
76 throw cms::Exception(
"UnimplementedFeature") <<
"ParticleReplacerParticleGun does NOT support merging at HepMC level" << std::endl;
78 std::auto_ptr<HepMC::GenEvent> evt(0);
79 std::vector<HepMC::FourVector> muons_corrected;
80 muons_corrected.reserve(muons.size());
85 for(
unsigned int i=0;
i<muons_corrected.size(); ++
i) {
86 HepMC::FourVector&
muon = muons_corrected[
i];
93 std::cout <<
" ///////////////////// After py1ent, before pyhepc /////////////////////" << std::endl;
101 std::cout <<
" ///////////////////// After pyhepc, before vertex shift /////////////////////" << std::endl;
102 HepMC::HEPEVT_Wrapper::print_hepevt();
105 int nparticles = HepMC::HEPEVT_Wrapper::number_entries();
106 HepMC::ThreeVector
shift(0,0,0);
109 throw cms::Exception(
"LogicError") <<
"Particle origin set to primaryVertex, but pvtx is null!" << std::endl;
111 shift.setX(evtVtx->
x()*10);
112 shift.setY(evtVtx->
y()*10);
113 shift.setZ(evtVtx->
z()*10);
115 for(
int i=1;
i <= nparticles; ++
i) {
117 throw cms::Exception(
"LogicError") <<
"Particle in HEPEVT is " << HepMC::HEPEVT_Wrapper::id(
i)
119 <<
" for index " <<
i << std::endl;
124 shift.setX(muon.
vx()*10);
125 shift.setY(muon.
vy()*10);
126 shift.setZ(muon.
vz()*10);
129 HepMC::HEPEVT_Wrapper::set_position(
i,
137 std::cout <<
" ///////////////////// After vertex shift, before pyhepc/tauola /////////////////////" << std::endl;
138 HepMC::HEPEVT_Wrapper::print_hepevt();
150 for(
unsigned int i=0;
i<muons_corrected.size(); ++
i) {
155 std::cout <<
" ///////////////////// After tauola, before pyhepc /////////////////////" << std::endl;
156 HepMC::HEPEVT_Wrapper::print_hepevt();
160 std::cout <<
" ///////////////////// After pyhepc, before vertex fix /////////////////////" << std::endl;
175 std::cout <<
" ///////////////////// After vertex fix, before pyexec /////////////////////" << std::endl;
182 std::cout <<
" ///////////////////// After pyhepc, before pyexec /////////////////////" << std::endl;
190 std::cout <<
" ///////////////////// After pyexec, before pyhepc /////////////////////" << std::endl;
196 HepMC::IO_HEPEVT
conv;
197 evt = std::auto_ptr<HepMC::GenEvent>(
new HepMC::GenEvent(*conv.read_next_event()));
202 std::cout << std::endl <<
"Vertices: " << std::endl;
203 for(HepMC::GenEvent::vertex_const_iterator iter = evt->vertices_begin(); iter != evt->vertices_end(); ++iter) {
204 std::cout <<
"Vertex " << (*iter)->id() <<
", barcode " << (*iter)->barcode() << std::endl;
206 HepMC::ThreeVector
point = (*iter)->point3d();
207 std::cout <<
" Point (" << point.x() <<
", " << point.y() <<
", " << point.z() <<
")" << std::endl;
210 for(HepMC::GenVertex::particles_in_const_iterator
pi = (*iter)->particles_in_const_begin();
pi != (*iter)->particles_in_const_end(); ++
pi) {
215 for(HepMC::GenVertex::particles_out_const_iterator
pi = (*iter)->particles_out_const_begin();
pi != (*iter)->particles_out_const_end(); ++
pi) {
229 for(std::vector<reco::Particle>::const_iterator iMuon = muons.begin(); iMuon != muons.end(); ++iMuon) {
232 double E =
sqrt(
tauMass*
tauMass + vec.x()*vec.x() + vec.y()*vec.y() + vec.z()*vec.z());
234 corrected.push_back(HepMC::FourVector(vec.x(), vec.y(), vec.z(), E));
239 for(std::vector<reco::Particle>::const_iterator iMuon = muons.begin(); iMuon != muons.end(); ++iMuon) {
240 corrected.push_back(iMuon->p4());
290 edm::LogError(
"MuonReplacement") <<
"[ParticleReplacerAlgoParticleGun::forceTauoladecays] "
291 <<
"Unknown value for forcing tau decays: " <<
forceTauDecay_ << std::endl;
296 if(
abs(pdg_id) != 15) {
297 edm::LogError(
"MuonReplacement") <<
"[ParticleReplacerAlgoParticleGun::tauola_forParticleGuns] "
298 <<
"Trying to decay something else than tau: pdg_id = " << pdg_id << std::endl;
341 else if (pdg_id == 15){
387 else return pol2_[2];
403 else return pol1_[2];
410 edm::LogError(
"MuonReplacement") <<
"[ParticleReplacerAlgoParticleGun::tauHelicity] "
411 <<
"tauHelicity undetermined, returning 0" << std::endl;
417 uint32_t randomNumber =
rand();
418 if(randomNumber%2 > 0.5)
return 1;
T getParameter(std::string const &) const
std::string generatorMode_
int forceTauMinusHelicity_
void tauola_forParticleGun(int, int, const HepMC::FourVector &)
static HepMC::IO_HEPEVT conv
double y() const
y coordinate
gen::Pythia6Service pythia_
double vz() const
z coordinate of vertex position
float randomPolarization()
T x() const
Cartesian x coordinate.
std::string forceTauPolarization_
void call_pylist(int mode)
std::string particleOrigin_
Abs< T >::type abs(const T &t)
double z() const
y coordinate
void correctTauMass(const std::vector< reco::Particle > &, std::vector< HepMC::FourVector > &)
double x() const
x coordinate
double vx() const
x coordinate of vertex position
std::string forceTauDecay_
std::auto_ptr< HepMC::GenEvent > produce(const std::vector< reco::Particle > &, const reco::Vertex *=0, const HepMC::GenEvent *=0, MCParticleReplacer *=0)
math::XYZTLorentzVector LorentzVector
Lorentz vector.
static unsigned int const shift
#define DEFINE_EDM_PLUGIN(factory, type, name)
int forceTauPlusHelicity_
double vy() const
y coordinate of vertex position
ParticleReplacerParticleGun(const edm::ParameterSet &)
gen::TauolaInterfaceBase * tauola_
T get(const Candidate &c)
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
void forceTauolaTauDecays()