#include <GenHeaderCnv.h>
Inheritance diagram for GenHeaderCnv:
bv@bnl.gov Wed Aug 6 16:10:24 2008
Definition at line 19 of file GenHeaderCnv.h.
GenHeaderCnv::GenHeaderCnv | ( | ISvcLocator * | svc | ) |
Definition at line 7 of file GenHeaderCnv.cc.
00008 : RootIOTypedCnv<PerGenHeader,GenHeader>("PerGenHeader", 00009 classID(),svc) 00010 { 00011 // Set threshold for maximum number of vertices. 00012 // GenHeaders with more vertices will not be written out 00013 // This is temporary for MDC10a 00014 // wangzhe 00015 // Raise it to 50 for safe. When adding muon spallation background, it is ofter above 10. 00016 m_maxVertices = 50; 00017 // Wz 00018 MsgStream log(msgSvc(), "GenHeaderCnv"); 00019 00020 log << MSG::INFO 00021 << "Only minimal GenHeader info will be persisted for GenHeaders with > " 00022 << m_maxVertices 00023 << " vertices. THIS IS TEMPORARY FOR MDC10a."<<endreq; 00024 }
GenHeaderCnv::~GenHeaderCnv | ( | ) | [virtual] |
static const CLID& GenHeaderCnv::classID | ( | ) | [inline, static] |
StatusCode GenHeaderCnv::PerToTran | ( | const PerGenHeader & | tobj, | |
DayaBay::GenHeader & | dobj | |||
) | [virtual] |
Copy data from TObject based class of type TType to DataObject based class of type DOType.
Implements RootIOTypedCnv< PerGenHeader, DayaBay::GenHeader >.
Definition at line 32 of file GenHeaderCnv.cc.
00034 { 00035 StatusCode sc = HeaderObjectCnv::toTran(perobj,tranobj); 00036 if (sc.isFailure()) return sc; 00037 00038 MsgStream log(msgSvc(), "GenHeaderCnv::PerToTran"); 00039 00040 tranobj.setGeneratorName(perobj.name); 00041 00042 PerGenEvent* pgevt = perobj.event; 00043 if (!pgevt) { 00044 tranobj.setEvent(0); 00045 log << MSG::WARNING 00046 << "Null PerGenEvent pointer" 00047 << endreq; 00048 return StatusCode::SUCCESS; 00049 } 00050 00051 HepMC::GenEvent* gevt = new HepMC::GenEvent(pgevt->signalProcessId, 00052 pgevt->eventNumber, 00053 0, 00054 pgevt->weights); 00055 00056 // Map from persistent to transient particles 00057 std::map<PerGenParticle*,HepMC::GenParticle*> particleMap; 00058 for (size_t ind=0; ind<pgevt->particles.size(); ++ind) { 00059 PerGenParticle* pgpart = pgevt->particles[ind]; 00060 HepMC::GenParticle* gpart = 00061 new HepMC::GenParticle(pgpart->momentum, 00062 pgpart->pdgId, 00063 pgpart->status, 00064 HepMC::Flow(), 00065 HepMC::Polarization(pgpart->polTheta, 00066 pgpart->polPhi)); 00067 00068 particleMap[pgpart] = gpart; 00069 } 00070 00071 // Convert vertices and add in/out particles 00072 std::map<PerGenVertex*,HepMC::GenVertex*> vertexMap; 00073 for (size_t ind=0; ind<pgevt->vertices.size(); ++ind) { 00074 PerGenVertex* pgvtx = pgevt->vertices[ind]; 00075 HepMC::GenVertex* gvtx = new HepMC::GenVertex(pgvtx->position, 00076 pgvtx->id, 00077 pgvtx->weights); 00078 gevt->add_vertex(gvtx); 00079 for (size_t pi_ind=0; pi_ind < pgvtx->particlesIn.size(); ++pi_ind) { 00080 PerGenParticle* pgpart = pgevt->particles[pgvtx->particlesIn[pi_ind]]; 00081 HepMC::GenParticle* gpart = particleMap[pgpart]; 00082 gvtx->add_particle_in(gpart); 00083 } 00084 for (size_t po_ind=0; po_ind < pgvtx->particlesOut.size(); ++po_ind) { 00085 PerGenParticle* pgpart = pgevt->particles[pgvtx->particlesOut[po_ind]]; 00086 HepMC::GenParticle* gpart = particleMap[pgpart]; 00087 gvtx->add_particle_out(gpart); 00088 } 00089 00090 if ((int)ind == pgevt->signalProcessIndex) { 00091 gevt->set_signal_process_vertex(gvtx); 00092 } 00093 } 00094 00095 tranobj.setEvent(gevt); 00096 00097 return StatusCode::SUCCESS; 00098 }
StatusCode GenHeaderCnv::TranToPer | ( | const DayaBay::GenHeader & | dobj, | |
PerGenHeader & | tobj | |||
) | [virtual] |
Copy data from DataObject based class of type DOType to TObject based class of type TType.
Implements RootIOTypedCnv< PerGenHeader, DayaBay::GenHeader >.
Definition at line 101 of file GenHeaderCnv.cc.
00103 { 00104 StatusCode sc = HeaderObjectCnv::toPer(tranobj,perobj); 00105 if (sc.isFailure()) return sc; 00106 00107 MsgStream log(msgSvc(), "GenHeaderCnv::TranToPer"); 00108 00109 perobj.name = tranobj.generatorName(); 00110 00111 const HepMC::GenEvent* genevt = tranobj.event(); 00112 00113 if (!genevt) { 00114 perobj.event = 0; 00115 log << MSG::WARNING 00116 << "Null HepMC::GenEvent pointer" 00117 << endreq; 00118 return StatusCode::SUCCESS; 00119 } 00120 00121 PerGenEvent* pgevt = new PerGenEvent(); 00122 00123 // Fill the event 00124 00125 // Basic stuff 00126 pgevt->eventNumber = genevt->event_number(); 00127 pgevt->signalProcessId = genevt->signal_process_id(); 00128 00129 00130 // Only save vertices when there are a few. 00131 // This is temporary for MDC10a 00132 log << MSG::DEBUG << "# vertices = " << genevt->vertices_size() << endreq; 00133 if (genevt->vertices_size() <= m_maxVertices ){ 00134 log << MSG::DEBUG << "Saving all vertices " << endreq; 00135 00136 // Weights 00137 const HepMC::WeightContainer& weights = genevt->weights(); 00138 pgevt->weights.clear(); 00139 pgevt->weights.insert(pgevt->weights.begin(), 00140 weights.begin(), weights.end()); 00141 00142 // Particles - first pass 00143 std::map<HepMC::GenParticle*,int> particleIndexMap; 00144 pgevt->particles.clear(); 00145 HepMC::GenEvent::particle_const_iterator pit, 00146 pdone = genevt->particles_end(); 00147 for (pit = genevt->particles_begin(); pit != pdone; ++pit) { 00148 HepMC::GenParticle* gpart = *pit; 00149 particleIndexMap[gpart] = pgevt->particles.size(); // for later lookup 00150 CLHEP::HepLorentzVector momentum(gpart->momentum().x(), 00151 gpart->momentum().y(), 00152 gpart->momentum().z(), 00153 gpart->momentum().t()); 00154 PerGenParticle* pgpart = 00155 new PerGenParticle(momentum, 00156 gpart->pdg_id(), 00157 gpart->status(), 00158 gpart->polarization().theta(), 00159 gpart->polarization().phi(), 00160 gpart->barcode()); 00161 pgevt->particles.push_back(pgpart); 00162 } 00163 00164 // Vertices 00165 pgevt->vertices.clear(); 00166 HepMC::GenVertex* signal_process_vertex = genevt->signal_process_vertex(); 00167 HepMC::GenEvent::vertex_const_iterator vit, 00168 vdone = genevt->vertices_end(); 00169 for (vit = genevt->vertices_begin(); vit != vdone; ++vit) { 00170 HepMC::GenVertex* gvtx = *vit; 00171 CLHEP::HepLorentzVector position(gvtx->position().x(), 00172 gvtx->position().y(), 00173 gvtx->position().z(), 00174 gvtx->position().t()); 00175 PerGenVertex* pgvtx = 00176 new PerGenVertex(position, 00177 gvtx->id(), 00178 gvtx->barcode(), 00179 gvtx->weights()); 00180 00181 // Fill in particle info 00182 HepMC::GenVertex::particles_in_const_iterator piit, 00183 pidone = gvtx->particles_in_const_end(); 00184 for (piit = gvtx->particles_in_const_begin(); piit != pidone; ++piit) { 00185 std::map<HepMC::GenParticle*,int>::iterator pimit = 00186 particleIndexMap.find(*piit); 00187 if (pimit != particleIndexMap.end()) { 00188 pgvtx->particlesIn.push_back(pimit->second); 00189 } 00190 } 00191 // Fill out particle info 00192 HepMC::GenVertex::particles_out_const_iterator poit, 00193 podone = gvtx->particles_out_const_end(); 00194 for (poit = gvtx->particles_out_const_begin(); poit != podone; ++poit) { 00195 std::map<HepMC::GenParticle*,int>::iterator pomit = 00196 particleIndexMap.find(*poit); 00197 if (pomit != particleIndexMap.end()) { 00198 pgvtx->particlesOut.push_back(pomit->second); 00199 } 00200 } 00201 00202 if (signal_process_vertex == gvtx) { 00203 pgevt->signalProcessIndex = pgevt->vertices.size(); 00204 } 00205 pgevt->vertices.push_back(pgvtx); 00206 } 00207 } 00208 else { 00209 log << MSG::DEBUG << "Not saving any vertices " << endreq; 00210 } //(genevt->vertices_size() <= m_maxVertices ) 00211 00212 delete perobj.event; 00213 perobj.event = pgevt; 00214 return StatusCode::SUCCESS; 00215 }
StatusCode GenHeaderCnv::fillRepRefs | ( | IOpaqueAddress * | addr, | |
DataObject * | dobj | |||
) | [virtual] |
Reimplemented from RootIOTypedCnv< PerGenHeader, DayaBay::GenHeader >.
Definition at line 217 of file GenHeaderCnv.cc.
00218 { 00219 MsgStream log(msgSvc(), "GenHeaderCnv::fillRepRefs"); 00220 GenHeader* gh = dynamic_cast<GenHeader*>(dobj); 00221 00222 log << MSG::DEBUG 00223 << "Saving links to " << gh->inputHeaders().size() 00224 << " input headers" << endreq; 00225 00226 StatusCode sc = HeaderObjectCnv::fillPer(m_rioSvc,*gh,*m_perOutObj); 00227 if (sc.isFailure()) { 00228 log << MSG::ERROR << "Failed to fill HeaderObject part" << endreq; 00229 return sc; 00230 } 00231 00232 // ... fill GenHeader part... 00233 return sc; 00234 }
StatusCode GenHeaderCnv::fillObjRefs | ( | IOpaqueAddress * | addr, | |
DataObject * | dobj | |||
) | [virtual] |
Reimplemented from RootIOTypedCnv< PerGenHeader, DayaBay::GenHeader >.
Definition at line 236 of file GenHeaderCnv.cc.
00237 { 00238 MsgStream log(msgSvc(), "GenHeaderCnv::fillObjRefs"); 00239 HeaderObject* hobj = dynamic_cast<HeaderObject*>(dobj); 00240 StatusCode sc = HeaderObjectCnv::fillTran(m_rioSvc,*m_perInObj,*hobj); 00241 if (sc.isFailure()) { 00242 log << MSG::ERROR << "Failed to fill HeaderObject part" << endreq; 00243 return sc; 00244 } 00245 00246 log << MSG::DEBUG 00247 << "Restored links to " << hobj->inputHeaders().size() 00248 << " input headers" << endreq; 00249 00250 // ... fill GenHeader part... 00251 return sc; 00252 }
PerGenHeader & RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::getPerInputObject | ( | ) | [inherited] |
PerGenHeader & RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::getPerOutputObject | ( | ) | [inherited] |
const RootIOBaseObject * RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::getBaseInputObject | ( | ) | [virtual, inherited] |
Implements RootIOBaseCnv.
const RootIOBaseObject * RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::getBaseOutputObject | ( | ) | [virtual, inherited] |
Implements RootIOBaseCnv.
virtual StatusCode RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::TranObjectToPerObject | ( | DataObject & | dat, | |
const RootOutputAddress & | ||||
) | [virtual, inherited] |
Implements RootIOBaseCnv.
virtual StatusCode RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::PerObjectToTranObject | ( | DataObject *& | dat | ) | [virtual, inherited] |
Implements RootIOBaseCnv.
virtual RootInputStream * RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::makeInputStream | ( | const RootInputAddress & | ria | ) | [virtual, inherited] |
Implements RootIOBaseCnv.
virtual RootOutputStream * RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::makeOutputStream | ( | const RootOutputAddress & | ria | ) | [virtual, inherited] |
Implements RootIOBaseCnv.
virtual long RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::repSvcType | ( | ) | const [virtual, inherited] |
Reimplemented from RootIOBaseCnv.
virtual StatusCode RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::initialize | ( | ) | [virtual, inherited] |
Reimplemented from RootIOBaseCnv.
virtual StatusCode RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::finalize | ( | ) | [virtual, inherited] |
Reimplemented from RootIOBaseCnv.
virtual StatusCode RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::createObj | ( | IOpaqueAddress * | addr, | |
DataObject *& | dat | |||
) | [virtual, inherited] |
Reimplemented from RootIOBaseCnv.
virtual StatusCode RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::createRep | ( | DataObject * | pObject, | |
IOpaqueAddress *& | refpAddress | |||
) | [virtual, inherited] |
Reimplemented from RootIOBaseCnv.
int RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::commit | ( | const RootOutputAddress & | roa | ) | [inherited] |
Reimplemented from RootIOBaseCnv.
RootIOBaseCnv * RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::otherConverter | ( | int | clID | ) | [inherited] |
Reimplemented from RootIOBaseCnv.
virtual StatusCode RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::queryInterface | ( | const InterfaceID & | riid, | |
void ** | ppvInterface | |||
) | [virtual, inherited] |
Reimplemented from RootIOBaseCnv.
virtual unsigned long RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::addRef | ( | ) | [virtual, inherited] |
Reimplemented from RootIOBaseCnv.
virtual unsigned long RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::release | ( | ) | [virtual, inherited] |
Reimplemented from RootIOBaseCnv.
virtual StatusCode RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::setDataProvider | ( | IDataProviderSvc * | svc | ) | [virtual, inherited] |
Reimplemented from RootIOBaseCnv.
virtual IDataProviderSvc * RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::dataProvider | ( | ) | const [virtual, inherited] |
Reimplemented from RootIOBaseCnv.
virtual StatusCode RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::setConversionSvc | ( | IConversionSvc * | svc | ) | [virtual, inherited] |
Reimplemented from RootIOBaseCnv.
virtual IConversionSvc * RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::conversionSvc | ( | ) | const [virtual, inherited] |
Reimplemented from RootIOBaseCnv.
virtual StatusCode RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::setAddressCreator | ( | IAddressCreator * | creator | ) | [virtual, inherited] |
Reimplemented from RootIOBaseCnv.
virtual IAddressCreator * RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::addressCreator | ( | ) | const [virtual, inherited] |
Reimplemented from RootIOBaseCnv.
virtual const CLID & RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::objType | ( | ) | const [virtual, inherited] |
Reimplemented from RootIOBaseCnv.
virtual long RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::i_repSvcType | ( | ) | const [virtual, inherited] |
Reimplemented from RootIOBaseCnv.
virtual StatusCode RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::updateObj | ( | IOpaqueAddress * | pAddress, | |
DataObject * | refpObject | |||
) | [virtual, inherited] |
Reimplemented from RootIOBaseCnv.
virtual StatusCode RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::updateObjRefs | ( | IOpaqueAddress * | pAddress, | |
DataObject * | pObject | |||
) | [virtual, inherited] |
Reimplemented from RootIOBaseCnv.
virtual StatusCode RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::updateRep | ( | IOpaqueAddress * | pAddress, | |
DataObject * | pObject | |||
) | [virtual, inherited] |
Reimplemented from RootIOBaseCnv.
virtual StatusCode RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::updateRepRefs | ( | IOpaqueAddress * | pAddress, | |
DataObject * | pObject | |||
) | [virtual, inherited] |
Reimplemented from RootIOBaseCnv.
StatusCode RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::service | ( | const std::string & | name, | |
T *& | psvc, | |||
bool | createIf = false | |||
) | const [inherited] |
Reimplemented from RootIOBaseCnv.
StatusCode RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::service | ( | const std::string & | type, | |
const std::string & | name, | |||
T *& | psvc | |||
) | const [inherited] |
Reimplemented from RootIOBaseCnv.
static unsigned char RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::storageType | ( | ) | [static, inherited] |
Reimplemented from RootIOBaseCnv.
static const InterfaceID & RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::interfaceID | ( | ) | [static, inherited] |
Reimplemented from RootIOBaseCnv.
static const InterfaceID & RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::interfaceID | ( | ) | [static, inherited] |
Reimplemented from RootIOBaseCnv.
ISvcLocator * RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::serviceLocator | ( | ) | const [protected, inherited] |
Reimplemented from RootIOBaseCnv.
IMessageSvc * RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::msgSvc | ( | ) | const [protected, inherited] |
Reimplemented from RootIOBaseCnv.
IMessageSvc * RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::messageService | ( | ) | const [protected, inherited] |
Reimplemented from RootIOBaseCnv.
IDataManagerSvc * RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::dataManager | ( | ) | const [protected, inherited] |
Reimplemented from RootIOBaseCnv.
int GenHeaderCnv::m_maxVertices [private] |
Definition at line 48 of file GenHeaderCnv.h.
RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::INVALID_ADDRESS [inherited] |
Reimplemented from RootIOBaseCnv.
RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::INVALID_OBJECT [inherited] |
Reimplemented from RootIOBaseCnv.
RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::NO_MEMORY [inherited] |
Reimplemented from RootIOBaseCnv.
RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::BAD_STORAGE_TYPE [inherited] |
Reimplemented from RootIOBaseCnv.
RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::NO_SOURCE_OBJECT [inherited] |
Reimplemented from RootIOBaseCnv.
RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::ICONVERSIONSVC_LAST_ERROR [inherited] |
Reimplemented from RootIOBaseCnv.
std::string RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::m_perclassName [protected, inherited] |
PerGenHeader * RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::m_perInObj [protected, inherited] |
PerGenHeader * RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::m_perOutObj [protected, inherited] |
IRootIOSvc * RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::m_rioSvc [protected, inherited] |
Reimplemented from RootIOBaseCnv.
IConversionSvc * RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::m_cnvSvc [protected, inherited] |
Reimplemented from RootIOBaseCnv.
RootInputStream * RootIOTypedCnv< PerGenHeader , DayaBay::GenHeader >::m_ris [protected, inherited] |
Reimplemented from RootIOBaseCnv.