122 int idParticles[100];
127 CLHEP::HepLorentzVector pParticles[100];
129 if (m_inputFile >> nParticles){
130 for (
int i = 0; i < nParticles; i++){
131 m_inputFile >> idParticles[i];
132 m_inputFile >> pxParticle; pParticles[i].setPx(pxParticle);
133 m_inputFile >> pyParticle; pParticles[i].setPy(pyParticle);
134 m_inputFile >> pzParticle; pParticles[i].setPz(pzParticle);
135 m_inputFile >> eParticle; pParticles[i].setE(eParticle);
140 cout <<
"ManualGenerator: RAN OUT OF INPUT EVENTS FROM FILE "
141 << m_inputFileName << endl;
142 return StatusCode::SUCCESS;
149 cout <<
"ManualGenerator: PROCESSING EVENT " << ++m_eventCounter << endl;
150 cout << nParticles << endl;
151 for (
int i = 0; i < nParticles; i++){
152 cout << idParticles[i] <<
"\t";
153 cout << pParticles[i].px() <<
"\t";
154 cout << pParticles[i].py() <<
"\t";
155 cout << pParticles[i].pz() <<
"\t";
156 cout << pParticles[i].e() << endl;
162 HepMC::GenEvent* genEvent = 0;
163 SmartDataPtr<McGenEventCol> initialMcCol(eventSvc(),
"/Event/Gen");
164 if (initialMcCol == 0){
175 cout <<
"ManualGenerator: COULD NOT FIND THE ORIGINAL MC EVENT COLLECTION" << endl;
180 genEvent = (*(initialMcCol->begin()))->getGenEvt();
188 HepMC::GenParticle* decayParticle = NULL;
189 for(HepMC::GenEvent::particle_const_iterator igenParticle = genEvent->particles_begin();
190 igenParticle != genEvent->particles_end(); ++igenParticle ){
191 decayParticle = *igenParticle;
192 if (decayParticle->status() == 1 && abs(decayParticle->pdg_id()) != 22)
break;
195 cout <<
"ManualGenerator: COULD NOT FIND A PARTICLE TO DECAY" << endl;
203 HepMC::GenVertex* initialVertex = decayParticle->production_vertex();
204 HepMC::GenVertex* newVertex =
new HepMC::GenVertex(initialVertex->position());
205 genEvent->add_vertex(newVertex);
206 newVertex->add_particle_in(decayParticle);
212 CLHEP::HepLorentzVector initialFourMomentum(decayParticle->momentum().px(),
213 decayParticle->momentum().py(),
214 decayParticle->momentum().pz(),
215 decayParticle->momentum().e());
216 CLHEP::HepLorentzVector finalFourMomentum(0,0,0,0);
217 for (
int i = 0; i < nParticles; i++){
219 finalFourMomentum += pParticles[i];
221 if ((fabs(initialFourMomentum.px() - finalFourMomentum.px()) > 0.0001) ||
222 (fabs(initialFourMomentum.py() - finalFourMomentum.py()) > 0.0001) ||
223 (fabs(initialFourMomentum.pz() - finalFourMomentum.pz()) > 0.0001) ||
224 (fabs(initialFourMomentum.e() - finalFourMomentum.e()) > 0.01)){
225 cout <<
"ManualGenerator: INITIAL AND FINAL STATES HAVE INCONSISTENT 4-MOMENTA" << endl;
226 cout <<
"delta px = " << initialFourMomentum.px() - finalFourMomentum.px() << endl;
227 cout <<
"delta py = " << initialFourMomentum.py() - finalFourMomentum.py() << endl;
228 cout <<
"delta pz = " << initialFourMomentum.pz() - finalFourMomentum.pz() << endl;
229 cout <<
"delta e = " << initialFourMomentum.e() - finalFourMomentum.e() << endl;
236 for (
int i = 0; i < nParticles; i++){
237 newVertex->add_particle_out(
new GenParticle(pParticles[i], idParticles[i], 1));
243 return StatusCode::SUCCESS;