47 Algorithm(name, pSvcLocator),
48 m_hgenerated(0), m_hfinal(0), m_ncharged(0),
49 m_hChargedPt(0), m_hChargedEta(0),
50 m_hZPtall(0), m_hZPt(0), m_hZPte(0), m_hZPtm(0), m_hZPtt(0),
51 m_massZall(0), m_massZ(0), m_massZe(0), m_massZm(0), m_massZt(0),
52 m_hPtPaire(0), m_hPtPairm(0), m_hPtPairt(0),
53 m_massPaire(0), m_massPairm(0), m_massPairt(0),
54 m_rapidity(0), m_pseudorapidity(0), m_hpte()
57 declareProperty(
"HistogramFlag", m_produceHistogram =
true );
133 MsgStream msglog(messageService(), name());
134 msglog << MSG::INFO <<
">>> HistSample from execute" << endreq;
151// (*it)->pGenEvt()->print();
153// fix the STDHEP mess for the Z status
154 int properStatus = 2;
155// switch ( (*it)->generatorName()[0] ) {
163// properStatus = 195;
169 HepMC::GenEvent* genEvt = (*it);
170 int g_id = genEvt->signal_process_id();
171 switch ( first_generator(g_id) ) {
187 int number_particles = 0;
189 int number_charged = 0;
190// Iterate over MC particles
191 for(HepMC::GenEvent::particle_iterator pitr=genEvt->particles_begin();
192 pitr!=genEvt->particles_end(); ++pitr ){
194// cout << "particle " << ((*pitr)->pdg_id()) << " status " << ((*pitr)->status()) << endl;
197 if( ((*pitr)->pdg_id()) == 23 && ((*pitr)->status()) == properStatus ){
198 HepMC::GenVertex::particle_iterator firstChild =
199 (*pitr)->end_vertex()->particles_begin(HepMC::children);
200 HepMC::GenVertex::particle_iterator endChild =
201 (*pitr)->end_vertex()->particles_end(HepMC::children);
202// plot Pt and mass of the Z (generator values)
203 if( ((*firstChild)->pdg_id()) != 23 ){
204 double ZPt = (*pitr)->momentum().perp();
205 m_hZPtall->fill( ZPt, 1.);
206 double Zmass = (*pitr)->momentum().m();
207 m_massZall->fill(Zmass, 1.);
218 HepMC::GenVertex::particle_iterator thisChild = firstChild;
219 for(; thisChild != endChild++; ++thisChild){
220 if( ((*thisChild)->pdg_id()) != 23 ){
221// cout << "Zchild id " << (*thisChild)->pdg_id() << endl;
223 if( abs((*thisChild)->pdg_id()) == 11 || abs((*thisChild)->pdg_id()) == 13 ||
224 abs((*thisChild)->pdg_id()) == 15 ){
225 if( abs((*thisChild)->pdg_id()) == 11 )++nelds;
226 if( abs((*thisChild)->pdg_id()) == 13 )++nmuds;
227 if( abs((*thisChild)->pdg_id()) == 15 )++ntauds;
228 sumx += (*thisChild)->momentum().x();
229 sumy += (*thisChild)->momentum().y();
230 sumz += (*thisChild)->momentum().z();
231 sume += (*thisChild)->momentum().e();
235// cout << "Zchildren " << Zchild << " nelds " << nelds << " nmuds " << nmuds << " ntauds " << ntauds << endl;
237 double PtZ2 = sumx*sumx + sumy*sumy;
239 if(PtZ2 > 0.) PtZ = sqrt(PtZ2);
240 if(PtZ != 0.)m_hZPt->fill( PtZ, 1.);
241 double massZ2 = sume*sume - sumx*sumx - sumy*sumy - sumz*sumz;
243 if(massZ2 > 0.) massZ = sqrt(massZ2);
244 if(massZ != 0.)m_massZ->fill( massZ, 1.);
246 m_hZPte->fill( PtZ, 1.);
247 m_massZe->fill( massZ, 1.);
250 m_hZPtm->fill( PtZ, 1.);
251 m_massZm->fill( massZ, 1.);
254 m_hZPtt->fill( PtZ, 1.);
255 m_massZt->fill( massZ, 1.);
259// all decays to l+l- pairs in the event
260 if( (*pitr)->end_vertex() ){
261 HepMC::GenVertex::particle_iterator fstChild =
262 (*pitr)->end_vertex()->particles_begin(HepMC::children);
263 HepMC::GenVertex::particle_iterator lstChild =
264 (*pitr)->end_vertex()->particles_end(HepMC::children);
272 HepMC::GenVertex::particle_iterator aChild = fstChild;
273 for(; aChild != lstChild++; ++aChild){
274 if( abs((*aChild)->pdg_id()) == 11 || abs((*aChild)->pdg_id()) == 13 ||
275 abs((*aChild)->pdg_id()) == 15 ){
276 if( abs((*aChild)->pdg_id()) == 11 )++nel;
277 if( abs((*aChild)->pdg_id()) == 13 )++nmu;
278 if( abs((*aChild)->pdg_id()) == 15 )++ntau;
279 sumpx += (*aChild)->momentum().x();
280 sumpy += (*aChild)->momentum().y();
281 sumpz += (*aChild)->momentum().z();
282 sumpe += (*aChild)->momentum().e();
285 if(nel == 2 || nmu == 2 || ntau == 2 ){
286 double PtPair2 = sumpx*sumpx + sumpy*sumpy;
288 if(PtPair2 > 0.) PtPair = sqrt(PtPair2);
289 double massPair2 = sumpe*sumpe - sumpx*sumpx - sumpy*sumpy - sumpz*sumpz;
290 double massPair = 0.;
291 if(massPair2 > 0.) massPair = sqrt(massPair2);
293 m_hPtPaire->fill( PtPair, 1.);
294 m_massPaire->fill( massPair, 1.);
297 m_hPtPairm->fill( PtPair, 1.);
298 m_massPairm->fill( massPair, 1.);
301 m_hPtPairt->fill( PtPair, 1.);
302 m_massPairt->fill( massPair, 1.);
308 HepPDT::ParticleData* ap = m_particleTable->particle( abs( (*pitr)->pdg_id() ) );
311// std::cout << "ChargeService WARNING: abs(id) "
312// << abs((*pitr)->pdg_id())
313// << " is not in particle data table" << std::endl;
320 if( ((*pitr)->status() == 1) && ( ! (*pitr)->end_vertex()) ) {
322 if( ((*pitr)->pdg_id()) == 11 ){
323 double ePt = (*pitr)->momentum().perp();
324 m_hpte->fill( ePt, 1.);
328 double chargedPt = (*pitr)->momentum().perp();
329 double chargedEta = (*pitr)->momentum().pseudoRapidity();
330 m_hChargedPt->fill( chargedPt, 1.);
331 m_hChargedEta->fill( chargedEta, 1.);
333 double px = (*pitr)->momentum().x();
334 double py = (*pitr)->momentum().y();
335 double pz = (*pitr)->momentum().z();
336 double pe = (*pitr)->momentum().e();
337 double pp2 = px*px + py*py + pz*pz;
339 if(pp2 > 0.) pp3 = sqrt(pp2);
341 if( (pe-pz) != 0. && (pe+pz)/(pe-pz) > 0. ) y = (1./2.)*log((pe+pz)/(pe-pz));
343 if( (pp3-pz) != 0. && (pp3+pz)/(pp3-pz) > 0. ) eta = (1./2.)*log((pp3+pz)/(pp3-pz));
344 m_rapidity->fill( y, 1.);
345 m_pseudorapidity->fill( eta, 1.);
349 m_hgenerated->fill( number_particles, 1.);
350 m_hfinal->fill( final_state, 1.);
351 m_ncharged->fill( number_charged, 1.);
356 return StatusCode::SUCCESS;