9.5.2012 Kamil Sedlak
Several smaller improvements, should not have impact on the simulation.
This commit is contained in:
@ -1201,6 +1201,19 @@ G4VPhysicalVolume* musrDetectorConstruction::Construct() {
|
||||
}
|
||||
}
|
||||
|
||||
else if (strcmp(tmpString1,"storeOnlyEventsWithMuonsDecayedInDetID")==0){
|
||||
G4int variable;
|
||||
sscanf(&line[0],"%*s %*s %d",&variable);
|
||||
if (variable!=0){
|
||||
musrParameters::storeOnlyEventsWithMuonsDecayedInDetID = variable;
|
||||
char eMessage[200];
|
||||
sprintf(eMessage,
|
||||
"musrDetectorConstruction.cc:: Only the events, in which muon stop in the detector ID=%d, are stored",
|
||||
variable);
|
||||
musrErrorMessage::GetInstance()->musrError(INFO,eMessage,false);
|
||||
}
|
||||
}
|
||||
|
||||
else if (strcmp(tmpString1,"storeOnlyEventsWithHits")==0){
|
||||
if (strcmp(tmpString2,"false")==0){ musrParameters::storeOnlyEventsWithHits = false; }
|
||||
}
|
||||
@ -1209,6 +1222,11 @@ G4VPhysicalVolume* musrDetectorConstruction::Construct() {
|
||||
if (strcmp(tmpString2,"true")==0){ musrParameters::storeOnlyTheFirstTimeHit = true; }
|
||||
}
|
||||
|
||||
else if (strcmp(tmpString1,"killAllElectrons")==0){
|
||||
if (strcmp(tmpString2,"true")==0){ musrParameters::killAllElectrons = true; }
|
||||
else { musrParameters::killAllElectrons = false; }
|
||||
}
|
||||
|
||||
else if (strcmp(tmpString1,"killAllPositrons")==0){
|
||||
if (strcmp(tmpString2,"true")==0){ musrParameters::killAllPositrons = true; }
|
||||
else { musrParameters::killAllPositrons = false; }
|
||||
@ -1224,6 +1242,22 @@ G4VPhysicalVolume* musrDetectorConstruction::Construct() {
|
||||
else { musrParameters::killAllNeutrinos = false; }
|
||||
}
|
||||
|
||||
else if (strcmp(tmpString1,"maximumTimePerEvent")==0){
|
||||
int variable;
|
||||
sscanf(&line[0],"%*s %*s %d",&variable);
|
||||
if (variable>0){
|
||||
musrParameters::maximumTimePerEvent = variable;
|
||||
}
|
||||
}
|
||||
|
||||
else if (strcmp(tmpString1,"maximumNrOfStepsPerTrack")==0){
|
||||
int variable;
|
||||
sscanf(&line[0],"%*s %*s %d",&variable);
|
||||
if (variable>0){
|
||||
musrParameters::maximumNrOfStepsPerTrack = variable;
|
||||
}
|
||||
}
|
||||
|
||||
else if (strcmp(tmpString1,"getDetectorMass")==0){
|
||||
G4LogicalVolume* massVol = FindLogicalVolume(tmpString2);
|
||||
if (massVol==NULL) {
|
||||
@ -1581,7 +1615,26 @@ void musrDetectorConstruction::DefineMaterials()
|
||||
|
||||
new G4Material("ArgonGas", z= 18., a= 39.95*g/mole, density= 0.00000000001*mg/cm3);
|
||||
|
||||
new G4Material("HeliumGas5mbar",z=2., a=4.002602*g/mole, density= 0.00000088132*g/cm3);
|
||||
new G4Material("HeliumGas5mbar", z=2., a=4.002602*g/mole, density= 0.00000088132*g/cm3);
|
||||
new G4Material("HeliumGas6mbar", z=2., a=4.002602*g/mole, density= 0.000001057584*g/cm3);
|
||||
new G4Material("HeliumGas7mbar", z=2., a=4.002602*g/mole, density= 0.000001233848*g/cm3);
|
||||
new G4Material("HeliumGas8mbar", z=2., a=4.002602*g/mole, density= 0.000001410112*g/cm3);
|
||||
new G4Material("HeliumGas9mbar", z=2., a=4.002602*g/mole, density= 0.000001586376*g/cm3);
|
||||
new G4Material("HeliumGas10mbar",z=2., a=4.002602*g/mole, density= 0.00000176264*g/cm3);
|
||||
new G4Material("HeliumGas11mbar",z=2., a=4.002602*g/mole, density= 0.000001938904*g/cm3);
|
||||
new G4Material("HeliumGas12mbar",z=2., a=4.002602*g/mole, density= 0.000002115168*g/cm3);
|
||||
new G4Material("HeliumGas13mbar",z=2., a=4.002602*g/mole, density= 0.000002291432*g/cm3);
|
||||
new G4Material("HeliumGas14mbar",z=2., a=4.002602*g/mole, density= 0.000002467696*g/cm3);
|
||||
new G4Material("HeliumGas15mbar",z=2., a=4.002602*g/mole, density= 0.00000264396*g/cm3);
|
||||
new G4Material("HeliumGas20mbar",z=2., a=4.002602*g/mole, density= 0.00000352528*g/cm3);
|
||||
new G4Material("HeliumGas30mbar",z=2., a=4.002602*g/mole, density= 0.00000528792*g/cm3);
|
||||
new G4Material("HeliumGas40mbar",z=2., a=4.002602*g/mole, density= 0.00000705056*g/cm3);
|
||||
new G4Material("HeliumGas50mbar",z=2., a=4.002602*g/mole, density= 0.00000881320*g/cm3);
|
||||
new G4Material("HeliumGas60mbar",z=2., a=4.002602*g/mole, density= 0.00001057584*g/cm3);
|
||||
new G4Material("HeliumGas70mbar",z=2., a=4.002602*g/mole, density= 0.00001233848*g/cm3);
|
||||
new G4Material("HeliumGas80mbar",z=2., a=4.002602*g/mole, density= 0.00001410112*g/cm3);
|
||||
new G4Material("HeliumGas90mbar",z=2., a=4.002602*g/mole, density= 0.00001586376*g/cm3);
|
||||
new G4Material("HeliumGas100mbar",z=2.,a=4.002602*g/mole, density= 0.00001762640*g/cm3);
|
||||
|
||||
if (musrParameters::boolG4OpticalPhotons) {
|
||||
|
||||
|
@ -112,7 +112,9 @@ G4bool musrParameters::storeOnlyEventsWithHits=true;
|
||||
G4int musrParameters::storeOnlyEventsWithHitInDetID=0;
|
||||
G4double musrParameters::signalSeparationTime=100*nanosecond;
|
||||
G4bool musrParameters::storeOnlyTheFirstTimeHit=false;
|
||||
G4int musrParameters::storeOnlyEventsWithMuonsDecayedInDetID=0;
|
||||
G4bool musrParameters::field_DecayWithSpin=false;
|
||||
G4bool musrParameters::killAllElectrons=false;
|
||||
G4bool musrParameters::killAllPositrons=false;
|
||||
G4bool musrParameters::killAllGammas=false;
|
||||
G4bool musrParameters::killAllNeutrinos=true;
|
||||
@ -123,3 +125,5 @@ G4bool musrParameters::boolG4OpticalPhotonsUnprocess=false;
|
||||
//G4bool musrParameters::boolG4GeneralParticleSource=true;
|
||||
G4int musrParameters::nrOfEventsToBeGenerated=0;
|
||||
G4bool musrParameters::finiteRiseTimeInScintillator=false;
|
||||
G4int musrParameters::maximumTimePerEvent=60;
|
||||
G4int musrParameters::maximumNrOfStepsPerTrack=100000;
|
||||
|
@ -158,6 +158,7 @@ void musrScintSD::Initialize(G4HCofThisEvent* HCE) {
|
||||
mySignalSeparationTime = musrParameters::signalSeparationTime;
|
||||
myStoreOnlyTheFirstTimeHit= musrParameters::storeOnlyTheFirstTimeHit;
|
||||
myStoreOnlyEventsWithHitInDetID = musrParameters::storeOnlyEventsWithHitInDetID;
|
||||
myStoreOnlyEventsWithMuonsDecayedInDetID = musrParameters::storeOnlyEventsWithMuonsDecayedInDetID;
|
||||
musrSteppingAction* myMusrSteppingAction = musrSteppingAction::GetInstance();
|
||||
boolIsVvvInfoRequested = myMusrSteppingAction->IsVvvInfoRequested();
|
||||
myRootOutput = musrRootOutput::GetRootInstance();
|
||||
@ -342,6 +343,10 @@ void musrScintSD::EndOfEvent(G4HCofThisEvent*) {
|
||||
}
|
||||
}
|
||||
|
||||
if (myStoreOnlyEventsWithMuonsDecayedInDetID) {
|
||||
if ((myRootOutput->GetDecayDetectorID())!=myStoreOnlyEventsWithMuonsDecayedInDetID) return;
|
||||
}
|
||||
|
||||
// Sort out hits and fill them into root
|
||||
if (NbHits>0) {
|
||||
const G4int det_IDmax = musrRootOutput::det_nMax;
|
||||
@ -1074,13 +1079,18 @@ void musrScintSD::EndOfEvent_OptiacalPhotons() {
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void musrScintSD::EndOfRun() {
|
||||
for (mapOfOPSAsumHistograms_Type::const_iterator it = mapOfOPSAsumHistograms.begin(); it!=mapOfOPSAsumHistograms.end(); it++) {
|
||||
(it->second) -> Write();
|
||||
if (musrParameters::boolG4OpticalPhotons) {
|
||||
if (!mapOfOPSAsumHistograms.empty()) {
|
||||
for (mapOfOPSAsumHistograms_Type::const_iterator it = mapOfOPSAsumHistograms.begin(); it!=mapOfOPSAsumHistograms.end(); it++) {
|
||||
(it->second) -> Write();
|
||||
}
|
||||
}
|
||||
if (!mapOfOPSAsum0Histograms.empty()) {
|
||||
for (mapOfOPSAsumHistograms_Type::const_iterator it = mapOfOPSAsum0Histograms.begin(); it!=mapOfOPSAsum0Histograms.end(); it++) {
|
||||
(it->second) -> Write();
|
||||
}
|
||||
}
|
||||
}
|
||||
for (mapOfOPSAsumHistograms_Type::const_iterator it = mapOfOPSAsum0Histograms.begin(); it!=mapOfOPSAsum0Histograms.end(); it++) {
|
||||
(it->second) -> Write();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
@ -89,18 +89,27 @@ void musrSteppingAction::DoAtTheBeginningOfEvent() {
|
||||
void musrSteppingAction::UserSteppingAction(const G4Step* aStep) {
|
||||
|
||||
G4Track* aTrack = aStep->GetTrack();
|
||||
|
||||
// kill the track, if required by user:
|
||||
if (aTrack->GetDefinition()) {
|
||||
G4String p_name = aTrack->GetDynamicParticle()->GetDefinition()->GetParticleName();
|
||||
if ((musrParameters::killAllPositrons)&&(p_name == "e+")) {aTrack->SetTrackStatus(fStopAndKill); return;} // suspend the track
|
||||
else if ((musrParameters::killAllElectrons)&&(p_name == "e-")) {aTrack->SetTrackStatus(fStopAndKill); return;}
|
||||
else if ((musrParameters::killAllGammas)&&(p_name == "gamma")) {aTrack->SetTrackStatus(fStopAndKill); return;}
|
||||
else if ((musrParameters::killAllNeutrinos)&&((p_name == "nu_mu")||(p_name == "anti_nu_mu")
|
||||
||(p_name == "nu_e")||(p_name == "anti_nu_e"))) {aTrack->SetTrackStatus(fStopAndKill); return;}
|
||||
}
|
||||
G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
|
||||
G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
|
||||
G4ThreeVector preStepPosition = preStepPoint->GetPosition();
|
||||
G4ThreeVector postStepPosition = postStepPoint->GetPosition();
|
||||
|
||||
// suspend the track if too many steps has already happened (relevant at high field)
|
||||
if (aTrack->GetCurrentStepNumber()>100000) {
|
||||
musrErrorMessage::GetInstance()->musrError(WARNING,
|
||||
"musrSteppingAction: Current number of steps for the track > 100000 ==> TRACK KILLED",true);
|
||||
// G4double x=aStep->GetPostStepPoint()->GetPosition().x()/mm;
|
||||
// G4double y=aStep->GetPostStepPoint()->GetPosition().y()/mm;
|
||||
// G4double z=aStep->GetPostStepPoint()->GetPosition().z()/mm;
|
||||
if (aTrack->GetCurrentStepNumber()>musrParameters::maximumNrOfStepsPerTrack) {
|
||||
char eMessage[200];
|
||||
sprintf(eMessage,"musrSteppingAction: Current number of steps for the track > %d ==> TRACK KILLED",
|
||||
musrParameters::maximumNrOfStepsPerTrack);
|
||||
musrErrorMessage::GetInstance()->musrError(WARNING,eMessage,true);
|
||||
G4double x = postStepPosition.x()/mm;
|
||||
G4double y = postStepPosition.y()/mm;
|
||||
G4double z = postStepPosition.z()/mm;
|
||||
@ -112,13 +121,14 @@ void musrSteppingAction::UserSteppingAction(const G4Step* aStep) {
|
||||
}
|
||||
|
||||
// abort the event if it takes too long to finish (e.g. more than 60 seconds)
|
||||
if ((time(0) - realTimeWhenThisEventStarted)>60) {
|
||||
if ((time(0) - realTimeWhenThisEventStarted)>musrParameters::maximumTimePerEvent) {
|
||||
G4RunManager* fRunManager = G4RunManager::GetRunManager();
|
||||
G4cout<<"musrSteppingAction: event "<<fRunManager->GetCurrentEvent()->GetEventID()
|
||||
<<" aborted because calculation took already 60 seconds."<<G4endl;
|
||||
musrErrorMessage::GetInstance()->musrError(WARNING,
|
||||
"musrSteppingAction: event aborted because its calculation takes more than 60 seconds.",true);
|
||||
//delete musrRootOutput* myRootOutput = musrRootOutput::GetRootInstance();
|
||||
<<" aborted because calculation took already "<<musrParameters::maximumTimePerEvent<<" seconds."<<G4endl;
|
||||
char eMessage[200];
|
||||
sprintf(eMessage,"musrSteppingAction: event aborted because its calculation takes more than %d seconds.",
|
||||
musrParameters::maximumTimePerEvent);
|
||||
musrErrorMessage::GetInstance()->musrError(WARNING,eMessage,true);
|
||||
myRootOutput->SetEventWeight(0);
|
||||
fRunManager->AbortEvent();
|
||||
}
|
||||
@ -372,11 +382,6 @@ void musrSteppingAction::UserSteppingAction(const G4Step* aStep) {
|
||||
// There is an example how to delete the track in example/novice/N04.
|
||||
// It is done in a different way here, because the example/novice/N04 was not doing
|
||||
// exactly what I wanted.
|
||||
if ( ((musrParameters::killAllPositrons)&&(p_name == "e+")) ||
|
||||
((musrParameters::killAllGammas)&&(p_name == "gamma")) ||
|
||||
((musrParameters::killAllNeutrinos)&&((p_name == "nu_mu")||(p_name == "anti_nu_mu")||(p_name == "nu_e")||(p_name == "anti_nu_e"))) ){
|
||||
aTrack->SetTrackStatus(fStopAndKill); // suspend the track
|
||||
}
|
||||
if((actualVolume(0,10)=="log_shield")||(actualVolume(0,10)=="log_Shield")) {
|
||||
aTrack->SetTrackStatus(fStopAndKill); // suspend the track
|
||||
}
|
||||
|
@ -65,7 +65,8 @@ void musrSteppingVerbose::StepInfo()
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().y(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().z(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetKineticEnergy(),"Energy")
|
||||
<< std::setw(6) << G4BestUnit(fStep->GetTotalEnergyDeposit(),"Energy")
|
||||
// << std::setw(6) << G4BestUnit(fStep->GetTotalEnergyDeposit(),"Energy")
|
||||
<< std::setw(6) << G4BestUnit(fStep->GetDeltaEnergy(),"Energy")
|
||||
<< std::setw(6) << G4BestUnit(fStep->GetStepLength(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetTrackLength(),"Length")
|
||||
<< " ";
|
||||
|
@ -518,17 +518,17 @@ void musrTabulatedElementField::addFieldValue3D(const G4double point[4],
|
||||
//cks The following check is necessary - even though xindex and zindex should never be out of range,
|
||||
// it may happen (due to some rounding error ?). It is better to leave the check here.
|
||||
if ((xindex<0)||(xindex>(nx-2))) {
|
||||
std::cout<<"SERIOUS PROBLEM: xindex out of range! xindex="<<xindex<<" x="<<x<<" xfraction="<<xfraction<<std::endl;
|
||||
std::cout<<"SERIOUS PROBLEM: xindex out of range! xindex="<<xindex<<" x="<<x<<" xfraction="<<xfraction<<" maximumx="<<maximumx<<std::endl;
|
||||
if (xindex<0) xindex=0;
|
||||
else xindex=nx-2;
|
||||
}
|
||||
if ((yindex<0)||(yindex>(ny-2))) {
|
||||
std::cout<<"SERIOUS PROBLEM: yindex out of range! yindex="<<yindex<<" y="<<y<<" yfraction="<<yfraction<<std::endl;
|
||||
std::cout<<"SERIOUS PROBLEM: yindex out of range! yindex="<<yindex<<" y="<<y<<" yfraction="<<yfraction<<" maximumy="<<maximumy<<std::endl;
|
||||
if (yindex<0) yindex=0;
|
||||
else yindex=ny-2;
|
||||
}
|
||||
if ((zindex<0)||(zindex>(nz-2))) {
|
||||
std::cout<<"SERIOUS PROBLEM: zindex out of range! zindex="<<zindex<<" z="<<z<<" zfraction="<<zfraction<<std::endl;
|
||||
std::cout<<"SERIOUS PROBLEM: zindex out of range! zindex="<<zindex<<" z="<<z<<" zfraction="<<zfraction<<" maximumz="<<maximumz<<std::endl;
|
||||
if (zindex<0) zindex=0;
|
||||
else zindex=nz-2;
|
||||
}
|
||||
|
Reference in New Issue
Block a user