From 6cccdea073537093039dda0543ba45bdedef7980 Mon Sep 17 00:00:00 2001 From: "zhangyz@ihep.ac.cn" Date: Fri, 30 Jun 2023 14:43:13 +0800 Subject: [PATCH 1/2] add VXDTestbeam --- Reconstruction/CMakeLists.txt | 1 + Reconstruction/VXDTestbeam/CMakeLists.txt | 28 +++++++ .../options/TBDataClusterReader.py | 24 ++++++ .../VXDTestbeam/options/TBDataReader.py | 24 ++++++ .../VXDTestbeam/src/TBDataAnalysis/pixel.cpp | 71 +++++++++++++++++ .../VXDTestbeam/src/TBDataAnalysis/pixel.h | 49 ++++++++++++ .../src/TBDataReader/TBDataClusterReader.cpp | 76 +++++++++++++++++++ .../src/TBDataReader/TBDataClusterReader.h | 51 +++++++++++++ .../src/TBDataReader/TBDataReader.cpp | 71 +++++++++++++++++ .../src/TBDataReader/TBDataReader.h | 49 ++++++++++++ .../VXDTestbeam/src/TBNumpyWriter/pixel.cpp | 71 +++++++++++++++++ .../VXDTestbeam/src/TBNumpyWriter/pixel.h | 49 ++++++++++++ .../src/VXDClusteringAlg/pixel.cpp | 71 +++++++++++++++++ .../VXDTestbeam/src/VXDClusteringAlg/pixel.h | 49 ++++++++++++ 14 files changed, 684 insertions(+) create mode 100644 Reconstruction/VXDTestbeam/CMakeLists.txt create mode 100644 Reconstruction/VXDTestbeam/options/TBDataClusterReader.py create mode 100644 Reconstruction/VXDTestbeam/options/TBDataReader.py create mode 100644 Reconstruction/VXDTestbeam/src/TBDataAnalysis/pixel.cpp create mode 100644 Reconstruction/VXDTestbeam/src/TBDataAnalysis/pixel.h create mode 100644 Reconstruction/VXDTestbeam/src/TBDataReader/TBDataClusterReader.cpp create mode 100644 Reconstruction/VXDTestbeam/src/TBDataReader/TBDataClusterReader.h create mode 100644 Reconstruction/VXDTestbeam/src/TBDataReader/TBDataReader.cpp create mode 100644 Reconstruction/VXDTestbeam/src/TBDataReader/TBDataReader.h create mode 100644 Reconstruction/VXDTestbeam/src/TBNumpyWriter/pixel.cpp create mode 100644 Reconstruction/VXDTestbeam/src/TBNumpyWriter/pixel.h create mode 100644 Reconstruction/VXDTestbeam/src/VXDClusteringAlg/pixel.cpp create mode 100644 Reconstruction/VXDTestbeam/src/VXDClusteringAlg/pixel.h diff --git a/Reconstruction/CMakeLists.txt b/Reconstruction/CMakeLists.txt index 6dd63b02c..ed8b1710a 100644 --- a/Reconstruction/CMakeLists.txt +++ b/Reconstruction/CMakeLists.txt @@ -4,3 +4,4 @@ add_subdirectory(PFA) add_subdirectory(SiliconTracking) add_subdirectory(Tracking) add_subdirectory(RecGenfitAlg) +add_subdirectory(VXDTestbeam) diff --git a/Reconstruction/VXDTestbeam/CMakeLists.txt b/Reconstruction/VXDTestbeam/CMakeLists.txt new file mode 100644 index 000000000..b23dd30ea --- /dev/null +++ b/Reconstruction/VXDTestbeam/CMakeLists.txt @@ -0,0 +1,28 @@ +# Headers and Libraries + +# Modules +gaudi_add_module(VXDTestbeam + SOURCES src/TBDataReader/TBDataReader.cpp + SOURCES src/TBDataReader/TBDataClusterReader.cpp + LINK #DetInterface + k4FWCore::k4FWCore + Gaudi::GaudiAlgLib Gaudi::GaudiKernel + ${LCIO_LIBRARIES} + ${DD4hep_COMPONENT_LIBRARIES} + EDM4HEP::edm4hep EDM4HEP::edm4hepDict + ${podio_LIBRARIES} podio::podioRootIO +) + +if (GenFit_FOUND) + target_link_libraries(VXDTestbeam PUBLIC GenFit::genfit2) +endif() + +target_include_directories(VXDTestbeam PUBLIC + $/include + $) + +install(TARGETS VXDTestbeam + EXPORT CEPCSWTargets + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT shlib + COMPONENT dev) diff --git a/Reconstruction/VXDTestbeam/options/TBDataClusterReader.py b/Reconstruction/VXDTestbeam/options/TBDataClusterReader.py new file mode 100644 index 000000000..af90cb9fb --- /dev/null +++ b/Reconstruction/VXDTestbeam/options/TBDataClusterReader.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python + +from Gaudi.Configuration import * + +from Configurables import k4DataSvc +dsvc = k4DataSvc("EventDataSvc") + +from Configurables import TBDataClusterReader +alg = TBDataClusterReader("TBDataClusterReader") +alg.TrackerHitOut.Path = "TrackerHit" + +from Configurables import PodioOutput +out = PodioOutput("out") +out.filename = "Testbeamcluster.root" +out.outputCommands = ["keep *"] + +# ApplicationMgr +from Configurables import ApplicationMgr +ApplicationMgr( TopAlg = [alg, out], + EvtSel = 'NONE', + EvtMax = 1883792, + ExtSvc=[dsvc], + # OutputLevel=DEBUG +) diff --git a/Reconstruction/VXDTestbeam/options/TBDataReader.py b/Reconstruction/VXDTestbeam/options/TBDataReader.py new file mode 100644 index 000000000..cabe3f7db --- /dev/null +++ b/Reconstruction/VXDTestbeam/options/TBDataReader.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python + +from Gaudi.Configuration import * + +from Configurables import k4DataSvc +dsvc = k4DataSvc("EventDataSvc") + +from Configurables import TBDataReader +alg = TBDataReader("TBDataReader") +alg.RawTimeSeriesOut.Path = "RawTimeSeries" + +from Configurables import PodioOutput +out = PodioOutput("out") +out.filename = "Testbeamdata.root" +out.outputCommands = ["keep *"] + +# ApplicationMgr +from Configurables import ApplicationMgr +ApplicationMgr( TopAlg = [alg, out], + EvtSel = 'NONE', + EvtMax = 8285, + ExtSvc=[dsvc], + # OutputLevel=DEBUG +) diff --git a/Reconstruction/VXDTestbeam/src/TBDataAnalysis/pixel.cpp b/Reconstruction/VXDTestbeam/src/TBDataAnalysis/pixel.cpp new file mode 100644 index 000000000..68073f508 --- /dev/null +++ b/Reconstruction/VXDTestbeam/src/TBDataAnalysis/pixel.cpp @@ -0,0 +1,71 @@ +// read csv +#include +#include +#include +#include + +// dependence +#include "pixel.h" +#include "edm4hep/RawTimeSeriesCollection.h" + +// root +#include +#include + +DECLARE_COMPONENT(PixelWrite) + +PixelWrite::PixelWrite(const std::string& name, ISvcLocator* svcLoc) + : GaudiAlgorithm(name, svcLoc) +{ + declareProperty("RawTimeSeriesOut", m_hitCol); +} + +StatusCode PixelWrite::initialize() +{ + info() << "begin initialize PixelWrite" << endmsg; + + // get file path + tree_file = new TFile("/afs/ihep.ac.cn/users/l/lishuqi/public/TB/AllSameTimeHitsLoose2_9.root", "READ"); + + if (!tree_file->IsOpen()) { + info() << "failed open file" << endmsg; + } + tree = (TTree*)tree_file->Get("TimeInfo"); + + tree->SetBranchAddress("timeChip", &timeChip); + tree->SetBranchAddress("planeID", &planeID); + tree->SetBranchAddress("row", &row); + tree->SetBranchAddress("col", &col); + + info() << "Total Number of Events = " << tree->GetEntries() << endmsg; + return GaudiAlgorithm::initialize(); +} + +StatusCode PixelWrite::execute() +{ + info() << "Executing Event " << eventid << endmsg; + + tree->GetEntry(eventid); + auto hits = m_hitCol.createAndPut(); + hits->setID(eventid); + int event_size = timeChip->size(); + for (int i=0; i < event_size; i++){ + auto hit = hits->create(); + hit.setTime(timeChip->at(i)); + // planeID:8,row:12,col:12 + dd4hep::rec::CellID ncellid; + m_decoder.set(ncellid, "planeID", planeID->at(i)); + m_decoder.set(ncellid, "row", row->at(i)); + m_decoder.set(ncellid, "col", col->at(i)); + hit.setCellID(ncellid); + } + + eventid += 1; + return StatusCode::SUCCESS; +} + +StatusCode PixelWrite::finalize() +{ + info() << "finalize PixelWrite" << endmsg; + return GaudiAlgorithm::finalize(); +} diff --git a/Reconstruction/VXDTestbeam/src/TBDataAnalysis/pixel.h b/Reconstruction/VXDTestbeam/src/TBDataAnalysis/pixel.h new file mode 100644 index 000000000..3486dd4b6 --- /dev/null +++ b/Reconstruction/VXDTestbeam/src/TBDataAnalysis/pixel.h @@ -0,0 +1,49 @@ +#ifndef PIXEL_H +#define PIXEL_H + +#include "k4FWCore/DataHandle.h" +#include "GaudiAlg/GaudiAlgorithm.h" +#include "DD4hep/Detector.h" +#include +#include + +namespace edm4hep { + class RawTimeSeriesCollection; +} + +namespace dd4hep { + namespace rec { + class CellIDPositionConverter; + } + namespace DDSegmentation { + class BitFieldCoder; + } +} + +class PixelWrite : public GaudiAlgorithm +{ + + public : + + PixelWrite(const std::string& name, ISvcLocator* svcLoc); + + virtual StatusCode initialize(); + virtual StatusCode execute(); + virtual StatusCode finalize(); + + private : + + DataHandle m_hitCol{"RawTimeSeries", Gaudi::DataHandle::Writer, this}; + dd4hep::DDSegmentation::BitFieldCoder m_decoder{"planeID:8,row:12,col:12"}; + // dd4hep::DDSegmentation::BitFieldCoder* m_decoder; + + int eventid = 0; + TFile *tree_file = NULL; + TTree *tree = NULL; + std::vector* timeChip = NULL; + std::vector* planeID = NULL; + std::vector* row = NULL; + std::vector* col = NULL; +}; + +#endif // PIXEL_H diff --git a/Reconstruction/VXDTestbeam/src/TBDataReader/TBDataClusterReader.cpp b/Reconstruction/VXDTestbeam/src/TBDataReader/TBDataClusterReader.cpp new file mode 100644 index 000000000..ff04031f6 --- /dev/null +++ b/Reconstruction/VXDTestbeam/src/TBDataReader/TBDataClusterReader.cpp @@ -0,0 +1,76 @@ +// read csv +#include +#include +#include +#include + +// dependence +#include "TBDataClusterReader.h" +#include "edm4hep/TrackerHitCollection.h" + +// root +#include +#include + +DECLARE_COMPONENT(TBDataClusterReader) + +TBDataClusterReader::TBDataClusterReader(const std::string& name, ISvcLocator* svcLoc) + : GaudiAlgorithm(name, svcLoc) +{ + declareProperty("TrackerHitOut", m_hitCol); +} + +StatusCode TBDataClusterReader::initialize() +{ + info() << "begin initialize TBDataClusterReader" << endmsg; + + // get file path + tree_file = new TFile("/afs/ihep.ac.cn/users/l/lishuqi/scratchfs_2Weeks/pub/Clusterxy_all2_9.root", "READ"); + + if (!tree_file->IsOpen()) { + info() << "failed open file" << endmsg; + } + tree = (TTree*)tree_file->Get("Event"); + + tree->SetBranchAddress("planeID", &planeID); + tree->SetBranchAddress("col", &col); + tree->SetBranchAddress("row", &row); + tree->SetBranchAddress("hitsNum", &hitsNum); + tree->SetBranchAddress("hitsNumX", &hitsNumX); + tree->SetBranchAddress("hitsNumY", &hitsNumY); + + info() << "Total Number of Events = " << tree->GetEntries() << endmsg; + return GaudiAlgorithm::initialize(); +} + +StatusCode TBDataClusterReader::execute() +{ + info() << "Executing Event " << eventid << endmsg; + + tree->GetEntry(eventid); + auto hits = m_hitCol.createAndPut(); + hits->setID(eventid); + int event_size = planeID->size(); + for (int i=0; i < event_size; i++){ + auto hit = hits->create(); + // use float type storage + hit.setTime(col->at(i)); + hit.setEDep(row->at(i)); + // planeID:8,hitsNum:8,hitsNumX:8,hitsNumY:8 + dd4hep::rec::CellID ncellid; + m_decoder.set(ncellid, "planeID", planeID->at(i)); + m_decoder.set(ncellid, "hitsNum", hitsNum->at(i)); + m_decoder.set(ncellid, "hitsNumX", hitsNumX->at(i)); + m_decoder.set(ncellid, "hitsNumY", hitsNumY->at(i)); + hit.setCellID(ncellid); + } + + eventid += 1; + return StatusCode::SUCCESS; +} + +StatusCode TBDataClusterReader::finalize() +{ + info() << "finalize TBDataClusterReader" << endmsg; + return GaudiAlgorithm::finalize(); +} diff --git a/Reconstruction/VXDTestbeam/src/TBDataReader/TBDataClusterReader.h b/Reconstruction/VXDTestbeam/src/TBDataReader/TBDataClusterReader.h new file mode 100644 index 000000000..db067eef4 --- /dev/null +++ b/Reconstruction/VXDTestbeam/src/TBDataReader/TBDataClusterReader.h @@ -0,0 +1,51 @@ +#ifndef TBDATACLUSTERREADER_H +#define TBDATACLUSTERREADER_H + +#include "k4FWCore/DataHandle.h" +#include "GaudiAlg/GaudiAlgorithm.h" +#include "DD4hep/Detector.h" +#include +#include + +namespace edm4hep { + class TrackerHitCollection; +} + +namespace dd4hep { + namespace rec { + class CellIDPositionConverter; + } + namespace DDSegmentation { + class BitFieldCoder; + } +} + +class TBDataClusterReader : public GaudiAlgorithm +{ + + public : + + TBDataClusterReader(const std::string& name, ISvcLocator* svcLoc); + + virtual StatusCode initialize(); + virtual StatusCode execute(); + virtual StatusCode finalize(); + + private : + + DataHandle m_hitCol{"TrackerHit", Gaudi::DataHandle::Writer, this}; + dd4hep::DDSegmentation::BitFieldCoder m_decoder{"planeID:8,hitsNum:8,hitsNumX:8,hitsNumY:8"}; + // dd4hep::DDSegmentation::BitFieldCoder* m_decoder; + + int eventid = 0; + TFile *tree_file = NULL; + TTree *tree = NULL; + std::vector* planeID = NULL; + std::vector* hitsNum = NULL; + std::vector* hitsNumX = NULL; + std::vector* hitsNumY = NULL; + std::vector* row = NULL; + std::vector* col = NULL; +}; + +#endif // TBDATACLUSTERREADER_H diff --git a/Reconstruction/VXDTestbeam/src/TBDataReader/TBDataReader.cpp b/Reconstruction/VXDTestbeam/src/TBDataReader/TBDataReader.cpp new file mode 100644 index 000000000..c5606fdc5 --- /dev/null +++ b/Reconstruction/VXDTestbeam/src/TBDataReader/TBDataReader.cpp @@ -0,0 +1,71 @@ +// read csv +#include +#include +#include +#include + +// dependence +#include "TBDataReader.h" +#include "edm4hep/RawTimeSeriesCollection.h" + +// root +#include +#include + +DECLARE_COMPONENT(TBDataReader) + +TBDataReader::TBDataReader(const std::string& name, ISvcLocator* svcLoc) + : GaudiAlgorithm(name, svcLoc) +{ + declareProperty("RawTimeSeriesOut", m_hitCol); +} + +StatusCode TBDataReader::initialize() +{ + info() << "begin initialize TBDataReader" << endmsg; + + // get file path + tree_file = new TFile("/afs/ihep.ac.cn/users/l/lishuqi/public/TB/AllSameTimeHitsLoose2_9.root", "READ"); + + if (!tree_file->IsOpen()) { + info() << "failed open file" << endmsg; + } + tree = (TTree*)tree_file->Get("TimeInfo"); + + tree->SetBranchAddress("timeChip", &timeChip); + tree->SetBranchAddress("planeID", &planeID); + tree->SetBranchAddress("row", &row); + tree->SetBranchAddress("col", &col); + + info() << "Total Number of Events = " << tree->GetEntries() << endmsg; + return GaudiAlgorithm::initialize(); +} + +StatusCode TBDataReader::execute() +{ + info() << "Executing Event " << eventid << endmsg; + + tree->GetEntry(eventid); + auto hits = m_hitCol.createAndPut(); + hits->setID(eventid); + int event_size = timeChip->size(); + for (int i=0; i < event_size; i++){ + auto hit = hits->create(); + hit.setTime(timeChip->at(i)); + // planeID:8,row:12,col:12 + dd4hep::rec::CellID ncellid; + m_decoder.set(ncellid, "planeID", planeID->at(i)); + m_decoder.set(ncellid, "row", row->at(i)); + m_decoder.set(ncellid, "col", col->at(i)); + hit.setCellID(ncellid); + } + + eventid += 1; + return StatusCode::SUCCESS; +} + +StatusCode TBDataReader::finalize() +{ + info() << "finalize TBDataReader" << endmsg; + return GaudiAlgorithm::finalize(); +} diff --git a/Reconstruction/VXDTestbeam/src/TBDataReader/TBDataReader.h b/Reconstruction/VXDTestbeam/src/TBDataReader/TBDataReader.h new file mode 100644 index 000000000..af42d1e63 --- /dev/null +++ b/Reconstruction/VXDTestbeam/src/TBDataReader/TBDataReader.h @@ -0,0 +1,49 @@ +#ifndef TBDATAREADER_H +#define TBDATAREADER_H + +#include "k4FWCore/DataHandle.h" +#include "GaudiAlg/GaudiAlgorithm.h" +#include "DD4hep/Detector.h" +#include +#include + +namespace edm4hep { + class RawTimeSeriesCollection; +} + +namespace dd4hep { + namespace rec { + class CellIDPositionConverter; + } + namespace DDSegmentation { + class BitFieldCoder; + } +} + +class TBDataReader : public GaudiAlgorithm +{ + + public : + + TBDataReader(const std::string& name, ISvcLocator* svcLoc); + + virtual StatusCode initialize(); + virtual StatusCode execute(); + virtual StatusCode finalize(); + + private : + + DataHandle m_hitCol{"RawTimeSeries", Gaudi::DataHandle::Writer, this}; + dd4hep::DDSegmentation::BitFieldCoder m_decoder{"planeID:8,row:12,col:12"}; + // dd4hep::DDSegmentation::BitFieldCoder* m_decoder; + + int eventid = 0; + TFile *tree_file = NULL; + TTree *tree = NULL; + std::vector* timeChip = NULL; + std::vector* planeID = NULL; + std::vector* row = NULL; + std::vector* col = NULL; +}; + +#endif // TBDATAREADER_H diff --git a/Reconstruction/VXDTestbeam/src/TBNumpyWriter/pixel.cpp b/Reconstruction/VXDTestbeam/src/TBNumpyWriter/pixel.cpp new file mode 100644 index 000000000..68073f508 --- /dev/null +++ b/Reconstruction/VXDTestbeam/src/TBNumpyWriter/pixel.cpp @@ -0,0 +1,71 @@ +// read csv +#include +#include +#include +#include + +// dependence +#include "pixel.h" +#include "edm4hep/RawTimeSeriesCollection.h" + +// root +#include +#include + +DECLARE_COMPONENT(PixelWrite) + +PixelWrite::PixelWrite(const std::string& name, ISvcLocator* svcLoc) + : GaudiAlgorithm(name, svcLoc) +{ + declareProperty("RawTimeSeriesOut", m_hitCol); +} + +StatusCode PixelWrite::initialize() +{ + info() << "begin initialize PixelWrite" << endmsg; + + // get file path + tree_file = new TFile("/afs/ihep.ac.cn/users/l/lishuqi/public/TB/AllSameTimeHitsLoose2_9.root", "READ"); + + if (!tree_file->IsOpen()) { + info() << "failed open file" << endmsg; + } + tree = (TTree*)tree_file->Get("TimeInfo"); + + tree->SetBranchAddress("timeChip", &timeChip); + tree->SetBranchAddress("planeID", &planeID); + tree->SetBranchAddress("row", &row); + tree->SetBranchAddress("col", &col); + + info() << "Total Number of Events = " << tree->GetEntries() << endmsg; + return GaudiAlgorithm::initialize(); +} + +StatusCode PixelWrite::execute() +{ + info() << "Executing Event " << eventid << endmsg; + + tree->GetEntry(eventid); + auto hits = m_hitCol.createAndPut(); + hits->setID(eventid); + int event_size = timeChip->size(); + for (int i=0; i < event_size; i++){ + auto hit = hits->create(); + hit.setTime(timeChip->at(i)); + // planeID:8,row:12,col:12 + dd4hep::rec::CellID ncellid; + m_decoder.set(ncellid, "planeID", planeID->at(i)); + m_decoder.set(ncellid, "row", row->at(i)); + m_decoder.set(ncellid, "col", col->at(i)); + hit.setCellID(ncellid); + } + + eventid += 1; + return StatusCode::SUCCESS; +} + +StatusCode PixelWrite::finalize() +{ + info() << "finalize PixelWrite" << endmsg; + return GaudiAlgorithm::finalize(); +} diff --git a/Reconstruction/VXDTestbeam/src/TBNumpyWriter/pixel.h b/Reconstruction/VXDTestbeam/src/TBNumpyWriter/pixel.h new file mode 100644 index 000000000..3486dd4b6 --- /dev/null +++ b/Reconstruction/VXDTestbeam/src/TBNumpyWriter/pixel.h @@ -0,0 +1,49 @@ +#ifndef PIXEL_H +#define PIXEL_H + +#include "k4FWCore/DataHandle.h" +#include "GaudiAlg/GaudiAlgorithm.h" +#include "DD4hep/Detector.h" +#include +#include + +namespace edm4hep { + class RawTimeSeriesCollection; +} + +namespace dd4hep { + namespace rec { + class CellIDPositionConverter; + } + namespace DDSegmentation { + class BitFieldCoder; + } +} + +class PixelWrite : public GaudiAlgorithm +{ + + public : + + PixelWrite(const std::string& name, ISvcLocator* svcLoc); + + virtual StatusCode initialize(); + virtual StatusCode execute(); + virtual StatusCode finalize(); + + private : + + DataHandle m_hitCol{"RawTimeSeries", Gaudi::DataHandle::Writer, this}; + dd4hep::DDSegmentation::BitFieldCoder m_decoder{"planeID:8,row:12,col:12"}; + // dd4hep::DDSegmentation::BitFieldCoder* m_decoder; + + int eventid = 0; + TFile *tree_file = NULL; + TTree *tree = NULL; + std::vector* timeChip = NULL; + std::vector* planeID = NULL; + std::vector* row = NULL; + std::vector* col = NULL; +}; + +#endif // PIXEL_H diff --git a/Reconstruction/VXDTestbeam/src/VXDClusteringAlg/pixel.cpp b/Reconstruction/VXDTestbeam/src/VXDClusteringAlg/pixel.cpp new file mode 100644 index 000000000..68073f508 --- /dev/null +++ b/Reconstruction/VXDTestbeam/src/VXDClusteringAlg/pixel.cpp @@ -0,0 +1,71 @@ +// read csv +#include +#include +#include +#include + +// dependence +#include "pixel.h" +#include "edm4hep/RawTimeSeriesCollection.h" + +// root +#include +#include + +DECLARE_COMPONENT(PixelWrite) + +PixelWrite::PixelWrite(const std::string& name, ISvcLocator* svcLoc) + : GaudiAlgorithm(name, svcLoc) +{ + declareProperty("RawTimeSeriesOut", m_hitCol); +} + +StatusCode PixelWrite::initialize() +{ + info() << "begin initialize PixelWrite" << endmsg; + + // get file path + tree_file = new TFile("/afs/ihep.ac.cn/users/l/lishuqi/public/TB/AllSameTimeHitsLoose2_9.root", "READ"); + + if (!tree_file->IsOpen()) { + info() << "failed open file" << endmsg; + } + tree = (TTree*)tree_file->Get("TimeInfo"); + + tree->SetBranchAddress("timeChip", &timeChip); + tree->SetBranchAddress("planeID", &planeID); + tree->SetBranchAddress("row", &row); + tree->SetBranchAddress("col", &col); + + info() << "Total Number of Events = " << tree->GetEntries() << endmsg; + return GaudiAlgorithm::initialize(); +} + +StatusCode PixelWrite::execute() +{ + info() << "Executing Event " << eventid << endmsg; + + tree->GetEntry(eventid); + auto hits = m_hitCol.createAndPut(); + hits->setID(eventid); + int event_size = timeChip->size(); + for (int i=0; i < event_size; i++){ + auto hit = hits->create(); + hit.setTime(timeChip->at(i)); + // planeID:8,row:12,col:12 + dd4hep::rec::CellID ncellid; + m_decoder.set(ncellid, "planeID", planeID->at(i)); + m_decoder.set(ncellid, "row", row->at(i)); + m_decoder.set(ncellid, "col", col->at(i)); + hit.setCellID(ncellid); + } + + eventid += 1; + return StatusCode::SUCCESS; +} + +StatusCode PixelWrite::finalize() +{ + info() << "finalize PixelWrite" << endmsg; + return GaudiAlgorithm::finalize(); +} diff --git a/Reconstruction/VXDTestbeam/src/VXDClusteringAlg/pixel.h b/Reconstruction/VXDTestbeam/src/VXDClusteringAlg/pixel.h new file mode 100644 index 000000000..3486dd4b6 --- /dev/null +++ b/Reconstruction/VXDTestbeam/src/VXDClusteringAlg/pixel.h @@ -0,0 +1,49 @@ +#ifndef PIXEL_H +#define PIXEL_H + +#include "k4FWCore/DataHandle.h" +#include "GaudiAlg/GaudiAlgorithm.h" +#include "DD4hep/Detector.h" +#include +#include + +namespace edm4hep { + class RawTimeSeriesCollection; +} + +namespace dd4hep { + namespace rec { + class CellIDPositionConverter; + } + namespace DDSegmentation { + class BitFieldCoder; + } +} + +class PixelWrite : public GaudiAlgorithm +{ + + public : + + PixelWrite(const std::string& name, ISvcLocator* svcLoc); + + virtual StatusCode initialize(); + virtual StatusCode execute(); + virtual StatusCode finalize(); + + private : + + DataHandle m_hitCol{"RawTimeSeries", Gaudi::DataHandle::Writer, this}; + dd4hep::DDSegmentation::BitFieldCoder m_decoder{"planeID:8,row:12,col:12"}; + // dd4hep::DDSegmentation::BitFieldCoder* m_decoder; + + int eventid = 0; + TFile *tree_file = NULL; + TTree *tree = NULL; + std::vector* timeChip = NULL; + std::vector* planeID = NULL; + std::vector* row = NULL; + std::vector* col = NULL; +}; + +#endif // PIXEL_H From e4e4888c755433ba4c01c5eb5efd72c7e91bfd9a Mon Sep 17 00:00:00 2001 From: James_Zhang <49799202+stch-zhangyzh@users.noreply.github.com> Date: Thu, 19 Oct 2023 19:01:15 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=B7=B2=E6=B7=BB=E5=8A=A0=20VDX.drawio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/VDX.drawio | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 docs/VDX.drawio diff --git a/docs/VDX.drawio b/docs/VDX.drawio new file mode 100644 index 000000000..1059526f0 --- /dev/null +++ b/docs/VDX.drawio @@ -0,0 +1,10 @@ + + + + + + + + + +