Skip to content

Commit

Permalink
Add tool config crpChannelFemb with test. #28
Browse files Browse the repository at this point in the history
  • Loading branch information
dladams committed May 9, 2023
1 parent 7fda7e3 commit cfc166a
Show file tree
Hide file tree
Showing 5 changed files with 220 additions and 12 deletions.
1 change: 1 addition & 0 deletions dunedataprep/DataPrep/fcl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
# August 2016

install_fhicl()
add_subdirectory(test)
21 changes: 21 additions & 0 deletions dunedataprep/DataPrep/fcl/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# dunedataprep/dunedataprep/DataPrep/fcl/test
#
# David Adams
# May 2023

#cet_test(test_tool_crpChannelFemb_root HANDBUILT TEST_EXEC root.exe DATAFILES test_tool_crpChannelFemb)

cet_test(test_tool_crpChannelFemb
SOURCES
test_tool_crpChannelFemb.cxx
LIBRARIES
dunecore_ArtSupport
art::Utilities
canvas::canvas
fhiclcpp
cetlib::cetlib cetlib_except
cetlib_except::cetlib_except
SQLITE3
Boost::filesystem
ROOT_BASIC_LIB_LIST
)
61 changes: 61 additions & 0 deletions dunedataprep/DataPrep/fcl/test/test_tool_crpChannelFemb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//usr/bin/env root.exe -l -q $0; exit $?

// test_tool_crpChannelFemb
//
// David Adams
// May 2023
//
// This is an example of a Root script that can be excuted directly
// from the command line.

#include "dunecore/DuneInterface/Tool/IndexMapTool.h"
#include "dunecore/ArtSupport/DuneToolManager.h"

using Index = unsigned int;

int test_tool_crpChannelFemb() {

string line = "-------------------------------------------------------";
string fclnam = "vdcb2_tools.fcl";
string tnam = "crpChannelFemb";
cout << "Testing tool " << tnam << " in fcl file " << fclnam << endl;

cout << line << endl;
cout << "Creating tool manager from fcl " << fclnam << endl;
DuneToolManager* ptm = DuneToolManager::instance(fclnam);

cout << line << endl;
cout << "Fetching tool " << tnam << " from tool manager." << endl;
auto ptoo = ptm->getPrivate<IndexMapTool>(tnam);
if ( ptoo == nullptr ) return 1;

cout << line << endl;
cout << "Looping over channels." << endl;
Index nchan = 3072;
map<Index, Index> fembChanCount;
Index fmin = 1;
Index fmax = 24;
for ( Index icha=0; icha<nchan; ++icha ) {
Index ifmb = ptoo->get(icha);
if ( fembChanCount.count(ifmb) == 0 ) {
cout << "Adding FEMB " << ifmb << endl;
fembChanCount[ifmb] = 0;
}
if ( ifmb < fmin ) return 2;
if ( ifmb > fmax ) return 3;
++fembChanCount[ifmb];
}

cout << line << endl;
cout << "Checking FEMB channel counts." << endl;
for ( auto ent : fembChanCount ) {
Index ifmb = ent.first;
Index count = ent.second;
cout << "FEMB " << ifmb << " has " << count << " channels." << endl;
if ( count != 128 ) return 4;
}

cout << line << endl;
cout << "All tests pass." << endl;
return 0;
}
73 changes: 73 additions & 0 deletions dunedataprep/DataPrep/fcl/test/test_tool_crpChannelFemb.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// test_tool_crpChannelFemb.cxx

// David Adams
// May 2023
//
// Test for tool instance crpChannelFemb.

#include "dunecore/DuneInterface/Tool/IndexMapTool.h"
#include "dunecore/ArtSupport/DuneToolManager.h"
#include <string>
#include <iostream>
#include <map>

using std::string;
using std::cout;
using std::endl;
using std::map;

using Index = unsigned int;

#undef NDEBUG
#include <cassert>

int test_tool_crpChannelFemb() {

string line = "-------------------------------------------------------";
string fclnam = "vdcb2_tools.fcl";
string tnam = "crpChannelFemb";
cout << "Testing tool " << tnam << " in fcl file " << fclnam << endl;

cout << line << endl;
cout << "Creating tool manager from fcl " << fclnam << endl;
DuneToolManager* ptm = DuneToolManager::instance(fclnam);

cout << line << endl;
cout << "Fetching tool " << tnam << " from tool manager." << endl;
auto ptoo = ptm->getPrivate<IndexMapTool>(tnam);
assert( ptoo != nullptr );

cout << line << endl;
cout << "Looping over channels." << endl;
Index nchan = 3072;
map<Index, Index> fembChanCount;
Index fmin = 1;
Index fmax = 24;
for ( Index icha=0; icha<nchan; ++icha ) {
Index ifmb = ptoo->get(icha);
if ( fembChanCount.count(ifmb) == 0 ) {
cout << "Adding FEMB " << ifmb << endl;
fembChanCount[ifmb] = 0;
}
assert( ifmb >= fmin );
assert( ifmb <= fmax );
++fembChanCount[ifmb];
}

cout << line << endl;
cout << "Checking FEMB channel counts." << endl;
for ( auto ent : fembChanCount ) {
Index ifmb = ent.first;
Index count = ent.second;
cout << "FEMB " << ifmb << " has " << count << " channels." << endl;
assert( count == 128 );
}

cout << line << endl;
cout << "All tests pass." << endl;
return 0;
}

int main() {
return test_tool_crpChannelFemb();
}
76 changes: 64 additions & 12 deletions dunedataprep/DataPrep/fcl/vdcb2_tools.fcl
Original file line number Diff line number Diff line change
Expand Up @@ -113,24 +113,54 @@ tools.onlineChannelMapVdcb: {
tools.channelRanges: @local::tools.channelRangesVdcb2
tools.channelGroups: @local::tools.channelGroupsVdcb2

# Return FEMB index (1-16) for a bottom offline relative channel (0-3071).
# See https://github.com/DUNE/dunedataprep/issues/28
tools.crpChannelFemb: {
tool_type: TextIndexMapTool
LogLevel: 1
FileName: "$DUNEPROTOTYPES_DIR/config_data/vdcbce_chanmap_v4.txt"
FieldSeparators: " "
IndexIndex: 0
ValueIndex: 9
DefaultValue: 999999
}

################################################################################
# Reco tools.
################################################################################

############## Charge calibration ###################

# Scale samples from ke to ADC count for bottom CRU
tools.vdbcb_adcScaleAdcToKe: @local::tools.adcScaleAdcToKe
tools.vdbcb_adcScaleAdcToKe.ScaleFactor: 0.025
tools.vdbcb_adcScaleKeToAdc: @local::tools.adcScaleKeToAdc
tools.vdbcb_adcScaleKeToAdc.ScaleFactor: 40.0
# Scale samples from ke to ADC count.
tmp.adcScaleKeToAdc: {
tool_type: AdcSampleScaler
LogLevel: 1
ScaleFactor: 40.0
InputUnit: "ke/tick"
OutputUnit: "ADC count"
}
tmp.adcScaleAdcToKe: {
tool_type: AdcSampleScaler
LogLevel: 1
ScaleFactor: 0.025
InputUnit: "ADC count"
OutputUnit: "ke/tick"
}

# Scale samples from ke to ADC count for bottom CRP1
tools.vdbcb_adcScaleAdcToKe: @local::tmp.adcScaleAdcToKe
tools.vdbcb_adcScaleKeToAdc: @local::tmp.adcScaleKeToAdc

# scale samples from ke to ADC count for Top CRP2/3
tools.vdtcb2_adcScaleAdcToKe: @local::tools.adcScaleAdcToKe
# scale samples from ke to ADC count for Top CRP2,3
tools.vdtcb2_adcScaleAdcToKe: @local::tmp.adcScaleAdcToKe
tools.vdtcb2_adcScaleAdcToKe.ScaleFactor: 0.0319
tools.vdtcb2_adcScaleKeToAdc: @local::tools.adcScaleKeToAdc
tools.vdtcb2_adcScaleKeToAdc: @local::tmp.adcScaleKeToAdc
tools.vdtcb2_adcScaleKeToAdc.ScaleFactor: 31.35

# Scale samples from ke to ADC count for CRP4,5
tools.vdbcb4_adcScaleAdcToKe: @local::tmp.adcScaleAdcToKe
tools.vdbcb4_adcScaleKeToAdc: @local::tmp.adcScaleKeToAdc

################# Noise removal. ####################

# Raw RMS for each TPS channel.
Expand All @@ -157,11 +187,31 @@ tools.vdtcb2_cnrw: {

################# Signal finder ####################

tools.vdc_thresholdSignalFinder: @local::tools.adcThresholdSignalFinder
tools.vdc_thresholdSignalFinder.Threshold: 1.0
# Find ADC signals with simple threshold algorithm.
tools.vdc_thresholdSignalFinder: {
tool_type: AdcThresholdSignalFinder
LogLevel: 1
Threshold: 1.0
BinsBefore: 10
BinsAfter: 20
FlagPositive: true
FlagNegative: true
}

tools.vdcb_noiseSignalFinder: @local::tools.adcNoiseSignalFinder
tools.vdcb_noiseSignalFinder.ThresholdMin: 0.2
# Dynamic signal finder.
tools.vdcb_noiseSignalFinder: {
tool_type: AdcNoiseSignalFinder
LogLevel: 1
SigFracMax: 0.80
ThresholdMin: 0.2
ThresholdRatio: 4.0
ThresholdRatioTol: 0.1
MaxLoop: 20.0
BinsBefore: 10
BinsAfter: 20
FlagPositive: true
FlagNegative: true
}

################################################################################
# Performance tools.
Expand Down Expand Up @@ -396,3 +446,5 @@ tools.vdcb2_isoDepRoiMatcher: {
##### write matched ROIs to TTree in specified output file
tools.vdcb2_isoDepRoiMatcherWithOutput : @local::tools.vdcb2_isoDepRoiMatcher
tools.vdcb2_isoDepRoiMatcherWithOutput.OutFile: "isorois.root"

tmp: @erase

0 comments on commit cfc166a

Please sign in to comment.