// // DetPlane.cpp // #include #include "DetPlane.h" #include "DetPlaneDef.h" #include "DaqSetup.h" #include "LogFile.h" extern "C" { #include } enum Sys_Dac {Vatt, Vref, None, Vcal}; // ====================================================== // constructor // ====================================================== DetPlane::DetPlane (int linkNr, DspCard* dsp) : ctrlBlk (dsp->ctrlBlk) { _link = linkNr; _the_dsp = dsp; _counterValue = 0; logFile << " DetPlane link: " << _link << " created for Dsp "; logFile << _the_dsp->dspNr () << endl; _planeName = _T(""); } DetPlane::~DetPlane () { logFile << " DetPlane link: " << _link << " deleted " << endl; } // ====================================================== // // ====================================================== int DetPlane::link () { return _link; } int DetPlane::dspNr () { return 0; } // ========================================= // init // ========================================= void DetPlane::init (char *detName) { _planeName = detName; logFile << " init detector plane " << _planeName << endl; // --------------------------- // read from file // --------------------------- calib.reset (); DetPlaneDef def; def.readFromFile (detName, this); // -------------------------------- // set counter value // -------------------------------- int tmp; tmp = 25 + _nChannels + 9 * (_nChannels / 128 - 1); if ( _counterValue == 0 ) { if ( tmp % 8 == 0 ) _counterValue = tmp / 8; else _counterValue = tmp / 8 + 1; } DetPlane::set_counterValue (_counterValue); if ( tmp % 32 == 0 ) _eventLength = tmp / 32; else _eventLength = tmp / 32 + 1; // ------------------------------------------- // list of channels to use (default all) // ------------------------------------------- chanList.setnChan (_nChannels); chanList.addChan (0, _nChannels - 1, 1); chanList.makeChanList (); } // ================================================ // setup Parameters // ================================================ // -------- nChannels -------------------- void DetPlane::set_nChan (int channels) { _nChannels = channels; } int DetPlane::nChan () { return _nChannels; } // -------- counterValue ---------------- void DetPlane::set_counterValue (int value) { _the_dsp->set_counterValue (value); } int DetPlane::counterValue () { return _the_dsp->get_counterValue (); } void DetPlane::set_eventLength (int value) { _eventLength = value; } int DetPlane::eventLength () { return _eventLength; } // -------- hitType --------------------- void DetPlane::set_hitType (int hitType) { if ( hitType == 0 ) _hitType = 0; else _hitType = 1; } int DetPlane::hitType () { return _hitType; } // -------- strobeDelay ---------------- void DetPlane::set_strobeDelay (int strobe) { _the_dsp->set_strobe_delay (strobe); } int DetPlane::strobeDelay () { return _the_dsp->get_strobe_delay (); } // -------- nLoops ---------------- void DetPlane::set_nLoops (int loops) { _nLoops = loops; } int DetPlane::nLoops () { return _nLoops; } // ================================================= void DetPlane::name (CString& name) { name = _planeName; return; } // ========================================= // dac's // ========================================= // ---------------------- // Vref // ---------------------- int DetPlane::setV_ref (double value) { Sys_Dac chan = Vref; if ( _the_dsp->set_sys_dac (chan, value) ) { return 1; } else { return 0; } } double DetPlane::getV_ref () { Sys_Dac chan = Vref; return ( _the_dsp->get_sys_dac (chan) ); } // ---------------------- // Vatt // ---------------------- int DetPlane::setV_att (double value) { Sys_Dac chan = Vatt; if ( _the_dsp->set_sys_dac (chan, value) ) { return 1; } else { return 0; } } double DetPlane::getV_att () { Sys_Dac chan = Vatt; return ( _the_dsp->get_sys_dac (chan) ); } // ---------------------- // Vcal // ---------------------- int DetPlane::setV_cal (double value) { Sys_Dac chan = Vcal; if ( _the_dsp->set_sys_dac (chan, value) ) { return 1; } else { return 0; } } double DetPlane::getV_cal () { Sys_Dac chan = Vcal; return ( _the_dsp->get_sys_dac (chan) ); } // ---------------------- // Vthres // ---------------------- int DetPlane::setV_thres (double value) { for ( int i = 0; i < 4; i++ ) { _the_dsp->set_ll_dac (i, value); } return 1; /* if ( _the_dsp->set_ll_dac (_linkNumber, value) ) { return 1; } else { return 0; } */ } double DetPlane::getV_thres () { return ( _the_dsp->get_ll_dac (_link) ); }