| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

SimHeaderCnv Class Reference

Converter between SimHeader and PerSimHeader. More...

#include <SimHeaderCnv.h>

Inheritance diagram for SimHeaderCnv:

[legend]
Collaboration diagram for SimHeaderCnv:
[legend]
List of all members.

Public Types

 INVALID_ADDRESS
 INVALID_OBJECT
 NO_MEMORY
 BAD_STORAGE_TYPE
 NO_SOURCE_OBJECT
 ICONVERSIONSVC_LAST_ERROR
 SUCCESS
 NO_INTERFACE
 VERSMISMATCH
 LAST_ERROR
enum  Status

Public Member Functions

 SimHeaderCnv (ISvcLocator *svc)
virtual ~SimHeaderCnv ()
StatusCode PerToTran (const PerSimHeader &tobj, DayaBay::SimHeader &dobj)
 Copy data from TObject based class of type TType to DataObject based class of type DOType.
StatusCode TranToPer (const DayaBay::SimHeader &dobj, PerSimHeader &tobj)
 Copy data from DataObject based class of type DOType to TObject based class of type TType.
StatusCode fillRepRefs (IOpaqueAddress *addr, DataObject *dobj)
StatusCode fillObjRefs (IOpaqueAddress *addr, DataObject *dobj)
PerSimHeadergetPerInputObject ()
PerSimHeadergetPerOutputObject ()
const RootIOBaseObjectgetBaseInputObject ()
const RootIOBaseObjectgetBaseOutputObject ()
virtual StatusCode TranObjectToPerObject (DataObject &dat, const RootOutputAddress &)
virtual StatusCode PerObjectToTranObject (DataObject *&dat)
virtual RootInputStreammakeInputStream (const RootInputAddress &ria)
virtual RootOutputStreammakeOutputStream (const RootOutputAddress &ria)
virtual long repSvcType () const
virtual StatusCode initialize ()
virtual StatusCode finalize ()
virtual StatusCode createObj (IOpaqueAddress *addr, DataObject *&dat)
virtual StatusCode createRep (DataObject *pObject, IOpaqueAddress *&refpAddress)
int commit (const RootOutputAddress &roa)
RootIOBaseCnvotherConverter (int clID)
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvInterface)
virtual unsigned long addRef ()
virtual unsigned long release ()
virtual StatusCode setDataProvider (IDataProviderSvc *svc)
virtual IDataProviderSvcdataProvider () const
virtual StatusCode setConversionSvc (IConversionSvc *svc)
virtual IConversionSvcconversionSvc () const
virtual StatusCode setAddressCreator (IAddressCreator *creator)
virtual IAddressCreatoraddressCreator () const
virtual const CLIDobjType () const
virtual long i_repSvcType () const
virtual StatusCode updateObj (IOpaqueAddress *pAddress, DataObject *refpObject)
virtual StatusCode updateObjRefs (IOpaqueAddress *pAddress, DataObject *pObject)
virtual StatusCode updateRep (IOpaqueAddress *pAddress, DataObject *pObject)
virtual StatusCode updateRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
StatusCode service (const std::string &name, T *&psvc, bool createIf=false) const
StatusCode service (const std::string &type, const std::string &name, T *&psvc) const

Static Public Member Functions

static const CLIDclassID ()
static unsigned char storageType ()
static const InterfaceIDinterfaceID ()
static const InterfaceIDinterfaceID ()

Public Attributes

 INVALID_ADDRESS
 INVALID_OBJECT
 NO_MEMORY
 BAD_STORAGE_TYPE
 NO_SOURCE_OBJECT
 ICONVERSIONSVC_LAST_ERROR

Protected Member Functions

ISvcLocatorserviceLocator () const
IMessageSvcmsgSvc () const
IMessageSvcmessageService () const
IDataManagerSvcdataManager () const

Protected Attributes

std::string m_perclassName
PerSimHeaderm_perInObj
PerSimHeaderm_perOutObj
IRootIOSvcm_rioSvc
IConversionSvcm_cnvSvc
RootInputStreamm_ris

Private Member Functions

DayaBay::SimParticleHistoryconvert (std::vector< DayaBay::SimTrack * > &timap, DayaBay::SimHeader &sh, const PerSimParticleHistory &pph)
PerSimParticleHistoryconvert (std::map< const DayaBay::SimTrack *, int > &trackMap, const DayaBay::SimParticleHistory &ph)
DayaBay::SimHitCollectionconvert (std::vector< DayaBay::SimTrack * > &timap, const PerSimHitCollection &phc)
PerSimHitCollectionconvert (std::map< const DayaBay::SimTrack *, int > &trackMap, const DayaBay::SimHitCollection &hc)
DayaBay::SimUnobservableStatisticsHeaderconvert (const PerSimUnobservableStatistics &pstat)
PerSimUnobservableStatisticsconvert (const DayaBay::SimUnobservableStatisticsHeader &stat)
void relate (DayaBay::SimHeader &sh)

Private Attributes

int m_maxNoPHtoS
int m_NoPHtoSmsgs
bool m_pruneSimHits

Detailed Description

Converter between SimHeader and PerSimHeader.

bv@bnl.gov Thu Aug 14 17:04:08 2008

Definition at line 29 of file SimHeaderCnv.h.


Constructor & Destructor Documentation

SimHeaderCnv::SimHeaderCnv ( ISvcLocator svc  ) 

Definition at line 13 of file SimHeaderCnv.cc.

00014     : RootIOTypedCnv<PerSimHeader,SimHeader>("PerSimHeader",
00015                                              classID(),svc)
00016 {
00017     // set maximum number of warnings of "no particle history to save"
00018     m_maxNoPHtoS = 10;
00019     m_NoPHtoSmsgs=  0;
00020 
00021     m_pruneSimHits = false;
00022     char* foo = getenv("NUWA_PRUNESIMHITS");
00023     if (foo) {
00024         m_pruneSimHits = true;
00025     }
00026 }

SimHeaderCnv::~SimHeaderCnv (  )  [virtual]

Definition at line 28 of file SimHeaderCnv.cc.

00029 {
00030 }


Member Function Documentation

static const CLID& SimHeaderCnv::classID (  )  [inline, static]

Definition at line 33 of file SimHeaderCnv.h.

00033                                  {
00034         return DayaBay::CLID_SimHeader;
00035     }

StatusCode SimHeaderCnv::PerToTran ( const PerSimHeader tobj,
DayaBay::SimHeader dobj 
) [virtual]

Copy data from TObject based class of type TType to DataObject based class of type DOType.

Implements RootIOTypedCnv< PerSimHeader, DayaBay::SimHeader >.

Definition at line 33 of file SimHeaderCnv.cc.

00035 {
00036     StatusCode sc = HeaderObjectCnv::toTran(perobj,tranobj);
00037     if (sc.isFailure()) return sc;
00038 
00039     MsgStream log(msgSvc(), "SimHeaderCnv::PerToTran");
00040 
00041     // Convert the historian part
00042     vector<SimTrack*> timap;
00043     const PerSimParticleHistory* pph = perobj.history;
00044     if (!pph) {
00045         log << MSG::DEBUG
00046             << "No particle history in persistent object." << endreq;
00047         tranobj.setParticleHistory(0);
00048     }
00049     else {
00050         SimParticleHistory* ph = convert(timap,tranobj,*pph);
00051         if (ph) {
00052             tranobj.setParticleHistory(ph);
00053         }
00054         else {
00055             log << MSG::ERROR
00056                 << "Failed to convert the SimParticleHistory" << endreq;
00057         }
00058     }
00059 
00060     if (perobj.hits) { // Convert the Hits part
00061         const PerSimHitHeader::phc_map& pcolmap = perobj.hits->hitCollections;
00062 
00063         log << MSG::DEBUG << "Reading " << pcolmap.size() << " hit collections" << endreq;
00064 
00065         SimHitHeader* shit_header = new SimHitHeader;
00066         shit_header->setHeader(&tranobj);
00067         tranobj.setHits(shit_header);
00068 
00069         PerSimHitHeader::phc_map::const_iterator it, done = pcolmap.end();
00070         for (it = pcolmap.begin(); it != done; ++it) {
00071             int detectorID = it->first;
00072             const PerSimHitCollection* phc = it->second;
00073             SimHitCollection* hc = convert(timap,*phc);
00074             hc->setHeader(shit_header);
00075             shit_header->addHitCollection(hc);
00076 
00077             DayaBay::Detector det((short)detectorID);
00078             log << MSG::DEBUG << "Reading " << phc->hits.size() 
00079                 << " hits for detector " << det.detName()
00080                 << " ("
00081                 << detectorID 
00082                 << ")"
00083                 << endreq;
00084         }
00085     }
00086     else {
00087         log << MSG::DEBUG << "No persistent hits to convert" << endreq;
00088     }
00089 
00090     { // Convert the stats part
00091         const PerSimUnobservableStatistics* pstat = perobj.stats;
00092         if (!pstat) {
00093             log << MSG::DEBUG
00094                 << "No unobservable statistics in persistent object." << endreq;
00095             tranobj.setUnobservableStatistics(0);
00096         }
00097         else {
00098             SimUnobservableStatisticsHeader* stat = convert(*pstat);
00099             tranobj.setUnobservableStatistics(stat);
00100         }
00101     }
00102 
00103     return StatusCode::SUCCESS;
00104 }

StatusCode SimHeaderCnv::TranToPer ( const DayaBay::SimHeader dobj,
PerSimHeader tobj 
) [virtual]

Copy data from DataObject based class of type DOType to TObject based class of type TType.

Implements RootIOTypedCnv< PerSimHeader, DayaBay::SimHeader >.

Definition at line 106 of file SimHeaderCnv.cc.

00108 {
00109     StatusCode sc = HeaderObjectCnv::toPer(tranobj,perobj);
00110     if (sc.isFailure()) return sc;
00111 
00112     MsgStream log(msgSvc(), "SimHeaderCnv::TranToPer");
00113 
00114     map<const SimTrack*,int> trackMap;
00115 
00116     { // Convert the historian part
00117         const SimParticleHistory* ph = tranobj.particleHistory();
00118         delete perobj.history;
00119         if (!ph) {
00120           m_NoPHtoSmsgs += 1;
00121           if ( m_NoPHtoSmsgs < m_maxNoPHtoS ) {
00122             log << MSG::WARNING
00123                 << "No Particle history to save" << endreq;
00124           }
00125           if ( m_NoPHtoSmsgs == m_maxNoPHtoS ) {
00126             log << MSG::WARNING
00127                 << "No Particle history to save. Additional warnings will be suppressed. " << endreq;
00128           }
00129           
00130             perobj.history = 0;
00131         }
00132         else {
00133             PerSimParticleHistory* pph = convert(trackMap,*ph);
00134             perobj.history = pph;
00135         }
00136     }
00137 
00138     { // Convert the Hits part
00139         if (perobj.hits) {
00140             delete perobj.hits;
00141             perobj.hits = 0;
00142         }
00143         perobj.hits = new PerSimHitHeader();
00144         PerSimHitHeader::phc_map& phcolmap = perobj.hits->hitCollections;
00145         if (m_pruneSimHits) {
00146             static int count = 0; 
00147             ++count;
00148             if (count<10) {
00149                 log << MSG::INFO << "Not saving SimHits, will say " << 10-count << " more times" << endreq;
00150             }
00151         }
00152         else {
00153             const SimHitHeader* header = tranobj.hits();
00154             if (!header) {
00155                 static int count = 0; 
00156                 if (count++ < 10) {
00157                     log << MSG::WARNING << "No Hit Header (I will say it " 
00158                         << 10 - count << " times again)" << endreq;
00159                 }
00160             }
00161             else {
00162                 const SimHitHeader::hc_map& colmap = header->hitCollection();
00163                 
00164                 log << MSG::DEBUG << "Saving " << colmap.size() << " hit collections" << endreq;
00165                 
00166                 SimHitHeader::hc_map::const_iterator it, done = colmap.end();
00167                 for (it = colmap.begin(); it != done; ++it) {
00168                     int detectorID = it->first;
00169                     static int nUnknownDet = 0;
00170                     if( detectorID == DetectorId::kUnknown ) {
00171                         nUnknownDet++;
00172                         if( nUnknownDet<10 ) {
00173                             log << MSG::WARNING << "No hit should be from unknown detector (I will say it "
00174                                 << 10 - nUnknownDet << " times again)" << endreq;
00175                         }
00176                     } 
00177                     else {
00178                         const SimHitCollection* hc = it->second;
00179                         PerSimHitCollection* phc = convert(trackMap,*hc);
00180                         phcolmap[detectorID] = phc;
00181                         DayaBay::Detector det((short)detectorID);
00182                         log << MSG::DEBUG << "Saving " << phc->hits.size() 
00183                             << " hits for detector " << det.detName()
00184                             << " ("
00185                             << detectorID 
00186                             << ")"
00187                             << endreq;
00188                     }
00189                 }
00190             }
00191         }
00192         log << MSG::DEBUG << "Saving " << phcolmap.size() << " hit collections" << endreq;
00193     }    
00194 
00195     { // Convert the stats part
00196         const SimUnobservableStatisticsHeader* stat = tranobj.unobservableStatistics();
00197         if (!stat) {
00198             log << MSG::DEBUG
00199                 << "No unobservable statistics" << endreq;
00200         }
00201         else {
00202             PerSimUnobservableStatistics* pstat = convert(*stat);
00203             delete perobj.stats;
00204             perobj.stats = pstat;
00205         }
00206     }
00207 
00208     return StatusCode::SUCCESS;
00209 }

StatusCode SimHeaderCnv::fillRepRefs ( IOpaqueAddress addr,
DataObject dobj 
) [virtual]

Reimplemented from RootIOTypedCnv< PerSimHeader, DayaBay::SimHeader >.

Definition at line 213 of file SimHeaderCnv.cc.

00214 {
00215     MsgStream log(msgSvc(), "SimHeaderCnv::fillRepRefs");
00216     SimHeader* sh = dynamic_cast<SimHeader*>(dobj);
00217 
00218     log << MSG::DEBUG
00219         << "Saving links to " << sh->inputHeaders().size() 
00220         << " input headers" << endreq;
00221 
00222     StatusCode sc = HeaderObjectCnv::fillPer(m_rioSvc,*sh,*m_perOutObj);
00223     if (sc.isFailure()) {
00224         log << MSG::ERROR << "Failed to fill HeaderObject part" << endreq;
00225         return sc;
00226     }
00227 
00228     // ... fill SimHeader part...
00229     return sc;
00230 }

StatusCode SimHeaderCnv::fillObjRefs ( IOpaqueAddress addr,
DataObject dobj 
) [virtual]

Reimplemented from RootIOTypedCnv< PerSimHeader, DayaBay::SimHeader >.

Definition at line 232 of file SimHeaderCnv.cc.

00233 {
00234     MsgStream log(msgSvc(), "SimHeaderCnv::fillObjRefs");
00235     HeaderObject* hobj = dynamic_cast<HeaderObject*>(dobj);
00236     StatusCode sc = HeaderObjectCnv::fillTran(m_rioSvc,*m_perInObj,*hobj);
00237     if (sc.isFailure()) {
00238         log << MSG::ERROR << "Failed to fill HeaderObject part" << endreq;
00239         return sc;
00240     }
00241 
00242     log << MSG::DEBUG
00243         << "Restored links to " << hobj->inputHeaders().size() 
00244         << " input headers" << endreq;
00245 
00246     // ... fill SimHeader part...
00247 
00248     DayaBay::SimHeader* sh = dynamic_cast<DayaBay::SimHeader*>(hobj);
00249     relate(*sh);
00250 
00251     return sc;
00252 }

DayaBay::SimParticleHistory* SimHeaderCnv::convert ( std::vector< DayaBay::SimTrack * > &  timap,
DayaBay::SimHeader sh,
const PerSimParticleHistory pph 
) [private]

PerSimParticleHistory * SimHeaderCnv::convert ( std::map< const DayaBay::SimTrack *, int > &  trackMap,
const DayaBay::SimParticleHistory ph 
) [private]

Definition at line 115 of file SimHeaderCnvHistory.cc.

00117 {
00118     MsgStream log(msgSvc(), "SimHeaderCnvHistory::convert(t2p)");
00119 
00120     PerSimParticleHistory* pph = new PerSimParticleHistory();
00121 
00122     typedef map<const SimVertex*,int> VertexMap_t;
00123     VertexMap_t vertexMap;
00124     vertexMap[0] = -1;//Hopefully trigger a SegV to catch bogus values
00125     { // Vertices
00126         const list<SimVertex*>& vertices = ph.vertices();
00127         log << MSG::VERBOSE 
00128             << "Adding " << vertices.size() << " vertices" << endreq;
00129         list<SimVertex*>::const_iterator it, done = vertices.end();
00130         for (it=vertices.begin(); it != done; ++it) {
00131             SimVertex* vertex = *it;
00132             PerSimVertex* pvertex = new PerSimVertex;
00133             pvertex->processType = vertex->process().type();
00134             pvertex->processName = vertex->process().name();
00135             pvertex->time = vertex->time();
00136             pvertex->energy = vertex->totalEnergy();
00137             pvertex->position = vertex->position();
00138             pvertex->momentum = vertex->momentum();
00139 
00140             vertexMap[vertex] = pph->vertices.size();
00141             log << MSG::VERBOSE 
00142                 << "Adding vertex from track " << vertex->track().track()->trackId()
00143                 << " @ " << (void*) vertex << endreq;
00144             pph->vertices.push_back(pvertex);
00145         }
00146     }
00147 
00148     trackMap[0] = -1;//Hopefully trigger a SegV to catch any bogus values
00149     { // Tracks
00150         const list<SimTrack*>& tracks = ph.tracks();
00151         list<SimTrack*>::const_iterator it, done = tracks.end();
00152         for (it=tracks.begin(); it != done; ++it) {
00153             SimTrack* track = *it;
00154             PerSimTrack* ptrack = new PerSimTrack;
00155             ptrack->geantID = track->trackId();
00156             ptrack->parentPDG = track->parentParticle();
00157             ptrack->particlePDG = track->particle();
00158             for (size_t ind=0; ind<track->vertices().size(); ++ind) {
00159                 VertexMap_t::iterator vit = vertexMap.find(track->vertices()[ind]);
00160                 if (vit == vertexMap.end()) {
00161                     log << MSG::ERROR
00162                         << "Track references unknown vertex #" << ind << endreq;
00163                     continue;
00164                 }
00165                 ptrack->vertexIndex.push_back(vit->second);
00166             }
00167 
00168             const SimVertexReference& ancestorVertex = track->ancestorVertex();
00169             if (ancestorVertex.vertex()) {
00170                 VertexMap_t::iterator vit = vertexMap.find(ancestorVertex.vertex());
00171                 if (vit == vertexMap.end()) {
00172                     log << MSG::ERROR
00173                         << "Track's ancestor vertex is not found, is from track ID "
00174                         << ancestorVertex.vertex()->track().track()->trackId() 
00175                         << " and @ " << (void*) ancestorVertex.vertex()
00176                         << endreq;
00177                     // Historian uses non-default values for NULL
00178                     // SimVertexReferences so pass them along.
00179                     ptrack->ancestorVertex.count = ancestorVertex.indirection();
00180                 }
00181                 else {
00182                     ptrack->ancestorVertex = PerSimIndirection(vit->second,
00183                                                                ancestorVertex.indirection());
00184                 }
00185             }
00186             else ptrack->ancestorVertex.count = ancestorVertex.indirection();
00187 
00188             // Rely on map<>'s default assignment
00189             ptrack->unrecordedDescendants = track->unrecordedDescendants();
00190 
00191             ptrack->primaryParticle = -1;
00192             if (track->primaryParticle()) {
00193                 ptrack->primaryParticle = track->primaryParticle()->barcode();
00194             }
00195 
00196             trackMap[track] = pph->tracks.size();
00197             pph->tracks.push_back(ptrack);
00198         }
00199     }
00200 
00201     { // Fix up Vertices
00202         const list<SimVertex*>& vertices = ph.vertices();
00203         list<SimVertex*>::const_iterator it, done = vertices.end();
00204         for (it=vertices.begin(); it != done; ++it) {
00205             SimVertex* vertex = *it;
00206             PerSimVertex* pvertex = pph->vertices[vertexMap[vertex]];
00207 
00208             // Fill from SimTrackReference "track"
00209             if (vertex->track().track()) {
00210                 int index = trackMap[vertex->track().track()];
00211                 int count = vertex->track().indirection();
00212                 pvertex->track = PerSimIndirection(index,count);
00213             }
00214             
00215             // Fill from SimTrackReferences "secondaries"
00216             const vector<SimTrackReference>& secondaries = vertex->secondaries();
00217             for (size_t ind=0; ind < secondaries.size(); ++ind) {
00218                 if (!secondaries[ind].track()) continue;
00219                 int index = trackMap[secondaries[ind].track()];
00220                 int count = secondaries[ind].indirection();
00221                 pvertex->secondaryTracks.push_back(PerSimIndirection(index,count));
00222             }
00223         }
00224     }
00225 
00226     { // Fill primary track indices
00227         const std::list<const SimTrack*>& primaries = ph.primaryTracks();
00228         std::list<const SimTrack*>::const_iterator it, done = primaries.end();
00229         for (it = primaries.begin(); it != done; ++it) {
00230             const SimTrack* track = *it;
00231             if (!track) continue;
00232             pph->primaryTrackIndex.push_back(trackMap[track]);
00233         }
00234     }
00235 
00236     { // Fix up missing track->ancestorTrack references
00237         const list<SimTrack*>& tracks = ph.tracks();
00238         list<SimTrack*>::const_iterator it, done = tracks.end();
00239         for (it=tracks.begin(); it != done; ++it) {
00240             SimTrack* track = *it;
00241             PerSimTrack* ptrack = pph->tracks[trackMap[track]];
00242 
00243             int count = track->ancestorTrack().indirection();
00244             const SimTrack* ancestorTrack = track->ancestorTrack().track();
00245             if (!ancestorTrack) {
00246                 ptrack->ancestorTrack.count = count;
00247             }
00248             else {
00249                 ptrack->ancestorTrack = PerSimIndirection(trackMap[ancestorTrack],count);
00250             }
00251         }
00252     }
00253 
00254     // Note: DO NOT fill idToTrack lookup.  It is an internal lookup
00255     // that will be refilled based on the the geantID stored in each
00256     // track....
00257 
00258     return pph;
00259 }

DayaBay::SimHitCollection* SimHeaderCnv::convert ( std::vector< DayaBay::SimTrack * > &  timap,
const PerSimHitCollection phc 
) [private]

PerSimHitCollection * SimHeaderCnv::convert ( std::map< const DayaBay::SimTrack *, int > &  trackMap,
const DayaBay::SimHitCollection hc 
) [private]

Definition at line 82 of file SimHeaderCnvHits.cc.

00084 {
00085     MsgStream log(msgSvc(), "SimHeaderCnvHits::convert(t2p)");
00086 
00087     const SimHitCollection::hit_container &hits = hc.collection();
00088 
00089     PerSimHitCollection* phc = new PerSimHitCollection;
00090     phc->detId = hc.detector().siteDetPackedData();
00091 
00092     size_t nhits = hits.size();
00093 
00094     if (!nhits) return phc; // empty
00095 
00096     bool is_pmt = (0 != dynamic_cast<const SimPmtHit*>(hits[0]));
00097 
00098     PerSimHitCollection::phit_container& phits = phc->hits;
00099 
00100     // First create the output hit of specific type and fill specific data
00101     if (is_pmt) {
00102         for (size_t ihit=0; ihit < nhits; ++ihit) {
00103             const SimPmtHit *hit = dynamic_cast<const SimPmtHit*>(hits[ihit]);
00104             PerSimPmtHit* pmt_hit = new PerSimPmtHit(hit->dir(),
00105                                                      hit->pol(),
00106                                                      hit->wavelength(),
00107                                                      hit->type());
00108             phits.push_back(pmt_hit);
00109         }
00110     }
00111     else {
00112         for (size_t ihit=0; ihit < nhits; ++ihit) {
00113             const SimRpcHit *hit = dynamic_cast<const SimRpcHit*>(hits[ihit]);
00114             PerSimRpcHit* rpc_hit = new PerSimRpcHit(hit->energyDep());
00115             phits.push_back(rpc_hit);
00116         }
00117     }
00118 
00119     // Now copy the common part
00120     int nfailed = 0;
00121     for (size_t ihit=0; ihit < nhits; ++ihit) {
00122         const SimHit *hit = hits[ihit];
00123         PerSimHit *phit = phits[ihit];
00124         phit->sensDetId = hit->sensDetId();
00125         phit->time = hit->hitTime();
00126         phit->pos = hit->localPos();
00127         phit->weight = hit->weight();
00128 
00129         const SimTrack* ancestor = hit->ancestor().track();
00130         if (!ancestor) {
00131             ++nfailed;
00132             continue;
00133         }
00134 
00135         map<const SimTrack*,int>::const_iterator ait = trackMap.find(ancestor);
00136         if (ait == trackMap.end()) {
00137             log << MSG::ERROR
00138                 << "No ancestor track index found for #" 
00139                 << ancestor->trackId()
00140                 << endreq;
00141             continue;
00142         }
00143         int count = hit->ancestor().indirection();
00144         phit->ancestor = PerSimIndirection(ait->second,count);
00145     }
00146     if (nfailed) {
00147         log << MSG::DEBUG
00148             << "Failed to find ancestor for hit " << nfailed << " times"  << endreq;
00149     }
00150         
00151     return phc;
00152 }

DayaBay::SimUnobservableStatisticsHeader * SimHeaderCnv::convert ( const PerSimUnobservableStatistics pstat  )  [private]

Definition at line 13 of file SimHeaderCnvStats.cc.

00014 {
00015     SimUnobservableStatisticsHeader* stat = new SimUnobservableStatisticsHeader;
00016     SimUnobservableStatisticsHeader::stat_map& stats = stat->stats();
00017 
00018     std::map<string,PerSimStat>::const_iterator it, done = pstat.stats.end();
00019     for (it = pstat.stats.begin(); it != done; ++it) {
00020         SimStatistic ss;
00021         ss.setCount(it->second.count);
00022         ss.setSum(it->second.sum);
00023         ss.setSquaredsum(it->second.squaredsum);
00024         stats[it->first] = ss;
00025     }
00026 
00027     return stat;
00028 }

PerSimUnobservableStatistics * SimHeaderCnv::convert ( const DayaBay::SimUnobservableStatisticsHeader stat  )  [private]

Definition at line 31 of file SimHeaderCnvStats.cc.

00032 {
00033     PerSimUnobservableStatistics* pstat = new PerSimUnobservableStatistics;
00034     std::map<std::string,PerSimStat>& pstats = pstat->stats;
00035     
00036     const SimUnobservableStatisticsHeader::stat_map& stats = stat.stats();
00037     SimUnobservableStatisticsHeader::stat_map::const_iterator it, done = stats.end();
00038     for (it = stats.begin(); it != done; ++it) {
00039         pstats[it->first] = 
00040             PerSimStat(it->second.count(),it->second.sum(),it->second.squaredsum());
00041     }
00042     return pstat;
00043 }

void SimHeaderCnv::relate ( DayaBay::SimHeader sh  )  [private]

Definition at line 261 of file SimHeaderCnvHistory.cc.

00262 {
00263     MsgStream log(msgSvc(), "SimHeaderCnvHistory::relate(p2t)");
00264     const HepMC::GenEvent* genEvent = 0;
00265     const std::vector<const DayaBay::IHeader*>& inputHeaders = sh.inputHeaders();
00266     log << MSG::DEBUG 
00267         << "Checking for GenHeader in " 
00268         << inputHeaders.size() << " input headers" 
00269         << endreq;
00270     for (size_t ind=0; ind<inputHeaders.size(); ++ind) {
00271         const GenHeader* genHeader = dynamic_cast<const GenHeader*>(inputHeaders[ind]);
00272         if (1) {
00273             const HeaderObject* ho = dynamic_cast<const HeaderObject*>(inputHeaders[ind]);
00274             log << MSG::DEBUG
00275                 << "checking " << ind << "/" << inputHeaders.size() 
00276                 << ": " << ho->name()
00277                 << endreq;
00278         }
00279         if (!genHeader) continue;
00280         genEvent = genHeader->event();
00281     }
00282     if (!genEvent) {
00283         log << MSG::DEBUG
00284             << "Could not find the HepMC::GenEvent used to create me." 
00285             << endreq;
00286         return;
00287     }
00288     
00289 
00290     if (!m_perInObj->history) {
00291         log << MSG::DEBUG
00292             << "No persistent particle history"
00293             << endreq;
00294         return;
00295     }
00296     const PerSimParticleHistory& pph = *(m_perInObj->history);
00297     if (!sh.particleHistory()) {
00298         log << MSG::ERROR
00299             << "No transient particle history"
00300             << endreq;
00301         return;
00302     }
00303 
00304     // Sometimes the genEvent barcodes for particles and vertices has been pruned
00305     // in the production of the original file. Report this here and
00306     // suppress issuing an ERROR for every particle that does not have a barcodes.
00307     bool empty = genEvent->particles_empty() && genEvent->vertices_empty() ;
00308     if (empty) log << MSG::INFO << "No GenEvent particles or vertices exist"<< endreq;
00309 
00310 
00311     const list<SimTrack*>& tracks = sh.particleHistory()->tracks();
00312     list<SimTrack*>::const_iterator it, done = tracks.end();
00313     size_t ind=0;
00314     for (it=tracks.begin(); it !=done && ind < pph.tracks.size(); ++ind, ++it) {
00315         PerSimTrack* ptrack = pph.tracks[ind];
00316         SimTrack* track = *it;
00317 
00318         if (genEvent) {
00319             int barcode = ptrack->primaryParticle;
00320 
00321             if (barcode < 0) {
00322                 track->setPrimaryParticle(0);
00323             }
00324             else {
00325                 const HepMC::GenParticle* part = genEvent->barcode_to_particle(barcode);
00326                 if (part) {
00327                     track->setPrimaryParticle(part);
00328                 }
00329                 else {
00330                   if (!empty){
00331                     log << MSG::ERROR
00332                         << "Failed to get a primary particle for barcode " << barcode << endreq;
00333                   }
00334                 }
00335             }
00336         }
00337     }
00338 }

PerSimHeader & RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::getPerInputObject (  )  [inherited]

PerSimHeader & RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::getPerOutputObject (  )  [inherited]

const RootIOBaseObject * RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::getBaseInputObject (  )  [virtual, inherited]

Implements RootIOBaseCnv.

const RootIOBaseObject * RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::getBaseOutputObject (  )  [virtual, inherited]

Implements RootIOBaseCnv.

virtual StatusCode RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::TranObjectToPerObject ( DataObject dat,
const RootOutputAddress  
) [virtual, inherited]

Implements RootIOBaseCnv.

virtual StatusCode RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::PerObjectToTranObject ( DataObject *&  dat  )  [virtual, inherited]

Implements RootIOBaseCnv.

virtual RootInputStream * RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::makeInputStream ( const RootInputAddress ria  )  [virtual, inherited]

Implements RootIOBaseCnv.

virtual RootOutputStream * RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::makeOutputStream ( const RootOutputAddress ria  )  [virtual, inherited]

Implements RootIOBaseCnv.

virtual long RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::repSvcType (  )  const [virtual, inherited]

Reimplemented from RootIOBaseCnv.

virtual StatusCode RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::initialize (  )  [virtual, inherited]

Reimplemented from RootIOBaseCnv.

virtual StatusCode RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::finalize (  )  [virtual, inherited]

Reimplemented from RootIOBaseCnv.

virtual StatusCode RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::createObj ( IOpaqueAddress addr,
DataObject *&  dat 
) [virtual, inherited]

Reimplemented from RootIOBaseCnv.

virtual StatusCode RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::createRep ( DataObject pObject,
IOpaqueAddress *&  refpAddress 
) [virtual, inherited]

Reimplemented from RootIOBaseCnv.

int RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::commit ( const RootOutputAddress roa  )  [inherited]

Reimplemented from RootIOBaseCnv.

RootIOBaseCnv * RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::otherConverter ( int  clID  )  [inherited]

Reimplemented from RootIOBaseCnv.

virtual StatusCode RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::queryInterface ( const InterfaceID riid,
void **  ppvInterface 
) [virtual, inherited]

Reimplemented from RootIOBaseCnv.

virtual unsigned long RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::addRef (  )  [virtual, inherited]

Reimplemented from RootIOBaseCnv.

virtual unsigned long RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::release (  )  [virtual, inherited]

Reimplemented from RootIOBaseCnv.

virtual StatusCode RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::setDataProvider ( IDataProviderSvc svc  )  [virtual, inherited]

Reimplemented from RootIOBaseCnv.

virtual IDataProviderSvc * RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::dataProvider (  )  const [virtual, inherited]

Reimplemented from RootIOBaseCnv.

virtual StatusCode RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::setConversionSvc ( IConversionSvc svc  )  [virtual, inherited]

Reimplemented from RootIOBaseCnv.

virtual IConversionSvc * RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::conversionSvc (  )  const [virtual, inherited]

Reimplemented from RootIOBaseCnv.

virtual StatusCode RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::setAddressCreator ( IAddressCreator creator  )  [virtual, inherited]

Reimplemented from RootIOBaseCnv.

virtual IAddressCreator * RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::addressCreator (  )  const [virtual, inherited]

Reimplemented from RootIOBaseCnv.

virtual const CLID & RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::objType (  )  const [virtual, inherited]

Reimplemented from RootIOBaseCnv.

virtual long RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::i_repSvcType (  )  const [virtual, inherited]

Reimplemented from RootIOBaseCnv.

virtual StatusCode RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::updateObj ( IOpaqueAddress pAddress,
DataObject refpObject 
) [virtual, inherited]

Reimplemented from RootIOBaseCnv.

virtual StatusCode RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::updateObjRefs ( IOpaqueAddress pAddress,
DataObject pObject 
) [virtual, inherited]

Reimplemented from RootIOBaseCnv.

virtual StatusCode RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::updateRep ( IOpaqueAddress pAddress,
DataObject pObject 
) [virtual, inherited]

Reimplemented from RootIOBaseCnv.

virtual StatusCode RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::updateRepRefs ( IOpaqueAddress pAddress,
DataObject pObject 
) [virtual, inherited]

Reimplemented from RootIOBaseCnv.

StatusCode RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::service ( const std::string &  name,
T *&  psvc,
bool  createIf = false 
) const [inherited]

Reimplemented from RootIOBaseCnv.

StatusCode RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::service ( const std::string &  type,
const std::string &  name,
T *&  psvc 
) const [inherited]

Reimplemented from RootIOBaseCnv.

static unsigned char RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::storageType (  )  [static, inherited]

Reimplemented from RootIOBaseCnv.

static const InterfaceID & RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::interfaceID (  )  [static, inherited]

Reimplemented from RootIOBaseCnv.

static const InterfaceID & RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::interfaceID (  )  [static, inherited]

Reimplemented from RootIOBaseCnv.

ISvcLocator * RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::serviceLocator (  )  const [protected, inherited]

Reimplemented from RootIOBaseCnv.

IMessageSvc * RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::msgSvc (  )  const [protected, inherited]

Reimplemented from RootIOBaseCnv.

IMessageSvc * RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::messageService (  )  const [protected, inherited]

Reimplemented from RootIOBaseCnv.

IDataManagerSvc * RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::dataManager (  )  const [protected, inherited]

Reimplemented from RootIOBaseCnv.


Member Data Documentation

int SimHeaderCnv::m_maxNoPHtoS [private]

Definition at line 80 of file SimHeaderCnv.h.

int SimHeaderCnv::m_NoPHtoSmsgs [private]

Definition at line 80 of file SimHeaderCnv.h.

bool SimHeaderCnv::m_pruneSimHits [private]

Definition at line 83 of file SimHeaderCnv.h.

RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::INVALID_ADDRESS [inherited]

Reimplemented from RootIOBaseCnv.

RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::INVALID_OBJECT [inherited]

Reimplemented from RootIOBaseCnv.

RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::NO_MEMORY [inherited]

Reimplemented from RootIOBaseCnv.

RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::BAD_STORAGE_TYPE [inherited]

Reimplemented from RootIOBaseCnv.

RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::NO_SOURCE_OBJECT [inherited]

Reimplemented from RootIOBaseCnv.

RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::ICONVERSIONSVC_LAST_ERROR [inherited]

Reimplemented from RootIOBaseCnv.

std::string RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::m_perclassName [protected, inherited]

PerSimHeader * RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::m_perInObj [protected, inherited]

PerSimHeader * RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::m_perOutObj [protected, inherited]

IRootIOSvc * RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::m_rioSvc [protected, inherited]

Reimplemented from RootIOBaseCnv.

IConversionSvc * RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::m_cnvSvc [protected, inherited]

Reimplemented from RootIOBaseCnv.

RootInputStream * RootIOTypedCnv< PerSimHeader , DayaBay::SimHeader >::m_ris [protected, inherited]

Reimplemented from RootIOBaseCnv.


The documentation for this class was generated from the following files:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:35:46 2011 for PerSimEvent by doxygen 1.4.7