Replies: 1 comment 9 replies
-
Everything works for me. I'm on slightly newer versions though.
In [15]: from coffea.nanoevents import NanoEventsFactory
In [16]: events = NanoEventsFactory.from_root({"https://github.com/CoffeaTeam/coffea/raw/master/tests/samples/nano_dy.root": "Events"}).events()
/usr/local/lib/python3.10/site-packages/coffea/nanoevents/methods/candidate.py:11: FutureWarning: In version 2024.7.0 (target date: 2024-06-30 11:59:59-05:00), this will be an error.
To raise these warnings as errors (and get stack traces to find out where they're called), run
import warnings
warnings.filterwarnings("error", module="coffea.*")
after the first `import coffea` or use `@pytest.mark.filterwarnings("error:::coffea.*")` in pytest.
Issue: coffea.nanoevents.methods.vector will be removed and replaced with scikit-hep vector. Nanoevents schemas internal to coffea will be migrated. Otherwise please consider using that package!.
from coffea.nanoevents.methods import vector
/usr/local/lib/python3.10/site-packages/coffea/nanoevents/schemas/nanoaod.py:243: RuntimeWarning: Missing cross-reference index for FatJet_genJetAK8Idx => GenJetAK8
warnings.warn(
In [17]: vector.register_awkward()
...:
...: pVec = ak.zip(
...: {
...: "pt": events.Jet.pt,
...: "eta": events.Jet.eta,
...: "phi": events.Jet.phi,
...: "energy": events.Jet.E
...: },
...: with_name="Momentum4D",
...: )
In [18]: jetDef = fastjet.JetDefinition(fastjet.antikt_algorithm, 0.8)
...: clusters = fastjet.ClusterSequence(pVec, jetDef)
...:
...: wideJets = clusters.inclusive_jets()
...: wideJets.compute()
Out[18]: <MomentumArray4D [[{px: -40.3, py: ..., ...}, ...], ...] type='40 * var * M...'>
In [19]: from coffea.nanoevents.methods import candidate
In [20]: vector.register_awkward()
...:
...: pVec = ak.zip(
...: {
...: "pt": events.Jet.pt,
...: "eta": events.Jet.eta,
...: "phi": events.Jet.phi,
...: "energy": events.Jet.E
...: },
...: with_name="PtEtaPhiECandidate",
...: behavior=candidate.behavior,
...: )
In [21]: jetDef = fastjet.JetDefinition(fastjet.antikt_algorithm, 0.8)
...: clusters = fastjet.ClusterSequence(pVec, jetDef)
...:
...: wideJets = clusters.inclusive_jets()
...: wideJets.compute()
Out[21]: <MomentumArray4D [[{px: -40.3, py: ..., ...}, ...], ...] type='40 * var * M...'>
In [22]: wideJets.pt
Out[22]: dask.awkward<pt, npartitions=1>
In [23]: wideJets.pt.compute()
Out[23]: <Array [[45.6, 59.4, 80.8], [...], ..., [18.3, 18.8]] type='40 * var * float64'> |
Beta Was this translation helpful? Give feedback.
9 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all,
I'm trying to read a custom root tree with NanoEvents (BaseSchema), build a cluster sequence with Fastjet and fill some histograms.
Basically, it boils down to the following pieces of code:
Read the events with
create a vector of particles with
vector
and running the clustering sequence
However, in this last step I get the error
I've tried to change the definition of
pVec
, by usingand , running
wideJets.compute()
returns the expected result!However, trying to do something like
wideJets.pt.compute()
, or simply usingwideJets.pt
to fill ahist
will cause an error similar to the previous one, sayingAm I doing something wrong? I could come up with some workarounds, but my final goal would be to integrate this into a Processor and apply it to a file set. I don't think calling `wideJets.compute()' is the right way, but I might be wrong.
I'm using
Thanks for your help!
Beta Was this translation helpful? Give feedback.
All reactions