#include <TesIO.h>
Collaboration diagram for Atlfast::TesIO:
Public Types | |
typedef std::string | String |
Public Member Functions | |
TesIO (std::string mcLocation="", bool justHardScatter=true) | |
TesIoStat | getMC (MCparticleCollection &) const |
TesIoStat | getMC (MCparticleCollection &, const HepMC_helper::IMCselector *) const |
TesIoStat | getMCweightContainers (MCweightContainerCollection &) const |
Get the mc weights: 1 container per McEvent. | |
template<class T> | |
TesIoStat | getDH (const T *&) const |
template<class T> | |
TesIoStat | getDH (const T *&, String key) const |
template<class T> | |
TesIoStat | store (T *) const |
template<class T> | |
TesIoStat | store (T *, String key) const |
template<class T> | |
TesIoStat | store (T *, String key, bool allowmods) const |
template<class T> | |
TesIoStat | lock (T *) const |
template<class T, class U> | |
TesIoStat | copy (U &, String key) const |
Private Attributes | |
std::string | m_mcLocation |
bool | m_justHardScatter |
StoreGateSvc * | m_sgSvc |
Definition at line 86 of file TesIO.h.
typedef std::string Atlfast::TesIO::String |
Atlfast::TesIO::TesIO | ( | std::string | mcLocation = "" , |
|
bool | justHardScatter = true | |||
) | [inline] |
Definition at line 120 of file TesIO.h.
00120 : 00121 m_mcLocation(mcLocation), m_justHardScatter(justHardScatter), m_sgSvc(0) { 00122 ISvcLocator* svcLoc = Gaudi::svcLocator( ); 00123 if( (svcLoc->service( "StoreGateSvc", m_sgSvc )).isFailure() ){ 00124 throw TesIoStat(StatusCode::FAILURE, "TesIO could not find StoreGate"); 00125 } 00126 } //**************************************************************************
TesIoStat Atlfast::TesIO::getMC | ( | MCparticleCollection & | ) | const |
Definition at line 28 of file TesIO.cxx.
00028 { 00029 HepMC_helper::All selector; 00030 TesIoStat stat = this->getMC(mcParticles, &selector); 00031 return stat; 00032 }
TesIoStat Atlfast::TesIO::getMC | ( | MCparticleCollection & | , | |
const HepMC_helper::IMCselector * | ||||
) | const |
Definition at line 35 of file TesIO.cxx.
00036 { 00037 00038 const McEventCollection* mcCollptr(0); 00039 TesIoStat stat; 00040 if(m_mcLocation==""){ 00041 // std::cout<<"MCLOCATION1=BLANK"<<std::endl; 00042 stat = this->getDH(mcCollptr); 00043 }else{ 00044 // std::cout<<"MCLOCATION1=NONBLANK"<<std::endl; 00045 stat = this->getDH(mcCollptr,m_mcLocation); 00046 } 00047 00048 if(!stat){ 00049 return TesIoStat(StatusCode::FAILURE,"Could not find MC ptcles in TES"); 00050 } 00051 00052 // HepMC_helper::MCselectorWrapper wrappedSelector(selector); 00053 00054 // Iterate over all McEvent records 00055 McEventCollection::const_iterator itr; 00056 for (itr = mcCollptr->begin(); itr!=mcCollptr->end(); ++itr) { 00057 00058 // For 12.0.4, GenEvents are not aware of their status (hard scatter, 00059 // pileup, etc.. The following line ensures only the first event in the 00060 // McEventCollection is considered until the situation changes and 00061 // IsFromHardScatter can do more than just return true! 00062 00063 if ( m_justHardScatter && itr != mcCollptr->begin() ) continue; 00064 00065 //16/10/03 Genevt has been removed 00066 // Access the HepMC record which is wrapped within McEvent 00067 //16/10/03 HepMC::GenEvent* genEvt = (*itr)->pGenEvt() ; 00068 //16/10/03 if(genEvt == 0) return TesIoStat(StatusCode::FAILURE, 00069 //16/10/03 "Could not find HEP Gen event"); 00070 00071 00072 00073 /* idiot test - range inserter DOES NOT WORL!! 00074 HepMC::GenEvent::particle_const_iterator j= (*itr)->particles_begin(); 00075 HepMC::GenEvent::particle_const_iterator jj= (*itr)->particles_end(); 00076 MCparticleCollection junk(j, jj); 00077 MCparticleCollection junk1; 00078 for(;j!=jj;++j){junk1.push_back(*j);} 00079 */ 00080 //Copy ALL particles into mcParticles 00081 00082 /* 00083 mcParticles.insert(mcParticles.end(), 00084 (*itr)->particles_begin(), 00085 (*itr)->particles_end() 00086 ); 00087 */ 00088 00089 //partition moves the unselected particles to the back of 00090 //the vector. Use erase to regain space and reset the constianer end. 00091 00092 //mcParticles.erase( 00093 // std::partition(mcParticles.begin(), 00094 // mcParticles.end(), 00095 // SelectorBridge(selector) 00096 // ), 00097 // mcParticles.end() 00098 // ); 00099 00100 00101 00102 00103 HepMC::GenEvent::particle_const_iterator it= (*itr)->particles_begin(); 00104 HepMC::GenEvent::particle_const_iterator en= (*itr)->particles_end(); 00105 for(; it!=en; ++it){ 00106 if((*selector)(*it)){mcParticles.push_back(*it);} 00107 } 00108 00109 } 00110 return TesIoStat(StatusCode::SUCCESS); 00111 }
TesIoStat Atlfast::TesIO::getMCweightContainers | ( | MCweightContainerCollection & | ) | const |
Get the mc weights: 1 container per McEvent.
Definition at line 114 of file TesIO.cxx.
00115 { 00116 00117 const McEventCollection* mcCollptr(0); 00118 TesIoStat stat; 00119 if(m_mcLocation==""){ 00120 // std::cout<<"MCLOCATION2=BLANK"<<std::endl; 00121 stat = this->getDH(mcCollptr); 00122 }else{ 00123 stat = this->getDH(mcCollptr, m_mcLocation); 00124 // std::cout<<"MCLOCATION2=NONBLANK"<<std::endl; 00125 } 00126 if(!stat){ 00127 return TesIoStat(StatusCode::FAILURE,"Could not find MCEventCollection"); 00128 } 00129 00130 // HepMC_helper::MCselectorWrapper wrappedSelector(selector); 00131 00132 // Iterate over all McEvent records 00133 McEventCollection::const_iterator itr; 00134 for (itr = mcCollptr->begin(); itr!=mcCollptr->end(); ++itr) { 00135 00136 //having a real hard time (as usual) with HepMC containers 00137 //intead, do a little copying... 00138 00139 MCweightContainer container( ((*itr)->weights()).begin(), 00140 ((*itr)->weights()).end() 00141 ); 00142 mcWeightContainers.push_back( container ); 00143 } 00144 00145 return TesIoStat(StatusCode::SUCCESS); 00146 }
TesIoStat Atlfast::TesIO::getDH | ( | const T *& | ) | const [inline] |
Definition at line 147 of file TesIO.h.
00147 { 00148 // std::cout<<"CCT+PS TesIO:: getDH(DH)"<<m_mcLocation<<std::endl; 00149 if((m_sgSvc->retrieve(dh)).isFailure() ){ 00150 return TesIoStat(StatusCode::FAILURE, 00151 "Could not find a valid DataHandle"); 00152 } 00153 return TesIoStat(StatusCode::SUCCESS, "Found unkeyed DH in TDS"); 00154 }
Definition at line 159 of file TesIO.h.
00159 { 00160 // std::cout<<"CCT+PS TesIO:: getDH(DH+STRING)"<<m_mcLocation<<std::endl; 00161 if( (m_sgSvc->retrieve(dh, key)).isFailure() ){ 00162 return TesIoStat(StatusCode::FAILURE, 00163 "Could not find a valid keyed DataHandle"); 00164 } 00165 return TesIoStat(StatusCode::SUCCESS, "Found keyed DH in TDS"); 00166 }
TesIoStat Atlfast::TesIO::store | ( | T * | ) | const [inline] |
TesIoStat Atlfast::TesIO::lock | ( | T * | ) | const [inline] |
copy from a Collection in the TES (template parameter T), to a local Collection U
Definition at line 131 of file TesIO.h.
00131 { 00132 const T* objects(0); 00133 TesIoStat stat = this->getDH(objects, key); 00134 if(!stat){ 00135 return TesIoStat(StatusCode::FAILURE, 00136 "Could not copyCollection keyed collection: "+stat.message()); 00137 } 00138 00139 std::copy(objects->begin(),objects->end(),std::back_inserter(localCopy)); 00140 return TesIoStat(StatusCode::SUCCESS, "Copied Collection from TDS"); 00141 00142 }
std::string Atlfast::TesIO::m_mcLocation [private] |
bool Atlfast::TesIO::m_justHardScatter [private] |
StoreGateSvc* Atlfast::TesIO::m_sgSvc [private] |