16 string optionString(
Index iopt) {
17 if ( iopt == 0 )
return "No copy";
18 if ( iopt == 1 )
return "One ROI/map";
19 if ( iopt == 2 )
return "One ROI for all maps";
20 return "Invalid option";
30 : m_LogLevel(ps.
get<
int>(
"LogLevel")),
34 const string myname =
"AdcToRoi2d::ctor: ";
36 cout << myname <<
"WARNING: Invalid option: " <<
m_Option 37 <<
" will be treated as 0." <<
endl;
42 cout << myname <<
" Option: " <<
m_Option 44 cout << myname <<
" OutputNames: [";
47 if ( first ) first =
false;
62 const string myname =
"AdcToRoi2d::updateTpcData: ";
68 vector<LongIndex> itck1s(nacm, lmax);
69 vector<LongIndex> itck2s(nacm, 0);
70 vector<Index> icha1s(nacm, imax);
71 vector<Index> icha2s(nacm, 0);
72 vector<Index> ndats(nacm, 0);
74 if (
m_LogLevel >= 3 ) cout << myname <<
"Channel map count: " << nacm <<
endl;
76 if ( mapIndices.size() == 0 ) {
77 for (
Index iacm=0; iacm<nacm; ++iacm ) mapIndices.push_back(iacm);
79 for (
Index iacm : mapIndices ) {
81 cout << myname <<
"WARNING: Skipping invalid ADC map index " << iacm <<
endl;
87 if (
m_LogLevel >=2 ) cout << myname <<
"Skipping missing ADC channel map." <<
endl;
91 if ( pacm->size() == 0 ) {
92 if (
m_LogLevel >=2 ) cout << myname <<
"Skipping empty ADC channel map." <<
endl;
96 if (
m_LogLevel >= 3 ) cout << myname <<
" Channel count: " << pacm->size() <<
endl;
97 for (
const auto& iacd : *pacm ) {
101 Index icha2 = icha1 + 1;
103 Index itck2 = itck1 + nsam;
104 if ( icha1 < icha1s[iacm] ) icha1s[iacm] = icha1;
105 if ( icha2 > icha2s[iacm] ) icha2s[iacm] = icha2;
106 if ( itck1 < itck1s[iacm] ) itck1s[iacm] = itck1;
107 if ( itck2 > itck2s[iacm] ) itck2s[iacm] = itck2;
109 <<
" sample count: " << nsam <<
endl;
112 if ( icha1s[iacm] >= icha2s[iacm] ) {
113 cout << myname <<
"ERROR: Channels out of range. Skipping ADC map " << iacm <<
"." <<
endl;
118 cout << myname <<
"ERROR: No samples found. Skipping ADC map " << iacm <<
"." <<
endl;
122 if ( itck1s[iacm] >= itck2s[iacm] ) {
123 cout << myname <<
"ERROR: Ticks out of range. Skipping ADC map " << iacm <<
"." <<
endl;
128 LongIndex ncha = icha2s[iacm] - icha1s[iacm];
129 LongIndex ntck = itck2s[iacm] - itck1s[iacm];
131 double frac = double(ndat)/double(ncht);
133 cout << myname <<
" ADC map is " << ncha <<
" x " << ntck
134 <<
" with fill fraction " << frac <<
endl;
135 cout << myname <<
" Channel range: [ " << icha1s[iacm] <<
", " << icha2s[iacm] <<
")" <<
endl;
136 cout << myname <<
" Tick range: [ " << itck1s[iacm] <<
", " << itck2s[iacm] <<
")" <<
endl;
142 for (
Index iacm=0; iacm<nacm; ++iacm ) {
143 Index icha1 = icha1s[iacm];
144 Index icha2 = icha2s[iacm];
147 if ( icha1 >= icha2 )
continue;
148 if ( itck1 >= itck2 )
continue;
149 Index ncha = icha2 - icha1;
152 tpd.
get2dRois().emplace_back(ncha, ntck, icha1, itck1);
157 cout << myname <<
"WARNING: No outpu name supplied for ADC map " << iacm <<
endl;
161 if ( ptpdo ==
nullptr ) {
163 if ( ptpdo ==
nullptr ) {
164 cout << myname <<
"ERROR: Unable to add TpcData directory " << nam <<
endl;
167 cout << myname <<
"Added TpcData directory " << nam <<
endl;
170 cout << myname <<
"Using existing TpcData directory " << nam <<
endl;
178 for (
const auto& iacd : *pacm ) {
180 idxs[0] = acd.
channel() - icha1;
182 for (
Index isam=0; isam<acd.
samples.size(); ++isam, ++idxs[1], ++ndat ) {
186 roiNdats.push_back(ndat);
187 if ( ndat != ndats[iacm] ) {
188 cout << myname <<
"ERROR: Unexpected fill count: " << ndat <<
" != " << ndats[iacm] <<
endl;
193 cout << myname <<
"ERROR: Merging of ADC data is not yet supported." <<
endl;
196 ret.
setInt(
"a2r_nroi", nroi);
DataMap updateTpcData(TpcData &tpd) const override
DataMap & setStatus(int stat)
std::shared_ptr< AdcChannelDataMap > AdcDataPtr
TpcData * addTpcData(Name nam, bool copyAdcData=true)
void setIntVector(Name name, const IntVector &val)
AdcDataVector & getAdcData()
std::vector< Name > NameVector
std::array< Index, 2 > IndexArray
AdcLongIndex tickOffset() const
void setInt(Name name, int val)
static constexpr double ps
AdcToRoi2d(fhicl::ParameterSet const &ps)
TpcData * getTpcData(Name nam)
const DataArray & data() const
std::vector< Index > IndexVector
auto const & get(AssnsNode< L, R, D > const &r)
IndexVector m_InputAdcMaps
Index setValue(const IndexArray &isams, Float val, Index *pchk=nullptr)
Tpc2dRoiVector & get2dRois()
QTextStream & endl(QTextStream &s)