130 {
131
132
133 MsgStream msglog(messageService(), name());
134 msglog << MSG::INFO << ">>> HistSample from execute" << endreq;
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151// (*it)->pGenEvt()->print();
152
153// fix the STDHEP mess for the Z status
154 int properStatus = 2;
155// switch ( (*it)->generatorName()[0] ) {
156// case 'P':
157// properStatus = 2;
158// break;
159// case 'I':
160// properStatus = 12;
161// break;
162// case 'H':
163// properStatus = 195;
164// break;
165// default:
166// properStatus = 2;
167// break;
168// }
169 HepMC::GenEvent* genEvt = (*it);
170 int g_id = genEvt->signal_process_id();
171 switch ( first_generator(g_id) ) {
172 case PYTHIA:
173 properStatus = 2;
174 break;
175 case ISAJET:
176 properStatus = 12;
177 break;
178 case HERWIG:
179 properStatus = 195;
180 break;
181 default:
182 properStatus = 2;
183 break;
184 }
185
186
187 int number_particles = 0;
188 int final_state = 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 ){
193 ++number_particles;
194// cout << "particle " << ((*pitr)->pdg_id()) << " status " << ((*pitr)->status()) << endl;
195
196// Z decays
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.);
208 }
209// Z decays to l+l-
210 double sumx = 0.0;
211 double sumy = 0.0;
212 double sumz = 0.0;
213 double sume = 0.0;
214 int nelds = 0;
215 int nmuds = 0;
216 int ntauds = 0;
217 int Zchild = 0;
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;
222 ++Zchild;
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();
232 }
233 }
234 }
235// cout << "Zchildren " << Zchild << " nelds " << nelds << " nmuds " << nmuds << " ntauds " << ntauds << endl;
236 if( Zchild != 0 ){
237 double PtZ2 = sumx*sumx + sumy*sumy;
238 double PtZ = 0.;
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;
242 double massZ = 0.;
243 if(massZ2 > 0.) massZ = sqrt(massZ2);
244 if(massZ != 0.)m_massZ->fill( massZ, 1.);
245 if(nelds == 2){
246 m_hZPte->fill( PtZ, 1.);
247 m_massZe->fill( massZ, 1.);
248 }
249 if(nmuds == 2){
250 m_hZPtm->fill( PtZ, 1.);
251 m_massZm->fill( massZ, 1.);
252 }
253 if(ntauds == 2){
254 m_hZPtt->fill( PtZ, 1.);
255 m_massZt->fill( massZ, 1.);
256 }
257 }
258 }
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);
265 double sumpx = 0.0;
266 double sumpy = 0.0;
267 double sumpz = 0.0;
268 double sumpe = 0.0;
269 int nel = 0;
270 int nmu = 0;
271 int ntau = 0;
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();
283 }
284 }
285 if(nel == 2 || nmu == 2 || ntau == 2 ){
286 double PtPair2 = sumpx*sumpx + sumpy*sumpy;
287 double PtPair = 0.;
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);
292 if(nel == 2){
293 m_hPtPaire->fill( PtPair, 1.);
294 m_massPaire->fill( massPair, 1.);
295 }
296 if(nmu == 2){
297 m_hPtPairm->fill( PtPair, 1.);
298 m_massPairm->fill( massPair, 1.);
299 }
300 if(ntau == 2){
301 m_hPtPairt->fill( PtPair, 1.);
302 m_massPairt->fill( massPair, 1.);
303 }
304 }
305 }
306// charged tracks
307 double c = 0.;
308 HepPDT::ParticleData* ap = m_particleTable->particle( abs( (*pitr)->pdg_id() ) );
309
310 if(!ap){
311// std::cout << "ChargeService WARNING: abs(id) "
312// << abs((*pitr)->pdg_id())
313// << " is not in particle data table" << std::endl;
314 }
315 else
316 {
317 c = ap->charge();
318 }
319
320 if( ((*pitr)->status() == 1) && ( ! (*pitr)->end_vertex()) ) {
321 ++final_state;
322 if( ((*pitr)->pdg_id()) == 11 ){
323 double ePt = (*pitr)->momentum().perp();
324 m_hpte->fill( ePt, 1.);
325 }
326 if(c!=0.){
327 ++number_charged;
328 double chargedPt = (*pitr)->momentum().perp();
329 double chargedEta = (*pitr)->momentum().pseudoRapidity();
330 m_hChargedPt->fill( chargedPt, 1.);
331 m_hChargedEta->fill( chargedEta, 1.);
332
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;
338 double pp3 = 0.;
339 if(pp2 > 0.) pp3 = sqrt(pp2);
340 double y = -999.;
341 if( (pe-pz) != 0. && (pe+pz)/(pe-pz) > 0. ) y = (1./2.)*log((pe+pz)/(pe-pz));
342 double eta = -999.;
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.);
346 }
347 }
348 }
349 m_hgenerated->fill( number_particles, 1.);
350 m_hfinal->fill( final_state, 1.);
351 m_ncharged->fill( number_charged, 1.);
352
353 }
354*/
355
356 return StatusCode::SUCCESS;
357}