From 5856cd842f6ba229f758cc13c56b6db4841a6fe5 Mon Sep 17 00:00:00 2001 From: Oliver Lantwin Date: Tue, 3 Dec 2024 16:18:23 +0100 Subject: [PATCH] Fix #569: Use std::swap instead of TVectorD::Use() --- CHANGELOG.md | 2 +- muonShieldOptimization/makeMuonDIS.py | 10 +++++++--- muonShieldOptimization/muDIS_mergeFiles.py | 8 ++++++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ef8f7be8..d4988c14e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/muonShieldOptimization/makeMuonDIS.py b/muonShieldOptimization/makeMuonDIS.py index 7ecde9c63..7337abfee 100644 --- a/muonShieldOptimization/makeMuonDIS.py +++ b/muonShieldOptimization/makeMuonDIS.py @@ -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) @@ -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() diff --git a/muonShieldOptimization/muDIS_mergeFiles.py b/muonShieldOptimization/muDIS_mergeFiles.py index abedbb4c9..c44372d0d 100644 --- a/muonShieldOptimization/muDIS_mergeFiles.py +++ b/muonShieldOptimization/muDIS_mergeFiles.py @@ -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()