From 5dbbd91fd82f6f319f98ff8b14a983ed05f5547a Mon Sep 17 00:00:00 2001 From: Pere Mato Date: Mon, 6 May 2024 16:28:38 +0200 Subject: [PATCH] Preparing new release --- Project.toml | 2 +- docs/src/release_notes.md | 7 + examples/FCC/analysis_MT.jl | 4 +- podio/genStructArrays-rntuple.jl | 429 ------------------------------ podio/genStructArrays-v16.jl | 430 ------------------------------- podio/genStructArrays-v17.jl | 401 ---------------------------- podio/generate.jl | 6 +- src/Components.jl | 5 + src/RootIO.jl | 95 +++++-- 9 files changed, 93 insertions(+), 1286 deletions(-) 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/analysis_MT.jl b/examples/FCC/analysis_MT.jl index 9d0fdaf..e51b3a5 100644 --- a/examples/FCC/analysis_MT.jl +++ b/examples/FCC/analysis_MT.jl @@ -42,18 +42,16 @@ mutable struct MyData <: AbstractAnalysisData end get_μIDs = RootIO.create_getter(reader, "Muon#0") -get_recps = RootIO.create_getter(reader, "ReconstructedParticles") +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#0"; register=false) # get the ids of muons - #μIDs = RootIO.getCollection{ObjectID{ReconstructedParticle},Symbol("Muon#0")}(evt,UInt32(0)) # 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.getCollection{ReconstructedParticle, :ReconstructedParticles}(evt, UInt32(15)) # get the reco particles recps = get_recps(evt) muons = recps[μIDs] # use the ids to subset the reco particles 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 a45830b..0000000 --- a/podio/genStructArrays-v16.jl +++ /dev/null @@ -1,430 +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{ReconstructedParticle, bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where bname - firstmem = getproperty(evt, Symbol(bname, :_energy)) - len = length(firstmem) - uint32_z = zeros(UInt32, len) #@view UInt32_zeros[1:len] - int32_z = zeros(Int32, len) #@view Int32_zeros[1:len] - float32_z = zeros(Float32, len) #@view Float32_zeros[1:len] - fcollid = fill(collid,len) - columns = ( - StructArray{ObjectID{ReconstructedParticle}}((collect(0:len-1),fcollid)), - int32_z, # sa.type, - firstmem, # getproperty(evt, Symbol(bname, :_energy)), - StructArray{Vector3f, Symbol(bname, :_momentum)}(evt, collid, len), - StructArray{Vector3f}((float32_z,float32_z, float32_z)), #StructArray{Vector3f, Symbol(bname, :_referencePoint)}(evt, collid, len), - getproperty(evt, Symbol(bname, :_charge)), - getproperty(evt, Symbol(bname, :_mass)), - float32_z, # sa.goodnessOfPID, # getproperty(evt, Symbol(bname, :_goodnessOfPID)), - StructArray{SVector{10,Float32}}(reshape(zeros(Float32, 10*len),10,len);dims=1), #StructArray{SVector{10,Float32}}(reshape(getproperty(evt, Symbol(bname, "_covMatrix[10]")), 10, len);dims=1), - StructArray{Relation{ReconstructedParticle,Cluster,1}}((uint32_z, uint32_z, fcollid)), #StructArray{Relation{ReconstructedParticle,Cluster,1}}((sa.clusters_begin, sa.clusters_end, fcollid)), - StructArray{Relation{ReconstructedParticle,Track,2}}((uint32_z, uint32_z, fcollid)), #StructArray{Relation{ReconstructedParticle,Track,2}}((sa.tracks_begin, sa.tracks_end, fcollid)), - StructArray{Relation{ReconstructedParticle,ReconstructedParticle,3}}((uint32_z, uint32_z, fcollid)), #StructArray{Relation{ReconstructedParticle,ReconstructedParticle,3}}((sa.particles_begin, sa.particles_end, fcollid)), - StructArray{Relation{ReconstructedParticle,ParticleID,4}}((uint32_z, uint32_z, fcollid)), #StructArray{Relation{ReconstructedParticle,ParticleID,4}}((sa.particleIDs_begin, sa.particleIDs_end, fcollid)), - StructArray{ObjectID{Vertex}}(( int32_z, uint32_z)), #StructArray{ObjectID{Vertex}}(StructArrays.components(getproperty(evt, Symbol(:_, branch, :_startVertex)))), - StructArray{ObjectID{ParticleID}}(( int32_z, uint32_z)) #StructArray{ObjectID{ParticleID}}(StructArrays.components(getproperty(evt, Symbol(:_, branch, :_particleIDUsed)))), - ) - 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 0664dc1..3dbbd8c 100644 --- a/src/RootIO.jl +++ b/src/RootIO.jl @@ -174,8 +174,6 @@ module RootIO getproperty(evt, bname) end - include(joinpath(@__DIR__,"../podio/genStructArrays-v16.jl")) - #---Generic StructArray constructor (fall-back)------------------------------------------------ function StructArray{T,bname}(evt::UnROOT.LazyEvent, collid = UInt32(0), len = -1) where {T,bname} fnames = fieldnames(T) @@ -191,8 +189,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) @@ -289,11 +293,11 @@ module RootIO end collid = Base.get(reader.collectionIDs, bname, UInt32(0)) # The CollectionID has beeen assigned when opening the file sbranch = Symbol(bname) - #if reader.isRNTuple - # sa = StructArray{btype}(evt, sbranch, collid) - #else + if reader.isRNTuple + sa = StructArray{btype}(evt, sbranch, collid) + else sa = StructArray{btype,sbranch}(evt, collid) - #end + end if register assignEDStore(sa, collid) if !isempty(layout[3]) # check if there are relations in this branch @@ -320,26 +324,75 @@ module RootIO _get(reader, evt, bname, btype, register) end - struct getCollection{ED <: EDM4hep.POD, B}; end - function getCollection{ED}(reader::Reader, evt::UnROOT.LazyEvent, bname::String) where ED - collid = Base.get(reader.collectionIDs, bname, UInt32(0)) - StructArray{ED, Symbol(bname)}(evt, collid, -1) - end - @inline function getCollection{ED,bname}(evt::UnROOT.LazyEvent, collid::UInt32) where {ED,bname} - StructArray{ED, bname}(evt, collid) + 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) - function create_getter(reader::Reader, bname::String) + 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, "#" => "_", " " => "_") - code = """ - function $fname(evt::UnROOT.LazyEvent) - StructArray{$btype, Symbol(\"$bname\")}(evt, $collid) + #---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 - +end # module RootIO \ No newline at end of file