#ifndef PlugStripColl_hh #define PlugStripColl_hh /** \class PlugStripColl This class holds the contents of a single strip after conversion to floats. \author Benn Tannenbaum benn@physics.ucla.edu \date 25 August 2000 I have no idea what most of this code does... it's copied from other, functional collections. Modified Apr 22 2003 by brubakee@fnal.gov Fix puffing problem by clarifying puffing "state machine": A PlugStripColl can be puffed or unpuffed, not both. The state is signalled by the _isPuffed variable. When it is puffed, only _container has valid information. When it is unpuffed, only _address, _energy, _counts, and _bufferSize have valid information. This could probably be done more intelligently. */ #include #include #include "Rtypes.h" #include "CalorObjects/PlugStrip.hh" #include "Edm/ConstHandle.hh" #include "Edm/Handle.hh" #include "Edm/StorableObject.hh" #include "EdmUtilities/FixedSizeTypes.hh" #include "StorableContainers/ValueVector.hh" //-------------------------------------------------------------- // Forward Declaration of Classes, needed for global typedefs -- //-------------------------------------------------------------- class PlugStripColl; //-------------------------------------------------------- // Global typedef's for EDM2 Handles for the collection -- //-------------------------------------------------------- typedef Handle PlugStripColl_h; typedef ConstHandle PlugStripColl_ch; class PlugStripColl : public StorableObject { public: //-------------------------------------------------------------------------- // typedef's for the collection //-------------------------------------------------------------------------- typedef PlugStrip value_type; typedef PlugStrip& reference; typedef const PlugStrip& const_reference; typedef PlugStrip* pointer; typedef const PlugStrip* const_pointer; typedef std::vector PlugStripVector; typedef PlugStripVector::iterator iterator; typedef PlugStripVector::const_iterator const_iterator; typedef ConstHandle const_handle; typedef Handle handle; typedef std::vector::difference_type difference_type; typedef std::vector::size_type size_type; typedef std::vector CollType; typedef CollType collection_type; //-------------------------------------------------------------------------- // Functions to retrieve the collection from the event //-------------------------------------------------------------------------- enum Error {ERROR, OK}; static Error find(PlugStripColl_ch & setHandle); static Error find(PlugStripColl_ch & setHandle, const StorableObject::Selector & selector ); static Error find(PlugStripColl_ch & setHandle, const std::string & description); //-------------------------------------------------------------------------- // Constructors //-------------------------------------------------------------------------- // Default constructor : PlugStripColl(); // Pseudo-constructor : virtual PlugStripColl* clone(void); //Copy constructor : PlugStripColl(const PlugStripColl& rhs); //-------------------------------------------------------------------------- // EDM: functions required by StorableObject //-------------------------------------------------------------------------- virtual std::string class_name() const ; virtual Version_t class_version() const; virtual bool postread(EventRecord* p); virtual bool prewrite(EventRecord* p); virtual bool activate(EventRecord* p); virtual bool deactivate(EventRecord* p); virtual void destroy(); virtual void deallocate(); // void Streamer(TBuffer& buf); // Declared by ClassDef() // Pretty text output method: void print(std::ostream& os = std::cout) const; //* Generates the vector of PlugStrips from the raw information arrays. void puffEvent() const; // Give access to the strips: PlugStripVector& contents() {return _container.contents();} const PlugStripVector& contents() const {return _container.contents();} // Destructor ~PlugStripColl(); private: // Container holding PlugStrips. Filled directly as PlugStrips are created, // or filled by puffEvent after raw information is streamed in. // Needs to be mutable to change it during puffing (a const operation). mutable ValueVector _container; // Arrays to hold raw information after streaming in and before puffing, // or just before streaming out. uint2* _address; float4* _energy; uint2* _counts; // Length of above raw information arrays. uint2 _bufferSize; // Has the collection been puffed? If so, only the information in _container // is valid. If not, only the raw information arrays are valid. mutable bool _isPuffed; // Private helper functions to stream raw information. void deleteArrays(); void unpuffEvent(); void writeToBuffer(TBuffer& iobuffer); void readFromBuffer(TBuffer& iobuffer); // This was 1, but following CESQColl.hh, I changed it bht 20 june 2002 ClassDef(PlugStripColl, 2) }; #endif