From d8574a489d8bfb6cac2a7d951d3b33918ea78219 Mon Sep 17 00:00:00 2001 From: Tingjun Yang Date: Sat, 23 Mar 2024 10:20:14 -0500 Subject: [PATCH 1/2] Add an analyzer module to analyze channel ID data. --- sbndcode/ChannelMaps/TPC/CMakeLists.txt | 8 ++ .../ChannelMaps/TPC/TPCChannelIDAna_module.cc | 135 ++++++++++++++++++ 2 files changed, 143 insertions(+) create mode 100644 sbndcode/ChannelMaps/TPC/TPCChannelIDAna_module.cc diff --git a/sbndcode/ChannelMaps/TPC/CMakeLists.txt b/sbndcode/ChannelMaps/TPC/CMakeLists.txt index b67ef20a5..e003e8fd1 100644 --- a/sbndcode/ChannelMaps/TPC/CMakeLists.txt +++ b/sbndcode/ChannelMaps/TPC/CMakeLists.txt @@ -12,4 +12,12 @@ art_make(SERVICE_LIBRARIES art::Persistency_Provenance messagefacility::MF_MessageLogger ROOT::Core + MODULE_LIBRARIES + art_root_io::TFileService_service + lardataobj::RawData + larcore::Geometry_Geometry_service + sbndcode_ChannelMaps_TPC_TPCChannelMapService_service + ROOT::Tree ) + + diff --git a/sbndcode/ChannelMaps/TPC/TPCChannelIDAna_module.cc b/sbndcode/ChannelMaps/TPC/TPCChannelIDAna_module.cc new file mode 100644 index 000000000..8c584f44f --- /dev/null +++ b/sbndcode/ChannelMaps/TPC/TPCChannelIDAna_module.cc @@ -0,0 +1,135 @@ +//////////////////////////////////////////////////////////////////////// +// Class: TPCChannelIDAna +// Plugin Type: analyzer +// File: PDSMeanRMSLZ_tool.cc +// Author: tjyang@fnal.gov +// +// Analyze channel ID data +// +//////////////////////////////////////////////////////////////////////// +#include "art/Framework/Core/EDAnalyzer.h" +#include "art/Framework/Core/ModuleMacros.h" +#include "art/Framework/Principal/Event.h" +#include "art/Framework/Principal/Handle.h" +#include "art/Framework/Principal/Run.h" +#include "art/Framework/Principal/SubRun.h" +#include "canvas/Utilities/InputTag.h" +#include "fhiclcpp/ParameterSet.h" +#include "messagefacility/MessageLogger/MessageLogger.h" +#include "art_root_io/TFileService.h" + +#include "lardataobj/RawData/RawDigit.h" +#include "lardataobj/RawData/raw.h" +#include "larcore/Geometry/Geometry.h" + +#include "sbndcode/ChannelMaps/TPC/TPCChannelMapService.h" + +#include "TTree.h" + +using namespace std; + +namespace sbnd { + class TPCChannelIDAna; +} + + +class sbnd::TPCChannelIDAna : public art::EDAnalyzer { +public: + explicit TPCChannelIDAna(fhicl::ParameterSet const& p); + // The compiler-generated destructor is fine for non-base + // classes without bare pointers or other resource use. + + // Plugins should not be copied or assigned. + TPCChannelIDAna(TPCChannelIDAna const&) = delete; + TPCChannelIDAna(TPCChannelIDAna&&) = delete; + TPCChannelIDAna& operator=(TPCChannelIDAna const&) = delete; + TPCChannelIDAna& operator=(TPCChannelIDAna&&) = delete; + + // Required functions. + void beginJob() override; + void analyze(art::Event const& e) override; + +private: + + // Declare member data here. + art::InputTag fRawDigitModuleLabel; + TTree *chs; + int ch; //offline channel + int chid; //measurement from channel ID data + int tpc; + int plane; + int wire; + int wibcrate; + int wib; + int fembonwib; + int fembch; + int fembonwib_fromchid; + int fembch_fromchid; + int femcrate; + int fem; + int femch; +}; + + +sbnd::TPCChannelIDAna::TPCChannelIDAna(fhicl::ParameterSet const& p) + : EDAnalyzer{p} + , fRawDigitModuleLabel{p.get("RawDigitModuleLabel")} + // More initializers here. +{ + // Call appropriate consumes<>() for any products to be retrieved by this module. +} + +void sbnd::TPCChannelIDAna::beginJob(){ + art::ServiceHandle tfs; + chs = tfs->make("chs","Channel information"); + chs->Branch("ch", &ch, "ch/I"); + chs->Branch("chid", &chid, "chid/I"); + chs->Branch("tpc", &tpc, "tpc/I"); + chs->Branch("plane", &plane, "plane/I"); + chs->Branch("wire", &wire, "wire/I"); + chs->Branch("wibcrate", &wibcrate, "wibcrate/I"); + chs->Branch("wib", &wib, "wib/I"); + chs->Branch("fembonwib", &fembonwib, "fembonwib/I"); + chs->Branch("fembch", &fembch, "fembch/I"); + chs->Branch("fembonwib_fromchid", &fembonwib_fromchid, "fembonwib_fromchid/I"); + chs->Branch("fembch_fromchid", &fembch_fromchid, "fembch_fromchid/I"); + chs->Branch("femcrate", &femcrate, "femcrate/I"); + chs->Branch("fem", &fem, "fem/I"); + chs->Branch("femch", &femch, "femch/I"); +} + +void sbnd::TPCChannelIDAna::analyze(art::Event const& e) +{ + // Implementation of required member function here. + + art::ServiceHandle geo; + art::ServiceHandle channelMap; + + // Get raw digits + auto const& rawdigts = e.getProduct>(fRawDigitModuleLabel); + for (const auto & rd : rawdigts){ + std::vector rawadc; //UNCOMPRESSED ADC VALUES. + rawadc.resize(rd.Samples()); + raw::Uncompress(rd.ADCs(), rawadc, rd.GetPedestal(), rd.Compression()); + //cout<ChannelToWire(ch); + tpc = chids[0].TPC; + plane = chids[0].Plane; + wire = chids[0].Wire; + auto const & chaninfo = channelMap->GetChanInfoFromOfflChan(ch); + wibcrate = chaninfo.WIBCrate; + wib = chaninfo.WIB; + fembonwib = chaninfo.FEMBOnWIB; + fembch = chaninfo.FEMBCh; + femcrate = chaninfo.FEMCrate; + fem = chaninfo.FEM; + femch = chaninfo.FEMCh; + fembonwib_fromchid = chid>>8; + fembch_fromchid = chid&0xFF; + chs->Fill(); + } +} + +DEFINE_ART_MODULE(sbnd::TPCChannelIDAna) From b582805eb0e5144af907515f493116b65a70f3e0 Mon Sep 17 00:00:00 2001 From: Tingjun Yang Date: Sat, 23 Mar 2024 10:20:47 -0500 Subject: [PATCH 2/2] Add a function to calculate the intersection point of two wires. --- sbndcode/Utilities/SBNDGeoHelper_module.cc | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/sbndcode/Utilities/SBNDGeoHelper_module.cc b/sbndcode/Utilities/SBNDGeoHelper_module.cc index b5d39913d..a3d388203 100644 --- a/sbndcode/Utilities/SBNDGeoHelper_module.cc +++ b/sbndcode/Utilities/SBNDGeoHelper_module.cc @@ -63,6 +63,7 @@ util::SBNDGeoHelper::SBNDGeoHelper(fhicl::ParameterSet const& p) while (input!=0){ cout<<"0: quit"<> input; if (input == 1){ @@ -90,6 +91,35 @@ util::SBNDGeoHelper::SBNDGeoHelper(fhicl::ParameterSet const& p) cout<<"FEM (1-16) = "<>tpc1; + cout<<"Plane1 number: "; + cin>>plane1; + cout<<"Wire1 number: "; + cin>>wire1; + cout<<"TPC2 number: "; + cin>>tpc2; + cout<<"Plane2 number: "; + cin>>plane2; + cout<<"Wire2 number: "; + cin>>wire2; + geo::WireID wid1(0,tpc1,plane1,wire1); + geo::WireID wid2(0,tpc2,plane2,wire2); + double y,z; + bool intersect = geo->IntersectionPoint(wid1,wid2,y,z); + cout<<"WireID 1:"<