Skip to content

Commit

Permalink
Merge pull request #279 from JeffersonLab/develop
Browse files Browse the repository at this point in the history
Merge develop into master for bugfix version
  • Loading branch information
wdconinc committed Oct 2, 2019
2 parents 323d1b4 + 292cfda commit 701c7e8
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 45 deletions.
6 changes: 2 additions & 4 deletions include/remollGlobalField.hh
Expand Up @@ -27,11 +27,9 @@ class remollGlobalField : public G4MagneticField {

void AddNewField(G4String& name);

void SetFieldScaleByString(G4String& name_scale);
void SetZOffset(const G4String& name, G4double offset);
void SetFieldScale(const G4String& name, G4double scale);

void SetMagnetCurrentByString(G4String& name_scale);
void SetMagnetCurrent(const G4String& name, G4double scale);
void SetMagnetCurrent(const G4String& name, G4double current);

void PrintFieldValue(const G4ThreeVector&);

Expand Down
4 changes: 2 additions & 2 deletions macros/runexample.mac
Expand Up @@ -21,8 +21,8 @@
/remoll/addfield map_directory/blockyHybrid_rm_3.0.txt
/remoll/addfield map_directory/blockyUpstream_rm_1.1.txt

#/remoll/scalefield map_directory/blockyHybrid_rm_3.0.txt 1.0
#/remoll/magcurrent map_directory/blockyHybrid_rm_3.0.txt 1000.0 A
#/remoll/field/scale map_directory/blockyHybrid_rm_3.0.txt 1.0
#/remoll/field/current map_directory/blockyHybrid_rm_3.0.txt 1000.0

# Raster and initial angle stuff
/remoll/oldras true
Expand Down
13 changes: 7 additions & 6 deletions src/remollBeamTarget.cc
Expand Up @@ -125,7 +125,7 @@ void remollBeamTarget::UpdateInfo()
if (!fTargetMother) {
return;
}
fMotherTargetAbsolutePosition = fTargetMother->GetFrameTranslation().z();
fMotherTargetAbsolutePosition = fTargetMother->GetTranslation().z();

for (std::vector<G4VPhysicalVolume *>::iterator
it = fTargetVolumes.begin(); it != fTargetVolumes.end(); it++) {
Expand Down Expand Up @@ -154,7 +154,7 @@ void remollBeamTarget::UpdateInfo()
fActiveTargetEffectiveLength = tubs->GetZHalfLength()*2.0
* material->GetDensity();

fActiveTargetRelativePosition = (*it)->GetFrameTranslation().z();
fActiveTargetRelativePosition = (*it)->GetTranslation().z();

fTotalTargetEffectiveLength += tubs->GetZHalfLength()*2.0
* material->GetDensity();
Expand Down Expand Up @@ -245,7 +245,7 @@ remollVertex remollBeamTarget::SampleVertex(SampType_t samp)
it = fTargetVolumes.begin(); it != fTargetVolumes.end() && !found_active_volume; it++ ){

// Relative position of this target volume in mother volume
//G4double relative_position = (*it)->GetFrameTranslation().z();
G4double volume_relative_position = (*it)->GetTranslation().z();

// Try to cast the target volume into its tubs solid
G4LogicalVolume* volume = (*it)->GetLogicalVolume();
Expand Down Expand Up @@ -304,9 +304,10 @@ remollVertex remollBeamTarget::SampleVertex(SampType_t samp)
// For our own info
fTravelledLength = actual_position_in_volume;
fRadiationLength = cumulative_radiation_length;
fVer = G4ThreeVector( rasx, rasy,
actual_position_in_volume - (*it)->GetFrameTranslation().z() + fMotherTargetAbsolutePosition
- tubs->GetZHalfLength() );
fVer = G4ThreeVector( rasx, rasy,
fMotherTargetAbsolutePosition
+ volume_relative_position - tubs->GetZHalfLength()
+ actual_position_in_volume );

G4double masssum = 0.0;
const G4int *atomvec = material->GetAtomsVector();
Expand Down
46 changes: 14 additions & 32 deletions src/remollGlobalField.cc
Expand Up @@ -66,8 +66,6 @@ remollGlobalField::remollGlobalField()
// Create generic messenger
fMessenger = new G4GenericMessenger(this,"/remoll/","Remoll properties");
fMessenger->DeclareMethod("addfield",&remollGlobalField::AddNewField,"Add magnetic field");
fMessenger->DeclareMethod("scalefield",&remollGlobalField::SetFieldScaleByString,"Scale magnetic field");
fMessenger->DeclareMethod("magcurrent",&remollGlobalField::SetMagnetCurrentByString,"Scale magnetic field by current");

// Create global field messenger
fGlobalFieldMessenger = new G4GenericMessenger(this,"/remoll/field/","Remoll global field properties");
Expand All @@ -80,6 +78,9 @@ remollGlobalField::remollGlobalField()
fGlobalFieldMessenger->DeclareProperty("deltachord",fDeltaChord,"Set delta chord for the chord finder");
fGlobalFieldMessenger->DeclareProperty("deltaonestep",fDeltaOneStep,"Set delta one step for the field manager");
fGlobalFieldMessenger->DeclareProperty("deltaintersection",fMinStep,"Set delta intersection for the field manager");
fGlobalFieldMessenger->DeclareMethod("zoffset",&remollGlobalField::SetZOffset,"Set magnetic field z offset");
fGlobalFieldMessenger->DeclareMethod("scale",&remollGlobalField::SetFieldScale,"Scale magnetic field by factor");
fGlobalFieldMessenger->DeclareMethod("current",&remollGlobalField::SetMagnetCurrent,"Scale magnetic field by current");
fGlobalFieldMessenger->DeclareMethod("value",&remollGlobalField::PrintFieldValue,"Print the field value at a given point (in m)");
}

Expand Down Expand Up @@ -271,16 +272,16 @@ void remollGlobalField::GetFieldValue(const G4double p[], G4double *resB) const
}
}

void remollGlobalField::SetFieldScaleByString(G4String& name_scale)
void remollGlobalField::SetZOffset(const G4String& name, G4double offset)
{
std::istringstream iss(name_scale);

G4String name, scalestr;
iss >> name;
iss >> scalestr;

G4double scaleval = atof(scalestr);
SetFieldScale(name, scaleval);
remollMagneticField *field = GetFieldByName(name);
if (field) {
G4AutoLock lock(&remollGlobalFieldMutex);
field->SetZoffset(offset);
} else {
G4cerr << "WARNING " << __FILE__ << " line " << __LINE__
<< ": field " << name << " offset failed" << G4endl;
}
}

void remollGlobalField::SetFieldScale(const G4String& name, G4double scale)
Expand All @@ -295,31 +296,12 @@ void remollGlobalField::SetFieldScale(const G4String& name, G4double scale)
}
}

void remollGlobalField::SetMagnetCurrentByString(G4String& name_scale)
{
std::istringstream iss(name_scale);

G4String name, scalestr, scaleunit;
iss >> name;
iss >> scalestr;
iss >> scaleunit;

if (scaleunit != "A") {
// FIXME: less snark and more functionality?
G4cerr << __FILE__ << " line " << __LINE__ << ":\n\tGraaaah - just put the current for " << name << " in amps..." << G4endl;
exit(1);
}

G4double scaleval = atof(scalestr);
SetMagnetCurrent(name, scaleval);
}

void remollGlobalField::SetMagnetCurrent(const G4String& name, G4double scale)
void remollGlobalField::SetMagnetCurrent(const G4String& name, G4double current)
{
remollMagneticField *field = GetFieldByName(name);
if (field) {
G4AutoLock lock(&remollGlobalFieldMutex);
field->SetMagnetCurrent(scale);
field->SetMagnetCurrent(current);
} else {
G4cerr << "WARNING " << __FILE__ << " line " << __LINE__
<< ": field " << name << " scaling failed" << G4endl;
Expand Down
5 changes: 4 additions & 1 deletion src/remollMagneticField.cc
Expand Up @@ -38,7 +38,10 @@ remollMagneticField::remollMagneticField( G4String filename ){

fPhi0 = -1e9;

fZoffset = 0.0;
// Default offset for field maps in reference frame with
// the hall pivot at z = 0.
fZoffset = -5087.0;

fInit = false;
fMagCurrent0 = -1e9;

Expand Down

0 comments on commit 701c7e8

Please sign in to comment.