// -*- C++ -*- // // Package: // Module: BeamEnergyProxy // // Description: // // Implementation: // // Author: Brian K. Heltsley // Created: Fri Aug 31 16:53:48 EDT 2001 // $Id: BeamEnergyProxy.cc,v 1.3 2004/02/09 20:37:57 bkh Exp $ // // Revision history // // $Log: BeamEnergyProxy.cc,v $ // Revision 1.3 2004/02/09 20:37:57 bkh // Alter message with beam energy shift to DEBUG // // Revision 1.2 2004/02/05 16:33:12 bkh // Add application of shift & new parameter to suppress shift, & new tag to get unshifted value // // Revision 1.1.1.1 2001/08/31 21:18:02 bkh // imported CesrBeamEnergyProd sources // // #include "Experiment/Experiment.h" // system include files #include // for ::exit #include #include //for auto_ptr // user include files #include "Experiment/report.h" #include "DataHandler/Record.h" #include "DataHandler/Frame.h" #include "FrameAccess/extract.h" #include "FrameAccess/FATable.h" #include "FrameAccess/FAConstants.h" #include "CesrBeamEnergyProd/BeamEnergyProxy.h" #include "CesrBeamEnergyProd/CesrBeamEnergyProd.h" #include "ProxyBind/ProxyBoundMethodAction.h" //need for PROXY_BIND_METHOD #include "CesrCleoComm/CesrBeamEnergy.h" #include "BeamEnergy/BeamStream.h" #include "DBBeamEnergyShift.hh" // STL classes // You may have to uncomment some of these or other stl headers // depending on what other header files you include (e.g. FrameAccess etc.)! //#include #include //#include #include //#include //#include #include #include // // constants, enums and typedefs // static const char* const kFacilityString = "CesrBeamEnergyProd.BeamEnergyProxy" ; // ---- cvs-based strings (Id and Tag with which file was checked out) static const char* const kIdString = "$Id: BeamEnergyProxy.cc,v 1.3 2004/02/09 20:37:57 bkh Exp $"; static const char* const kTagString = "$Name: v01_00_02 $"; // // static data member definitions // // // constructors and destructor // BeamEnergyProxy::BeamEnergyProxy( const CesrBeamEnergyProd* callingProd ) : m_BeamEnergy( 0 ) , m_prod ( callingProd ) { //bind 'auxilliary' functions that you want called when a // new Record on the particular Stream appears //bind( &BeamEnergyProxy::boundMethod, Stream::kBeginRun ); } // BeamEnergyProxy::BeamEnergyProxy( const BeamEnergyProxy& iproxy ) // { // *this = iproxy; // } BeamEnergyProxy::~BeamEnergyProxy() { delete m_BeamEnergy ; } // // assignment operators // // const BeamEnergyProxy& BeamEnergyProxy::operator=( const BeamEnergyProxy& iproxy ) // { // if( this != &iproxy ) { // // do actual copying here, plus: // // "SuperClass"::operator=( iproxy ); // } // // return *this; // } // // member functions // void BeamEnergyProxy::invalidateCache() { delete m_BeamEnergy ; m_BeamEnergy = 0 ; } const BeamEnergyProxy::value_type* BeamEnergyProxy::faultHandler( const Record& iRecord, const DataKey& iKey ) { // be assertive: there should be no cached data at this point, else // it's a programming error assert( 0 == m_BeamEnergy ); //if an exception is thrown during this function, p_BeamEnergy will // automatically delete the object it is refering to auto_ptr p_BeamEnergy; FAItem< CesrBeamEnergy > cesr ; extract( iRecord.frame().record( Stream::kStartRun ) , cesr ) ; double eShift ( 0 ) ; FAConstants< DBBeamEnergyShift > shift ; if( m_prod->useBeamEnergyShift() ) { extract( iRecord.frame().record( BeamStream::kBeamEnergyShift ) , shift ) ; eShift = shift.front().get_beamEnergyShift() ; report( DEBUG, kFacilityString ) << "Applying Beam Energy shift of " << eShift << " GeV" << endl ; } else { report( DEBUG, kFacilityString ) << "You have turned OFF inclusion of the Beam Energy shift " << endl ; } //have p_BeamEnergy hold onto the new object p_BeamEnergy.reset( new BeamEnergy( cesr->value() + eShift ) ); std::cout << "xshi_debug >>> beam energy:" << std::setprecision(8) << p_BeamEnergy->value() << std::endl; //Since no exception happened, tell p_BeamEnergy to give its pointer to // m_BeamEnergy return ( m_BeamEnergy = p_BeamEnergy.release() ) ; } // // const member functions // // // static member functions // // // 'bound' functions // //void //BeamEnergyProxy::boundMethod( const Record& iRecord ) //{ // report( INFO, kFacilityString) <<"BoundMethod: " <; PROXY_BIND_METHOD( BeamEnergyProxy ) //-----------------------------------------------