Pārlūkot izejas kodu

initial implementation of analysis code for electron tracking validation, included plots for dz vs. eta and dphi vs. eta between sim-hits and rec-hits in the pixel barrel

Caleb Fangmeier 7 gadi atpakaļ
revīzija
a6295f14f9
9 mainītis faili ar 2602 papildinājumiem un 0 dzēšanām
  1. 4 0
      .gitignore
  2. 3 0
      .gitmodules
  3. 63 0
      CMakeLists.txt
  4. 1180 0
      analysis/TrackingNtuple.h
  5. 915 0
      analysis/obj_types.cpp
  6. 183 0
      analysis/tracking_validation.cpp
  7. 16 0
      cmake/FindJupyter.cmake
  8. 237 0
      cmake/FindROOT.cmake
  9. 1 0
      filval

+ 4 - 0
.gitignore

@@ -0,0 +1,4 @@
+
+legacy/
+data/
+build/

+ 3 - 0
.gitmodules

@@ -0,0 +1,3 @@
+[submodule "filval"]
+	path = filval
+	url = gogs@git.fangmeier.tech:caleb/filval.git

+ 63 - 0
CMakeLists.txt

@@ -0,0 +1,63 @@
+
+CMAKE_MINIMUM_REQUIRED (VERSION 2.8)
+
+PROJECT (EGAMMA CXX)
+
+# Declare semantic versioning for FILVAL
+SET(FILVAL_VERSION_MAJOR 0)
+SET(FILVAL_VERSION_MINOR 1)
+SET(FILVAL_VERSION_PATCH 0)
+SET(CMAKE_BUILD_TYPE "Release")
+
+CONFIGURE_FILE (
+  "${PROJECT_SOURCE_DIR}/filval/filval.hpp"
+  "${PROJECT_BINARY_DIR}/filval/filval.hpp"
+  )
+
+
+SET( EGAMMA_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
+SET( EGAMMA_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} )
+
+# Setup clang as the project compiler
+SET (CMAKE_CXX_COMPILER             "/usr/bin/clang++")
+SET (CMAKE_CXX_FLAGS                "-Wall")
+SET (CMAKE_CXX_FLAGS_DEBUG          "-g")
+SET (CMAKE_CXX_FLAGS_MINSIZEREL     "-Os -DNDEBUG")
+SET (CMAKE_CXX_FLAGS_RELEASE        "-O3 -DNDEBUG")
+SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
+
+SET (CMAKE_AR      "/usr/bin/llvm-ar")
+SET (CMAKE_LINKER  "/usr/bin/llvm-ld")
+SET (CMAKE_NM      "/usr/bin/llvm-nm")
+SET (CMAKE_OBJDUMP "/usr/bin/llvm-objdump")
+SET (CMAKE_RANLIB  "/usr/bin/llvm-ranlib")
+
+LIST( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake )
+
+FIND_PACKAGE(Jupyter)
+IF(NBCONVERT_FOUND)
+    ADD_CUSTOM_TARGET(notebook-docs
+        ${CMAKE_CURRENT_SOURCE_DIR}/cmake/convert_nb ${NBCONVERT_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxygen_site
+        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+        COMMENT "Converting Jupyter Notebooks to HTML" VERBATIM
+    )
+
+    ADD_CUSTOM_TARGET(notebooks
+        ${CMAKE_CURRENT_SOURCE_DIR}/cmake/convert_nb ${NBCONVERT_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxygen_site --update
+        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+        COMMENT "Re-Running notebooks and converting to HTML" VERBATIM
+    )
+ENDIF(NBCONVERT_FOUND)
+
+FIND_PACKAGE(ROOT REQUIRED)
+INCLUDE_DIRECTORIES( SYSTEM ${ROOT_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
+
+# Adds the dictionary library for addiitonal type serialization
+SET( CLINGDICTFILE ${CMAKE_CURRENT_BINARY_DIR}/clingdict.cpp )
+ROOT_GENERATE_DICTIONARY( "" ${CMAKE_CURRENT_SOURCE_DIR}/filval/root/LinkDef.hpp ${CLINGDICTFILE} "" )
+ADD_LIBRARY( filval SHARED ${CLINGDICTFILE} )
+
+# Compiles main analysis routine
+ADD_EXECUTABLE(tracking_validation ${CMAKE_CURRENT_SOURCE_DIR}/analysis/tracking_validation.cpp)
+TARGET_LINK_LIBRARIES( tracking_validation filval ${ROOT_LIBRARIES} )
+

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1180 - 0
analysis/TrackingNtuple.h


+ 915 - 0
analysis/obj_types.cpp

@@ -0,0 +1,915 @@
+#include "filval/filval.hpp"
+#include "filval/root/filval.hpp"
+
+#include "TrackingNtuple.h"
+
+using namespace std;
+using namespace fv;
+using namespace fv::root;
+
+using namespace std;
+
+typedef TreeDataSet<TrackingNtuple> TrackingDataSet;
+
+//#^#=========================================================================
+//==============PIXEL REC HIT=================================================
+//============================================================================
+struct PixRecHit {
+    unsigned short det;
+    unsigned short lay;
+    unsigned int   detId;
+    unsigned short simType;
+    float          x;
+    float          y;
+    float          z;
+    float          xx;
+    float          xy;
+    float          yy;
+    float          yz;
+    float          zz;
+    float          zx;
+    float          radL;
+    float          bbxi;
+    vector<int>    trkIdx;
+    vector<int>    seeIdx;
+    vector<int>    simHitIdx;
+    vector<float>  chargeFraction;
+};
+
+Value<vector<PixRecHit>>*
+register_pixrec_hits(TrackingDataSet &tds){
+    auto& builder = func<std::vector<PixRecHit>(vector<unsigned short>,
+                                                vector<unsigned short>,
+                                                vector<unsigned int>,
+                                                vector<unsigned short>,
+                                                vector<float>,
+                                                vector<float>,
+                                                vector<float>,
+                                                vector<float>,
+                                                vector<float>,
+                                                vector<float>,
+                                                vector<float>,
+                                                vector<float>,
+                                                vector<float>,
+                                                vector<float>,
+                                                vector<float>,
+                                                vector<vector<int>>,
+                                                vector<vector<int>>,
+                                                vector<vector<int>>,
+                                                vector<vector<float>>)>("build_pixrec_hits",
+        FUNC(([](const vector<unsigned short>& det,
+                 const vector<unsigned short>& lay,
+                 const vector<unsigned int>&   detId,
+                 const vector<unsigned short>& simType,
+                 const vector<float>& x,
+                 const vector<float>& y,
+                 const vector<float>& z,
+                 const vector<float>& xx,
+                 const vector<float>& xy,
+                 const vector<float>& yy,
+                 const vector<float>& yz,
+                 const vector<float>& zz,
+                 const vector<float>& zx,
+                 const vector<float>& radL,
+                 const vector<float>& bbxi,
+                 const vector<vector<int>>& trkIdx,
+                 const vector<vector<int>>& seeIdx,
+                 const vector<vector<int>>& simHitIdx,
+                 const vector<vector<float>>& chargeFraction){
+            std::vector<PixRecHit> pixrec_hits;
+            for(int i=0; i<det.size(); i++)
+                pixrec_hits.push_back({det[i],
+                                   lay[i],
+                                   detId[i],
+                                   simType[i],
+                                   x[i],
+                                   y[i],
+                                   z[i],
+                                   xx[i],
+                                   xy[i],
+                                   yy[i],
+                                   yz[i],
+                                   zz[i],
+                                   zx[i],
+                                   radL[i],
+                                   bbxi[i],
+                                   trkIdx[i],
+                                   seeIdx[i],
+                                   simHitIdx[i],
+                                   chargeFraction[i]
+                                   });
+            return pixrec_hits;
+        })));
+
+
+    return apply(builder,
+        fv::tuple(tds.track_branch_obj<vector<unsigned short>>("pix_det"),
+                  tds.track_branch_obj<vector<unsigned short>>("pix_lay"),
+                  tds.track_branch_obj<vector<unsigned int>>("pix_detId"),
+                  tds.track_branch_obj<vector<unsigned short>>("pix_simType"),
+                  tds.track_branch_obj<vector<float>>("pix_x"),
+                  tds.track_branch_obj<vector<float>>("pix_y"),
+                  tds.track_branch_obj<vector<float>>("pix_z"),
+                  tds.track_branch_obj<vector<float>>("pix_xx"),
+                  tds.track_branch_obj<vector<float>>("pix_xy"),
+                  tds.track_branch_obj<vector<float>>("pix_yy"),
+                  tds.track_branch_obj<vector<float>>("pix_yz"),
+                  tds.track_branch_obj<vector<float>>("pix_zz"),
+                  tds.track_branch_obj<vector<float>>("pix_zx"),
+                  tds.track_branch_obj<vector<float>>("pix_radL"),
+                  tds.track_branch_obj<vector<float>>("pix_bbxi"),
+                  tds.track_branch_obj<vector<vector<int>>>("pix_trkIdx"),
+                  tds.track_branch_obj<vector<vector<int>>>("pix_seeIdx"),
+                  tds.track_branch_obj<vector<vector<int>>>("pix_simHitIdx"),
+                  tds.track_branch_obj<vector<vector<float>>>("pix_chargeFraction")),
+        "pixrec_hits");
+}
+
+//#^#=========================================================================
+//===================SIM HIT==================================================
+//============================================================================
+struct SimHit {
+   unsigned short det;
+   unsigned short lay;
+   unsigned int   detId;
+   float          x;
+   float          y;
+   float          z;
+   int            particle;
+   short          process;
+   float          eloss;
+   float          tof;
+   int            simTrkIdx;
+   vector<int>    hitIdx;
+   vector<int>    hitType;
+};
+
+Value<vector<SimHit>>*
+register_sim_hits(TrackingDataSet &tds){
+    auto& builder =
+        func<std::vector<SimHit>(vector<unsigned short>, //  det;
+                                 vector<unsigned short>, //  lay;
+                                 vector<unsigned int>,   //  detId;
+                                 vector<float>,          //  x;
+                                 vector<float>,          //  y;
+                                 vector<float>,          //  z;
+                                 vector<int>  ,          //  particle;
+                                 vector<short>,          //  process;
+                                 vector<float>,          //  eloss;
+                                 vector<float>,          //  tof;
+                                 vector<int>  ,          //  simTrkIdx;
+                                 vector<vector<int>>,    //  hitIdx;
+                                 vector<vector<int>>     //  hitType;
+            )>("build_sim_hits", FUNC(([](
+                 const vector<unsigned short>& det,
+                 const vector<unsigned short>& lay,
+                 const vector<unsigned int>&   detId,
+                 const vector<float>&          x,
+                 const vector<float>&          y,
+                 const vector<float>&          z,
+                 const vector<int>&            particle,
+                 const vector<short>&          process,
+                 const vector<float>&          eloss,
+                 const vector<float>&          tof,
+                 const vector<int>&            simTrkIdx,
+                 const vector<vector<int>>&    hitIdx,
+                 const vector<vector<int>>&    hitType
+                 ){
+            std::vector<SimHit> sim_hits;
+            for(int i=0; i<det.size(); i++)
+                sim_hits.push_back({det[i],
+                                    lay[i],
+                                    detId[i],
+                                    x[i],
+                                    y[i],
+                                    z[i],
+                                    particle[i],
+                                    process[i],
+                                    eloss[i],
+                                    tof[i],
+                                    simTrkIdx[i],
+                                    hitIdx[i],
+                                    hitType[i]});
+            return sim_hits;
+        })));
+
+
+    return apply(builder,
+        fv::tuple(tds.track_branch_obj<vector<unsigned short>>("simhit_det"),
+                  tds.track_branch_obj<vector<unsigned short>>("simhit_lay"),
+                  tds.track_branch_obj<vector<unsigned int>>("simhit_detId"),
+                  tds.track_branch_obj<vector<float>>("simhit_x"),
+                  tds.track_branch_obj<vector<float>>("simhit_y"),
+                  tds.track_branch_obj<vector<float>>("simhit_z"),
+                  tds.track_branch_obj<vector<int>>("simhit_particle"),
+                  tds.track_branch_obj<vector<short>>("simhit_process"),
+                  tds.track_branch_obj<vector<float>>("simhit_eloss"),
+                  tds.track_branch_obj<vector<float>>("simhit_tof"),
+                  tds.track_branch_obj<vector<int>>("simhit_simTrkIdx"),
+                  tds.track_branch_obj<vector<vector<int>>>("simhit_hitIdx"),
+                  tds.track_branch_obj<vector<vector<int>>>("simhit_hitType")),
+        "sim_hits");
+}
+
+//#^#=========================================================================
+//=======================SEED=================================================
+//============================================================================
+struct Seed {
+   short          fitok;
+   float          px;
+   float          py;
+   float          pz;
+   float          pt;
+   float          eta;
+   float          phi;
+   float          dxy;
+   float          dz;
+   float          ptErr;
+   float          etaErr;
+   float          phiErr;
+   float          dxyErr;
+   float          dzErr;
+   float          chi2;
+   int            q;
+   unsigned int   nValid;
+   unsigned int   nPixel;
+   unsigned int   nGlued;
+   unsigned int   nStrip;
+   unsigned int   algo;
+   unsigned int   algoOriginal;
+   int            trkIdx;
+   vector<float>  shareFrac;
+   vector<int>    simTrkIdx;
+   vector<int>    hitIdx;
+   vector<int>    hitType;
+   unsigned int   offset;
+   unsigned char  hitsMask;
+   int            subDet2;
+   float          dRz2;
+   float          dPhi2;
+   float          dRz2Pos;
+   float          dPhi2Pos;
+   int            subDet1;
+   float          dRz1;
+   float          dPhi1;
+   float          dRz1Pos;
+   float          dPhi1Pos;
+   float          hoe1;
+   float          hoe2;
+   float          superClusterEnergy;
+   float          superClusterEta;
+   float          superClusterPhi;
+   float          superClusterEt;
+   int            superClusterIdx;
+   unsigned int   ecalDriven;
+   unsigned int   trkDriven;
+};
+
+
+Value<vector<Seed>>*
+register_seeds(TrackingDataSet &tds){
+    auto& builder = func<std::vector<Seed>(vector<short>,          // fitok;
+                                               vector<float>,          // px;
+                                               vector<float>,          // py;
+                                               vector<float>,          // pz;
+                                               vector<float>,          // pt;
+                                               vector<float>,          // eta;
+                                               vector<float>,          // phi;
+                                               vector<float>,          // dxy;
+                                               vector<float>,          // dz;
+                                               vector<float>,          // ptErr;
+                                               vector<float>,          // etaErr;
+                                               vector<float>,          // phiErr;
+                                               vector<float>,          // dxyErr;
+                                               vector<float>,          // dzErr;
+                                               vector<float>,          // chi2;
+                                               vector<int>,            // q;
+                                               vector<unsigned int>,   // nValid;
+                                               vector<unsigned int>,   // nPixel;
+                                               vector<unsigned int>,   // nGlued;
+                                               vector<unsigned int>,   // nStrip;
+                                               vector<unsigned int>,   // algo;
+                                               vector<unsigned int>,   // algoOriginal;
+                                               vector<int>,            // trkIdx;
+                                               vector<vector<float> >, // shareFrac;
+                                               vector<vector<int> >,   // simTrkIdx;
+                                               vector<vector<int> >,   // hitIdx;
+                                               vector<vector<int> >,   // hitType;
+                                               vector<unsigned int>,   // offset;
+                                               vector<unsigned char>,  // hitsMask;
+                                               vector<int>,            // subDet2;
+                                               vector<float>,          // dRz2;
+                                               vector<float>,          // dPhi2;
+                                               vector<float>,          // dRz2Pos;
+                                               vector<float>,          // dPhi2Pos;
+                                               vector<int>,            // subDet1;
+                                               vector<float>,          // dRz1;
+                                               vector<float>,          // dPhi1;
+                                               vector<float>,          // dRz1Pos;
+                                               vector<float>,          // dPhi1Pos;
+                                               vector<float>,          // hoe1;
+                                               vector<float>,          // hoe2;
+                                               vector<float>,          // superClusterEnergy;
+                                               vector<float>,          // superClusterEta;
+                                               vector<float>,          // superClusterPhi;
+                                               vector<float>,          // superClusterEt;
+                                               vector<int>,            // superClusterIdx;
+                                               vector<unsigned int>,   // ecalDriven;
+                                               vector<unsigned int>    // trkDriven;
+             )>("build_seeds", FUNC(([](
+               const vector<short>&  fitok,
+               const vector<float>&  px,
+               const vector<float>&  py,
+               const vector<float>&  pz,
+               const vector<float>&  pt,
+               const vector<float>&  eta,
+               const vector<float>&  phi,
+               const vector<float>&  dxy,
+               const vector<float>&  dz,
+               const vector<float>&  ptErr,
+               const vector<float>&  etaErr,
+               const vector<float>&  phiErr,
+               const vector<float>&  dxyErr,
+               const vector<float>&  dzErr,
+               const vector<float>&  chi2,
+               const vector<int>&  q,
+               const vector<unsigned int>&  nValid,
+               const vector<unsigned int>&  nPixel,
+               const vector<unsigned int>&  nGlued,
+               const vector<unsigned int>&  nStrip,
+               const vector<unsigned int>&  algo,
+               const vector<unsigned int>&  algoOriginal,
+               const vector<int>&  trkIdx,
+               const vector<vector<float> >&  shareFrac,
+               const vector<vector<int> >&  simTrkIdx,
+               const vector<vector<int> >&  hitIdx,
+               const vector<vector<int> >&  hitType,
+               const vector<unsigned int>&  offset,
+               const vector<unsigned char>&  hitsMask,
+               const vector<int>&  subDet2,
+               const vector<float>&  dRz2,
+               const vector<float>&  dPhi2,
+               const vector<float>&  dRz2Pos,
+               const vector<float>&  dPhi2Pos,
+               const vector<int>&  subDet1,
+               const vector<float>&  dRz1,
+               const vector<float>&  dPhi1,
+               const vector<float>&  dRz1Pos,
+               const vector<float>&  dPhi1Pos,
+               const vector<float>&  hoe1,
+               const vector<float>&  hoe2,
+               const vector<float>&  superClusterEnergy,
+               const vector<float>&  superClusterEta,
+               const vector<float>&  superClusterPhi,
+               const vector<float>&  superClusterEt,
+               const vector<int>&  superClusterIdx,
+               const vector<unsigned int>& ecalDriven,
+               const vector<unsigned int>& trkDriven){
+            std::vector<Seed> seeds;
+            for(int i=0; i<fitok.size(); i++)
+                seeds.push_back({fitok[i],
+                                 px[i],
+                                 py[i],
+                                 pz[i],
+                                 pt[i],
+                                 eta[i],
+                                 phi[i],
+                                 dxy[i],
+                                 dz[i],
+                                 ptErr[i],
+                                 etaErr[i],
+                                 phiErr[i],
+                                 dxyErr[i],
+                                 dzErr[i],
+                                 chi2[i],
+                                 q[i],
+                                 nValid[i],
+                                 nPixel[i],
+                                 nGlued[i],
+                                 nStrip[i],
+                                 algo[i],
+                                 algoOriginal[i],
+                                 trkIdx[i],
+                                 shareFrac[i],
+                                 simTrkIdx[i],
+                                 hitIdx[i],
+                                 hitType[i],
+                                 offset[i],
+                                 hitsMask[i],
+                                 subDet2[i],
+                                 dRz2[i],
+                                 dPhi2[i],
+                                 dRz2Pos[i],
+                                 dPhi2Pos[i],
+                                 subDet1[i],
+                                 dRz1[i],
+                                 dPhi1[i],
+                                 dRz1Pos[i],
+                                 dPhi1Pos[i],
+                                 hoe1[i],
+                                 hoe2[i],
+                                 superClusterEnergy[i],
+                                 superClusterEta[i],
+                                 superClusterPhi[i],
+                                 superClusterEt[i],
+                                 superClusterIdx[i],
+                                 ecalDriven[i],
+                                 trkDriven[i]});
+            return seeds;
+        })));
+
+
+    return apply(builder,
+        fv::tuple(tds.track_branch_obj<vector<short>>("see_fitok"),
+                 tds.track_branch_obj<vector<float>>("see_px"),
+                 tds.track_branch_obj<vector<float>>("see_py"),
+                 tds.track_branch_obj<vector<float>>("see_pz"),
+                 tds.track_branch_obj<vector<float>>("see_pt"),
+                 tds.track_branch_obj<vector<float>>("see_eta"),
+                 tds.track_branch_obj<vector<float>>("see_phi"),
+                 tds.track_branch_obj<vector<float>>("see_dxy"),
+                 tds.track_branch_obj<vector<float>>("see_dz"),
+                 tds.track_branch_obj<vector<float>>("see_ptErr"),
+                 tds.track_branch_obj<vector<float>>("see_etaErr"),
+                 tds.track_branch_obj<vector<float>>("see_phiErr"),
+                 tds.track_branch_obj<vector<float>>("see_dxyErr"),
+                 tds.track_branch_obj<vector<float>>("see_dzErr"),
+                 tds.track_branch_obj<vector<float>>("see_chi2"),
+                 tds.track_branch_obj<vector<int>>("see_q"),
+                 tds.track_branch_obj<vector<unsigned int>>("see_nValid"),
+                 tds.track_branch_obj<vector<unsigned int>>("see_nPixel"),
+                 tds.track_branch_obj<vector<unsigned int>>("see_nGlued"),
+                 tds.track_branch_obj<vector<unsigned int>>("see_nStrip"),
+                 tds.track_branch_obj<vector<unsigned int>>("see_algo"),
+                 tds.track_branch_obj<vector<unsigned int>>("see_algoOriginal"),
+                 tds.track_branch_obj<vector<int>>("see_trkIdx"),
+                 tds.track_branch_obj<vector<vector<float> >> ("see_shareFrac"),
+                 tds.track_branch_obj<vector<vector<int> >>("see_simTrkIdx"),
+                 tds.track_branch_obj<vector<vector<int> >>("see_hitIdx"),
+                 tds.track_branch_obj<vector<vector<int> >>("see_hitType"),
+                 tds.track_branch_obj<vector<unsigned int>>("see_offset"),
+                 tds.track_branch_obj<vector<unsigned char>>("see_hitsMask"),
+                 tds.track_branch_obj<vector<int>>("see_subDet2"),
+                 tds.track_branch_obj<vector<float>>("see_dRz2"),
+                 tds.track_branch_obj<vector<float>>("see_dPhi2"),
+                 tds.track_branch_obj<vector<float>>("see_dRz2Pos"),
+                 tds.track_branch_obj<vector<float>>("see_dPhi2Pos"),
+                 tds.track_branch_obj<vector<int>>("see_subDet1"),
+                 tds.track_branch_obj<vector<float>>("see_dRz1"),
+                 tds.track_branch_obj<vector<float>>("see_dPhi1"),
+                 tds.track_branch_obj<vector<float>>("see_dRz1Pos"),
+                 tds.track_branch_obj<vector<float>>("see_dPhi1Pos"),
+                 tds.track_branch_obj<vector<float>>("see_hoe1"),
+                 tds.track_branch_obj<vector<float>>("see_hoe2"),
+                 tds.track_branch_obj<vector<float>>("see_superClusterEnergy"),
+                 tds.track_branch_obj<vector<float>>("see_superClusterEta"),
+                 tds.track_branch_obj<vector<float>>("see_superClusterPhi"),
+                 tds.track_branch_obj<vector<float>>("see_superClusterEt"),
+                 tds.track_branch_obj<vector<int>>("see_superClusterIdx"),
+                 tds.track_branch_obj<vector<unsigned int>>("see_ecalDriven"),
+                 tds.track_branch_obj<vector<unsigned int>>("see_trkDriven")),
+        "seeds");
+}
+
+
+//#^#=========================================================================
+//=======================TRACK================================================
+//============================================================================
+struct Track{
+   float         px;
+   float         py;
+   float         pz;
+   float         pt;
+   float         inner_px;
+   float         inner_py;
+   float         inner_pz;
+   float         inner_pt;
+   float         outer_px;
+   float         outer_py;
+   float         outer_pz;
+   float         outer_pt;
+   float         eta;
+   float         lambda;
+   float         cotTheta;
+   float         phi;
+   float         dxy;
+   float         dz;
+   float         ptErr;
+   float         etaErr;
+   float         lambdaErr;
+   float         phiErr;
+   float         dxyErr;
+   float         dzErr;
+   float         refpoint_x;
+   float         refpoint_y;
+   float         refpoint_z;
+   float         nChi2;
+   int           q;
+   unsigned int  nValid;
+   unsigned int  nInvalid;
+   unsigned int  nPixel;
+   unsigned int  nStrip;
+   unsigned int  nPixelLay;
+   unsigned int  nStripLay;
+   unsigned int  n3DLay;
+   unsigned int  nOuterLost;
+   unsigned int  nInnerLost;
+   unsigned int  algo;
+   unsigned int  originalAlgo;
+   ULong64_t     algoMask;
+   unsigned int  stopReason;
+   short         isHP;
+   int           seedIdx;
+   float         vtxx;
+   float         vtxy;
+   float         vtxz;
+   vector<float> shareFrac;
+   vector<int>   simTrkIdx;
+   vector<int>   hitIdx;
+   vector<int>   hitType;
+   int           genIdx;
+   float         genDR;
+};
+
+Value<vector<Track>>*
+register_tracks(TrackingDataSet &tds){
+    auto& builder= func<std::vector<Track>(vector<float>,         //  px;
+                                                vector<float>,         //  py;
+                                                vector<float>,         //  pz;
+                                                vector<float>,         //  pt;
+                                                vector<float>,         //  inner_px;
+                                                vector<float>,         //  inner_py;
+                                                vector<float>,         //  inner_pz;
+                                                vector<float>,         //  inner_pt;
+                                                vector<float>,         //  outer_px;
+                                                vector<float>,         //  outer_py;
+                                                vector<float>,         //  outer_pz;
+                                                vector<float>,         //  outer_pt;
+                                                vector<float>,         //  eta;
+                                                vector<float>,         //  lambda;
+                                                vector<float>,         //  cotTheta;
+                                                vector<float>,         //  phi;
+                                                vector<float>,         //  dxy;
+                                                vector<float>,         //  dz;
+                                                vector<float>,         //  ptErr;
+                                                vector<float>,         //  etaErr;
+                                                vector<float>,         //  lambdaErr;
+                                                vector<float>,         //  phiErr;
+                                                vector<float>,         //  dxyErr;
+                                                vector<float>,         //  dzErr;
+                                                vector<float>,         //  refpoint_x;
+                                                vector<float>,         //  refpoint_y;
+                                                vector<float>,         //  refpoint_z;
+                                                vector<float>,         //  nChi2;
+                                                vector<int>,           //  q;
+                                                vector<unsigned int>,  //  nValid;
+                                                vector<unsigned int>,  //  nInvalid;
+                                                vector<unsigned int>,  //  nPixel;
+                                                vector<unsigned int>,  //  nStrip;
+                                                vector<unsigned int>,  //  nPixelLay;
+                                                vector<unsigned int>,  //  nStripLay;
+                                                vector<unsigned int>,  //  n3DLay;
+                                                vector<unsigned int>,  //  nOuterLost;
+                                                vector<unsigned int>,  //  nInnerLost;
+                                                vector<unsigned int>,  //  algo;
+                                                vector<unsigned int>,  //  originalAlgo;
+                                                vector<ULong64_t>,     //  algoMask;
+                                                vector<unsigned int>,  //  stopReason;
+                                                vector<short>,         //  isHP;
+                                                vector<int>,           //  seedIdx;
+                                                vector<float>,         //  vtxx;
+                                                vector<float>,         //  vtxy;
+                                                vector<float>,         //  vtxz;
+                                                vector<vector<float>>, //  shareFrac;
+                                                vector<vector<int>>,   //  simTrkIdx;
+                                                vector<vector<int>>,   //  hitIdx;
+                                                vector<vector<int>>,   //  hitType;
+                                                vector<int>,           //  genIdx;
+                                                vector<float>          //  genDR;
+        )>("build_tracks", FUNC(([](const vector<float>&         px,
+                                    const vector<float>&         py,
+                                    const vector<float>&         pz,
+                                    const vector<float>&         pt,
+                                    const vector<float>&         inner_px,
+                                    const vector<float>&         inner_py,
+                                    const vector<float>&         inner_pz,
+                                    const vector<float>&         inner_pt,
+                                    const vector<float>&         outer_px,
+                                    const vector<float>&         outer_py,
+                                    const vector<float>&         outer_pz,
+                                    const vector<float>&         outer_pt,
+                                    const vector<float>&         eta,
+                                    const vector<float>&         lambda,
+                                    const vector<float>&         cotTheta,
+                                    const vector<float>&         phi,
+                                    const vector<float>&         dxy,
+                                    const vector<float>&         dz,
+                                    const vector<float>&         ptErr,
+                                    const vector<float>&         etaErr,
+                                    const vector<float>&         lambdaErr,
+                                    const vector<float>&         phiErr,
+                                    const vector<float>&         dxyErr,
+                                    const vector<float>&         dzErr,
+                                    const vector<float>&         refpoint_x,
+                                    const vector<float>&         refpoint_y,
+                                    const vector<float>&         refpoint_z,
+                                    const vector<float>&         nChi2,
+                                    const vector<int>&           q,
+                                    const vector<unsigned int>&  nValid,
+                                    const vector<unsigned int>&  nInvalid,
+                                    const vector<unsigned int>&  nPixel,
+                                    const vector<unsigned int>&  nStrip,
+                                    const vector<unsigned int>&  nPixelLay,
+                                    const vector<unsigned int>&  nStripLay,
+                                    const vector<unsigned int>&  n3DLay,
+                                    const vector<unsigned int>&  nOuterLost,
+                                    const vector<unsigned int>&  nInnerLost,
+                                    const vector<unsigned int>&  algo,
+                                    const vector<unsigned int>&  originalAlgo,
+                                    const vector<ULong64_t>&     algoMask,
+                                    const vector<unsigned int>&  stopReason,
+                                    const vector<short>&         isHP,
+                                    const vector<int>&           seedIdx,
+                                    const vector<float>&         vtxx,
+                                    const vector<float>&         vtxy,
+                                    const vector<float>&         vtxz,
+                                    const vector<vector<float>>& shareFrac,
+                                    const vector<vector<int>>&   simTrkIdx,
+                                    const vector<vector<int>>&   hitIdx,
+                                    const vector<vector<int>>&   hitType,
+                                    const vector<int>&           genIdx,
+                                    const vector<float>&         genDR){
+            std::vector<Track> tracks;
+            for(int i=0; i<px.size(); i++)
+                tracks.push_back({px[i],
+                                  py[i],
+                                  pz[i],
+                                  pt[i],
+                                  inner_px[i],
+                                  inner_py[i],
+                                  inner_pz[i],
+                                  inner_pt[i],
+                                  outer_px[i],
+                                  outer_py[i],
+                                  outer_pz[i],
+                                  outer_pt[i],
+                                  eta[i],
+                                  lambda[i],
+                                  cotTheta[i],
+                                  phi[i],
+                                  dxy[i],
+                                  dz[i],
+                                  ptErr[i],
+                                  etaErr[i],
+                                  lambdaErr[i],
+                                  phiErr[i],
+                                  dxyErr[i],
+                                  dzErr[i],
+                                  refpoint_x[i],
+                                  refpoint_y[i],
+                                  refpoint_z[i],
+                                  nChi2[i],
+                                  q[i],
+                                  nValid[i],
+                                  nInvalid[i],
+                                  nPixel[i],
+                                  nStrip[i],
+                                  nPixelLay[i],
+                                  nStripLay[i],
+                                  n3DLay[i],
+                                  nOuterLost[i],
+                                  nInnerLost[i],
+                                  algo[i],
+                                  originalAlgo[i],
+                                  algoMask[i],
+                                  stopReason[i],
+                                  isHP[i],
+                                  seedIdx[i],
+                                  vtxx[i],
+                                  vtxy[i],
+                                  vtxz[i],
+                                  shareFrac[i],
+                                  simTrkIdx[i],
+                                  hitIdx[i],
+                                  hitType[i],
+                                  genIdx[i],
+                                  genDR[i]});
+            return tracks;
+        })));
+    return apply(builder,
+        fv::tuple(tds.track_branch_obj<vector<float>>("trk_px"),
+                  tds.track_branch_obj<vector<float>>("trk_py"),
+                  tds.track_branch_obj<vector<float>>("trk_pz"),
+                  tds.track_branch_obj<vector<float>>("trk_pt"),
+                  tds.track_branch_obj<vector<float>>("trk_inner_px"),
+                  tds.track_branch_obj<vector<float>>("trk_inner_py"),
+                  tds.track_branch_obj<vector<float>>("trk_inner_pz"),
+                  tds.track_branch_obj<vector<float>>("trk_inner_pt"),
+                  tds.track_branch_obj<vector<float>>("trk_outer_px"),
+                  tds.track_branch_obj<vector<float>>("trk_outer_py"),
+                  tds.track_branch_obj<vector<float>>("trk_outer_pz"),
+                  tds.track_branch_obj<vector<float>>("trk_outer_pt"),
+                  tds.track_branch_obj<vector<float>>("trk_eta"),
+                  tds.track_branch_obj<vector<float>>("trk_lambda"),
+                  tds.track_branch_obj<vector<float>>("trk_cotTheta"),
+                  tds.track_branch_obj<vector<float>>("trk_phi"),
+                  tds.track_branch_obj<vector<float>>("trk_dxy"),
+                  tds.track_branch_obj<vector<float>>("trk_dz"),
+                  tds.track_branch_obj<vector<float>>("trk_ptErr"),
+                  tds.track_branch_obj<vector<float>>("trk_etaErr"),
+                  tds.track_branch_obj<vector<float>>("trk_lambdaErr"),
+                  tds.track_branch_obj<vector<float>>("trk_phiErr"),
+                  tds.track_branch_obj<vector<float>>("trk_dxyErr"),
+                  tds.track_branch_obj<vector<float>>("trk_dzErr"),
+                  tds.track_branch_obj<vector<float>>("trk_refpoint_x"),
+                  tds.track_branch_obj<vector<float>>("trk_refpoint_y"),
+                  tds.track_branch_obj<vector<float>>("trk_refpoint_z"),
+                  tds.track_branch_obj<vector<float>>("trk_nChi2"),
+                  tds.track_branch_obj<vector<int>>("trk_q"),
+                  tds.track_branch_obj<vector<unsigned int>>("trk_nValid"),
+                  tds.track_branch_obj<vector<unsigned int>>("trk_nInvalid"),
+                  tds.track_branch_obj<vector<unsigned int>>("trk_nPixel"),
+                  tds.track_branch_obj<vector<unsigned int>>("trk_nStrip"),
+                  tds.track_branch_obj<vector<unsigned int>>("trk_nPixelLay"),
+                  tds.track_branch_obj<vector<unsigned int>>("trk_nStripLay"),
+                  tds.track_branch_obj<vector<unsigned int>>("trk_n3DLay"),
+                  tds.track_branch_obj<vector<unsigned int>>("trk_nOuterLost"),
+                  tds.track_branch_obj<vector<unsigned int>>("trk_nInnerLost"),
+                  tds.track_branch_obj<vector<unsigned int>>("trk_algo"),
+                  tds.track_branch_obj<vector<unsigned int>>("trk_originalAlgo"),
+                  tds.track_branch_obj<vector<ULong64_t>>("trk_algoMask"),
+                  tds.track_branch_obj<vector<unsigned int>>("trk_stopReason"),
+                  tds.track_branch_obj<vector<short>>("trk_isHP"),
+                  tds.track_branch_obj<vector<int>>("trk_seedIdx"),
+                  tds.track_branch_obj<vector<float>>("trk_vtxx"),
+                  tds.track_branch_obj<vector<float>>("trk_vtxy"),
+                  tds.track_branch_obj<vector<float>>("trk_vtxz"),
+                  tds.track_branch_obj<vector<vector<float>>>("trk_shareFrac"),
+                  tds.track_branch_obj<vector<vector<int>>>("trk_simTrkIdx"),
+                  tds.track_branch_obj<vector<vector<int>>>("trk_hitIdx"),
+                  tds.track_branch_obj<vector<vector<int>>>("trk_hitType"),
+                  tds.track_branch_obj<vector<int>>("trk_genIdx"),
+                  tds.track_branch_obj<vector<float>>("trk_genDR")),
+        "tracks");
+}
+
+
+//#^#=========================================================================
+//===================SIM TRACK================================================
+//============================================================================
+struct SimTrack{
+   int           event;
+   int           bunchCrossing;
+   int           pdgId;
+   float         px;
+   float         py;
+   float         pz;
+   float         pt;
+   float         eta;
+   float         phi;
+   float         pca_pt;
+   float         pca_eta;
+   float         pca_lambda;
+   float         pca_cotTheta;
+   float         pca_phi;
+   float         pca_dxy;
+   float         pca_dz;
+   int           q;
+   unsigned int  nValid;
+   unsigned int  nPixel;
+   unsigned int  nStrip;
+   unsigned int  nLay;
+   unsigned int  nPixelLay;
+   unsigned int  n3DLay;
+   vector<int>   trkIdx;
+   vector<float> shareFrac;
+   int           parentVtxIdx;
+   vector<int>   decayVtxIdx;
+   vector<int>   simHitIdx;
+};
+
+
+Value<vector<SimTrack>>*
+register_sim_tracks(TrackingDataSet &tds){
+    auto& builder = func<std::vector<SimTrack>(vector<int>,           //  event;
+                                               vector<int>,           //  bunchCrossing;
+                                               vector<int>,           //  pdgId;
+                                               vector<float>,         //  px;
+                                               vector<float>,         //  py;
+                                               vector<float>,         //  pz;
+                                               vector<float>,         //  pt;
+                                               vector<float>,         //  eta;
+                                               vector<float>,         //  phi;
+                                               vector<float>,         //  pca_pt;
+                                               vector<float>,         //  pca_eta;
+                                               vector<float>,         //  pca_lambda;
+                                               vector<float>,         //  pca_cotTheta;
+                                               vector<float>,         //  pca_phi;
+                                               vector<float>,         //  pca_dxy;
+                                               vector<float>,         //  pca_dz;
+                                               vector<int>,           //  q;
+                                               vector<unsigned int>,  //  nValid;
+                                               vector<unsigned int>,  //  nPixel;
+                                               vector<unsigned int>,  //  nStrip;
+                                               vector<unsigned int>,  //  nLay;
+                                               vector<unsigned int>,  //  nPixelLay;
+                                               vector<unsigned int>,  //  n3DLay;
+                                               vector<vector<int>>,   //  trkIdx;
+                                               vector<vector<float>>, //  shareFrac;
+                                               vector<int>,           //  parentVtxIdx;
+                                               vector<vector<int>>,   //  decayVtxIdx;
+                                               vector<vector<int>>    //  simHitIdx;
+            )>("build_sim_tracks", FUNC(([](
+               const vector<int>&           event,
+               const vector<int>&           bunchCrossing,
+               const vector<int>&           pdgId,
+               const vector<float>&         px,
+               const vector<float>&         py,
+               const vector<float>&         pz,
+               const vector<float>&         pt,
+               const vector<float>&         eta,
+               const vector<float>&         phi,
+               const vector<float>&         pca_pt,
+               const vector<float>&         pca_eta,
+               const vector<float>&         pca_lambda,
+               const vector<float>&         pca_cotTheta,
+               const vector<float>&         pca_phi,
+               const vector<float>&         pca_dxy,
+               const vector<float>&         pca_dz,
+               const vector<int>&           q,
+               const vector<unsigned int>&  nValid,
+               const vector<unsigned int>&  nPixel,
+               const vector<unsigned int>&  nStrip,
+               const vector<unsigned int>&  nLay,
+               const vector<unsigned int>&  nPixelLay,
+               const vector<unsigned int>&  n3DLay,
+               const vector<vector<int>>&   trkIdx,
+               const vector<vector<float>>& shareFrac,
+               const vector<int>&           parentVtxIdx,
+               const vector<vector<int>>&   decayVtxIdx,
+               const vector<vector<int>>&   simHitIdx){
+            std::vector<SimTrack> sim_tracks;
+            for(int i=0; i<event.size(); i++)
+                sim_tracks.push_back({
+                   event[i],
+                   bunchCrossing[i],
+                   pdgId[i],
+                   px[i],
+                   py[i],
+                   pz[i],
+                   pt[i],
+                   eta[i],
+                   phi[i],
+                   pca_pt[i],
+                   pca_eta[i],
+                   pca_lambda[i],
+                   pca_cotTheta[i],
+                   pca_phi[i],
+                   pca_dxy[i],
+                   pca_dz[i],
+                   q[i],
+                   nValid[i],
+                   nPixel[i],
+                   nStrip[i],
+                   nLay[i],
+                   nPixelLay[i],
+                   n3DLay[i],
+                   trkIdx[i],
+                   shareFrac[i],
+                   parentVtxIdx[i],
+                   decayVtxIdx[i],
+                   simHitIdx[i]
+                });
+            return sim_tracks;
+        })));
+    return apply(builder,
+        fv::tuple(tds.track_branch_obj<vector<int>>("sim_event"),
+                  tds.track_branch_obj<vector<int>>("sim_bunchCrossing"),
+                  tds.track_branch_obj<vector<int>>("sim_pdgId"),
+                  tds.track_branch_obj<vector<float>>("sim_px"),
+                  tds.track_branch_obj<vector<float>>("sim_py"),
+                  tds.track_branch_obj<vector<float>>("sim_pz"),
+                  tds.track_branch_obj<vector<float>>("sim_pt"),
+                  tds.track_branch_obj<vector<float>>("sim_eta"),
+                  tds.track_branch_obj<vector<float>>("sim_phi"),
+                  tds.track_branch_obj<vector<float>>("sim_pca_pt"),
+                  tds.track_branch_obj<vector<float>>("sim_pca_eta"),
+                  tds.track_branch_obj<vector<float>>("sim_pca_lambda"),
+                  tds.track_branch_obj<vector<float>>("sim_pca_cotTheta"),
+                  tds.track_branch_obj<vector<float>>("sim_pca_phi"),
+                  tds.track_branch_obj<vector<float>>("sim_pca_dxy"),
+                  tds.track_branch_obj<vector<float>>("sim_pca_dz"),
+                  tds.track_branch_obj<vector<int>>("sim_q"),
+                  tds.track_branch_obj<vector<unsigned int>>("sim_nValid"),
+                  tds.track_branch_obj<vector<unsigned int>>("sim_nPixel"),
+                  tds.track_branch_obj<vector<unsigned int>>("sim_nStrip"),
+                  tds.track_branch_obj<vector<unsigned int>>("sim_nLay"),
+                  tds.track_branch_obj<vector<unsigned int>>("sim_nPixelLay"),
+                  tds.track_branch_obj<vector<unsigned int>>("sim_n3DLay"),
+                  tds.track_branch_obj<vector<vector<int>>>("sim_trkIdx"),
+                  tds.track_branch_obj<vector<vector<float>>>("sim_shareFrac"),
+                  tds.track_branch_obj<vector<int>>("sim_parentVtxIdx"),
+                  tds.track_branch_obj<vector<vector<int>>>("sim_decayVtxIdx"),
+                  tds.track_branch_obj<vector<vector<int>>>("sim_simHitIdx")),
+        "sim_tracks");
+}

+ 183 - 0
analysis/tracking_validation.cpp

@@ -0,0 +1,183 @@
+#include <iostream>
+#include <vector>
+#include <utility>
+#include <numeric>
+#include <limits>
+#include <cmath>
+
+#include <TSystem.h>
+
+#include "filval/filval.hpp"
+#include "filval/root/filval.hpp"
+
+#include <boost/range/combine.hpp>
+
+#include "TrackingNtuple.h"
+#include "analysis/obj_types.cpp"
+
+using namespace std;
+using namespace fv;
+using namespace fv::root;
+
+using namespace std;
+
+#define HIT_TYPE_PIXEL 0
+#define HIT_TYPE_GLUED 1
+#define HIT_TYPE_STRIP 2
+
+Value<vector<Seed>>* seeds;
+Value<vector<PixRecHit>>* pixrec_hits;
+Value<vector<Track>>* tracks;
+Value<vector<SimHit>>* sim_hits;
+Value<vector<SimTrack>>* sim_tracks;
+
+void register_objects(TrackingDataSet& tds){
+    seeds = register_seeds(tds);
+
+    pixrec_hits = register_pixrec_hits(tds);
+    tracks = register_tracks(tds);
+
+    sim_hits = register_sim_hits(tds);
+    sim_tracks = register_sim_tracks(tds);
+}
+
+void setup_dphi_vs_eta(TrackingDataSet& tds){
+    auto& calc_dphi_vs_eta =
+    func<std::pair<vector<float>,vector<float>>(vector<Seed>,
+                                                vector<PixRecHit>,
+                                                vector<SimHit>, int)>("calc_dphi_vs_eta",
+            FUNC(([](const vector<Seed>& seeds,
+                     const vector<PixRecHit> pixrec_hits,
+                     const vector<SimHit> sim_hits,
+                     int layer){
+                vector<float> dphi;
+                vector<float> eta;
+                for(const Seed &seed : seeds){
+                    int hitIdx, hitType;
+                    for(auto tup : boost::combine(seed.hitIdx, seed.hitType)){
+                        boost::tie(hitIdx, hitType) = tup;
+                        if(hitType == HIT_TYPE_PIXEL){
+                            const PixRecHit &hit = pixrec_hits[hitIdx];
+                            if(layer && hit.lay != layer) continue;
+                            float hit_phi = atan2(hit.y, hit.x);
+                            for(const int& simHitIdx : hit.simHitIdx){
+                                const SimHit &sim_hit = sim_hits[simHitIdx];
+                                dphi.push_back(hit_phi-atan2(sim_hit.y, sim_hit.x));
+                                eta.push_back(seed.eta);
+                            }
+                        }
+                    }
+                }
+                return std::make_pair(dphi,eta);
+            })));
+
+    auto dphi_vs_eta_B1 =
+    fv::apply(calc_dphi_vs_eta, fv::tuple(seeds, pixrec_hits, sim_hits, constant<int>("1", 1)), "dphi_vs_eta_B1");
+    auto dphi_vs_eta_B2 =
+    fv::apply(calc_dphi_vs_eta, fv::tuple(seeds, pixrec_hits, sim_hits, constant<int>("2", 2)), "dphi_vs_eta_B2");
+    auto dphi_vs_eta_B3 =
+    fv::apply(calc_dphi_vs_eta, fv::tuple(seeds, pixrec_hits, sim_hits, constant<int>("3", 3)), "dphi_vs_eta_B3");
+    auto dphi_vs_eta_B4 =
+    fv::apply(calc_dphi_vs_eta, fv::tuple(seeds, pixrec_hits, sim_hits, constant<int>("4", 4)), "dphi_vs_eta_B4");
+
+
+    tds.register_container<ContainerTH2Many<float>>("dphi_vs_eta_B1", "dz vs eta (BPIX L1)",
+                                                      dphi_vs_eta_B1, 100, -0.002, 0.002, 20, -3, 3,
+                                                      "dphi",  "eta");
+    tds.register_container<ContainerTH2Many<float>>("dphi_vs_eta_B2", "dz vs eta (BPIX L2)",
+                                                      dphi_vs_eta_B2, 100, -0.002, 0.002, 20, -3, 3,
+                                                      "dphi",  "eta");
+    tds.register_container<ContainerTH2Many<float>>("dphi_vs_eta_B3", "dz vs eta (BPIX L3)",
+                                                      dphi_vs_eta_B3, 100, -0.002, 0.002, 20, -3, 3,
+                                                      "dphi",  "eta");
+    tds.register_container<ContainerTH2Many<float>>("dphi_vs_eta_B4", "dz vs eta (BPIX L4)",
+                                                      dphi_vs_eta_B4, 100, -0.002, 0.002, 20, -3, 3,
+                                                      "dphi",  "eta");
+
+}
+
+void setup_dz_vs_eta(TrackingDataSet& tds){
+    auto& calc_dz_vs_eta =
+    func<std::pair<vector<float>,vector<float>>(vector<Seed>,
+                                                vector<PixRecHit>,
+                                                vector<SimHit>, int)>("calc_dz_vs_eta",
+            FUNC(([](const vector<Seed>& seeds,
+                     const vector<PixRecHit> pixrec_hits,
+                     const vector<SimHit> sim_hits,
+                     int layer){
+                vector<float> dz;
+                vector<float> eta;
+                for(const Seed &seed : seeds){
+                    int hitIdx, hitType;
+                    for(auto tup : boost::combine(seed.hitIdx, seed.hitType)){
+                        boost::tie(hitIdx, hitType) = tup;
+                        if(hitType == HIT_TYPE_PIXEL){
+                            const PixRecHit &hit = pixrec_hits[hitIdx];
+                            if(layer && hit.lay != layer) continue;
+                            for(const int& simHitIdx : hit.simHitIdx){
+                                dz.push_back(hit.z-sim_hits[simHitIdx].z);
+                                eta.push_back(seed.eta);
+                            }
+                        }
+                    }
+                }
+                return std::make_pair(dz,eta);
+            })));
+
+    auto dz_vs_eta_B1 =
+    fv::apply(calc_dz_vs_eta, fv::tuple(seeds, pixrec_hits, sim_hits, constant<int>("1", 1)), "dz_vs_eta_B1");
+    auto dz_vs_eta_B2 =
+    fv::apply(calc_dz_vs_eta, fv::tuple(seeds, pixrec_hits, sim_hits, constant<int>("2", 2)), "dz_vs_eta_B2");
+    auto dz_vs_eta_B3 =
+    fv::apply(calc_dz_vs_eta, fv::tuple(seeds, pixrec_hits, sim_hits, constant<int>("3", 3)), "dz_vs_eta_B3");
+    auto dz_vs_eta_B4 =
+    fv::apply(calc_dz_vs_eta, fv::tuple(seeds, pixrec_hits, sim_hits, constant<int>("4", 4)), "dz_vs_eta_B4");
+
+
+    tds.register_container<ContainerTH2Many<float>>("dz_vs_eta_B1", "dz vs eta (BPIX L1)",
+                                                      dz_vs_eta_B1, 20, -0.01, .01, 20, -3, 3,
+                                                      "dz",  "eta");
+    tds.register_container<ContainerTH2Many<float>>("dz_vs_eta_B2", "dz vs eta (BPIX L2)",
+                                                      dz_vs_eta_B2, 20, -0.01, .01, 20, -3, 3,
+                                                      "dz",  "eta");
+    tds.register_container<ContainerTH2Many<float>>("dz_vs_eta_B3", "dz vs eta (BPIX L3)",
+                                                      dz_vs_eta_B3, 20, -0.01, .01, 20, -3, 3,
+                                                      "dz",  "eta");
+    tds.register_container<ContainerTH2Many<float>>("dz_vs_eta_B4", "dz vs eta (BPIX L4)",
+                                                      dz_vs_eta_B4, 20, -0.01, .01, 20, -3, 3,
+                                                      "dz",  "eta");
+
+}
+
+void run_analysis(const std::string& input_filename, const std::string& data_label, bool silent){
+    gSystem->Load("libfilval.so");
+    auto replace_suffix = [](const std::string& input, const std::string& new_suffix){
+        return input.substr(0, input.find_last_of(".")) + new_suffix;
+    };
+    string log_filename = replace_suffix(input_filename, "_result.log");
+    fv::util::Log::init_logger(log_filename, fv::util::LogPriority::kLogDebug);
+
+    string output_filename = replace_suffix(input_filename, "_result.root");
+    TrackingDataSet tds(output_filename, input_filename, data_label, "trackingNtuple/tree");
+    register_objects(tds);
+
+    setup_dz_vs_eta(tds);
+    setup_dphi_vs_eta(tds);
+
+
+    tds.process(silent);
+    tds.save_all();
+}
+
+int main(int argc, char * argv[])
+{
+    fv::util::ArgParser args(argc, argv);
+    if(!args.cmdOptionExists("-l") || !args.cmdOptionExists("-f")) {
+        cout << "Usage: ./main (-s) -l DATA_LABEL -f treefile.root" << endl;
+        return -1;
+    }
+    bool silent = args.cmdOptionExists("-s");
+    string input_filename = args.getCmdOption("-f");
+    string data_label = args.getCmdOption("-l");
+    run_analysis(input_filename, data_label, silent);
+}

+ 16 - 0
cmake/FindJupyter.cmake

@@ -0,0 +1,16 @@
+# - Find Jupyter instalation
+# This module tries to find the Jupyter installation on your system.
+
+FIND_PROGRAM(JUPYTER_EXECUTABLE NAMES jupyter)
+SET(JUPYTER_FOUND False)
+IF(NOT ${JUPYTER_EXECUTABLE} MATCHES "JUPYTER_EXECUTABLE-NOTFOUND")
+    SET(JUPYTER_FOUND True)
+    MESSAGE("-- Found Jupyter: " ${JUPYTER_EXECUTABLE})
+ENDIF(NOT ${JUPYTER_EXECUTABLE} MATCHES "JUPYTER_EXECUTABLE-NOTFOUND")
+
+FIND_PROGRAM(NBCONVERT_EXECUTABLE NAMES jupyter-nbconvert)
+SET(NBCONVERT_FOUND False)
+IF(NOT ${NBCONVERT_EXECUTABLE} MATCHES "NBCONVERT_EXECUTABLE-NOTFOUND")
+    SET(NBCONVERT_FOUND True)
+    MESSAGE("-- Found nbconvert: " ${NBCONVERT_EXECUTABLE})
+ENDIF(NOT ${NBCONVERT_EXECUTABLE} MATCHES "NBCONVERT_EXECUTABLE-NOTFOUND")

+ 237 - 0
cmake/FindROOT.cmake

@@ -0,0 +1,237 @@
+# - Find ROOT instalation
+# This module tries to find the ROOT installation on your system.
+# It tries to find the root-config script which gives you all the needed information.
+# If the system variable ROOTSYS is set this is straight forward.
+# If not the module uses the pathes given in ROOT_CONFIG_SEARCHPATH.
+# If you need an other path you should add this path to this varaible.
+# The root-config script is then used to detect basically everything else.
+# This module defines a number of key variables and macros.
+
+# F.Uhlig@gsi.de (fairroot.gsi.de)
+
+
+SET(ROOT_CONFIG_SEARCHPATH
+  ${SIMPATH}/tools/root/bin
+  $ENV{ROOTSYS}/bin
+  /usr/local/bin
+  /opt/local/bin
+  /root/bin
+)
+
+SET(ROOT_DEFINITIONS "")
+
+SET(ROOT_INSTALLED_VERSION_TOO_OLD FALSE)
+
+SET(ROOT_CONFIG_EXECUTABLE ROOT_CONFIG_EXECUTABLE-NOTFOUND)
+
+FIND_PROGRAM(ROOT_CONFIG_EXECUTABLE NAMES root-config PATHS
+   ${ROOT_CONFIG_SEARCHPATH}
+   NO_DEFAULT_PATH)
+
+IF (${ROOT_CONFIG_EXECUTABLE} MATCHES "ROOT_CONFIG_EXECUTABLE-NOTFOUND")
+  MESSAGE( FATAL_ERROR "ROOT not installed in the searchpath and ROOTSYS is not set. Please
+ set ROOTSYS or add the path to your ROOT installation in the Macro FindROOT.cmake in the
+ subdirectory cmake/modules.")
+ELSE (${ROOT_CONFIG_EXECUTABLE} MATCHES "ROOT_CONFIG_EXECUTABLE-NOTFOUND")
+  STRING(REGEX REPLACE "(^.*)/bin/root-config" "\\1" test ${ROOT_CONFIG_EXECUTABLE})
+  SET( ENV{ROOTSYS} ${test})
+  set( ROOTSYS ${test})
+ENDIF (${ROOT_CONFIG_EXECUTABLE} MATCHES "ROOT_CONFIG_EXECUTABLE-NOTFOUND")
+
+# root config is a bash script and not commonly executable under Windows
+# make some static assumptions instead
+IF (WIN32)
+  SET(ROOT_FOUND FALSE)
+  IF (ROOT_CONFIG_EXECUTABLE)
+    SET(ROOT_FOUND TRUE)
+    set(ROOT_INCLUDE_DIR ${ROOTSYS}/include)
+    set(ROOT_LIBRARY_DIR ${ROOTSYS}/lib)
+    SET(ROOT_BINARY_DIR ${ROOTSYS}/bin)
+    set(ROOT_LIBRARIES -LIBPATH:${ROOT_LIBRARY_DIR} libGpad.lib libHist.lib libGraf.lib libGraf3d.lib libTree.lib libRint.lib libPostscript.lib libMatrix.lib libPhysics.lib libMathCore.lib libRIO.lib libNet.lib libThread.lib libCore.lib libCint.lib libMinuit.lib libGui.lib libSpectrum.lib)
+    FIND_PROGRAM(ROOT_CINT_EXECUTABLE
+      NAMES rootcint
+      PATHS ${ROOT_BINARY_DIR}
+      NO_DEFAULT_PATH
+      )
+    MESSAGE(STATUS "Found ROOT: $ENV{ROOTSYS}/bin/root (WIN32/version not identified)")
+  ENDIF (ROOT_CONFIG_EXECUTABLE)
+
+ELSE(WIN32)
+
+  IF (ROOT_CONFIG_EXECUTABLE)
+
+    SET(ROOT_FOUND FALSE)
+
+    EXEC_PROGRAM(${ROOT_CONFIG_EXECUTABLE} ARGS "--version" OUTPUT_VARIABLE ROOTVERSION)
+
+    MESSAGE(STATUS "Found ROOT: $ENV{ROOTSYS}/bin/root (found version ${ROOTVERSION})")
+
+    # we need at least version 5.00/00
+    IF (NOT ROOT_MIN_VERSION)
+      SET(ROOT_MIN_VERSION "5.00/00")
+    ENDIF (NOT ROOT_MIN_VERSION)
+
+    # now parse the parts of the user given version string into variables
+    STRING(REGEX REPLACE "^([0-9]+)\\.[0-9][0-9]+\\/[0-9][0-9]+" "\\1" req_root_major_vers "${ROOT_MIN_VERSION}")
+    STRING(REGEX REPLACE "^[0-9]+\\.([0-9][0-9])+\\/[0-9][0-9]+.*" "\\1" req_root_minor_vers "${ROOT_MIN_VERSION}")
+    STRING(REGEX REPLACE "^[0-9]+\\.[0-9][0-9]+\\/([0-9][0-9]+)" "\\1" req_root_patch_vers "${ROOT_MIN_VERSION}")
+
+    # and now the version string given by qmake
+    STRING(REGEX REPLACE "^([0-9]+)\\.[0-9][0-9]+\\/[0-9][0-9]+.*" "\\1" found_root_major_vers "${ROOTVERSION}")
+    STRING(REGEX REPLACE "^[0-9]+\\.([0-9][0-9])+\\/[0-9][0-9]+.*" "\\1" found_root_minor_vers "${ROOTVERSION}")
+    STRING(REGEX REPLACE "^[0-9]+\\.[0-9][0-9]+\\/([0-9][0-9]+).*" "\\1" found_root_patch_vers "${ROOTVERSION}")
+
+    IF (found_root_major_vers LESS 5)
+      MESSAGE( FATAL_ERROR "Invalid ROOT version \"${ROOTERSION}\", at least major version 4 is required, e.g. \"5.00/00\"")
+    ENDIF (found_root_major_vers LESS 5)
+
+    # compute an overall version number which can be compared at once
+    MATH(EXPR req_vers "${req_root_major_vers}*10000 + ${req_root_minor_vers}*100 + ${req_root_patch_vers}")
+    MATH(EXPR found_vers "${found_root_major_vers}*10000 + ${found_root_minor_vers}*100 + ${found_root_patch_vers}")
+
+    IF (found_vers LESS req_vers)
+      SET(ROOT_FOUND FALSE)
+      SET(ROOT_INSTALLED_VERSION_TOO_OLD TRUE)
+    ELSE (found_vers LESS req_vers)
+      SET(ROOT_FOUND TRUE)
+    ENDIF (found_vers LESS req_vers)
+
+  ENDIF (ROOT_CONFIG_EXECUTABLE)
+
+
+  IF (ROOT_FOUND)
+
+    STRING(REGEX REPLACE "^([0-9]+)\\.[0-9][0-9]+\\/[0-9][0-9]+" "\\1" ROOT_MAJOR_VER "${ROOTVERSION}")
+    IF(ROOT_MAJOR_VER EQUAL 6)
+      MESSAGE("-- ROOT 6 detected - requiring C++11")
+      ADD_DEFINITIONS("-std=c++1y -DROOT_MAJOR_VER=6")
+    ENDIF(ROOT_MAJOR_VER EQUAL 6)
+
+    # ask root-config for the library dir
+    # Set ROOT_LIBRARY_DIR
+
+    EXEC_PROGRAM( ${ROOT_CONFIG_EXECUTABLE}
+      ARGS "--libdir"
+      OUTPUT_VARIABLE ROOT_LIBRARY_DIR_TMP )
+
+    IF(EXISTS "${ROOT_LIBRARY_DIR_TMP}")
+      SET(ROOT_LIBRARY_DIR ${ROOT_LIBRARY_DIR_TMP} )
+    ELSE(EXISTS "${ROOT_LIBRARY_DIR_TMP}")
+      MESSAGE("Warning: ROOT_CONFIG_EXECUTABLE reported ${ROOT_LIBRARY_DIR_TMP} as library path,")
+      MESSAGE("Warning: but ${ROOT_LIBRARY_DIR_TMP} does NOT exist, ROOT must NOT be installed correctly.")
+    ENDIF(EXISTS "${ROOT_LIBRARY_DIR_TMP}")
+
+    # ask root-config for the binary dir
+    EXEC_PROGRAM(${ROOT_CONFIG_EXECUTABLE}
+      ARGS "--bindir"
+      OUTPUT_VARIABLE root_bins )
+    SET(ROOT_BINARY_DIR ${root_bins})
+
+    # ask root-config for the include dir
+    EXEC_PROGRAM( ${ROOT_CONFIG_EXECUTABLE}
+      ARGS "--incdir"
+      OUTPUT_VARIABLE root_headers )
+    SET(ROOT_INCLUDE_DIR ${root_headers})
+    # CACHE INTERNAL "")
+
+    # ask root-config for the library varaibles
+    EXEC_PROGRAM( ${ROOT_CONFIG_EXECUTABLE}
+      #    ARGS "--noldflags --noauxlibs --libs"
+      ARGS "--glibs"
+      OUTPUT_VARIABLE root_flags )
+
+    #  STRING(REGEX MATCHALL "([^ ])+"  root_libs_all ${root_flags})
+    #  STRING(REGEX MATCHALL "-L([^ ])+"  root_library ${root_flags})
+    #  REMOVE_FROM_LIST(root_flags "${root_libs_all}" "${root_library}")
+
+    SET(ROOT_LIBRARIES "${root_flags} -lMinuit -lSpectrum -lTMVA")
+
+    # Make variables changeble to the advanced user
+    MARK_AS_ADVANCED( ROOT_LIBRARY_DIR ROOT_INCLUDE_DIR ROOT_DEFINITIONS)
+
+    # Set ROOT_INCLUDES
+    SET( ROOT_INCLUDES ${ROOT_INCLUDE_DIR})
+
+    SET(LD_LIBRARY_PATH ${LD_LIBRARY_PATH} ${ROOT_LIBRARY_DIR})
+
+    #######################################
+    #
+    #       Check the executables of ROOT
+    #          ( rootcint )
+    #
+    #######################################
+
+    FIND_PROGRAM(ROOT_CINT_EXECUTABLE
+      NAMES rootcint
+      PATHS ${ROOT_BINARY_DIR}
+      NO_DEFAULT_PATH
+      )
+
+  ENDIF (ROOT_FOUND)
+ENDIF(WIN32)
+
+  ###########################################
+  #
+  #       Macros for building ROOT dictionary
+  #
+  ###########################################
+
+MACRO (ROOT_GENERATE_DICTIONARY INFILES LINKDEF_FILE OUTFILE INCLUDE_DIRS_IN)
+
+  set(INCLUDE_DIRS)
+
+  foreach (_current_FILE ${INCLUDE_DIRS_IN})
+    set(INCLUDE_DIRS ${INCLUDE_DIRS} -I${_current_FILE})
+  endforeach (_current_FILE ${INCLUDE_DIRS_IN})
+
+  if (CMAKE_SYSTEM_NAME MATCHES Linux)
+    ADD_CUSTOM_COMMAND(OUTPUT ${OUTFILE}
+       COMMAND LD_LIBRARY_PATH=${ROOT_LIBRARY_DIR} ROOTSYS=${ROOTSYS} ${ROOT_CINT_EXECUTABLE}
+       ARGS -f ${OUTFILE} -c -DHAVE_CONFIG_H ${INCLUDE_DIRS} ${INFILES} ${LINKDEF_FILE} DEPENDS ${INFILES} ${LINKDEF_FILE})
+  else (CMAKE_SYSTEM_NAME MATCHES Linux)
+    if (CMAKE_SYSTEM_NAME MATCHES Darwin)
+      ADD_CUSTOM_COMMAND(OUTPUT ${OUTFILE}
+       COMMAND DYLD_LIBRARY_PATH=${ROOT_LIBRARY_DIR} ROOTSYS=${ROOTSYS} ${ROOT_CINT_EXECUTABLE}
+       ARGS -f ${OUTFILE} -c -DHAVE_CONFIG_H ${INCLUDE_DIRS} ${INFILES} ${LINKDEF_FILE} DEPENDS ${INFILES} ${LINKDEF_FILE})
+    endif (CMAKE_SYSTEM_NAME MATCHES Darwin)
+  endif (CMAKE_SYSTEM_NAME MATCHES Linux)
+
+ENDMACRO (ROOT_GENERATE_DICTIONARY)
+
+MACRO (GENERATE_ROOT_TEST_SCRIPT SCRIPT_FULL_NAME)
+
+  get_filename_component(path_name ${SCRIPT_FULL_NAME} PATH)
+  get_filename_component(file_extension ${SCRIPT_FULL_NAME} EXT)
+  get_filename_component(file_name ${SCRIPT_FULL_NAME} NAME_WE)
+  set(shell_script_name "${file_name}.sh")
+
+  #MESSAGE("PATH: ${path_name}")
+  #MESSAGE("Ext: ${file_extension}")
+  #MESSAGE("Name: ${file_name}")
+  #MESSAGE("Shell Name: ${shell_script_name}")
+
+  string(REPLACE ${PROJECT_SOURCE_DIR}
+         ${PROJECT_BINARY_DIR} new_path ${path_name}
+        )
+
+  #MESSAGE("New PATH: ${new_path}")
+
+  file(MAKE_DIRECTORY ${new_path}/data)
+
+  CONVERT_LIST_TO_STRING(${LD_LIBRARY_PATH})
+  set(MY_LD_LIBRARY_PATH ${output})
+  set(my_script_name ${SCRIPT_FULL_NAME})
+
+  if(CMAKE_SYSTEM MATCHES Darwin)
+    configure_file(${PROJECT_SOURCE_DIR}/cmake/scripts/root_macro_macos.sh.in
+                   ${new_path}/${shell_script_name}
+                  )
+  else(CMAKE_SYSTEM MATCHES Darwin)
+    configure_file(${PROJECT_SOURCE_DIR}/cmake/scripts/root_macro.sh.in
+                   ${new_path}/${shell_script_name}
+                  )
+  endif(CMAKE_SYSTEM MATCHES Darwin)
+
+  EXEC_PROGRAM(/bin/chmod ARGS "u+x  ${new_path}/${shell_script_name}")
+
+ENDMACRO (GENERATE_ROOT_TEST_SCRIPT)

+ 1 - 0
filval

@@ -0,0 +1 @@
+Subproject commit 7c5a06c426dbfff8a46a305d5b084b7f59053da9