jpata / hepaccelerate-cms Goto Github PK
View Code? Open in Web Editor NEWAccelerated HEP analysis on arrays
Accelerated HEP analysis on arrays
Working on enabling JER. Recommendation TWiki, Pisa group presentation.
Needs a fix in coffea: CoffeaTeam/coffea#190.
I was setting up some tests (PR #55) on an unskimmed 2016 sync file and I noticed an issue with the muon FSR correction code on hmumu_utils.py#L1228. You can see the automatic test failing here.
It's not correct to assume that one can use offsets[0:-1]
to index into the underlying data array. In particular, if e.g. the last event has 0 muons, the offsets will be [ ... 181229 181231 181231]
, where the muon data array has length 181231. This did not show up in testing as we apply a skim on the HLT bit, which removes such events. I think that there should be no physics effect from this bug if there is no error, but I'm not 100% sure. In this case, the error arises because we are doing manual offset manipulation. I think offset manipulation would be best left to either:
One can test this with the following script:
import uproot
tt = uproot.open("data/myNanoProdMc2016_NANO.root").get("Events")
mu_pt = tt.array("Muon_pt")
print(mu_pt.content.shape)
print(mu_pt.offsets)
for iev in range(len(mu_pt.offsets) - 1):
imu1 = mu_pt.offsets[iev]
imu2 = mu_pt.offsets[iev+1]
print(f"Event {iev} has {imu2-imu1} muons (offsets {imu1}:{imu2})")
for imu in range(imu1, imu2):
print(imu, mu_pt.content[imu])
mu_pt.content[mu_pt.offsets[0:-1]]
Test file: myNanoProdMc2016_NANO.root
@kondratyevd if you have time next week, could you take a look at this? To me, a CPU-only numba function such as the following:
#Corrects the muon momentum and isolation, if a matched FSR photon with dR<0.4 is found
@numba.njit
def correct_muon_with_fsr(
muons_offsets, fsr_offsets,
muons_pt, muons_eta, muons_phi, muons_mass, muons_iso, muons_fsrIndex
fsr_pt, fsr_eta, fsr_phi, fsr_mass,
out_muons_pt, out_muons_eta, out_muons_phi, out_muons_mass, out_muons_iso
):
for iev in numba.prange(len(muons_offsets) - 1):
#loop over muons in event
mu1 = muons_offsets[iev]
mu2 = muons_offsets[iev + 1]
for imu in range(mu1, mu2):
#relative FSR index in the event
fsr_idx_relative = muons_fsrIndex[imu]
if fsr_idx_relative >= 0:
#absolute index in the full FSR vector for all events
ifsr = fsr_offsets[iev] + fsr_idx_relative
this_mu_pt = muons_pt[imu]
... (and others)
this_fsr_pt = fsr_pt[ifsr]
... (and others)
#compute dR between muon and FSR, check <0.4
#compute and set corrected isolation
#compute and set corrected momentum
would perhaps be easier to follow and debug. What do you think? I'm also open to alternatives...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.