10 using namespace lcio ;
 
   56   LCReader* 
lcReader = LCFactory::getInstance()->createLCReader() ;
 
   58   lcReader->open( 
"recjob.slcio" ) ;
 
   65   while( (evt = lcReader->readNextEvent()) != 0 && nEvents < 1 ) {
 
   68     LCCollection* mcpcol = evt->getCollection(
"MCParticle" ) ;
 
   70     int nmcp = mcpcol->getNumberOfElements() ;
 
   72     for(
int i=0 ; i< nmcp  ; i++ ){
 
   74       MCParticle*  mcp = 
dynamic_cast<MCParticle*
>( mcpcol->getElementAt(i) ) ;
 
   79       mcp->ext<
Index>() = i ;   
 
   81       mcp->ext<
Mass>() = mcp->getMass() ;
 
  104       else if( ! ((i+1) % 3) )
 
  108       else if( ! ((i+2) % 3) )
 
  117       for(
unsigned j=0 ; j< daughters.size()   ; j++ ){
 
  119     add_relation<ParentDaughter>( mcp, daughters[j] ) ;
 
  126     LCCollection* trkcol = evt->getCollection(
"SomeTracks" ) ;
 
  127     LCCollection* clucol = evt->getCollection(
"SomeClusters" ) ;
 
  129     if( trkcol && clucol ) {
 
  131       int nclu = clucol->getNumberOfElements() ;
 
  132       int ntrk = trkcol->getNumberOfElements() ;
 
  135       for(
int j=0 ; j< ntrk  ; j++ ){
 
  137     Track*   trk = 
dynamic_cast<Track*
>   ( trkcol->getElementAt(j) ) ;
 
  141     trk->ext<
Index>() = j ;   
 
  143     for(
int k=0 ; k< nclu ; k++ ){
 
  145       Cluster* clu = 
dynamic_cast<Cluster*
> ( clucol->getElementAt(k) ) ;
 
  149         clu->ext<
Index>() = k ;
 
  151       if( j % 2  && ( k == j || k == j-1 ) )  
 
  153         add_relation<TrkCluLink>( trk ,clu );
 
  161       for(
int j=0 ; j< ntrk ; j++ ){
 
  164     Track*   trk = 
dynamic_cast<Track*
>   ( trkcol->getElementAt(j) ) ;
 
  166     std::cout << 
" track " << trk->ext<
Index>()  << 
" assigned to clusters :   " ; 
 
  168     TrkCluLink::to::rel_type clulist =  trk->rel<TrkCluLink::to>() ;
 
  170     for( TrkCluLink::to::const_iterator iclu = clulist->begin() ;
 
  171          iclu != clulist->end() ; ++iclu ){
 
  182       for(
int k=0 ; k< nclu ; k++ ){
 
  184     Cluster* clu = 
dynamic_cast<Cluster*
> ( clucol->getElementAt(k) ) ;
 
  187     Track* trk =  clu->rel<TrkCluLink::from>() ;
 
  190           << clu->ext<
Index>() << 
" assigned from track:   " ;
 
  204       nmcp = ( nmcp < 10 ? nmcp : 10 ) ;
 
  206       MCParticle*  mcp0 = 0 ;   
 
  208       for(
int i=0 ; i<nmcp  ; i++ ){
 
  210     MCParticle*  mcp = 
dynamic_cast<MCParticle*
>( mcpcol->getElementAt(i) ) ;
 
  212     if( i == 0 ) mcp0 = mcp  ;
 
  214     ParticleIDs::ext_type pidv =  mcp->ext<
ParticleIDs>() ;
 
  216     std::cout <<  
"   --- particle " << mcp->ext<
Index>()  << 
" found to be : " ;  
 
  218     for( ParticleIDs::const_iterator ipid = pidv->begin() ; ipid != pidv->end(); ++ipid){
 
  223     if( ( *(*pidv)[0] == 
"charged" && *(*pidv)[1] == 
"photon"  ) ||
 
  224         ( *(*pidv)[0] == 
"neutral" && *(*pidv)[1] == 
"electron")   )
 
  232     std::cout <<  
"   --- particle " << mcp->ext<
Index>()   <<  
" user extension : "  
  242     std::cout <<  
"   --- particle " << mcp->ext<
Index>()   <<  
" daughters: "  
  247     for(MCParticleVec::const_iterator idau = daughters.begin() ; 
 
  248         idau != daughters.end() ; ++idau){
 
  250       std::cout << (*idau)->ext<
Index>() << 
", " ; 
 
  255     std::cout <<  
"      --- from runtime rel: " ; 
 
  258     ParentDaughter::to::rel_type daulist =  mcp->rel<ParentDaughter::to>() ;
 
  260     for( ParentDaughter::to::const_iterator idau = daulist->begin(); 
 
  261          idau != daulist->end(); ++idau){
 
  263       std::cout << (*idau)->ext<
Index>() << 
", " ;
 
  268     std::cout <<  
"   --- particle " << mcp->ext<
Index>()   <<  
" parents: "  
  271     std::cout <<  
"      --- from MCParticle:  " ; 
 
  276     for(MCParticleVec::const_iterator ipar = parents.begin() ; 
 
  277         ipar != parents.end() ; ++ipar){
 
  279       std::cout << (*ipar)->ext<
Index>() << 
", " ; 
 
  284     std::cout <<  
"      --- from runtime rel: " ; 
 
  287     ParentDaughter::from::rel_type parlist =  mcp->rel<ParentDaughter::from>() ;
 
  289     for( ParentDaughter::from::const_iterator ipar = parlist->begin(); 
 
  290          ipar != parlist->end(); ++ipar){
 
  292       std::cout << (*ipar)->ext<
Index>() << 
", " ;
 
  300       merge_relations<ParentDaughter>( mcp0 , mcp ) ;
 
  304       for(
int i=0 ; i<nmcp  ; i++ ){
 
  306     MCParticle*  mcp = 
dynamic_cast<MCParticle*
>( mcpcol->getElementAt(i) ) ;
 
  308     std::cout <<  
"   --- particle " << mcp->ext<
Index>()  << 
" ( mass: " << mcp->ext<
Mass>() << 
") " 
  309           <<  
" daughters after merging : " ;
 
  312     ParentDaughter::to::rel_type daulist =  mcp->rel<ParentDaughter::to>() ;
 
  314     for( ParentDaughter::to::const_iterator idau = daulist->begin(); 
 
  315          idau != daulist->end(); ++idau){
 
std::vector< MCParticle * > MCParticleVec
Vector of (pointers to) MCParticles. 
 
int main(int argc, char **argv)
Simple program that opens existing LCIO files and appends the records needed for direct access - if t...