45 #ifdef CEXMC_USE_PERSISTENCY
46 #include <boost/archive/binary_oarchive.hpp>
80 G4double CexmcSmallCircleScreenSize( 5.0 );
81 G4double CexmcBigCircleScreenSize( 10.0 );
82 G4Colour CexmcTrackPointsMarkerColour( 0.0, 1.0, 0.4 );
83 G4Colour CexmcRecTrackPointsMarkerColour( 1.0, 0.4, 0.0 );
88 return std::sqrt( momentumAmp * momentumAmp + mass * mass ) - mass;
95 physicsManager( physicsManager ), reconstructor( NULL ), opKinEnergy( 0. ),
96 verbose( verbose ), verboseDraw( 4 ), messenger( NULL )
111 delete reconstructor;
126 ( static_cast< CexmcTrackingAction * >(
127 const_cast< G4UserTrackingAction * >(
149 calorimeterEDLeftCollection(
152 calorimeterEDRightCollection(
157 vetoCounterEDRight, calorimeterEDLeft, calorimeterEDRight,
158 calorimeterEDLeftMaxX, calorimeterEDLeftMaxY,
159 calorimeterEDRightMaxX, calorimeterEDRightMaxY,
160 calorimeterEDLeftCollection, calorimeterEDRightCollection );
170 targetTPBeamParticle(
173 targetTPOutputParticle(
176 targetTPNucleusParticle(
179 targetTPOutputParticleDecayProductParticle1(
181 GetTargetTPOutputParticleDecayProductParticle( 0 ) );
183 targetTPOutputParticleDecayProductParticle2(
185 GetTargetTPOutputParticleDecayProductParticle( 1 ) );
201 targetTPOutputParticle, targetTPNucleusParticle,
202 targetTPOutputParticleDecayProductParticle1,
203 targetTPOutputParticleDecayProductParticle2,
204 vetoCounterTPLeft, vetoCounterTPRight,
205 calorimeterTPLeft, calorimeterTPRight );
213 G4cout <<
" monitor : " <<
219 G4cout <<
" cal (l) : " <<
222 G4cout <<
" cal (r) : " <<
248 G4cout <<
" angle between the " <<
250 " decay products : " <<
262 G4cout <<
" --- Triggered angular ranges: " << angularRanges;
263 G4cout <<
" --- Production model data: " << pmData;
267 void CexmcEventAction::PrintReconstructedData(
288 G4cout <<
" < mass cut passed >" << G4endl;
295 G4cout <<
" < absorbed energy cut passed >" << G4endl;
301 G4cout <<
" -- production model data: " << pmData;
302 G4cout <<
" -- triggered angular ranges: ";
303 if ( triggeredRecAngularRanges.empty() )
304 G4cout <<
"< orphan detected, gap " << angularGap <<
" >" << G4endl;
306 G4cout << triggeredRecAngularRanges;
310 #ifdef CEXMC_USE_ROOT
315 CexmcHistoManager * histoManager( CexmcHistoManager::Instance() );
317 histoManager->Add( CexmcAbsorbedEnergy_EDT_Histo, 0,
321 for ( CexmcAngularRangeList::const_iterator
322 k( triggeredAngularRanges.begin() );
323 k != triggeredAngularRanges.end(); ++k )
325 histoManager->Add( CexmcAbsEnInLeftCalorimeter_ARReal_EDT_Histo,
327 histoManager->Add( CexmcAbsEnInRightCalorimeter_ARReal_EDT_Histo,
337 CexmcHistoManager * histoManager( CexmcHistoManager::Instance() );
341 histoManager->Add( CexmcMomentumBP_TPT_Histo, 0,
343 histoManager->Add( CexmcTPInMonitor_TPT_Histo, 0,
350 histoManager->Add( CexmcTPInTarget_TPT_Histo, 0,
354 if ( histoManager->GetVerboseLevel() > 0 )
356 histoManager->Add( CexmcMomentumIP_TPT_Histo, 0,
361 for ( CexmcAngularRangeList::const_iterator
362 k( triggeredAngularRanges.begin() );
363 k != triggeredAngularRanges.end(); ++k )
369 histoManager->Add( CexmcKinEnAtLeftCalorimeter_ARReal_TPT_Histo,
370 k->index, kinEnergy );
375 histoManager->Add( CexmcKinEnAtRightCalorimeter_ARReal_TPT_Histo,
376 k->index, kinEnergy );
380 histoManager->Add( CexmcTPInTarget_ARReal_TPT_Histo, k->index,
384 histoManager->Add( CexmcKinEnOP_LAB_ARReal_TPT_Histo, k->index,
386 histoManager->Add( CexmcAngleOP_SCM_ARReal_TPT_Histo, k->index,
394 directionWorld.angle( tpStore->
395 targetTPOutputParticleDecayProductParticle2.
396 directionWorld ) /
deg );
397 histoManager->Add( CexmcOpenAngle_ARReal_TPT_Histo, k->index,
404 void CexmcEventAction::FillRTHistos(
G4bool reconstructorHasFullTrigger,
410 CexmcHistoManager * histoManager( CexmcHistoManager::Instance() );
415 histoManager->Add( CexmcRecMasses_EDT_Histo, 0, opMass, nopMass );
417 for ( CexmcAngularRangeList::const_iterator
418 k( triggeredAngularRanges.begin() );
419 k != triggeredAngularRanges.end(); ++k )
423 histoManager->Add( CexmcOPDPAtLeftCalorimeter_ARReal_EDT_Histo,
430 histoManager->Add( CexmcOPDPAtRightCalorimeter_ARReal_EDT_Histo,
435 histoManager->Add( CexmcRecOPDPAtLeftCalorimeter_ARReal_EDT_Histo,
439 histoManager->Add( CexmcRecOPDPAtRightCalorimeter_ARReal_EDT_Histo,
445 if ( ! reconstructorHasFullTrigger )
450 histoManager->Add( CexmcMomentumBP_RT_Histo, 0,
456 histoManager->Add( CexmcTPInTarget_RT_Histo, 0,
462 histoManager->Add( CexmcRecMasses_RT_Histo, 0,
466 histoManager->Add( CexmcAbsorbedEnergy_RT_Histo, 0,
471 outputParticleSCM.cosTheta());
473 for ( CexmcAngularRangeList::const_iterator
474 k( triggeredAngularRanges.begin() );
475 k != triggeredAngularRanges.end(); ++k )
477 histoManager->Add( CexmcRecMassOP_ARReal_RT_Histo, k->index, opMass );
478 histoManager->Add( CexmcRecMassNOP_ARReal_RT_Histo, k->index, nopMass );
482 histoManager->Add( CexmcKinEnAtLeftCalorimeter_ARReal_RT_Histo,
483 k->index, kinEnergy );
484 histoManager->Add( CexmcMissEnFromLeftCalorimeter_ARReal_RT_Histo,
491 histoManager->Add( CexmcKinEnAtRightCalorimeter_ARReal_RT_Histo,
492 k->index, kinEnergy );
493 histoManager->Add( CexmcMissEnFromRightCalorimeter_ARReal_RT_Histo,
499 histoManager->Add( CexmcTPInTarget_ARReal_RT_Histo, k->index,
503 histoManager->Add( CexmcKinEnOP_LAB_ARReal_RT_Histo, k->index,
505 histoManager->Add( CexmcAngleOP_SCM_ARReal_RT_Histo, k->index,
509 histoManager->Add( CexmcDiffAngleOP_SCM_ARReal_RT_Histo, k->index,
517 directionWorld.angle( tpStore->
518 targetTPOutputParticleDecayProductParticle2.
519 directionWorld ) /
deg );
520 histoManager->Add( CexmcOpenAngle_ARReal_RT_Histo, k->index,
524 histoManager->Add( CexmcDiffOpenAngle_ARReal_RT_Histo, k->index,
529 histoManager->Add( CexmcOPDPAtLeftCalorimeter_ARReal_RT_Histo,
536 histoManager->Add( CexmcOPDPAtRightCalorimeter_ARReal_RT_Histo,
541 histoManager->Add( CexmcAbsEnInLeftCalorimeter_ARReal_RT_Histo,
543 histoManager->Add( CexmcAbsEnInRightCalorimeter_ARReal_RT_Histo,
545 histoManager->Add( CexmcRecAngleOP_SCM_ARReal_RT_Histo,
546 k->index, recCosTheta );
547 histoManager->Add( CexmcRecOpenAngle_ARReal_RT_Histo,
549 histoManager->Add( CexmcRecOPDPAtLeftCalorimeter_ARReal_RT_Histo,
553 histoManager->Add( CexmcRecOPDPAtRightCalorimeter_ARReal_RT_Histo,
563 void CexmcEventAction::DrawTrajectories(
const G4Event * event )
565 G4VisManager * visManager( static_cast< G4VisManager * >(
567 if ( ! visManager || ! visManager->GetCurrentGraphicsSystem() )
573 if ( ! trajContainer )
576 nTraj = trajContainer->
entries();
578 for (
int i( 0 ); i < nTraj; ++i )
581 traj->DrawTrajectory();
586 void CexmcEventAction::DrawTrackPoints(
589 G4VisManager * visManager( static_cast< G4VisManager * >(
591 if ( ! visManager || ! visManager->GetCurrentGraphicsSystem() )
603 visManager->Draw( circle );
609 visManager->Draw( circle );
615 visManager->Draw( circle );
621 visManager->Draw( circle );
627 visManager->Draw( circle );
633 visManager->Draw( circle );
639 visManager->Draw( circle );
644 void CexmcEventAction::DrawReconstructionData(
void )
646 G4VisManager * visManager( static_cast< G4VisManager * >(
648 if ( ! visManager || ! visManager->GetCurrentGraphicsSystem() )
656 visManager->Draw( circle );
660 visManager->Draw( circle );
663 visManager->Draw( circle );
667 void CexmcEventAction::UpdateRunHits(
670 G4bool tpDigitizerHasTriggered,
671 G4bool edDigitizerHasTriggered,
672 G4bool edDigitizerMonitorHasTriggered,
673 G4bool reconstructorHasFullTrigger,
677 const CexmcRun * run( static_cast< const CexmcRun * >(
678 runManager->GetCurrentRun() ) );
679 CexmcRun * theRun( const_cast< CexmcRun * >( run ) );
681 if ( tpDigitizerHasTriggered )
683 for ( CexmcAngularRangeList::const_iterator k( aRangesReal.begin() );
684 k != aRangesReal.end(); ++k )
686 theRun->IncrementNmbOfHitsSampledFull( k->index );
687 if ( edDigitizerMonitorHasTriggered )
688 theRun->IncrementNmbOfHitsSampled( k->index );
689 if ( reconstructorHasFullTrigger )
690 theRun->IncrementNmbOfHitsTriggeredRealRange( k->index );
692 if ( reconstructorHasFullTrigger )
694 if ( aRangesRec.empty() )
696 theRun->IncrementNmbOfOrphanHits( aGap.
index );
700 for ( CexmcAngularRangeList::const_iterator
701 k( aRangesRec.begin() ); k != aRangesRec.end(); ++k )
703 theRun->IncrementNmbOfHitsTriggeredRecRange( k->index );
710 if ( edDigitizerHasTriggered )
711 theRun->IncrementNmbOfFalseHitsTriggeredEDT();
712 if ( reconstructorHasFullTrigger )
713 theRun->IncrementNmbOfFalseHitsTriggeredRec();
718 #ifdef CEXMC_USE_PERSISTENCY
720 void CexmcEventAction::SaveEvent(
const G4Event * event,
721 G4bool edDigitizerHasTriggered,
728 if ( ! runManager->ProjectIsSaved() )
734 if ( ! edDigitizerHasTriggered && runManager->GetEventDataVerboseLevel() !=
738 boost::archive::binary_oarchive * archive(
739 runManager->GetEventsArchive() );
742 CexmcEventSObject sObject = {
event->GetEventID(),
743 edDigitizerHasTriggered, edStore->
monitorED,
754 archive->operator<<( sObject );
755 const CexmcRun * run( static_cast< const CexmcRun * >(
756 runManager->GetCurrentRun() ) );
757 CexmcRun * theRun( const_cast< CexmcRun * >( run ) );
758 theRun->IncrementNmbOfSavedEvents();
763 void CexmcEventAction::SaveEventFast(
const G4Event * event,
764 G4bool tpDigitizerHasTriggered,
765 G4bool edDigitizerHasTriggered,
766 G4bool edDigitizerMonitorHasTriggered,
771 if ( ! runManager->ProjectIsSaved() )
777 boost::archive::binary_oarchive * archive(
778 runManager->GetFastEventsArchive() );
781 if ( ! tpDigitizerHasTriggered )
784 CexmcEventFastSObject sObject = {
event->GetEventID(), opCosThetaSCM,
785 edDigitizerHasTriggered,
786 edDigitizerMonitorHasTriggered };
787 archive->operator<<( sObject );
788 const CexmcRun * run( static_cast< const CexmcRun * >(
789 runManager->GetCurrentRun() ) );
790 CexmcRun * theRun( const_cast< CexmcRun * >( run ) );
791 theRun->IncrementNmbOfSavedFastEvents();
802 static_cast< CexmcEnergyDepositDigitizer * >( digiManager->
805 static_cast< CexmcTrackPointsDigitizer * >( digiManager->
811 G4bool edDigitizerMonitorHasTriggered(
813 G4bool edDigitizerHasTriggered(
false );
818 edDigitizerHasTriggered = energyDepositDigitizer->
HasTriggered();
821 G4bool reconstructorHasBasicTrigger(
false );
822 G4bool reconstructorHasFullTrigger(
false );
825 energyDepositDigitizer ) );
827 trackPointsDigitizer ) );
834 if ( ! productionModel )
838 productionModel->GetAngularRanges() );
840 productionModel->GetTriggeredAngularRanges() );
842 productionModel->GetProductionModelData() );
844 if ( edDigitizerHasTriggered )
853 if ( reconstructorHasBasicTrigger )
855 for ( CexmcAngularRangeList::const_iterator
856 k( angularRanges.begin() ); k != angularRanges.end(); ++k )
859 outputParticleSCM.cosTheta() );
860 if ( cosTheta <= k->top && cosTheta > k->bottom )
862 k->top, k->bottom, k->index ) );
867 if ( triggeredRecAngularRanges.empty() )
871 for ( CexmcAngularRangeList::const_iterator
872 k( angularGaps.begin() ); k != angularGaps.end(); ++k )
875 outputParticleSCM.cosTheta() );
876 if ( cosTheta <= k->top && cosTheta > k->bottom )
884 UpdateRunHits( triggeredAngularRanges, triggeredRecAngularRanges,
885 tpDigitizerHasTriggered, edDigitizerHasTriggered,
886 edDigitizerMonitorHasTriggered,
887 reconstructorHasFullTrigger, angularGap );
891 G4bool printMessages( verbose > 3 ||
892 ( ( verbose == 1 ) && tpDigitizerHasTriggered ) ||
893 ( ( verbose == 2 ) && edDigitizerHasTriggered ) ||
894 ( ( verbose == 3 ) && ( tpDigitizerHasTriggered ||
895 edDigitizerHasTriggered ) ) );
899 if ( tpDigitizerHasTriggered )
904 if ( reconstructorHasBasicTrigger )
905 PrintReconstructedData( triggeredRecAngularRanges,
907 if ( edDigitizerHasTriggered )
912 if ( verboseDraw > 0 )
914 G4bool drawTrajectories( verboseDraw > 3 ||
915 ( ( verboseDraw == 1 ) && tpDigitizerHasTriggered ) ||
916 ( ( verboseDraw == 2 ) && edDigitizerHasTriggered ) ||
917 ( ( verboseDraw == 3 ) && ( tpDigitizerHasTriggered ||
918 edDigitizerHasTriggered ) ) );
919 if ( drawTrajectories )
921 DrawTrajectories( event );
922 if ( tpDigitizerHasTriggered )
923 DrawTrackPoints( tpStore );
924 if ( reconstructorHasBasicTrigger )
925 DrawReconstructionData();
929 #ifdef CEXMC_USE_PERSISTENCY
930 if ( edDigitizerHasTriggered || tpDigitizerHasTriggered )
932 SaveEventFast( event, tpDigitizerHasTriggered,
933 edDigitizerHasTriggered,
934 edDigitizerMonitorHasTriggered,
936 SaveEvent( event, edDigitizerHasTriggered, edStore, tpStore,
941 #ifdef CEXMC_USE_ROOT
945 opKinEnergy = CexmcGetKinEnergy(
950 if ( edDigitizerHasTriggered )
951 FillEDTHistos( edStore, triggeredAngularRanges );
955 if ( tpDigitizerHasTriggered && edDigitizerMonitorHasTriggered )
956 FillTPTHistos( tpStore, pmData, triggeredAngularRanges );
958 if ( reconstructorHasBasicTrigger )
959 FillRTHistos( reconstructorHasFullTrigger, edStore, tpStore,
960 pmData, triggeredAngularRanges );
963 G4Event * theEvent( const_cast< G4Event * >( event ) );
970 edDigitizerHasTriggered,
971 tpDigitizerHasTriggered,
972 reconstructorHasFullTrigger ) );