12 #include "HepMC/GenEvent.h"
13 #include "HepMC/IO_HEPEVT.h"
14 #include "HepMC/HEPEVT_Wrapper.h"
113 for (
int ip=0; ip<evt->particles_size(); ip++ )
122 bool tau_leptonic_decay =
false;
123 int iTauDescCounter = 0;
126 for (
int iv=1; iv<=evt->vertices_size(); iv++ )
129 HepMC::GenVertex* vtx = evt->barcode_to_vertex( -iv ) ;
130 if ( vtx->particles_in_size() != 1 )
continue;
131 if ( vtx->particles_out_size() <= 0 )
continue;
134 bool legalVtx =
false;
135 for ( HepMC::GenVertex::particle_iterator pitr=vtx->particles_begin(HepMC::children);
136 pitr != vtx->particles_end(HepMC::children); ++pitr)
138 if ( (*pitr)->status() == 1 || (*pitr)->end_vertex() )
146 if ( !legalVtx )
continue;
152 HepMC::HEPEVT_Wrapper::zero_everything();
158 HepMC::HEPEVT_Wrapper::set_id( index, (*(vtx->particles_in_const_begin()))->pdg_id() );
159 HepMC::FourVector vec4;
160 vec4 = (*(vtx->particles_in_const_begin()))->momentum();
161 HepMC::HEPEVT_Wrapper::set_momentum( index, vec4.x(), vec4.y(), vec4.z(), vec4.e() );
162 HepMC::HEPEVT_Wrapper::set_mass( index, (*(vtx->particles_in_const_begin()))->generated_mass() );
163 HepMC::HEPEVT_Wrapper::set_position( index, vtx->position().x(), vtx->position().y(),
164 vtx->position().z(), vtx->position().t() );
165 HepMC::HEPEVT_Wrapper::set_status( index, (*(vtx->particles_in_const_begin()))->status() );
166 HepMC::HEPEVT_Wrapper::set_parents( index, 0, 0 );
167 fBarcodes.push_back( (*(vtx->particles_in_const_begin()))->barcode() );
174 for ( HepMC::GenVertex::particle_iterator pitr=vtx->particles_begin(HepMC::children);
175 pitr != vtx->particles_end(HepMC::children); ++pitr)
177 if (
abs((*pitr)->pdg_id()) == 11 ||
abs((*pitr)->pdg_id()) == 13 )
180 tau_leptonic_decay =
true;
184 if ( vtx->particles_begin(HepMC::children) == vtx->particles_begin(HepMC::descendants) &&
185 vtx->particles_end(HepMC::children) == vtx->particles_end(HepMC::descendants) )
187 nTauDesc = vtx->particles_out_size();
191 for ( HepMC::GenVertex::particle_iterator pitr1=vtx->particles_begin(HepMC::children);
192 pitr1 != vtx->particles_end(HepMC::children); ++pitr1)
204 int mbcode = (*(vtx->particles_in_const_begin()))->barcode();
209 for ( HepMC::GenVertex::particle_iterator pitr=vtx->particles_begin(HepMC::children);
210 pitr != vtx->particles_end(HepMC::children); ++pitr)
216 vec4 = (*pitr)->momentum();
217 double mass2 = vec4.m2();
218 double pxn = vec4.px() *
fScaleFactors[mbcode-1].weights.x();
219 double pyn = vec4.py() *
fScaleFactors[mbcode-1].weights.y();
220 double pzn = vec4.pz() *
fScaleFactors[mbcode-1].weights.z();
221 double en =
sqrt( pxn*pxn + pyn*pyn + pzn*pzn + mass2 );
222 (*pitr)->set_momentum( HepMC::FourVector(pxn,pyn,pzn,en) );
223 int curbcode = (*pitr)->barcode();
233 if ( (*pitr)->status() == 1 || (*pitr)->end_vertex() )
236 vec4 = (*pitr)->momentum();
237 HepMC::HEPEVT_Wrapper::set_id( index, (*pitr)->pdg_id() );
238 HepMC::HEPEVT_Wrapper::set_momentum( index, vec4.x(), vec4.y(), vec4.z(), vec4.e() );
239 HepMC::HEPEVT_Wrapper::set_mass( index, (*pitr)->generated_mass() );
240 vec4 = (*pitr)->production_vertex()->position();
241 HepMC::HEPEVT_Wrapper::set_position( index, vec4.x(), vec4.y(), vec4.z(), vec4.t() );
242 HepMC::HEPEVT_Wrapper::set_status( index, (*pitr)->status() );
243 HepMC::HEPEVT_Wrapper::set_parents( index, 1, 1 );
244 fBarcodes.push_back( (*pitr)->barcode() );
256 int nentries =
index;
260 HepMC::HEPEVT_Wrapper::set_children ( index, 2, lastDau );
265 HepMC::HEPEVT_Wrapper::set_number_entries( nentries );
288 tau_leptonic_decay =
false;
294 HepMC::HEPEVT_Wrapper::set_event_number( evt->event_number() );
307 if ( HepMC::HEPEVT_Wrapper::number_entries() > nentries )
315 int largestBarcode = -1;
317 for (
int ip=1; ip<Nbcodes; ip++ )
321 if ( bcode > largestBarcode ) largestBarcode = bcode;
322 double px = HepMC::HEPEVT_Wrapper::px(ip+1);
323 double py = HepMC::HEPEVT_Wrapper::py(ip+1);
324 double pz = HepMC::HEPEVT_Wrapper::pz(ip+1);
325 double e = HepMC::HEPEVT_Wrapper::e(ip+1);
326 HepMC::FourVector mom4 = prt->momentum();
339 prt->set_momentum( HepMC::FourVector(px,py,pz,e) );
347 int newlyGen = HepMC::HEPEVT_Wrapper::number_entries() - nentries;
349 if ( largestBarcode < evt->particles_size() )
355 for (
int ipp=evt->particles_size(); ipp>largestBarcode; ipp-- )
357 (evt->barcode_to_particle(ipp))->suggest_barcode( ipp+newlyGen );
363 for (
int ipnw=1; ipnw<=newlyGen; ipnw++ )
365 int nbcode = largestBarcode+ipnw;
366 int pdg_id = HepMC::HEPEVT_Wrapper::id( nentries+ipnw );
368 double px = HepMC::HEPEVT_Wrapper::px( nentries+ipnw );
369 double py = HepMC::HEPEVT_Wrapper::py( nentries+ipnw );
370 double pz = HepMC::HEPEVT_Wrapper::pz( nentries+ipnw );
371 double e = HepMC::HEPEVT_Wrapper::e( nentries+ipnw );
376 NewPart->set_generated_mass( m );
377 NewPart->suggest_barcode( nbcode );
378 vtx->add_particle_out( NewPart ) ;
void attachParticles(HepMC::GenEvent *, HepMC::GenVertex *, int)
double phoran_(int *idummy)
std::vector< Scaling > fScaleFactors
std::vector< int > fBarcodes
bool fAvoidTauLeptonicDecays
std::vector< std::string > fSpecialSettings
CLHEP::HepRandomEngine * decayRandomEngine
HepMC::GenEvent * apply(HepMC::GenEvent *)