Skip to content

Commit 701c7e8

Browse files
authored
Merge pull request #279 from JeffersonLab/develop
Merge develop into master for bugfix version
2 parents 323d1b4 + 292cfda commit 701c7e8

File tree

5 files changed

+29
-45
lines changed

5 files changed

+29
-45
lines changed

include/remollGlobalField.hh

+2-4
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,9 @@ class remollGlobalField : public G4MagneticField {
2727

2828
void AddNewField(G4String& name);
2929

30-
void SetFieldScaleByString(G4String& name_scale);
30+
void SetZOffset(const G4String& name, G4double offset);
3131
void SetFieldScale(const G4String& name, G4double scale);
32-
33-
void SetMagnetCurrentByString(G4String& name_scale);
34-
void SetMagnetCurrent(const G4String& name, G4double scale);
32+
void SetMagnetCurrent(const G4String& name, G4double current);
3533

3634
void PrintFieldValue(const G4ThreeVector&);
3735

macros/runexample.mac

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
/remoll/addfield map_directory/blockyHybrid_rm_3.0.txt
2222
/remoll/addfield map_directory/blockyUpstream_rm_1.1.txt
2323

24-
#/remoll/scalefield map_directory/blockyHybrid_rm_3.0.txt 1.0
25-
#/remoll/magcurrent map_directory/blockyHybrid_rm_3.0.txt 1000.0 A
24+
#/remoll/field/scale map_directory/blockyHybrid_rm_3.0.txt 1.0
25+
#/remoll/field/current map_directory/blockyHybrid_rm_3.0.txt 1000.0
2626

2727
# Raster and initial angle stuff
2828
/remoll/oldras true

src/remollBeamTarget.cc

+7-6
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ void remollBeamTarget::UpdateInfo()
125125
if (!fTargetMother) {
126126
return;
127127
}
128-
fMotherTargetAbsolutePosition = fTargetMother->GetFrameTranslation().z();
128+
fMotherTargetAbsolutePosition = fTargetMother->GetTranslation().z();
129129

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

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

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

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

250250
// Try to cast the target volume into its tubs solid
251251
G4LogicalVolume* volume = (*it)->GetLogicalVolume();
@@ -304,9 +304,10 @@ remollVertex remollBeamTarget::SampleVertex(SampType_t samp)
304304
// For our own info
305305
fTravelledLength = actual_position_in_volume;
306306
fRadiationLength = cumulative_radiation_length;
307-
fVer = G4ThreeVector( rasx, rasy,
308-
actual_position_in_volume - (*it)->GetFrameTranslation().z() + fMotherTargetAbsolutePosition
309-
- tubs->GetZHalfLength() );
307+
fVer = G4ThreeVector( rasx, rasy,
308+
fMotherTargetAbsolutePosition
309+
+ volume_relative_position - tubs->GetZHalfLength()
310+
+ actual_position_in_volume );
310311

311312
G4double masssum = 0.0;
312313
const G4int *atomvec = material->GetAtomsVector();

src/remollGlobalField.cc

+14-32
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ remollGlobalField::remollGlobalField()
6666
// Create generic messenger
6767
fMessenger = new G4GenericMessenger(this,"/remoll/","Remoll properties");
6868
fMessenger->DeclareMethod("addfield",&remollGlobalField::AddNewField,"Add magnetic field");
69-
fMessenger->DeclareMethod("scalefield",&remollGlobalField::SetFieldScaleByString,"Scale magnetic field");
70-
fMessenger->DeclareMethod("magcurrent",&remollGlobalField::SetMagnetCurrentByString,"Scale magnetic field by current");
7169

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

@@ -271,16 +272,16 @@ void remollGlobalField::GetFieldValue(const G4double p[], G4double *resB) const
271272
}
272273
}
273274

274-
void remollGlobalField::SetFieldScaleByString(G4String& name_scale)
275+
void remollGlobalField::SetZOffset(const G4String& name, G4double offset)
275276
{
276-
std::istringstream iss(name_scale);
277-
278-
G4String name, scalestr;
279-
iss >> name;
280-
iss >> scalestr;
281-
282-
G4double scaleval = atof(scalestr);
283-
SetFieldScale(name, scaleval);
277+
remollMagneticField *field = GetFieldByName(name);
278+
if (field) {
279+
G4AutoLock lock(&remollGlobalFieldMutex);
280+
field->SetZoffset(offset);
281+
} else {
282+
G4cerr << "WARNING " << __FILE__ << " line " << __LINE__
283+
<< ": field " << name << " offset failed" << G4endl;
284+
}
284285
}
285286

286287
void remollGlobalField::SetFieldScale(const G4String& name, G4double scale)
@@ -295,31 +296,12 @@ void remollGlobalField::SetFieldScale(const G4String& name, G4double scale)
295296
}
296297
}
297298

298-
void remollGlobalField::SetMagnetCurrentByString(G4String& name_scale)
299-
{
300-
std::istringstream iss(name_scale);
301-
302-
G4String name, scalestr, scaleunit;
303-
iss >> name;
304-
iss >> scalestr;
305-
iss >> scaleunit;
306-
307-
if (scaleunit != "A") {
308-
// FIXME: less snark and more functionality?
309-
G4cerr << __FILE__ << " line " << __LINE__ << ":\n\tGraaaah - just put the current for " << name << " in amps..." << G4endl;
310-
exit(1);
311-
}
312-
313-
G4double scaleval = atof(scalestr);
314-
SetMagnetCurrent(name, scaleval);
315-
}
316-
317-
void remollGlobalField::SetMagnetCurrent(const G4String& name, G4double scale)
299+
void remollGlobalField::SetMagnetCurrent(const G4String& name, G4double current)
318300
{
319301
remollMagneticField *field = GetFieldByName(name);
320302
if (field) {
321303
G4AutoLock lock(&remollGlobalFieldMutex);
322-
field->SetMagnetCurrent(scale);
304+
field->SetMagnetCurrent(current);
323305
} else {
324306
G4cerr << "WARNING " << __FILE__ << " line " << __LINE__
325307
<< ": field " << name << " scaling failed" << G4endl;

src/remollMagneticField.cc

+4-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ remollMagneticField::remollMagneticField( G4String filename ){
3838

3939
fPhi0 = -1e9;
4040

41-
fZoffset = 0.0;
41+
// Default offset for field maps in reference frame with
42+
// the hall pivot at z = 0.
43+
fZoffset = -5087.0;
44+
4245
fInit = false;
4346
fMagCurrent0 = -1e9;
4447

0 commit comments

Comments
 (0)