/****************************************************************************** * PlugStrip class function definition file * * * * Author: Benn Tannenbaum * * * *****************************************************************************/ //----------------------- // This Class's Header -- //----------------------- #include "CalorObjects/PlugStrip.hh" //--------------- // C++ Headers -- //--------------- #include #include "TBuffer.h" #include "ErrorLogger_i/gERRLOG.hh" // SET THE VERSION NUMBER : const Version_t PlugStrip::_VERSION = 2; //***************************************************************************** // Class Implementation //***************************************************************************** /************************************************************************** * PlugStrip Default Constructor * **************************************************************************/ PlugStrip::PlugStrip() { clear(); } /************************************************************************** * PlugStrip Copy Constructor * **************************************************************************/ PlugStrip::PlugStrip( const PlugStrip& oldPlugStrip ) { theEnergy = oldPlugStrip.theEnergy; theLocation = oldPlugStrip.theLocation; theCounts = oldPlugStrip.theCounts; } /************************************************************************** * PlugStrip Custom Constructor * **************************************************************************/ PlugStrip::PlugStrip(int plug, int octant, int layer, int strip, float energy) { clear(); theEnergy = energy; theLocation = plug; // 1 bit of endplug theLocation += (octant << 1); // 3 bits of octant theLocation += (layer << 4); // 1 bit of u or v layer theLocation += (strip << 5); // 8 bits of strip number } PlugStrip::PlugStrip(int address, int counts, float energy) { clear(); theEnergy = energy; theCounts = counts; theLocation = address; } PlugStrip::PlugStrip(int plug, int octant, int layer, int strip, int status, int counts, float energy) { clear(); theLocation = plug; // 1 bit of endplug theLocation += (octant << 1); // 3 bits of octant theLocation += (layer << 4); // 1 bit of u or v layer theLocation += (strip << 5); // 8 bits of strip number theLocation += (status << 13); // 3 bits of status theCounts = counts; theEnergy = energy; } void PlugStrip::clear() { theLocation = 0; theEnergy = 0; theCounts = 0; } /*===========================================================================*\ * Principal Assignment Operator Overload * \*===========================================================================*/ PlugStrip& PlugStrip::operator = (const PlugStrip & rhs) { if (this != &rhs) { // beware of self-assignment // Handle base class assignment this->StreamableObject::operator=(rhs); // Now copy data members of PlugStrip theEnergy = rhs.theEnergy; theCounts = rhs.theCounts; theLocation = rhs.theLocation; } return *this; } /*===========================================================================*\ * Operator overloads * \*===========================================================================*/ inline bool PlugStrip::operator == (const PlugStrip& rhs) const { if ( this->PesEnergy() != rhs.PesEnergy() || this->PesCounts() != rhs.PesCounts() || this->PesAddress() != rhs.PesAddress()) { return false; } else { return true; } } inline bool PlugStrip::operator != (const PlugStrip& rhs) const { return (!(*this == rhs)); } void PlugStrip::print(std::ostream& os) const { os << "Endplug: " << (PesPlug() ? "East" : "West") << " Octant: " << PesOctant() << " Layer: " << PesLayer() << " Strip: " << PesStrip() << " ADC Counts: " << PesCounts() << " Energy: " << PesEnergy(); } //=========================================================================== // Required by StorableObject //=========================================================================== void PlugStrip::Streamer(TBuffer& iobuffer) { //--------------------------------------------------------------------------- // Read object from buffer //--------------------------------------------------------------------------- if (iobuffer.IsReading()) { Version_t version; iobuffer >> version; if (version == 1) { iobuffer>> theLocation >> theEnergy; } if (version == 2) { iobuffer>> theLocation >> theEnergy >> theCounts; } else { ERRLOG( ELerror, "Unsupported PlugStrip version" ) << version << "@SUB=PlugStrip::Streamer()" << "PlugStrip cannot be read" << endmsg; } } //--------------------------------------------------------------------------- // Write object to buffer //--------------------------------------------------------------------------- else if (iobuffer.IsWriting()) { iobuffer << class_version(); iobuffer << theLocation << theEnergy<< theCounts; } //--------------------------------------------------------------------------- // Unanticipated action //--------------------------------------------------------------------------- else { ERRLOG( ELerror, "PlugStrip::Streamer()") << "@SUB=PlugStrip::Streamer" << "NOTHING DONE." << endmsg; } } bool PlugStrip::postread(EventRecord* p) {return true;} bool PlugStrip::prewrite(EventRecord* p) {return true;}