-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tool config crpChannelFemb with test. #28
- Loading branch information
Showing
5 changed files
with
220 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
# August 2016 | ||
|
||
install_fhicl() | ||
add_subdirectory(test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
73
dunedataprep/DataPrep/fcl/test/test_tool_crpChannelFemb.cxx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters