#ifdef USE_CDFEDM2 ////////////////////////////////////////////////////////////////////////// // // Component: SourceCdfTrackView.cc // Purpose: This is a concrete class that uses CdfTrackView to fill // EnergyData object. This class inherits from // InputSource. // // The following variable will be filled in EnergyData // from CdfTracks: // - emPhi: phi0 of track // - hadPhi: samething as above // - emEnergy: 60% of track momentum // - hadEnergy: 40% of track momentum // - eta: track pseudorapidity // Note: The ratio em/had is based on an average // for jets // // ieta and iphi are dummy, and are incremented by one // at each new track. We fill them because that's how // they're stored in PhysicsTowerData. // // Created: Aug 6 2002, Jean-Francois Arguin // History: // 25/11/2002 Matthias Toennesmann - Create EnergyData object from 4-vector (was: 3-vector). The 4-vector is assumed to be // massless. (Should we assign the pion mass to it?) // ////////////////////////////////////////////////////////////////////////// #include "Edm/GenericConstHandle.hh" #include "Calor/SourceCdfTrackView.hh" #include "CalorGeometry/CalConstants.hh" #include "ErrorLogger_i/gERRLOG.hh" // namespace calor { SourceCdfTrackView::SourceCdfTrackView():_sourceName("CdfTrackView"){} Id SourceCdfTrackView::initEvent(AbsEvent* anEvent){ ERRLOG(ELwarning,"SourceCdfTrackView: ") << "No object ID specified. Will use defTracks" << endmsg; CdfTrackView_h tmpHandle(new CdfTrackView()); const std::string inputDesc = "DefTracksExample"; tmpHandle->set_description(inputDesc); if(CdfTrackView::defTracks(tmpHandle) == CdfTrackView::OK) GenericConstHandle writeHandle(anEvent->append(tmpHandle)); StorableObject::SelectByDescription selector( inputDesc); EventRecord::ConstIterator cdfTrackViewIter( anEvent, selector ); if ( !cdfTrackViewIter.is_valid() ) { _dataHandle.set_null(); ERRLOG(ELerror,"SourceCdfTrackView: ") << "Could not find CdfTrackView" << endmsg; } _dataHandle = CdfTrackView_ch( cdfTrackViewIter ); _iter = _dataHandle->contents().begin(); _end = _dataHandle->contents().end(); _ietaCount = 0; _iphiCount = 0; return _dataHandle->object_id(); // return the object ID } Id SourceCdfTrackView::initEvent(AbsEvent* anEvent, Id objectId){ StorableObject::SelectByObjectId selector( objectId); EventRecord::ConstIterator cdfTrackViewIter( anEvent, selector ); if ( cdfTrackViewIter.is_valid() ) _dataHandle = CdfTrackView_ch( cdfTrackViewIter ); else { _dataHandle.set_null(); ERRLOG(ELerror,"SourceCdfTrackView: ") << "Could not find CdfTrackView with requested object ID" << endmsg; return 0; } _iter = _dataHandle->contents().begin(); _end = _dataHandle->contents().end(); _ietaCount = 0; _iphiCount = 0; return 1; } EnergyData* SourceCdfTrackView::next(){ // Average em fraction and had fraction in a jet are respectively 60% and 40% // That's what we assign to the emEnergy and hadEnergy of the tower . EnergyData* eData = new EnergyData((*_iter)->phi0(), (*_iter)->phi0(), 0.60 * (*_iter)->momentum().mag(), 0.40 * (*_iter)->momentum().mag(), _ietaCount, _iphiCount, HepLorentzVector((*_iter)->momentum(),(*_iter)->momentum().mag())); ++_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