Skip to content

Commit

Permalink
Fix #569: Use std::swap instead of TVectorD::Use()
Browse files Browse the repository at this point in the history
  • Loading branch information
olantwin committed Dec 11, 2024
1 parent 41a895e commit 3437d92
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ it in future.

### Fixed

* Use ConstructedAt instead of remove pythonization for TClonesArray
* Use ConstructedAt + std::swap to replace removed pythonization for TCA
* Octant symmetry was incorrect for B_z when using field maps (reported and fixed by M. Ferro-Luzzi)
* Tof calculation corrected in GenieGenerator.cxx, wrong units previously used.

Expand Down
10 changes: 7 additions & 3 deletions muonShieldOptimization/makeMuonDIS.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,14 @@ def rotate(ctheta,stheta,cphi,sphi,px,py,pz):
ctheta,stheta = ROOT.TMath.Cos(theta),ROOT.TMath.Sin(theta)
cphi,sphi = ROOT.TMath.Cos(phi),ROOT.TMath.Sin(phi)
mu = array('d',[pid,px,py,pz,E,x,y,z,w])
muPart = ROOT.TVectorD(9,mu)
myPythia.Initialize('FIXT',mutype[pid],'p+',p)
for n in range(nMult):
dPart.Clear()
iMuon.Clear()
iMuon.ConstructedAt(0).Use(muPart)
tca_vec = iMuon.ConstructedAt(0)
muPart = ROOT.TVectorD(9, mu)
tca_vec.ResizeTo(muPart)
ROOT.std.swap(tca_vec, muPart)
myPythia.GenerateEvent()
# remove all unnecessary stuff
myPythia.Pyedit(2)
Expand All @@ -99,7 +101,9 @@ def rotate(ctheta,stheta,cphi,sphi,px,py,pz):
# copy to branch
nPart = dPart.GetEntries()
if dPart.GetSize() == nPart: dPart.Expand(nPart+10)
dPart.ConstructedAt(nPart).Use(part)
tca_vec = dPart.ConstructedAt(nPart)
tca_vec.ResizeTo(part)
ROOT.std.swap(tca_vec, part)
nMade+=1
if nMade%10000==0: print('made so far ',nMade)
dTree.Fill()
Expand Down
8 changes: 6 additions & 2 deletions muonShieldOptimization/muDIS_mergeFiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@ def merge():
sTree.GetEvent(n)
dPart.Clear()
iMuon.Clear()
iMuon.ConstructedAt(0).Use(sTree.InMuon[0])
tca_vec = iMuon.ConstructedAt(0)
tca_vec.ResizeTo(sTree.InMuon[0])
ROOT.std.swap(tca_vec, sTree.InMuon[0])
for part in sTree.Particles:
nPart = dPart.GetEntries()
if dPart.GetSize() == nPart: dPart.Expand(nPart+10)
dPart.ConstructedAt(nPart).Use(part)
tca_vec = dPart.ConstructedAt(nPart)
tca_vec.ResizeTo(part)
ROOT.std.swap(tca_vec, part)
dPartBranch.Fill()
iMuonBranch.Fill()
nTree.Fill()
Expand Down

0 comments on commit 3437d92

Please sign in to comment.