197 {
198
199 double eBeam = m_ecm / 2;
200
201 MsgStream log(
msgSvc(), name() );
202 log << MSG::INFO << "in execute()" << endmsg;
203
204 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc(), "/Event/EventHeader" );
205 int run = eventHeader->runNumber();
206 int event = eventHeader->eventNumber();
207 if ( event % m_RunEventFreq == 0 )
208 std::cout << "Run " << run << ", event " << event << std::endl;
209
211 log << MSG::DEBUG << "ncharg, nneu, tottks = " << evtRecEvent->totalCharged() << " , "
212 << evtRecEvent->totalNeutral() << " , " << evtRecEvent->totalTracks() << endmsg;
213
215
216
217
218 int nChargedTracks = 0, nChargedTracksIP = 0;
219 int nCharge = 0, nChargeIP = 0;
220 double totalVisibleEnergy = 0, totalChargedEnergy = 0, totalEMCEnergy = 0;
221 double totalChargedPX = 0, totalChargedPY = 0, totalChargedPZ = 0;
222
223 double highestIPTrackP = -1, secondHighestIPTrackP = -2;
224 int highestPIPTrackId = -1, secondHighestPIPTrackId = -1;
225
226
227 for ( int i = 0; i < evtRecEvent->totalCharged(); i++ )
228 {
230 if ( !( *itTrk )->isMdcTrackValid() ) continue;
231 RecMdcTrack* mdcTrk = ( *itTrk )->mdcTrack();
232
233 int trackId = mdcTrk->
trackId();
234 int charge = mdcTrk->
charge();
235 double r0 = mdcTrk->
r();
236 double z0 = mdcTrk->
z();
237 h_trackR0->fill( r0 );
238 h_trackZ0->fill( z0 );
239
240 nChargedTracks++;
241 nCharge += charge;
242
243 double pX = mdcTrk->
px();
244 double pY = mdcTrk->
py();
245 double pZ = mdcTrk->
pz();
246 double pMag = mdcTrk->
p();
247 double cosTheta =
cos( mdcTrk->
theta() );
248 double phi = mdcTrk->
phi();
249
250 double chargedEnergy = sqrt( pMag * pMag +
mPi *
mPi );
251 totalVisibleEnergy += chargedEnergy;
252 totalChargedEnergy += chargedEnergy;
253
254 totalChargedPX += pX;
255 totalChargedPY += pY;
256 totalChargedPZ += pZ;
257
258
259 if ( ( *itTrk )->isEmcShowerValid() )
260 {
261 RecEmcShower* emcChargedTrk = ( *itTrk )->emcShower();
262 totalEMCEnergy += emcChargedTrk->
energy();
263 }
264
265
266 if ( ( *itTrk )->isMucTrackValid() )
267 {
268 RecMucTrack* mucTrk = ( *itTrk )->mucTrack();
269 double mucDepth = mucTrk->
depth();
270 if ( mucDepth > 0 )
271 {
272 h_mucDepth->fill( mucDepth );
273 h_mucDepthVsCosTheta->fill( cosTheta, mucDepth );
274 h_mucDepthVsPhi->fill( phi, mucDepth );
275 }
276 }
277
278
279
280 if ( fabs( z0 ) >= m_vz0cut ) continue;
281 if ( r0 >= m_vr0cut ) continue;
282
283 nChargedTracksIP++;
284 nChargeIP += charge;
285
286
287 double dedxProbPH = -10;
288 int dedxNumTotalHits = -10;
289 int dedxNumGoodHits = -10;
290
291 if ( ( *itTrk )->isMdcDedxValid() )
292 {
293 RecMdcDedx* dedxTrk = ( *itTrk )->mdcDedx();
294
297 h_dedxTotalHitsIP->fill( dedxNumTotalHits );
298 h_dedxGoodHitsIP->fill( dedxNumGoodHits );
299
300 h_dedxElecChiIP->fill( dedxTrk->
chiE() );
301 h_dedxMuonChiIP->fill( dedxTrk->
chiMu() );
302 h_dedxPionChiIP->fill( dedxTrk->
chiPi() );
303 h_dedxKaonChiIP->fill( dedxTrk->
chiK() );
304 h_dedxProtonChiIP->fill( dedxTrk->
chiP() );
305
306 dedxProbPH = dedxTrk->
probPH();
307 h_dedxProbPHIP->fill( dedxProbPH );
308 h_dedxProbPHVsMomentumIP->fill( pMag, dedxProbPH );
309
310 }
311
312
313 if ( ( *itTrk )->isTofTrackValid() )
314 {
315 SmartRefVector<RecTofTrack> tofTrkCol = ( *itTrk )->tofTrack();
316 SmartRefVector<RecTofTrack>::iterator iter_tof = tofTrkCol.begin();
317
318 for ( ; iter_tof != tofTrkCol.end(); iter_tof++ )
319 {
320 TofHitStatus* status = new TofHitStatus;
321 status->
setStatus( ( *iter_tof )->status() );
322
324 {
326
327 double tofPH = ( *iter_tof )->ph();
328 double tof = ( *iter_tof )->tof();
329
330 h_tofElecIP_Barrel->fill( tof - ( *iter_tof )->texpElectron() );
331 h_tofMuonIP_Barrel->fill( tof - ( *iter_tof )->texpMuon() );
332 h_tofPionIP_Barrel->fill( tof - ( *iter_tof )->texpPion() );
333 h_tofKaonIP_Barrel->fill( tof - ( *iter_tof )->texpKaon() );
334 h_tofProtonIP_Barrel->fill( tof - ( *iter_tof )->texpProton() );
335 h_tofVsMomentumIP->fill( pMag, tof );
336
337 if ( status->
layer() == 1 )
338 {
339 h_tofPHIP_BarrelLayer1->fill( tofPH );
340 h_tofIP_BarrelLayer1->fill( tof );
341 }
342 if ( status->
layer() == 2 )
343 {
344 h_tofPHIP_BarrelLayer2->fill( tofPH );
345 h_tofIP_BarrelLayer2->fill( tof );
346 }
347 }
348
349 else
350 {
352
353 double tofPH = ( *iter_tof )->ph();
354 double tof = ( *iter_tof )->tof();
355
356 h_tofElecIP_Endcap->fill( tof - ( *iter_tof )->texpElectron() );
357 h_tofMuonIP_Endcap->fill( tof - ( *iter_tof )->texpMuon() );
358 h_tofPionIP_Endcap->fill( tof - ( *iter_tof )->texpPion() );
359 h_tofKaonIP_Endcap->fill( tof - ( *iter_tof )->texpKaon() );
360 h_tofProtonIP_Endcap->fill( tof - ( *iter_tof )->texpProton() );
361 h_tofVsMomentumIP->fill( pMag, tof );
362
364 {
365 h_tofPHIP_EastEndcap->fill( tofPH );
366 h_tofIP_EastEndcap->fill( tof );
367 }
368 else
369 {
370 h_tofPHIP_WestEndcap->fill( tofPH );
371 h_tofIP_WestEndcap->fill( tof );
372 }
373 }
374
375 }
376 }
377
378
379 if ( pMag > highestIPTrackP )
380 {
381 secondHighestPIPTrackId = highestPIPTrackId;
382 secondHighestIPTrackP = highestIPTrackP;
383 highestPIPTrackId = trackId;
384 highestIPTrackP = pMag;
385 }
386 if ( ( pMag > secondHighestIPTrackP ) && ( pMag < highestIPTrackP ) )
387 {
388 secondHighestPIPTrackId = trackId;
389 secondHighestIPTrackP = pMag;
390 }
391
392 }
393
394
395
396 if ( nChargedTracksIP > 0 )
397 {
399 RecMdcTrack* mdcTrk = ( *itTrk )->mdcTrack();
400 double highestPPhi0 = mdcTrk->
phi();
401 h_pIPTrack1DivEb->fill( mdcTrk->
p() / eBeam );
402
403 if ( ( *itTrk )->isEmcShowerValid() )
404 {
405 RecEmcShower* emcChargedTrk = ( *itTrk )->emcShower();
406 h_eEMCIPTrack1DivEb->fill( emcChargedTrk->
energy() / eBeam );
407 }
408
409
410 if ( nChargedTracksIP > 1 )
411 {
412 itTrk = evtRecTrkCol->begin() + secondHighestPIPTrackId;
413 RecMdcTrack* mdcTrk = ( *itTrk )->mdcTrack();
414 double secondHighestPPhi0 = mdcTrk->
phi();
415 h_pIPTrack2DivEb->fill( mdcTrk->
p() / eBeam );
416
417 if ( ( *itTrk )->isEmcShowerValid() )
418 {
419 RecEmcShower* emcChargedTrk = ( *itTrk )->emcShower();
420 h_eEMCIPTrack2DivEb->fill( emcChargedTrk->
energy() / eBeam );
421 }
422
423 h_acoplanarity_2HighestPIPTracks->fill(
424 fabs( CLHEP::pi - fabs( highestPPhi0 - secondHighestPPhi0 ) ) );
425 }
426 }
427
428
429
430 int nNeutralTracks = 0, nNeutralTracksGT30MeV = 0;
431 double totalNeutralEnergy = 0;
432 double totalNeutralPX = 0, totalNeutralPY = 0, totalNeutralPZ = 0;
433
434 for ( int i = evtRecEvent->totalCharged(); i < evtRecEvent->totalTracks(); i++ )
435 {
437 if ( !( *itTrk )->isEmcShowerValid() ) continue;
438 RecEmcShower* emcTrk = ( *itTrk )->emcShower();
439
440 nNeutralTracks++;
441 double eraw = emcTrk->
energy();
442 if ( eraw > 0.030 ) nNeutralTracksGT30MeV++;
443
444 totalVisibleEnergy += eraw;
445 totalEMCEnergy += eraw;
446 totalNeutralEnergy += eraw;
447
448 double theta = emcTrk->
theta();
449 double phi = emcTrk->
phi();
450
451 double pX = eraw *
cos( phi ) *
sin( theta );
452 double pY = eraw *
sin( phi ) *
sin( theta );
453 double pZ = eraw *
cos( theta );
454
455 totalNeutralPX += pX;
456 totalNeutralPY += pY;
457 totalNeutralPZ += pZ;
458
459
460 if ( nNeutralTracks == 1 ) h_eEMCShower1DivEb->fill( eraw / eBeam );
461 if ( nNeutralTracks == 2 ) h_eEMCShower2DivEb->fill( eraw / eBeam );
462 if ( nNeutralTracks == 3 ) h_eEMCShower3DivEb->fill( eraw / eBeam );
463
464 }
465
466
467
468
469 h_nChargedTracks->fill( nChargedTracks );
470 h_nChargedTracksIP->fill( nChargedTracksIP );
471
472 h_netCharge->fill( nCharge );
473 h_netChargeIP->fill( nChargeIP );
474
475 h_nNeutralTracks->fill( nNeutralTracks );
476 h_nNeutralTracksGT30MeV->fill( nNeutralTracksGT30MeV );
477
478
479 h_eVisibleDivEcm->fill( totalVisibleEnergy / m_ecm );
480 h_eEMCDivEcm->fill( totalEMCEnergy / m_ecm );
481 h_eNeutralDivEcm->fill( totalNeutralEnergy / m_ecm );
482 h_eChargedDivEcm->fill( totalChargedEnergy / m_ecm );
483
484
485 double totalChargedPXY =
486 sqrt( totalChargedPX * totalChargedPX + totalChargedPY * totalChargedPY );
487 double totalChargedP =
488 sqrt( totalChargedPXY * totalChargedPXY + totalChargedPZ * totalChargedPZ );
489
490 h_netMomentumDivEcm_AllChargedTracks->fill( totalChargedP / m_ecm );
491 h_netTransMomentumDivEcm_AllChargedTracks->fill( totalChargedPXY / m_ecm );
492 if ( totalChargedP > 0 )
493 { h_cosTheta_AllChargedTracks->fill( totalChargedPZ / totalChargedP ); }
494 else
495 {
496 if ( nChargedTracks > 0 )
497 {
498 log << MSG::INFO << "Run " << run << ", event " << event << ": totalChargedP <= 0! "
499 << endmsg;
500 }
501 }
502
503
504 double totalNeutralPXY =
505 sqrt( totalNeutralPX * totalNeutralPX + totalNeutralPY * totalNeutralPY );
506 double totalNeutralP =
507 sqrt( totalNeutralPXY * totalNeutralPXY + totalNeutralPZ * totalNeutralPZ );
508
509 h_netMomentumDivEcm_AllNeutralTracks->fill( totalNeutralP / m_ecm );
510 h_netTransMomentumDivEcm_AllNeutralTracks->fill( totalNeutralPXY / m_ecm );
511 if ( totalNeutralP > 0 )
512 { h_cosTheta_AllNeutralTracks->fill( totalNeutralPZ / totalNeutralP ); }
513 else
514 {
515 if ( nNeutralTracks > 0 )
516 {
517 log << MSG::INFO << "Run " << run << ", event " << event << ": totalNeutralP <= 0! "
518 << endmsg;
519 }
520 }
521
522
523 double totalEventPX = totalChargedPX + totalNeutralPX;
524 double totalEventPY = totalChargedPY + totalNeutralPY;
525 double totalEventPZ = totalChargedPZ + totalNeutralPZ;
526
527 double totalEventPXY = sqrt( totalEventPX * totalEventPX + totalEventPY * totalEventPY );
528 double totalEventP = sqrt( totalEventPXY * totalEventPXY + totalEventPZ * totalEventPZ );
529
530 h_netMomentumDivEcm_AllTracks->fill( totalEventP / m_ecm );
531 h_netTransMomentumDivEcm_AllTracks->fill( totalEventPXY / m_ecm );
532 if ( totalEventP > 0 ) { h_cosTheta_AllTracks->fill( totalEventPZ / totalEventP ); }
533 else
534 {
535 log << MSG::INFO << "Run " << run << ", event " << event << ": totalEventP <= 0! "
536 << endmsg;
537 }
538
539
540 SmartDataPtr<EvtRecVeeVertexCol> evtRecVeeVertexCol( eventSvc(),
541 "/Event/EvtRec/EvtRecVeeVertexCol" );
542 if ( !evtRecVeeVertexCol )
543 {
544 log << MSG::FATAL << "Could not find EvtRecVeeVertexCol" << endmsg;
545 return StatusCode::FAILURE;
546 }
547
548
549 int numKs = 0, numLambda = 0;
550 for ( EvtRecVeeVertexCol::iterator veeItr = evtRecVeeVertexCol->begin();
551 veeItr < evtRecVeeVertexCol->end(); veeItr++ )
552 {
553
554 h_ksMass->fill( ( *veeItr )->mass() );
555 if ( fabs( ( *veeItr )->mass() -
mKs ) < 0.010 ) ++numKs;
556
557 h_lambdaMass->fill( ( *veeItr )->mass() );
558 if ( fabs( ( *veeItr )->mass() -
mLambda ) < 0.010 ) ++numLambda;
559
560 }
561
562 h_nKs->fill( numKs );
563 h_nLambda->fill( numLambda );
564
565 return StatusCode::SUCCESS;
566}
EvtRecTrackCol::iterator EvtRecTrackIterator
double sin(const BesAngle a)
double cos(const BesAngle a)
const double theta() const
const int trackId() const
unsigned int layer() const
void setStatus(unsigned int status)
_EXTERN_ std::string EvtRecEvent
_EXTERN_ std::string EvtRecTrackCol