Skip to content

Commit cbf2bbd

Browse files
author
Mun Jung Jung
committed
fcl to filter or save choppy events
1 parent f42c6be commit cbf2bbd

5 files changed

Lines changed: 92 additions & 61 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
add_subdirectory(OpReco)
22
add_subdirectory(CRT)
3+
add_subdirectory(DQM)

sbndcode/Calibration/DQM/CMakeLists.txt

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,3 @@
1-
# cet_build_plugin(FlagChoppy art::module
2-
# lardataobj::RecoBase
3-
# ROOT::Core
4-
# ROOT::Tree
5-
# art::Framework_Core
6-
# art::Framework_Principal
7-
# art::Utilities
8-
# art_root_io::tfile_support
9-
# art_root_io::TFileService_service
10-
# canvas::canvas
11-
# fhiclcpp::fhiclcpp
12-
# cetlib::cetlib
13-
# cetlib_except::cetlib_except
14-
# messagefacility::MF_MessageLogger
15-
# lardataobj::RawData
16-
# larcore::Geometry_Geometry_service
17-
# fhiclcpp::fhiclcpp
18-
# cetlib::cetlib
19-
# CLHEP::Random
20-
# ROOT::Geom
21-
# ROOT::XMLIO
22-
# ROOT::Gdml
23-
# ROOT::FFTW
24-
# )
25-
261
cet_build_plugin(FilterChoppy art::module
272
lardataobj::RecoBase
283
ROOT::Core

sbndcode/Calibration/DQM/FilterChoppy_module.cc

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ namespace filt{
9898
npeak = 0;
9999
delta_tmaxmin = 0;
100100

101-
102101
// get the timestamps
103102
art::Handle<std::vector<raw::RDTimeStamp>> timestamp_handle;
104103
evt.getByLabel("daq", timestamp_handle);
@@ -110,16 +109,14 @@ namespace filt{
110109
}
111110
art::fill_ptr_vector(raw_timestamps_handle, timestamp_handle);
112111

113-
114-
// analyze timestamp distributions
115-
// collect timestamps
112+
// collect TS
116113
unsigned timeindex = 0;
117114
for (auto const& timestamps: raw_timestamps_handle) {
118115
long this_ts = timestamps->GetTimeStamp();
119116
ts_vec.push_back(this_ts);
120117
timeindex++;
121118
}
122-
// make binned hist
119+
// find min, max TS values
123120
long ts_min = ts_vec[0];
124121
long ts_max = ts_vec[0];
125122
for (long ts : ts_vec) {
@@ -132,39 +129,42 @@ namespace filt{
132129
}
133130
delta_tmaxmin = std::abs(ts_max - ts_min);
134131

135-
float nbin = 100.;
136-
float bin_width = (ts_max - ts_min)/nbin;
137-
for (int i = 0; i < 100; ++i) {
138-
float bin_low = ts_min + i*bin_width;
139-
float bin_high = ts_min + (i+1)*bin_width;
140-
int bin_count = 0;
141-
for (long ts : ts_vec) {
142-
if ((bin_low < ts) & (ts <= bin_high)) {
143-
bin_count += 1;
144-
}
145-
}
146-
ts_hist_vec.push_back(bin_count);
147-
}
148-
// find peak bins
149-
for (int bc : ts_hist_vec) {
150-
//TODO: make threshold fcl parameter
151-
if (bc > 1000) {
152-
npeak += 1;
153-
}
154-
}
155-
156-
// If the energy deposit within the beam time is greater than some limit then trigger the event
157-
if (npeak > 1){
158-
std::cout << "Event " << event << " has " << npeak << " peaks" << std::endl;
159-
}
160-
if (delta_tmaxmin > 100000){
161-
std::cout << "Event " << event << " has a delta_tmaxmin of " << delta_tmaxmin << std::endl;
162-
}
163-
//return npeak < 2;
132+
// if (delta_tmaxmin > 100000){
133+
// std::cout << "Event " << event << " has a delta_tmaxmin of " << delta_tmaxmin << std::endl;
134+
// }
164135
return delta_tmaxmin < 100000;
165136

166-
}
167137

138+
// // Identify choppy events by looking at the # of peaks in the TS distribution
139+
// make binned hist
140+
// float nbin = 100.;
141+
// float bin_width = (ts_max - ts_min)/nbin;
142+
// for (int i = 0; i < 100; ++i) {
143+
// float bin_low = ts_min + i*bin_width;
144+
// float bin_high = ts_min + (i+1)*bin_width;
145+
// int bin_count = 0;
146+
// for (long ts : ts_vec) {
147+
// if ((bin_low < ts) & (ts <= bin_high)) {
148+
// bin_count += 1;
149+
// }
150+
// }
151+
// ts_hist_vec.push_back(bin_count);
152+
// }
153+
// // find peak bins
154+
// for (int bc : ts_hist_vec) {
155+
// //TODO: make threshold fcl parameter
156+
// if (bc > 1000) {
157+
// npeak += 1;
158+
// }
159+
// }
160+
161+
// // If the energy deposit within the beam time is greater than some limit then trigger the event
162+
// if (npeak > 1){
163+
// std::cout << "Event " << event << " has " << npeak << " peaks" << std::endl;
164+
// }
165+
// return npeak < 2;
166+
167+
}
168168

169169
void FilterChoppy::beginJob() {
170170
}

sbndcode/Calibration/DQM/filterchoppy.fcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ outputs:
3131
out1:
3232
{
3333
module_type: RootOutput
34-
fileName: "%ifb_filtered.root"
34+
fileName: "%ifb_choppyfiltered.root"
3535
dataTier: "filtered"
3636
fastCloning: true
3737
SelectEvents: [ filter ]
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#include "services_sbnd.fcl"
2+
#include "TPCChannelMapService.fcl"
3+
4+
process_name: FilterChoppy
5+
6+
services:
7+
{
8+
TFileService: { fileName: "reco_hist.root"}
9+
MemoryTracker: {}
10+
TimeTracker: {}
11+
RandomNumberGenerator: {}
12+
message: @local::sbnd_message_services_prod_debug
13+
FileCatalogMetadata: @local::art_file_catalog_mc
14+
TPCChannelMapService: @local::SBNDTPCChannelMapServiceDefaults
15+
AuxDetExptGeoHelperInterface: { service_provider: "sbndcode/CRT/CRTGeometryHelper" }
16+
ExptGeoHelperInterface: @local::sbnd_geometry_helper
17+
Geometry: @local::sbnd_geo
18+
GeometryConfigurationWriter: {}
19+
@table::sbnd_basic_services
20+
@table::sbnd_random_services
21+
}
22+
23+
source:
24+
{
25+
module_type: RootInput
26+
maxEvents: -1
27+
}
28+
29+
outputs:
30+
{
31+
out1:
32+
{
33+
module_type: RootOutput
34+
fileName: "%ifb_choppy.root"
35+
dataTier: "filtered"
36+
fastCloning: true
37+
SelectEvents: [ savechoppy ]
38+
}
39+
}
40+
41+
physics:
42+
{
43+
filters:
44+
{
45+
filterchoppy: {
46+
module_type: FilterChoppy
47+
}
48+
}
49+
50+
savechoppy: [ "!filterchoppy"]
51+
stream1: [ out1 ]
52+
trigger_paths: [ savechoppy ]
53+
end_paths: [ stream1 ]
54+
}
55+

0 commit comments

Comments
 (0)