Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
191 commits
Select commit Hold shift + click to select a range
94c59df
first build + commit
lynnt20 Oct 19, 2022
08bd042
added root tree, more explicit cut parameters, and opflashes
lynnt20 Oct 21, 2022
fa2b8a7
first commit of light reco attempt using visibility map
lynnt20 Oct 24, 2022
ccea7c6
working version with reco/true comparisons
lynnt20 Nov 4, 2022
afea365
added backtracker info
lynnt20 Nov 11, 2022
7ed0f0e
cleaned up trees, added wire assn, gamma weighted avg, true hit info
lynnt20 Nov 15, 2022
31847f3
clean up truth/reco hit information
lynnt20 Nov 29, 2022
b119273
add calibration constants for all planes
lynnt20 Dec 15, 2022
55032e6
use all hits instead of spacepoints->hits
lynnt20 Dec 15, 2022
fea4bf4
clean up calorimetry cmakelists
lynnt20 Jan 6, 2023
477b63a
calculate median as light estimate
lynnt20 Jan 11, 2023
eea4729
removed unweighted fcl, added arapucas and noise threshold
lynnt20 Jan 23, 2023
081f01d
fix tpc split bug, comitting debugging couts, add mean+median functions
lynnt20 Jan 24, 2023
91ad097
cleanup
lynnt20 Jan 25, 2023
2e972c0
cleanup: remove hardcoded values, add fcl params
lynnt20 Feb 17, 2023
ab13d13
Merge tag 'v09_67_00' into feature/lynnt_lightcalorimetry
lynnt20 Mar 7, 2023
5a0893c
added verbose + skip truth validation fcl
lynnt20 Mar 7, 2023
bd8b760
added verbose + skip truth validation fcl
lynnt20 Mar 7, 2023
bf0b0cc
initial commit of producer module
lynnt20 Apr 20, 2023
8411be8
working version of producer module
lynnt20 Apr 21, 2023
52c18df
cleanup, new functions, fcl parameters:
lynnt20 Apr 26, 2023
a1df52b
update output ttree, fix initialized/dummy ttree variables
lynnt20 May 16, 2023
d21b784
Merge tag 'v09_89_01' into feature/lynnt_lightcalorimetry
lynnt20 May 16, 2024
16ce241
switch to correct namespace for photon model, cleanup
lynnt20 May 16, 2024
b791b51
update opdet efficiencies and simulation values
lynnt20 May 16, 2024
543c337
make working version of fcl without the analyzer
lynnt20 May 16, 2024
2fc9be1
update noise/non-linearity thresholds
lynnt20 May 16, 2024
6b59f8e
small cleanup
lynnt20 Feb 12, 2025
07bdd70
Merge tag 'v09_93_01_02p02' into feature/lynnt_lightcalorimetry
lynnt20 Feb 12, 2025
37a8831
Merge tag 'v10_04_07' into feature/lynnt_lightcalorimetry
lynnt20 Apr 28, 2025
30cf079
update geometry service to compile with v10_04_07
lynnt20 Apr 28, 2025
22c27ad
intermediate commit for first lines that include opt0finder (compiles)
lynnt20 Apr 28, 2025
82222e3
update efficiency, visibility configs, and add channel mask
lynnt20 Apr 29, 2025
6ad380a
add fcl config to choose between flash matchers
lynnt20 Apr 29, 2025
c1dd670
fix bug with visibility/efficiency
lynnt20 Apr 29, 2025
dd10310
fcl syntax fix, adding `OpT0FinderProducer` value to fcl
lynnt20 Apr 29, 2025
c8561f8
add simple analyzer to scrape mc sim energy depo information after g4…
lynnt20 Apr 29, 2025
b83e549
add lightcalo ana only fcl
lynnt20 Apr 29, 2025
7ed0b0d
Merge tag 'v10_05_00' into feature/lynnt_lightcalorimetry
lynnt20 Apr 30, 2025
b2f560c
update running fcls
lynnt20 Aug 4, 2025
6a6a6f6
use vector instead of unordered set
lynnt20 Aug 4, 2025
b9e13a0
Merge tag 'v10_06_02' into feature/lynnt_lightcalorimetry
lynnt20 Aug 4, 2025
37d4683
Add pmt variations fcls
asanchezcastillo Jul 28, 2025
6447cf1
add more feaetures to mccaloana
asanchezcastillo Jul 28, 2025
151b2c9
Setup to start extended fragments feature
aliciavr Oct 9, 2025
1e492fd
Shift timing function
aliciavr Oct 9, 2025
3f93ceb
Waveforms decoding function
aliciavr Oct 9, 2025
b416a56
Add dump waveforms function
aliciavr Oct 9, 2025
0d9f644
Combine waveforms and correctly differentiates nominal from extended
aliciavr Oct 10, 2025
c1a42c0
Combine all extended fragments succesfully
aliciavr Oct 14, 2025
e165606
Add new comments for code documenting. New variable for debugging the…
aliciavr Oct 15, 2025
60036c5
Update SBN Document for reference
aliciavr Oct 15, 2025
2f7ff45
Add version number and update number of debug waveforms to 0
aliciavr Nov 5, 2025
15f34cd
First version of timing check implemented (some extended fragments do…
aliciavr Nov 6, 2025
3f44697
Add jittering debug option and combine fragments option
aliciavr Nov 7, 2025
b27bf1a
add more features to lightcaloana
lynnt20 Nov 13, 2025
a149a0c
update producer module to be aligned with analyzer
lynnt20 Nov 13, 2025
f4a7206
add more features to mccalo, now assumes only ONE neutrino interactio…
lynnt20 Nov 13, 2025
4b05f10
Merge tag 'v10_11_01_01' into feature/lynnt_lightcalorimetry_dev
lynnt20 Nov 13, 2025
103c567
updates to calls for semi analytical model, now using optical path tool
lynnt20 Nov 13, 2025
8a9f255
Merge branch 'feature/lynnt_lightcalorimetry' into feature/lynnt_ligh…
lynnt20 Nov 13, 2025
81b6742
remove simpleflash, add barycenter fm, add template class for collect…
lynnt20 Nov 13, 2025
ad848b4
missing import of optical path fcl config
lynnt20 Nov 13, 2025
c789803
properly define tree/branches (it runs now!)
lynnt20 Nov 13, 2025
882af92
clean up some includes
lynnt20 Nov 13, 2025
f289952
move bulk of code into new function to allow easier returns, official…
lynnt20 Nov 18, 2025
536eaac
move accessing flash matching handles into their relevant scopes
lynnt20 Nov 18, 2025
4fc4108
remove unneeded modules
lynnt20 Nov 18, 2025
26e3199
remove unecessary branches, TTrees, and fix mean functions
lynnt20 Nov 18, 2025
0ecce33
fix median function (don't need to separate between tpcs...)
lynnt20 Nov 18, 2025
c3eccec
remove truth validation, keep fcl prefix consistent in variable names…
lynnt20 Nov 19, 2025
43f7614
Update combination condition with timing features integrating the exp…
aliciavr Nov 24, 2025
177f2b4
Add warning for some unexpected types of fragments and fix fragments …
aliciavr Nov 25, 2025
8ee9ff5
cleanup
lynnt20 Jan 14, 2026
7c5d380
add to workflow and add sce labels by default
lynnt20 Jan 14, 2026
5c36bc8
Merge tag 'v10_14_02' into feature/lynnt_lightcalorimetry
lynnt20 Jan 14, 2026
e8a12f8
remove unused variable, match lightcalo constructor to updated obj
lynnt20 Jan 14, 2026
923e0fe
update to latest TPC calibration constants, opdet efficiencies, and m…
lynnt20 Jan 15, 2026
367fe62
mask should contain both off pmts and not reconstructable pmts
lynnt20 Jan 15, 2026
03e277f
add sce lightcalo label to cafmakerjob
lynnt20 Jan 15, 2026
132c8df
temporarily disable blipreco
lynnt20 Jan 15, 2026
d10e1ae
get opflashes explicitly for slices that cross the cathode; light wei…
lynnt20 Jan 21, 2026
40f18b7
get opflashes explicitly for slices that cross the cathode; light wei…
lynnt20 Jan 21, 2026
017f9ee
lightcalo fcl organization
lynnt20 Jan 21, 2026
4c0ebe0
remove nuscore cut since we're not using it anyways
lynnt20 Jan 21, 2026
c67c53b
undo blip commenting out
lynnt20 Jan 21, 2026
297632a
use pmt calibration database instead of fcl param to identify on/reco…
lynnt20 Jan 22, 2026
6432861
update PMT efficiencies to latest, remove hardcoded off/non-reconstru…
lynnt20 Jan 22, 2026
193666b
Merge branch 'feature/lynnt_lightcalorimetry' into feature/lynnt_ligh…
lynnt20 Jan 22, 2026
7fe5bab
inherit efficiency, tpc constants from their initial fcls; add units …
lynnt20 Jan 28, 2026
8f48fed
checks opflash producer size instead of assuming both tpcs
lynnt20 Jan 28, 2026
18876a7
add fcl param on whether to fill TTree, add more comments, remove unu…
lynnt20 Jan 28, 2026
8dff5ed
cleanup unused includes and dependencies
lynnt20 Jan 28, 2026
916b861
add initial filename/timestamp info on the output art file
lynnt20 Jan 29, 2026
2e219b7
update LightCaloProducer to conditionally fill TTree and enhance logg…
lynnt20 Jan 29, 2026
2bfc1df
Revert "Update to larsoft v10_14_02"
lynnt20 Jan 29, 2026
eb1a3a9
Add electron lifetime database support to LightCaloProducer and updat…
lynnt20 Jan 29, 2026
68d3ab0
Merge tag 'v10_14_02_01' into feature/lynnt_lightcalorimetry
lynnt20 Jan 29, 2026
81a67e8
order matters for reco workflow includes!
lynnt20 Jan 29, 2026
d6b3270
update CMake dependences for TPC calibdb
lynnt20 Jan 29, 2026
1a5e851
fix some elifetime bugs
lynnt20 Jan 29, 2026
da3ae91
move electron lifetime retrieval to avoid duplication during slice loop
lynnt20 Jan 29, 2026
9b056c4
remove or disable files which reference LegacyLArG4
lgarren Jan 30, 2026
9297360
remove or disable files which reference LegacyLArG4
lgarren Jan 30, 2026
a531049
remove or disable files which reference LegacyLArG4
lgarren Jan 30, 2026
cc0cd3a
Restore the shower merging algorithm in another place to avoid incons…
aliciavr Feb 3, 2026
888ecbb
Add fcl and pandora xml to support cluster validation metrics in ci s…
AndyChappell Feb 5, 2026
bcb99ee
Add synchronisation comment to Pandora Master xml
AndyChappell Feb 5, 2026
542d2f5
Add CRTBlob producer
henrylay97 Apr 3, 2025
5811843
Add blobs to CRT only fcls
henrylay97 Apr 3, 2025
8dba497
Modernise CMakeLists
henrylay97 Feb 16, 2026
5cb14c3
Change ADC saturation value to match data
henrylay97 Feb 20, 2025
6220ac4
Use saturation to correctly label strip hits
henrylay97 Feb 20, 2025
ae474af
Add option for blob branches in CRTAnalysis module
henrylay97 Feb 17, 2026
8e22b42
Clean up fcls
henrylay97 Feb 17, 2026
2215cc3
Manually check saturation
henrylay97 Feb 18, 2026
65b6003
Update sbncode version to v10_14_02_03
nathanielerowe Feb 19, 2026
7e3ef07
Merge branch 'develop' into feature/chappell_ci_pandora_clstr
nathanielerowe Feb 19, 2026
6419fbf
Add channel mapping version of module and relevant config
henrylay97 Feb 6, 2024
bb8dc73
Add bash script for making pdf
henrylay97 Feb 6, 2024
50586c9
Z points North not South, duh
henrylay97 Feb 6, 2024
184da01
Update channel map evds to test David's updates
henrylay97 Jun 24, 2024
f97696f
New CRT gdml channel mapping evds
henrylay97 Aug 25, 2024
27d0e16
Changes to channel map evd producer
henrylay97 Sep 28, 2024
25bc903
New round of channel map evds
henrylay97 Jan 27, 2025
a30a782
Updated CRT channel mapping display
henrylay97 May 15, 2025
380b27f
Make tex script more configurable
henrylay97 Feb 20, 2026
9a5c2ed
Make compatible with current develop
henrylay97 Feb 20, 2026
a196d7c
Remove unnecessary fcl
henrylay97 Feb 20, 2026
b36419c
Add functionality for turning off inversion - useful for the channel …
henrylay97 Jul 9, 2024
2134fb7
More configurable
henrylay97 Feb 23, 2026
cc83f73
Correctly name parameter
henrylay97 Feb 23, 2026
e20d622
Make consistent between fcl and bash script
henrylay97 Feb 23, 2026
df8562a
Include table for no inversion channel map
henrylay97 Feb 23, 2026
02dc045
Ensure tex file is saved in correct area
henrylay97 Feb 23, 2026
3ba37b5
Update sbncode version to v10_14_02_03
nathanielerowe Feb 19, 2026
029de7c
Missing branch from CRTAnalysis
henrylay97 Feb 23, 2026
b674480
Add ADRIFT - module for CRT calibration
henrylay97 Feb 23, 2026
70411b5
Add CRTRateAnalysis - module for CRT real time rate analysis
henrylay97 Feb 23, 2026
a446e0b
Add CRTTopHatAnalysis - module for CRT beam top hat analysis
henrylay97 Feb 23, 2026
c752a91
Add relevant functions for ADRIFT to GeoService
henrylay97 Feb 23, 2026
8693f80
Update sbncode version to v10_15_00
nathanielerowe Feb 24, 2026
263176b
Add skeleton for timing analysis
henrylay97 Feb 24, 2026
46bb0a2
Refactor cluster characterisation to allow external use of timing cor…
henrylay97 Feb 24, 2026
1459913
Update channel map service to add timing chains
henrylay97 Feb 24, 2026
75870c2
Fill space point branches in timing analysis
henrylay97 Feb 24, 2026
0f58321
Add track content to CRTTimingAnalysis module, plus a few bugfixes to…
henrylay97 Feb 25, 2026
1ca6df6
Make fcl changes to run CRTTimingAnalysis
henrylay97 Feb 25, 2026
8f8b77b
Make sure timing chain map is installed to path
henrylay97 Feb 25, 2026
cacb8d8
Add TPC slice based variables
henrylay97 Feb 25, 2026
5e7f17d
Add more reference shifts
henrylay97 Feb 25, 2026
2b8362d
Add a few missing branches
henrylay97 Feb 26, 2026
7bc5dee
More sensible default for uint
henrylay97 Feb 26, 2026
44a0672
Remove unnecessary tophat analysis module
henrylay97 Feb 27, 2026
cb47ee9
Remove reference to my data area
henrylay97 Feb 27, 2026
bdf38e4
Reduce code duplication
henrylay97 Feb 27, 2026
8efaff2
Correct some very old naming problems
henrylay97 Feb 27, 2026
076fc35
Add rate for tracks of limited angle
henrylay97 Mar 3, 2026
c505fda
Add xshift for CRT-TPC track matching
henrylay97 Mar 3, 2026
2771a92
Add track direction branches to spacepoint timing tree
henrylay97 Mar 5, 2026
a8353e2
If we're going to do comments lets get them right
henrylay97 Mar 5, 2026
1dd3071
Add README to point to documentation
henrylay97 Mar 5, 2026
3e9df79
Make safer - at John's suggestion
henrylay97 Mar 5, 2026
f27bb1b
Merge branch 'develop' into feature/hlay_crt_channel_map_evds
nathanielerowe Mar 6, 2026
b9c9abf
updating memory and cpu usage error bounds for CI tests
Mar 7, 2026
5f8afc2
Merge branch 'develop' into feature/hlay_crt_ana
nathanielerowe Mar 13, 2026
69a761a
Merge branch 'develop' into feature/aliciavr_XARAPUCA_offline_decoder…
nathanielerowe Mar 13, 2026
4360a3e
Merge pull request #847 from SBNSoftware/feature/aliciavr_XARAPUCA_of…
nathanielerowe Mar 13, 2026
6fde8ad
Merge branch 'develop' into bugfix/PandoraNeutrinoSettingsShowerMergi…
nathanielerowe Mar 13, 2026
9022e7b
Merge pull request #907 from SBNSoftware/bugfix/PandoraNeutrinoSettin…
nathanielerowe Mar 13, 2026
18f9f5b
Merge branch 'develop' into feature/lg_geant4_11
nathanielerowe Mar 13, 2026
8cb3f91
Merge pull request #903 from lgarren/feature/lg_geant4_11
nathanielerowe Mar 13, 2026
8d5b79e
Merge branch 'develop' into feature/hlay_crt_blobs
nathanielerowe Mar 13, 2026
f23c4b0
Merge pull request #916 from SBNSoftware/feature/hlay_crt_blobs
nathanielerowe Mar 13, 2026
5ae81e8
Merge branch 'develop' into feature/hlay_crt_saturation
nathanielerowe Mar 13, 2026
8f5dd42
Merge pull request #917 from SBNSoftware/feature/hlay_crt_saturation
nathanielerowe Mar 13, 2026
38d8ed4
Merge branch 'develop' into ci_memory_updates
nathanielerowe Mar 13, 2026
130c116
Merge pull request #921 from SBNSoftware/ci_memory_updates
nathanielerowe Mar 13, 2026
a1cccf8
Update sbncode version to v10_20_03
nathanielerowe Mar 13, 2026
30b75c8
Merge branch 'develop' into feature/hlay_crt_channel_map_evds
nathanielerowe Mar 13, 2026
c06fc26
Merge branch 'develop' into feature/hlay_crt_ana
nathanielerowe Mar 13, 2026
43e7807
Merge pull request #920 from SBNSoftware/feature/hlay_crt_ana
nathanielerowe Mar 13, 2026
1b8c860
Merge branch 'develop' into feature/hlay_crt_channel_map_evds
nathanielerowe Mar 13, 2026
4f6b3ea
Merge pull request #918 from SBNSoftware/feature/hlay_crt_channel_map…
nathanielerowe Mar 13, 2026
782ea81
Merge branch 'develop' into feature/chappell_ci_pandora_clstr
nathanielerowe Mar 13, 2026
04e41a8
Merge pull request #909 from SBNSoftware/feature/chappell_ci_pandora_…
nathanielerowe Mar 13, 2026
62fc4d5
Update versioning
nathanielerowe Mar 16, 2026
41d1365
Merge branch 'release/v10_20_03'
nathanielerowe Mar 16, 2026
9f1fff2
Merge tag 'v10_20_03' into develop
nathanielerowe Mar 16, 2026
229cb46
Remove LegacyLArG4 from MODULE_LIBRARIES
lynnt20 Apr 14, 2026
e64b8a4
Merge branch 'develop' into feature/lynnt_lightcalorimetry
nathanielerowe Apr 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

cmake_minimum_required(VERSION 3.20 FATAL_ERROR)

set(${PROJECT_NAME}_CMAKE_PROJECT_VERSION_STRING 10.14.02.02)
set(${PROJECT_NAME}_CMAKE_PROJECT_VERSION_STRING 10.20.03)
find_package(cetmodules REQUIRED)
project(sbndcode LANGUAGES CXX)

Expand Down
1 change: 1 addition & 0 deletions sbndcode/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ add_subdirectory(FlashMatch)
add_subdirectory(Filters)
add_subdirectory(ToFStudies)

add_subdirectory(Calorimetry)
# for wirecell
add_subdirectory(WireCell)

Expand Down
1,424 changes: 1,424 additions & 0 deletions sbndcode/CRT/CRTAna/ADRIFT_module.cc

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions sbndcode/CRT/CRTAna/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
art_make(
MODULE_LIBRARIES
ROOT::Tree
ROOT::Graf3d
art_root_io::TFileService_service
larsim::Utils
lardata::DetectorClocksService
sbndaq_artdaq_core::sbndaq-artdaq-core_Obj_SBND
sbnobj::SBND_CRT
sbnobj::SBND_Timing
sbnobj::Common_Reco
sbndcode_CRT_CRTBackTracker
sbndcode_CRT_CRTReco
sbndcode_ChannelMaps_CRT_CRTChannelMapService_service
)

install_fhicl()
149 changes: 108 additions & 41 deletions sbndcode/CRT/CRTAna/CRTAnalysis_module.cc

Large diffs are not rendered by default.

292 changes: 292 additions & 0 deletions sbndcode/CRT/CRTAna/CRTRateAnalysis_module.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,292 @@
////////////////////////////////////////////////////////////////////////
// Class: CRTRateAnalysis
// Plugin Type: analyzer (Unknown Unknown)
// File: CRTRateAnalysis_module.cc
//
// Generated at Tue Jan 7 05:28:06 2025 by Henry Lay using cetskelgen
// from cetlib version 3.18.02.
////////////////////////////////////////////////////////////////////////

#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 "TTree.h"

#include "canvas/Persistency/Common/FindOneP.h"
#include "canvas/Persistency/Common/FindManyP.h"

#include "artdaq-core/Data/RawEvent.hh"

#include "sbnobj/SBND/CRT/FEBData.hh"
#include "sbnobj/SBND/CRT/CRTSpacePoint.hh"
#include "sbnobj/SBND/CRT/CRTCluster.hh"
#include "sbnobj/SBND/CRT/CRTBlob.hh"

#include "sbndcode/Geometry/GeometryWrappers/CRTGeoService.h"
#include "sbndcode/ChannelMaps/CRT/CRTChannelMapService.h"

namespace sbnd {
namespace crt {
class CRTRateAnalysis;
}
}


class sbnd::crt::CRTRateAnalysis : public art::EDAnalyzer {
public:
explicit CRTRateAnalysis(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.
CRTRateAnalysis(CRTRateAnalysis const&) = delete;
CRTRateAnalysis(CRTRateAnalysis&&) = delete;
CRTRateAnalysis& operator=(CRTRateAnalysis const&) = delete;
CRTRateAnalysis& operator=(CRTRateAnalysis&&) = delete;

// Required functions.
void analyze(art::Event const& e) override;

void ResetEventVars();
void ResetRawVars();
void ResetSpacePointVars();
void ResetBlobVars();

private:

art::ServiceHandle<CRTGeoService> fCRTGeoService;
art::ServiceHandle<SBND::CRTChannelMapService> fCRTChannelMapService;

std::string fFEBDataModuleLabel, fCRTSpacePointModuleLabel,
fCRTBlobModuleLabel, fDAQHeaderModuleLabel, fDAQHeaderInstanceLabel;

TTree *fEventTree, *fRawTree, *fSpacePointTree, *fBlobTree;

int32_t _run, _subrun, _event;
uint32_t _event_header_ts;

int16_t _tagger, _module;
uint16_t _max_channel;

int16_t _n_hits;
double _x, _y, _z, _pe;

int16_t _n_total_sps, _n_bottom_sps, _n_bottom_sps_twohits, _n_south_sps,
_n_north_sps, _n_west_sps, _n_east_sps, _n_toplow_sps, _n_tophigh_sps;
};


sbnd::crt::CRTRateAnalysis::CRTRateAnalysis(fhicl::ParameterSet const& p)
: EDAnalyzer{p}
, fFEBDataModuleLabel(p.get<std::string>("FEBDataModuleLabel"))
, fCRTSpacePointModuleLabel(p.get<std::string>("CRTSpacePointModuleLabel"))
, fCRTBlobModuleLabel(p.get<std::string>("CRTBlobModuleLabel"))
, fDAQHeaderModuleLabel(p.get<std::string>("DAQHeaderModuleLabel"))
, fDAQHeaderInstanceLabel(p.get<std::string>("DAQHeaderInstanceLabel"))
{
art::ServiceHandle<art::TFileService> fs;

fEventTree = fs->make<TTree>("events", "");
fEventTree->Branch("run", &_run);
fEventTree->Branch("subrun", &_subrun);
fEventTree->Branch("event", &_event);
fEventTree->Branch("event_header_ts", &_event_header_ts);

fRawTree = fs->make<TTree>("readouts", "");
fRawTree->Branch("run", &_run);
fRawTree->Branch("subrun", &_subrun);
fRawTree->Branch("event", &_event);
fRawTree->Branch("event_header_ts", &_event_header_ts);
fRawTree->Branch("tagger", &_tagger);
fRawTree->Branch("module", &_module);
fRawTree->Branch("max_channel", &_max_channel);

fSpacePointTree = fs->make<TTree>("spacepoints", "");
fSpacePointTree->Branch("run", &_run);
fSpacePointTree->Branch("subrun", &_subrun);
fSpacePointTree->Branch("event", &_event);
fSpacePointTree->Branch("event_header_ts", &_event_header_ts);
fSpacePointTree->Branch("tagger", &_tagger);
fSpacePointTree->Branch("n_hits", &_n_hits);
fSpacePointTree->Branch("x", &_x);
fSpacePointTree->Branch("y", &_y);
fSpacePointTree->Branch("z", &_z);
fSpacePointTree->Branch("pe", &_pe);

fBlobTree = fs->make<TTree>("blobs", "");
fBlobTree->Branch("run", &_run);
fBlobTree->Branch("subrun", &_subrun);
fBlobTree->Branch("event", &_event);
fBlobTree->Branch("event_header_ts", &_event_header_ts);
fBlobTree->Branch("n_total_sps", &_n_total_sps);
fBlobTree->Branch("n_bottom_sps", &_n_bottom_sps);
fBlobTree->Branch("n_bottom_sps_twohits", &_n_bottom_sps_twohits);
fBlobTree->Branch("n_south_sps", &_n_south_sps);
fBlobTree->Branch("n_north_sps", &_n_north_sps);
fBlobTree->Branch("n_west_sps", &_n_west_sps);
fBlobTree->Branch("n_east_sps", &_n_east_sps);
fBlobTree->Branch("n_toplow_sps", &_n_toplow_sps);
fBlobTree->Branch("n_tophigh_sps", &_n_tophigh_sps);
fBlobTree->Branch("pe", &_pe);
}

void sbnd::crt::CRTRateAnalysis::analyze(art::Event const& e)
{
ResetEventVars();

_run = e.id().run();
_subrun = e.id().subRun();
_event = e.id().event();

art::Handle<artdaq::detail::RawEventHeader> DAQHeaderHandle;
e.getByLabel(fDAQHeaderModuleLabel, fDAQHeaderInstanceLabel, DAQHeaderHandle);

if(DAQHeaderHandle.isValid())
{
artdaq::RawEvent rawHeaderEvent = artdaq::RawEvent(*DAQHeaderHandle);
uint64_t raw_ts = rawHeaderEvent.timestamp();
_event_header_ts = raw_ts / static_cast<uint32_t>(1e9);
}

fEventTree->Fill();

art::Handle<std::vector<FEBData>> FEBDataHandle;
e.getByLabel(fFEBDataModuleLabel, FEBDataHandle);

std::vector<art::Ptr<FEBData>> FEBDataVec;
art::fill_ptr_vector(FEBDataVec, FEBDataHandle);

for(auto const& data : FEBDataVec)
{
ResetRawVars();
_tagger = fCRTGeoService->AuxDetIndexToTaggerEnum(data->Mac5());
_module = data->Mac5();

int max_adc = -1, max_ch = -1;

for(int ch = 0; ch < 32; ++ch)
{
int adc = data->ADC(ch);

if(adc > max_adc)
{
max_adc = adc;
max_ch = ch;
}
}

_max_channel = fCRTChannelMapService->ConstructOfflineChannelIDFromOfflineModuleIDAndOfflineLocalChannel(_module, max_ch);

fRawTree->Fill();
}

art::Handle<std::vector<CRTSpacePoint>> CRTSpacePointHandle;
e.getByLabel(fCRTSpacePointModuleLabel, CRTSpacePointHandle);

std::vector<art::Ptr<CRTSpacePoint>> CRTSpacePointVec;
art::fill_ptr_vector(CRTSpacePointVec, CRTSpacePointHandle);

art::FindOneP<CRTCluster> spacePointsToClusters(CRTSpacePointHandle, e, fCRTSpacePointModuleLabel);

for(auto const& spacePoint : CRTSpacePointVec)
{
ResetSpacePointVars();

const art::Ptr<CRTCluster> cluster = spacePointsToClusters.at(spacePoint.key());

_tagger = cluster->Tagger();
_n_hits = cluster->NHits();
_x = spacePoint->X();
_y = spacePoint->Y();
_z = spacePoint->Z();
_pe = spacePoint->PE();

fSpacePointTree->Fill();
}

art::Handle<std::vector<CRTBlob>> CRTBlobHandle;
e.getByLabel(fCRTBlobModuleLabel, CRTBlobHandle);

std::vector<art::Ptr<CRTBlob>> CRTBlobVec;
art::fill_ptr_vector(CRTBlobVec, CRTBlobHandle);

art::FindManyP<CRTSpacePoint> blobsToSpacePoints(CRTBlobHandle, e, fCRTBlobModuleLabel);

for(auto const& blob : CRTBlobVec)
{
ResetBlobVars();

_n_total_sps = blob->TotalSpacePoints();
_n_bottom_sps = blob->SpacePointsInTagger(kBottomTagger);
_n_south_sps = blob->SpacePointsInTagger(kSouthTagger);
_n_north_sps = blob->SpacePointsInTagger(kNorthTagger);
_n_west_sps = blob->SpacePointsInTagger(kWestTagger);
_n_east_sps = blob->SpacePointsInTagger(kEastTagger);
_n_toplow_sps = blob->SpacePointsInTagger(kTopLowTagger);
_n_tophigh_sps = blob->SpacePointsInTagger(kTopHighTagger);
_pe = blob->PE();

_n_bottom_sps_twohits = 0;

const std::vector<art::Ptr<CRTSpacePoint>> spacePoints = blobsToSpacePoints.at(blob.key());

for(auto const& spacePoint : spacePoints)
{
const art::Ptr<CRTCluster> cluster = spacePointsToClusters.at(spacePoint.key());

if(cluster->Tagger() == kBottomTagger && cluster->NHits() > 1)
++_n_bottom_sps_twohits;
}

fBlobTree->Fill();
}
}

void sbnd::crt::CRTRateAnalysis::ResetEventVars()
{
_run = -1; _subrun = -1; _event = -1;
_event_header_ts = std::numeric_limits<uint32_t>::max();
}

void sbnd::crt::CRTRateAnalysis::ResetRawVars()
{
_tagger = -1; _module = -1;
_max_channel = std::numeric_limits<uint16_t>::max();
}

void sbnd::crt::CRTRateAnalysis::ResetSpacePointVars()
{
_tagger = -1;

_n_hits = -1;

_x = std::numeric_limits<double>::lowest();
_y = std::numeric_limits<double>::lowest();
_z = std::numeric_limits<double>::lowest();
_pe = std::numeric_limits<double>::lowest();
}

void sbnd::crt::CRTRateAnalysis::ResetBlobVars()
{
_n_total_sps = -1;
_n_bottom_sps = -1;
_n_bottom_sps_twohits = -1;
_n_south_sps = -1;
_n_north_sps = -1;
_n_west_sps = -1;
_n_east_sps = -1;
_n_toplow_sps = -1;
_n_tophigh_sps = -1;

_pe = std::numeric_limits<double>::lowest();
}

DEFINE_ART_MODULE(sbnd::crt::CRTRateAnalysis)
Loading