#ifdef USE_CDFEDM2 ////////////////////////////////////////////////////////////////////////// // // Component: SourceTrackCal.cc // Purpose: This is a concrete class that uses the TrackCal object to // fill the EnergyData object. This class inherits from // InputSource. // // Created: 28/06/99 Pierre Savard // History: // ////////////////////////////////////////////////////////////////////////// #include "Calor/SourceTrackCal.hh" #include "ErrorLogger_i/gERRLOG.hh" // namespace calor { SourceTrackCal::SourceTrackCal():_sourceName("TrackCal"){} Id SourceTrackCal::initEvent(AbsEvent* anEvent){ // StorableObject::SelectByProcessName selector1( anEvent->process_name() ); StorableObject::SelectByClassName cName("TrackCal"); EventRecord::ConstIterator trackCalIter( anEvent,"TrackCalColl","TrackCalColl"); if ( trackCalIter.is_valid() ) { _dataHandle = ConstHandle(trackCalIter); } else{ _dataHandle.set_null(); ERRLOG(ELerror,"SourceTrackCal: ") << "Could not find TrackCal" << endmsg; return 0; } _iter = _dataHandle->contents().begin(); _end = _dataHandle->contents().end(); _ietaCount = 10; _iphiCount = 0; return _dataHandle->object_id(); // return the object ID } Id SourceTrackCal::initEvent(AbsEvent* anEvent, Id objectId){ StorableObject::SelectByObjectId selector( objectId); EventRecord::ConstIterator trackCalIter( anEvent,"trackCalColl","trackCalColl"); if ( trackCalIter.is_valid() ) { // _dataHandle = TrackCal_ch( trackCalIter ); // _dataHandle->puff(); _dataHandle = ConstHandle(trackCalIter); } else { _dataHandle.set_null(); ERRLOG(ELerror,"SourceTrackCal: ") << "Could not find TrackCalColl with requested object ID" << endmsg; return 0; } _iter = _dataHandle->contents().begin(); _end = _dataHandle->contents().end(); _ietaCount = 0; _iphiCount = 0; return 1; } EnergyData* SourceTrackCal::next(){ EnergyData* eData =0; //while(_iter < _end && _iter->istdhep(_iter) != 1) // _iter++; if(_iter < _end){ HepLorentzVector vec = HepLorentzVector(_iter->Px(),_iter->Py(), _iter->Pz(),_iter->Energy()); //Since PhysicsTowerDataMaker expects only one entry per tower position //we do not give the real ieta and iphi but dummy values double trf=_iter->TrkFrac(); //we store track fraction in place of had fraction eData = new EnergyData(vec.phi(), vec.phi(), (1-trf)*_iter->Energy(), trf*_iter->Energy(), _ietaCount, _iphiCount, vec); } _iter++; // Here, we increment iphi by one, and ieta if iphi is at the end of the calorimeter grid _iphiCount++; if(_iphiCount == TOWER_PHI_SEG[TOWER_TYPE[_ietaCount]]){ _ietaCount++; _iphiCount = 0; } return eData; } #endif // USE_CDFEDM2