6 #include "HepMC/PythiaWrapper.h"
7 #include "HepMC/IO_HEPEVT.h"
12 particleOrigin_(iConfig.getParameter<std::string>(
"particleOrigin")),
13 forceTauPolarization_(iConfig.getParameter<std::string>(
"forceTauPolarization")),
14 forceTauDecay_(iConfig.getParameter<std::string>(
"forceTauDecay")),
15 generatorMode_(iConfig.getParameter<std::string>(
"generatorMode")),
16 gunParticle_(iConfig.getParameter<int>(
"gunParticle")),
17 forceTauPlusHelicity_(iConfig.getParameter<int>(
"forceTauPlusHelicity")),
18 forceTauMinusHelicity_(iConfig.getParameter<int>(
"forceTauMinusHelicity")),
29 edm::LogInfo(
"MuonReplacement") <<
"[ParticleReplacer::ParticleReplacer] "
32 edm::LogInfo(
"MuonReplacement") <<
"[ParticleReplacer::ParticleReplacer] "
35 edm::LogInfo(
"MuonReplacement") <<
"[ParticleReplacer::ParticleReplacer] "
38 edm::LogInfo(
"MuonReplacement") <<
"[ParticleReplacer::ParticleReplacer] "
41 std::memset(
pol1_, 0, 4*
sizeof(
float));
42 std::memset(
pol2_, 0, 4*
sizeof(
float));
45 throw cms::Exception(
"Configuration") <<
"Generator mode other than Tauola is not supported" << std::endl;
47 throw cms::Exception(
"UnimplementedFeature") <<
"ParticleReplacerParticleGun is not usable yet." << std::endl;
79 throw cms::Exception(
"UnimplementedFeature") <<
"ParticleReplacerParticleGun does NOT support merging at HepMC level" << std::endl;
81 std::auto_ptr<HepMC::GenEvent> evt(0);
82 std::vector<HepMC::FourVector> muons_corrected;
83 muons_corrected.reserve(muons.size());
88 for(
unsigned int i=0;
i<muons_corrected.size(); ++
i) {
89 HepMC::FourVector&
muon = muons_corrected[
i];
96 std::cout <<
" ///////////////////// After py1ent, before pyhepc /////////////////////" << std::endl;
104 std::cout <<
" ///////////////////// After pyhepc, before vertex shift /////////////////////" << std::endl;
105 HepMC::HEPEVT_Wrapper::print_hepevt();
108 int nparticles = HepMC::HEPEVT_Wrapper::number_entries();
109 HepMC::ThreeVector
shift(0,0,0);
112 throw cms::Exception(
"LogicError") <<
"Particle origin set to primaryVertex, but pvtx is null!" << std::endl;
114 shift.setX(pvtx->
x()*10);
115 shift.setY(pvtx->
y()*10);
116 shift.setZ(pvtx->
z()*10);
118 for(
int i=1;
i <= nparticles; ++
i) {
122 <<
" for index " <<
i << std::endl;
127 shift.setX(muon.
vx()*10);
128 shift.setY(muon.
vy()*10);
129 shift.setZ(muon.
vz()*10);
132 HepMC::HEPEVT_Wrapper::set_position(
i,
140 std::cout <<
" ///////////////////// After vertex shift, before pyhepc/tauola /////////////////////" << std::endl;
141 HepMC::HEPEVT_Wrapper::print_hepevt();
153 for(
unsigned int i=0;
i<muons_corrected.size(); ++
i) {
158 std::cout <<
" ///////////////////// After tauola, before pyhepc /////////////////////" << std::endl;
159 HepMC::HEPEVT_Wrapper::print_hepevt();
163 std::cout <<
" ///////////////////// After pyhepc, before vertex fix /////////////////////" << std::endl;
178 std::cout <<
" ///////////////////// After vertex fix, before pyexec /////////////////////" << std::endl;
185 std::cout <<
" ///////////////////// After pyhepc, before pyexec /////////////////////" << std::endl;
193 std::cout <<
" ///////////////////// After pyexec, before pyhepc /////////////////////" << std::endl;
199 HepMC::IO_HEPEVT
conv;
200 evt = std::auto_ptr<HepMC::GenEvent>(
new HepMC::GenEvent(*conv.read_next_event()));
205 std::cout << std::endl <<
"Vertices: " << std::endl;
206 for(HepMC::GenEvent::vertex_const_iterator iter = evt->vertices_begin(); iter != evt->vertices_end(); ++iter) {
207 std::cout <<
"Vertex " << (*iter)->id() <<
", barcode " << (*iter)->barcode() << std::endl;
209 HepMC::ThreeVector
point = (*iter)->point3d();
210 std::cout <<
" Point (" << point.x() <<
", " << point.y() <<
", " << point.z() <<
")" << std::endl;
213 for(HepMC::GenVertex::particles_in_const_iterator
pi = (*iter)->particles_in_const_begin();
pi != (*iter)->particles_in_const_end(); ++
pi) {
218 for(HepMC::GenVertex::particles_out_const_iterator
pi = (*iter)->particles_out_const_begin();
pi != (*iter)->particles_out_const_end(); ++
pi) {
231 for(reco::MuonCollection::const_iterator iMuon = muons.begin(); iMuon != muons.end(); ++iMuon) {
234 double E =
sqrt(
tauMass*
tauMass + vec.x()*vec.x() + vec.y()*vec.y() + vec.z()*vec.z());
236 corrected.push_back(HepMC::FourVector(vec.x(), vec.y(), vec.z(), E));
241 for(reco::MuonCollection::const_iterator iMuon = muons.begin(); iMuon != muons.end(); ++iMuon) {
242 corrected.push_back(iMuon->p4());
292 edm::LogError(
"MuonReplacement") <<
"[ParticleReplacerAlgoParticleGun::forceTauoladecays] "
293 <<
"Unknown value for forcing tau decays: " <<
forceTauDecay_ << std::endl;
297 if(
abs(pdg_id) != 15) {
298 edm::LogError(
"MuonReplacement") <<
"[ParticleReplacerAlgoParticleGun::tauola_forParticleGuns] "
299 <<
"Trying to decay something else than tau: pdg_id = " << pdg_id << std::endl;
342 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;
416 uint32_t randomNumber =
rand();
417 if(randomNumber%2 > 0.5)
return 1;
std::string generatorMode_
int forceTauMinusHelicity_
void call_pylist(int mode)
static HepMC::IO_HEPEVT conv
double y() const
y coordinate
void correctTauMass(const reco::MuonCollection &muons, std::vector< HepMC::FourVector > &corrected)
gen::Pythia6Service pythia_
float randomPolarization()
virtual double vy() const
y coordinate of vertex position
void tauola_forParticleGun(int tau_idx, int pdg_id, const HepMC::FourVector &particle_momentum)
std::vector< Muon > MuonCollection
collection of Muon objects
std::string forceTauPolarization_
float tauHelicity(int pdg_id)
std::string particleOrigin_
ParticleReplacerParticleGun(const edm::ParameterSet &, bool)
double z() const
y coordinate
virtual double vz() const
z coordinate of vertex position
double x() const
x coordinate
std::string forceTauDecay_
math::XYZTLorentzVector LorentzVector
Lorentz vector.
virtual ~ParticleReplacerParticleGun()
std::auto_ptr< HepMC::GenEvent > produce(const reco::MuonCollection &muons, const reco::Vertex *pvtx=0, const HepMC::GenEvent *genEvt=0)
static unsigned int const shift
virtual double vx() const
x coordinate of vertex position
int forceTauPlusHelicity_
*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()