Browse Source

First version of PicoDst format + converter

ParfenovPeter 2 years ago
commit
6c109db697

+ 151 - 0
CMakeLists.txt

@@ -0,0 +1,151 @@
+# CMakeLists.txt for FAS package. It creates a library with dictionary and a main program
+cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
+project(PicoDst)
+
+# You need to tell CMake where to find the ROOT installation. This can be done
+# in a number of ways:
+#   - ROOT built with classic configure/make use the provided
+#   $ROOTSYS/etc/cmake/FindROOT.cmake
+#   - ROOT built with CMake. Add in CMAKE_PREFIX_PATH the installation prefix
+#   for ROOT
+
+list(APPEND CMAKE_PREFIX_PATH $ENV{ROOTSYS})
+
+#---Locate the ROOT package and defines a number of variables (e.g. ROOT_INCLUDE_DIRS)
+find_package(ROOT REQUIRED COMPONENTS MathCore RIO Hist Tree Net)
+
+set(FAIRSOFT_PATH $ENV{FAIRROOTPATH}/share/fairbase/cmake/modules)
+list(APPEND CMAKE_MODULE_PATH ${FAIRSOFT_PATH})
+find_package(FairRoot COMPONENTS Base)
+
+if(NOT FAIRROOT_FOUND)
+  message(STATUS "FairRoot package NOT found.")
+endif()
+
+#---Define useful ROOT functions and macros (e.g. ROOT_GENERATE_DICTIONARY)
+include(${ROOT_USE_FILE})
+
+
+set (CMAKE_CXX_STANDARD 11)
+add_definitions(${ROOT_CXX_FLAGS})
+
+set(CMAKE_BUILD_TYPE Debug)
+#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -Wall -pthread")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wall")
+
+set(PICO_DST_INCLUDE_DIRECTORIES
+  ${CMAKE_SOURCE_DIR}
+  "${CMAKE_SOURCE_DIR}/converter"
+  "${CMAKE_SOURCE_DIR}/include"
+  "${CMAKE_SOURCE_DIR}/src"
+  ${CMAKE_CURRENT_SOURCE_DIR}
+  ${ROOT_INLCUDE_DIRS}
+)
+
+include_directories(${PICO_DST_INCLUDE_DIRECTORIES})
+
+set(PICO_DST_INCLUDE_LIBRARIES
+  ${ROOT_LIBRARIES}
+)
+
+set(PicoDst_h_files
+  "include/PicoDstBaseEvent.h"
+  "include/PicoDstMCEvent.h"
+  "include/PicoDstRecoEvent.h"
+  "include/PicoDstBaseTrack.h"
+  "include/PicoDstMCTrack.h"
+  "include/PicoDstRecoTrack.h"
+  "include/PicoDstFHCal.h"
+)
+
+set(PicoDst_cxx_files
+  "src/PicoDstBaseEvent.cxx"
+  "src/PicoDstMCEvent.cxx"
+  "src/PicoDstRecoEvent.cxx"
+  "src/PicoDstBaseTrack.cxx"
+  "src/PicoDstMCTrack.cxx"
+  "src/PicoDstRecoTrack.cxx"
+  "src/PicoDstFHCal.cxx"
+)
+
+set(PicoDst_LinkDef
+  "include/PicoDst.LinkDef.h"
+)
+
+#---Generate dictionary
+ROOT_GENERATE_DICTIONARY(G__PicoDst
+  ${PicoDst_h_files}
+  LINKDEF ${PicoDst_LinkDef}
+)
+
+#---Compile library
+add_library(PicoDst SHARED ${PicoDst_cxx_files} G__PicoDst.cxx)
+target_link_libraries(PicoDst ${PICO_DST_INCLUDE_LIBRARIES})
+
+set(ENV{PICO_DST_BIN} "${CMAKE_CURRENT_BINARY_DIR}")
+set(ENV{PICO_DST_SRC} "${CMAKE_CURRENT_SOURCE_DIR}")
+message(STATUS "PICO_DST_BIN: " $ENV{PICO_DST_BIN})
+message(STATUS "PICO_DST_SRC: " $ENV{PICO_DST_SRC})
+set(BASH "/bin/bash")
+file( WRITE  ${CMAKE_BINARY_DIR}/setPicoDst.sh "#!${BASH}\n")
+file( APPEND ${CMAKE_BINARY_DIR}/setPicoDst.sh "\n")
+file( APPEND ${CMAKE_BINARY_DIR}/setPicoDst.sh "export PICO_DST_BIN=$ENV{PICO_DST_BIN}\n")
+file( APPEND ${CMAKE_BINARY_DIR}/setPicoDst.sh "export PICO_DST_SRC=$ENV{PICO_DST_SRC}\n")
+file( APPEND ${CMAKE_BINARY_DIR}/setPicoDst.sh "\n")
+file( APPEND ${CMAKE_BINARY_DIR}/setPicoDst.sh "export LD_LIBRARY_PATH=$PICO_DST_BIN:$LD_LIBRARY_PATH\n")
+file( APPEND ${CMAKE_BINARY_DIR}/setPicoDst.sh "export PATH=$PICO_DST_BIN:$PATH\n")
+
+if( FAIRROOT_FOUND )
+#---Compile executable
+set(MPDROOTDIR $ENV{VMCWORKDIR})
+set(PICODSTCONVERTER_INCLUDE_DIRECTORIES
+  ${FAIRROOT_INCLUDE_DIR}
+  ${MPDROOTDIR}/tpc
+  ${MPDROOTDIR}/kalman
+  ${MPDROOTDIR}/lhetrack
+  ${MPDROOTDIR}/mcstack
+  ${MPDROOTDIR}/strawendcap
+  ${MPDROOTDIR}/etof
+  ${MPDROOTDIR}/tof
+  ${MPDROOTDIR}/sft
+  ${MPDROOTDIR}/sts
+  ${MPDROOTDIR}/zdc
+  ${MPDROOTDIR}/mpddst
+  ${MPDROOTDIR}/mpdbase
+  ${MPDROOTDIR}/mpdpid
+)
+
+#---Add Needed libraries
+find_library(BASE NAMES Base PATHS ${FAIRROOT_LIBRARY_DIR})
+find_library(MCSTACK NAMES MCStack PATHS $ENV{FAIRLIBDIR})
+find_library(PASSIVE NAMES Passive PATHS $ENV{FAIRLIBDIR})
+find_library(MPDFIELD NAMES MpdField PATHS $ENV{FAIRLIBDIR})
+find_library(MPDBASE NAMES MpdBase PATHS $ENV{FAIRLIBDIR})
+find_library(MPDDST NAMES MpdDst PATHS $ENV{FAIRLIBDIR})
+find_library(MPDGENERALGENERATOR NAMES MpdGeneralGenerator PATHS $ENV{FAIRLIBDIR})
+find_library(KALMAN NAMES Kalman PATHS $ENV{FAIRLIBDIR})
+find_library(CLUSTER NAMES Cluster PATHS $ENV{FAIRLIBDIR})
+find_library(TPC NAMES tpc PATHS $ENV{FAIRLIBDIR})
+find_library(TOF NAMES Tof PATHS $ENV{FAIRLIBDIR})
+find_library(ETOF NAMES Etof PATHS $ENV{FAIRLIBDIR})
+find_library(STRAWENDCAP NAMES Strawendcap PATHS $ENV{FAIRLIBDIR})
+find_library(ZDC NAMES Zdc PATHS $ENV{FAIRLIBDIR})
+find_library(FFD NAMES Ffd PATHS $ENV{FAIRLIBDIR})
+find_library(CPC NAMES Cpc PATHS $ENV{FAIRLIBDIR})
+find_library(STRAWECT NAMES StrawECT PATHS $ENV{FAIRLIBDIR})
+find_library(LHETrack NAMES LHETrack PATHS $ENV{FAIRLIBDIR})
+find_library(STS NAMES Sts PATHS $ENV{FAIRLIBDIR})
+find_library(MPDPID NAMES MpdPid PATHS $ENV{FAIRLIBDIR})
+
+set(PICODSTCONVERTER_INCLUDE_LIBRARIES
+  PicoDst ${BASE}
+  ${MCSTACK} ${PASSIVE} ${KALMAN} ${CLUSTER} ${TPC} ${STS} ${ZDC} ${FFD}
+  ${STRAWECT} ${STRAWENDCAP} ${LHETRACK} ${TOF}
+  ${MPDFIELD} ${MPDBASE} ${MPDDST} ${MPDGENERALGENERATOR} ${MPDPID}
+)
+
+add_executable(PicoDstConverter "converter/PicoDstConverter.cpp")
+target_include_directories(PicoDstConverter PUBLIC ${PICODSTCONVERTER_INCLUDE_DIRECTORIES})
+target_link_libraries(PicoDstConverter ${PICODSTCONVERTER_INCLUDE_LIBRARIES})
+
+endif()

+ 282 - 0
converter/PicoDstConverter.cpp

@@ -0,0 +1,282 @@
+#include <iostream>
+#include <set>
+
+#include <TROOT.h>
+#include <TChain.h>
+#include <TH1.h>
+#include <TF1.h>
+#include <TFile.h>
+#include <TTree.h>
+#include <TRandom1.h>
+#include <TClonesArray.h>
+#include <TFile.h>
+#include <TTree.h>
+#include <TString.h>
+#include <TMath.h>
+#include <TSystem.h>
+#include <TVector3.h>
+#include <TStopwatch.h>
+
+#include "FairMCEventHeader.h"
+#include "FairMCTrack.h"
+#include "MpdEvent.h"
+#include "MpdZdcDigi.h"
+#include "MpdPid.h"
+#include "MpdTrack.h"
+#include "MpdKalmanTrack.h"
+#include "MpdVertex.h"
+
+#include "PicoDstMCEvent.h"
+#include "PicoDstRecoEvent.h"
+#include "PicoDstMCTrack.h"
+#include "PicoDstRecoTrack.h"
+#include "PicoDstFHCal.h"
+
+int main(int argc, char **argv)
+{
+
+  TString iFileName, oFileName;
+  if (argc < 5)
+  {
+    std::cerr << "./reducedTreeCreator -i inputfile -o outputfile" << std::endl;
+    return 1;
+  }
+  for (int i = 1; i < argc; i++)
+  {
+    if (std::string(argv[i]) != "-i" &&
+      std::string(argv[i]) != "-o")
+    {
+            std::cerr << "\n[ERROR]: Unknown parameter " << i << ": " << argv[i] << std::endl;
+      return 1;
+    }
+    else
+    {
+      if (std::string(argv[i]) == "-i" && i != argc - 1)
+      {
+        iFileName = argv[++i];
+        continue;
+      }
+      if (std::string(argv[i]) == "-i" && i == argc - 1)
+      {
+        std::cerr << "\n[ERROR]: Input file name was not specified " << std::endl;
+        return 1;
+      }
+      if (std::string(argv[i]) == "-o" && i != argc - 1)
+      {
+        oFileName = argv[++i];
+        continue;
+      }
+      if (std::string(argv[i]) == "-o" && i == argc - 1)
+      {
+        std::cerr << "\n[ERROR]: Output file name was not specified " << std::endl;
+        return 1;
+      }
+    }
+  }
+
+  TStopwatch timer;
+  timer.Start();
+
+  ///////////////////////////////////////////
+  //TChain *dstTree;
+  TFile *fi = new TFile(iFileName.Data(),"read");
+  TTree  *dstTree = (TTree*) fi->Get("mpdsim");
+
+  TFile *outFile = new TFile(oFileName.Data(), "RECREATE");
+  
+  // TTree connfiguration
+  TTree *outTree = new TTree("picodst","Pico Dst for flow calculations at MPD");
+
+  const Double_t PIDsigM = 4.0;
+  const Double_t PIDsigE = 4.0;
+  const Double_t PIDenergy = 11.;
+  const Double_t PIDkoeff = 1.;
+  const TString PIDgenerator = "URQMD";
+  const TString PIDtracking = "CF";
+  const TString PIDparticles = "pikapr";
+  const Int_t   Num_Of_Modules = 90;
+
+  MpdPid *pid = new MpdPid(PIDsigM, PIDsigE, PIDenergy, PIDkoeff, PIDgenerator, PIDtracking, PIDparticles);
+
+  // PicoDst-related variables
+  PicoDstMCEvent *mcEvent = new PicoDstMCEvent();
+  PicoDstRecoEvent *recoEvent = new PicoDstRecoEvent();
+  TClonesArray *mcTracks = new TClonesArray("PicoDstMCTrack");
+  TClonesArray *recoTracks = new TClonesArray("PicoDstRecoTrack");
+  TClonesArray *fhcalModules = new TClonesArray("PicoDstFHCal");
+
+  outTree->Branch("mcevent.",     &mcEvent,      32000,  99);
+  outTree->Branch("recoevent.",   &recoEvent,    32000,  99);
+  outTree->Branch("mctracks",     &mcTracks,     256000, 99);
+  outTree->Branch("recotracks",   &recoTracks,   256000, 99);
+  outTree->Branch("FHCalModules", &fhcalModules, 128000, 99);
+  mcTracks->BypassStreamer();
+  recoTracks->BypassStreamer();
+  fhcalModules->BypassStreamer();
+
+  FairMCEventHeader *MCHeader;
+  TClonesArray *MCTracks;
+  MpdEvent *MPDEvent;
+  TClonesArray *FHCalHits;
+  TClonesArray *MpdGlobalTracks;
+  MpdZdcDigi *FHCalHit;
+  //TClonesArray *mpdKalmanTracks;
+  TClonesArray *vertexes;
+
+  MCHeader = nullptr;
+  MCTracks = nullptr;
+  MPDEvent = nullptr;
+  FHCalHits = nullptr;
+  //mpdKalmanTracks = nullptr;
+  vertexes = nullptr;
+
+  dstTree->SetBranchAddress("MCEventHeader.", &MCHeader);
+  dstTree->SetBranchAddress("MCTrack", &MCTracks);
+  dstTree->SetBranchAddress("MPDEvent.", &MPDEvent);
+  dstTree->SetBranchAddress("ZdcDigi", &FHCalHits);
+  //dstTree->SetBranchAddress("TpcKalmanTrack", &mpdKalmanTracks);
+  dstTree->SetBranchAddress("Vertex", &vertexes);
+
+  // Starting event loop
+  TVector3 primaryVertex;
+  //std::set <Int_t> UsedMCTracks;
+  std::map <Int_t,Int_t> InitMcRecoId; // map[init-mc-id] = reco-id
+  std::map <Int_t,Int_t> InitMcNewMcId; // map[old-mc-id] = new-mc-id
+  Float_t FHCalSumEnergy[Num_Of_Modules];
+  Int_t n_entries = dstTree->GetEntriesFast();
+  Bool_t isGoodPID;
+  Short_t charge_mpd;
+  for (int iEv = 0; iEv < n_entries; iEv++)
+  {
+    std::cout << "EVENT N " << iEv << std::endl;
+    dstTree->GetEntry(iEv);
+
+    mcTracks->Clear();
+    recoTracks->Clear();
+    InitMcRecoId.clear();
+    InitMcNewMcId.clear();
+    for (int i=0; i<Num_Of_Modules; i++)
+    {
+      FHCalSumEnergy[i] = 0.;
+    }
+
+    // Read MC Event
+    mcEvent->SetB(MCHeader->GetB());
+    mcEvent->SetPhiRP(MCHeader->GetRotZ());
+    mcEvent->SetVertex(MCHeader->GetX(), MCHeader->GetY(), MCHeader->GetZ());
+
+    // Reading Reco Event
+    MpdVertex *vertex = (MpdVertex *)vertexes->First();
+    vertex->Position(primaryVertex);
+    recoEvent->SetVertex(primaryVertex.X(), primaryVertex.Y(), primaryVertex.Z());
+
+    // Read energy reconstructed in the FHCal modules
+    Int_t number_of_FHCal_hits = FHCalHits->GetEntriesFast();
+    for(int ihit=0; ihit<number_of_FHCal_hits; ihit++)
+    {
+      FHCalHit = (MpdZdcDigi*) FHCalHits->UncheckedAt(ihit);
+      Int_t DetId = FHCalHit->GetDetectorID();
+      FHCalSumEnergy[(FHCalHit->GetModuleID()-1)+(Num_Of_Modules/2)*(DetId-1)] += FHCalHit->GetELoss();
+    }
+    // Fill fDetectorID = 1 part
+    for (int imodule=0; imodule<Num_Of_Modules; imodule++)
+    {
+      PicoDstFHCal *fhcalModule = (PicoDstFHCal*)fhcalModules->ConstructedAt(imodule);
+      fhcalModule->SetEnergy(FHCalSumEnergy[imodule]);
+    }
+    
+    // Reading Reco Tracks
+    MpdGlobalTracks = (TClonesArray*)MPDEvent->GetGlobalTracks();
+    for (int itrack=0; itrack<MpdGlobalTracks->GetEntriesFast(); itrack++)
+    {
+      MpdTrack* mpdtrack = (MpdTrack*) MpdGlobalTracks->UncheckedAt(itrack);
+      InitMcRecoId[mpdtrack->GetID()] = itrack;
+      PicoDstRecoTrack *recoTrack = (PicoDstRecoTrack*)recoTracks->ConstructedAt(itrack);
+      
+      recoTrack->SetInitialMcId(mpdtrack->GetID());
+      recoTrack->SetPx(mpdtrack->GetPx());
+      recoTrack->SetPy(mpdtrack->GetPy());
+      recoTrack->SetPz(mpdtrack->GetPz());
+      recoTrack->SetNhits(mpdtrack->GetNofHits());
+      recoTrack->SetNhitsPoss(mpdtrack->GetNofHitsPossTpc());
+      recoTrack->SetTofMass2(mpdtrack->GetTofMass2());
+      recoTrack->SetTofFlag(mpdtrack->GetTofFlag());
+      recoTrack->SetTpcdEdx(mpdtrack->GetdEdXTPC());
+      recoTrack->SetChi2(mpdtrack->GetChi2());
+      recoTrack->SetDCAx(mpdtrack->GetDCAX());
+      recoTrack->SetDCAy(mpdtrack->GetDCAY());
+      recoTrack->SetDCAz(mpdtrack->GetDCAZ());
+      charge_mpd = (mpdtrack->GetPt() < 0) ? 1 : -1;
+      recoTrack->SetCharge(charge_mpd);
+
+      // PID
+      if (mpdtrack->GetTofFlag() == 2 || mpdtrack->GetTofFlag() == 6)
+      {
+        isGoodPID = pid->FillProbs(TMath::Abs(mpdtrack->GetPt()) * TMath::CosH(mpdtrack->GetEta()),
+                                   mpdtrack->GetdEdXTPC(), mpdtrack->GetTofMass2(), charge_mpd);
+      }
+      else
+      {
+        isGoodPID = pid->FillProbs(TMath::Abs(mpdtrack->GetPt()) * TMath::CosH(mpdtrack->GetEta()),
+                                   mpdtrack->GetdEdXTPC(), charge_mpd);
+      }
+
+      if (isGoodPID)
+      {
+        recoTrack->SetPidProbPion(pid->GetProbPi());   //mpdtrack->GetTPCPidProbPion();
+        recoTrack->SetPidProbKaon(pid->GetProbKa());   //mpdtrack->GetTPCPidProbKaon();
+        recoTrack->SetPidProbProton(pid->GetProbPr()); //mpdtrack->GetTPCPidProbProton();
+      }
+      else
+      {
+        recoTrack->SetPidProbPion(-999.);
+        recoTrack->SetPidProbKaon(-999.);
+        recoTrack->SetPidProbProton(-999.);
+      }
+    }
+
+    // Reading MC Tracks
+    int mcTrackCounter = 0;
+    for (int imctrack=0; imctrack<MCTracks->GetEntriesFast(); imctrack++)
+    {
+      FairMCTrack *mctrack = (FairMCTrack*) MCTracks->UncheckedAt(imctrack);
+      bool isUsed = (InitMcRecoId.count(imctrack));
+
+      // If motherId != 1 and mc track doesn't relate to any reco track - skip
+      //if (mctrack->GetMotherId() != -1) continue;
+      if (mctrack->GetMotherId() != -1 && !isUsed) continue;
+      if (isUsed) //std::cout << "VVVVVVV" << std::endl;
+      {
+        InitMcNewMcId[imctrack] = mcTrackCounter;
+      }
+      PicoDstMCTrack *mcPicoTrack = (PicoDstMCTrack*)mcTracks->ConstructedAt(mcTrackCounter);
+      mcPicoTrack->SetInitialId(imctrack);
+      mcPicoTrack->SetPx(mctrack->GetPx());
+      mcPicoTrack->SetPy(mctrack->GetPy());
+      mcPicoTrack->SetPz(mctrack->GetPz());
+      mcPicoTrack->SetMotherId(mctrack->GetMotherId());
+      mcPicoTrack->SetPdg(mctrack->GetPdgCode());
+      mcPicoTrack->SetEnergy(mctrack->GetEnergy());
+      mcTrackCounter++;
+    }
+
+    for (int itrack=0; itrack<recoTracks->GetEntriesFast(); itrack++)
+    {
+      PicoDstRecoTrack *recoTrack = (PicoDstRecoTrack*) recoTracks->UncheckedAt(itrack);
+      MpdTrack* mpdtrack = (MpdTrack*) MpdGlobalTracks->UncheckedAt(itrack);
+      recoTrack->SetMcId(InitMcNewMcId[mpdtrack->GetID()]);
+    }
+
+    outTree->Fill();
+  } // End of the Event loop
+
+  outFile->cd();
+  outTree->Print();
+  outTree->Write();
+  outFile->Close();
+
+  timer.Stop();
+  timer.Print();
+
+  return 0;
+}

+ 16 - 0
include/PicoDst.LinkDef.h

@@ -0,0 +1,16 @@
+#ifdef __CINT__
+
+#pragma link off all global;
+#pragma link off all classes;
+#pragma link off all functions;
+//#pragma link off all extern;
+
+#pragma link C++ class PicoDstBaseEvent+;
+#pragma link C++ class PicoDstMCEvent+;
+#pragma link C++ class PicoDstRecoEvent+;
+#pragma link C++ class PicoDstBaseTrack+;
+#pragma link C++ class PicoDstMCTrack+;
+#pragma link C++ class PicoDstRecoTrack+;
+#pragma link C++ class PicoDstFHCal+;
+
+#endif

+ 27 - 0
include/PicoDstBaseEvent.h

@@ -0,0 +1,27 @@
+#ifndef PICODST_BASE_EVENT_H
+#define PICODST_BASE_EVENT_H
+
+#include <TROOT.h>
+#include <TVector3.h>
+
+class PicoDstBaseEvent
+{
+private:
+  TVector3 fVertex;
+public:
+  PicoDstBaseEvent();
+  virtual ~PicoDstBaseEvent();
+
+  // Setters
+  virtual void SetVertex(Float_t _x, Float_t _y, Float_t _z){ fVertex.SetXYZ(_x,_y,_z); }
+
+  // Getters
+  virtual TVector3 GetVertex() const { return fVertex; }
+  virtual Float_t  GetVertexX() const { return fVertex.X(); }
+  virtual Float_t  GetVertexY() const { return fVertex.Y(); }
+  virtual Float_t  GetVertexZ() const { return fVertex.Z(); }
+  
+  ClassDef(PicoDstBaseEvent,1);
+};
+
+#endif

+ 46 - 0
include/PicoDstBaseTrack.h

@@ -0,0 +1,46 @@
+#ifndef PICODST_BASE_TRACK_H
+#define PICODST_BASE_TRACK_H
+
+#include <TROOT.h>
+#include <TObject.h>
+#include <TVector3.h>
+
+class PicoDstBaseTrack : public TObject
+{
+private:
+  TVector3 fMom;
+  TVector3 fDCA;
+public:
+  PicoDstBaseTrack();
+  virtual ~PicoDstBaseTrack();
+
+  virtual void Clear(Option_t *option = "") { TObject::Clear(option); fMom.SetXYZ(0,0,0); fDCA.SetXYZ(0,0,0); }
+
+  // Setters
+  virtual void SetPxPyPz(Float_t _px, Float_t _py, Float_t _pz) { fMom.SetXYZ(_px,_py,_pz); }
+  virtual void SetPx(Float_t _a) { fMom.SetX(_a); }
+  virtual void SetPy(Float_t _a) { fMom.SetY(_a); }
+  virtual void SetPz(Float_t _a) { fMom.SetZ(_a); }
+  virtual void SetDCA(Float_t _dcax, Float_t _dcay, Float_t _dcaz) { fDCA.SetXYZ(_dcax,_dcay,_dcaz); }
+  virtual void SetDCAx(Float_t _a) { fDCA.SetX(_a); }
+  virtual void SetDCAy(Float_t _a) { fDCA.SetY(_a); }
+  virtual void SetDCAz(Float_t _a) { fDCA.SetZ(_a); }
+
+  // Getters
+  virtual TVector3 GetMom() { return fMom; }
+  virtual Float_t  GetPx() { return fMom.X(); }
+  virtual Float_t  GetPy() { return fMom.Y(); }
+  virtual Float_t  GetPz() { return fMom.Z(); }
+  virtual Float_t  GetPt() { return fMom.Perp(); }
+  virtual Float_t  GetP() { return fMom.Mag(); }
+  virtual Float_t  GetEta() { return fMom.Eta(); }
+  virtual Float_t  GetPhi() { return fMom.Phi(); }
+  virtual TVector3 GetDCA() { return fDCA; }
+  virtual Float_t  GetDCAx() { return fDCA.X(); }
+  virtual Float_t  GetDCAy() { return fDCA.Y(); }
+  virtual Float_t  GetDCAz() { return fDCA.Z(); }
+
+  ClassDef(PicoDstBaseTrack,1);
+};
+
+#endif

+ 26 - 0
include/PicoDstFHCal.h

@@ -0,0 +1,26 @@
+#ifndef PICIODST_FHCAL_H
+#define PICIODST_FHCAL_H
+
+#include <TROOT.h>
+#include <TObject.h>
+
+class PicoDstFHCal : public TObject
+{
+private:
+  Float_t fEnergy;
+public:
+  PicoDstFHCal();
+  virtual ~PicoDstFHCal();
+
+  virtual void Clear(Option_t *option = "");
+
+  // Setters
+  virtual void SetEnergy(Float_t _a) { fEnergy = _a; }
+
+  // Getters
+  virtual Float_t GetEnergy() const { return fEnergy; }
+
+  ClassDef(PicoDstFHCal,1);
+};
+
+#endif

+ 28 - 0
include/PicoDstMCEvent.h

@@ -0,0 +1,28 @@
+#ifndef PICODST_MC_EVENT_H
+#define PICODST_MC_EVENT_H
+
+#include <TROOT.h>
+#include <TObject.h>
+#include "PicoDstBaseEvent.h"
+
+class PicoDstMCEvent : public PicoDstBaseEvent, public TObject
+{
+private:
+  Float_t fB;
+  Float_t fPhiRP;
+public:
+  PicoDstMCEvent();
+  virtual ~PicoDstMCEvent();
+
+  // Setters
+  virtual void SetB(Float_t _a) { fB = _a; }
+  virtual void SetPhiRP(Float_t _a) { fPhiRP = _a; }
+
+  // Getters
+  virtual Float_t GetB() const { return fB; }
+  virtual Float_t GetPhiRP() const { return fPhiRP; }
+
+  ClassDef(PicoDstMCEvent,1);
+};
+
+#endif

+ 35 - 0
include/PicoDstMCTrack.h

@@ -0,0 +1,35 @@
+#ifndef PICODST_MC_TRACK_H
+#define PICODST_MC_TRACK_H
+
+#include <TROOT.h>
+#include "PicoDstBaseTrack.h"
+
+class PicoDstMCTrack : public PicoDstBaseTrack
+{
+private:
+  Int_t fMotherId;
+  Int_t fPdg;
+  Float_t fEnergy;
+  Int_t  fInitialId;
+public:
+  PicoDstMCTrack();
+  virtual ~PicoDstMCTrack();
+
+  virtual void Clear(Option_t *option = "");
+
+  // Setters
+  virtual void SetInitialId(Int_t _a) { fInitialId = _a; }
+  virtual void SetMotherId(Int_t _a) { fMotherId = _a; }
+  virtual void SetPdg(Int_t _a) { fPdg = _a; }
+  virtual void SetEnergy(Float_t _a) { fEnergy = _a; }
+
+  // Getters
+  virtual Int_t GetInitialId() const { return fInitialId; }
+  virtual Int_t GetMotherId() const { return fMotherId; }
+  virtual Int_t GetPdg() const { return fPdg; }
+  virtual Float_t GetEnergy() const { return fEnergy; }
+
+  ClassDef(PicoDstMCTrack,1);
+};
+
+#endif

+ 16 - 0
include/PicoDstRecoEvent.h

@@ -0,0 +1,16 @@
+#ifndef PICODST_RECO_EVENT_H
+#define PICODST_RECO_EVENT_H
+
+#include <TROOT.h>
+#include "PicoDstBaseEvent.h"
+
+class PicoDstRecoEvent : public PicoDstBaseEvent, public TObject
+{
+public:
+  PicoDstRecoEvent();
+  virtual ~PicoDstRecoEvent();
+
+  ClassDef(PicoDstRecoEvent,1);
+};
+
+#endif

+ 58 - 0
include/PicoDstRecoTrack.h

@@ -0,0 +1,58 @@
+#ifndef PICODST_RECO_TRACK_H
+#define PICODST_RECO_TRACK_H
+
+#include "PicoDstBaseTrack.h"
+
+class PicoDstRecoTrack : public PicoDstBaseTrack
+{
+private:
+  Int_t fId; // Id of the corresponding MC track
+  Int_t fInitialId; // Initial Id of the corresponding MC track
+  Int_t fTofFlag;
+  Float_t fTpcdEdx;
+  Float_t fTofMass2;
+  Float_t fPidProbPion;
+  Float_t fPidProbKaon;
+  Float_t fPidProbProton;
+  Float_t fChi2;
+  Int_t fNhits;
+  Int_t fNhitsPoss;
+  Short_t fChargeSign;
+public:
+  PicoDstRecoTrack();
+  virtual ~PicoDstRecoTrack();
+
+  virtual void Clear(Option_t *option = "");
+
+  // Setters
+  virtual void SetInitialMcId(Int_t _a) { fInitialId = _a; }
+  virtual void SetMcId(Int_t _a) { fId = _a; }
+  virtual void SetTofFlag(Int_t _a) { fTofFlag = _a; }
+  virtual void SetTpcdEdx(Float_t _a) { fTpcdEdx = _a; }
+  virtual void SetTofMass2(Float_t _a) { fTofMass2 = _a; }
+  virtual void SetPidProbPion(Float_t _a) { fPidProbPion = _a; }
+  virtual void SetPidProbKaon(Float_t _a) { fPidProbKaon = _a; }
+  virtual void SetPidProbProton(Float_t _a) { fPidProbProton = _a; }
+  virtual void SetChi2(Float_t _a) { fChi2 = _a; }
+  virtual void SetNhits(Int_t _a) { fNhits = _a; }
+  virtual void SetNhitsPoss(Int_t _a) { fNhitsPoss = _a; }
+  virtual void SetCharge(Short_t _a) { fChargeSign = _a; }
+  
+  // Getters
+  virtual Int_t   GetInitialMcId() const { return fInitialId; }
+  virtual Int_t   GetMcId() const { return fId; }
+  virtual Int_t   GetTofFlag() const { return fTofFlag; }
+  virtual Float_t GetTpcdEdx() const { return fTpcdEdx; }
+  virtual Float_t GetTofMass2() const { return fTofMass2; }
+  virtual Float_t GetPidProbPion() const { return fPidProbPion; }
+  virtual Float_t GetPidProbKaon() const { return fPidProbKaon; }
+  virtual Float_t GetPidProbProton() const { return fPidProbProton; }
+  virtual Float_t GetChi2() const { return fChi2; }
+  virtual Int_t   GetNhits() const { return fNhits; }
+  virtual Int_t   GetNhitsPoss() const { return fNhitsPoss; }
+  virtual Short_t GetCharge() const { return fChargeSign; }
+
+  ClassDef(PicoDstRecoTrack,1);
+};
+
+#endif

+ 22 - 0
macros/test_Ids.C

@@ -0,0 +1,22 @@
+R__LOAD_LIBRARY(/nica/mpd21/parfenov/mpd_winter2019/winter_scripts/build_test/PicoDst/libPicoDst.so)
+
+void test_Ids()
+{
+  TFile *fi = new TFile("test_picodst.root","read");
+  TTree *tree = (TTree*) fi->Get("picodst");
+  TClonesArray *recoTracks = nullptr;
+  TClonesArray *mcTracks = nullptr;
+  tree->SetBranchAddress("mctracks",&mcTracks);
+  tree->SetBranchAddress("recotracks",&recoTracks);
+  for (int iEv=0; iEv<tree->GetEntriesFast(); iEv++)
+  { 
+    tree->GetEntry(iEv); 
+    for (int i=0; i<recoTracks->GetEntriesFast(); i++)
+    { 
+      auto recoTrack = (PicoDstRecoTrack*) recoTracks->UncheckedAt(i); 
+      auto mcTrack = (PicoDstMCTrack*) mcTracks->UncheckedAt(recoTrack->GetMcId()); 
+      if (recoTrack->GetInitialMcId() != mcTrack->GetInitialId()) 
+        std::cout << "Event " << iEv << ", recotrack " << i << ": InitMcId(reco)= " << recoTrack->GetInitialMcId() << ", InitMcId(mc)= " << mcTrack->GetInitialId() << ", McId= " << recoTrack->GetMcId() << std::endl; 
+    } 
+  }
+}

+ 11 - 0
src/PicoDstBaseEvent.cxx

@@ -0,0 +1,11 @@
+#include "PicoDstBaseEvent.h"
+
+ClassImp(PicoDstBaseEvent);
+
+PicoDstBaseEvent::PicoDstBaseEvent()
+{
+}
+
+PicoDstBaseEvent::~PicoDstBaseEvent()
+{
+}

+ 12 - 0
src/PicoDstBaseTrack.cxx

@@ -0,0 +1,12 @@
+#include "PicoDstBaseTrack.h"
+
+ClassImp(PicoDstBaseTrack);
+
+PicoDstBaseTrack::PicoDstBaseTrack()
+{
+}
+
+PicoDstBaseTrack::~PicoDstBaseTrack()
+{
+  Clear();
+}

+ 18 - 0
src/PicoDstFHCal.cxx

@@ -0,0 +1,18 @@
+#include "PicoDstFHCal.h"
+
+ClassImp(PicoDstFHCal);
+
+PicoDstFHCal::PicoDstFHCal()
+{
+}
+
+PicoDstFHCal::~PicoDstFHCal()
+{
+  Clear();
+}
+
+void PicoDstFHCal::Clear(Option_t *option)
+{
+  TObject::Clear(option);
+  fEnergy = 0;
+}

+ 11 - 0
src/PicoDstMCEvent.cxx

@@ -0,0 +1,11 @@
+#include "PicoDstMCEvent.h"
+
+ClassImp(PicoDstMCEvent);
+
+PicoDstMCEvent::PicoDstMCEvent()
+{
+}
+
+PicoDstMCEvent::~PicoDstMCEvent()
+{
+}

+ 20 - 0
src/PicoDstMCTrack.cxx

@@ -0,0 +1,20 @@
+#include "PicoDstMCTrack.h"
+
+ClassImp(PicoDstMCTrack);
+
+PicoDstMCTrack::PicoDstMCTrack()
+{
+}
+
+PicoDstMCTrack::~PicoDstMCTrack()
+{
+  Clear();
+}
+
+void PicoDstMCTrack::Clear(Option_t *option)
+{
+  PicoDstBaseTrack::Clear(option);
+  fMotherId = 0;
+  fPdg = 0;
+  fEnergy = 0.;
+}

+ 11 - 0
src/PicoDstRecoEvent.cxx

@@ -0,0 +1,11 @@
+#include "PicoDstRecoEvent.h"
+
+ClassImp(PicoDstRecoEvent);
+
+PicoDstRecoEvent::PicoDstRecoEvent()
+{
+}
+
+PicoDstRecoEvent::~PicoDstRecoEvent()
+{
+}

+ 28 - 0
src/PicoDstRecoTrack.cxx

@@ -0,0 +1,28 @@
+#include "PicoDstRecoTrack.h"
+
+ClassImp(PicoDstRecoTrack);
+
+PicoDstRecoTrack::PicoDstRecoTrack()
+{
+}
+
+PicoDstRecoTrack::~PicoDstRecoTrack()
+{
+  Clear();
+}
+
+void PicoDstRecoTrack::Clear(Option_t *option)
+{
+  PicoDstBaseTrack::Clear(option);
+  fId = 0;
+  fTofFlag = 0;
+  fTpcdEdx = 0.;
+  fTofMass2 = 0.;
+  fPidProbPion = 0.;
+  fPidProbKaon = 0.;
+  fPidProbProton = 0.;
+  fChi2 = 0.;
+  fNhits = 0;
+  fNhitsPoss = 0;
+  fChargeSign = 0;
+}