diff --git a/.gitignore b/.gitignore index 084a2be968c4e983d82198b07a66187b2de24480..8c6a4ddd21d2324b5212cd35417606841aa87de5 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ objs run *.root dict/* +tmp diff --git a/include/TSMerger.h b/include/TSMerger.h index 0b52d05380e390026aaaf60a6fa3d35e262a0ffe..afb200d1bfca3944271e5e3bf6748043d68ed8d4 100644 --- a/include/TSMerger.h +++ b/include/TSMerger.h @@ -6,6 +6,9 @@ #include #include + +#include "Print.h" + #include #include #include @@ -46,9 +49,9 @@ class TSMerger while ( ! obj1.end() || ! obj2.end() ) { if ((obj1.getTimeStamp() > obj2.getTimeStamp() || obj1.end()) && !obj2.end()) { ++obj2; - obj1.set_null(); + obj1.unset(); } else if ((obj1.getTimeStamp() < obj2.getTimeStamp() || obj2.end()) && !obj1.end()) { - obj2.set_null(); + obj2.unset(); ++obj1; } else if ( !obj1.end() && !obj2.end()) { ++obj1; @@ -71,9 +74,9 @@ class TSMerger while ( ! obj1.end() || ! obj2.end() ) { if ((obj1.getTimeStamp() > obj2.getTimeStamp() || obj1.end()) && !obj2.end()) { ++obj2; - obj1.set_null(); + obj1.unset(); } else if ((obj1.getTimeStamp() < obj2.getTimeStamp() || obj2.end()) && !obj1.end()) { - obj2.set_null(); + obj2.unset(); ++obj1; } else if ( !obj1.end() && !obj2.end()) { ++obj1; @@ -100,7 +103,7 @@ class TSObjectMerger TFile* output_file = nullptr; TTree* output = nullptr; - std::string branch_name = "tree"; + std::string branch_name = "merged"; public : TSObjectMerger( const Object1 &t1, const Object2 &t2 ){ @@ -131,24 +134,31 @@ class TSObjectMerger */ template void merge(TSObjectMergerCondition condition) { - bool younger = 0; obj1.reset(); obj2.reset(); while ( ! obj1.end() || ! obj2.end() ) { - if ((obj1.getTimeStamp() > obj2.getTimeStamp() || obj1.end()) && !obj2.end()) { + if ((obj1.getTimeStamp() > obj2.getTimeStamp() || obj1.end() ) && !obj2.end()) { + obj1.unset(); + obj2.set(); + if ( condition.wonnow(*obj1.get(), *obj2.get(), obj3) ) + output->Fill(); ++obj2; - obj1.set_null(); - younger = 1; - } else if ((obj1.getTimeStamp() < obj2.getTimeStamp() || obj2.end()) && !obj1.end()) { - obj2.set_null(); + } else if ((obj1.getTimeStamp() < obj2.getTimeStamp() || obj2.end() ) && !obj1.end()) { + obj2.unset(); + obj1.set(); + if ( condition.wonnow(*obj1.get(), *obj2.get(), obj3) ) + output->Fill(); ++obj1; - younger = 0; - } else if ( !obj1.end() && !obj2.end()) { + } else if ( obj1.getTimeStamp() == obj2.getTimeStamp() && !obj1.end() && !obj2.end()) { + obj1.set(); + obj2.set(); + if ( condition.wonnow(*obj1.get(), *obj2.get(), obj3) ) + output->Fill(); ++obj1; ++obj2; } - if ( condition.wonnow(*obj1.get(), *obj2.get(), obj3, younger) ) - output->Fill(); + //if ( condition.wonnow(*obj1.get(), *obj2.get(), obj3) ) + // output->Fill(); } std::cout << "TSObjectMerger::Notes. Merge completed." << std::endl; output->Write(); diff --git a/include/ts_object.h b/include/TSObject.h similarity index 100% rename from include/ts_object.h rename to include/TSObject.h diff --git a/include/ts_tree_object.h b/include/TSTreeObject.h similarity index 92% rename from include/ts_tree_object.h rename to include/TSTreeObject.h index 60470925a382c5fdab5af3ae2409c7c1dd202184..b683443253ca3e7865b28744a343b9e310e7cdff 100644 --- a/include/ts_tree_object.h +++ b/include/TSTreeObject.h @@ -1,7 +1,7 @@ #ifndef TS_TREE_OBJECT_H #define TS_TREE_OBJECT_H -#include "ts_object.h" +#include "TSObject.h" template class TSTreeObject : public TSObject @@ -27,10 +27,16 @@ class TSTreeObject : public TSObject unsigned long long getTimeStamp() const { return ts_obj->ts; } T* get() const { return ts_obj; } - void set_null() { + + void unset() { ts_obj->set_null(); ts_obj->status = false; } + void set() { + ts_obj->status = true; + } + + void reset() { i=0; fTree->GetEntry(i); } Bool_t end() { return !(i < n); } Bool_t begin() { return i == 0; } diff --git a/include/classdef.h b/include/classdef.h index 1ca123d995c674ccf6ddade6de70aae3c03844fc..d75967724444f18b4999a02ea05d2f19ac0a9f53 100644 --- a/include/classdef.h +++ b/include/classdef.h @@ -55,8 +55,14 @@ class MergedData : public TObject public : ULong64_t ts; + ULong64_t o1ts, o2ts; Double_t x, y; + Double_t xx, yy; Int_t l, m, n; + + Bool_t o1, o2; + + UShort_t id = 0; Bool_t status = 0; ClassDef(MergedData, 1); diff --git a/include/print.h b/include/print.h index 335b466f745c449fbc8cca6f331597bbce3a3891..74a7be675d9ac55dbe648d7dbd350fe6cdb16fcf 100644 --- a/include/print.h +++ b/include/print.h @@ -1,3 +1,6 @@ +#ifndef PRINT_H +#define PRINT_H + #include #include #include @@ -34,3 +37,5 @@ template void print(Head&& head, Tail&&... tail) { cout << head << " "; print(forward(tail)...); } + +#endif diff --git a/lib/Dict_rdict.pcm b/lib/Dict_rdict.pcm index aa80a9e34c13761d32222168209009f50cee7ac0..411888e589ded27b0585a54d57fbd85188c48824 100644 Binary files a/lib/Dict_rdict.pcm and b/lib/Dict_rdict.pcm differ diff --git a/lib/libclass.so b/lib/libclass.so index 46f80454ce26f2003f22ce33e5751fc1669769ee..08052ffc6c72d8ec85a60550d3b5d67597891533 100755 Binary files a/lib/libclass.so and b/lib/libclass.so differ diff --git a/make_dict.py b/make_dict.py index 43e2a88627dd219461c91e981bf3495ffbfba891..a40c7072dce74a392468f20fe545021a6a4e87dc 100644 --- a/make_dict.py +++ b/make_dict.py @@ -8,13 +8,8 @@ else : files = [f for f in os.listdir(path) if os.path.isfile(os.path.join(path, f))] - - import re - - - classes = [] for f in files : diff --git a/makefile b/makefile index ddfc5b03710b4dd1010ef3b418f3fbca92f300f2..23c31a208f9905f574b471af8b43e7d00726615a 100644 --- a/makefile +++ b/makefile @@ -13,7 +13,7 @@ TARGET = run #INCLUDES = -I./include -INCLUDES = -I./include -I./lib/src/class +INCLUDES = -I./include SRC_DIR = src #NOMAKEDIR= .git% data% doc% bin% src/bin% tmp% OBJDIR = objs diff --git a/src/main.cpp b/src/main.cpp index 43c4da80a7b8410d5be4e93d04b1b77ea1a6b181..eef5ab60a7b1789ae7145095112a90d9ab2b4e8f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,9 +1,9 @@ -#include "ts_object.h" +#include "TSObject.h" #include "TSMerger.h" -#include "ts_tree_object.h" +#include "TSTreeObject.h" -#include "print.h" +#include "Print.h" #include "utils.h" #include "classdef.h" @@ -30,12 +30,11 @@ class Condition } }; - template class TSObjectMergerCondition { public : - bool wonnow(const T1 &o1, const T2 &o2, merged &Obj, bool younger){ + bool wonnow(const T1 &o1, const T2 &o2, merged &Obj){ // Define merged Data Obj.l = o1.l; @@ -44,13 +43,54 @@ class TSObjectMergerCondition Obj.x = o2.x; Obj.y = o2.y; - // Necessary - Obj.ts = ! younger ? o1.ts : o2.ts; + + + + Obj.o1 = o1.status; + Obj.o2 = o2.status; + Obj.o1ts = o1.ts; + Obj.o2ts = o2.ts; + + + + // Do not change here + Obj.id = 2 * o2.status + o1.status; + switch (Obj.id){ + case 1 : + Obj.ts = o1.ts; + break; + case 2 : + Obj.ts = o2.ts; + break; + case 3 : + Obj.ts = o2.ts; + break; + case 0 : + return false; + break; + } + /* + * o1 o2 | 2*o2 + o1 + * -------- | --------- + * 1 1 | 3 + * 1 0 | 1 + * 0 1 | 2 + * 0 0 | 0 + * + * id = 0 : invalid data + * id = 1 : o1 data + * id = 2 : o2 data + * id = 3 : coincidence + * + */ + + Obj.xx = o2.x * Obj.ts; + Obj.yy = o2.y * Obj.ts; // Condition - Bool_t condition = std::abs((long long)(o1.ts - o2.ts)) < 4 ; - Obj.status = condition; - return condition; + //Bool_t condition = std::abs((long long)(o1.ts - o2.ts)) < 5 ; + Bool_t condition = true; + return condition; } }; @@ -91,7 +131,7 @@ int main(int argc, char **argv) typedef TSObjectMergerCondition TSMC; TSMC condition; TSObjectMerger< TSTreeObject, TSTreeObject, MergedData > merger(t1, t2); - merger.setOutputTree("merged", "tree"); + merger.setOutputTree("merged", "br"); merger.merge(condition); end = std::chrono::system_clock::now();