Linear Collider Forum



Home » Software Tools » LCIO » Seg Fault when adding collections
Seg Fault when adding collections [message #2206] Wed, 15 February 2012 04:29 Go to previous message
tonyprice1877
Messages: 16
Registered: September 2010
Location: Birmingham
Hi All,

I hope somebody can help me I am fairly new to the iLCSoft/LCIO stuff. I am trying to figure out how to add Collections to an .slcio file and I keep getting a seg fault for some reason! I have stripped my code back to filling a ReconstructedParticleVec with all the ReconstructedParticles and then trying to write them back as a new collection the code is simply as follows

void MyTestJetFinderProcessor::processEvent( LCEvent * evt ) { 


  // this gets called for every event 
  // usually the working horse ...
	
	/////////////////////////////////////////////
	//////// Look at the PandoraPFO /////////////
	/////////////////////////////////////////////
	
	//get the rteconstructed particles collection
  LCCollection* col_rp = evt->getCollection( _colName_ReconstructedParticle ) ;
 	if( col_rp != 0 )
 	{ 	
 		_vParticles.clear();
 		_vJets.clear();
 		
  	int n = col_rp->getNumberOfElements();
		
		//loop through and get the particles
		for(int i=0; i<n; i++) 
		{
				ReconstructedParticle* rp = dynamic_cast<ReconstructedParticle*>( col_rp->getElementAt(i) );
				//std::cout << rp->getParticles().size() << std::endl;
				_vParticles.push_back(rp);
		}
		
		IMPL::LCCollectionVec* lccParticlesOut = new IMPL::LCCollectionVec(LCIO::RECONSTRUCTEDPARTICLE);
		for(unsigned i=0; i<_vParticles.size(); i++) lccParticlesOut->addElement( _vParticles[i] );
		evt->addCollection(lccParticlesOut, _lcJetOutName);
       } // end of if( col_rp != 0 )	
	std::cout << "Event " << _nEvt << " analysed" << std::endl;
	
	//incriment the event counter
    _nEvt ++ ;
  
}


if I remove the line

 lccParticlesOut->addElement( _vParticles[i] ); 


then there is no seg fault. Can anybody see what I am doing wrong?

Tony
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic:LCIO Wiki
Next Topic:Request: addition of "quality" word to TrackerData
Goto Forum:
  


Current Time: Wed Aug 15 17:17:26 Pacific Daylight Time 2018
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.1.
Copyright ©2001-2010 FUDforum Bulletin Board Software