From 0b10cc13136d6e283d57e5153e3f2f4ad7a28be6 Mon Sep 17 00:00:00 2001 From: Giulio Eulisse Date: Thu, 27 Feb 2020 16:30:32 +0100 Subject: [PATCH 1/3] DPL: introduce Analysis/DataModel We should move here all the basic building blocks of our (ALICE) AOD schema. I also extracted Gian Michele SecondaryVertex schema from the task and put it here. --- Analysis/CMakeLists.txt | 2 +- Analysis/DataModel/CMakeLists.txt | 21 +++++ .../include/Analysis/SecondaryVertex.h | 91 +++++++++++++++++++ Analysis/DataModel/src/dummy.cxx | 1 + .../DataModel}/src/dumpDataModel.cxx | 3 + Analysis/Tasks/CMakeLists.txt | 2 +- Analysis/Tasks/vertexerhf.cxx | 81 +---------------- Framework/Core/CMakeLists.txt | 6 -- 8 files changed, 119 insertions(+), 88 deletions(-) create mode 100644 Analysis/DataModel/CMakeLists.txt create mode 100644 Analysis/DataModel/include/Analysis/SecondaryVertex.h create mode 100644 Analysis/DataModel/src/dummy.cxx rename {Framework/Core => Analysis/DataModel}/src/dumpDataModel.cxx (97%) diff --git a/Analysis/CMakeLists.txt b/Analysis/CMakeLists.txt index 3404f8b1ee5f9..5f5ec9b76515e 100644 --- a/Analysis/CMakeLists.txt +++ b/Analysis/CMakeLists.txt @@ -9,6 +9,6 @@ # submit itself to any jurisdiction. add_subdirectory(Core) -#add_subdirectory(Tools) +add_subdirectory(DataModel) add_subdirectory(Tasks) add_subdirectory(Tutorials) diff --git a/Analysis/DataModel/CMakeLists.txt b/Analysis/DataModel/CMakeLists.txt new file mode 100644 index 0000000000000..a33849ddf1ed2 --- /dev/null +++ b/Analysis/DataModel/CMakeLists.txt @@ -0,0 +1,21 @@ +# Copyright CERN and copyright holders of ALICE O2. This software is distributed +# under the terms of the GNU General Public License v3 (GPL Version 3), copied +# verbatim in the file "COPYING". +# +# See http://alice-o2.web.cern.ch/license for full licensing information. +# +# In applying this license CERN does not waive the privileges and immunities +# granted to it by virtue of its status as an Intergovernmental Organization or +# submit itself to any jurisdiction. + +o2_add_library(AnalysisDataModel + SOURCES src/dummy.cxx + PRIVATE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_LIST_DIR}/src + PUBLIC_LINK_LIBRARIES + O2::Framework + ) + +o2_add_executable(dump-aod-data-model + SOURCES src/dumpDataModel.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2::AnalysisDataModel + ) diff --git a/Analysis/DataModel/include/Analysis/SecondaryVertex.h b/Analysis/DataModel/include/Analysis/SecondaryVertex.h new file mode 100644 index 0000000000000..68720b69f68be --- /dev/null +++ b/Analysis/DataModel/include/Analysis/SecondaryVertex.h @@ -0,0 +1,91 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. +#include "Framework/AnalysisDataModel.h" + +namespace o2::aod +{ +namespace secvtx2prong +{ +DECLARE_SOA_COLUMN(CollisionId, collisionId, int, "fCollisionsID"); +DECLARE_SOA_COLUMN(Posdecayx, posdecayx, float, "fPosdecayx"); +DECLARE_SOA_COLUMN(Posdecayy, posdecayy, float, "fPosdecayy"); +DECLARE_SOA_COLUMN(Posdecayz, posdecayz, float, "fPosdecayz"); +DECLARE_SOA_COLUMN(Index0, index0, int, "fIndex0"); +DECLARE_SOA_COLUMN(Px0, px0, float, "fPx0"); +DECLARE_SOA_COLUMN(Py0, py0, float, "fPy0"); +DECLARE_SOA_COLUMN(Pz0, pz0, float, "fPz0"); +DECLARE_SOA_COLUMN(Index1, index1, int, "fIndex1"); +DECLARE_SOA_COLUMN(Px1, px1, float, "fPx1"); +DECLARE_SOA_COLUMN(Py1, py1, float, "fPy1"); +DECLARE_SOA_COLUMN(Pz1, pz1, float, "fPz1"); +DECLARE_SOA_COLUMN(IndexDCApair, indexDCApair, int, "fIndexDCApair"); +DECLARE_SOA_COLUMN(Mass, mass, float, "fMass"); +DECLARE_SOA_COLUMN(Massbar, massbar, float, "fMassbar"); +DECLARE_SOA_DYNAMIC_COLUMN(DecaylengthXY, decaylengthXY, [](float xvtxd, float yvtxd, float xvtxp, float yvtxp) { return sqrtf((yvtxd - yvtxp) * (yvtxd - yvtxp) + (xvtxd - xvtxp) * (xvtxd - xvtxp)); }); +DECLARE_SOA_DYNAMIC_COLUMN(Decaylength, decaylength, [](float xvtxd, float yvtxd, float zvtxd, float xvtxp, float yvtxp, float zvtxp) { return sqrtf((yvtxd - yvtxp) * (yvtxd - yvtxp) + (xvtxd - xvtxp) * (xvtxd - xvtxp) + (zvtxd - zvtxp) * (zvtxd - zvtxp)); }); + +//old way of doing it +//DECLARE_SOA_COLUMN(Decaylength, decaylength, float, "fDecaylength"); +//DECLARE_SOA_COLUMN(DecaylengthXY, decaylengthXY, float, "fDecaylengthXY"); + +} // namespace secvtx2prong +namespace cand2prong +{ +DECLARE_SOA_COLUMN(CollisionId, collisionId, int, "fCollisionsID"); +DECLARE_SOA_COLUMN(MassD0, massD0, float, "fMassD0"); +DECLARE_SOA_COLUMN(MassD0bar, massD0bar, float, "fMassD0bar"); +} // namespace cand2prong + +DECLARE_SOA_TABLE(SecVtx2Prong, "AOD", "CAND2PRONG", + secvtx2prong::CollisionId, collision::PosX, collision::PosY, collision::PosZ, + secvtx2prong::Posdecayx, secvtx2prong::Posdecayy, secvtx2prong::Posdecayz, + secvtx2prong::Index0, secvtx2prong::Px0, secvtx2prong::Py0, secvtx2prong::Pz0, + secvtx2prong::Index1, secvtx2prong::Px1, secvtx2prong::Py1, secvtx2prong::Pz1, + secvtx2prong::IndexDCApair, secvtx2prong::Mass, secvtx2prong::Massbar, + secvtx2prong::DecaylengthXY, + secvtx2prong::Decaylength); + +DECLARE_SOA_TABLE(Cand2Prong, "AOD", "CANDDZERO", + cand2prong::CollisionId, cand2prong::MassD0, cand2prong::MassD0bar); +} // namespace o2::aod + +using namespace o2; +using namespace o2::framework; + +float decaylengthXY(float xvtxp, float yvtxp, float xvtxd, float yvtxd) +{ + float decl_ = sqrtf((yvtxd - yvtxp) * (yvtxd - yvtxp) + (xvtxd - xvtxp) * (xvtxd - xvtxp)); + return decl_; +}; + +float decaylength(float xvtxp, float yvtxp, float zvtxp, float xvtxd, float yvtxd, float zvtxd) +{ + float decl_ = sqrtf((yvtxd - yvtxp) * (yvtxd - yvtxp) + (xvtxd - xvtxp) * (xvtxd - xvtxp) + (zvtxd - zvtxp) * (zvtxd - zvtxp)); + return decl_; +}; + +float energy(float px, float py, float pz, float mass) +{ + float en_ = sqrtf(mass * mass + px * px + py * py + pz * pz); + return en_; +}; + +float invmass2prongs(float px0, float py0, float pz0, float mass0, + float px1, float py1, float pz1, float mass1) +{ + + float energy0_ = energy(px0, py0, pz0, mass0); + float energy1_ = energy(px1, py1, pz1, mass1); + float energytot = energy0_ + energy1_; + + float psum2 = (px0 + px1) * (px0 + px1) + (py0 + py1) * (py0 + py1) + (pz0 + pz1) * (pz0 + pz1); + float mass = sqrtf(energytot * energytot - psum2); + return mass; +}; diff --git a/Analysis/DataModel/src/dummy.cxx b/Analysis/DataModel/src/dummy.cxx new file mode 100644 index 0000000000000..28656363d8e9c --- /dev/null +++ b/Analysis/DataModel/src/dummy.cxx @@ -0,0 +1 @@ +#include "Analysis/SecondaryVertex.h" diff --git a/Framework/Core/src/dumpDataModel.cxx b/Analysis/DataModel/src/dumpDataModel.cxx similarity index 97% rename from Framework/Core/src/dumpDataModel.cxx rename to Analysis/DataModel/src/dumpDataModel.cxx index 10c9db49e0407..639c2e63b6560 100644 --- a/Framework/Core/src/dumpDataModel.cxx +++ b/Analysis/DataModel/src/dumpDataModel.cxx @@ -8,6 +8,7 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. #include "Framework/AnalysisDataModel.h" +#include "Analysis/SecondaryVertex.h" #include #include @@ -114,5 +115,7 @@ edge[dir=back, arrowtail=empty] dumpTable(); dumpTable(); dumpTable(); + dumpTable(); + dumpTable(); fmt::printf("%s\n", R"(})"); } diff --git a/Analysis/Tasks/CMakeLists.txt b/Analysis/Tasks/CMakeLists.txt index f8cf4891e43d2..efe1970682282 100644 --- a/Analysis/Tasks/CMakeLists.txt +++ b/Analysis/Tasks/CMakeLists.txt @@ -20,7 +20,7 @@ o2_add_executable(correlations-collection o2_add_executable(vertexing-hf SOURCES vertexerhf.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase + PUBLIC_LINK_LIBRARIES O2::Framework O2::AnalysisDataModel O2::DetectorsBase COMPONENT_NAME Analysis) o2_add_executable(validation diff --git a/Analysis/Tasks/vertexerhf.cxx b/Analysis/Tasks/vertexerhf.cxx index d36b09b87c92b..8d150c62774aa 100644 --- a/Analysis/Tasks/vertexerhf.cxx +++ b/Analysis/Tasks/vertexerhf.cxx @@ -10,6 +10,7 @@ #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" +#include "Analysis/SecondaryVertex.h" #include "DetectorsBase/DCAFitter.h" #include "ReconstructionDataFormats/Track.h" @@ -17,86 +18,6 @@ #include #include #include -namespace o2::aod -{ -namespace secvtx2prong -{ -DECLARE_SOA_COLUMN(CollisionId, collisionId, int, "fCollisionsID"); -DECLARE_SOA_COLUMN(Posdecayx, posdecayx, float, "fPosdecayx"); -DECLARE_SOA_COLUMN(Posdecayy, posdecayy, float, "fPosdecayy"); -DECLARE_SOA_COLUMN(Posdecayz, posdecayz, float, "fPosdecayz"); -DECLARE_SOA_COLUMN(Index0, index0, int, "fIndex0"); -DECLARE_SOA_COLUMN(Px0, px0, float, "fPx0"); -DECLARE_SOA_COLUMN(Py0, py0, float, "fPy0"); -DECLARE_SOA_COLUMN(Pz0, pz0, float, "fPz0"); -DECLARE_SOA_COLUMN(Index1, index1, int, "fIndex1"); -DECLARE_SOA_COLUMN(Px1, px1, float, "fPx1"); -DECLARE_SOA_COLUMN(Py1, py1, float, "fPy1"); -DECLARE_SOA_COLUMN(Pz1, pz1, float, "fPz1"); -DECLARE_SOA_COLUMN(IndexDCApair, indexDCApair, int, "fIndexDCApair"); -DECLARE_SOA_COLUMN(Mass, mass, float, "fMass"); -DECLARE_SOA_COLUMN(Massbar, massbar, float, "fMassbar"); -DECLARE_SOA_DYNAMIC_COLUMN(DecaylengthXY, decaylengthXY, [](float xvtxd, float yvtxd, float xvtxp, float yvtxp) { return sqrtf((yvtxd - yvtxp) * (yvtxd - yvtxp) + (xvtxd - xvtxp) * (xvtxd - xvtxp)); }); -DECLARE_SOA_DYNAMIC_COLUMN(Decaylength, decaylength, [](float xvtxd, float yvtxd, float zvtxd, float xvtxp, float yvtxp, float zvtxp) { return sqrtf((yvtxd - yvtxp) * (yvtxd - yvtxp) + (xvtxd - xvtxp) * (xvtxd - xvtxp) + (zvtxd - zvtxp) * (zvtxd - zvtxp)); }); - -//old way of doing it -//DECLARE_SOA_COLUMN(Decaylength, decaylength, float, "fDecaylength"); -//DECLARE_SOA_COLUMN(DecaylengthXY, decaylengthXY, float, "fDecaylengthXY"); - -} // namespace secvtx2prong -namespace cand2prong -{ -DECLARE_SOA_COLUMN(CollisionId, collisionId, int, "fCollisionsID"); -DECLARE_SOA_COLUMN(MassD0, massD0, float, "fMassD0"); -DECLARE_SOA_COLUMN(MassD0bar, massD0bar, float, "fMassD0bar"); -} // namespace cand2prong - -DECLARE_SOA_TABLE(SecVtx2Prong, "AOD", "CAND2PRONG", - secvtx2prong::CollisionId, collision::PosX, collision::PosY, collision::PosZ, - secvtx2prong::Posdecayx, secvtx2prong::Posdecayy, secvtx2prong::Posdecayz, - secvtx2prong::Index0, secvtx2prong::Px0, secvtx2prong::Py0, secvtx2prong::Pz0, - secvtx2prong::Index1, secvtx2prong::Px1, secvtx2prong::Py1, secvtx2prong::Pz1, - secvtx2prong::IndexDCApair, secvtx2prong::Mass, secvtx2prong::Massbar, - secvtx2prong::DecaylengthXY, - secvtx2prong::Decaylength); - -DECLARE_SOA_TABLE(Cand2Prong, "AOD", "CANDDZERO", - cand2prong::CollisionId, cand2prong::MassD0, cand2prong::MassD0bar); -} // namespace o2::aod - -using namespace o2; -using namespace o2::framework; - -float decaylengthXY(float xvtxp, float yvtxp, float xvtxd, float yvtxd) -{ - float decl_ = sqrtf((yvtxd - yvtxp) * (yvtxd - yvtxp) + (xvtxd - xvtxp) * (xvtxd - xvtxp)); - return decl_; -}; - -float decaylength(float xvtxp, float yvtxp, float zvtxp, float xvtxd, float yvtxd, float zvtxd) -{ - float decl_ = sqrtf((yvtxd - yvtxp) * (yvtxd - yvtxp) + (xvtxd - xvtxp) * (xvtxd - xvtxp) + (zvtxd - zvtxp) * (zvtxd - zvtxp)); - return decl_; -}; - -float energy(float px, float py, float pz, float mass) -{ - float en_ = sqrtf(mass * mass + px * px + py * py + pz * pz); - return en_; -}; - -float invmass2prongs(float px0, float py0, float pz0, float mass0, - float px1, float py1, float pz1, float mass1) -{ - - float energy0_ = energy(px0, py0, pz0, mass0); - float energy1_ = energy(px1, py1, pz1, mass1); - float energytot = energy0_ + energy1_; - - float psum2 = (px0 + px1) * (px0 + px1) + (py0 + py1) * (py0 + py1) + (pz0 + pz1) * (pz0 + pz1); - float mass = sqrtf(energytot * energytot - psum2); - return mass; -}; struct CandidateBuilding2Prong { // secondary vertex position diff --git a/Framework/Core/CMakeLists.txt b/Framework/Core/CMakeLists.txt index c21a4ae51f405..a527391ecdbee 100644 --- a/Framework/Core/CMakeLists.txt +++ b/Framework/Core/CMakeLists.txt @@ -190,12 +190,6 @@ o2_add_executable(verify-aod-file PUBLIC_LINK_LIBRARIES O2::Framework COMPONENT_NAME Framework) -o2_add_executable(dump-aod-data-model - SOURCES src/dumpDataModel.cxx - PUBLIC_LINK_LIBRARIES O2::Framework - COMPONENT_NAME Framework - ) - # tests with input data o2_data_file(COPY test/test_DataSampling.json DESTINATION tests) From 368e429da418ed96895e842c11ee6b972a3885ce Mon Sep 17 00:00:00 2001 From: Giulio Eulisse Date: Thu, 27 Feb 2020 21:48:12 +0100 Subject: [PATCH 2/3] Fix copyright. --- Analysis/DataModel/src/dummy.cxx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Analysis/DataModel/src/dummy.cxx b/Analysis/DataModel/src/dummy.cxx index 28656363d8e9c..03082405d8cf5 100644 --- a/Analysis/DataModel/src/dummy.cxx +++ b/Analysis/DataModel/src/dummy.cxx @@ -1 +1,10 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. #include "Analysis/SecondaryVertex.h" From bb2d4247f68db4fb6d12e1987d6525adb6d5d9ec Mon Sep 17 00:00:00 2001 From: Giulio Eulisse Date: Thu, 27 Feb 2020 21:49:31 +0100 Subject: [PATCH 3/3] Add guards --- Analysis/DataModel/include/Analysis/SecondaryVertex.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Analysis/DataModel/include/Analysis/SecondaryVertex.h b/Analysis/DataModel/include/Analysis/SecondaryVertex.h index 68720b69f68be..d06175da4cab4 100644 --- a/Analysis/DataModel/include/Analysis/SecondaryVertex.h +++ b/Analysis/DataModel/include/Analysis/SecondaryVertex.h @@ -7,6 +7,9 @@ // In applying this license CERN does not waive the privileges and immunities // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +#ifndef O2_ANALYSIS_SECONDARYVERTEX_H_ +#define O2_ANALYSIS_SECONDARYVERTEX_H_ + #include "Framework/AnalysisDataModel.h" namespace o2::aod @@ -89,3 +92,5 @@ float invmass2prongs(float px0, float py0, float pz0, float mass0, float mass = sqrtf(energytot * energytot - psum2); return mass; }; + +#endif // O2_ANALYSIS_SECONDARYVERTEX_H_