From 64ecac115f0ef20cf669118be4f080cb715e7a44 Mon Sep 17 00:00:00 2001 From: Anna Heggestuen Date: Fri, 8 Nov 2024 14:52:10 -0600 Subject: [PATCH 1/2] add function that returns a CRTPMT Match type based on CRT-PMT time difference --- sbnobj/Common/CRT/CRTPMTMatching.hh | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/sbnobj/Common/CRT/CRTPMTMatching.hh b/sbnobj/Common/CRT/CRTPMTMatching.hh index e1eb62c9..8761cf67 100644 --- a/sbnobj/Common/CRT/CRTPMTMatching.hh +++ b/sbnobj/Common/CRT/CRTPMTMatching.hh @@ -33,6 +33,42 @@ namespace sbn::crt { exSide_enBottom = 14, ///< Matched with one Bottom CRT hit before the optical flash and matched with one Side CRT hit after the optical flash. others = 9 ///< All the other cases. }; + MatchType assignFlashClassification(uint topen, uint topex, + uint sideen, uint sideex, + uint bottomen, uint bottomex) + { + MatchType flashType; + if (topen == 0 && sideen == 0 && topex == 0 && sideex == 0){ + if(bottomex==0 && bottomen==0) flashType = MatchType::noMatch; + else if (bottomex>=1 && bottomen==0) flashType = MatchType::exBottom; + else if (bottomex==0 && bottomen>=1) flashType = MatchType::enBottom; + else flashType = MatchType::others; + } + else if (topen == 1 && sideen == 0 && topex == 0 && sideex == 0){ + if(bottomex==1 && bottomen==0) flashType = MatchType::enTop_exBottom; + else flashType = MatchType::enTop; + } + else if (topen == 0 && sideen == 1 && topex == 0 && sideex == 0) + if(bottomex==1 && bottomen==0) flashType = MatchType::enSide_exBottom; + else flashType = MatchType::enSide; + else if (topen == 1 && sideen == 0 && topex == 0 && sideex == 1) + flashType = MatchType::enTop_exSide; + else if (topen == 0 && sideen == 0 && topex == 1 && sideex == 0){ + if(bottomex==0 && bottomen==1) flashType = MatchType::exTop_enBottom; + else flashType = MatchType::exTop; + } + else if (topen == 0 && sideen == 0 && topex == 0 && sideex == 1) + if(bottomex==0 && bottomen==1) flashType = MatchType::exSide_enBottom; + else flashType = MatchType::exSide; + else if (topen >= 1 && sideen == 0 && topex == 0 && sideex == 0) // could also add `if (MatchBottomCRT)` here + flashType = MatchType::enTop_mult; + else if (topen >= 1 && sideen == 0 && topex == 0 && sideex >= 1) // and here + flashType = MatchType::enTop_exSide_mult; + else + flashType = MatchType::others; + return flashType; + } + /// Information about a CRT hit matched with a PMT flash. struct MatchedCRT { From a97b2773d58f57dcb8dbc311613c4a227ed1c361 Mon Sep 17 00:00:00 2001 From: Anna Heggestuen Date: Tue, 3 Dec 2024 13:34:43 -0600 Subject: [PATCH 2/2] move AssignFlashClassification function definition to sbnobj/Common/CRT/CRTPMTMatching.hh and add documentation --- sbnobj/Common/CRT/CRTPMTMatching.cxx | 49 +++++++++++++++++++++++++ sbnobj/Common/CRT/CRTPMTMatching.hh | 54 +++++++++------------------- 2 files changed, 66 insertions(+), 37 deletions(-) create mode 100644 sbnobj/Common/CRT/CRTPMTMatching.cxx diff --git a/sbnobj/Common/CRT/CRTPMTMatching.cxx b/sbnobj/Common/CRT/CRTPMTMatching.cxx new file mode 100644 index 00000000..166561fc --- /dev/null +++ b/sbnobj/Common/CRT/CRTPMTMatching.cxx @@ -0,0 +1,49 @@ +/** + * @file sbnobj/Common/CRTPMTMatching.cxx + * @brief Data product to store CRT PMT Matches (implementation file). + * @author Anna Heggestuen (aheggest@colostate.edu) and Francesco Poppi (poppi@bo.infn.it) + * @date November 22, 2024 + * @see sbnobj/Common/CRTPMTMatching.hh + */ + +// Library header +#include "sbnobj/Common/CRT/CRTPMTMatching.hh" + +sbn::crt::MatchType sbn::crt::assignFlashClassification( + unsigned int topen, unsigned int topex, + unsigned int sideen, unsigned int sideex, + unsigned int bottomen, unsigned int bottomex +) +{ + MatchType flashType; + if (topen == 0 && sideen == 0 && topex == 0 && sideex == 0){ + if(bottomex==0 && bottomen==0) flashType = MatchType::noMatch; + else if (bottomex>=1 && bottomen==0) flashType = MatchType::exBottom; + else if (bottomex==0 && bottomen>=1) flashType = MatchType::enBottom; + else flashType = MatchType::others; + } + else if (topen == 1 && sideen == 0 && topex == 0 && sideex == 0){ + if(bottomex==1 && bottomen==0) flashType = MatchType::enTop_exBottom; + else flashType = MatchType::enTop; + } + else if (topen == 0 && sideen == 1 && topex == 0 && sideex == 0) + if(bottomex==1 && bottomen==0) flashType = MatchType::enSide_exBottom; + else flashType = MatchType::enSide; + else if (topen == 1 && sideen == 0 && topex == 0 && sideex == 1) + flashType = MatchType::enTop_exSide; + else if (topen == 0 && sideen == 0 && topex == 1 && sideex == 0){ + if(bottomex==0 && bottomen==1) flashType = MatchType::exTop_enBottom; + else flashType = MatchType::exTop; + } + else if (topen == 0 && sideen == 0 && topex == 0 && sideex == 1) + if(bottomex==0 && bottomen==1) flashType = MatchType::exSide_enBottom; + else flashType = MatchType::exSide; + else if (topen >= 1 && sideen == 0 && topex == 0 && sideex == 0) // could also add `if (MatchBottomCRT)` here + flashType = MatchType::enTop_mult; + else if (topen >= 1 && sideen == 0 && topex == 0 && sideex >= 1) // and here + flashType = MatchType::enTop_exSide_mult; + else + flashType = MatchType::others; + return flashType; + +} diff --git a/sbnobj/Common/CRT/CRTPMTMatching.hh b/sbnobj/Common/CRT/CRTPMTMatching.hh index 8761cf67..2c2b336a 100644 --- a/sbnobj/Common/CRT/CRTPMTMatching.hh +++ b/sbnobj/Common/CRT/CRTPMTMatching.hh @@ -5,8 +5,8 @@ * @date June 1 2023. */ -#ifndef CRTPMTMATCHING_hh_ -#define CRTPMTMATCHING_hh_ +#ifndef SBNOBJ_COMMON_CRTPMTMATCHING_HH +#define SBNOBJ_COMMON_CRTPMTMATCHING_HH // C++ includes #include @@ -33,41 +33,21 @@ namespace sbn::crt { exSide_enBottom = 14, ///< Matched with one Bottom CRT hit before the optical flash and matched with one Side CRT hit after the optical flash. others = 9 ///< All the other cases. }; - MatchType assignFlashClassification(uint topen, uint topex, - uint sideen, uint sideex, - uint bottomen, uint bottomex) - { - MatchType flashType; - if (topen == 0 && sideen == 0 && topex == 0 && sideex == 0){ - if(bottomex==0 && bottomen==0) flashType = MatchType::noMatch; - else if (bottomex>=1 && bottomen==0) flashType = MatchType::exBottom; - else if (bottomex==0 && bottomen>=1) flashType = MatchType::enBottom; - else flashType = MatchType::others; - } - else if (topen == 1 && sideen == 0 && topex == 0 && sideex == 0){ - if(bottomex==1 && bottomen==0) flashType = MatchType::enTop_exBottom; - else flashType = MatchType::enTop; - } - else if (topen == 0 && sideen == 1 && topex == 0 && sideex == 0) - if(bottomex==1 && bottomen==0) flashType = MatchType::enSide_exBottom; - else flashType = MatchType::enSide; - else if (topen == 1 && sideen == 0 && topex == 0 && sideex == 1) - flashType = MatchType::enTop_exSide; - else if (topen == 0 && sideen == 0 && topex == 1 && sideex == 0){ - if(bottomex==0 && bottomen==1) flashType = MatchType::exTop_enBottom; - else flashType = MatchType::exTop; - } - else if (topen == 0 && sideen == 0 && topex == 0 && sideex == 1) - if(bottomex==0 && bottomen==1) flashType = MatchType::exSide_enBottom; - else flashType = MatchType::exSide; - else if (topen >= 1 && sideen == 0 && topex == 0 && sideex == 0) // could also add `if (MatchBottomCRT)` here - flashType = MatchType::enTop_mult; - else if (topen >= 1 && sideen == 0 && topex == 0 && sideex >= 1) // and here - flashType = MatchType::enTop_exSide_mult; - else - flashType = MatchType::others; - return flashType; - } + + /** + * @brief Returns the classification of a TPC object based on the CRT hits associated to it. + * @param topen number of hits on the top CRT earlier than the object (entering) + * @param topex number of hits on the top CRT later than the object (exiting) + * @param sideen number of hits on any side CRT earlier than the object (entering) + * @param sideex number of hits on any side CRT later than the object (exiting) + * @param bottomen number of hits on the bottom CRT earlier than the object (entering) + * @param bottomex number of hits on the bottom side CRT later than the object (exiting) + * @return a value encoding the classification of the TPC object + * + */ + MatchType assignFlashClassification(unsigned int topen, unsigned int topex, + unsigned int sideen, unsigned int sideex, + unsigned int bottomen, unsigned int bottomex); /// Information about a CRT hit matched with a PMT flash. struct MatchedCRT {