15 using std::ostringstream;
20 : m_LogLevel(ps.
get<
Index>(
"LogLevel")),
21 m_PlotChannelRanges(ps.
get<
NameVector>(prefix +
"ChannelRanges")),
22 m_PlotChannelGroups(ps.
get<
NameVector>(prefix +
"ChannelGroups")),
23 m_PlotOverlayGroups(ps.
get<
Index>(prefix +
"OverlayGroups")),
24 m_PlotDataView(ps.
get<
Name>(prefix +
"DataView")),
25 m_PlotName(ps.
get<
Name>(prefix +
"Name")),
26 m_PlotSummaryNames(ps.
get<
NameVector>(prefix +
"SummaryNames")),
27 m_PlotSizeX(ps.
get<
Index>(prefix +
"SizeX")),
28 m_PlotSizeY(ps.
get<
Index>(prefix +
"SizeY")),
29 m_PlotSplitX(ps.
get<
Index>(prefix +
"SplitX")),
30 m_PlotSplitY(ps.
get<
Index>(prefix +
"SplitY")) {
31 const Name myname =
"AdcMultiChannelPlotter::ctor: ";
35 cout << myname <<
" " << prefix +
"ChannelRanges: [";
37 if ( first ) first =
false;
42 cout << myname <<
" " << prefix +
"ChannelGroups: [";
45 if ( first ) first =
false;
53 cout << myname <<
" " << prefix <<
"SummaryNames: [";
56 if ( first ) first =
false;
66 Name stringBuilder =
"adcStringBuilder";
68 if ( ptm ==
nullptr ) {
69 cout << myname <<
"ERROR: Tool manager not found." <<
endl;
74 cout << myname <<
"WARNING: AdcChannelStringTool not found: " << stringBuilder <<
endl;
79 if ( pcgt ==
nullptr ) {
80 cout << myname <<
"ERROR: IndexRangeGroupTool not found: channelGroups" <<
endl;
85 cout << myname <<
"WARNING: Skipping invalid group " << cgn <<
endl;
93 cout << myname <<
"WARNING: Skipping invalid range " << crn <<
" in group " << cgn <<
endl;
96 if ( ppad ==
nullptr ) {
100 if ( ppad->
crmap.find(crn) != ppad->
crmap.end() ) {
101 cout << myname <<
"WARNING: Ignoring duplicate channel range group " << cgn <<
endl;
105 ppad->
crmap[crn] = ran;
114 if ( pcrt ==
nullptr ) {
115 cout << myname <<
"ERROR: IndexRangeTool not found: channelRanges" <<
endl;
120 cout << myname <<
"WARNING: Skipping invalid range " << crn <<
endl;
126 pad.
crmap[crn] = ran;
143 const Name myname =
"AdcMultiChannelPlotter::viewMap: ";
145 if ( acds.size() == 0 )
return ret;
152 Index npadOnPage = 0;
156 npadOnPage = npadx*npady;
159 cout << myname <<
"Per page pad count is " << npadOnPage <<
" (" << npady <<
" x " << npadx <<
")" <<
endl;
168 for ( AdcChannelDataMap::value_type iacd : acds ) {
174 Name scha = sscha.str();
175 while ( scha.size() < 6 ) scha =
"0" + scha;
176 scha =
"chan" + scha;
177 localPads.emplace_back(scha);
178 Pad& pad = localPads.back();
184 Index npad = pads.size();
185 if (
getLogLevel() >= 4 ) cout << myname <<
"Pad count is " << npad <<
endl;
188 Index ipadOnPage = 0;
189 for (
Index ipad=0; ipad<npad; ++ipad ) {
190 const Pad& pad = pads[ipad];
193 cout << myname <<
" Processing pad " << ipad <<
" for channel group " << cgn <<
endl;
196 for (
Index icr=0; icr<ncr; ++icr ) {
200 cout <<
"ERROR: Range " << crn <<
" in pad group " << cgn <<
" is invalid. Aborting." <<
endl;
204 cout << myname <<
" Processing range " << ran <<
endl;
207 if ( iacd1 == acds.end() ) {
208 if (
getLogLevel() >= 5 ) cout << myname <<
" Skipping range above data." << endl;
212 if ( iacd2 == iacd1 ) {
213 if (
getLogLevel() >= 5 ) cout << myname <<
" Skipping range below data." << endl;
220 Index icha = iacd->first;
222 cout << myname <<
"WARNING: View " <<
getDataView() <<
" is missing for channel " 223 << icha <<
"." <<
endl;
226 for (
Index idve=0; idve<ndve; ++idve ) {
232 Index nacd = acdvec.size();
233 cout << myname <<
" Processing channel range " << crn <<
" with " << nacd
234 <<
" entr" << (nacd == 1 ?
"y" :
"ies" ) <<
" in " << ncha <<
" channel" 235 << (ncha == 1 ?
"" :
"s") <<
"." <<
endl;
239 acdTmp.
setEventInfo(acds.begin()->second.getEventInfoPtr());
240 if ( pmantop ==
nullptr ) {
243 if ( npadOnPage > 1 ) pmantop->
split(npadx, npady);
246 if ( cgrn.size() == 0 ) {
251 if ( plotName.size() == 0 && acdvec.size() ) {
257 sman.
replace(
"%CGRNAME%", cgrn);
259 plotName = sman.
str();
261 if ( plotName.size() ) cout << myname <<
" Created pad with plot name " << plotName << endl;
262 else cout << myname <<
" Created pad with no plot name." <<
endl;
265 cout << myname <<
" Run " << acdFirst.
run() <<
", event " << acdFirst.
event()
266 <<
" group/range " << cgrn <<
" ==> plot name " << plotName <<
endl;
271 if ( ppadPage ==
nullptr ) {
272 cout << myname <<
"ERROR: View pad " << ipadOnPage <<
" not found for pad " << ipad
273 <<
", channel range " << crn <<
"." <<
endl;
281 bool lastpad = (npadOnPage == 0) || (ipadOnPage == npadOnPage) || (ipad+1 == npad);
282 if ( lastpad && pmantop !=
nullptr ) {
283 if ( plotName.size() ) {
284 if (
getLogLevel() >= 3 ) cout << myname <<
" Printing canvas to " << plotName << endl;
285 pmantop->
print(plotName);
287 if (
getLogLevel() >= 3 ) cout << myname <<
" Not printing canvas for channel group/range " 288 << cgrn <<
"." <<
endl;
299 ret.
setInt(
"multiChannelNChannel", ncha);
300 ret.
setInt(
"multiChannelNPlot", nplt);
307 const Name myname =
"AdcMultiChannelPlotter::viewSummary: ";
309 if (
getLogLevel() >= 3 ) cout << myname <<
"Summmary plots not named for level " << ilev <<
endl;
312 if (
getLogLevel() >= 3 ) cout << myname <<
"Creating summmary plots for level " << ilev <<
endl;
315 Index npadOnPage = 1;
319 npadOnPage = npadx*npady;
322 cout << myname <<
"Pad count/page is " << npadOnPage <<
" (" << npady <<
" x " << npadx <<
")" <<
endl;
332 Name scha = sscha.str();
333 while ( scha.size() < 6 ) scha =
"0" + scha;
334 scha =
"chan" + scha;
335 localPads.emplace_back(scha);
336 Pad& pad = localPads.back();
342 Index npad = pads.size();
348 if (
getLogLevel() >= 3 ) cout << myname <<
"Pad count is " << npad <<
endl;
349 for (
Index ipad =0; ipad<npad; ++ipad ) {
350 const Pad& pad = pads[ipad];
352 Index ipadOnPage = npad == 0 ? 0 : ipad % npadOnPage;
353 if (
getLogLevel() >= 4 ) cout << myname <<
" Channel group " << cgn
354 <<
" channel range count is " << pad.
crnames.size() <<
endl;
357 for (
Index icrn=0; icrn<ncrn; ++icrn ) {
360 cout << myname <<
" Processing group/range " << cgn <<
"/" << crn <<
endl;
363 if ( cgrn.size() == 0 ) {
368 if ( pmantop ==
nullptr ) {
369 if (
getLogLevel() >= 3 ) cout << myname <<
" Creating canvas for run " << acdPrint.
run()
370 <<
", event " << acdPrint.
event() <<
"." <<
endl;
373 if ( npadOnPage > 1 ) pmantop->
split(npadx, npady);
381 sman.
replace(
"%CGRNAME%", cgrn);
385 int rstat =
viewMapSummary(ilev, cgn, crn, *pmantop->
man(ipadOnPage), ncrn, icrn);
386 if ( rstat >= 1 ) cout << myname <<
"WARNING: viewMapSummary returned error code " << rstat <<
endl;
387 if (
getLogLevel() >= 5 ) cout << myname <<
" Pad " << ipadOnPage <<
" extra object count: " 391 bool lastpad = (npadOnPage == 0) || (ipadOnPage+1 == npadOnPage) || (ipad+1 == npad);
392 if ( lastpad && pmantop !=
nullptr ) {
393 if (
getLogLevel() >= 3 ) cout << myname <<
" Printing summary canvas to " << plotName << endl;
394 pmantop->
print(plotName);
406 const Name myname =
"AdcMultiChannelPlotter::getChannelGroup: ";
Index getLogLevel() const
Index m_PlotOverlayGroups
std::vector< Name > NameVector
Name getPlotSummaryName(Index ilev) const
BaseState & getBaseState() const
~AdcMultiChannelPlotter() override
int replace(std::string substr, const T &xsub)
int setCanvasSize(int wx, int wy)
int split(Index nx, Index ny)
const std::string & str() const
NameVector m_PlotChannelRanges
void viewSummary(Index ilev) const
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
void setChannelInfo(ChannelInfoPtr pchi)
AdcMultiChannelPlotter(const fhicl::ParameterSet &ps, Name prefix="Plot")
const IndexRangeGroup & getChannelGroup(Name cgn) const
bool haveChannelRanges() const
DataMap viewMap(const AdcChannelDataMap &acds) const override
bool haveChannelGroups() const
void setEventInfo(EventInfoPtr pevi)
void setInt(Name name, int val)
virtual int viewMapSummary(Index ilev, Name cgn, Name crn, TPadManipulator &man, Index ncr, Index icr) const =0
static constexpr double ps
TPadManipulator * man(unsigned int ipad=0)
bool overlayGroups() const
std::vector< Pad > PadVector
NameVector m_PlotChannelGroups
virtual int viewMapChannels(Name crn, const AcdVector &acds, TPadManipulator &man, Index ncr, Index icr) const =0
const AdcChannelData * viewEntry(Name vpnam, AdcIndex ient) const
std::map< AdcChannel, AdcChannelData > AdcChannelDataMap
const TObjVector & objects() const
auto const & get(AssnsNode< L, R, D > const &r)
bool hasView(Name vnam) const
const AdcChannelStringTool * m_adcStringBuilder
int print(std::string fname, std::string spat="{,}")
std::vector< const AdcChannelData * > AcdVector
QTextStream & endl(QTextStream &s)
Event finding and building.
NameVector m_PlotSummaryNames