45 #ifdef CEXMC_USE_PERSISTENCY
46 #include <boost/archive/binary_oarchive.hpp>
81 G4double CexmcSmallCircleScreenSize( 5.0 );
82 G4double CexmcBigCircleScreenSize( 10.0 );
83 G4Colour CexmcTrackPointsMarkerColour( 0.0, 1.0, 0.4 );
84 G4Colour CexmcRecTrackPointsMarkerColour( 1.0, 0.4, 0.0 );
89 return std::sqrt( momentumAmp * momentumAmp + mass * mass ) -
mass;
97 physicsManager( physicsManager_ ), reconstructor( NULL ),
101 verbose( verbose_ ), verboseDraw( 4 ), messenger( NULL )
131 ( static_cast< CexmcTrackingAction * >(
132 const_cast< G4UserTrackingAction * >(
154 calorimeterEDLeftCollection(
157 calorimeterEDRightCollection(
162 vetoCounterEDRight, calorimeterEDLeft, calorimeterEDRight,
163 calorimeterEDLeftMaxX, calorimeterEDLeftMaxY,
164 calorimeterEDRightMaxX, calorimeterEDRightMaxY,
165 calorimeterEDLeftCollection, calorimeterEDRightCollection );
175 targetTPBeamParticle(
178 targetTPOutputParticle(
181 targetTPNucleusParticle(
184 targetTPOutputParticleDecayProductParticle1(
186 GetTargetTPOutputParticleDecayProductParticle( 0 ) );
188 targetTPOutputParticleDecayProductParticle2(
190 GetTargetTPOutputParticleDecayProductParticle( 1 ) );
206 targetTPOutputParticle, targetTPNucleusParticle,
207 targetTPOutputParticleDecayProductParticle1,
208 targetTPOutputParticleDecayProductParticle2,
209 vetoCounterTPLeft, vetoCounterTPRight,
210 calorimeterTPLeft, calorimeterTPRight );
218 G4cout <<
" monitor : " <<
224 G4cout <<
" cal (l) : " <<
227 G4cout <<
" cal (r) : " <<
253 G4cout <<
" angle between the " <<
255 " decay products : " <<
267 G4cout <<
" --- Triggered angular ranges: " << angularRanges;
268 G4cout <<
" --- Production model data: " << pmData;
293 G4cout <<
" < mass cut passed >" << G4endl;
300 G4cout <<
" < absorbed energy cut passed >" << G4endl;
306 G4cout <<
" -- production model data: " << pmData;
307 G4cout <<
" -- triggered angular ranges: ";
308 if ( triggeredRecAngularRanges.empty() )
309 G4cout <<
"< orphan detected, gap " << angularGap <<
" >" << G4endl;
311 G4cout << triggeredRecAngularRanges;
315 #ifdef CEXMC_USE_ROOT
320 CexmcHistoManager * histoManager( CexmcHistoManager::Instance() );
322 histoManager->Add( CexmcAbsorbedEnergy_EDT_Histo, 0,
326 for ( CexmcAngularRangeList::const_iterator
327 k( triggeredAngularRanges.begin() );
328 k != triggeredAngularRanges.end(); ++
k )
330 histoManager->Add( CexmcAbsEnInLeftCalorimeter_ARReal_EDT_Histo,
332 histoManager->Add( CexmcAbsEnInRightCalorimeter_ARReal_EDT_Histo,
342 CexmcHistoManager * histoManager( CexmcHistoManager::Instance() );
346 histoManager->Add( CexmcMomentumBP_TPT_Histo, 0,
348 histoManager->Add( CexmcTPInMonitor_TPT_Histo, 0,
355 histoManager->Add( CexmcTPInTarget_TPT_Histo, 0,
359 if ( histoManager->GetVerboseLevel() > 0 )
361 histoManager->Add( CexmcMomentumIP_TPT_Histo, 0,
366 for ( CexmcAngularRangeList::const_iterator
367 k( triggeredAngularRanges.begin() );
368 k != triggeredAngularRanges.end(); ++
k )
374 histoManager->Add( CexmcKinEnAtLeftCalorimeter_ARReal_TPT_Histo,
375 k->index, kinEnergy );
380 histoManager->Add( CexmcKinEnAtRightCalorimeter_ARReal_TPT_Histo,
381 k->index, kinEnergy );
385 histoManager->Add( CexmcTPInTarget_ARReal_TPT_Histo,
k->index,
389 histoManager->Add( CexmcKinEnOP_LAB_ARReal_TPT_Histo,
k->index,
391 histoManager->Add( CexmcAngleOP_SCM_ARReal_TPT_Histo,
k->index,
399 directionWorld.angle( tpStore->
400 targetTPOutputParticleDecayProductParticle2.
401 directionWorld ) /
deg );
402 histoManager->Add( CexmcOpenAngle_ARReal_TPT_Histo,
k->index,
409 void CexmcEventAction::FillRTHistos(
G4bool reconstructorHasFullTrigger,
415 CexmcHistoManager * histoManager( CexmcHistoManager::Instance() );
420 histoManager->Add( CexmcRecMasses_EDT_Histo, 0, opMass, nopMass );
422 for ( CexmcAngularRangeList::const_iterator
423 k( triggeredAngularRanges.begin() );
424 k != triggeredAngularRanges.end(); ++
k )
428 histoManager->Add( CexmcOPDPAtLeftCalorimeter_ARReal_EDT_Histo,
435 histoManager->Add( CexmcOPDPAtRightCalorimeter_ARReal_EDT_Histo,
440 histoManager->Add( CexmcRecOPDPAtLeftCalorimeter_ARReal_EDT_Histo,
444 histoManager->Add( CexmcRecOPDPAtRightCalorimeter_ARReal_EDT_Histo,
450 if ( ! reconstructorHasFullTrigger )
455 histoManager->Add( CexmcMomentumBP_RT_Histo, 0,
461 histoManager->Add( CexmcTPInTarget_RT_Histo, 0,
467 histoManager->Add( CexmcRecMasses_RT_Histo, 0,
471 histoManager->Add( CexmcAbsorbedEnergy_RT_Histo, 0,
476 outputParticleSCM.cosTheta());
478 for ( CexmcAngularRangeList::const_iterator
479 k( triggeredAngularRanges.begin() );
480 k != triggeredAngularRanges.end(); ++
k )
482 histoManager->Add( CexmcRecMassOP_ARReal_RT_Histo,
k->index, opMass );
483 histoManager->Add( CexmcRecMassNOP_ARReal_RT_Histo,
k->index, nopMass );
487 histoManager->Add( CexmcKinEnAtLeftCalorimeter_ARReal_RT_Histo,
488 k->index, kinEnergy );
489 histoManager->Add( CexmcMissEnFromLeftCalorimeter_ARReal_RT_Histo,
496 histoManager->Add( CexmcKinEnAtRightCalorimeter_ARReal_RT_Histo,
497 k->index, kinEnergy );
498 histoManager->Add( CexmcMissEnFromRightCalorimeter_ARReal_RT_Histo,
504 histoManager->Add( CexmcTPInTarget_ARReal_RT_Histo,
k->index,
508 histoManager->Add( CexmcKinEnOP_LAB_ARReal_RT_Histo,
k->index,
510 histoManager->Add( CexmcAngleOP_SCM_ARReal_RT_Histo,
k->index,
514 histoManager->Add( CexmcDiffAngleOP_SCM_ARReal_RT_Histo,
k->index,
522 directionWorld.angle( tpStore->
523 targetTPOutputParticleDecayProductParticle2.
524 directionWorld ) /
deg );
525 histoManager->Add( CexmcOpenAngle_ARReal_RT_Histo,
k->index,
529 histoManager->Add( CexmcDiffOpenAngle_ARReal_RT_Histo,
k->index,
534 histoManager->Add( CexmcOPDPAtLeftCalorimeter_ARReal_RT_Histo,
541 histoManager->Add( CexmcOPDPAtRightCalorimeter_ARReal_RT_Histo,
546 histoManager->Add( CexmcAbsEnInLeftCalorimeter_ARReal_RT_Histo,
548 histoManager->Add( CexmcAbsEnInRightCalorimeter_ARReal_RT_Histo,
550 histoManager->Add( CexmcRecAngleOP_SCM_ARReal_RT_Histo,
551 k->index, recCosTheta );
552 histoManager->Add( CexmcRecOpenAngle_ARReal_RT_Histo,
554 histoManager->Add( CexmcRecOPDPAtLeftCalorimeter_ARReal_RT_Histo,
558 histoManager->Add( CexmcRecOPDPAtRightCalorimeter_ARReal_RT_Histo,
570 G4VisManager * visManager( static_cast< G4VisManager * >(
578 if ( ! trajContainer )
581 nTraj = trajContainer->
entries();
583 for (
int i( 0 ); i < nTraj; ++i )
594 G4VisManager * visManager( static_cast< G4VisManager * >(
608 visManager->
Draw( circle );
614 visManager->
Draw( circle );
620 visManager->
Draw( circle );
626 visManager->
Draw( circle );
632 visManager->
Draw( circle );
638 visManager->
Draw( circle );
644 visManager->
Draw( circle );
651 G4VisManager * visManager( static_cast< G4VisManager * >(
660 circle.SetVisAttributes( visAttributes );
661 visManager->
Draw( circle );
663 circle.SetScreenSize( CexmcBigCircleScreenSize );
665 visManager->
Draw( circle );
668 visManager->
Draw( circle );
675 G4bool tpDigitizerHasTriggered,
676 G4bool edDigitizerHasTriggered,
677 G4bool edDigitizerMonitorHasTriggered,
678 G4bool reconstructorHasFullTrigger,
682 const CexmcRun * run( static_cast< const CexmcRun * >(
684 CexmcRun * theRun( const_cast< CexmcRun * >( run ) );
686 if ( tpDigitizerHasTriggered )
688 for ( CexmcAngularRangeList::const_iterator
k( aRangesReal.begin() );
689 k != aRangesReal.end(); ++
k )
692 if ( edDigitizerMonitorHasTriggered )
694 if ( reconstructorHasFullTrigger )
697 if ( reconstructorHasFullTrigger )
699 if ( aRangesRec.empty() )
705 for ( CexmcAngularRangeList::const_iterator
706 k( aRangesRec.begin() );
k != aRangesRec.end(); ++
k )
715 if ( edDigitizerHasTriggered )
717 if ( reconstructorHasFullTrigger )
723 #ifdef CEXMC_USE_PERSISTENCY
725 void CexmcEventAction::SaveEvent(
const G4Event * event,
726 G4bool edDigitizerHasTriggered,
733 if ( ! runManager->ProjectIsSaved() )
739 if ( ! edDigitizerHasTriggered && runManager->GetEventDataVerboseLevel() !=
743 boost::archive::binary_oarchive * archive(
744 runManager->GetEventsArchive() );
747 CexmcEventSObject sObject = {
event->GetEventID(),
748 edDigitizerHasTriggered, edStore->
monitorED,
759 archive->operator<<( sObject );
760 const CexmcRun * run( static_cast< const CexmcRun * >(
761 runManager->GetCurrentRun() ) );
762 CexmcRun * theRun( const_cast< CexmcRun * >( run ) );
763 theRun->IncrementNmbOfSavedEvents();
768 void CexmcEventAction::SaveEventFast(
const G4Event * event,
769 G4bool tpDigitizerHasTriggered,
770 G4bool edDigitizerHasTriggered,
771 G4bool edDigitizerMonitorHasTriggered,
776 if ( ! runManager->ProjectIsSaved() )
782 boost::archive::binary_oarchive * archive(
783 runManager->GetFastEventsArchive() );
786 if ( ! tpDigitizerHasTriggered )
789 CexmcEventFastSObject sObject = {
event->GetEventID(), opCosThetaSCM,
790 edDigitizerHasTriggered,
791 edDigitizerMonitorHasTriggered };
792 archive->operator<<( sObject );
793 const CexmcRun * run( static_cast< const CexmcRun * >(
794 runManager->GetCurrentRun() ) );
795 CexmcRun * theRun( const_cast< CexmcRun * >( run ) );
796 theRun->IncrementNmbOfSavedFastEvents();
807 static_cast< CexmcEnergyDepositDigitizer * >( digiManager->
810 static_cast< CexmcTrackPointsDigitizer * >( digiManager->
816 G4bool edDigitizerMonitorHasTriggered(
818 G4bool edDigitizerHasTriggered(
false );
823 edDigitizerHasTriggered = energyDepositDigitizer->
HasTriggered();
826 G4bool reconstructorHasBasicTrigger(
false );
827 G4bool reconstructorHasFullTrigger(
false );
830 energyDepositDigitizer ) );
832 trackPointsDigitizer ) );
839 if ( ! productionModel )
843 productionModel->GetAngularRanges() );
845 productionModel->GetTriggeredAngularRanges() );
847 productionModel->GetProductionModelData() );
849 if ( edDigitizerHasTriggered )
858 if ( reconstructorHasBasicTrigger )
860 for ( CexmcAngularRangeList::const_iterator
861 k( angularRanges.begin() );
k != angularRanges.end(); ++
k )
864 outputParticleSCM.cosTheta() );
865 if ( cosTheta <= k->top && cosTheta >
k->bottom )
867 k->top,
k->bottom,
k->index ) );
872 if ( triggeredRecAngularRanges.empty() )
876 for ( CexmcAngularRangeList::const_iterator
877 k( angularGaps.begin() );
k != angularGaps.end(); ++
k )
880 outputParticleSCM.cosTheta() );
881 if ( cosTheta <= k->top && cosTheta >
k->bottom )
889 UpdateRunHits( triggeredAngularRanges, triggeredRecAngularRanges,
890 tpDigitizerHasTriggered, edDigitizerHasTriggered,
891 edDigitizerMonitorHasTriggered,
892 reconstructorHasFullTrigger, angularGap );
897 ( (
verbose == 1 ) && tpDigitizerHasTriggered ) ||
898 ( (
verbose == 2 ) && edDigitizerHasTriggered ) ||
899 ( (
verbose == 3 ) && ( tpDigitizerHasTriggered ||
900 edDigitizerHasTriggered ) ) );
904 if ( tpDigitizerHasTriggered )
909 if ( reconstructorHasBasicTrigger )
912 if ( edDigitizerHasTriggered )
920 ( (
verboseDraw == 1 ) && tpDigitizerHasTriggered ) ||
921 ( (
verboseDraw == 2 ) && edDigitizerHasTriggered ) ||
922 ( (
verboseDraw == 3 ) && ( tpDigitizerHasTriggered ||
923 edDigitizerHasTriggered ) ) );
924 if ( drawTrajectories )
927 if ( tpDigitizerHasTriggered )
929 if ( reconstructorHasBasicTrigger )
934 #ifdef CEXMC_USE_PERSISTENCY
935 if ( edDigitizerHasTriggered || tpDigitizerHasTriggered )
937 SaveEventFast( event, tpDigitizerHasTriggered,
938 edDigitizerHasTriggered,
939 edDigitizerMonitorHasTriggered,
941 SaveEvent( event, edDigitizerHasTriggered, edStore, tpStore,
946 #ifdef CEXMC_USE_ROOT
950 opKinEnergy = CexmcGetKinEnergy(
955 if ( edDigitizerHasTriggered )
956 FillEDTHistos( edStore, triggeredAngularRanges );
960 if ( tpDigitizerHasTriggered && edDigitizerMonitorHasTriggered )
961 FillTPTHistos( tpStore, pmData, triggeredAngularRanges );
963 if ( reconstructorHasBasicTrigger )
964 FillRTHistos( reconstructorHasFullTrigger, edStore, tpStore,
965 pmData, triggeredAngularRanges );
968 G4Event * theEvent( const_cast< G4Event * >( event ) );
975 edDigitizerHasTriggered,
976 tpDigitizerHasTriggered,
977 reconstructorHasFullTrigger ) );