149 MsgStream msglog(
msgSvc(), name() );
150 msglog << MSG::INFO <<
">>> HistSample from execute" << endmsg;
167 // (*it)->pGenEvt()->print();
169 // fix the STDHEP mess for the Z status
170 int properStatus = 2;
171 // switch ( (*it)->generatorName()[0] ) {
176 // properStatus = 12;
179 // properStatus = 195;
185 HepMC::GenEvent* genEvt = (*it);
186 int g_id = genEvt->signal_process_id();
187 switch ( first_generator(g_id) ) {
203 int number_particles = 0;
205 int number_charged = 0;
206 // Iterate over MC particles
207 for(HepMC::GenEvent::particle_iterator pitr=genEvt->particles_begin();
208 pitr!=genEvt->particles_end(); ++pitr ){
210 // cout << "particle " << ((*pitr)->pdg_id()) << " status " <<
211 ((*pitr)->status()) << endl;
214 if( ((*pitr)->pdg_id()) == 23 && ((*pitr)->status()) == properStatus ){
215 HepMC::GenVertex::particle_iterator firstChild =
216 (*pitr)->end_vertex()->particles_begin(HepMC::children);
217 HepMC::GenVertex::particle_iterator endChild =
218 (*pitr)->end_vertex()->particles_end(HepMC::children);
219 // plot Pt and mass of the Z (generator values)
220 if( ((*firstChild)->pdg_id()) != 23 ){
221 double ZPt = (*pitr)->momentum().perp();
222 m_hZPtall->fill( ZPt, 1.);
223 double Zmass = (*pitr)->momentum().m();
224 m_massZall->fill(Zmass, 1.);
235 HepMC::GenVertex::particle_iterator thisChild = firstChild;
236 for(; thisChild != endChild++; ++thisChild){
237 if( ((*thisChild)->pdg_id()) != 23 ){
238 // cout << "Zchild id " << (*thisChild)->pdg_id() << endl;
240 if( abs((*thisChild)->pdg_id()) == 11 || abs((*thisChild)->pdg_id()) ==
241 13 || abs((*thisChild)->pdg_id()) == 15 ){ if( abs((*thisChild)->pdg_id()) == 11 )++nelds;
242 if( abs((*thisChild)->pdg_id()) == 13 )++nmuds;
243 if( abs((*thisChild)->pdg_id()) == 15 )++ntauds;
244 sumx += (*thisChild)->momentum().x();
245 sumy += (*thisChild)->momentum().y();
246 sumz += (*thisChild)->momentum().z();
247 sume += (*thisChild)->momentum().e();
251 // cout << "Zchildren " << Zchild << " nelds " << nelds << " nmuds " << nmuds
252 << " ntauds " << ntauds << endl; if( Zchild != 0 ){ double PtZ2 = sumx*sumx + sumy*sumy;
254 if(PtZ2 > 0.) PtZ = sqrt(PtZ2);
255 if(PtZ != 0.)m_hZPt->fill( PtZ, 1.);
256 double massZ2 = sume*sume - sumx*sumx - sumy*sumy - sumz*sumz;
258 if(massZ2 > 0.) massZ = sqrt(massZ2);
259 if(massZ != 0.)m_massZ->fill( massZ, 1.);
261 m_hZPte->fill( PtZ, 1.);
262 m_massZe->fill( massZ, 1.);
265 m_hZPtm->fill( PtZ, 1.);
266 m_massZm->fill( massZ, 1.);
269 m_hZPtt->fill( PtZ, 1.);
270 m_massZt->fill( massZ, 1.);
274 // all decays to l+l- pairs in the event
275 if( (*pitr)->end_vertex() ){
276 HepMC::GenVertex::particle_iterator fstChild =
277 (*pitr)->end_vertex()->particles_begin(HepMC::children);
278 HepMC::GenVertex::particle_iterator lstChild =
279 (*pitr)->end_vertex()->particles_end(HepMC::children);
287 HepMC::GenVertex::particle_iterator aChild = fstChild;
288 for(; aChild != lstChild++; ++aChild){
289 if( abs((*aChild)->pdg_id()) == 11 || abs((*aChild)->pdg_id()) == 13 ||
290 abs((*aChild)->pdg_id()) == 15 ){
291 if( abs((*aChild)->pdg_id()) == 11 )++nel;
292 if( abs((*aChild)->pdg_id()) == 13 )++nmu;
293 if( abs((*aChild)->pdg_id()) == 15 )++ntau;
294 sumpx += (*aChild)->momentum().x();
295 sumpy += (*aChild)->momentum().y();
296 sumpz += (*aChild)->momentum().z();
297 sumpe += (*aChild)->momentum().e();
300 if(nel == 2 || nmu == 2 || ntau == 2 ){
301 double PtPair2 = sumpx*sumpx + sumpy*sumpy;
303 if(PtPair2 > 0.) PtPair = sqrt(PtPair2);
304 double massPair2 = sumpe*sumpe - sumpx*sumpx - sumpy*sumpy - sumpz*sumpz;
305 double massPair = 0.;
306 if(massPair2 > 0.) massPair = sqrt(massPair2);
308 m_hPtPaire->fill( PtPair, 1.);
309 m_massPaire->fill( massPair, 1.);
312 m_hPtPairm->fill( PtPair, 1.);
313 m_massPairm->fill( massPair, 1.);
316 m_hPtPairt->fill( PtPair, 1.);
317 m_massPairt->fill( massPair, 1.);
323 HepPDT::ParticleData* ap = m_particleTable->particle( abs( (*pitr)->pdg_id() )
327 // std::cout << "ChargeService WARNING: abs(id) "
328 // << abs((*pitr)->pdg_id())
329 // << " is not in particle data table" << std::endl;
336 if( ((*pitr)->status() == 1) && ( ! (*pitr)->end_vertex()) ) {
338 if( ((*pitr)->pdg_id()) == 11 ){
339 double ePt = (*pitr)->momentum().perp();
340 m_hpte->fill( ePt, 1.);
344 double chargedPt = (*pitr)->momentum().perp();
345 double chargedEta = (*pitr)->momentum().pseudoRapidity();
346 m_hChargedPt->fill( chargedPt, 1.);
347 m_hChargedEta->fill( chargedEta, 1.);
349 double px = (*pitr)->momentum().x();
350 double py = (*pitr)->momentum().y();
351 double pz = (*pitr)->momentum().z();
352 double pe = (*pitr)->momentum().e();
353 double pp2 = px*px + py*py + pz*pz;
355 if(pp2 > 0.) pp3 = sqrt(pp2);
357 if( (pe-pz) != 0. && (pe+pz)/(pe-pz) > 0. ) y =
358 (1./2.)*log((pe+pz)/(pe-pz)); double eta = -999.; if( (pp3-pz) != 0. && (pp3+pz)/(pp3-pz) >
359 0. ) eta = (1./2.)*log((pp3+pz)/(pp3-pz)); m_rapidity->fill( y, 1.); m_pseudorapidity->fill(
364 m_hgenerated->fill( number_particles, 1.);
365 m_hfinal->fill( final_state, 1.);
366 m_ncharged->fill( number_charged, 1.);
371 return StatusCode::SUCCESS;