#ifdef USE_CDFEDM2 ////////////////////////////////////////////////////////////////////////// // // Component: SourceHEPG.cc // Purpose: This is a concrete class that uses HEPG bank to fill // EnergyData object. This class inherits from // InputSource. // // The following variable will be filled in EnergyData // - emPhi: phi of particle // - hadPhi: samething as above // - emEnergy: 60% of particle energy // - hadEnergy: 40% of particle energy // - eta: particle 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 particle. They need to be filled to // store in a PhysicsTowerData. // // Created: Aug 15 2002, Jean-Francois Arguin // History: // 25/11/2002 Matthias Toennesmann - Create EnergyData object from 4-vector (was: 3-vector). // ////////////////////////////////////////////////////////////////////////// #include "Edm/GenericConstHandle.hh" #include "Calor/SourceHEPG.hh" #include "CalorGeometry/CalConstants.hh" #include "ErrorLogger_i/gERRLOG.hh" // namespace calor { SourceHEPG::SourceHEPG():_sourceName("HEPG"){} Id SourceHEPG::initEvent(AbsEvent* anEvent){ StorableObject::SelectByClassName cName( "HEPG_StorableBank" ); EventRecord::ConstIterator hepgIterator(anEvent, cName); if ( hepgIterator.is_valid() ) _dataHandle = ConstHandle(hepgIterator); else { _dataHandle.set_null(); ERRLOG(ELerror,"SourceHEPG: ") << "Could not find HEPG_StorableBank" << endmsg; return 0; } //HEPG_StorableBank::particleIter thisParticle(*_dataHandle, 0); _iter = _dataHandle->first_displaced(); _end = _dataHandle->n_particles(); _ietaCount = 0; _iphiCount = 0; return _dataHandle->object_id(); // return the object ID } Id SourceHEPG::initEvent(AbsEvent* anEvent, Id objectId){ StorableObject::SelectByObjectId selector( objectId); EventRecord::ConstIterator hepgIterator( anEvent, selector ); if ( hepgIterator.is_valid() ) _dataHandle = ConstHandle(hepgIterator); else { _dataHandle.set_null(); ERRLOG(ELerror,"SourceHEPG: ") << "Could not find HEPG StorableBank with requested object ID" << endmsg; return 0; } _iter = _dataHandle->first_displaced(); _end = _dataHandle->n_particles(); _ietaCount = 0; _iphiCount = 0; return 1; } EnergyData* SourceHEPG::next(){ HepLorentzVector vec(_dataHandle->Px(_iter),_dataHandle->Py(_iter),_dataHandle->Pz(_iter),_dataHandle->E(_iter)); float thePhi = vec.phi(); if(thePhi < 0) thePhi += TWOPI; EnergyData* eData = new EnergyData(thePhi, thePhi, 0.60 * _dataHandle->E(_iter), 0.40 * _dataHandle->E(_iter), _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