//----------------------- // This Class's Header -- //----------------------- #include "CalorObjects/Cp2ClusterColl.hh" //------------------------------- // Collaborating Class Headers -- //------------------------------- #include "Experiment/Experiment.hh" #include "AbsEnv/AbsEnv.hh" // ROOT Headers : #include "TBuffer.h" #include "EdmUtilities/CdfClassImp.hh" //----------------------------------------------------------------------------- // Creation //----------------------------------------------------------------------------- Cp2ClusterColl::Cp2ClusterColl() : StorableObject() {} Cp2ClusterColl::Cp2ClusterColl(const Cp2ClusterColl& rhs) : StorableObject(rhs), _container(rhs._container) {} //----------------------------------------------------------------------------- // Destruction //----------------------------------------------------------------------------- Cp2ClusterColl::~Cp2ClusterColl() {} void Cp2ClusterColl::destroy() { Cp2ClusterColl::deallocate(); delete this; } void Cp2ClusterColl::deallocate() { StorableObject::deallocate(); } //----------------------------------------------------------------------------- // EDM: functions required by StorableObject //----------------------------------------------------------------------------- std::string Cp2ClusterColl::class_name() const { return "Cp2ClusterColl"; } Version_t Cp2ClusterColl::class_version() const { return Cp2ClusterColl::Class_Version(); } void Cp2ClusterColl::print(std::ostream& os) const { StorableObject::print(os); _container.print(os); } bool Cp2ClusterColl::postread(EventRecord* record) { // Note : ValueVector does not currently call postread on its elements, // so do so here : bool status = StorableObject::postread(record); status = _container.postread(record) && status; for (Cp2ClusterColl::iterator i = _container.contents().begin(); i != _container.contents().end(); ++i) { status = (*i).postread(record) && status; } return status; } bool Cp2ClusterColl::prewrite(EventRecord* record) { // Note : ValueVector does not currently call prewrite on its elements, // so do so here : bool status = StorableObject::prewrite(record); status = _container.prewrite(record) && status; for (Cp2ClusterColl::iterator i = _container.contents().begin(); i != _container.contents().end(); ++i) { status = (*i).prewrite(record) && status; } return status; } bool Cp2ClusterColl::activate(EventRecord* record) { bool status = StorableObject::activate(record); return status; } bool Cp2ClusterColl::deactivate(EventRecord* record) { bool status = StorableObject::deactivate(record); return status; } void Cp2ClusterColl::Streamer(TBuffer& iobuffer) { unsigned int start = 0 ; unsigned int byte_count = 0 ; //----------------------------------------------------------------------------- // Read object from buffer //----------------------------------------------------------------------------- if (iobuffer.IsReading()) { Version_t original_version = iobuffer.ReadVersion(&start, &byte_count) ; if (original_version == 1) { StorableObject::Streamer(iobuffer) ; _container.Streamer(iobuffer); } else { std::cerr << "Cp2ClusterColl::Streamer(IsReading): " << "Unsupported Cp2ClusterColl class version cannot be treated.\n" ; } iobuffer.CheckByteCount(start, byte_count, Cp2ClusterColl::IsA()) ; } //----------------------------------------------------------------------------- // Write object to buffer //----------------------------------------------------------------------------- else if (iobuffer.IsWriting()) { byte_count = iobuffer.WriteVersion(Cp2ClusterColl::IsA(), kTRUE) ; Version_t current_version = Cp2ClusterColl::class_version() ; if (current_version == 1) { StorableObject::Streamer(iobuffer) ; _container.Streamer(iobuffer); } else { std::cerr << "Cp2ClusterColl::Streamer(IsWriting): " << "Unsupported Cp2ClusterColl class version cannot be treated.\n" ; } iobuffer.SetByteCount(byte_count, kTRUE) ; } //----------------------------------------------------------------------------- // Unanticipated action //----------------------------------------------------------------------------- else { std::cerr << "Cp2ClusterColl::Streamer(): " << "NOTHING DONE.\n" ; } } //----------------------------------------------------------------------------- // Functions to retrieve the collection from the event //----------------------------------------------------------------------------- Cp2ClusterColl::Error Cp2ClusterColl::find(Cp2ClusterColl_ch& cHandle) { EventRecord::ConstIterator ciEvent(AbsEnv::theEvent(),"Cp2ClusterColl"); if (ciEvent.is_valid()) { cHandle = ciEvent; return OK; } else { cHandle.set_null(); return ERROR; } } Cp2ClusterColl::Error Cp2ClusterColl::find(Cp2ClusterColl_ch& cHandle, const StorableObject::Selector & selector) { EventRecord::ConstIterator ciEvent(AbsEnv::theEvent(),"Cp2ClusterColl"); while (ciEvent.is_valid() && !selector(*ciEvent)) { ++ciEvent; } if (ciEvent.is_valid()) { cHandle = ciEvent; return OK; } else { cHandle.set_null(); return ERROR; } } //============================================================================= // ROOT I/O Hook //============================================================================= CdfClassImp(Cp2ClusterColl)