203 const string myname =
"AdcDataPlotter::viewMap: ";
205 if ( acds.size() == 0 ) {
206 cout << myname <<
"WARNING: Channel map is empty. No plot is created." <<
endl;
217 for (
const AdcChannelDataMap::value_type& iacd : acds ) {
219 cout << myname <<
"WARNING: Channel map has invalid channels. No plot is created." <<
endl;
221 Tick ntick = isRaw ? iacd.second.raw.size() : iacd.second.samples.size();
222 if ( ntick > maxtick ) maxtick = ntick;
226 unsigned long tick1 = 0;
227 unsigned long tick2 = maxtick;
232 Tick ntick = tick2 - tick1;
233 ret.
setInt(
"ntick", ntick);
235 cout << myname <<
"ERROR: Invalid tick range." <<
endl;
243 cout << myname <<
"WARNING: RunData not found for run " << run <<
"." <<
endl;
254 if ( ran.name ==
"data" ) {
255 ran.begin = acdChanFirst;
256 ran.end = acdChanLast + 1;
258 if ( ! ran.isValid() ) {
259 cout << myname <<
"ERROR: Skipping invalid channel range " << ran.name <<
endl;
262 Index chanBegin = ran.first();
263 Index chanEnd = ran.end;
267 Index chanDataEnd = ichanDataEnd == acds.end() ? chanEnd : ichanDataEnd->first;
268 Index chanDataBegin = ichanDataBegin == acds.end() ? chanDataEnd : ichanDataBegin->first;
270 if ( chanDataEnd <= chanDataBegin ) {
271 if (
m_LogLevel >= 2 ) cout << myname <<
"Data has no entries in channel range " << ran.name <<
endl;
273 cout << myname <<
" chanBegin: " << chanBegin <<
endl;
274 cout << myname <<
" chanEnd: " << chanEnd <<
endl;
275 cout << myname <<
" chanDataBegin: " << chanDataBegin <<
endl;
276 cout << myname <<
" chanDataEnd: " << chanDataEnd <<
endl;
280 if (
m_LogLevel >= 2 ) cout << myname <<
"Creating histogram for channel range " << ran.name <<
endl;
281 AdcIndex nchan = chanEnd - chanBegin;
284 dm.
setInt(
"chan1", acdChanFirst);
285 dm.
setInt(
"chan2", acdChanLast-1);
291 string szunits =
"(ADC counts)";
294 if ( szunits.find(
" ") != string::npos ) szunits =
"(" + szunits +
")";
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";
301 htitl +=
"; Tick; Channel; Signal [" + zunit +
"]";
308 TH2* ph =
new TH2F(hname.c_str(), htitl.c_str(), ntick, tick1, tick2, nchan, chanBegin, chanEnd);
309 ph->SetDirectory(
nullptr);
311 if (
m_LogLevel >= 2 ) cout << myname <<
"Created histogram " << hname <<
endl;
312 ph->GetZaxis()->SetRangeUser(zmin, zmax);
314 double zempty = colorEmptyBins ? zmin - 1000.0 : 0.0;
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);
321 for (
AdcChannel chan=chanDataBegin; chan<chanDataEnd; ++chan ) {
323 if ( iacd == acds.end() )
continue;
327 if ( drops.size() && std::find(drops.begin(), drops.end(), chstat) != drops.end() )
continue;
328 Index ibiny = chan-chanBegin + 1;
331 cout << myname <<
"WARNING: Unable to find data view name " <<
m_DataView <<
endl;
333 for (
Index ient=0; ient<nent; ++ient ) {
335 cout << myname <<
"Processing data view " << ient <<
"/" << nent <<
endl;
338 if ( pacd ==
nullptr ) {
339 cout << myname <<
"ERROR: Skipping null view entry " <<
m_DataView <<
"[" << ient
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;
353 bool isRawPed =
false;
358 Tick nsam = isRaw ? raw.size() : sams.size();
368 cout << myname <<
" FEMB tick offsets provided without online channel mapping tool." <<
endl;
372 Index ifmb = chanOn/128;
377 cout << myname <<
"Filling channel-tick histogram with " << nsam <<
" samples and offset " 378 << dsam <<
" for channel " << chan <<
endl;
380 Index ibin = ph->GetBin(1, ibiny);
381 for (
Tick itck=tick1; itck<tick2; ++itck, ++ibin ) {
387 if ( (isSig || isNsg) && isam >= pacd->
signal.size() ) {
389 cout << myname <<
" Signal array not filled for sample " << isam
390 <<
" and above--stopping fill." <<
endl;
395 if ( isam < sams.size() ) sig = sams[isam];
397 }
else if ( isRawPed ) {
398 if ( isam < raw.size() ) sig = raw[isam] - ped;
400 }
else if ( isRaw && isam >= raw.size() ) {
403 }
else if ( isSig ) {
404 if ( isam < sams.size() && isam < keep.size() ) {
405 if ( keep[isam] ) sig = sams[isam];
409 }
else if ( isNsg ) {
410 if ( isam < sams.size() ) {
411 if ( isam >= keep.size() || !keep[isam] ) sig = sams[isam];
416 cout << myname <<
"Fill failed for bin " << ibin <<
endl;
418 if ( colorEmptyBins && sig < zmin ) sig = zmin;
419 ph->SetBinContent(ibin, sig);
428 ph->SetDirectory(
nullptr);
431 ph->GetZaxis()->SetRangeUser(-zmax, zmax);
439 if ( ppal ==
nullptr ) {
440 cout << myname <<
"ERROR: Unable to find palette " <<
m_Palette <<
endl;
459 for (
Index icha : m_ChannelLinePattern ) {
460 if ( icha > chanBegin && icha < chanEnd ) {
465 TLatex* pptl =
nullptr;
466 if ( ptitl.size() ) {
467 pptl =
new TLatex(0.01, 0.015, ptitl.c_str());
469 pptl->SetTextFont(42);
470 pptl->SetTextSize(0.030);
479 std::getline(cin, line);
482 cout << myname <<
"Created plot ";
483 cout <<
"for channels [" << chanBegin <<
" - " 484 << chanEnd <<
"): " << ofname <<
endl;
486 if ( ofrname.size() ) {
487 TFile* pfile = TFile::Open(ofrname.c_str(),
"UPDATE");
489 if (
m_LogLevel > 1 ) cout << myname <<
"Wrote " << ph->GetName() <<
" to " << ofrname <<
endl;
497 ret.
setInt(
"nhist", nhist);
std::vector< AdcCount > AdcCountVector
IndexVector m_SkipChannelStatus
int add(unsigned int ipad, TObject *pobj, std::string sopt="", bool replace=false)
DataMap & setStatus(int stat)
IndexVector m_ChannelLinePattern
int setRangeZ(double y1, double y2)
int setCanvasSize(int wx, int wy)
IntVector m_FembTickOffsets
int setFrameFillColor(int col)
Name nameReplace(Name name, const AdcChannelData &acd, const IndexRange &ran) const
int addHorizontalLine(double yoff=0.0, double lenfrac=1.0, int isty=1)
int addAxis(bool flag=true)
void setInt(Name name, int val)
Index channelStatus() const
std::vector< bool > AdcFilterVector
const std::vector< int > & colorVector() const
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
const RunDataTool * m_prdtool
static Index badChannel()
const IndexMapTool * m_pOnlineChannelMapTool
SetStat setFormulaPars(TFormula *form)
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="{,}")
AdcLongIndex triggerClock() const
QTextStream & endl(QTextStream &s)
static const RootPalette * find(unsigned int ipal)
Index m_ChannelLineModulus