/** TrackingNtupleObjs.hpp created on 2018-03-08 10:59:46.474049 by generate_class.py
 * AVOID EDITING THIS FILE BY HAND!! Instead edit TrackingNtupleObjs.yaml and re-run
 * generate_class.py
 */
#include "filval.hpp"
#include "root_filval.hpp"

#include<cmath>

#include "TrackingNtuple.h"

using namespace std;
using namespace fv;
using namespace fv_root;

typedef TreeDataSet<TrackingNtuple> TrackingDataSet;
struct Seed;

class SeedCollection {
  public:
    class iter {
      public:
        iter(const SeedCollection* collection, size_t idx)
          :collection(collection), idx(idx) { }
        iter operator++() { ++idx; return *this; }
        bool operator!=(const iter & other) { return idx != other.idx; }
        const Seed operator*() const;
      private:
        const SeedCollection* collection;
        size_t idx;
    };

    Value<vector<short>>* val_fitok;
    Value<vector<float>>* val_px;
    Value<vector<float>>* val_py;
    Value<vector<float>>* val_pz;
    Value<vector<float>>* val_pt;
    Value<vector<float>>* val_eta;
    Value<vector<float>>* val_phi;
    Value<vector<float>>* val_dxy;
    Value<vector<float>>* val_dz;
    Value<vector<float>>* val_ptErr;
    Value<vector<float>>* val_etaErr;
    Value<vector<float>>* val_phiErr;
    Value<vector<float>>* val_dxyErr;
    Value<vector<float>>* val_dzErr;
    Value<vector<float>>* val_chi2;
    Value<vector<int>>* val_q;
    Value<vector<unsigned int>>* val_nValid;
    Value<vector<unsigned int>>* val_nPixel;
    Value<vector<unsigned int>>* val_nGlued;
    Value<vector<unsigned int>>* val_nStrip;
    Value<vector<unsigned int>>* val_algo;
    Value<vector<int>>* val_trkIdx;
    Value<vector<vector<float>>>* val_shareFrac;
    Value<vector<vector<int>>>* val_simTrkIdx;
    Value<vector<unsigned int>>* val_offset;
    Value<vector<float>>* val_Et;
    Value<vector<float>>* val_hoe;
    Value<vector<vector<int>>>* val_isBarrel;
    Value<vector<vector<int>>>* val_layerOrDiskNr;
    Value<vector<vector<int>>>* val_isValidPos;
    Value<vector<vector<float>>>* val_dRZPos;
    Value<vector<vector<float>>>* val_dPhiPos;
    Value<vector<vector<int>>>* val_isValidNeg;
    Value<vector<vector<float>>>* val_dRZNeg;
    Value<vector<vector<float>>>* val_dPhiNeg;
    Value<vector<short>>* val_isECALDriven;

    SeedCollection() { }

    void init(TrackingDataSet& tds){
        val_fitok = tds.track_branch_obj<vector<short>>("see_fitok");
        val_px = tds.track_branch_obj<vector<float>>("see_px");
        val_py = tds.track_branch_obj<vector<float>>("see_py");
        val_pz = tds.track_branch_obj<vector<float>>("see_pz");
        val_pt = tds.track_branch_obj<vector<float>>("see_pt");
        val_eta = tds.track_branch_obj<vector<float>>("see_eta");
        val_phi = tds.track_branch_obj<vector<float>>("see_phi");
        val_dxy = tds.track_branch_obj<vector<float>>("see_dxy");
        val_dz = tds.track_branch_obj<vector<float>>("see_dz");
        val_ptErr = tds.track_branch_obj<vector<float>>("see_ptErr");
        val_etaErr = tds.track_branch_obj<vector<float>>("see_etaErr");
        val_phiErr = tds.track_branch_obj<vector<float>>("see_phiErr");
        val_dxyErr = tds.track_branch_obj<vector<float>>("see_dxyErr");
        val_dzErr = tds.track_branch_obj<vector<float>>("see_dzErr");
        val_chi2 = tds.track_branch_obj<vector<float>>("see_chi2");
        val_q = tds.track_branch_obj<vector<int>>("see_q");
        val_nValid = tds.track_branch_obj<vector<unsigned int>>("see_nValid");
        val_nPixel = tds.track_branch_obj<vector<unsigned int>>("see_nPixel");
        val_nGlued = tds.track_branch_obj<vector<unsigned int>>("see_nGlued");
        val_nStrip = tds.track_branch_obj<vector<unsigned int>>("see_nStrip");
        val_algo = tds.track_branch_obj<vector<unsigned int>>("see_algo");
        val_trkIdx = tds.track_branch_obj<vector<int>>("see_trkIdx");
        val_shareFrac = tds.track_branch_obj<vector<vector<float>>>("see_shareFrac");
        val_simTrkIdx = tds.track_branch_obj<vector<vector<int>>>("see_simTrkIdx");
        val_offset = tds.track_branch_obj<vector<unsigned int>>("see_offset");
        val_Et = tds.track_branch_obj<vector<float>>("see_Et");
        val_hoe = tds.track_branch_obj<vector<float>>("see_hoe");
        val_isBarrel = tds.track_branch_obj<vector<vector<int>>>("see_isBarrel");
        val_layerOrDiskNr = tds.track_branch_obj<vector<vector<int>>>("see_layerOrDiskNr");
        val_isValidPos = tds.track_branch_obj<vector<vector<int>>>("see_isValidPos");
        val_dRZPos = tds.track_branch_obj<vector<vector<float>>>("see_dRZPos");
        val_dPhiPos = tds.track_branch_obj<vector<vector<float>>>("see_dPhiPos");
        val_isValidNeg = tds.track_branch_obj<vector<vector<int>>>("see_isValidNeg");
        val_dRZNeg = tds.track_branch_obj<vector<vector<float>>>("see_dRZNeg");
        val_dPhiNeg = tds.track_branch_obj<vector<vector<float>>>("see_dPhiNeg");
        val_isECALDriven = tds.track_branch_obj<vector<short>>("see_isECALDriven");
    }

    size_t size() const { return (*val_fitok)().size();}

    const Seed operator[](size_t) const;
    iter begin() const { return iter(this, 0); }
    iter end() const { return iter(this, size()); }
};

struct Seed {
    const SeedCollection* collection;
    const size_t idx;
    Seed(const SeedCollection* collection, const size_t idx)
      :collection(collection), idx(idx) { }

    const short& fitok() const {return (*collection->val_fitok)().at(idx);}
    const float& px() const {return (*collection->val_px)().at(idx);}
    const float& py() const {return (*collection->val_py)().at(idx);}
    const float& pz() const {return (*collection->val_pz)().at(idx);}
    const float& pt() const {return (*collection->val_pt)().at(idx);}
    const float& eta() const {return (*collection->val_eta)().at(idx);}
    const float& phi() const {return (*collection->val_phi)().at(idx);}
    const float& dxy() const {return (*collection->val_dxy)().at(idx);}
    const float& dz() const {return (*collection->val_dz)().at(idx);}
    const float& ptErr() const {return (*collection->val_ptErr)().at(idx);}
    const float& etaErr() const {return (*collection->val_etaErr)().at(idx);}
    const float& phiErr() const {return (*collection->val_phiErr)().at(idx);}
    const float& dxyErr() const {return (*collection->val_dxyErr)().at(idx);}
    const float& dzErr() const {return (*collection->val_dzErr)().at(idx);}
    const float& chi2() const {return (*collection->val_chi2)().at(idx);}
    const int& q() const {return (*collection->val_q)().at(idx);}
    const unsigned int& nValid() const {return (*collection->val_nValid)().at(idx);}
    const unsigned int& nPixel() const {return (*collection->val_nPixel)().at(idx);}
    const unsigned int& nGlued() const {return (*collection->val_nGlued)().at(idx);}
    const unsigned int& nStrip() const {return (*collection->val_nStrip)().at(idx);}
    const unsigned int& algo() const {return (*collection->val_algo)().at(idx);}
    const int& trkIdx() const {return (*collection->val_trkIdx)().at(idx);}
    const vector<float>& shareFrac() const {return (*collection->val_shareFrac)().at(idx);}
    const vector<int>& simTrkIdx() const {return (*collection->val_simTrkIdx)().at(idx);}
    const unsigned int& offset() const {return (*collection->val_offset)().at(idx);}
    const float& Et() const {return (*collection->val_Et)().at(idx);}
    const float& hoe() const {return (*collection->val_hoe)().at(idx);}
    const vector<int>& isBarrel() const {return (*collection->val_isBarrel)().at(idx);}
    const vector<int>& layerOrDiskNr() const {return (*collection->val_layerOrDiskNr)().at(idx);}
    const vector<int>& isValidPos() const {return (*collection->val_isValidPos)().at(idx);}
    const vector<float>& dRZPos() const {return (*collection->val_dRZPos)().at(idx);}
    const vector<float>& dPhiPos() const {return (*collection->val_dPhiPos)().at(idx);}
    const vector<int>& isValidNeg() const {return (*collection->val_isValidNeg)().at(idx);}
    const vector<float>& dRZNeg() const {return (*collection->val_dRZNeg)().at(idx);}
    const vector<float>& dPhiNeg() const {return (*collection->val_dPhiNeg)().at(idx);}
    const short& isECALDriven() const {return (*collection->val_isECALDriven)().at(idx);}
};

const Seed SeedCollection::iter::operator*() const {
    return {collection, idx};
}
const Seed SeedCollection::operator[](size_t idx) const {
    return {this, idx};
}
struct Track;

class TrackCollection {
  public:
    class iter {
      public:
        iter(const TrackCollection* collection, size_t idx)
          :collection(collection), idx(idx) { }
        iter operator++() { ++idx; return *this; }
        bool operator!=(const iter & other) { return idx != other.idx; }
        const Track operator*() const;
      private:
        const TrackCollection* collection;
        size_t idx;
    };

    Value<vector<float>>* val_px;
    Value<vector<float>>* val_py;
    Value<vector<float>>* val_pz;
    Value<vector<float>>* val_pt;
    Value<vector<float>>* val_inner_px;
    Value<vector<float>>* val_inner_py;
    Value<vector<float>>* val_inner_pz;
    Value<vector<float>>* val_inner_pt;
    Value<vector<float>>* val_outer_px;
    Value<vector<float>>* val_outer_py;
    Value<vector<float>>* val_outer_pz;
    Value<vector<float>>* val_outer_pt;
    Value<vector<float>>* val_eta;
    Value<vector<float>>* val_lambda;
    Value<vector<float>>* val_cotTheta;
    Value<vector<float>>* val_phi;
    Value<vector<float>>* val_dxy;
    Value<vector<float>>* val_dz;
    Value<vector<float>>* val_ptErr;
    Value<vector<float>>* val_etaErr;
    Value<vector<float>>* val_lambdaErr;
    Value<vector<float>>* val_phiErr;
    Value<vector<float>>* val_dxyErr;
    Value<vector<float>>* val_dzErr;
    Value<vector<float>>* val_refpoint_x;
    Value<vector<float>>* val_refpoint_y;
    Value<vector<float>>* val_refpoint_z;
    Value<vector<float>>* val_nChi2;
    Value<vector<int>>* val_q;
    Value<vector<unsigned int>>* val_nValid;
    Value<vector<unsigned int>>* val_nInvalid;
    Value<vector<unsigned int>>* val_nPixel;
    Value<vector<unsigned int>>* val_nStrip;
    Value<vector<unsigned int>>* val_nPixelLay;
    Value<vector<unsigned int>>* val_nStripLay;
    Value<vector<unsigned int>>* val_n3DLay;
    Value<vector<unsigned int>>* val_nOuterLost;
    Value<vector<unsigned int>>* val_nInnerLost;
    Value<vector<unsigned int>>* val_algo;
    Value<vector<unsigned int>>* val_originalAlgo;
    Value<vector<ULong64_t>>* val_algoMask;
    Value<vector<unsigned int>>* val_stopReason;
    Value<vector<short>>* val_isHP;
    Value<vector<int>>* val_seedIdx;
    Value<vector<float>>* val_vtxx;
    Value<vector<float>>* val_vtxy;
    Value<vector<float>>* val_vtxz;
    Value<vector<vector<float>>>* val_shareFrac;
    Value<vector<vector<int>>>* val_simTrkIdx;
    Value<vector<int>>* val_genIdx;
    Value<vector<float>>* val_genDR;

    TrackCollection() { }

    void init(TrackingDataSet& tds){
        val_px = tds.track_branch_obj<vector<float>>("trk_px");
        val_py = tds.track_branch_obj<vector<float>>("trk_py");
        val_pz = tds.track_branch_obj<vector<float>>("trk_pz");
        val_pt = tds.track_branch_obj<vector<float>>("trk_pt");
        val_inner_px = tds.track_branch_obj<vector<float>>("trk_inner_px");
        val_inner_py = tds.track_branch_obj<vector<float>>("trk_inner_py");
        val_inner_pz = tds.track_branch_obj<vector<float>>("trk_inner_pz");
        val_inner_pt = tds.track_branch_obj<vector<float>>("trk_inner_pt");
        val_outer_px = tds.track_branch_obj<vector<float>>("trk_outer_px");
        val_outer_py = tds.track_branch_obj<vector<float>>("trk_outer_py");
        val_outer_pz = tds.track_branch_obj<vector<float>>("trk_outer_pz");
        val_outer_pt = tds.track_branch_obj<vector<float>>("trk_outer_pt");
        val_eta = tds.track_branch_obj<vector<float>>("trk_eta");
        val_lambda = tds.track_branch_obj<vector<float>>("trk_lambda");
        val_cotTheta = tds.track_branch_obj<vector<float>>("trk_cotTheta");
        val_phi = tds.track_branch_obj<vector<float>>("trk_phi");
        val_dxy = tds.track_branch_obj<vector<float>>("trk_dxy");
        val_dz = tds.track_branch_obj<vector<float>>("trk_dz");
        val_ptErr = tds.track_branch_obj<vector<float>>("trk_ptErr");
        val_etaErr = tds.track_branch_obj<vector<float>>("trk_etaErr");
        val_lambdaErr = tds.track_branch_obj<vector<float>>("trk_lambdaErr");
        val_phiErr = tds.track_branch_obj<vector<float>>("trk_phiErr");
        val_dxyErr = tds.track_branch_obj<vector<float>>("trk_dxyErr");
        val_dzErr = tds.track_branch_obj<vector<float>>("trk_dzErr");
        val_refpoint_x = tds.track_branch_obj<vector<float>>("trk_refpoint_x");
        val_refpoint_y = tds.track_branch_obj<vector<float>>("trk_refpoint_y");
        val_refpoint_z = tds.track_branch_obj<vector<float>>("trk_refpoint_z");
        val_nChi2 = tds.track_branch_obj<vector<float>>("trk_nChi2");
        val_q = tds.track_branch_obj<vector<int>>("trk_q");
        val_nValid = tds.track_branch_obj<vector<unsigned int>>("trk_nValid");
        val_nInvalid = tds.track_branch_obj<vector<unsigned int>>("trk_nInvalid");
        val_nPixel = tds.track_branch_obj<vector<unsigned int>>("trk_nPixel");
        val_nStrip = tds.track_branch_obj<vector<unsigned int>>("trk_nStrip");
        val_nPixelLay = tds.track_branch_obj<vector<unsigned int>>("trk_nPixelLay");
        val_nStripLay = tds.track_branch_obj<vector<unsigned int>>("trk_nStripLay");
        val_n3DLay = tds.track_branch_obj<vector<unsigned int>>("trk_n3DLay");
        val_nOuterLost = tds.track_branch_obj<vector<unsigned int>>("trk_nOuterLost");
        val_nInnerLost = tds.track_branch_obj<vector<unsigned int>>("trk_nInnerLost");
        val_algo = tds.track_branch_obj<vector<unsigned int>>("trk_algo");
        val_originalAlgo = tds.track_branch_obj<vector<unsigned int>>("trk_originalAlgo");
        val_algoMask = tds.track_branch_obj<vector<ULong64_t>>("trk_algoMask");
        val_stopReason = tds.track_branch_obj<vector<unsigned int>>("trk_stopReason");
        val_isHP = tds.track_branch_obj<vector<short>>("trk_isHP");
        val_seedIdx = tds.track_branch_obj<vector<int>>("trk_seedIdx");
        val_vtxx = tds.track_branch_obj<vector<float>>("trk_vtxx");
        val_vtxy = tds.track_branch_obj<vector<float>>("trk_vtxy");
        val_vtxz = tds.track_branch_obj<vector<float>>("trk_vtxz");
        val_shareFrac = tds.track_branch_obj<vector<vector<float>>>("trk_shareFrac");
        val_simTrkIdx = tds.track_branch_obj<vector<vector<int>>>("trk_simTrkIdx");
        val_genIdx = tds.track_branch_obj<vector<int>>("trk_genIdx");
        val_genDR = tds.track_branch_obj<vector<float>>("trk_genDR");
    }

    size_t size() const { return (*val_px)().size();}

    const Track operator[](size_t) const;
    iter begin() const { return iter(this, 0); }
    iter end() const { return iter(this, size()); }
};

struct Track {
    const TrackCollection* collection;
    const size_t idx;
    Track(const TrackCollection* collection, const size_t idx)
      :collection(collection), idx(idx) { }

    const float& px() const {return (*collection->val_px)().at(idx);}
    const float& py() const {return (*collection->val_py)().at(idx);}
    const float& pz() const {return (*collection->val_pz)().at(idx);}
    const float& pt() const {return (*collection->val_pt)().at(idx);}
    const float& inner_px() const {return (*collection->val_inner_px)().at(idx);}
    const float& inner_py() const {return (*collection->val_inner_py)().at(idx);}
    const float& inner_pz() const {return (*collection->val_inner_pz)().at(idx);}
    const float& inner_pt() const {return (*collection->val_inner_pt)().at(idx);}
    const float& outer_px() const {return (*collection->val_outer_px)().at(idx);}
    const float& outer_py() const {return (*collection->val_outer_py)().at(idx);}
    const float& outer_pz() const {return (*collection->val_outer_pz)().at(idx);}
    const float& outer_pt() const {return (*collection->val_outer_pt)().at(idx);}
    const float& eta() const {return (*collection->val_eta)().at(idx);}
    const float& lambda() const {return (*collection->val_lambda)().at(idx);}
    const float& cotTheta() const {return (*collection->val_cotTheta)().at(idx);}
    const float& phi() const {return (*collection->val_phi)().at(idx);}
    const float& dxy() const {return (*collection->val_dxy)().at(idx);}
    const float& dz() const {return (*collection->val_dz)().at(idx);}
    const float& ptErr() const {return (*collection->val_ptErr)().at(idx);}
    const float& etaErr() const {return (*collection->val_etaErr)().at(idx);}
    const float& lambdaErr() const {return (*collection->val_lambdaErr)().at(idx);}
    const float& phiErr() const {return (*collection->val_phiErr)().at(idx);}
    const float& dxyErr() const {return (*collection->val_dxyErr)().at(idx);}
    const float& dzErr() const {return (*collection->val_dzErr)().at(idx);}
    const float& refpoint_x() const {return (*collection->val_refpoint_x)().at(idx);}
    const float& refpoint_y() const {return (*collection->val_refpoint_y)().at(idx);}
    const float& refpoint_z() const {return (*collection->val_refpoint_z)().at(idx);}
    const float& nChi2() const {return (*collection->val_nChi2)().at(idx);}
    const int& q() const {return (*collection->val_q)().at(idx);}
    const unsigned int& nValid() const {return (*collection->val_nValid)().at(idx);}
    const unsigned int& nInvalid() const {return (*collection->val_nInvalid)().at(idx);}
    const unsigned int& nPixel() const {return (*collection->val_nPixel)().at(idx);}
    const unsigned int& nStrip() const {return (*collection->val_nStrip)().at(idx);}
    const unsigned int& nPixelLay() const {return (*collection->val_nPixelLay)().at(idx);}
    const unsigned int& nStripLay() const {return (*collection->val_nStripLay)().at(idx);}
    const unsigned int& n3DLay() const {return (*collection->val_n3DLay)().at(idx);}
    const unsigned int& nOuterLost() const {return (*collection->val_nOuterLost)().at(idx);}
    const unsigned int& nInnerLost() const {return (*collection->val_nInnerLost)().at(idx);}
    const unsigned int& algo() const {return (*collection->val_algo)().at(idx);}
    const unsigned int& originalAlgo() const {return (*collection->val_originalAlgo)().at(idx);}
    const ULong64_t& algoMask() const {return (*collection->val_algoMask)().at(idx);}
    const unsigned int& stopReason() const {return (*collection->val_stopReason)().at(idx);}
    const short& isHP() const {return (*collection->val_isHP)().at(idx);}
    const int& seedIdx() const {return (*collection->val_seedIdx)().at(idx);}
    const float& vtxx() const {return (*collection->val_vtxx)().at(idx);}
    const float& vtxy() const {return (*collection->val_vtxy)().at(idx);}
    const float& vtxz() const {return (*collection->val_vtxz)().at(idx);}
    const vector<float>& shareFrac() const {return (*collection->val_shareFrac)().at(idx);}
    const vector<int>& simTrkIdx() const {return (*collection->val_simTrkIdx)().at(idx);}
    const int& genIdx() const {return (*collection->val_genIdx)().at(idx);}
    const float& genDR() const {return (*collection->val_genDR)().at(idx);}
};

const Track TrackCollection::iter::operator*() const {
    return {collection, idx};
}
const Track TrackCollection::operator[](size_t idx) const {
    return {this, idx};
}
struct SimTrack;

class SimTrackCollection {
  public:
    class iter {
      public:
        iter(const SimTrackCollection* collection, size_t idx)
          :collection(collection), idx(idx) { }
        iter operator++() { ++idx; return *this; }
        bool operator!=(const iter & other) { return idx != other.idx; }
        const SimTrack operator*() const;
      private:
        const SimTrackCollection* collection;
        size_t idx;
    };

    Value<vector<int>>* val_event;
    Value<vector<int>>* val_bunchCrossing;
    Value<vector<int>>* val_pdgId;
    Value<vector<float>>* val_px;
    Value<vector<float>>* val_py;
    Value<vector<float>>* val_pz;
    Value<vector<float>>* val_pt;
    Value<vector<float>>* val_eta;
    Value<vector<float>>* val_phi;
    Value<vector<float>>* val_pca_pt;
    Value<vector<float>>* val_pca_eta;
    Value<vector<float>>* val_pca_lambda;
    Value<vector<float>>* val_pca_cotTheta;
    Value<vector<float>>* val_pca_phi;
    Value<vector<float>>* val_pca_dxy;
    Value<vector<float>>* val_pca_dz;
    Value<vector<int>>* val_q;
    Value<vector<unsigned int>>* val_nValid;
    Value<vector<unsigned int>>* val_nPixel;
    Value<vector<unsigned int>>* val_nStrip;
    Value<vector<unsigned int>>* val_nLay;
    Value<vector<unsigned int>>* val_nPixelLay;
    Value<vector<unsigned int>>* val_n3DLay;
    Value<vector<vector<int>>>* val_trkIdx;
    Value<vector<vector<float>>>* val_shareFrac;
    Value<vector<int>>* val_parentVtxIdx;
    Value<vector<vector<int>>>* val_decayVtxIdx;
    Value<vector<vector<int>>>* val_seedIdx;

    SimTrackCollection() { }

    void init(TrackingDataSet& tds){
        val_event = tds.track_branch_obj<vector<int>>("sim_event");
        val_bunchCrossing = tds.track_branch_obj<vector<int>>("sim_bunchCrossing");
        val_pdgId = tds.track_branch_obj<vector<int>>("sim_pdgId");
        val_px = tds.track_branch_obj<vector<float>>("sim_px");
        val_py = tds.track_branch_obj<vector<float>>("sim_py");
        val_pz = tds.track_branch_obj<vector<float>>("sim_pz");
        val_pt = tds.track_branch_obj<vector<float>>("sim_pt");
        val_eta = tds.track_branch_obj<vector<float>>("sim_eta");
        val_phi = tds.track_branch_obj<vector<float>>("sim_phi");
        val_pca_pt = tds.track_branch_obj<vector<float>>("sim_pca_pt");
        val_pca_eta = tds.track_branch_obj<vector<float>>("sim_pca_eta");
        val_pca_lambda = tds.track_branch_obj<vector<float>>("sim_pca_lambda");
        val_pca_cotTheta = tds.track_branch_obj<vector<float>>("sim_pca_cotTheta");
        val_pca_phi = tds.track_branch_obj<vector<float>>("sim_pca_phi");
        val_pca_dxy = tds.track_branch_obj<vector<float>>("sim_pca_dxy");
        val_pca_dz = tds.track_branch_obj<vector<float>>("sim_pca_dz");
        val_q = tds.track_branch_obj<vector<int>>("sim_q");
        val_nValid = tds.track_branch_obj<vector<unsigned int>>("sim_nValid");
        val_nPixel = tds.track_branch_obj<vector<unsigned int>>("sim_nPixel");
        val_nStrip = tds.track_branch_obj<vector<unsigned int>>("sim_nStrip");
        val_nLay = tds.track_branch_obj<vector<unsigned int>>("sim_nLay");
        val_nPixelLay = tds.track_branch_obj<vector<unsigned int>>("sim_nPixelLay");
        val_n3DLay = tds.track_branch_obj<vector<unsigned int>>("sim_n3DLay");
        val_trkIdx = tds.track_branch_obj<vector<vector<int>>>("sim_trkIdx");
        val_shareFrac = tds.track_branch_obj<vector<vector<float>>>("sim_shareFrac");
        val_parentVtxIdx = tds.track_branch_obj<vector<int>>("sim_parentVtxIdx");
        val_decayVtxIdx = tds.track_branch_obj<vector<vector<int>>>("sim_decayVtxIdx");
        val_seedIdx = tds.track_branch_obj<vector<vector<int>>>("sim_seedIdx");
    }

    size_t size() const { return (*val_event)().size();}

    const SimTrack operator[](size_t) const;
    iter begin() const { return iter(this, 0); }
    iter end() const { return iter(this, size()); }
};

struct SimTrack {
    const SimTrackCollection* collection;
    const size_t idx;
    SimTrack(const SimTrackCollection* collection, const size_t idx)
      :collection(collection), idx(idx) { }

    const int& event() const {return (*collection->val_event)().at(idx);}
    const int& bunchCrossing() const {return (*collection->val_bunchCrossing)().at(idx);}
    const int& pdgId() const {return (*collection->val_pdgId)().at(idx);}
    const float& px() const {return (*collection->val_px)().at(idx);}
    const float& py() const {return (*collection->val_py)().at(idx);}
    const float& pz() const {return (*collection->val_pz)().at(idx);}
    const float& pt() const {return (*collection->val_pt)().at(idx);}
    const float& eta() const {return (*collection->val_eta)().at(idx);}
    const float& phi() const {return (*collection->val_phi)().at(idx);}
    const float& pca_pt() const {return (*collection->val_pca_pt)().at(idx);}
    const float& pca_eta() const {return (*collection->val_pca_eta)().at(idx);}
    const float& pca_lambda() const {return (*collection->val_pca_lambda)().at(idx);}
    const float& pca_cotTheta() const {return (*collection->val_pca_cotTheta)().at(idx);}
    const float& pca_phi() const {return (*collection->val_pca_phi)().at(idx);}
    const float& pca_dxy() const {return (*collection->val_pca_dxy)().at(idx);}
    const float& pca_dz() const {return (*collection->val_pca_dz)().at(idx);}
    const int& q() const {return (*collection->val_q)().at(idx);}
    const unsigned int& nValid() const {return (*collection->val_nValid)().at(idx);}
    const unsigned int& nPixel() const {return (*collection->val_nPixel)().at(idx);}
    const unsigned int& nStrip() const {return (*collection->val_nStrip)().at(idx);}
    const unsigned int& nLay() const {return (*collection->val_nLay)().at(idx);}
    const unsigned int& nPixelLay() const {return (*collection->val_nPixelLay)().at(idx);}
    const unsigned int& n3DLay() const {return (*collection->val_n3DLay)().at(idx);}
    const vector<int>& trkIdx() const {return (*collection->val_trkIdx)().at(idx);}
    const vector<float>& shareFrac() const {return (*collection->val_shareFrac)().at(idx);}
    const int& parentVtxIdx() const {return (*collection->val_parentVtxIdx)().at(idx);}
    const vector<int>& decayVtxIdx() const {return (*collection->val_decayVtxIdx)().at(idx);}
    const vector<int>& seedIdx() const {return (*collection->val_seedIdx)().at(idx);}
};

const SimTrack SimTrackCollection::iter::operator*() const {
    return {collection, idx};
}
const SimTrack SimTrackCollection::operator[](size_t idx) const {
    return {this, idx};
}
struct SimVertex;

class SimVertexCollection {
  public:
    class iter {
      public:
        iter(const SimVertexCollection* collection, size_t idx)
          :collection(collection), idx(idx) { }
        iter operator++() { ++idx; return *this; }
        bool operator!=(const iter & other) { return idx != other.idx; }
        const SimVertex operator*() const;
      private:
        const SimVertexCollection* collection;
        size_t idx;
    };

    Value<vector<int>>* val_event;
    Value<vector<int>>* val_bunchCrossing;
    Value<vector<unsigned int>>* val_processType;
    Value<vector<float>>* val_x;
    Value<vector<float>>* val_y;
    Value<vector<float>>* val_z;
    Value<vector<vector<int>>>* val_sourceSimIdx;
    Value<vector<vector<int>>>* val_daughterSimIdx;

    SimVertexCollection() { }

    void init(TrackingDataSet& tds){
        val_event = tds.track_branch_obj<vector<int>>("simvtx_event");
        val_bunchCrossing = tds.track_branch_obj<vector<int>>("simvtx_bunchCrossing");
        val_processType = tds.track_branch_obj<vector<unsigned int>>("simvtx_processType");
        val_x = tds.track_branch_obj<vector<float>>("simvtx_x");
        val_y = tds.track_branch_obj<vector<float>>("simvtx_y");
        val_z = tds.track_branch_obj<vector<float>>("simvtx_z");
        val_sourceSimIdx = tds.track_branch_obj<vector<vector<int>>>("simvtx_sourceSimIdx");
        val_daughterSimIdx = tds.track_branch_obj<vector<vector<int>>>("simvtx_daughterSimIdx");
    }

    size_t size() const { return (*val_event)().size();}

    const SimVertex operator[](size_t) const;
    iter begin() const { return iter(this, 0); }
    iter end() const { return iter(this, size()); }
};

struct SimVertex {
    const SimVertexCollection* collection;
    const size_t idx;
    SimVertex(const SimVertexCollection* collection, const size_t idx)
      :collection(collection), idx(idx) { }

    const int& event() const {return (*collection->val_event)().at(idx);}
    const int& bunchCrossing() const {return (*collection->val_bunchCrossing)().at(idx);}
    const unsigned int& processType() const {return (*collection->val_processType)().at(idx);}
    const float& x() const {return (*collection->val_x)().at(idx);}
    const float& y() const {return (*collection->val_y)().at(idx);}
    const float& z() const {return (*collection->val_z)().at(idx);}
    const vector<int>& sourceSimIdx() const {return (*collection->val_sourceSimIdx)().at(idx);}
    const vector<int>& daughterSimIdx() const {return (*collection->val_daughterSimIdx)().at(idx);}
};

const SimVertex SimVertexCollection::iter::operator*() const {
    return {collection, idx};
}
const SimVertex SimVertexCollection::operator[](size_t idx) const {
    return {this, idx};
}
