Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
AdcDataPlotter Class Reference

#include <AdcDataPlotter.h>

Inheritance diagram for AdcDataPlotter:
TpcDataTool

Public Types

using Index = unsigned int
 
using IndexVector = std::vector< Index >
 
using IntVector = std::vector< int >
 
using IndexRangeVector = std::vector< IndexRange >
 
using Name = std::string
 
using NameVector = std::vector< Name >
 

Public Member Functions

 AdcDataPlotter (fhicl::ParameterSet const &ps)
 
 ~AdcDataPlotter () override=default
 
DataMap viewMap (const AdcChannelDataMap &acds) const override
 
bool updateWithView () const override
 

Private Member Functions

Name nameReplace (Name name, const AdcChannelData &acd, const IndexRange &ran) const
 
- Private Member Functions inherited from TpcDataTool
virtual DataMap updateTpcData (TpcData &) const
 
virtual DataMap viewTpcData (const TpcData &) const
 
virtual int forwardTpcData () const
 
- Private Member Functions inherited from AdcChannelTool
virtual ~AdcChannelTool ()=default
 
virtual DataMap update (AdcChannelData &) const
 
virtual DataMap view (const AdcChannelData &acd) const
 
virtual DataMap updateMap (AdcChannelDataMap &acds) const
 
virtual bool viewWithUpdate () const
 
virtual DataMap beginEvent (const DuneEventInfo &) const
 
virtual DataMap endEvent (const DuneEventInfo &) const
 
virtual DataMap close (const DataMap *dmin=nullptr)
 

Private Attributes

int m_LogLevel
 
int m_DataType
 
Name m_DataView
 
Name m_TickRange
 
Index m_TickRebin
 
NameVector m_ChannelRanges
 
float m_ClockFactor
 
float m_ClockOffset
 
IntVector m_FembTickOffsets
 
Name m_OnlineChannelMapTool
 
ParFormulam_MinSignal
 
ParFormulam_MaxSignal
 
IndexVector m_SkipChannelStatus
 
Index m_EmptyColor
 
Index m_ChannelLineModulus
 
IndexVector m_ChannelLinePattern
 
int m_Palette
 
Name m_HistName
 
Name m_HistTitle
 
Name m_PlotTitle
 
Index m_PlotSizeX
 
Index m_PlotSizeY
 
Name m_PlotFileName
 
Name m_RootFileName
 
IndexRange m_tickRange
 
bool m_needRunData
 
IndexRangeVector m_crs
 
const AdcChannelStringToolm_adcStringBuilder
 
const IndexMapToolm_pOnlineChannelMapTool
 
const RunDataToolm_prdtool
 

Additional Inherited Members

- Private Types inherited from AdcChannelTool
using Index = unsigned int
 
- Static Private Member Functions inherited from AdcChannelTool
static int interfaceNotImplemented ()
 

Detailed Description

Definition at line 88 of file AdcDataPlotter.h.

Member Typedef Documentation

using AdcDataPlotter::Index = unsigned int

Definition at line 92 of file AdcDataPlotter.h.

Definition at line 95 of file AdcDataPlotter.h.

Definition at line 93 of file AdcDataPlotter.h.

Definition at line 94 of file AdcDataPlotter.h.

Definition at line 96 of file AdcDataPlotter.h.

Definition at line 97 of file AdcDataPlotter.h.

Constructor & Destructor Documentation

AdcDataPlotter::AdcDataPlotter ( fhicl::ParameterSet const &  ps)

Definition at line 35 of file AdcDataPlotter_tool.cc.

36 : m_LogLevel(ps.get<int>("LogLevel")),
37  m_DataType(ps.get<int>("DataType")),
38  m_DataView(ps.get<string>("DataView")),
39  m_TickRange(ps.get<string>("TickRange")),
40  m_TickRebin(ps.get<Index>("TickRebin")),
41  m_ChannelRanges(ps.get<NameVector>("ChannelRanges")),
42  m_ClockFactor(ps.get<float>("ClockFactor")),
43  m_ClockOffset(ps.get<float>("ClockOffset")),
44  m_FembTickOffsets(ps.get<IntVector>("FembTickOffsets")),
45  m_MinSignal(nullptr),
46  m_MaxSignal(new RootParFormula("MaxSignal", ps.get<Name>("MaxSignal"))),
47  m_SkipChannelStatus(ps.get<IndexVector>("SkipChannelStatus")),
48  m_EmptyColor(ps.get<double>("EmptyColor")),
49  m_ChannelLineModulus(ps.get<Index>("ChannelLineModulus")),
50  m_ChannelLinePattern(ps.get<IndexVector>("ChannelLinePattern")),
51  m_Palette(ps.get<int>("Palette")),
52  m_HistName(ps.get<string>("HistName")),
53  m_HistTitle(ps.get<string>("HistTitle")),
54  m_PlotTitle(ps.get<string>("PlotTitle")),
55  m_PlotSizeX(ps.get<Index>("PlotSizeX")),
56  m_PlotSizeY(ps.get<Index>("PlotSizeY")),
57  m_PlotFileName(ps.get<string>("PlotFileName")),
58  m_RootFileName(ps.get<string>("RootFileName")),
59  m_needRunData(false),
60  m_pOnlineChannelMapTool(nullptr),
61  m_prdtool(nullptr) {
62  const string myname = "AdcDataPlotter::ctor: ";
63  string stmp;
64  if ( m_MaxSignal->npar() ) m_needRunData = true;
65  ps.get_if_present("MinSignal", stmp);
66  if ( stmp.size() ) {
67  m_MinSignal = new RootParFormula("MinSignal", stmp);
68  if ( m_MinSignal->npar() ) m_needRunData = true;
69  }
71  string stringBuilder = "adcStringBuilder";
72  m_adcStringBuilder = ptm->getShared<AdcChannelStringTool>(stringBuilder);
73  if ( m_adcStringBuilder == nullptr ) {
74  cout << myname << "WARNING: AdcChannelStringTool not found: " << stringBuilder << endl;
75  }
76  if ( m_FembTickOffsets.size() ) {
77  m_OnlineChannelMapTool = ps.get<string>("OnlineChannelMapTool");
79  }
80  // Fetch tick range.
81  string descTickRange;
82  if ( m_TickRange.size() ) {
83  const string tnam = "tickRanges";
84  const IndexRangeTool* ptool = ptm->getShared<IndexRangeTool>(tnam);
85  if ( ptool == nullptr ) {
86  cout << myname << "WARNING: Tick range tool not found: " << tnam << endl;
87  } else {
88  m_tickRange = ptool->get(m_TickRange);
89  }
90  if ( ! m_tickRange.isValid() ) {
91  // Issue warning if the range does not have label.
92  if ( m_tickRange.label(0) == "" ) {
93  cout << myname << "WARNING: Tick range not found: " << m_TickRange << endl;
94  }
95  }
96  descTickRange = m_TickRange + " " + m_tickRange.rangeString();
97  }
98  // Fetch channel ranges.
99  const IndexRangeTool* pcrt = nullptr;
100  for ( Name crn : m_ChannelRanges.size() ? m_ChannelRanges : NameVector(1, "") ) {
101  string::size_type ipos = crn.find(":");
102  if ( crn.size() == 0 || crn == "data" ) {
103  m_crs.emplace_back("data", 0, 0, "All data");
104  } else if ( ipos != string::npos ) {
105  cout << myname << "Decoding explicit range " << crn << endl;
106  Index ich1 = std::stoi(crn.substr(0,ipos));
107  Index ich2 = std::stoi(crn.substr(ipos+1));
108  Name rename = crn.substr(0,ipos) + "to" + crn.substr(ipos+1);
109  m_crs.emplace_back(rename, ich1, ich2, crn);
110  } else {
111  if ( pcrt == nullptr ) {
112  pcrt = ptm->getShared<IndexRangeTool>("channelRanges");
113  if ( pcrt == nullptr ) {
114  cout << myname << "ERROR: IndexRangeTool not found: channelRanges" << endl;
115  }
116  }
117  if ( pcrt != nullptr ) {
118  IndexRange ran = pcrt->get(crn);
119  if ( ran.isValid() ) {
120  m_crs.push_back(ran);
121  } else {
122  cout << myname << "WARNING: Channel range not found: " << crn << endl;
123  }
124  }
125  }
126  }
127  // Fetch the run data tool.
128  if ( m_needRunData ) {
129  string stnam = "runDataTool";
130  m_prdtool = ptm->getShared<RunDataTool>(stnam);
131  if ( m_prdtool == nullptr ) {
132  cout << myname << "ERROR: RunDataTool " << stnam
133  << " not found. Metric limits will not be evaluated." << endl;
134  } else {
135  cout << myname << "RunDataTool retrieved." << endl;
136  }
137  }
138  // Display configuration.
139  if ( m_LogLevel ) {
140  cout << myname << "Configuration: " << endl;
141  cout << myname << " LogLevel: " << m_LogLevel << endl;
142  cout << myname << " DataType: " << m_DataType << endl;
143  cout << myname << " DataView: " << m_DataView << endl;
144  cout << myname << " TickRange: " << descTickRange << endl;
145  cout << myname << " TickRebin: " << m_TickRebin << endl;
146  cout << myname << " ChannelRanges: [";
147  bool first = true;
148  for ( const IndexRange& ran : m_crs ) {
149  if ( ! first ) cout << ", ";
150  else first = false;
151  cout << ran.name;
152  }
153  cout << "]" << endl;
154  cout << myname << " FembTickOffsets: [";
155  first = true;
156  for ( int ioff : m_FembTickOffsets ) {
157  if ( first ) first = false;
158  else cout << ", ";
159  cout << ioff;
160  }
161  cout << "]" << endl;
162  cout << myname << " ClockFactor: " << m_ClockFactor << endl;
163  cout << myname << " ClockOffset: " << m_ClockOffset << endl;
164  if ( m_FembTickOffsets.size() ) {
165  cout << myname << " OnlineChannelMapTool: " << m_OnlineChannelMapTool << " @ "
167  }
168  if ( m_MinSignal != nullptr )
169  cout << myname << " MinSignal: " << m_MinSignal->formulaString() << endl;
170  cout << myname << " MaxSignal: " << m_MaxSignal->formulaString() << endl;
171  cout << myname << " SkipChannelStatus: [";
172  first = true;
173  for ( Index ista : m_SkipChannelStatus ) {
174  if ( ! first ) cout << ", ";
175  first = false;
176  cout << ista;
177  }
178  cout << "]" << endl;
179  cout << myname << " EmptyColor: " << m_EmptyColor << endl;
180  cout << myname << " ChannelLineModulus: " << m_ChannelLineModulus << endl;
181  cout << myname << " ChannelLinePattern: {";
182  first = true;
183  for ( Index icha : m_ChannelLinePattern ) {
184  if ( ! first ) cout << ", ";
185  first = false;
186  cout << icha;
187  }
188  cout << "}" << endl;
189  cout << myname << " Palette: " << m_Palette << endl;
190  cout << myname << " HistName: " << m_HistName << endl;
191  cout << myname << " HistTitle: " << m_HistTitle << endl;
192  cout << myname << " PlotTitle: " << m_PlotTitle << endl;
193  cout << myname << " PlotSizeX: " << m_PlotSizeX << endl;
194  cout << myname << " PlotSizeY: " << m_PlotSizeY << endl;
195  cout << myname << " PlotFileName: " << m_PlotFileName << endl;
196  cout << myname << " RootFileName: " << m_RootFileName << endl;
197  }
198 }
std::vector< Index > IndexVector
IndexVector m_SkipChannelStatus
virtual Name formulaString() const =0
IndexVector m_ChannelLinePattern
ChannelGroupService::Name Name
IntVector m_FembTickOffsets
IndexRange m_tickRange
unsigned int Index
bool isValid() const
Definition: IndexRange.h:94
Name m_OnlineChannelMapTool
Name name
Definition: IndexRange.h:32
virtual Index npar() const
Definition: ParFormula.h:44
const AdcChannelStringTool * m_adcStringBuilder
static constexpr double ps
Definition: Units.h:99
Name label(Index ilab=0) const
Definition: IndexRange.h:106
std::vector< int > IntVector
Definition: fcldump.cxx:26
ParFormula * m_MinSignal
NameVector m_ChannelRanges
std::vector< string > NameVector
IndexRangeVector m_crs
ParFormula * m_MaxSignal
const RunDataTool * m_prdtool
std::string rangeString() const
Definition: IndexRange.h:97
const IndexMapTool * m_pOnlineChannelMapTool
std::vector< Name > NameVector
static DuneToolManager * instance(std::string fclname="", int dbg=1)
T * getShared(std::string name)
QTextStream & endl(QTextStream &s)
Index m_ChannelLineModulus
virtual IndexRange get(Name nam) const =0
def rename(src, dest)
AdcDataPlotter::~AdcDataPlotter ( )
overridedefault

Member Function Documentation

string AdcDataPlotter::nameReplace ( Name  name,
const AdcChannelData acd,
const IndexRange ran 
) const
private

Definition at line 504 of file AdcDataPlotter_tool.cc.

504  {
505  StringManipulator sman(name, false);
506  sman.replace("%CRNAME%", ran.name);
507  sman.replace("%CRLABEL%", ran.label(0));
508  sman.replace("%CRLABEL1%", ran.label(1));
509  sman.replace("%CRLABEL2%", ran.label(2));
511  if ( pnbl == nullptr ) return name;
512  DataMap dm;
513  dm.setInt("chan1", ran.first());
514  dm.setInt("chan2", ran.last());
515  return pnbl->build(acd, dm, name);
516 }
static QCString name
Definition: declinfo.cpp:673
Name name
Definition: IndexRange.h:32
Index last() const
Definition: IndexRange.h:96
static std::string build(const AdcChannelStringTool *ptool, const AdcChannelData &acd, const DataMap &dm, std::string spat)
void setInt(Name name, int val)
Definition: DataMap.h:131
const AdcChannelStringTool * m_adcStringBuilder
Name label(Index ilab=0) const
Definition: IndexRange.h:106
Index first() const
Definition: IndexRange.h:95
bool AdcDataPlotter::updateWithView ( ) const
inlineoverridevirtual

Reimplemented from AdcChannelTool.

Definition at line 104 of file AdcDataPlotter.h.

104 { return true; }
DataMap AdcDataPlotter::viewMap ( const AdcChannelDataMap acds) const
overridevirtual

Reimplemented from AdcChannelTool.

Definition at line 202 of file AdcDataPlotter_tool.cc.

202  {
203  const string myname = "AdcDataPlotter::viewMap: ";
204  DataMap ret;
205  if ( acds.size() == 0 ) {
206  cout << myname << "WARNING: Channel map is empty. No plot is created." << endl;
207  return ret.setStatus(1);
208  }
209  const AdcChannelData& acdFirst = acds.begin()->second;
210  const AdcChannelData& acdLast = acds.rbegin()->second;
211  bool isPrep = m_DataType == 0;
212  bool isRaw = m_DataType == 1;
213  bool isSig = m_DataType == 2;
214  bool isNsg = m_DataType == 3;
215  // Find the tick range.
216  Tick maxtick = 0;
217  for ( const AdcChannelDataMap::value_type& iacd : acds ) {
218  if ( iacd.first == AdcChannelData::badChannel() ) {
219  cout << myname << "WARNING: Channel map has invalid channels. No plot is created." << endl;
220  }
221  Tick ntick = isRaw ? iacd.second.raw.size() : iacd.second.samples.size();
222  if ( ntick > maxtick ) maxtick = ntick;
223  }
224  AdcIndex acdChanFirst = acdFirst.channel();
225  AdcIndex acdChanLast = acdLast.channel();
226  unsigned long tick1 = 0;
227  unsigned long tick2 = maxtick;
228  if ( m_tickRange.isValid() ) {
229  tick1 = m_tickRange.begin;
230  tick2 = m_tickRange.end;
231  }
232  Tick ntick = tick2 - tick1;
233  ret.setInt("ntick", ntick);
234  if ( ntick <= 0 ) {
235  cout << myname << "ERROR: Invalid tick range." << endl;
236  return ret.setStatus(2);
237  }
238  // Evaluate formulas.
239  if ( m_prdtool != nullptr ) {
240  Index run = acdFirst.run();
241  RunData rdat = m_prdtool->runData(run);
242  if ( ! rdat.isValid() ) {
243  cout << myname << "WARNING: RunData not found for run " << run << "." << endl;
244  } else {
246  if ( m_MinSignal != nullptr ) rdat.setFormulaPars(*m_MinSignal);
247  }
248  }
249  double zmax = m_MaxSignal->eval();
250  double zmin = m_MinSignal == nullptr ? -zmax : m_MinSignal->eval();
251  // Loop over channel ranges.
252  Index nhist = 0;
253  for ( IndexRange ran : m_crs ) {
254  if ( ran.name == "data" ) {
255  ran.begin = acdChanFirst;
256  ran.end = acdChanLast + 1;
257  }
258  if ( ! ran.isValid() ) {
259  cout << myname << "ERROR: Skipping invalid channel range " << ran.name << endl;
260  continue;
261  }
262  Index chanBegin = ran.first();
263  Index chanEnd = ran.end;
264  // Find the range of data channels in the plot range: [ichanDataBegin, ichanDataEnd)
265  AdcChannelDataMap::const_iterator ichanDataBegin = acds.lower_bound(chanBegin);
266  AdcChannelDataMap::const_iterator ichanDataEnd = acds.upper_bound(ran.last());
267  Index chanDataEnd = ichanDataEnd == acds.end() ? chanEnd : ichanDataEnd->first;
268  Index chanDataBegin = ichanDataBegin == acds.end() ? chanDataEnd : ichanDataBegin->first;
269  // Skip plot if no data channels are in range.
270  if ( chanDataEnd <= chanDataBegin ) {
271  if ( m_LogLevel >= 2 ) cout << myname << "Data has no entries in channel range " << ran.name << endl;
272  if ( m_LogLevel >= 3 ) {
273  cout << myname << " chanBegin: " << chanBegin << endl;
274  cout << myname << " chanEnd: " << chanEnd << endl;
275  cout << myname << " chanDataBegin: " << chanDataBegin << endl;
276  cout << myname << " chanDataEnd: " << chanDataEnd << endl;
277  }
278  continue;
279  }
280  if ( m_LogLevel >= 2 ) cout << myname << "Creating histogram for channel range " << ran.name << endl;
281  AdcIndex nchan = chanEnd - chanBegin;
282  // Create title and file names.
283  DataMap dm;
284  dm.setInt("chan1", acdChanFirst);
285  dm.setInt("chan2", acdChanLast-1);
286  string hname = nameReplace( m_HistName, acdFirst, ran);
287  string htitl = nameReplace( m_HistTitle, acdFirst, ran);
288  string ptitl = nameReplace( m_PlotTitle, acdFirst, ran);
289  string ofname = nameReplace(m_PlotFileName, acdFirst, ran);
290  string ofrname = nameReplace(m_RootFileName, acdFirst, ran);
291  string szunits = "(ADC counts)";
292  if ( ! isRaw ) {
293  szunits = acdFirst.sampleUnit;
294  if ( szunits.find(" ") != string::npos ) szunits = "(" + szunits + ")";
295  }
296  string zunit = szunits;
297  if ( zunit.find(" ") != string::npos ) zunit = "(" + zunit + ")";
298  bool zhasTick = zunit.find("Tick") != string::npos || zunit.find("tick") != string::npos;
299  if ( ! zhasTick ) zunit += "/tick";
300  zunit += "/channel";
301  htitl += "; Tick; Channel; Signal [" + zunit + "]";
302  // Set flag indicating we want to show empty bins with the color m_EmptyColor.
303  // We initialize all bins below zmin and fill with zmin where the value would be lower.
304  // We do not attempt this this where rebinning is done.
305  //bool colorEmptyBins = m_EmptyColor >= 0 && m_TickRebin <= 1;
306  bool colorEmptyBins = m_TickRebin <= 1;
307  // Create histogram.
308  TH2* ph = new TH2F(hname.c_str(), htitl.c_str(), ntick, tick1, tick2, nchan, chanBegin, chanEnd);
309  ph->SetDirectory(nullptr);
310  ph->SetStats(0);
311  if ( m_LogLevel >= 2 ) cout << myname << "Created histogram " << hname << endl;
312  ph->GetZaxis()->SetRangeUser(zmin, zmax);
313  ph->SetContour(200);
314  double zempty = colorEmptyBins ? zmin - 1000.0 : 0.0;
315  // Initialize bins to zmin.
316  for ( Index icha=1; icha<=nchan; ++icha ) {
317  Index ibin0 = (ntick+2)*icha + 1;
318  for ( Index ibin=ibin0; ibin<ibin0+ntick; ++ibin ) ph->SetBinContent(ibin, zempty);
319  }
320  // Fill histogram.
321  for ( AdcChannel chan=chanDataBegin; chan<chanDataEnd; ++chan ) {
322  AdcChannelDataMap::const_iterator iacd = acds.find(chan);
323  if ( iacd == acds.end() ) continue;
324  const AdcChannelData& acdtop = iacd->second;
325  Index chstat = acdtop.channelStatus();
326  const IndexVector& drops = m_SkipChannelStatus;
327  if ( drops.size() && std::find(drops.begin(), drops.end(), chstat) != drops.end() ) continue;
328  Index ibiny = chan-chanBegin + 1;
329  Index nent = acdtop.viewSize(m_DataView);
330  if ( m_LogLevel >= 2 && nent == 0 ) {
331  cout << myname << "WARNING: Unable to find data view name " << m_DataView << endl;
332  }
333  for ( Index ient=0; ient<nent; ++ient ) {
334  if ( m_LogLevel >= 3 ) {
335  cout << myname << "Processing data view " << ient << "/" << nent << endl;
336  }
337  const AdcChannelData* pacd = acdtop.viewEntry(m_DataView, ient);
338  if ( pacd == nullptr ) {
339  cout << myname << "ERROR: Skipping null view entry " << m_DataView << "[" << ient
340  << "]." << endl;
341  continue;
342  }
343  if ( pacd->channel() != chan ) {
344  cout << myname << "ERROR: Skipping view entry " << m_DataView << "[" << ient
345  << "] with the wrong the wrong channel: "
346  << pacd->channel() << " != " << chan <<"." << endl;
347  continue;
348  }
349  const AdcSignalVector& sams = pacd->samples;
350  const AdcFilterVector& keep = pacd->signal;
351  const AdcCountVector& raw = pacd->raw;
352  AdcSignal ped = 0.0;
353  bool isRawPed = false;
354  if ( isRaw ) {
355  ped = pacd->pedestal;
356  isRawPed = ped != AdcChannelData::badSignal();
357  }
358  Tick nsam = isRaw ? raw.size() : sams.size();
359  AdcInt dsam = pacd->tick0;
360  if ( m_ClockFactor > 0.0 ) {
361  double dclk = 0.0;
362  if ( pacd->channelClock >= pacd->triggerClock() ) dclk = pacd->channelClock - pacd->triggerClock();
363  else dclk = -double(pacd->triggerClock() - pacd->channelClock);
364  dsam += m_ClockFactor*(dclk + m_ClockOffset);
365  }
366  if ( m_FembTickOffsets.size() ) {
367  if ( m_pOnlineChannelMapTool == nullptr ) {
368  cout << myname << " FEMB tick offsets provided without online channel mapping tool." << endl;
369  break;
370  }
371  Index chanOn = m_pOnlineChannelMapTool->get(chan);
372  Index ifmb = chanOn/128;
373  if ( ifmb < m_FembTickOffsets.size() ) dsam += m_FembTickOffsets[ifmb];
374 
375  }
376  if ( m_LogLevel >= 3 ) {
377  cout << myname << "Filling channel-tick histogram with " << nsam << " samples and offset "
378  << dsam << " for channel " << chan << endl;
379  }
380  Index ibin = ph->GetBin(1, ibiny);
381  for ( Tick itck=tick1; itck<tick2; ++itck, ++ibin ) {
382  AdcInt iisam = itck;
383  iisam -= dsam;
384  if ( iisam >= 0 ) {
385  AdcIndex isam = iisam;
386  float sig = 0.0;
387  if ( (isSig || isNsg) && isam >= pacd->signal.size() ) {
388  if ( m_LogLevel >= 3 ) {
389  cout << myname << " Signal array not filled for sample " << isam
390  << " and above--stopping fill." << endl;
391  }
392  break;
393  }
394  if ( isPrep ) {
395  if ( isam < sams.size() ) sig = sams[isam];
396  else break;
397  } else if ( isRawPed ) {
398  if ( isam < raw.size() ) sig = raw[isam] - ped;
399  else break;
400  } else if ( isRaw && isam >= raw.size() ) {
401  // Ped missing is ok if we have no raw
402  break;
403  } else if ( isSig ) {
404  if ( isam < sams.size() && isam < keep.size() ) {
405  if ( keep[isam] ) sig = sams[isam];
406  } else {
407  break;
408  }
409  } else if ( isNsg ) {
410  if ( isam < sams.size() ) {
411  if ( isam >= keep.size() || !keep[isam] ) sig = sams[isam];
412  } else {
413  break;
414  }
415  } else {
416  cout << myname << "Fill failed for bin " << ibin << endl;
417  }
418  if ( colorEmptyBins && sig < zmin ) sig = zmin;
419  ph->SetBinContent(ibin, sig);
420  }
421  }
422  }
423  }
424  // Rebin.
425  if ( m_TickRebin > 1 ) {
426  TH2* ph0 = ph;
427  ph = ph0->RebinX(m_TickRebin, ph->GetName());
428  ph->SetDirectory(nullptr);
429  delete ph0;
430  ph->Scale(1.0/m_TickRebin);
431  ph->GetZaxis()->SetRangeUser(-zmax, zmax);
432  }
433 /*
434  // Save the original color map.
435  RootPalette oldPalette;
436  RootPalette::set(m_Palette);
437 */
438  const RootPalette* ppal = RootPalette::find(m_Palette);
439  if ( ppal == nullptr ) {
440  cout << myname << "ERROR: Unable to find palette " << m_Palette << endl;
441  return ret.setStatus(3);
442  }
443  TPadManipulator man;
444  man.setPalette(m_Palette);
446  man.add(ph, "colz");
447  man.setRangeZ(zmin, zmax);
448  man.addAxis();
449  // Root uses the frame color for underflows.
450  // If we are coloring empty bins, we use that color.
451  // If not, we use the color for the first (lowest) bin.
452  int frameColor = colorEmptyBins ? m_EmptyColor : ppal->colorVector()[0];
453  man.setFrameFillColor(frameColor); // Otherwise Root uses white for underflows
454  if ( m_ChannelLineModulus ) {
455  for ( Index icha : m_ChannelLinePattern ) {
457  }
458  } else {
459  for ( Index icha : m_ChannelLinePattern ) {
460  if ( icha > chanBegin && icha < chanEnd ) {
461  man.addHorizontalLine(icha, 1.0, 3);
462  }
463  }
464  }
465  TLatex* pptl = nullptr;
466  if ( ptitl.size() ) {
467  pptl = new TLatex(0.01, 0.015, ptitl.c_str());
468  pptl->SetNDC();
469  pptl->SetTextFont(42);
470  pptl->SetTextSize(0.030);
471  man.add(pptl);
472  }
473  man.print(ofname);
474  delete pptl;
475  if ( 0 ) {
476  string line;
477  cout << myname;
478  cout.flush();
479  std::getline(cin, line);
480  }
481  if ( m_LogLevel > 1 ) {
482  cout << myname << "Created plot ";
483  cout << "for channels [" << chanBegin << " - "
484  << chanEnd << "): " << ofname << endl;
485  }
486  if ( ofrname.size() ) {
487  TFile* pfile = TFile::Open(ofrname.c_str(), "UPDATE");
488  ph->Write();
489  if ( m_LogLevel > 1 ) cout << myname << "Wrote " << ph->GetName() << " to " << ofrname << endl;
490  delete pfile;
491  }
492 /*
493  oldPalette.setRootPalette();
494 */
495  ++nhist;
496  }
497  ret.setInt("nhist", nhist);
498  return ret;
499 }
std::vector< AdcCount > AdcCountVector
Definition: AdcTypes.h:19
std::vector< Index > IndexVector
IndexVector m_SkipChannelStatus
int add(unsigned int ipad, TObject *pobj, std::string sopt="", bool replace=false)
DataMap & setStatus(int stat)
Definition: DataMap.h:130
float AdcSignal
Definition: AdcTypes.h:21
Index begin
Definition: IndexRange.h:34
virtual double eval(const Values &vars) const =0
IndexVector m_ChannelLinePattern
int setRangeZ(double y1, double y2)
int setCanvasSize(int wx, int wy)
IntVector m_FembTickOffsets
IndexRange m_tickRange
intermediate_table::const_iterator const_iterator
Raw data description.
unsigned int Index
bool isValid() const
Definition: IndexRange.h:94
int setFrameFillColor(int col)
Index end
Definition: IndexRange.h:35
Name nameReplace(Name name, const AdcChannelData &acd, const IndexRange &ran) const
bool isValid() const
Definition: RunData.h:48
static Index badSignal()
int addHorizontalLine(double yoff=0.0, double lenfrac=1.0, int isty=1)
int AdcInt
Definition: AdcTypes.h:14
virtual Index get(Index idx) const =0
AdcIndex run() const
int addAxis(bool flag=true)
void setInt(Name name, int val)
Definition: DataMap.h:131
virtual RunData runData(Index run, Index subRun=0) const =0
AdcSignalVector::size_type Tick
AdcCountVector raw
unsigned int AdcIndex
Definition: AdcTypes.h:15
Index channelStatus() const
ParFormula * m_MinSignal
Channel channel() const
AdcSignal pedestal
AdcFilterVector signal
std::vector< bool > AdcFilterVector
Definition: AdcTypes.h:27
const std::vector< int > & colorVector() const
Definition: RootPalette.h:79
unsigned int AdcChannel
Definition: AdcTypes.h:50
IndexRangeVector m_crs
void line(double t, double *p, double &x, double &y, double &z)
const AdcChannelData * viewEntry(Name vpnam, AdcIndex ient) const
AdcLongIndex channelClock
std::vector< AdcSignal > AdcSignalVector
Definition: AdcTypes.h:22
ParFormula * m_MaxSignal
const RunDataTool * m_prdtool
size_t viewSize() const
static Index badChannel()
const IndexMapTool * m_pOnlineChannelMapTool
SetStat setFormulaPars(TFormula *form)
Definition: RunData.h:87
int addHorizontalModLines(double ymod, double yoff=0.0, double lenfrac=1.0, int isty=3)
void setPalette(int ipal)
int print(std::string fname, std::string spat="{,}")
AdcSignalVector samples
AdcLongIndex triggerClock() const
QTextStream & endl(QTextStream &s)
static const RootPalette * find(unsigned int ipal)
Definition: RootPalette.cxx:34
Index m_ChannelLineModulus

Member Data Documentation

const AdcChannelStringTool* AdcDataPlotter::m_adcStringBuilder
private

Definition at line 142 of file AdcDataPlotter.h.

Index AdcDataPlotter::m_ChannelLineModulus
private

Definition at line 123 of file AdcDataPlotter.h.

IndexVector AdcDataPlotter::m_ChannelLinePattern
private

Definition at line 124 of file AdcDataPlotter.h.

NameVector AdcDataPlotter::m_ChannelRanges
private

Definition at line 114 of file AdcDataPlotter.h.

float AdcDataPlotter::m_ClockFactor
private

Definition at line 115 of file AdcDataPlotter.h.

float AdcDataPlotter::m_ClockOffset
private

Definition at line 116 of file AdcDataPlotter.h.

IndexRangeVector AdcDataPlotter::m_crs
private

Definition at line 139 of file AdcDataPlotter.h.

int AdcDataPlotter::m_DataType
private

Definition at line 110 of file AdcDataPlotter.h.

Name AdcDataPlotter::m_DataView
private

Definition at line 111 of file AdcDataPlotter.h.

Index AdcDataPlotter::m_EmptyColor
private

Definition at line 122 of file AdcDataPlotter.h.

IntVector AdcDataPlotter::m_FembTickOffsets
private

Definition at line 117 of file AdcDataPlotter.h.

Name AdcDataPlotter::m_HistName
private

Definition at line 126 of file AdcDataPlotter.h.

Name AdcDataPlotter::m_HistTitle
private

Definition at line 127 of file AdcDataPlotter.h.

int AdcDataPlotter::m_LogLevel
private

Definition at line 109 of file AdcDataPlotter.h.

ParFormula* AdcDataPlotter::m_MaxSignal
private

Definition at line 120 of file AdcDataPlotter.h.

ParFormula* AdcDataPlotter::m_MinSignal
private

Definition at line 119 of file AdcDataPlotter.h.

bool AdcDataPlotter::m_needRunData
private

Definition at line 136 of file AdcDataPlotter.h.

Name AdcDataPlotter::m_OnlineChannelMapTool
private

Definition at line 118 of file AdcDataPlotter.h.

int AdcDataPlotter::m_Palette
private

Definition at line 125 of file AdcDataPlotter.h.

Name AdcDataPlotter::m_PlotFileName
private

Definition at line 131 of file AdcDataPlotter.h.

Index AdcDataPlotter::m_PlotSizeX
private

Definition at line 129 of file AdcDataPlotter.h.

Index AdcDataPlotter::m_PlotSizeY
private

Definition at line 130 of file AdcDataPlotter.h.

Name AdcDataPlotter::m_PlotTitle
private

Definition at line 128 of file AdcDataPlotter.h.

const IndexMapTool* AdcDataPlotter::m_pOnlineChannelMapTool
private

Definition at line 143 of file AdcDataPlotter.h.

const RunDataTool* AdcDataPlotter::m_prdtool
private

Definition at line 144 of file AdcDataPlotter.h.

Name AdcDataPlotter::m_RootFileName
private

Definition at line 132 of file AdcDataPlotter.h.

IndexVector AdcDataPlotter::m_SkipChannelStatus
private

Definition at line 121 of file AdcDataPlotter.h.

Name AdcDataPlotter::m_TickRange
private

Definition at line 112 of file AdcDataPlotter.h.

IndexRange AdcDataPlotter::m_tickRange
private

Definition at line 135 of file AdcDataPlotter.h.

Index AdcDataPlotter::m_TickRebin
private

Definition at line 113 of file AdcDataPlotter.h.


The documentation for this class was generated from the following files: