// Read the documentation to learn more about C++ code generator // versioning. // %X% %Q% %Z% %W% // Plot #include // DataContainer #include // PlotEfficiency #include #include #include #include #include "XSContainer.h" #include "XSsymbol.h" #include "XSstreams.h" // Class PlotEfficiency PlotEfficiency::PlotEfficiency (Plot* plot) : PlotCommand(plot) { modelRequired(Plot::INACTIVE); } void PlotEfficiency::primaryGraph (const string& value) { Plot* pPlot = plot(); Plot::XaxisMode saveXoption (pPlot->xOption()); if ( saveXoption == Plot::CHANNELS ) { pPlot->setXOption("energy"); pPlot->plotXLog(pPlot->xLog()); } // set titles pPlot->setSelectedLabel(2,"te"); pPlot->autoSelectedLabels("e*"); try { // manufacture necessary data arrays into pPlot's PlotGroup container. // For this particular graph need X axis set by setXaxis using the // Response's energy array (Ehi, Elo, not EboundsMax, EboundsMin) // and its efficiency array. pPlot->makePlotArraysFromSpectra(); // the manipulate call manipulates the structures produced by makeUnbinnedPlotArrays // to get the dedicated arrays required by this particular plot. In this case, it // grabs the efficiency arrays from the Response. manipulate(); fillDataAttributes(0,PlotStyle::DASHDOT,2); if (pPlot->plotYLog()) { pPlot->fixYMax(pPlot->ranges("y").second*2); pPlot->fixYMin(std::max(pPlot->ranges("y").first,pPlot->ranges("y").second*1.e-07)); } else { pPlot->fixYMax(pPlot->ranges("y").second*1.05); pPlot->fixYMin(-0.01*pPlot->ranges("y").second); } pPlot->rangeDefaultFlags(3); // graph it. pPlot->bundlePlotVectors(); pPlot->prepareTheGraph(); pPlot->makeTheGraph(); } catch (YellowAlert &) { if ( saveXoption == Plot::CHANNELS ) pPlot->setXOption("channel"); throw; } if ( saveXoption == Plot::CHANNELS ) pPlot->setXOption("channel"); } void PlotEfficiency::manipulate () { Plot* pPlot = plot(); PlotGroupContainer::iterator ipg ( pPlot->groups().begin()); PlotGroupContainer::iterator ipgEnd ( pPlot->groups().end()); const string Y("y"); Real& yLow = plot()->ranges(Y).first; Real& yHigh = plot()->ranges(Y).second; yLow = LARGE; yHigh = -LARGE; const size_t NS (XSContainer::datasets->numberOfSpectra()); for (size_t iSpec=1; iSpec<=NS; ++iSpec) { const SpectralData* spectrum = XSContainer::datasets->lookup(iSpec); const std::vector& detectors = spectrum->detector(); const size_t nDets = detectors.size(); for (size_t iDet=0; iDetefficiency(); if (gr->yData.data.size() != efficiency.size()) { throw RedAlert("PlotGroup/Efficiency array size mismatch."); } for (size_t k=0; kn; ++k) { const Real effVal = efficiency[k]; gr->yData.data[k] = effVal; if (effVal < yLow) yLow = effVal; if (effVal > yHigh) yHigh = effVal; } gr->yData.lineStyle = PlotStyle::DASHDOT; gr->yData.errors[0].resize(0); gr->model[0].lineStyle = PlotStyle::NONE; gr->model[0].symbolStyle = PlotStyle::BLANK; ++ipg; } } } } // Additional Declarations