From 1c925534a6a27dd1c3871bce2406eb3a8f079cef Mon Sep 17 00:00:00 2001 From: ggfdsa10 Date: Thu, 26 Jun 2025 19:07:45 +0900 Subject: [PATCH 1/6] New MC tag container --- source/container/LKMCTag.cpp | 89 ++++++++++++++++++++++++++++++++++++ source/container/LKMCTag.h | 32 +++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 source/container/LKMCTag.cpp create mode 100644 source/container/LKMCTag.h diff --git a/source/container/LKMCTag.cpp b/source/container/LKMCTag.cpp new file mode 100644 index 0000000..50cb024 --- /dev/null +++ b/source/container/LKMCTag.cpp @@ -0,0 +1,89 @@ +#include "LKMCTag.h" + +LKMCTag::LKMCTag() +{ +} + +LKMCTag::~LKMCTag() +{ +} + +void LKMCTag::Clear(Option_t *option) +{ + LKContainer::Clear(option); + fIndex.clear(); + fMCID.clear(); + fWeight.clear(); +} + +void LKMCTag::Copy(TObject &obj) const +{ + ((LKMCTag&)obj).Clear(); + LKContainer::Copy(obj); + for (auto i=0; i= GetMCNum(index)) return -999; + + int tmpIdx = 0; + for(auto i=0; i= GetMCNum(index)) return -999.; + + double mcIdxWeight = 0.; + double weightSum = 0.; + int tmpIdx = 0; + for (auto i=0; i + +#include "LKContainer.h" + +class LKMCTag : public LKContainer +{ + protected: + std::vector fIndex; // Index in LKChannel + std::vector fMCID; // Truth track ID + std::vector fWeight; // Truth track weight within same index + + public: + LKMCTag(); + virtual ~LKMCTag(); + + virtual void Clear(Option_t *option = ""); + virtual void Copy (TObject &object) const; + + void AddMCTag(Int_t mcId, Int_t index=-1); + void AddMCWeightTag(Int_t mcId, Double_t weight, Int_t index=-1); + + Int_t GetMCNum(int index=-1); + Int_t GetMCID(int mcIdx=0, int index=-1); + Double_t GetMCPurity(int mcIdx=0, int index=-1); + + ClassDef(LKMCTag, 1) +}; + +#endif \ No newline at end of file From 5bd6685c3a0019d906f5087a27c2619da5f9f4b0 Mon Sep 17 00:00:00 2001 From: ggfdsa10 Date: Thu, 26 Jun 2025 19:15:11 +0900 Subject: [PATCH 2/6] Change the inheritance from LKContainer to LKChannel --- source/container/LKMCTag.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/container/LKMCTag.h b/source/container/LKMCTag.h index 48a4a7b..20688d0 100644 --- a/source/container/LKMCTag.h +++ b/source/container/LKMCTag.h @@ -3,12 +3,12 @@ #include -#include "LKContainer.h" +#include "LKChannel.h" -class LKMCTag : public LKContainer +class LKMCTag : public LKChannel { protected: - std::vector fIndex; // Index in LKChannel + std::vector fIndex; // Index in channel std::vector fMCID; // Truth track ID std::vector fWeight; // Truth track weight within same index From f711bf92682015593623959295c27d7b02f72fe8 Mon Sep 17 00:00:00 2001 From: ggfdsa10 Date: Fri, 27 Jun 2025 14:31:39 +0900 Subject: [PATCH 3/6] Change LKChannel to LKContainer --- source/container/LKMCTag.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/container/LKMCTag.h b/source/container/LKMCTag.h index 20688d0..e7db7b6 100644 --- a/source/container/LKMCTag.h +++ b/source/container/LKMCTag.h @@ -3,12 +3,12 @@ #include -#include "LKChannel.h" +#include "LKContainer.h" -class LKMCTag : public LKChannel +class LKMCTag : public LKContainer { protected: - std::vector fIndex; // Index in channel + std::vector fIndex; // Arbitrary index std::vector fMCID; // Truth track ID std::vector fWeight; // Truth track weight within same index From 44c18a96ca822850d26571f771ae772d293f5b8b Mon Sep 17 00:00:00 2001 From: ggfdsa10 Date: Fri, 27 Jun 2025 17:21:48 +0900 Subject: [PATCH 4/6] modify to the duplicated MC data add weight in exist MC index --- source/container/LKMCTag.cpp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/source/container/LKMCTag.cpp b/source/container/LKMCTag.cpp index 50cb024..4fdc8c9 100644 --- a/source/container/LKMCTag.cpp +++ b/source/container/LKMCTag.cpp @@ -27,16 +27,26 @@ void LKMCTag::Copy(TObject &obj) const void LKMCTag::AddMCTag(Int_t mcId, Int_t index) { - fIndex.push_back(index); - fMCID.push_back(mcId); - fWeight.push_back(1.); + AddMCWeightTag(mcId, 1., index); } void LKMCTag::AddMCWeightTag(Int_t mcId, Double_t weight, Int_t index) { - fIndex.push_back(index); - fMCID.push_back(mcId); - fWeight.push_back(fabs(weight)); + bool isExist = false; + for (auto i=0; i= GetMCNum(index)) return -999; int tmpIdx = 0; - for(auto i=0; i Date: Sun, 29 Jun 2025 17:02:10 +0900 Subject: [PATCH 5/6] added ClassImp and change some code format --- source/container/LKMCTag.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/container/LKMCTag.cpp b/source/container/LKMCTag.cpp index 4fdc8c9..1d63683 100644 --- a/source/container/LKMCTag.cpp +++ b/source/container/LKMCTag.cpp @@ -1,5 +1,7 @@ #include "LKMCTag.h" +ClassImp(LKMCTag) + LKMCTag::LKMCTag() { } @@ -42,7 +44,7 @@ void LKMCTag::AddMCWeightTag(Int_t mcId, Double_t weight, Int_t index) } } - if(!isExist){ + if (!isExist) { fIndex.push_back(index); fMCID.push_back(mcId); fWeight.push_back(fabs(weight)); @@ -76,7 +78,7 @@ Int_t LKMCTag::GetMCID(int mcIdx, int index) Double_t LKMCTag::GetMCPurity(int mcIdx, int index) { - if(mcIdx >= GetMCNum(index)) return -999.; + if (mcIdx >= GetMCNum(index)) return -999.; double mcIdxWeight = 0.; double weightSum = 0.; From ebc5090ff1c0acb607d3d7bc8c14e0af990aa01b Mon Sep 17 00:00:00 2001 From: ggfdsa10 Date: Mon, 30 Jun 2025 00:16:12 +0900 Subject: [PATCH 6/6] add Clear() in class constructor --- source/container/LKMCTag.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/source/container/LKMCTag.cpp b/source/container/LKMCTag.cpp index 1d63683..68c522c 100644 --- a/source/container/LKMCTag.cpp +++ b/source/container/LKMCTag.cpp @@ -4,6 +4,7 @@ ClassImp(LKMCTag) LKMCTag::LKMCTag() { + Clear(); } LKMCTag::~LKMCTag()