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;
96 physicsManager( physicsManager ), reconstructor( NULL ), opKinEnergy( 0. ),
97 verbose( verbose ), verboseDraw( 4 ), messenger( NULL )
127 ( static_cast< CexmcTrackingAction * >(
128 const_cast< G4UserTrackingAction * >(
150 calorimeterEDLeftCollection(
153 calorimeterEDRightCollection(
158 vetoCounterEDRight, calorimeterEDLeft, calorimeterEDRight,
159 calorimeterEDLeftMaxX, calorimeterEDLeftMaxY,
160 calorimeterEDRightMaxX, calorimeterEDRightMaxY,
161 calorimeterEDLeftCollection, calorimeterEDRightCollection );
171 targetTPBeamParticle(
174 targetTPOutputParticle(
177 targetTPNucleusParticle(
180 targetTPOutputParticleDecayProductParticle1(
182 GetTargetTPOutputParticleDecayProductParticle( 0 ) );
184 targetTPOutputParticleDecayProductParticle2(
186 GetTargetTPOutputParticleDecayProductParticle( 1 ) );
202 targetTPOutputParticle, targetTPNucleusParticle,
203 targetTPOutputParticleDecayProductParticle1,
204 targetTPOutputParticleDecayProductParticle2,
205 vetoCounterTPLeft, vetoCounterTPRight,
206 calorimeterTPLeft, calorimeterTPRight );
214 G4cout <<
" monitor : " <<
220 G4cout <<
" cal (l) : " <<
223 G4cout <<
" cal (r) : " <<
249 G4cout <<
" angle between the " <<
251 " decay products : " <<
263 G4cout <<
" --- Triggered angular ranges: " << angularRanges;
264 G4cout <<
" --- Production model data: " << pmData;
289 G4cout <<
" < mass cut passed >" << G4endl;
296 G4cout <<
" < absorbed energy cut passed >" << G4endl;
302 G4cout <<
" -- production model data: " << pmData;
303 G4cout <<
" -- triggered angular ranges: ";
304 if ( triggeredRecAngularRanges.empty() )
305 G4cout <<
"< orphan detected, gap " << angularGap <<
" >" << G4endl;
307 G4cout << triggeredRecAngularRanges;
311 #ifdef CEXMC_USE_ROOT
316 CexmcHistoManager * histoManager( CexmcHistoManager::Instance() );
318 histoManager->Add( CexmcAbsorbedEnergy_EDT_Histo, 0,
322 for ( CexmcAngularRangeList::const_iterator
323 k( triggeredAngularRanges.begin() );
324 k != triggeredAngularRanges.end(); ++k )
326 histoManager->Add( CexmcAbsEnInLeftCalorimeter_ARReal_EDT_Histo,
328 histoManager->Add( CexmcAbsEnInRightCalorimeter_ARReal_EDT_Histo,
338 CexmcHistoManager * histoManager( CexmcHistoManager::Instance() );
342 histoManager->Add( CexmcMomentumBP_TPT_Histo, 0,
344 histoManager->Add( CexmcTPInMonitor_TPT_Histo, 0,
351 histoManager->Add( CexmcTPInTarget_TPT_Histo, 0,
355 if ( histoManager->GetVerboseLevel() > 0 )
357 histoManager->Add( CexmcMomentumIP_TPT_Histo, 0,
362 for ( CexmcAngularRangeList::const_iterator
363 k( triggeredAngularRanges.begin() );
364 k != triggeredAngularRanges.end(); ++k )
370 histoManager->Add( CexmcKinEnAtLeftCalorimeter_ARReal_TPT_Histo,
371 k->index, kinEnergy );
376 histoManager->Add( CexmcKinEnAtRightCalorimeter_ARReal_TPT_Histo,
377 k->index, kinEnergy );
381 histoManager->Add( CexmcTPInTarget_ARReal_TPT_Histo, k->index,
385 histoManager->Add( CexmcKinEnOP_LAB_ARReal_TPT_Histo, k->index,
387 histoManager->Add( CexmcAngleOP_SCM_ARReal_TPT_Histo, k->index,
395 directionWorld.angle( tpStore->
396 targetTPOutputParticleDecayProductParticle2.
397 directionWorld ) /
deg );
398 histoManager->Add( CexmcOpenAngle_ARReal_TPT_Histo, k->index,
405 void CexmcEventAction::FillRTHistos(
G4bool reconstructorHasFullTrigger,
411 CexmcHistoManager * histoManager( CexmcHistoManager::Instance() );
416 histoManager->Add( CexmcRecMasses_EDT_Histo, 0, opMass, nopMass );
418 for ( CexmcAngularRangeList::const_iterator
419 k( triggeredAngularRanges.begin() );
420 k != triggeredAngularRanges.end(); ++k )
424 histoManager->Add( CexmcOPDPAtLeftCalorimeter_ARReal_EDT_Histo,
431 histoManager->Add( CexmcOPDPAtRightCalorimeter_ARReal_EDT_Histo,
436 histoManager->Add( CexmcRecOPDPAtLeftCalorimeter_ARReal_EDT_Histo,
440 histoManager->Add( CexmcRecOPDPAtRightCalorimeter_ARReal_EDT_Histo,
446 if ( ! reconstructorHasFullTrigger )
451 histoManager->Add( CexmcMomentumBP_RT_Histo, 0,
457 histoManager->Add( CexmcTPInTarget_RT_Histo, 0,
463 histoManager->Add( CexmcRecMasses_RT_Histo, 0,
467 histoManager->Add( CexmcAbsorbedEnergy_RT_Histo, 0,
472 outputParticleSCM.cosTheta());
474 for ( CexmcAngularRangeList::const_iterator
475 k( triggeredAngularRanges.begin() );
476 k != triggeredAngularRanges.end(); ++k )
478 histoManager->Add( CexmcRecMassOP_ARReal_RT_Histo, k->index, opMass );
479 histoManager->Add( CexmcRecMassNOP_ARReal_RT_Histo, k->index, nopMass );
483 histoManager->Add( CexmcKinEnAtLeftCalorimeter_ARReal_RT_Histo,
484 k->index, kinEnergy );
485 histoManager->Add( CexmcMissEnFromLeftCalorimeter_ARReal_RT_Histo,
492 histoManager->Add( CexmcKinEnAtRightCalorimeter_ARReal_RT_Histo,
493 k->index, kinEnergy );
494 histoManager->Add( CexmcMissEnFromRightCalorimeter_ARReal_RT_Histo,
500 histoManager->Add( CexmcTPInTarget_ARReal_RT_Histo, k->index,
504 histoManager->Add( CexmcKinEnOP_LAB_ARReal_RT_Histo, k->index,
506 histoManager->Add( CexmcAngleOP_SCM_ARReal_RT_Histo, k->index,
510 histoManager->Add( CexmcDiffAngleOP_SCM_ARReal_RT_Histo, k->index,
518 directionWorld.angle( tpStore->
519 targetTPOutputParticleDecayProductParticle2.
520 directionWorld ) /
deg );
521 histoManager->Add( CexmcOpenAngle_ARReal_RT_Histo, k->index,
525 histoManager->Add( CexmcDiffOpenAngle_ARReal_RT_Histo, k->index,
530 histoManager->Add( CexmcOPDPAtLeftCalorimeter_ARReal_RT_Histo,
537 histoManager->Add( CexmcOPDPAtRightCalorimeter_ARReal_RT_Histo,
542 histoManager->Add( CexmcAbsEnInLeftCalorimeter_ARReal_RT_Histo,
544 histoManager->Add( CexmcAbsEnInRightCalorimeter_ARReal_RT_Histo,
546 histoManager->Add( CexmcRecAngleOP_SCM_ARReal_RT_Histo,
547 k->index, recCosTheta );
548 histoManager->Add( CexmcRecOpenAngle_ARReal_RT_Histo,
550 histoManager->Add( CexmcRecOPDPAtLeftCalorimeter_ARReal_RT_Histo,
554 histoManager->Add( CexmcRecOPDPAtRightCalorimeter_ARReal_RT_Histo,
566 G4VisManager * visManager( static_cast< G4VisManager * >(
574 if ( ! trajContainer )
577 nTraj = trajContainer->
entries();
579 for (
int i( 0 ); i < nTraj; ++i )
590 G4VisManager * visManager( static_cast< G4VisManager * >(
604 visManager->
Draw( circle );
610 visManager->
Draw( circle );
616 visManager->
Draw( circle );
622 visManager->
Draw( circle );
628 visManager->
Draw( circle );
634 visManager->
Draw( circle );
640 visManager->
Draw( circle );
647 G4VisManager * visManager( static_cast< G4VisManager * >(
656 circle.SetVisAttributes( visAttributes );
657 visManager->
Draw( circle );
659 circle.SetScreenSize( CexmcBigCircleScreenSize );
661 visManager->
Draw( circle );
664 visManager->
Draw( circle );
671 G4bool tpDigitizerHasTriggered,
672 G4bool edDigitizerHasTriggered,
673 G4bool edDigitizerMonitorHasTriggered,
674 G4bool reconstructorHasFullTrigger,
678 const CexmcRun * run( static_cast< const CexmcRun * >(
680 CexmcRun * theRun( const_cast< CexmcRun * >( run ) );
682 if ( tpDigitizerHasTriggered )
684 for ( CexmcAngularRangeList::const_iterator k( aRangesReal.begin() );
685 k != aRangesReal.end(); ++k )
688 if ( edDigitizerMonitorHasTriggered )
690 if ( reconstructorHasFullTrigger )
693 if ( reconstructorHasFullTrigger )
695 if ( aRangesRec.empty() )
701 for ( CexmcAngularRangeList::const_iterator
702 k( aRangesRec.begin() ); k != aRangesRec.end(); ++k )
711 if ( edDigitizerHasTriggered )
713 if ( reconstructorHasFullTrigger )
719 #ifdef CEXMC_USE_PERSISTENCY
721 void CexmcEventAction::SaveEvent(
const G4Event * event,
722 G4bool edDigitizerHasTriggered,
729 if ( ! runManager->ProjectIsSaved() )
735 if ( ! edDigitizerHasTriggered && runManager->GetEventDataVerboseLevel() !=
739 boost::archive::binary_oarchive * archive(
740 runManager->GetEventsArchive() );
743 CexmcEventSObject sObject = {
event->GetEventID(),
744 edDigitizerHasTriggered, edStore->
monitorED,
755 archive->operator<<( sObject );
756 const CexmcRun * run( static_cast< const CexmcRun * >(
757 runManager->GetCurrentRun() ) );
758 CexmcRun * theRun( const_cast< CexmcRun * >( run ) );
759 theRun->IncrementNmbOfSavedEvents();
764 void CexmcEventAction::SaveEventFast(
const G4Event * event,
765 G4bool tpDigitizerHasTriggered,
766 G4bool edDigitizerHasTriggered,
767 G4bool edDigitizerMonitorHasTriggered,
772 if ( ! runManager->ProjectIsSaved() )
778 boost::archive::binary_oarchive * archive(
779 runManager->GetFastEventsArchive() );
782 if ( ! tpDigitizerHasTriggered )
785 CexmcEventFastSObject sObject = {
event->GetEventID(), opCosThetaSCM,
786 edDigitizerHasTriggered,
787 edDigitizerMonitorHasTriggered };
788 archive->operator<<( sObject );
789 const CexmcRun * run( static_cast< const CexmcRun * >(
790 runManager->GetCurrentRun() ) );
791 CexmcRun * theRun( const_cast< CexmcRun * >( run ) );
792 theRun->IncrementNmbOfSavedFastEvents();
803 static_cast< CexmcEnergyDepositDigitizer * >( digiManager->
806 static_cast< CexmcTrackPointsDigitizer * >( digiManager->
812 G4bool edDigitizerMonitorHasTriggered(
814 G4bool edDigitizerHasTriggered(
false );
819 edDigitizerHasTriggered = energyDepositDigitizer->
HasTriggered();
822 G4bool reconstructorHasBasicTrigger(
false );
823 G4bool reconstructorHasFullTrigger(
false );
826 energyDepositDigitizer ) );
828 trackPointsDigitizer ) );
835 if ( ! productionModel )
839 productionModel->GetAngularRanges() );
841 productionModel->GetTriggeredAngularRanges() );
843 productionModel->GetProductionModelData() );
845 if ( edDigitizerHasTriggered )
854 if ( reconstructorHasBasicTrigger )
856 for ( CexmcAngularRangeList::const_iterator
857 k( angularRanges.begin() ); k != angularRanges.end(); ++k )
860 outputParticleSCM.cosTheta() );
861 if ( cosTheta <= k->top && cosTheta > k->bottom )
863 k->top, k->bottom, k->index ) );
868 if ( triggeredRecAngularRanges.empty() )
872 for ( CexmcAngularRangeList::const_iterator
873 k( angularGaps.begin() ); k != angularGaps.end(); ++k )
876 outputParticleSCM.cosTheta() );
877 if ( cosTheta <= k->top && cosTheta > k->bottom )
885 UpdateRunHits( triggeredAngularRanges, triggeredRecAngularRanges,
886 tpDigitizerHasTriggered, edDigitizerHasTriggered,
887 edDigitizerMonitorHasTriggered,
888 reconstructorHasFullTrigger, angularGap );
893 ( (
verbose == 1 ) && tpDigitizerHasTriggered ) ||
894 ( (
verbose == 2 ) && edDigitizerHasTriggered ) ||
895 ( (
verbose == 3 ) && ( tpDigitizerHasTriggered ||
896 edDigitizerHasTriggered ) ) );
900 if ( tpDigitizerHasTriggered )
905 if ( reconstructorHasBasicTrigger )
908 if ( edDigitizerHasTriggered )
916 ( (
verboseDraw == 1 ) && tpDigitizerHasTriggered ) ||
917 ( (
verboseDraw == 2 ) && edDigitizerHasTriggered ) ||
918 ( (
verboseDraw == 3 ) && ( tpDigitizerHasTriggered ||
919 edDigitizerHasTriggered ) ) );
920 if ( drawTrajectories )
923 if ( tpDigitizerHasTriggered )
925 if ( reconstructorHasBasicTrigger )
930 #ifdef CEXMC_USE_PERSISTENCY
931 if ( edDigitizerHasTriggered || tpDigitizerHasTriggered )
933 SaveEventFast( event, tpDigitizerHasTriggered,
934 edDigitizerHasTriggered,
935 edDigitizerMonitorHasTriggered,
937 SaveEvent( event, edDigitizerHasTriggered, edStore, tpStore,
942 #ifdef CEXMC_USE_ROOT
951 if ( edDigitizerHasTriggered )
952 FillEDTHistos( edStore, triggeredAngularRanges );
956 if ( tpDigitizerHasTriggered && edDigitizerMonitorHasTriggered )
957 FillTPTHistos( tpStore, pmData, triggeredAngularRanges );
959 if ( reconstructorHasBasicTrigger )
960 FillRTHistos( reconstructorHasFullTrigger, edStore, tpStore,
961 pmData, triggeredAngularRanges );
964 G4Event * theEvent( const_cast< G4Event * >( event ) );
971 edDigitizerHasTriggered,
972 tpDigitizerHasTriggered,
973 reconstructorHasFullTrigger ) );
G4double vetoCounterEDLeft
CexmcEventActionMessenger * messenger
const G4String CexmcTPDigitizerName("TPDig")
G4double GetTheAngle(void) const
G4bool HasTriggered(void) const
const G4ThreeVector & GetTargetEPPosition(void) const
G4VUserEventInformation * GetUserInformation() const
G4bool IsMassCutUsed(void) const
void EndOfEventAction(const G4Event *event)
const G4ThreeVector & GetCalorimeterEPLeftPosition(void) const
G4double GetOutputParticleMass(void) const
void PrintReconstructedData(const CexmcAngularRangeList &angularRanges, const CexmcAngularRange &angularGap) const
void IncrementNmbOfOrphanHits(G4int index)
G4double GetVetoCounterEDRight(void) const
static G4VVisManager * GetConcreteInstance()
G4double calorimeterEDLeft
void SetupBeamParticle(void)
const CexmcTrackPointInfo & GetVetoCounterTPRight(void) const
const CexmcEnergyDepositCalorimeterCollection & calorimeterEDLeftCollection
CexmcChargeExchangeReconstructor * reconstructor
void IncrementNmbOfHitsTriggeredRecRange(G4int index)
const CexmcTrackPointInfo & GetMonitorTP(void) const
G4ThreeVector positionLocal
G4double calorimeterEDRight
void SetFillStyle(FillStyle)
static G4DigiManager * GetDMpointer()
static G4double angle[DIM]
const CexmcTrackPointInfo & GetTargetTPNucleusParticle(void) const
static void PrintProductionModelData(const CexmcAngularRangeList &angularRanges, const CexmcProductionModelData &pmData)
G4VGraphicsSystem * GetCurrentGraphicsSystem() const
G4bool IsAbsorbedEnergyCutUsed(void) const
const CexmcTrackPointInfo & GetTargetTPBeamParticle(void) const
void IncrementNmbOfHitsTriggeredRealRange(G4int index)
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
G4LorentzVector incidentParticleLAB
G4double vetoCounterEDRight
void DrawReconstructionData(void)
virtual ~CexmcEventAction()
CexmcEventAction(CexmcPhysicsManager *physicsManager, G4int verbose=0)
G4TrajectoryContainer * GetTrajectoryContainer() const
const G4Run * GetCurrentRun() const
const G4String & GetParticleName() const
G4LorentzVector outputParticleSCM
const G4String CexmcEDDigitizerName("EDDig")
virtual void DrawTrajectory() const
G4bool MonitorHasTriggered(void) const
G4int GetCalorimeterEDRightMaxY(void) const
void UpdateRunHits(const CexmcAngularRangeList &aRangesReal, const CexmcAngularRangeList &aRangesRec, G4bool tpDigitizerHasTriggered, G4bool edDigitizerHasTriggered, G4bool edDigitizerMonitorHasTriggered, G4bool reconstructorHasTriggered, const CexmcAngularRange &aGap)
void IncrementNmbOfFalseHitsTriggeredEDT(void)
const CexmcTrackPointInfo & targetTPNucleusParticle
void IncrementNmbOfFalseHitsTriggeredRec(void)
std::vector< CexmcEnergyDepositCrystalRowCollection > CexmcEnergyDepositCalorimeterCollection
void SetUserInformation(G4VUserEventInformation *anInfo)
G4GLOB_DLL std::ostream G4cout
const G4double CexmcInvalidCosTheta(2.0)
CexmcPhysicsManager * physicsManager
G4double GetVetoCounterEDLeft(void) const
void Reconstruct(const CexmcEnergyDepositStore *edStore)
void IncrementNmbOfHitsSampled(G4int index)
G4bool HasBasicTrigger(void) const
static CexmcEnergyDepositStore * MakeEnergyDepositStore(const CexmcEnergyDepositDigitizer *digitizer)
G4double GetMonitorED(void) const
void IncrementNmbOfHitsSampledFull(G4int index)
G4ThreeVector positionWorld
static void PrintTrackPoints(const CexmcTrackPointsStore *tpStore)
const CexmcTrackPointInfo & calorimeterTPRight
const CexmcTrackPointInfo & GetCalorimeterTPRight(void) const
const CexmcTrackPointInfo & GetCalorimeterTPLeft(void) const
const G4UserTrackingAction * GetUserTrackingAction() const
static void PrintEnergyDeposit(const CexmcEnergyDepositStore *edStore)
void BeginOfEventAction(const G4Event *event)
void AddNewModule(G4VDigitizerModule *DM)
static CexmcTrackPointsStore * MakeTrackPointsStore(const CexmcTrackPointsDigitizer *digitizer)
G4bool HasFullTrigger(void) const
const CexmcTrackPointInfo & GetTargetTPOutputParticle(void) const
void SetVisAttributes(const G4VisAttributes *)
const char * what(void) const
void DrawTrajectories(const G4Event *event)
static G4RunManager * GetRunManager()
const CexmcProductionModelData & GetProductionModelData(void) const
G4int GetCalorimeterEDLeftMaxY(void) const
G4double GetPDGMass() const
void SetPosition(const G4Point3D &)
G4double GetCalorimeterEDRight(void) const
G4bool EdTriggerIsOk(void) const
const CexmcTrackPointInfo & vetoCounterTPRight
const CexmcTrackPointInfo & targetTPOutputParticleDecayProductParticle2
G4int GetCalorimeterEDLeftMaxX(void) const
G4bool HasAbsorbedEnergyCutTriggered(void) const
G4bool IsValid(void) const
void Draw(const G4Circle &, const G4Transform3D &objectTransformation=G4Transform3D())
std::vector< CexmcAngularRange > CexmcAngularRangeList
const CexmcEnergyDepositCalorimeterCollection & GetCalorimeterEDRightCollection(void) const
const CexmcTrackPointInfo & vetoCounterTPLeft
G4int GetCalorimeterEDRightMaxX(void) const
const G4ThreeVector & GetCalorimeterEPRightWorldPosition(void) const
G4bool HasMassCutTriggered(void) const
const G4ThreeVector & GetCalorimeterEPLeftWorldPosition(void) const
const CexmcEnergyDepositCalorimeterCollection & GetCalorimeterEDLeftCollection(void) const
const CexmcTrackPointInfo & GetVetoCounterTPLeft(void) const
G4double GetNucleusOutputParticleMass(void) const
void ResetNumberOfTriggeredStudiedInteractions(void)
const CexmcEnergyDepositCalorimeterCollection & calorimeterEDRightCollection
G4bool HasTriggered(void) const
void DrawTrackPoints(const CexmcTrackPointsStore *tpStore) const
const CexmcTrackPointInfo & targetTPOutputParticle
const CexmcTrackPointInfo & calorimeterTPLeft
virtual CexmcProductionModel * GetProductionModel(void)=0
const G4ThreeVector & GetCalorimeterEPRightPosition(void) const
const G4ThreeVector & GetTargetEPWorldPosition(void) const
const CexmcTrackPointInfo & targetTPBeamParticle
void BeginOfEventAction(void)
G4double GetCalorimeterEDLeft(void) const
void GetAngularGaps(const CexmcAngularRangeList &src, CexmcAngularRangeList &dst)
const CexmcTrackPointInfo & monitorTP
void BeamParticleChangeHook(void)
void SetScreenSize(G4double)
G4ThreeVector directionWorld
const CexmcTrackPointInfo & targetTPOutputParticleDecayProductParticle1
const G4ParticleDefinition * particle