48 #ifdef CEXMC_USE_PERSISTENCY
49 #include <boost/archive/binary_iarchive.hpp>
50 #include <boost/archive/binary_oarchive.hpp>
100 G4String gdmlFileExtension(
".gdml" );
101 G4String gdmlbz2FileExtension(
".gdml.bz2" );
107 G4bool overrideExistingProject ) :
110 gdmlFileName(
"default.gdml" ), shouldGdmlFileBeValidated( true ),
111 zipGdmlFile( false ), projectsDir(
"." ), projectId( projectId ),
112 rProject( rProject ), guiMacroName(
"" ), cfFileName(
"" ),
114 skipInteractionsWithoutEDTonWrite( true ),
117 numberOfEventsProcessedEffective( 0 ), curEventRead( 0 ),
118 #ifdef CEXMC_USE_PERSISTENCY
119 eventsArchive( NULL ), fastEventsArchive( NULL ),
120 #ifdef CEXMC_USE_CUSTOM_FILTER
121 customFilter( NULL ),
124 physicsManager( NULL ), messenger( NULL )
127 if ( rProject !=
"" && rProject == projectId )
130 const char * projectsDirEnv( getenv(
"CEXMC_PROJECTS_DIR" ) );
132 if ( projectsDirEnv )
133 projectsDir = projectsDirEnv;
137 stat( ( projectsDir +
"/" + projectId +
".rdb" ).c_str(), &tmp ) == 0
138 && ! overrideExistingProject )
143 #ifdef CEXMC_USE_PERSISTENCY
145 ReadPreinitProjectData();
152 #ifdef CEXMC_USE_CUSTOM_FILTER
159 #ifdef CEXMC_USE_PERSISTENCY
161 void CexmcRunManager::ReadPreinitProjectData(
void )
167 std::ifstream runDataFile( ( projectsDir +
"/" + rProject +
".rdb" ).
173 boost::archive::binary_iarchive archive( runDataFile );
177 basePhysicsUsed = sObject.basePhysicsUsed;
179 productionModelType = sObject.productionModelType;
185 G4String fileExtension( zipGdmlFile ? gdmlbz2FileExtension :
187 cmd =
G4String(
"cp " ) + projectsDir +
"/" + rProject + fileExtension +
188 " " + projectsDir +
"/" + projectId + fileExtension;
189 if ( system( cmd ) != 0 )
195 cmd =
G4String(
"bunzip2 " ) + projectsDir +
"/" + rProject +
196 gdmlbz2FileExtension;
197 if ( system( cmd ) != 0 )
201 gdmlFileName = projectsDir +
"/" + rProject + gdmlFileExtension;
205 void CexmcRunManager::ReadProject(
void )
210 if ( ! physicsManager )
214 sObject.angularRanges );
216 for ( CexmcDecayBranchesStore::const_iterator
217 k( sObject.etaDecayTable.GetDecayBranches().begin() );
218 k != sObject.etaDecayTable.GetDecayBranches().end(); ++k )
220 etaDecayTable->GetDecayChannel( k->first )->SetBR( k->second );
224 sObject.fermiMotionIsOn,
false );
225 eventCountPolicy = sObject.eventCountPolicy;
232 region->GetProductionCuts()->SetProductionCuts(
233 sObject.calorimeterRegCuts );
236 static_cast< const CexmcPrimaryGeneratorAction * >(
239 const_cast< CexmcPrimaryGeneratorAction * >(
240 primaryGeneratorAction ) );
242 thePrimaryGeneratorAction->GetParticleGun() );
245 sObject.beamParticle ) );
246 if ( ! particleDefinition )
249 particleGun->SetParticleDefinition( particleDefinition );
250 particleGun->SetOrigPosition( sObject.beamPos,
false );
251 particleGun->SetOrigDirection( sObject.beamDir,
false );
252 particleGun->SetOrigMomentumAmp( sObject.beamMomentumAmp,
false );
254 thePrimaryGeneratorAction->SetFwhmPosX( sObject.beamFwhmPosX,
false );
255 thePrimaryGeneratorAction->SetFwhmPosY( sObject.beamFwhmPosY,
false );
256 thePrimaryGeneratorAction->SetFwhmDirX( sObject.beamFwhmDirX,
false );
257 thePrimaryGeneratorAction->SetFwhmDirY( sObject.beamFwhmDirY,
false );
258 thePrimaryGeneratorAction->SetFwhmMomentumAmp(
259 sObject.beamFwhmMomentumAmp,
false );
263 static_cast< CexmcEnergyDepositDigitizer * >(
268 edDigitizer->SetMonitorThreshold( sObject.monitorEDThreshold,
false );
269 edDigitizer->SetVetoCounterLeftThreshold(
270 sObject.vetoCounterEDLeftThreshold,
false );
271 edDigitizer->SetVetoCounterRightThreshold(
272 sObject.vetoCounterEDRightThreshold,
false );
273 edDigitizer->SetCalorimeterLeftThreshold(
274 sObject.calorimeterEDLeftThreshold,
false );
275 edDigitizer->SetCalorimeterRightThreshold(
276 sObject.calorimeterEDRightThreshold,
false );
277 edDigitizer->SetCalorimeterTriggerAlgorithm(
278 sObject.calorimeterTriggerAlgorithm,
false );
279 edDigitizer->SetOuterCrystalsVetoAlgorithm(
280 sObject.outerCrystalsVetoAlgorithm,
false );
281 edDigitizer->SetOuterCrystalsVetoFraction(
282 sObject.outerCrystalsVetoFraction,
false );
283 edDigitizer->ApplyFiniteCrystalResolution(
284 sObject.applyFiniteCrystalResolution,
false );
285 edDigitizer->SetCrystalResolutionData( sObject.crystalResolutionData );
295 theEventAction->GetReconstructor() );
296 if ( ! reconstructor )
299 reconstructor->SetCalorimeterEntryPointDefinitionAlgorithm(
300 sObject.epDefinitionAlgorithm );
301 reconstructor->SetCalorimeterEntryPointDepthDefinitionAlgorithm(
302 sObject.epDepthDefinitionAlgorithm );
303 reconstructor->SetCrystalSelectionAlgorithm( sObject.csAlgorithm );
304 reconstructor->UseInnerRefCrystal( sObject.useInnerRefCrystal );
305 reconstructor->SetCalorimeterEntryPointDepth( sObject.epDepth );
306 reconstructor->UseTableMass( sObject.useTableMass );
307 reconstructor->UseMassCut( sObject.useMassCut );
308 reconstructor->SetMassCutOPCenter( sObject.mCutOPCenter );
309 reconstructor->SetMassCutNOPCenter( sObject.mCutNOPCenter );
310 reconstructor->SetMassCutOPWidth( sObject.mCutOPWidth );
311 reconstructor->SetMassCutNOPWidth( sObject.mCutNOPWidth );
312 reconstructor->SetMassCutEllipseAngle( sObject.mCutAngle );
313 reconstructor->UseAbsorbedEnergyCut( sObject.useAbsorbedEnergyCut );
314 reconstructor->SetAbsorbedEnergyCutCLCenter( sObject.aeCutCLCenter );
315 reconstructor->SetAbsorbedEnergyCutCRCenter( sObject.aeCutCRCenter );
316 reconstructor->SetAbsorbedEnergyCutCLWidth( sObject.aeCutCLWidth );
317 reconstructor->SetAbsorbedEnergyCutCRWidth( sObject.aeCutCRWidth );
318 reconstructor->SetAbsorbedEnergyCutEllipseAngle( sObject.aeCutAngle );
319 reconstructor->SetExpectedMomentumAmp( sObject.expectedMomentumAmp );
320 reconstructor->SetEDCollectionAlgorithm( sObject.edCollectionAlgorithm );
324 rEvDataVerboseLevel = sObject.evDataVerboseLevel;
325 evDataVerboseLevel = rEvDataVerboseLevel;
329 void CexmcRunManager::SaveProject(
void )
335 if ( ! physicsManager )
338 CexmcSimpleDecayTableStore etaDecayTable(
341 static_cast< const CexmcPrimaryGeneratorAction * >(
344 const_cast< CexmcPrimaryGeneratorAction * >(
345 primaryGeneratorAction ) );
347 thePrimaryGeneratorAction->GetParticleGun() );
351 static_cast< CexmcEnergyDepositDigitizer * >(
361 theEventAction->GetReconstructor() );
363 std::vector< G4double > calorimeterRegCuts( 4 );
366 calorimeterRegCuts = sObject.calorimeterRegCuts;
375 calorimeterRegCuts = region->GetProductionCuts()->GetProductionCuts();
383 G4int nmbOfFalseHitsTriggeredEDT( 0 );
384 G4int nmbOfFalseHitsTriggeredRec( 0 );
385 G4int nmbOfSavedEvents( 0 );
386 G4int nmbOfSavedFastEvents( 0 );
391 nmbOfHitsSampled = run->GetNmbOfHitsSampled();
392 nmbOfHitsSampledFull = run->GetNmbOfHitsSampledFull();
393 nmbOfHitsTriggeredRealRange = run->GetNmbOfHitsTriggeredRealRange();
394 nmbOfHitsTriggeredRecRange = run->GetNmbOfHitsTriggeredRecRange();
395 nmbOfOrphanHits = run->GetNmbOfOrphanHits();
396 nmbOfFalseHitsTriggeredEDT = run->GetNmbOfFalseHitsTriggeredEDT();
397 nmbOfFalseHitsTriggeredRec = run->GetNmbOfFalseHitsTriggeredRec();
398 nmbOfSavedEvents = run->GetNmbOfSavedEvents();
399 nmbOfSavedFastEvents = run->GetNmbOfSavedFastEvents();
402 CexmcRunSObject sObjectToWrite = {
403 basePhysicsUsed, productionModelType, gdmlFileName, etaDecayTable,
406 calorimeterRegCuts, eventCountPolicy,
407 particleGun->GetParticleDefinition()->GetParticleName(),
408 particleGun->GetOrigPosition(), particleGun->GetOrigDirection(),
409 particleGun->GetOrigMomentumAmp(),
410 primaryGeneratorAction->GetFwhmPosX(),
411 primaryGeneratorAction->GetFwhmPosY(),
412 primaryGeneratorAction->GetFwhmDirX(),
413 primaryGeneratorAction->GetFwhmDirY(),
414 primaryGeneratorAction->GetFwhmMomentumAmp(),
415 edDigitizer->GetMonitorThreshold(),
416 edDigitizer->GetVetoCounterLeftThreshold(),
417 edDigitizer->GetVetoCounterRightThreshold(),
418 edDigitizer->GetCalorimeterLeftThreshold(),
419 edDigitizer->GetCalorimeterRightThreshold(),
420 edDigitizer->GetCalorimeterTriggerAlgorithm(),
421 edDigitizer->GetOuterCrystalsVetoAlgorithm(),
422 edDigitizer->GetOuterCrystalsVetoFraction(),
423 edDigitizer->IsFiniteCrystalResolutionApplied(),
424 edDigitizer->GetCrystalResolutionData(),
425 reconstructor->GetCalorimeterEntryPointDefinitionAlgorithm(),
426 reconstructor->GetCalorimeterEntryPointDepthDefinitionAlgorithm(),
427 reconstructor->GetCrystalSelectionAlgorithm(),
428 reconstructor->IsInnerRefCrystalUsed(),
429 reconstructor->GetCalorimeterEntryPointDepth(),
430 reconstructor->IsTableMassUsed(), reconstructor->IsMassCutUsed(),
431 reconstructor->GetMassCutOPCenter(),
432 reconstructor->GetMassCutNOPCenter(),
433 reconstructor->GetMassCutOPWidth(), reconstructor->GetMassCutNOPWidth(),
434 reconstructor->GetMassCutEllipseAngle(),
435 reconstructor->IsAbsorbedEnergyCutUsed(),
436 reconstructor->GetAbsorbedEnergyCutCLCenter(),
437 reconstructor->GetAbsorbedEnergyCutCRCenter(),
438 reconstructor->GetAbsorbedEnergyCutCLWidth(),
439 reconstructor->GetAbsorbedEnergyCutCRWidth(),
440 reconstructor->GetAbsorbedEnergyCutEllipseAngle(),
441 nmbOfHitsSampled, nmbOfHitsSampledFull, nmbOfHitsTriggeredRealRange,
442 nmbOfHitsTriggeredRecRange, nmbOfOrphanHits, nmbOfFalseHitsTriggeredEDT,
443 nmbOfFalseHitsTriggeredRec, nmbOfSavedEvents, nmbOfSavedFastEvents,
444 numberOfEventsProcessed, numberOfEventsProcessedEffective,
447 reconstructor->GetExpectedMomentumAmp(),
448 reconstructor->GetEDCollectionAlgorithm(), 0 };
450 std::ofstream runDataFile( ( projectsDir +
"/" + projectId +
".rdb" ).
454 boost::archive::binary_oarchive archive( runDataFile );
455 archive << sObjectToWrite;
462 void CexmcRunManager::DoCommonEventLoop(
G4int nEvent,
const G4String & cmd,
466 G4int iEventEffective( 0 );
468 for ( iEvent = 0; iEventEffective < nEvent; ++iEvent )
474 switch ( eventCountPolicy )
480 if ( eventInfo->TpTriggerIsOk() )
484 if ( eventInfo->EdTriggerIsOk() )
493 if ( iEvent < nSelect )
501 numberOfEventsProcessed = iEvent;
502 numberOfEventsProcessedEffective = iEventEffective;
506 #ifdef CEXMC_USE_PERSISTENCY
508 void CexmcRunManager::DoReadEventLoop(
G4int nEvent )
511 G4int iEventEffective( 0 );
512 G4int nEventCount( 0 );
517 if ( ! physicsManager )
522 if ( ! productionModel )
529 CexmcEventSObject evSObject;
530 CexmcEventFastSObject evFastSObject;
533 std::ifstream eventsDataFile(
534 ( projectsDir +
"/" + rProject +
".edb" ).c_str() );
535 if ( ! eventsDataFile )
538 boost::archive::binary_iarchive evArchive( eventsDataFile );
540 std::ifstream eventsFastDataFile(
541 ( projectsDir +
"/" + rProject +
".fdb" ).c_str() );
542 if ( ! eventsFastDataFile )
545 boost::archive::binary_iarchive evFastArchive( eventsFastDataFile );
550 event.SetHCofThisEvent( sdManager->PrepareNewEvent() );
555 G4int hcId( digiManager->GetHitsCollectionID(
560 hcOfThisEvent->AddHitsCollection( hcId, monitorED );
561 hcId = digiManager->GetHitsCollectionID(
566 hcOfThisEvent->AddHitsCollection( hcId, vetoCounterED );
567 hcId = digiManager->GetHitsCollectionID(
572 hcOfThisEvent->AddHitsCollection( hcId, calorimeterED );
573 hcId = digiManager->GetHitsCollectionID(
577 hcOfThisEvent->AddHitsCollection( hcId, monitorTP );
578 hcId = digiManager->GetHitsCollectionID(
583 hcOfThisEvent->AddHitsCollection( hcId, vetoCounterTP );
584 hcId = digiManager->GetHitsCollectionID(
589 hcOfThisEvent->AddHitsCollection( hcId, calorimeterTP );
590 hcId = digiManager->GetHitsCollectionID(
594 hcOfThisEvent->AddHitsCollection( hcId, targetTP );
596 #ifdef CEXMC_USE_CUSTOM_FILTER
598 customFilter->SetAddressedData( &evFastSObject, &evSObject );
602 sObject.nmbOfSavedFastEvents );
603 G4bool eventDataWrittenOnEveryTPT( rEvDataVerboseLevel ==
606 for (
int i( 0 ); i < nmbOfSavedEvents; ++i )
608 evFastArchive >> evFastSObject;
610 if ( nEventCount < curEventRead )
612 if ( eventDataWrittenOnEveryTPT ||
613 evFastSObject.edDigitizerHasTriggered )
615 evArchive >> evSObject;
616 if ( evFastSObject.edDigitizerHasTriggered )
624 productionModel->SetTriggeredAngularRanges(
625 evFastSObject.opCosThetaSCM );
627 productionModel->GetTriggeredAngularRanges() );
629 if ( ! eventDataWrittenOnEveryTPT &&
630 ! evFastSObject.edDigitizerHasTriggered )
632 #ifdef CEXMC_USE_CUSTOM_FILTER
638 if ( customFilter && ! customFilter->EvalTPT() )
641 SaveCurrentTPTEvent( evFastSObject, triggeredAngularRanges,
646 evArchive >> evSObject;
648 G4bool skipEDTOnThisEvent(
false );
650 #ifdef CEXMC_USE_CUSTOM_FILTER
651 if ( customFilter && ! customFilter->EvalTPT() )
653 if ( customFilter && ! customFilter->EvalEDT() )
655 if ( ! eventDataWrittenOnEveryTPT )
657 SaveCurrentTPTEvent( evFastSObject, triggeredAngularRanges,
661 skipEDTOnThisEvent =
true;
665 event.SetEventID( evSObject.eventId );
672 monitorED->GetMap()->operator[]( 0 ) = &evSObject.monitorED;
673 vetoCounterED->GetMap()->operator[]( 0 ) = &evSObject.vetoCounterEDLeft;
674 vetoCounterED->GetMap()->operator[]( 1 <<
676 &evSObject.vetoCounterEDRight;
679 for ( CexmcEnergyDepositCalorimeterCollection::iterator
680 k( evSObject.calorimeterEDLeftCollection.begin() );
681 k != evSObject.calorimeterEDLeftCollection.end(); ++k )
686 for ( CexmcEnergyDepositCrystalRowCollection::iterator
687 l( k->begin() ); l != k->end(); ++l )
689 calorimeterED->GetMap()->operator[](
index | column ) = &*l;
695 for ( CexmcEnergyDepositCalorimeterCollection::iterator
696 k( evSObject.calorimeterEDRightCollection.begin() );
697 k != evSObject.calorimeterEDRightCollection.end(); ++k )
704 for ( CexmcEnergyDepositCrystalRowCollection::iterator
705 l( k->begin() ); l != k->end(); ++l )
707 calorimeterED->GetMap()->operator[](
index | column ) = &*l;
715 evSObject.targetTPBeamParticle );
717 evSObject.targetTPOutputParticle );
719 evSObject.targetTPNucleusParticle );
721 evSObject.targetTPOutputParticleDecayProductParticle1 );
723 evSObject.targetTPOutputParticleDecayProductParticle2 );
725 evSObject.vetoCounterTPLeft );
727 evSObject.vetoCounterTPRight );
729 evSObject.calorimeterTPLeft );
731 evSObject.calorimeterTPRight );
733 if ( monitorTPInfo.IsValid() )
734 monitorTP->GetMap()->operator[]( monitorTPInfo.trackId ) =
736 if ( targetTPBeamParticleInfo.IsValid() )
737 targetTP->GetMap()->operator[](
738 targetTPBeamParticleInfo.trackId ) =
739 &targetTPBeamParticleInfo;
740 if ( targetTPOutputParticleInfo.IsValid() )
741 targetTP->GetMap()->operator[](
742 targetTPOutputParticleInfo.trackId ) =
743 &targetTPOutputParticleInfo;
744 if ( targetTPNucleusParticleInfo.IsValid() )
745 targetTP->GetMap()->operator[](
746 targetTPNucleusParticleInfo.trackId ) =
747 &targetTPNucleusParticleInfo;
748 if ( targetTPOutputParticleDecayProductParticle1Info.IsValid() )
749 targetTP->GetMap()->operator[](
750 targetTPOutputParticleDecayProductParticle1Info.trackId ) =
751 &targetTPOutputParticleDecayProductParticle1Info;
752 if ( targetTPOutputParticleDecayProductParticle2Info.IsValid() )
753 targetTP->GetMap()->operator[](
754 targetTPOutputParticleDecayProductParticle2Info.trackId ) =
755 &targetTPOutputParticleDecayProductParticle2Info;
756 if ( vetoCounterTPLeftInfo.IsValid() )
757 vetoCounterTP->GetMap()->operator[](
758 vetoCounterTPLeftInfo.trackId ) = &vetoCounterTPLeftInfo;
759 if ( vetoCounterTPRightInfo.IsValid() )
760 vetoCounterTP->GetMap()->operator[](
762 vetoCounterTPRightInfo.trackId ) = &vetoCounterTPRightInfo;
765 if ( calorimeterTPLeftInfo.IsValid() )
767 pos = calorimeterTPLeftInfo.positionLocal;
768 setup->ConvertToCrystalGeometry(
769 calorimeterTPLeftInfo.positionLocal, row, column, pos );
770 calorimeterTPLeftInfo.positionLocal = pos;
771 calorimeterTP->GetMap()->operator[](
776 calorimeterTPLeftInfo.trackId ) = &calorimeterTPLeftInfo;
778 if ( calorimeterTPRightInfo.IsValid() )
780 pos = calorimeterTPRightInfo.positionLocal;
781 setup->ConvertToCrystalGeometry(
782 calorimeterTPRightInfo.positionLocal, row, column, pos );
783 calorimeterTPRightInfo.positionLocal = pos;
784 calorimeterTP->GetMap()->operator[](
790 calorimeterTPRightInfo.trackId ) = &calorimeterTPRightInfo;
793 productionModel->SetProductionModelData(
794 evSObject.productionModelData );
803 monitorED->GetMap()->clear();
804 vetoCounterED->GetMap()->clear();
805 calorimeterED->GetMap()->clear();
806 monitorTP->GetMap()->clear();
807 targetTP->GetMap()->clear();
808 vetoCounterTP->GetMap()->clear();
809 calorimeterTP->GetMap()->clear();
813 if ( skipEDTOnThisEvent )
819 theEventAction->EndOfEventAction( &event );
824 if ( eventInfo->EdTriggerIsOk() )
828 event.SetUserInformation( NULL );
830 monitorED->GetMap()->clear();
831 vetoCounterED->GetMap()->clear();
832 calorimeterED->GetMap()->clear();
833 monitorTP->GetMap()->clear();
834 targetTP->GetMap()->clear();
835 vetoCounterTP->GetMap()->clear();
836 calorimeterTP->GetMap()->clear();
840 if ( nEvent > 0 && iEventEffective == nEvent )
844 curEventRead = nEventCount + iEventEffective;
846 numberOfEventsProcessed = iEvent;
847 numberOfEventsProcessedEffective = iEventEffective;
849 #ifdef CEXMC_USE_CUSTOM_FILTER
851 customFilter->SetAddressedData( NULL, NULL );
856 void CexmcRunManager::SaveCurrentTPTEvent(
857 const CexmcEventFastSObject & evFastSObject,
866 for ( CexmcAngularRangeList::const_iterator k( angularRanges.begin() );
867 k != angularRanges.end(); ++k )
869 run->IncrementNmbOfHitsSampledFull( k->index );
870 if ( evFastSObject.edDigitizerMonitorHasTriggered )
871 run->IncrementNmbOfHitsSampled( k->index );
874 if ( writeToDatabase )
876 fastEventsArchive->operator<<( evFastSObject );
877 run->IncrementNmbOfSavedFastEvents();
892 if ( macroFile != 0 )
896 cmd =
"/control/execute ";
904 numberOfEventsProcessed = 0;
905 numberOfEventsProcessedEffective = 0;
907 #ifdef CEXMC_USE_PERSISTENCY
908 eventsArchive = NULL;
909 fastEventsArchive = NULL;
914 std::ofstream eventsDataFile(
915 ( projectsDir +
"/" + projectId +
".edb" ).c_str() );
916 boost::archive::binary_oarchive eventsArchive_( eventsDataFile );
917 std::ofstream fastEventsDataFile(
918 ( projectsDir +
"/" + projectId +
".fdb" ).c_str() );
919 boost::archive::binary_oarchive fastEventsArchive_(
920 fastEventsDataFile );
921 eventsArchive = &eventsArchive_;
922 fastEventsArchive = &fastEventsArchive_;
923 DoReadEventLoop( nEvent );
927 DoReadEventLoop( nEvent );
934 std::ofstream eventsDataFile(
935 ( projectsDir +
"/" + projectId +
".edb" ).c_str() );
936 boost::archive::binary_oarchive eventsArchive_( eventsDataFile );
937 std::ofstream fastEventsDataFile(
938 ( projectsDir +
"/" + projectId +
".fdb" ).c_str() );
939 boost::archive::binary_oarchive fastEventsArchive_(
940 fastEventsDataFile );
941 eventsArchive = &eventsArchive_;
942 fastEventsArchive = &fastEventsArchive_;
943 DoCommonEventLoop( nEvent, cmd, nSelect );
947 DoCommonEventLoop( nEvent, cmd, nSelect );
950 eventsArchive = NULL;
951 fastEventsArchive = NULL;
953 DoCommonEventLoop( nEvent, cmd, nSelect );
963 G4cout <<
" Run Aborted after " << numberOfEventsProcessed <<
964 " events processed." <<
G4endl;
968 G4cout <<
" Number of events processed : " <<
969 numberOfEventsProcessed <<
", effectively: " <<
970 numberOfEventsProcessedEffective <<
G4endl;
977 #ifdef CEXMC_USE_PERSISTENCY
979 void CexmcRunManager::PrintReadRunData(
void )
const
984 G4bool refCrystalInfoPrinted(
false );
988 G4cout <<
" (archive class version " <<
989 sObject.actualVersion <<
")" <<
G4endl;
990 if ( ! sObject.rProject.empty() )
992 G4cout <<
" -- Based on project '" << sObject.rProject <<
"'" <<
994 if ( ! sObject.cfFileName.empty() )
995 G4cout <<
" -- Custom filter script '" << sObject.cfFileName <<
996 "' was used" << G4endl;
998 G4cout <<
" -- Event data verbose level (0 - not saved, 1 - triggers, "
999 "2 - interactions): " << sObject.evDataVerboseLevel <<
G4endl;
1000 if ( ! sObject.rProject.empty() )
1004 G4cout <<
" -- (fdb file contains " <<
1005 ( sObject.interactionsWithoutEDTWereSkipped ?
1006 "only interactions when an event was triggered" :
1007 "all interactions" ) <<
")" << std::endl;
1010 G4cout <<
" -- Base physics used (1 - QGSP_BERT, 2 - QGSP_BIC_EMY): " <<
1011 sObject.basePhysicsUsed <<
G4endl;
1012 G4cout <<
" -- Production model (1 - pi0, 2 - eta): " <<
1013 sObject.productionModelType <<
G4endl;
1014 G4cout <<
" -- Geometry definition file: " << sObject.gdmlFileName <<
1016 G4cout <<
" -- Angular ranges: " << sObject.angularRanges <<
G4endl;
1019 G4cout <<
" -- Fermi motion status (0 - disabled, 1 - enabled): " <<
1020 sObject.fermiMotionIsOn <<
G4endl;
1021 if ( sObject.calorimeterRegCuts.size() < 4 )
1023 G4cout <<
" -- Production cuts in calorimeter (gamma, e-, e+, p): " <<
1024 G4BestUnit( sObject.calorimeterRegCuts[ 0 ],
"Length" ) <<
", " <<
1025 G4BestUnit( sObject.calorimeterRegCuts[ 1 ],
"Length" ) <<
", " <<
1026 G4BestUnit( sObject.calorimeterRegCuts[ 2 ],
"Length" ) <<
", " <<
1028 G4cout <<
" -- Proposed max interaction length in the target: " <<
1030 G4cout <<
" -- Event count policy (0 - all, 1 - interaction, 2 - trigger)"
1031 ": " << sObject.eventCountPolicy <<
G4endl;
1032 G4cout <<
" -- Number of events (processed / effective / ordered): " <<
1033 sObject.numberOfEventsProcessed <<
" / " <<
1034 sObject.numberOfEventsProcessedEffective <<
" / " <<
1035 sObject.numberOfEventsToBeProcessed <<
G4endl;
1036 G4cout <<
" -- Incident beam particle: " << sObject.beamParticle <<
G4endl;
1037 G4cout <<
" position: " <<
1039 G4cout <<
" direction: " <<
1041 G4cout <<
" momentum: " <<
1043 G4cout <<
" momentum fwhm: " << sObject.beamFwhmMomentumAmp <<
1045 G4cout <<
" pos fwhm (x): " <<
1047 G4cout <<
" pos fwhm (y): " <<
1049 G4cout <<
" dir fwhm (x): " << sObject.beamFwhmDirX /
deg <<
1051 G4cout <<
" dir fwhm (y): " << sObject.beamFwhmDirY /
deg <<
1053 G4cout <<
" -- Monitor ED threshold: " <<
1055 G4cout <<
" -- Veto counter (l/r) ED threshold: " <<
1056 G4BestUnit( sObject.vetoCounterEDLeftThreshold,
"Energy" ) <<
1058 G4BestUnit( sObject.vetoCounterEDRightThreshold,
"Energy" ) <<
1060 G4cout <<
" -- Calorimeter (l/r) ED threshold: " <<
1061 G4BestUnit( sObject.calorimeterEDLeftThreshold,
"Energy" ) <<
1063 G4BestUnit( sObject.calorimeterEDRightThreshold,
"Energy" ) <<
1065 G4cout <<
" -- Calorimeter trigger algorithm (0 - all, 1 - inner): " <<
1066 sObject.calorimeterTriggerAlgorithm <<
G4endl;
1067 G4cout <<
" -- Outer crystals veto algorithm "
1068 "(0 - none, 1 - max, 2 - fraction): " <<
1069 sObject.outerCrystalsVetoAlgorithm <<
G4endl;
1070 if ( sObject.outerCrystalsVetoAlgorithm ==
1073 G4cout <<
" -- Outer crystals veto fraction: " <<
1074 sObject.outerCrystalsVetoFraction <<
G4endl;
1076 G4cout <<
" -- Finite crystal resolution applied (0 - no, 1 - yes): " <<
1077 sObject.applyFiniteCrystalResolution <<
G4endl;
1078 if ( sObject.applyFiniteCrystalResolution )
1080 G4cout <<
" -- Crystal resolution data: " <<
1081 sObject.crystalResolutionData;
1084 if ( sObject.expectedMomentumAmp > 0 )
1086 G4cout <<
" -- expected momentum in the target: " <<
1089 G4cout <<
" -- ed collection algorithm (0 - all, 1 - adjacent): " <<
1090 sObject.edCollectionAlgorithm <<
G4endl;
1094 " -- inner crystal used as reference (0 - no, 1 - yes): " <<
1095 sObject.useInnerRefCrystal <<
G4endl;
1096 refCrystalInfoPrinted =
true;
1098 G4cout <<
" -- entry point definition algorithm " <<
G4endl;
1099 G4cout <<
" (0 - center of calorimeter, 1 - center of crystal with "
1101 G4cout <<
" 2 - linear, 3 - square): " <<
1102 sObject.epDefinitionAlgorithm <<
G4endl;
1103 G4cout <<
" -- entry point depth definition algorithm "
1104 "(0 - plain, 1 - sphere): " <<
1105 sObject.epDepthDefinitionAlgorithm <<
G4endl;
1106 G4cout <<
" -- entry point depth: " <<
1112 " -- crystal selection algorithm (0 - all, 1 - adjacent): " <<
1113 sObject.csAlgorithm <<
G4endl;
1115 if ( ! refCrystalInfoPrinted &&
1116 ( sObject.epDefinitionAlgorithm ==
1119 sObject.epDefinitionAlgorithm ==
1124 " -- inner crystal used as reference (0 - no, 1 - yes): " <<
1125 sObject.useInnerRefCrystal <<
G4endl;
1127 G4cout <<
" -- table mass of output particle used "
1128 "(0 - no, 1 - yes): " << sObject.useTableMass <<
G4endl;
1129 G4cout <<
" -- mass cut is enabled (0 - no, 1 - yes): " <<
1130 sObject.useMassCut <<
G4endl;
1131 if ( sObject.useMassCut )
1133 G4cout <<
" -- mass cut output particle center: " <<
1135 G4cout <<
" -- mass cut nucleus output particle center: " <<
1137 G4cout <<
" -- mass cut output particle width of the ellipse: " <<
1139 G4cout <<
" -- mass cut nucleus output particle width of the "
1142 G4cout <<
" -- mass cut angle of the ellipse: " <<
1143 sObject.mCutAngle /
deg <<
" deg" <<
G4endl;
1145 G4cout <<
" -- absorbed energy cut is enabled (0 - no, 1 - yes): " <<
1146 sObject.useAbsorbedEnergyCut <<
G4endl;
1147 if ( sObject.useAbsorbedEnergyCut )
1149 G4cout <<
" -- absorbed energy cut left calorimeter center: " <<
1151 G4cout <<
" -- absorbed energy cut right calorimeter center: " <<
1153 G4cout <<
" -- absorbed energy cut left calorimeter width of the "
1156 G4cout <<
" -- absorbed energy cut right calorimeter width of the "
1159 G4cout <<
" -- absorbed energy cut angle of the ellipse: " <<
1160 sObject.aeCutAngle /
deg <<
" deg" <<
G4endl;
1164 sObject.nmbOfHitsSampledFull,
1165 sObject.nmbOfHitsTriggeredRealRange,
1166 sObject.nmbOfHitsTriggeredRecRange,
1167 sObject.nmbOfOrphanHits,
1168 sObject.angularRanges,
1169 sObject.nmbOfFalseHitsTriggeredEDT,
1170 sObject.nmbOfFalseHitsTriggeredRec );
1175 void CexmcRunManager::ReadAndPrintEventsData(
void )
const
1180 CexmcEventSObject evSObject;
1183 std::ifstream eventsDataFile(
1184 ( projectsDir +
"/" + rProject +
".edb" ).c_str() );
1185 if ( ! eventsDataFile )
1188 boost::archive::binary_iarchive evArchive( eventsDataFile );
1190 for (
int i( 0 ); i < sObject.nmbOfSavedEvents; ++i )
1192 evArchive >> evSObject;
1194 if ( ! evSObject.edDigitizerMonitorHasTriggered )
1198 evSObject.vetoCounterEDLeft, evSObject.vetoCounterEDRight,
1199 evSObject.calorimeterEDLeft, evSObject.calorimeterEDRight,
1200 0, 0, 0, 0, evSObject.calorimeterEDLeftCollection,
1201 evSObject.calorimeterEDRightCollection );
1204 evSObject.targetTPBeamParticle, evSObject.targetTPOutputParticle,
1205 evSObject.targetTPNucleusParticle,
1206 evSObject.targetTPOutputParticleDecayProductParticle1,
1207 evSObject.targetTPOutputParticleDecayProductParticle2,
1208 evSObject.vetoCounterTPLeft, evSObject.vetoCounterTPRight,
1209 evSObject.calorimeterTPLeft, evSObject.calorimeterTPRight );
1212 evSObject.productionModelData );
1216 G4cout <<
" --- Production model data: " << pmData;
1222 void CexmcRunManager::PrintReadData(
1228 G4bool addSpace(
false );
1230 CexmcOutputDataTypeSet::const_iterator found(
1232 if ( found != outputData.end() )
1235 gdmlFileExtension );
1236 if ( system( cmd ) != 0 )
1241 cmd =
G4String(
"bzip2 " ) + projectsDir +
"/" + rProject +
1243 if ( system( cmd ) != 0 )
1251 if ( found != outputData.end() )
1256 ReadAndPrintEventsData();
1262 if ( found != outputData.end() )
1268 for ( CexmcDecayBranchesStore::const_iterator
1269 k( sObject.etaDecayTable.GetDecayBranches().begin() );
1270 k != sObject.etaDecayTable.GetDecayBranches().end(); ++k )
1272 etaDecayTable->GetDecayChannel( k->first )->SetBR( k->second );
1280 #ifdef CEXMC_USE_CUSTOM_FILTER
1282 void CexmcRunManager::SetCustomFilter(
const G4String & cfFileName_ )
1286 delete customFilter;
1287 customFilter = NULL;
1290 if ( cfFileName_.empty() )
1297 cfFileName = cfFileName_;
1299 customFilter =
new CexmcCustomFilterEval( cfFileName );
1309 G4VisManager * visManager( static_cast< G4VisManager * >(
1319 #if G4VERSION_NUMBER < 960
1320 typedef std::vector< G4VModel * > MList;
1322 typedef std::vector< G4Scene::Model > MList;
1324 const MList & mList( curScene->GetRunDurationModelList() );
1326 for ( MList::const_iterator k( mList.begin() ); k != mList.end(); ++k )
1328 #if G4VERSION_NUMBER < 960
1329 const G4String & modelDesc( ( *k )->GetGlobalDescription() );
1331 const G4String & modelDesc( k->fpModel->GetGlobalDescription() );
1351 if ( ! eventAction )
1362 #ifdef CEXMC_USE_PERSISTENCY
1371 cmd =
G4String(
"bzip2 " ) + projectsDir +
"/" + rProject +
1377 cmd =
G4String(
"bzip2 -c " ) + gdmlFileName +
" > " +
1378 projectsDir +
"/" + projectId + gdmlbz2FileExtension;
1385 cmd =
G4String(
"cp " ) + gdmlFileName +
" " + projectsDir +
"/" +
1386 projectId + gdmlFileExtension;
1390 if ( ! cmd.empty() && system( cmd ) != 0 )