#ifdef USE_CDFEDM2 ////////////////////////////////////////////////////////////////////////// // // Component: SourceCalData.cc // Purpose: This is a concrete class that uses the CalData object to // fill the EnergyData object. This class inherits from // InputSource. // // Created: 28/06/99 Pierre Savard // History: // ////////////////////////////////////////////////////////////////////////// #include "Calor/SourceCalData.hh" #include "ErrorLogger_i/gERRLOG.hh" // namespace calor { SourceCalData::SourceCalData():_sourceName("CalData"){} Id SourceCalData::initEvent(AbsEvent* anEvent){ StorableObject::SelectByProcessName selector1( anEvent->process_name() ); StorableObject::SelectByClassName selector2("CalData"); EventRecord::ConstIterator calDataIter( anEvent, selector1 && selector2); if ( calDataIter.is_valid() ) { _dataHandle = CalData_ch( calDataIter ); _dataHandle->puff(); } else{ // could not find CalData with concurrent process name // ERRLOG(ELwarning,"SourceCalData: ") << "Could not find CalData with same process name" << endmsg; EventRecord::ConstIterator calDataIter2( anEvent, selector2 ); if ( calDataIter2.is_valid() ) { _dataHandle = CalData_ch( calDataIter2 ); _dataHandle->puff(); } else { _dataHandle.set_null(); ERRLOG(ELerror,"SourceCalData: ") << "Could not find CalData" << endmsg; return 0; } } _iter = _dataHandle->begin(); _end = _dataHandle->end(); return _dataHandle->object_id(); // return the object ID } Id SourceCalData::initEvent(AbsEvent* anEvent, Id objectId){ StorableObject::SelectByObjectId selector( objectId); EventRecord::ConstIterator calDataIter( anEvent, selector ); if ( calDataIter.is_valid() ) { _dataHandle = CalData_ch( calDataIter ); _dataHandle->puff(); } else { _dataHandle.set_null(); ERRLOG(ELerror,"SourceCalData: ") << "Could not find CalData with requested object ID" << endmsg; return 0; } _iter = _dataHandle->begin(); _end = _dataHandle->end(); return 1; } EnergyData* SourceCalData::next(){ CalTower* t = _iter.tower(); EnergyData* eData; eData = new EnergyData(t->emPhi(), t->hadPhi(), t->emEnergy(), t->hadEnergy(), t->iEta(), t->iPhi()); ++_iter; return eData; } #endif // USE_CDFEDM2