/* * ProfilerPlaneSimulator.hh * * Class for simulating the response of profiler plane to the beam. * Inherits from ProfilerPlaneV, templated so that it can be used for both * X- and Y-planes. The objects of this class are independent from the objects * of ProfilerPlane which is instantiated to analyze the response from the * actual beam-profiler scaler or from these simulator planes. But the * ProfilerPlane and ProfilerPlaneSimulator objects will belong to the same * detector and the threads are launched from the same location in ProfilerDetector. * * Created on: Oct 17, 2015 * Author: Hovanes Egiyan */ #ifndef PROFILERPLANESIMULATOR_HH_ #define PROFILERPLANESIMULATOR_HH_ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "MutexedClass.hh" #include "ProfilerPlaneData.hh" #include "ProfilerDetComponent.hh" #include "ProfilerPlaneSimulatorV.hh" #include "ProfilerPVs.hh" using namespace std; template class ProfilerPlaneSimulator: public ProfilerPlaneSimulatorV { protected: public: // Main constructor ProfilerPlaneSimulator( ProfilerDetector* det, const double centerPos, const bool reversedAxis ) : MutexedClass(), ProfilerPlaneData( reversedAxis ), ProfilerPlaneSimulatorV( det, reversedAxis ) { ppdCenterPosition = centerPos; ppdName = getDetectorName() + ":" + P ; // Define the x-axis this->defineAxis(); return; } // Copy constructor ProfilerPlaneSimulator( const ProfilerPlaneSimulator& p ) : MutexedClass( p ), ProfilerPlaneData( p ), ProfilerPlaneSimulatorV( p ) { return; } // Destructor virtual ~ProfilerPlaneSimulator() { } // Assignment operator ProfilerPlaneSimulator& operator=( const ProfilerPlaneSimulator& p ) { ProfilerPlaneSimulatorV::operator=( p ); return *this; } // Publish values to EPICS. virtual void publishValues(); }; // Publish values in each fiber as waveform with time-slices template void ProfilerPlaneSimulator

::publishValues() { // reserve the buffer with long elements to be sent to EPICS as a waveform // cout << "Simulator will publish values " << ppdSlices.size() << " long " << endl; // Loop over fibers and set the EPICS record for the waveform for ( unsigned iFibr = 1; iFibr <= getChanNumber(); iFibr++ ) { long fibrWave[ppdSlices.size()]; // Loop over time slices to set the waveform elements for individual fibers // cout << "Simulated values for fiber " << iFibr << " for " << getName() << " are " << endl; for ( unsigned iSlice = 0; iSlice < ppdSlices.size(); iSlice++ ) { ProfilerPlaneSliceSimulator* simSlice = dynamic_cast( ppdSlices[iSlice] ); // Get the bin content from the simulation histogram fibrWave[iSlice] = static_cast( round( simSlice->getHist()->GetBinContent( iFibr ) ) ); // cout << iSlice << ":" << fibrWave[iSlice] << "=" << simSlice->getHist()->GetBinContent( iFibr ) // << " @ " << simSlice->getHist() << " " ; } // cout << endl; // Find the EPICS name and publish the waveform stringstream ssFibr; ssFibr << iFibr; std::string sFibr = ssFibr.str(); std::string pvLabel = std::string( "sim_" ) + P + std::string( ":" ) + sFibr; pdcPV->setValue( pvLabel, reinterpret_cast( fibrWave ), SYNC ); } } #endif /* PROFILERPLANESIMULATOR_HH_ */