/****************************************************************************** * CesCluster class function definition file * * * * Author: Michael Riveline * * * * Description: Functions for the CesCluster class * * * * Revision History: * * 11-May-2000 Bob Wagner view accessor method always returned 0. * * Modify so it returns _view. * * 23-May-2000 Bob Wagner Add a copy constructor declaration to the * * class. This is necessary in order that * * overriden pure virtual functions get pointed * * to properly * * 23-May-2000 Bob Wagner Insert a non-inlined and correct principal * * assignment operator * * 01-Jun-2000 Dave Waters Add version information. * * 05-Feb-2000 Michael Riveline Change to version 2. * * 27-Feb-2002 Bob Wagner Change deprecated data member * * Link _tempTheTrack to type * * Link per instructions of Rob * * Kennedy. This allows reading of old data * * version == 2 although the track link from * * those versions will no longer be useful as * * CdfTrack is no longer Storable but Streamable* * 27-Feb-2002 Bob Wagner Attempt to speed up Streamer and postread * * methods by not restoring track link pointer * * when the CdfTrack_clnk is not valid. This is* * the case always for UNBIASED collection which* * never has a valid track link. Also use * * ReadFastArray to read in 3 int's and 8 floats* * * *****************************************************************************/ //----------------------- // This Class's Header -- //----------------------- #include "CalorObjects/CesCluster.hh" //--------------- // C++ Headers -- //--------------- #include #include "TBuffer.h" //------------------------------- // Collaborating Class Headers -- //------------------------------- #include "CalorGeometry/CalConstants.hh" #include "ErrorLogger_i/gERRLOG.hh" // SET THE VERSION NUMBER : const Version_t CesCluster::_VERSION = 3; //***************************************************************************** // Class Implementation //***************************************************************************** /************************************************************************** * CesCluster Default Constructor * **************************************************************************/ CesCluster::CesCluster( void ) : _barrel(0), _module(0), _view(0), _stripRawPosition(0.0), _stripRawEnergy(0.0), _stripFitPosition(0.0), _stripFitEnergy(0.0), _stripChi2(0.0), _stripWidth(0.0), _stripWidthError(0.0), _distTrackClust(0.0), _first_el(0), _num_el(0),_theTrack(NULL),_tempTheTrack(NULL), _globalPosition(0.0) { } /************************************************************************** * CesCluster Copy Constructor * **************************************************************************/ CesCluster::CesCluster( const CesCluster& oldCesCluster ) { _module = oldCesCluster._module; _barrel = oldCesCluster._barrel; _view = oldCesCluster._view; _stripRawPosition = oldCesCluster._stripRawPosition; _stripRawEnergy = oldCesCluster._stripRawEnergy; _stripFitPosition = oldCesCluster._stripFitPosition; _stripFitEnergy = oldCesCluster._stripFitEnergy; _stripChi2 = oldCesCluster._stripChi2; _stripWidth = oldCesCluster._stripWidth; _stripWidthError = oldCesCluster._stripWidthError; _distTrackClust = oldCesCluster._distTrackClust; _globalPosition = oldCesCluster._globalPosition; _first_el = oldCesCluster._first_el; _num_el = oldCesCluster._num_el; _theTrack = oldCesCluster._theTrack; _tempTheTrack = oldCesCluster._tempTheTrack; _copyStrips = oldCesCluster._copyStrips; _copyWires = oldCesCluster._copyWires; } /************************************************************************** * CesCluster Custom Constructor * **************************************************************************/ CesCluster::CesCluster( int barrel, int module, int view, float fitted_position, float raw_position, float fitted_energy, float raw_energy, float chi2_strip, float width, float width_error, float dist_track_clust, const CdfTrack_clnk& theTrack, float global_pos, uint2 first_el, uint2 num_el, const vector strips, const vector wires ) : _barrel(barrel), _module(module), _view(view), _stripFitPosition(fitted_position), _stripRawPosition(raw_position), _stripFitEnergy(fitted_energy), _stripRawEnergy(raw_energy), _stripChi2(chi2_strip), _stripWidth(width), _stripWidthError(width_error), _distTrackClust(dist_track_clust), _theTrack(theTrack),_tempTheTrack(NULL),_globalPosition(global_pos), _first_el(first_el),_num_el(num_el), _copyStrips(strips), _copyWires(wires) { } /*===========================================================================*\ * Principal Assignment Operator Overload * \*===========================================================================*/ CesCluster& CesCluster::operator = (const CesCluster & rhs) { if (this != &rhs) { // beware of self-assignment // Handle base class assignment this->StreamableObject::operator=(rhs); // Now copy data members of CesCluster _module = rhs._module; _barrel = rhs._barrel; _view = rhs._view; _stripRawPosition = rhs._stripRawPosition; _stripRawEnergy = rhs._stripRawEnergy; _stripFitPosition = rhs._stripFitPosition; _stripFitEnergy = rhs._stripFitEnergy; _stripChi2 = rhs._stripChi2; _stripWidth = rhs._stripWidth; _stripWidthError = rhs._stripWidthError; _distTrackClust = rhs._distTrackClust; _theTrack = rhs._theTrack; _tempTheTrack = rhs._tempTheTrack; _globalPosition = rhs._globalPosition; _first_el = rhs._first_el; _num_el = rhs._num_el; _copyStrips = rhs._copyStrips; _copyWires = rhs._copyWires; } return *this; } /************************************************************************** * CesCluster::print * * Print information for cluster * **************************************************************************/ void CesCluster::print(std::ostream& os) const { os << "*************************************************" << "\n"; os << "CES cluster " << "\n"; os << "Module " << _module << "\n"; os << "Barrel " << _barrel << "\n"; os << "View " << view() << "\n"; os << "****************Strip cluster********************" << "\n"; os << "Raw position " << _stripRawPosition << "\n" ; os << "Fitted position " << _stripFitPosition << "\n" ; os << "Raw energy " << _stripRawEnergy << "\n" ; os << "Fitted energy " << _stripFitEnergy << "\n" ; os << "Chi2 " << _stripChi2 << "\n" ; os << "Width " << _stripWidth << "\n" ; os << "Width Error " << _stripWidthError << "\n" ; os << "Distance track cluster " << _distTrackClust << "\n" ; os << "Global Position " << _globalPosition << "\n" ; os << "First strip/wire " << _first_el << "\n" ; os << "Number of strips/wires " << _num_el << "\n" ; os << "*************************************************" << "\n"; } /*===========================================================================*\ * CesCluster accessors * \*===========================================================================*/ /************************************************************************** * CesCluster::clusterWidth * * Return width of CES Cluster * **************************************************************************/ float CesCluster::clusterWidth( void ) const { return _stripWidth; } /************************************************************************** * CesCluster::region * * Return the detector identification number which should be 0 * * for the CES. * **************************************************************************/ Detector CesCluster::region( void ) const { return CEM; } /************************************************************************** * CesCluster::energy * * Return energy of CES Cluster * **************************************************************************/ float CesCluster::energy( void ) const { return _stripRawEnergy; } /************************************************************************** * CesCluster::localCoord * * Return float giving value of shower centroid * * in local coordinate system * **************************************************************************/ float CesCluster::localCoord( void ) const { return _stripFitPosition; } /************************************************************************** * CesCluster::globalCoord * * Return float giving value of shower centroid * * in global coordinate system * **************************************************************************/ float CesCluster::globalCoord( void ) const { return _globalPosition; } /************************************************************************** * CesCluster::module * * Return wedge number containing CES Cluster * **************************************************************************/ int CesCluster::module( void ) const { return _module; } /***************************************************************************** * CesCluster::side * * Return integer indicating East or West detector contains CES Cluster * *****************************************************************************/ int CesCluster::side( void ) const { return _barrel; } /************************************************************************** * CesCluster::view * * Return integer indicating CES Cluster is in X or Z view * **************************************************************************/ int CesCluster::view( void ) const { return _view; } //=========================================================================== // Required by StorableObject //=========================================================================== void CesCluster::Streamer(TBuffer& iobuffer) { //--------------------------------------------------------------------------- // Read object from buffer //--------------------------------------------------------------------------- if (iobuffer.IsReading()) { ShowerMaxCluster::Streamer(iobuffer); Version_t version; iobuffer >> version; _version = version; const int numberOfInts = 3; int intBufferBlock[numberOfInts]; iobuffer.ReadFastArray( intBufferBlock, numberOfInts ); _view = intBufferBlock[0]; _barrel = intBufferBlock[1]; _module = intBufferBlock[2]; if (version == 1) { // // in version 1, all the accessors were double. Convert // them to float for backward compatibility. // double tempdouble; iobuffer >> tempdouble; _stripRawPosition = float(tempdouble); iobuffer >> tempdouble; _stripFitPosition = float(tempdouble); iobuffer >> tempdouble; _stripRawEnergy = float(tempdouble); iobuffer >> tempdouble; _stripChi2 = float(tempdouble); iobuffer >> tempdouble; _stripWidth = float(tempdouble); iobuffer >> tempdouble; _stripWidthError = float(tempdouble); } else if (version == 2){ iobuffer >> _stripRawPosition >> _stripFitPosition >> _stripRawEnergy >> _stripChi2 >> _stripWidth >> _stripWidthError >> _distTrackClust >> _globalPosition >> _first_el >> _num_el ; _tempTheTrack.Streamer(iobuffer); } else if (version == 3){ const int numberOfFloats = 8; float floatBufferBlock[numberOfFloats]; iobuffer.ReadFastArray( floatBufferBlock, numberOfFloats ); _stripRawPosition = floatBufferBlock[0]; _stripFitPosition = floatBufferBlock[1]; _stripRawEnergy = floatBufferBlock[2]; _stripChi2 = floatBufferBlock[3]; _stripWidth = floatBufferBlock[4]; _stripWidthError = floatBufferBlock[5]; _distTrackClust = floatBufferBlock[6]; _globalPosition = floatBufferBlock[7]; iobuffer >> _first_el >> _num_el ; _theTrack.readStreamer(iobuffer); } else { ERRLOG( ELerror, "Unsupported CesCluster version" ) << "@SUB=CesCluster::Streamer()" << "CesCluster cannot be read" << version << endmsg; } } //--------------------------------------------------------------------------- // Write object to buffer //--------------------------------------------------------------------------- else if (iobuffer.IsWriting()) { ShowerMaxCluster::Streamer(iobuffer); iobuffer << class_version(); iobuffer << _view << _barrel << _module << _stripRawPosition << _stripFitPosition << _stripRawEnergy << _stripChi2 << _stripWidth << _stripWidthError << _distTrackClust << _globalPosition << _first_el << _num_el ; _theTrack.writeStreamer(iobuffer); } //--------------------------------------------------------------------------- // Unanticipated action //--------------------------------------------------------------------------- else { ERRLOG( ELerror, "CesCluster::Streamer()") << "@SUB=CesCluster::Streamer" << "NOTHING DONE." << endmsg; } } bool CesCluster::postread(EventRecord* p) { if (_version==3) { if (_theTrack.index() >= 0) _theTrack.restore( p ); } return ShowerMaxCluster::postread(p); } bool CesCluster::prewrite(EventRecord* p) {return ShowerMaxCluster::prewrite(p);}