From 895d9dca3af8f5d2f1654e5f2ffe5630c2a972b0 Mon Sep 17 00:00:00 2001 From: Pere Mato Date: Mon, 6 May 2024 21:28:11 +0200 Subject: [PATCH] Added some optimisations (#7) * Better API for selecting reading fields * Preparing new release * Fix for collectionID == -2 --- Project.toml | 2 +- docs/src/release_notes.md | 7 + examples/FCC/Project.toml | 1 + examples/FCC/analysis_MT.jl | 36 ++- examples/LCIO/edm4heo_hrecoil.jl | 42 +++ podio/genStructArrays-rntuple.jl | 429 ------------------------------- podio/genStructArrays-v16.jl | 401 ----------------------------- podio/genStructArrays-v17.jl | 401 ----------------------------- podio/generate.jl | 6 +- src/Components.jl | 5 + src/RootIO.jl | 93 ++++++- 11 files changed, 173 insertions(+), 1250 deletions(-) create mode 100644 examples/LCIO/edm4heo_hrecoil.jl delete mode 100644 podio/genStructArrays-rntuple.jl delete mode 100644 podio/genStructArrays-v16.jl delete mode 100644 podio/genStructArrays-v17.jl diff --git a/Project.toml b/Project.toml index fb7a8da..062dc1c 100644 --- a/Project.toml +++ b/Project.toml @@ -19,11 +19,11 @@ Accessors = "0.1" Corpuscles = "2" FHist = "0.10" Graphs = "1" +PrettyTables = "2" StaticArrays = "1.9" StructArrays = "0.6" UnROOT = "0.10" YAML = "0.4" -PrettyTables = "2" julia = "1" [extras] diff --git a/docs/src/release_notes.md b/docs/src/release_notes.md index a29a983..f7a01f8 100644 --- a/docs/src/release_notes.md +++ b/docs/src/release_notes.md @@ -1,6 +1,13 @@ # Release Notes + +## 0.4.0 +### New Functionality +- Added function `RootIO.create_getter(reader::Reader, bname::String; selection=nothing)` to create a getter function for a specific branch. + The optional argument allows to select leaves to be read. +- The overall performance is highly improved (factor 3 with respect previous version) + ## 0.3.1 ### Bug Fixes - Legacy podio test fixed diff --git a/examples/FCC/Project.toml b/examples/FCC/Project.toml index 20c03e2..c37c710 100644 --- a/examples/FCC/Project.toml +++ b/examples/FCC/Project.toml @@ -1,4 +1,5 @@ [deps] +BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa" DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" EDM4hep = "eb32b910-dde9-4347-8fce-cd6be3498f0c" diff --git a/examples/FCC/analysis_MT.jl b/examples/FCC/analysis_MT.jl index 58996ed..e51b3a5 100644 --- a/examples/FCC/analysis_MT.jl +++ b/examples/FCC/analysis_MT.jl @@ -8,22 +8,25 @@ using DataFrames include("analysis_functions.jl") fnames = """ -events_000189367.root -events_000787350.root -events_001145354.root -events_001680909.root -events_001893485.root -events_002227306.root -events_002498645.root -events_002528960.root -events_002763770.root -events_003579490.root +events_017670037.root +events_020572434.root +events_031357685.root +events_043326581.root +events_063734251.root +events_067932171.root +events_100167569.root +events_115460704.root +events_137485372.root +events_184128869.root +events_192636993.root +events_193400175.root """ -froot = "root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_ZZ_ecm240" +froot = "root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/wzp6_ee_mumuH_ecm240" files = joinpath.(Ref(froot),split(fnames)) #files = "root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_ZZ_ecm240/events_000189367.root" -files = "/Users/mato/cernbox/Data/events_000189367-rntuple-rc2.root" +#files = "/Users/mato/cernbox/Data/events_000189367-rntuple-rc2.root" +#files = "/Users/mato/cernbox/Data/events_017670037.root" reader = RootIO.Reader(files); events = RootIO.get(reader, "events"); @@ -38,13 +41,18 @@ mutable struct MyData <: AbstractAnalysisData MyData() = new(DataFrame(Zcand_m = Float32[], Zcand_recoil_m = Float32[], Zcand_q = Int32[]), 0, 0) end +get_μIDs = RootIO.create_getter(reader, "Muon#0") +get_recps = RootIO.create_getter(reader, "ReconstructedParticles"; selection=[:energy,:momentum,:charge,:mass]) + function myanalysis!(data::MyData, reader, events) for evt in events data.pevts += 1 # count process events - μIDs = RootIO.get(reader, evt, "Muon_objIdx"; register=false) # get the ids of muons + #μIDs = RootIO.get(reader, evt, "Muon#0"; register=false) # get the ids of muons + μIDs = get_μIDs(evt) length(μIDs) < 2 && continue # skip if less than 2 - recps = RootIO.get(reader, evt, "ReconstructedParticles"; register=false) + #recps = RootIO.get(reader, evt, "ReconstructedParticles"; register=false) + recps = get_recps(evt) muons = recps[μIDs] # use the ids to subset the reco particles sel_muons = filter(x -> pₜ(x) > 10GeV, muons) # select the the Pt of muons diff --git a/examples/LCIO/edm4heo_hrecoil.jl b/examples/LCIO/edm4heo_hrecoil.jl new file mode 100644 index 0000000..416308d --- /dev/null +++ b/examples/LCIO/edm4heo_hrecoil.jl @@ -0,0 +1,42 @@ +using EDM4hep +using EDM4hep.RootIO + + +#file = "/Users/gaede/data/rv02-02.sv02-02.mILD_l5_o1_v02.E250-SetA.I402003.Pe2e2h.eL.pR.n000.d_dstm_15089_0.edm4hep_v02-03-02.root" +#file = "/Users/gaede/data/rv02-02.sv02-02.mILD_l5_o1_v02.E250-SetA.I402003.Pe2e2h.eL.pR.n000.d_dstm_15089_0.edm4hep.root" +#file = "/Users/gaede/data/rv02-02.sv02-02.mILD_l5_o1_v02.E250-SetA.I402003.Pe2e2h.eL.pR.n000.d_dstm_15089_0_NEW.edm4hep.root" + +#file = "/Users/mato/Downloads/rv02-02.sv02-02.mILD_l5_o1_v02.E250-SetA.I402003.Pe2e2h.eL.pR.n000.d_dstm_15089_0.edm4hep.root" +#file = "/Users/mato/Downloads/rv02-02.sv02-02.mILD_l5_o1_v02.E250-SetA.I402003.Pe2e2h.eL.pR.n000.d_dstm_15089_0_NEW.edm4hep.root" +file = "/Users/mato/Downloads/rv02-02.sv02-02.mILD_l5_o1_v02.E250-SetA.I402003.Pe2e2h.eL.pR.n000.d_dstm_15089_0.edm4hep_v02-03-02.root" +##file = "/Users/mato/Downloads/rv02-02.sv02-02.mILD_l5_o1_v02.E250_pandorapfo_10evt_edm4hep.root" +reader = RootIO.Reader(file) + +dimuonmass = Float64[] +recoilmass = Float64[] + +mass4v( a ) = sqrt( a[1]^2 - a[2]^2 - a[3]^2 - a[4]^2 ) + + + +events = RootIO.get(reader, "events"); +#for evt in events +# evt +#if 1==1 + evt = events[1]; + pfos = RootIO.get(reader, evt, "PandoraPFOs"); + + muons = [] + for pfo in pfos + + if abs( pfo.type ) == 13 + + # --- save the muon 4-vector (a simple julia vector w/ 4 elements) + push!( muons, [ pfo.energy, pfo.momentum.x, pfo.momentum.y, pfo.momentum.z ] ) + print( pfo.type ) + + end + end +#end + +muons diff --git a/podio/genStructArrays-rntuple.jl b/podio/genStructArrays-rntuple.jl deleted file mode 100644 index cf81239..0000000 --- a/podio/genStructArrays-rntuple.jl +++ /dev/null @@ -1,429 +0,0 @@ -function StructArray{SimTrackerHit}(evt::UnROOT.LazyEvent, branch::Symbol, collid = UInt32(0)) - sa = getproperty(evt, branch) - len = length(sa.cellID) - fcollid = fill(collid,len) - columns = (StructArray{ObjectID{SimTrackerHit}}((collect(0:len-1),fcollid)), - sa.cellID, - sa.EDep, - sa.time, - sa.pathLength, - sa.quality, - StructArray{Vector3d}(StructArrays.components(sa.position)), - StructArray{Vector3f}(StructArrays.components(sa.momentum)), - StructArray{ObjectID{MCParticle}}(StructArrays.components(getproperty(evt, Symbol(:_, branch, :_MCParticle)))), - ) - return StructArray{SimTrackerHit}(columns) -end - -function StructArray{TrackerHitPlane}(evt::UnROOT.LazyEvent, branch::Symbol, collid = UInt32(0)) - sa = getproperty(evt, branch) - len = length(sa.cellID) - fcollid = fill(collid,len) - columns = (StructArray{ObjectID{TrackerHitPlane}}((collect(0:len-1),fcollid)), - sa.cellID, - sa.type, - sa.quality, - sa.time, - sa.eDep, - sa.eDepError, - StructArray{Vector2f}(StructArrays.components(sa.u)), - StructArray{Vector2f}(StructArrays.components(sa.v)), - sa.du, - sa.dv, - StructArray{Vector3d}(StructArrays.components(sa.position)), - sa.covMatrix, - StructArray{PVector{TrackerHitPlane,ObjectID,1}}((sa.rawHits_begin, sa.rawHits_end, fcollid)), - ) - return StructArray{TrackerHitPlane}(columns) -end - -function StructArray{Track}(evt::UnROOT.LazyEvent, branch::Symbol, collid = UInt32(0)) - sa = getproperty(evt, branch) - len = length(sa.type) - fcollid = fill(collid,len) - columns = (StructArray{ObjectID{Track}}((collect(0:len-1),fcollid)), - sa.type, - sa.chi2, - sa.ndf, - sa.dEdx, - sa.dEdxError, - sa.radiusOfInnermostHit, - StructArray{PVector{Track,Int32,1}}((sa.subDetectorHitNumbers_begin, sa.subDetectorHitNumbers_end, fcollid)), - StructArray{PVector{Track,TrackState,2}}((sa.trackStates_begin, sa.trackStates_end, fcollid)), - StructArray{PVector{Track,Quantity,3}}((sa.dxQuantities_begin, sa.dxQuantities_end, fcollid)), - StructArray{Relation{Track,TrackerHit,1}}((sa.trackerHits_begin, sa.trackerHits_end, fcollid)), - StructArray{Relation{Track,Track,2}}((sa.tracks_begin, sa.tracks_end, fcollid)), - ) - return StructArray{Track}(columns) -end - -function StructArray{Vertex}(evt::UnROOT.LazyEvent, branch::Symbol, collid = UInt32(0)) - sa = getproperty(evt, branch) - len = length(sa.primary) - fcollid = fill(collid,len) - columns = (StructArray{ObjectID{Vertex}}((collect(0:len-1),fcollid)), - sa.primary, - sa.chi2, - sa.probability, - StructArray{Vector3f}(StructArrays.components(sa.position)), - sa.covMatrix, - sa.algorithmType, - StructArray{PVector{Vertex,Float32,1}}((sa.parameters_begin, sa.parameters_end, fcollid)), - StructArray{ObjectID{POD}}(StructArrays.components(getproperty(evt, Symbol(:_, branch, :_associatedParticle)))), - ) - return StructArray{Vertex}(columns) -end - -function StructArray{RecIonizationCluster}(evt::UnROOT.LazyEvent, branch::Symbol, collid = UInt32(0)) - sa = getproperty(evt, branch) - len = length(sa.cellID) - fcollid = fill(collid,len) - columns = (StructArray{ObjectID{RecIonizationCluster}}((collect(0:len-1),fcollid)), - sa.cellID, - sa.significance, - sa.type, - StructArray{Relation{RecIonizationCluster,TrackerPulse,1}}((sa.trackerPulse_begin, sa.trackerPulse_end, fcollid)), - ) - return StructArray{RecIonizationCluster}(columns) -end - -function StructArray{RawCalorimeterHit}(evt::UnROOT.LazyEvent, branch::Symbol, collid = UInt32(0)) - sa = getproperty(evt, branch) - len = length(sa.cellID) - fcollid = fill(collid,len) - columns = (StructArray{ObjectID{RawCalorimeterHit}}((collect(0:len-1),fcollid)), - sa.cellID, - sa.amplitude, - sa.timeStamp, - ) - return StructArray{RawCalorimeterHit}(columns) -end - -function StructArray{TrackerHit}(evt::UnROOT.LazyEvent, branch::Symbol, collid = UInt32(0)) - sa = getproperty(evt, branch) - len = length(sa.cellID) - fcollid = fill(collid,len) - columns = (StructArray{ObjectID{TrackerHit}}((collect(0:len-1),fcollid)), - sa.cellID, - sa.type, - sa.quality, - sa.time, - sa.eDep, - sa.eDepError, - StructArray{Vector3d}(StructArrays.components(sa.position)), - sa.covMatrix, - StructArray{PVector{TrackerHit,ObjectID,1}}((sa.rawHits_begin, sa.rawHits_end, fcollid)), - ) - return StructArray{TrackerHit}(columns) -end - -function StructArray{EventHeader}(evt::UnROOT.LazyEvent, branch::Symbol, collid = UInt32(0)) - sa = getproperty(evt, branch) - len = length(sa.eventNumber) - fcollid = fill(collid,len) - columns = (StructArray{ObjectID{EventHeader}}((collect(0:len-1),fcollid)), - sa.eventNumber, - sa.runNumber, - sa.timeStamp, - sa.weight, - ) - return StructArray{EventHeader}(columns) -end - -function StructArray{MCRecoTrackParticleAssociation}(evt::UnROOT.LazyEvent, branch::Symbol, collid = UInt32(0)) - sa = getproperty(evt, branch) - len = length(sa.weight) - fcollid = fill(collid,len) - columns = (StructArray{ObjectID{MCRecoTrackParticleAssociation}}((collect(0:len-1),fcollid)), - sa.weight, - StructArray{ObjectID{Track}}(StructArrays.components(getproperty(evt, Symbol(:_, branch, :_rec)))), - StructArray{ObjectID{MCParticle}}(StructArrays.components(getproperty(evt, Symbol(:_, branch, :_sim)))), - ) - return StructArray{MCRecoTrackParticleAssociation}(columns) -end - -function StructArray{TrackerPulse}(evt::UnROOT.LazyEvent, branch::Symbol, collid = UInt32(0)) - sa = getproperty(evt, branch) - len = length(sa.cellID) - fcollid = fill(collid,len) - columns = (StructArray{ObjectID{TrackerPulse}}((collect(0:len-1),fcollid)), - sa.cellID, - sa.time, - sa.charge, - sa.quality, - sa.covMatrix, - StructArray{ObjectID{TimeSeries}}(StructArrays.components(getproperty(evt, Symbol(:_, branch, :_timeSeries)))), - ) - return StructArray{TrackerPulse}(columns) -end - -function StructArray{MCRecoParticleAssociation}(evt::UnROOT.LazyEvent, branch::Symbol, collid = UInt32(0)) - sa = getproperty(evt, branch) - len = length(sa.weight) - fcollid = fill(collid,len) - columns = (StructArray{ObjectID{MCRecoParticleAssociation}}((collect(0:len-1),fcollid)), - sa.weight, - StructArray{ObjectID{ReconstructedParticle}}(StructArrays.components(getproperty(evt, Symbol(:_, branch, :_rec)))), - StructArray{ObjectID{MCParticle}}(StructArrays.components(getproperty(evt, Symbol(:_, branch, :_sim)))), - ) - return StructArray{MCRecoParticleAssociation}(columns) -end - -function StructArray{MCRecoCaloAssociation}(evt::UnROOT.LazyEvent, branch::Symbol, collid = UInt32(0)) - sa = getproperty(evt, branch) - len = length(sa.weight) - fcollid = fill(collid,len) - columns = (StructArray{ObjectID{MCRecoCaloAssociation}}((collect(0:len-1),fcollid)), - sa.weight, - StructArray{ObjectID{CalorimeterHit}}(StructArrays.components(getproperty(evt, Symbol(:_, branch, :_rec)))), - StructArray{ObjectID{SimCalorimeterHit}}(StructArrays.components(getproperty(evt, Symbol(:_, branch, :_sim)))), - ) - return StructArray{MCRecoCaloAssociation}(columns) -end - -function StructArray{RawTimeSeries}(evt::UnROOT.LazyEvent, branch::Symbol, collid = UInt32(0)) - sa = getproperty(evt, branch) - len = length(sa.cellID) - fcollid = fill(collid,len) - columns = (StructArray{ObjectID{RawTimeSeries}}((collect(0:len-1),fcollid)), - sa.cellID, - sa.quality, - sa.time, - sa.charge, - sa.interval, - StructArray{PVector{RawTimeSeries,Int32,1}}((sa.adcCounts_begin, sa.adcCounts_end, fcollid)), - ) - return StructArray{RawTimeSeries}(columns) -end - -function StructArray{CaloHitContribution}(evt::UnROOT.LazyEvent, branch::Symbol, collid = UInt32(0)) - sa = getproperty(evt, branch) - len = length(sa.PDG) - fcollid = fill(collid,len) - columns = (StructArray{ObjectID{CaloHitContribution}}((collect(0:len-1),fcollid)), - sa.PDG, - sa.energy, - sa.time, - StructArray{Vector3f}(StructArrays.components(sa.stepPosition)), - StructArray{ObjectID{MCParticle}}(StructArrays.components(getproperty(evt, Symbol(:_, branch, :_particle)))), - ) - return StructArray{CaloHitContribution}(columns) -end - -function StructArray{MCRecoTrackerHitPlaneAssociation}(evt::UnROOT.LazyEvent, branch::Symbol, collid = UInt32(0)) - sa = getproperty(evt, branch) - len = length(sa.weight) - fcollid = fill(collid,len) - columns = (StructArray{ObjectID{MCRecoTrackerHitPlaneAssociation}}((collect(0:len-1),fcollid)), - sa.weight, - StructArray{ObjectID{TrackerHitPlane}}(StructArrays.components(getproperty(evt, Symbol(:_, branch, :_rec)))), - StructArray{ObjectID{SimTrackerHit}}(StructArrays.components(getproperty(evt, Symbol(:_, branch, :_sim)))), - ) - return StructArray{MCRecoTrackerHitPlaneAssociation}(columns) -end - -function StructArray{MCRecoCaloParticleAssociation}(evt::UnROOT.LazyEvent, branch::Symbol, collid = UInt32(0)) - sa = getproperty(evt, branch) - len = length(sa.weight) - fcollid = fill(collid,len) - columns = (StructArray{ObjectID{MCRecoCaloParticleAssociation}}((collect(0:len-1),fcollid)), - sa.weight, - StructArray{ObjectID{CalorimeterHit}}(StructArrays.components(getproperty(evt, Symbol(:_, branch, :_rec)))), - StructArray{ObjectID{MCParticle}}(StructArrays.components(getproperty(evt, Symbol(:_, branch, :_sim)))), - ) - return StructArray{MCRecoCaloParticleAssociation}(columns) -end - -function StructArray{MCParticle}(evt::UnROOT.LazyEvent, branch::Symbol, collid = UInt32(0)) - sa = getproperty(evt, branch) - len = length(sa.PDG) - fcollid = fill(collid,len) - columns = (StructArray{ObjectID{MCParticle}}((collect(0:len-1),fcollid)), - sa.PDG, - sa.generatorStatus, - sa.simulatorStatus, - sa.charge, - sa.time, - sa.mass, - StructArray{Vector3d}(StructArrays.components(sa.vertex)), - StructArray{Vector3d}(StructArrays.components(sa.endpoint)), - StructArray{Vector3d}(StructArrays.components(sa.momentum)), - StructArray{Vector3d}(StructArrays.components(sa.momentumAtEndpoint)), - StructArray{Vector3f}(StructArrays.components(sa.spin)), - StructArray{Vector2i}(StructArrays.components(sa.colorFlow)), - StructArray{Relation{MCParticle,MCParticle,1}}((sa.parents_begin, sa.parents_end, fcollid)), - StructArray{Relation{MCParticle,MCParticle,2}}((sa.daughters_begin, sa.daughters_end, fcollid)), - ) - return StructArray{MCParticle}(columns) -end - -function StructArray{ReconstructedParticle}(evt::UnROOT.LazyEvent, branch::Symbol, collid = UInt32(0)) - sa = getproperty(evt, branch) - len = length(sa.type) - fcollid = fill(collid,len) - columns = (StructArray{ObjectID{ReconstructedParticle}}((collect(0:len-1),fcollid)), - sa.type, - sa.energy, - StructArray{Vector3f}(StructArrays.components(sa.momentum)), - StructArray{Vector3f}(StructArrays.components(sa.referencePoint)), - sa.charge, - sa.mass, - sa.goodnessOfPID, - sa.covMatrix, - StructArray{Relation{ReconstructedParticle,Cluster,1}}((sa.clusters_begin, sa.clusters_end, fcollid)), - StructArray{Relation{ReconstructedParticle,Track,2}}((sa.tracks_begin, sa.tracks_end, fcollid)), - StructArray{Relation{ReconstructedParticle,ReconstructedParticle,3}}((sa.particles_begin, sa.particles_end, fcollid)), - StructArray{Relation{ReconstructedParticle,ParticleID,4}}((sa.particleIDs_begin, sa.particleIDs_end, fcollid)), - StructArray{ObjectID{Vertex}}(StructArrays.components(getproperty(evt, Symbol(:_, branch, :_startVertex)))), - StructArray{ObjectID{ParticleID}}(StructArrays.components(getproperty(evt, Symbol(:_, branch, :_particleIDUsed)))), - ) - return StructArray{ReconstructedParticle}(columns) -end - -function StructArray{SimPrimaryIonizationCluster}(evt::UnROOT.LazyEvent, branch::Symbol, collid = UInt32(0)) - sa = getproperty(evt, branch) - len = length(sa.cellID) - fcollid = fill(collid,len) - columns = (StructArray{ObjectID{SimPrimaryIonizationCluster}}((collect(0:len-1),fcollid)), - sa.cellID, - sa.time, - StructArray{Vector3d}(StructArrays.components(sa.position)), - sa.type, - StructArray{PVector{SimPrimaryIonizationCluster,UInt64,1}}((sa.electronCellID_begin, sa.electronCellID_end, fcollid)), - StructArray{PVector{SimPrimaryIonizationCluster,Float32,2}}((sa.electronTime_begin, sa.electronTime_end, fcollid)), - StructArray{PVector{SimPrimaryIonizationCluster,Vector3d,3}}((sa.electronPosition_begin, sa.electronPosition_end, fcollid)), - StructArray{PVector{SimPrimaryIonizationCluster,Float32,4}}((sa.pulseTime_begin, sa.pulseTime_end, fcollid)), - StructArray{PVector{SimPrimaryIonizationCluster,Float32,5}}((sa.pulseAmplitude_begin, sa.pulseAmplitude_end, fcollid)), - StructArray{ObjectID{MCParticle}}(StructArrays.components(getproperty(evt, Symbol(:_, branch, :_MCParticle)))), - ) - return StructArray{SimPrimaryIonizationCluster}(columns) -end - -function StructArray{SimCalorimeterHit}(evt::UnROOT.LazyEvent, branch::Symbol, collid = UInt32(0)) - sa = getproperty(evt, branch) - len = length(sa.cellID) - fcollid = fill(collid,len) - columns = (StructArray{ObjectID{SimCalorimeterHit}}((collect(0:len-1),fcollid)), - sa.cellID, - sa.energy, - StructArray{Vector3f}(StructArrays.components(sa.position)), - StructArray{Relation{SimCalorimeterHit,CaloHitContribution,1}}((sa.contributions_begin, sa.contributions_end, fcollid)), - ) - return StructArray{SimCalorimeterHit}(columns) -end - -function StructArray{Cluster}(evt::UnROOT.LazyEvent, branch::Symbol, collid = UInt32(0)) - sa = getproperty(evt, branch) - len = length(sa.type) - fcollid = fill(collid,len) - columns = (StructArray{ObjectID{Cluster}}((collect(0:len-1),fcollid)), - sa.type, - sa.energy, - sa.energyError, - StructArray{Vector3f}(StructArrays.components(sa.position)), - sa.positionError, - sa.iTheta, - sa.phi, - StructArray{Vector3f}(StructArrays.components(sa.directionError)), - StructArray{PVector{Cluster,Float32,1}}((sa.shapeParameters_begin, sa.shapeParameters_end, fcollid)), - StructArray{PVector{Cluster,Float32,2}}((sa.subdetectorEnergies_begin, sa.subdetectorEnergies_end, fcollid)), - StructArray{Relation{Cluster,Cluster,1}}((sa.clusters_begin, sa.clusters_end, fcollid)), - StructArray{Relation{Cluster,CalorimeterHit,2}}((sa.hits_begin, sa.hits_end, fcollid)), - StructArray{Relation{Cluster,ParticleID,3}}((sa.particleIDs_begin, sa.particleIDs_end, fcollid)), - ) - return StructArray{Cluster}(columns) -end - -function StructArray{RecoParticleVertexAssociation}(evt::UnROOT.LazyEvent, branch::Symbol, collid = UInt32(0)) - sa = getproperty(evt, branch) - len = length(sa.weight) - fcollid = fill(collid,len) - columns = (StructArray{ObjectID{RecoParticleVertexAssociation}}((collect(0:len-1),fcollid)), - sa.weight, - StructArray{ObjectID{ReconstructedParticle}}(StructArrays.components(getproperty(evt, Symbol(:_, branch, :_rec)))), - StructArray{ObjectID{Vertex}}(StructArrays.components(getproperty(evt, Symbol(:_, branch, :_vertex)))), - ) - return StructArray{RecoParticleVertexAssociation}(columns) -end - -function StructArray{RecDqdx}(evt::UnROOT.LazyEvent, branch::Symbol, collid = UInt32(0)) - sa = getproperty(evt, branch) - len = length(sa.dQdx) - fcollid = fill(collid,len) - columns = (StructArray{ObjectID{RecDqdx}}((collect(0:len-1),fcollid)), - sa.dQdx, - sa.particleType, - sa.type, - sa.hypotheses, - StructArray{PVector{RecDqdx,HitLevelData,1}}((sa.hitData_begin, sa.hitData_end, fcollid)), - StructArray{ObjectID{Track}}(StructArrays.components(getproperty(evt, Symbol(:_, branch, :_track)))), - ) - return StructArray{RecDqdx}(columns) -end - -function StructArray{CalorimeterHit}(evt::UnROOT.LazyEvent, branch::Symbol, collid = UInt32(0)) - sa = getproperty(evt, branch) - len = length(sa.cellID) - fcollid = fill(collid,len) - columns = (StructArray{ObjectID{CalorimeterHit}}((collect(0:len-1),fcollid)), - sa.cellID, - sa.energy, - sa.energyError, - sa.time, - StructArray{Vector3f}(StructArrays.components(sa.position)), - sa.type, - ) - return StructArray{CalorimeterHit}(columns) -end - -function StructArray{TimeSeries}(evt::UnROOT.LazyEvent, branch::Symbol, collid = UInt32(0)) - sa = getproperty(evt, branch) - len = length(sa.cellID) - fcollid = fill(collid,len) - columns = (StructArray{ObjectID{TimeSeries}}((collect(0:len-1),fcollid)), - sa.cellID, - sa.time, - sa.interval, - StructArray{PVector{TimeSeries,Float32,1}}((sa.amplitude_begin, sa.amplitude_end, fcollid)), - ) - return StructArray{TimeSeries}(columns) -end - -function StructArray{MCRecoTrackerAssociation}(evt::UnROOT.LazyEvent, branch::Symbol, collid = UInt32(0)) - sa = getproperty(evt, branch) - len = length(sa.weight) - fcollid = fill(collid,len) - columns = (StructArray{ObjectID{MCRecoTrackerAssociation}}((collect(0:len-1),fcollid)), - sa.weight, - StructArray{ObjectID{TrackerHit}}(StructArrays.components(getproperty(evt, Symbol(:_, branch, :_rec)))), - StructArray{ObjectID{SimTrackerHit}}(StructArrays.components(getproperty(evt, Symbol(:_, branch, :_sim)))), - ) - return StructArray{MCRecoTrackerAssociation}(columns) -end - -function StructArray{ParticleID}(evt::UnROOT.LazyEvent, branch::Symbol, collid = UInt32(0)) - sa = getproperty(evt, branch) - len = length(sa.type) - fcollid = fill(collid,len) - columns = (StructArray{ObjectID{ParticleID}}((collect(0:len-1),fcollid)), - sa.type, - sa.PDG, - sa.algorithmType, - sa.likelihood, - StructArray{PVector{ParticleID,Float32,1}}((sa.parameters_begin, sa.parameters_end, fcollid)), - ) - return StructArray{ParticleID}(columns) -end - -function StructArray{MCRecoClusterParticleAssociation}(evt::UnROOT.LazyEvent, branch::Symbol, collid = UInt32(0)) - sa = getproperty(evt, branch) - len = length(sa.weight) - fcollid = fill(collid,len) - columns = (StructArray{ObjectID{MCRecoClusterParticleAssociation}}((collect(0:len-1),fcollid)), - sa.weight, - StructArray{ObjectID{Cluster}}(StructArrays.components(getproperty(evt, Symbol(:_, branch, :_rec)))), - StructArray{ObjectID{MCParticle}}(StructArrays.components(getproperty(evt, Symbol(:_, branch, :_sim)))), - ) - return StructArray{MCRecoClusterParticleAssociation}(columns) -end - diff --git a/podio/genStructArrays-v16.jl b/podio/genStructArrays-v16.jl deleted file mode 100644 index 9856a30..0000000 --- a/podio/genStructArrays-v16.jl +++ /dev/null @@ -1,401 +0,0 @@ -function StructArray{SimTrackerHit, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_cellID)) - len = length(firstmem) - columns = (StructArray{ObjectID{SimTrackerHit}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_EDep)), - getproperty(evt, Symbol(bname, :_time)), - getproperty(evt, Symbol(bname, :_pathLength)), - getproperty(evt, Symbol(bname, :_quality)), - StructArray{Vector3d, Symbol(bname, :_position)}(evt, collid, len), - StructArray{Vector3f, Symbol(bname, :_momentum)}(evt, collid, len), - StructArray{ObjectID{MCParticle}, Symbol(bname, "#0")}(evt, collid, len), - ) - return StructArray{SimTrackerHit}(columns) -end - -function StructArray{TrackerHitPlane, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_cellID)) - len = length(firstmem) - columns = (StructArray{ObjectID{TrackerHitPlane}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_type)), - getproperty(evt, Symbol(bname, :_quality)), - getproperty(evt, Symbol(bname, :_time)), - getproperty(evt, Symbol(bname, :_eDep)), - getproperty(evt, Symbol(bname, :_eDepError)), - StructArray{Vector2f, Symbol(bname, :_u)}(evt, collid, len), - StructArray{Vector2f, Symbol(bname, :_v)}(evt, collid, len), - getproperty(evt, Symbol(bname, :_du)), - getproperty(evt, Symbol(bname, :_dv)), - StructArray{Vector3d, Symbol(bname, :_position)}(evt, collid, len), - StructArray{SVector{6,Float32}}(reshape(getproperty(evt, Symbol(bname, "_covMatrix[6]")), 6, len);dims=1), - StructArray{PVector{TrackerHitPlane,ObjectID,1}, Symbol(bname, :_rawHits)}(evt, collid, len), - ) - return StructArray{TrackerHitPlane}(columns) -end - -function StructArray{Track, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_type)) - len = length(firstmem) - columns = (StructArray{ObjectID{Track}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_chi2)), - getproperty(evt, Symbol(bname, :_ndf)), - getproperty(evt, Symbol(bname, :_dEdx)), - getproperty(evt, Symbol(bname, :_dEdxError)), - getproperty(evt, Symbol(bname, :_radiusOfInnermostHit)), - StructArray{PVector{Track,Int32,1}, Symbol(bname, :_subDetectorHitNumbers)}(evt, collid, len), - StructArray{PVector{Track,TrackState,2}, Symbol(bname, :_trackStates)}(evt, collid, len), - StructArray{PVector{Track,Quantity,3}, Symbol(bname, :_dxQuantities)}(evt, collid, len), - StructArray{Relation{Track,TrackerHit,1}, Symbol(bname, :_trackerHits)}(evt, collid, len), - StructArray{Relation{Track,Track,2}, Symbol(bname, :_tracks)}(evt, collid, len), - ) - return StructArray{Track}(columns) -end - -function StructArray{Vertex, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_primary)) - len = length(firstmem) - columns = (StructArray{ObjectID{Vertex}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_chi2)), - getproperty(evt, Symbol(bname, :_probability)), - StructArray{Vector3f, Symbol(bname, :_position)}(evt, collid, len), - StructArray{SVector{6,Float32}}(reshape(getproperty(evt, Symbol(bname, "_covMatrix[6]")), 6, len);dims=1), - getproperty(evt, Symbol(bname, :_algorithmType)), - StructArray{PVector{Vertex,Float32,1}, Symbol(bname, :_parameters)}(evt, collid, len), - StructArray{ObjectID{POD}, Symbol(bname, "#0")}(evt, collid, len), - ) - return StructArray{Vertex}(columns) -end - -function StructArray{RecIonizationCluster, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_cellID)) - len = length(firstmem) - columns = (StructArray{ObjectID{RecIonizationCluster}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_significance)), - getproperty(evt, Symbol(bname, :_type)), - StructArray{Relation{RecIonizationCluster,TrackerPulse,1}, Symbol(bname, :_trackerPulse)}(evt, collid, len), - ) - return StructArray{RecIonizationCluster}(columns) -end - -function StructArray{RawCalorimeterHit, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_cellID)) - len = length(firstmem) - columns = (StructArray{ObjectID{RawCalorimeterHit}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_amplitude)), - getproperty(evt, Symbol(bname, :_timeStamp)), - ) - return StructArray{RawCalorimeterHit}(columns) -end - -function StructArray{TrackerHit, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_cellID)) - len = length(firstmem) - columns = (StructArray{ObjectID{TrackerHit}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_type)), - getproperty(evt, Symbol(bname, :_quality)), - getproperty(evt, Symbol(bname, :_time)), - getproperty(evt, Symbol(bname, :_eDep)), - getproperty(evt, Symbol(bname, :_eDepError)), - StructArray{Vector3d, Symbol(bname, :_position)}(evt, collid, len), - StructArray{SVector{6,Float32}}(reshape(getproperty(evt, Symbol(bname, "_covMatrix[6]")), 6, len);dims=1), - StructArray{PVector{TrackerHit,ObjectID,1}, Symbol(bname, :_rawHits)}(evt, collid, len), - ) - return StructArray{TrackerHit}(columns) -end - -function StructArray{EventHeader, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_eventNumber)) - len = length(firstmem) - columns = (StructArray{ObjectID{EventHeader}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_runNumber)), - getproperty(evt, Symbol(bname, :_timeStamp)), - getproperty(evt, Symbol(bname, :_weight)), - ) - return StructArray{EventHeader}(columns) -end - -function StructArray{MCRecoTrackParticleAssociation, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_weight)) - len = length(firstmem) - columns = (StructArray{ObjectID{MCRecoTrackParticleAssociation}}((collect(0:len-1),fill(collid,len))), - firstmem, - StructArray{ObjectID{Track}, Symbol(bname, "#0")}(evt, collid, len), - StructArray{ObjectID{MCParticle}, Symbol(bname, "#1")}(evt, collid, len), - ) - return StructArray{MCRecoTrackParticleAssociation}(columns) -end - -function StructArray{TrackerPulse, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_cellID)) - len = length(firstmem) - columns = (StructArray{ObjectID{TrackerPulse}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_time)), - getproperty(evt, Symbol(bname, :_charge)), - getproperty(evt, Symbol(bname, :_quality)), - StructArray{SVector{3,Float32}}(reshape(getproperty(evt, Symbol(bname, "_covMatrix[3]")), 3, len);dims=1), - StructArray{ObjectID{TimeSeries}, Symbol(bname, "#0")}(evt, collid, len), - ) - return StructArray{TrackerPulse}(columns) -end - -function StructArray{MCRecoParticleAssociation, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_weight)) - len = length(firstmem) - columns = (StructArray{ObjectID{MCRecoParticleAssociation}}((collect(0:len-1),fill(collid,len))), - firstmem, - StructArray{ObjectID{ReconstructedParticle}, Symbol(bname, "#0")}(evt, collid, len), - StructArray{ObjectID{MCParticle}, Symbol(bname, "#1")}(evt, collid, len), - ) - return StructArray{MCRecoParticleAssociation}(columns) -end - -function StructArray{MCRecoCaloAssociation, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_weight)) - len = length(firstmem) - columns = (StructArray{ObjectID{MCRecoCaloAssociation}}((collect(0:len-1),fill(collid,len))), - firstmem, - StructArray{ObjectID{CalorimeterHit}, Symbol(bname, "#0")}(evt, collid, len), - StructArray{ObjectID{SimCalorimeterHit}, Symbol(bname, "#1")}(evt, collid, len), - ) - return StructArray{MCRecoCaloAssociation}(columns) -end - -function StructArray{RawTimeSeries, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_cellID)) - len = length(firstmem) - columns = (StructArray{ObjectID{RawTimeSeries}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_quality)), - getproperty(evt, Symbol(bname, :_time)), - getproperty(evt, Symbol(bname, :_charge)), - getproperty(evt, Symbol(bname, :_interval)), - StructArray{PVector{RawTimeSeries,Int32,1}, Symbol(bname, :_adcCounts)}(evt, collid, len), - ) - return StructArray{RawTimeSeries}(columns) -end - -function StructArray{CaloHitContribution, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_PDG)) - len = length(firstmem) - columns = (StructArray{ObjectID{CaloHitContribution}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_energy)), - getproperty(evt, Symbol(bname, :_time)), - StructArray{Vector3f, Symbol(bname, :_stepPosition)}(evt, collid, len), - StructArray{ObjectID{MCParticle}, Symbol(bname, "#0")}(evt, collid, len), - ) - return StructArray{CaloHitContribution}(columns) -end - -function StructArray{MCRecoTrackerHitPlaneAssociation, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_weight)) - len = length(firstmem) - columns = (StructArray{ObjectID{MCRecoTrackerHitPlaneAssociation}}((collect(0:len-1),fill(collid,len))), - firstmem, - StructArray{ObjectID{TrackerHitPlane}, Symbol(bname, "#0")}(evt, collid, len), - StructArray{ObjectID{SimTrackerHit}, Symbol(bname, "#1")}(evt, collid, len), - ) - return StructArray{MCRecoTrackerHitPlaneAssociation}(columns) -end - -function StructArray{MCRecoCaloParticleAssociation, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_weight)) - len = length(firstmem) - columns = (StructArray{ObjectID{MCRecoCaloParticleAssociation}}((collect(0:len-1),fill(collid,len))), - firstmem, - StructArray{ObjectID{CalorimeterHit}, Symbol(bname, "#0")}(evt, collid, len), - StructArray{ObjectID{MCParticle}, Symbol(bname, "#1")}(evt, collid, len), - ) - return StructArray{MCRecoCaloParticleAssociation}(columns) -end - -function StructArray{MCParticle, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_PDG)) - len = length(firstmem) - columns = (StructArray{ObjectID{MCParticle}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_generatorStatus)), - getproperty(evt, Symbol(bname, :_simulatorStatus)), - getproperty(evt, Symbol(bname, :_charge)), - getproperty(evt, Symbol(bname, :_time)), - getproperty(evt, Symbol(bname, :_mass)), - StructArray{Vector3d, Symbol(bname, :_vertex)}(evt, collid, len), - StructArray{Vector3d, Symbol(bname, :_endpoint)}(evt, collid, len), - StructArray{Vector3d, Symbol(bname, :_momentum)}(evt, collid, len), - StructArray{Vector3d, Symbol(bname, :_momentumAtEndpoint)}(evt, collid, len), - StructArray{Vector3f, Symbol(bname, :_spin)}(evt, collid, len), - StructArray{Vector2i, Symbol(bname, :_colorFlow)}(evt, collid, len), - StructArray{Relation{MCParticle,MCParticle,1}, Symbol(bname, :_parents)}(evt, collid, len), - StructArray{Relation{MCParticle,MCParticle,2}, Symbol(bname, :_daughters)}(evt, collid, len), - ) - return StructArray{MCParticle}(columns) -end - -function StructArray{ReconstructedParticle, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_type)) - len = length(firstmem) - columns = (StructArray{ObjectID{ReconstructedParticle}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_energy)), - StructArray{Vector3f, Symbol(bname, :_momentum)}(evt, collid, len), - StructArray{Vector3f, Symbol(bname, :_referencePoint)}(evt, collid, len), - getproperty(evt, Symbol(bname, :_charge)), - getproperty(evt, Symbol(bname, :_mass)), - getproperty(evt, Symbol(bname, :_goodnessOfPID)), - StructArray{SVector{10,Float32}}(reshape(getproperty(evt, Symbol(bname, "_covMatrix[10]")), 10, len);dims=1), - StructArray{Relation{ReconstructedParticle,Cluster,1}, Symbol(bname, :_clusters)}(evt, collid, len), - StructArray{Relation{ReconstructedParticle,Track,2}, Symbol(bname, :_tracks)}(evt, collid, len), - StructArray{Relation{ReconstructedParticle,ReconstructedParticle,3}, Symbol(bname, :_particles)}(evt, collid, len), - StructArray{Relation{ReconstructedParticle,ParticleID,4}, Symbol(bname, :_particleIDs)}(evt, collid, len), - StructArray{ObjectID{Vertex}, Symbol(bname, "#4")}(evt, collid, len), - StructArray{ObjectID{ParticleID}, Symbol(bname, "#5")}(evt, collid, len), - ) - return StructArray{ReconstructedParticle}(columns) -end - -function StructArray{SimPrimaryIonizationCluster, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_cellID)) - len = length(firstmem) - columns = (StructArray{ObjectID{SimPrimaryIonizationCluster}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_time)), - StructArray{Vector3d, Symbol(bname, :_position)}(evt, collid, len), - getproperty(evt, Symbol(bname, :_type)), - StructArray{PVector{SimPrimaryIonizationCluster,UInt64,1}, Symbol(bname, :_electronCellID)}(evt, collid, len), - StructArray{PVector{SimPrimaryIonizationCluster,Float32,2}, Symbol(bname, :_electronTime)}(evt, collid, len), - StructArray{PVector{SimPrimaryIonizationCluster,Vector3d,3}, Symbol(bname, :_electronPosition)}(evt, collid, len), - StructArray{PVector{SimPrimaryIonizationCluster,Float32,4}, Symbol(bname, :_pulseTime)}(evt, collid, len), - StructArray{PVector{SimPrimaryIonizationCluster,Float32,5}, Symbol(bname, :_pulseAmplitude)}(evt, collid, len), - StructArray{ObjectID{MCParticle}, Symbol(bname, "#0")}(evt, collid, len), - ) - return StructArray{SimPrimaryIonizationCluster}(columns) -end - -function StructArray{SimCalorimeterHit, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_cellID)) - len = length(firstmem) - columns = (StructArray{ObjectID{SimCalorimeterHit}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_energy)), - StructArray{Vector3f, Symbol(bname, :_position)}(evt, collid, len), - StructArray{Relation{SimCalorimeterHit,CaloHitContribution,1}, Symbol(bname, :_contributions)}(evt, collid, len), - ) - return StructArray{SimCalorimeterHit}(columns) -end - -function StructArray{Cluster, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_type)) - len = length(firstmem) - columns = (StructArray{ObjectID{Cluster}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_energy)), - getproperty(evt, Symbol(bname, :_energyError)), - StructArray{Vector3f, Symbol(bname, :_position)}(evt, collid, len), - StructArray{SVector{6,Float32}}(reshape(getproperty(evt, Symbol(bname, "_positionError[6]")), 6, len);dims=1), - getproperty(evt, Symbol(bname, :_iTheta)), - getproperty(evt, Symbol(bname, :_phi)), - StructArray{Vector3f, Symbol(bname, :_directionError)}(evt, collid, len), - StructArray{PVector{Cluster,Float32,1}, Symbol(bname, :_shapeParameters)}(evt, collid, len), - StructArray{PVector{Cluster,Float32,2}, Symbol(bname, :_subdetectorEnergies)}(evt, collid, len), - StructArray{Relation{Cluster,Cluster,1}, Symbol(bname, :_clusters)}(evt, collid, len), - StructArray{Relation{Cluster,CalorimeterHit,2}, Symbol(bname, :_hits)}(evt, collid, len), - StructArray{Relation{Cluster,ParticleID,3}, Symbol(bname, :_particleIDs)}(evt, collid, len), - ) - return StructArray{Cluster}(columns) -end - -function StructArray{RecoParticleVertexAssociation, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_weight)) - len = length(firstmem) - columns = (StructArray{ObjectID{RecoParticleVertexAssociation}}((collect(0:len-1),fill(collid,len))), - firstmem, - StructArray{ObjectID{ReconstructedParticle}, Symbol(bname, "#0")}(evt, collid, len), - StructArray{ObjectID{Vertex}, Symbol(bname, "#1")}(evt, collid, len), - ) - return StructArray{RecoParticleVertexAssociation}(columns) -end - -function StructArray{RecDqdx, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_dQdx)) - len = length(firstmem) - columns = (StructArray{ObjectID{RecDqdx}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_particleType)), - getproperty(evt, Symbol(bname, :_type)), - StructArray{SVector{5,Hypothesis}}(reshape(getproperty(evt, Symbol(bname, "_hypotheses[5]")), 5, len);dims=1), - StructArray{PVector{RecDqdx,HitLevelData,1}, Symbol(bname, :_hitData)}(evt, collid, len), - StructArray{ObjectID{Track}, Symbol(bname, "#0")}(evt, collid, len), - ) - return StructArray{RecDqdx}(columns) -end - -function StructArray{CalorimeterHit, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_cellID)) - len = length(firstmem) - columns = (StructArray{ObjectID{CalorimeterHit}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_energy)), - getproperty(evt, Symbol(bname, :_energyError)), - getproperty(evt, Symbol(bname, :_time)), - StructArray{Vector3f, Symbol(bname, :_position)}(evt, collid, len), - getproperty(evt, Symbol(bname, :_type)), - ) - return StructArray{CalorimeterHit}(columns) -end - -function StructArray{TimeSeries, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_cellID)) - len = length(firstmem) - columns = (StructArray{ObjectID{TimeSeries}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_time)), - getproperty(evt, Symbol(bname, :_interval)), - StructArray{PVector{TimeSeries,Float32,1}, Symbol(bname, :_amplitude)}(evt, collid, len), - ) - return StructArray{TimeSeries}(columns) -end - -function StructArray{MCRecoTrackerAssociation, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_weight)) - len = length(firstmem) - columns = (StructArray{ObjectID{MCRecoTrackerAssociation}}((collect(0:len-1),fill(collid,len))), - firstmem, - StructArray{ObjectID{TrackerHit}, Symbol(bname, "#0")}(evt, collid, len), - StructArray{ObjectID{SimTrackerHit}, Symbol(bname, "#1")}(evt, collid, len), - ) - return StructArray{MCRecoTrackerAssociation}(columns) -end - -function StructArray{ParticleID, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_type)) - len = length(firstmem) - columns = (StructArray{ObjectID{ParticleID}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_PDG)), - getproperty(evt, Symbol(bname, :_algorithmType)), - getproperty(evt, Symbol(bname, :_likelihood)), - StructArray{PVector{ParticleID,Float32,1}, Symbol(bname, :_parameters)}(evt, collid, len), - ) - return StructArray{ParticleID}(columns) -end - -function StructArray{MCRecoClusterParticleAssociation, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_weight)) - len = length(firstmem) - columns = (StructArray{ObjectID{MCRecoClusterParticleAssociation}}((collect(0:len-1),fill(collid,len))), - firstmem, - StructArray{ObjectID{Cluster}, Symbol(bname, "#0")}(evt, collid, len), - StructArray{ObjectID{MCParticle}, Symbol(bname, "#1")}(evt, collid, len), - ) - return StructArray{MCRecoClusterParticleAssociation}(columns) -end - diff --git a/podio/genStructArrays-v17.jl b/podio/genStructArrays-v17.jl deleted file mode 100644 index 3ac9e90..0000000 --- a/podio/genStructArrays-v17.jl +++ /dev/null @@ -1,401 +0,0 @@ -function StructArray{SimTrackerHit, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_cellID)) - len = length(firstmem) - columns = (StructArray{ObjectID{SimTrackerHit}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_EDep)), - getproperty(evt, Symbol(bname, :_time)), - getproperty(evt, Symbol(bname, :_pathLength)), - getproperty(evt, Symbol(bname, :_quality)), - StructArray{Vector3d, Symbol(bname, :_position)}(evt, collid, len), - StructArray{Vector3f, Symbol(bname, :_momentum)}(evt, collid, len), - StructArray{ObjectID{MCParticle}, Symbol(:_, bname, "_MCParticle")}(evt, collid, len), - ) - return StructArray{SimTrackerHit}(columns) -end - -function StructArray{TrackerHitPlane, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_cellID)) - len = length(firstmem) - columns = (StructArray{ObjectID{TrackerHitPlane}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_type)), - getproperty(evt, Symbol(bname, :_quality)), - getproperty(evt, Symbol(bname, :_time)), - getproperty(evt, Symbol(bname, :_eDep)), - getproperty(evt, Symbol(bname, :_eDepError)), - StructArray{Vector2f, Symbol(bname, :_u)}(evt, collid, len), - StructArray{Vector2f, Symbol(bname, :_v)}(evt, collid, len), - getproperty(evt, Symbol(bname, :_du)), - getproperty(evt, Symbol(bname, :_dv)), - StructArray{Vector3d, Symbol(bname, :_position)}(evt, collid, len), - StructArray{SVector{6,Float32}}(reshape(getproperty(evt, Symbol(bname, "_covMatrix[6]")), 6, len);dims=1), - StructArray{PVector{TrackerHitPlane,ObjectID,1}, Symbol(bname, :_rawHits)}(evt, collid, len), - ) - return StructArray{TrackerHitPlane}(columns) -end - -function StructArray{Track, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_type)) - len = length(firstmem) - columns = (StructArray{ObjectID{Track}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_chi2)), - getproperty(evt, Symbol(bname, :_ndf)), - getproperty(evt, Symbol(bname, :_dEdx)), - getproperty(evt, Symbol(bname, :_dEdxError)), - getproperty(evt, Symbol(bname, :_radiusOfInnermostHit)), - StructArray{PVector{Track,Int32,1}, Symbol(bname, :_subDetectorHitNumbers)}(evt, collid, len), - StructArray{PVector{Track,TrackState,2}, Symbol(bname, :_trackStates)}(evt, collid, len), - StructArray{PVector{Track,Quantity,3}, Symbol(bname, :_dxQuantities)}(evt, collid, len), - StructArray{Relation{Track,TrackerHit,1}, Symbol(bname, :_trackerHits)}(evt, collid, len), - StructArray{Relation{Track,Track,2}, Symbol(bname, :_tracks)}(evt, collid, len), - ) - return StructArray{Track}(columns) -end - -function StructArray{Vertex, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_primary)) - len = length(firstmem) - columns = (StructArray{ObjectID{Vertex}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_chi2)), - getproperty(evt, Symbol(bname, :_probability)), - StructArray{Vector3f, Symbol(bname, :_position)}(evt, collid, len), - StructArray{SVector{6,Float32}}(reshape(getproperty(evt, Symbol(bname, "_covMatrix[6]")), 6, len);dims=1), - getproperty(evt, Symbol(bname, :_algorithmType)), - StructArray{PVector{Vertex,Float32,1}, Symbol(bname, :_parameters)}(evt, collid, len), - StructArray{ObjectID{POD}, Symbol(:_, bname, "_associatedParticle")}(evt, collid, len), - ) - return StructArray{Vertex}(columns) -end - -function StructArray{RecIonizationCluster, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_cellID)) - len = length(firstmem) - columns = (StructArray{ObjectID{RecIonizationCluster}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_significance)), - getproperty(evt, Symbol(bname, :_type)), - StructArray{Relation{RecIonizationCluster,TrackerPulse,1}, Symbol(bname, :_trackerPulse)}(evt, collid, len), - ) - return StructArray{RecIonizationCluster}(columns) -end - -function StructArray{RawCalorimeterHit, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_cellID)) - len = length(firstmem) - columns = (StructArray{ObjectID{RawCalorimeterHit}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_amplitude)), - getproperty(evt, Symbol(bname, :_timeStamp)), - ) - return StructArray{RawCalorimeterHit}(columns) -end - -function StructArray{TrackerHit, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_cellID)) - len = length(firstmem) - columns = (StructArray{ObjectID{TrackerHit}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_type)), - getproperty(evt, Symbol(bname, :_quality)), - getproperty(evt, Symbol(bname, :_time)), - getproperty(evt, Symbol(bname, :_eDep)), - getproperty(evt, Symbol(bname, :_eDepError)), - StructArray{Vector3d, Symbol(bname, :_position)}(evt, collid, len), - StructArray{SVector{6,Float32}}(reshape(getproperty(evt, Symbol(bname, "_covMatrix[6]")), 6, len);dims=1), - StructArray{PVector{TrackerHit,ObjectID,1}, Symbol(bname, :_rawHits)}(evt, collid, len), - ) - return StructArray{TrackerHit}(columns) -end - -function StructArray{EventHeader, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_eventNumber)) - len = length(firstmem) - columns = (StructArray{ObjectID{EventHeader}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_runNumber)), - getproperty(evt, Symbol(bname, :_timeStamp)), - getproperty(evt, Symbol(bname, :_weight)), - ) - return StructArray{EventHeader}(columns) -end - -function StructArray{MCRecoTrackParticleAssociation, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_weight)) - len = length(firstmem) - columns = (StructArray{ObjectID{MCRecoTrackParticleAssociation}}((collect(0:len-1),fill(collid,len))), - firstmem, - StructArray{ObjectID{Track}, Symbol(:_, bname, "_rec")}(evt, collid, len), - StructArray{ObjectID{MCParticle}, Symbol(:_, bname, "_sim")}(evt, collid, len), - ) - return StructArray{MCRecoTrackParticleAssociation}(columns) -end - -function StructArray{TrackerPulse, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_cellID)) - len = length(firstmem) - columns = (StructArray{ObjectID{TrackerPulse}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_time)), - getproperty(evt, Symbol(bname, :_charge)), - getproperty(evt, Symbol(bname, :_quality)), - StructArray{SVector{3,Float32}}(reshape(getproperty(evt, Symbol(bname, "_covMatrix[3]")), 3, len);dims=1), - StructArray{ObjectID{TimeSeries}, Symbol(:_, bname, "_timeSeries")}(evt, collid, len), - ) - return StructArray{TrackerPulse}(columns) -end - -function StructArray{MCRecoParticleAssociation, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_weight)) - len = length(firstmem) - columns = (StructArray{ObjectID{MCRecoParticleAssociation}}((collect(0:len-1),fill(collid,len))), - firstmem, - StructArray{ObjectID{ReconstructedParticle}, Symbol(:_, bname, "_rec")}(evt, collid, len), - StructArray{ObjectID{MCParticle}, Symbol(:_, bname, "_sim")}(evt, collid, len), - ) - return StructArray{MCRecoParticleAssociation}(columns) -end - -function StructArray{MCRecoCaloAssociation, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_weight)) - len = length(firstmem) - columns = (StructArray{ObjectID{MCRecoCaloAssociation}}((collect(0:len-1),fill(collid,len))), - firstmem, - StructArray{ObjectID{CalorimeterHit}, Symbol(:_, bname, "_rec")}(evt, collid, len), - StructArray{ObjectID{SimCalorimeterHit}, Symbol(:_, bname, "_sim")}(evt, collid, len), - ) - return StructArray{MCRecoCaloAssociation}(columns) -end - -function StructArray{RawTimeSeries, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_cellID)) - len = length(firstmem) - columns = (StructArray{ObjectID{RawTimeSeries}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_quality)), - getproperty(evt, Symbol(bname, :_time)), - getproperty(evt, Symbol(bname, :_charge)), - getproperty(evt, Symbol(bname, :_interval)), - StructArray{PVector{RawTimeSeries,Int32,1}, Symbol(bname, :_adcCounts)}(evt, collid, len), - ) - return StructArray{RawTimeSeries}(columns) -end - -function StructArray{CaloHitContribution, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_PDG)) - len = length(firstmem) - columns = (StructArray{ObjectID{CaloHitContribution}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_energy)), - getproperty(evt, Symbol(bname, :_time)), - StructArray{Vector3f, Symbol(bname, :_stepPosition)}(evt, collid, len), - StructArray{ObjectID{MCParticle}, Symbol(:_, bname, "_particle")}(evt, collid, len), - ) - return StructArray{CaloHitContribution}(columns) -end - -function StructArray{MCRecoTrackerHitPlaneAssociation, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_weight)) - len = length(firstmem) - columns = (StructArray{ObjectID{MCRecoTrackerHitPlaneAssociation}}((collect(0:len-1),fill(collid,len))), - firstmem, - StructArray{ObjectID{TrackerHitPlane}, Symbol(:_, bname, "_rec")}(evt, collid, len), - StructArray{ObjectID{SimTrackerHit}, Symbol(:_, bname, "_sim")}(evt, collid, len), - ) - return StructArray{MCRecoTrackerHitPlaneAssociation}(columns) -end - -function StructArray{MCRecoCaloParticleAssociation, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_weight)) - len = length(firstmem) - columns = (StructArray{ObjectID{MCRecoCaloParticleAssociation}}((collect(0:len-1),fill(collid,len))), - firstmem, - StructArray{ObjectID{CalorimeterHit}, Symbol(:_, bname, "_rec")}(evt, collid, len), - StructArray{ObjectID{MCParticle}, Symbol(:_, bname, "_sim")}(evt, collid, len), - ) - return StructArray{MCRecoCaloParticleAssociation}(columns) -end - -function StructArray{MCParticle, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_PDG)) - len = length(firstmem) - columns = (StructArray{ObjectID{MCParticle}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_generatorStatus)), - getproperty(evt, Symbol(bname, :_simulatorStatus)), - getproperty(evt, Symbol(bname, :_charge)), - getproperty(evt, Symbol(bname, :_time)), - getproperty(evt, Symbol(bname, :_mass)), - StructArray{Vector3d, Symbol(bname, :_vertex)}(evt, collid, len), - StructArray{Vector3d, Symbol(bname, :_endpoint)}(evt, collid, len), - StructArray{Vector3d, Symbol(bname, :_momentum)}(evt, collid, len), - StructArray{Vector3d, Symbol(bname, :_momentumAtEndpoint)}(evt, collid, len), - StructArray{Vector3f, Symbol(bname, :_spin)}(evt, collid, len), - StructArray{Vector2i, Symbol(bname, :_colorFlow)}(evt, collid, len), - StructArray{Relation{MCParticle,MCParticle,1}, Symbol(bname, :_parents)}(evt, collid, len), - StructArray{Relation{MCParticle,MCParticle,2}, Symbol(bname, :_daughters)}(evt, collid, len), - ) - return StructArray{MCParticle}(columns) -end - -function StructArray{ReconstructedParticle, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_type)) - len = length(firstmem) - columns = (StructArray{ObjectID{ReconstructedParticle}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_energy)), - StructArray{Vector3f, Symbol(bname, :_momentum)}(evt, collid, len), - StructArray{Vector3f, Symbol(bname, :_referencePoint)}(evt, collid, len), - getproperty(evt, Symbol(bname, :_charge)), - getproperty(evt, Symbol(bname, :_mass)), - getproperty(evt, Symbol(bname, :_goodnessOfPID)), - StructArray{SVector{10,Float32}}(reshape(getproperty(evt, Symbol(bname, "_covMatrix[10]")), 10, len);dims=1), - StructArray{Relation{ReconstructedParticle,Cluster,1}, Symbol(bname, :_clusters)}(evt, collid, len), - StructArray{Relation{ReconstructedParticle,Track,2}, Symbol(bname, :_tracks)}(evt, collid, len), - StructArray{Relation{ReconstructedParticle,ReconstructedParticle,3}, Symbol(bname, :_particles)}(evt, collid, len), - StructArray{Relation{ReconstructedParticle,ParticleID,4}, Symbol(bname, :_particleIDs)}(evt, collid, len), - StructArray{ObjectID{Vertex}, Symbol(:_, bname, "_startVertex")}(evt, collid, len), - StructArray{ObjectID{ParticleID}, Symbol(:_, bname, "_particleIDUsed")}(evt, collid, len), - ) - return StructArray{ReconstructedParticle}(columns) -end - -function StructArray{SimPrimaryIonizationCluster, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_cellID)) - len = length(firstmem) - columns = (StructArray{ObjectID{SimPrimaryIonizationCluster}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_time)), - StructArray{Vector3d, Symbol(bname, :_position)}(evt, collid, len), - getproperty(evt, Symbol(bname, :_type)), - StructArray{PVector{SimPrimaryIonizationCluster,UInt64,1}, Symbol(bname, :_electronCellID)}(evt, collid, len), - StructArray{PVector{SimPrimaryIonizationCluster,Float32,2}, Symbol(bname, :_electronTime)}(evt, collid, len), - StructArray{PVector{SimPrimaryIonizationCluster,Vector3d,3}, Symbol(bname, :_electronPosition)}(evt, collid, len), - StructArray{PVector{SimPrimaryIonizationCluster,Float32,4}, Symbol(bname, :_pulseTime)}(evt, collid, len), - StructArray{PVector{SimPrimaryIonizationCluster,Float32,5}, Symbol(bname, :_pulseAmplitude)}(evt, collid, len), - StructArray{ObjectID{MCParticle}, Symbol(:_, bname, "_MCParticle")}(evt, collid, len), - ) - return StructArray{SimPrimaryIonizationCluster}(columns) -end - -function StructArray{SimCalorimeterHit, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_cellID)) - len = length(firstmem) - columns = (StructArray{ObjectID{SimCalorimeterHit}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_energy)), - StructArray{Vector3f, Symbol(bname, :_position)}(evt, collid, len), - StructArray{Relation{SimCalorimeterHit,CaloHitContribution,1}, Symbol(bname, :_contributions)}(evt, collid, len), - ) - return StructArray{SimCalorimeterHit}(columns) -end - -function StructArray{Cluster, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_type)) - len = length(firstmem) - columns = (StructArray{ObjectID{Cluster}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_energy)), - getproperty(evt, Symbol(bname, :_energyError)), - StructArray{Vector3f, Symbol(bname, :_position)}(evt, collid, len), - StructArray{SVector{6,Float32}}(reshape(getproperty(evt, Symbol(bname, "_positionError[6]")), 6, len);dims=1), - getproperty(evt, Symbol(bname, :_iTheta)), - getproperty(evt, Symbol(bname, :_phi)), - StructArray{Vector3f, Symbol(bname, :_directionError)}(evt, collid, len), - StructArray{PVector{Cluster,Float32,1}, Symbol(bname, :_shapeParameters)}(evt, collid, len), - StructArray{PVector{Cluster,Float32,2}, Symbol(bname, :_subdetectorEnergies)}(evt, collid, len), - StructArray{Relation{Cluster,Cluster,1}, Symbol(bname, :_clusters)}(evt, collid, len), - StructArray{Relation{Cluster,CalorimeterHit,2}, Symbol(bname, :_hits)}(evt, collid, len), - StructArray{Relation{Cluster,ParticleID,3}, Symbol(bname, :_particleIDs)}(evt, collid, len), - ) - return StructArray{Cluster}(columns) -end - -function StructArray{RecoParticleVertexAssociation, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_weight)) - len = length(firstmem) - columns = (StructArray{ObjectID{RecoParticleVertexAssociation}}((collect(0:len-1),fill(collid,len))), - firstmem, - StructArray{ObjectID{ReconstructedParticle}, Symbol(:_, bname, "_rec")}(evt, collid, len), - StructArray{ObjectID{Vertex}, Symbol(:_, bname, "_vertex")}(evt, collid, len), - ) - return StructArray{RecoParticleVertexAssociation}(columns) -end - -function StructArray{RecDqdx, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_dQdx)) - len = length(firstmem) - columns = (StructArray{ObjectID{RecDqdx}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_particleType)), - getproperty(evt, Symbol(bname, :_type)), - StructArray{SVector{5,Hypothesis}}(reshape(getproperty(evt, Symbol(bname, "_hypotheses[5]")), 5, len);dims=1), - StructArray{PVector{RecDqdx,HitLevelData,1}, Symbol(bname, :_hitData)}(evt, collid, len), - StructArray{ObjectID{Track}, Symbol(:_, bname, "_track")}(evt, collid, len), - ) - return StructArray{RecDqdx}(columns) -end - -function StructArray{CalorimeterHit, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_cellID)) - len = length(firstmem) - columns = (StructArray{ObjectID{CalorimeterHit}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_energy)), - getproperty(evt, Symbol(bname, :_energyError)), - getproperty(evt, Symbol(bname, :_time)), - StructArray{Vector3f, Symbol(bname, :_position)}(evt, collid, len), - getproperty(evt, Symbol(bname, :_type)), - ) - return StructArray{CalorimeterHit}(columns) -end - -function StructArray{TimeSeries, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_cellID)) - len = length(firstmem) - columns = (StructArray{ObjectID{TimeSeries}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_time)), - getproperty(evt, Symbol(bname, :_interval)), - StructArray{PVector{TimeSeries,Float32,1}, Symbol(bname, :_amplitude)}(evt, collid, len), - ) - return StructArray{TimeSeries}(columns) -end - -function StructArray{MCRecoTrackerAssociation, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_weight)) - len = length(firstmem) - columns = (StructArray{ObjectID{MCRecoTrackerAssociation}}((collect(0:len-1),fill(collid,len))), - firstmem, - StructArray{ObjectID{TrackerHit}, Symbol(:_, bname, "_rec")}(evt, collid, len), - StructArray{ObjectID{SimTrackerHit}, Symbol(:_, bname, "_sim")}(evt, collid, len), - ) - return StructArray{MCRecoTrackerAssociation}(columns) -end - -function StructArray{ParticleID, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_type)) - len = length(firstmem) - columns = (StructArray{ObjectID{ParticleID}}((collect(0:len-1),fill(collid,len))), - firstmem, - getproperty(evt, Symbol(bname, :_PDG)), - getproperty(evt, Symbol(bname, :_algorithmType)), - getproperty(evt, Symbol(bname, :_likelihood)), - StructArray{PVector{ParticleID,Float32,1}, Symbol(bname, :_parameters)}(evt, collid, len), - ) - return StructArray{ParticleID}(columns) -end - -function StructArray{MCRecoClusterParticleAssociation, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_weight)) - len = length(firstmem) - columns = (StructArray{ObjectID{MCRecoClusterParticleAssociation}}((collect(0:len-1),fill(collid,len))), - firstmem, - StructArray{ObjectID{Cluster}, Symbol(:_, bname, "_rec")}(evt, collid, len), - StructArray{ObjectID{MCParticle}, Symbol(:_, bname, "_sim")}(evt, collid, len), - ) - return StructArray{MCRecoClusterParticleAssociation}(columns) -end - diff --git a/podio/generate.jl b/podio/generate.jl index 442105d..46f99f8 100644 --- a/podio/generate.jl +++ b/podio/generate.jl @@ -226,6 +226,7 @@ function gen_docstring(io, key, dtype) println(io,"\"\"\"") end +#= function gen_structarray(io, key, dtype; podio=17) jtype = to_julia(key) println(io, "function StructArray{$jtype, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname") @@ -326,6 +327,7 @@ function gen_structarray_rntuple(io, key, dtype) println(io, " return StructArray{$jtype}(columns)") println(io, "end\n") end +=# function build_graph(datatypes) types = to_julia.(keys(datatypes)) @@ -341,7 +343,6 @@ function build_graph(datatypes) graph end - #---Components------------------------------------------------------------------------------------- io = open(joinpath(@__DIR__, "genComponents.jl"), "w") components = data["components"] @@ -367,6 +368,7 @@ end println(io, "export $(join(unique(exports),", "))") close(io) +#= #---StructArrays-------------------------------------------------------------------------------------- for v in (16,17) local io = open(joinpath(@__DIR__, "genStructArrays-v$(v).jl"), "w") @@ -381,4 +383,6 @@ datatypes = data["datatypes"] for (key,value) in pairs(datatypes) gen_structarray_rntuple(io, key, value) end +=# + close(io) \ No newline at end of file diff --git a/src/Components.jl b/src/Components.jl index 2417146..b9c72e9 100644 --- a/src/Components.jl +++ b/src/Components.jl @@ -24,6 +24,7 @@ Base.iterate(v::Vector3d, i=1) = i > 3 ? nothing : (getproperty(v, propertynames Base.length(v::Vector3d) = 3 θ(v::Vector3d) = atan(√(v.x^2+v.y^2), v.z) ϕ(v::Vector3d) = atan(v.y, v.x) +Base.zero(::Type{Vector3d}) = Vector3d() #---Vector3f Base.show(io::IO, v::Vector3f) = print(io, "($(v.x), $(v.y), $(v.z))") @@ -40,6 +41,7 @@ Base.iterate(v::Vector3f, i=1) = i > 3 ? nothing : (getproperty(v, propertynames Base.length(v::Vector3f) = 3 θ(v::Vector3f) = atan(√(v.x^2+v.y^2), v.z) ϕ(v::Vector3f) = atan(v.y, v.x) +Base.zero(::Type{Vector3f}) = Vector3f() #---Vector2i Base.show(io::IO, v::Vector2i) = print(io, "($(v.a), $(v.b))") @@ -47,6 +49,7 @@ Base.:+(v1::Vector2i, v2::Vector2i) = Vector3d(v1.a + v2.a, v1.b + v2.b) Base.:-(v1::Vector2i, v2::Vector2i) = Vector3d(v1.a - v2.a, v1.b - v2.b) Base.:*(v::Vector2i, a::Number) = Vector3d(a*v.a, a*v.b) Base.:*(a::Number, v::Vector2i) = v * a +Base.zero(::Type{Vector2i}) = Vector2i() #---Vector4f Base.show(io::IO, v::Vector4f) = print(io, "($(v.x), $(v.y), $(v.z), $(v.t))") @@ -60,6 +63,7 @@ function Base.isapprox(v1::Vector4f, v2::Vector4f; atol::Real=0, rtol::Real=Base isapprox(v1.z, v2.z; atol=atol, rtol=rtol, nans=nans) && isapprox(v1.t, v2.t; atol=atol, rtol=rtol, nans=nans) end +Base.zero(::Type{Vector4f}) = Vector4f() #-------------------------------------------------------------------------------------------------- #---ObjectID{ED}----------------------------------------------------------------------------------- @@ -145,6 +149,7 @@ Base.getindex(r::Relation{ED,TD,N}, i) where {ED,TD,N} = 0 < i <= (r.last - r.fi Base.size(r::Relation) = (r.last-r.first,) Base.length(r::Relation) = r.last-r.first Base.eltype(::Type{Relation{ED,TD,N}}) where {ED,TD,N} = TD +Base.zero(::Type{Relation{ED,TD,N}}) where {ED,TD,N} = Relation{ED,TD,N}(0,0,0) function relations(::Type{ED}) where ED (ft for ft in fieldtypes(ED) if ft <: Relation) end diff --git a/src/RootIO.jl b/src/RootIO.jl index 4ebee48..0227dbd 100644 --- a/src/RootIO.jl +++ b/src/RootIO.jl @@ -90,12 +90,14 @@ module RootIO # layouts and branch types reader.btypes = Dict{String, Type}() reader.layouts = Dict{String, Tuple}() + #= if !reader.isRNTuple pmajor = reader.podioversion >= newpodio ? "17" : "16" include(joinpath(@__DIR__,"../podio/genStructArrays-v$pmajor.jl")) else include(joinpath(@__DIR__,"../podio/genStructArrays-rntuple.jl")) end + =# return reader end @@ -144,6 +146,7 @@ module RootIO end #---StructArray constructors-------------------------------------------------------------------- + @inline function StructArray{Relation{ED,TD,N}, bname}(evt::UnROOT.LazyEvent, collid, len) where {ED,TD,N,bname} StructArray{Relation{ED,TD,N}}((getproperty(evt, Symbol(bname, :_begin)), getproperty(evt, Symbol(bname, :_end)), fill(collid,len))) end @@ -156,9 +159,15 @@ module RootIO @inline function StructArray{ObjectID{ED}, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where {ED,bname} inds = getproperty(evt, Symbol(bname, :_index)) cids = getproperty(evt, Symbol(bname, :_collectionID)) - len > 0 && cids[1] == -2 && fill!(cids, 0) # Handle the case collid is -2 :-( ) + #len > 0 && cids[1] == -2 && fill!(cids, 0) # Handle the case collid is -2 :-( ) + replace!(cids, -2 => 0) StructArray{ObjectID{ED}}((inds, cids)) end + @inline function StructArray{ObjectID, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where {bname} + inds = getproperty(evt, Symbol(bname, :_index)) + cids = getproperty(evt, Symbol(bname, :_collectionID)) + StructArray{ObjectID}((inds, cids)) + end @inline function StructArray{Vector3f, bname}(evt::UnROOT.LazyEvent, collid, len) where {bname} StructArray{Vector3f}((getproperty(evt, Symbol(bname, :_x)), getproperty(evt, Symbol(bname, :_y)), getproperty(evt, Symbol(bname, :_z)))) end @@ -181,8 +190,14 @@ module RootIO StructArray{ft,Symbol(bname,:_,fn)}(evt, collid, len) elseif ft <: ObjectID # index of another one.... n_rels += 1 - StructArray{ft, Symbol(bname, "#$(n_rels-1)")}(evt, collid, len) + if isnewpodio() + na = replace("$(fn)", "_idx" => "", "mcparticle" => "MCParticle") # remove the added suffix + StructArray{ft, Symbol("_", bname, "_$(na)")}(evt, collid, len) + else + StructArray{ft, Symbol(bname, "#$(n_rels-1)")}(evt, collid, len) + end else + fn == :subdetectorHitNumbers && (fn = :subDetectorHitNumbers) # adhoc fixes StructArray{ft,Symbol(bname,:_,fn)}(evt, collid, len) end end) @@ -309,4 +324,76 @@ module RootIO btype = btype === Any ? reader.btypes[bname] : btype # Allow the user to force the actual type _get(reader, evt, bname, btype, register) end -end + + selectednames(btype::Type, selection::Union{AbstractString, Symbol, Regex}) = selectednames(btype, [selection]) + function selectednames(btype::Type, selection) + field_names = fieldnames(btype) + _m(r::Regex) = Base.Fix1(occursin, r) ∘ string + filtered_names = mapreduce(∪, selection) do b + if b isa Regex + filter(_m(b), field_names) + elseif b isa String + Symbol(b) in field_names ? [Symbol(b)] : [] + elseif b isa Symbol + b in field_names ? [b] : [] + else + error("branch selection must be String, Symbol or Regex") + end + end + filtered_names + end + + """ + create_getter(reader::Reader, bname::String; selection=nothing) + + This function creates a getter function for a given branch name. The getter function is a function that takes an event and + returns a `StructArray` with the data of the branch. The getter function is created as a function with the name `get_`. + The optional parameter `selection` is a list of field names to be selected from the branch. If `selection` is not provided, all fields are selected. + The user can use a list of strings, symbols or regular expressions to select the fields. + """ + function create_getter(reader::Reader, bname::String; selection=nothing) + btype = reader.btypes[bname] + collid = Base.get(reader.collectionIDs, bname, UInt32(0)) + snames = isnothing(selection) ? fieldnames(btype) : selectednames(btype, selection) + fname = "get_" * replace(bname, "#" => "_", " " => "_") + #---Create the function as a string and evaluate it + code = "function $fname(evt::UnROOT.LazyEvent)\n" + if btype == ObjectID + code *= " return StructArray{ObjectID}((getproperty(evt, Symbol(\"$bname\",:_index)),getproperty(evt, Symbol(\"$bname\",:_collectionID))))\n" + else + first = true + n_rels = 0 # number of one-to-one or one-to-many Relations + for (ft, fn) in zip(fieldtypes(btype), fieldnames(btype)) + #fn in snames || continue + if first + fn == :index && continue # skip the index field + code *= " firstmem = getproperty(evt, Symbol(\"$(bname)_$fn\"))\n" + code *= " len = length(firstmem)\n" + code *= " columns = (StructArray{ObjectID{$(btype)}}((collect(0:len-1),fill($(collid),len))),\n" + code *= " firstmem,\n" + first = false + else + (ft <: Relation || ft <: ObjectID) && (n_rels += 1) + if fn in snames + if isprimitivetype(ft) + code *= " getproperty(evt, Symbol(\"$(bname)_$fn\")),\n" + elseif ft <: SVector + N = size(ft)[1] + code *= " StructArray{$ft}(reshape(getproperty(evt, Symbol(\"$(bname)_$fn[$N]\")), $N, len);dims=1),\n" + elseif ft <: ObjectID # one-to-one relation + code *= " StructArray{$ft, Symbol(\"$(bname)#$(n_rels-1)\")}(evt, $(collid), len),\n" + else + code *= " StructArray{$ft, Symbol(\"$(bname)_$fn\")}(evt, $(collid), len),\n" + end + else + code *= " zeros($ft, len),\n" + end + end + end + code *= " )\n" + code *= " return StructArray{$btype}(columns)\n" + end + code *= "end\n" + Meta.parse(code) |> eval + end +end # module RootIO \ No newline at end of file