Linear Collider Forum



Home » Analysis and Reconstruction » Reconstruction » MC association
Re: MC association [message #477 is a reply to message #476] Fri, 19 May 2006 07:07 Go to previous messageGo to previous message
gaede
Messages: 233
Registered: January 2004
Location: DESY, Hamburg
Hi Fabio,


I don't know which program has created the LCIO file that you are analyzing - however if it is writing 'proper' LCIO your code should fail where you try to cast a raw hit to a SimCalorimeterHit:

 
LCObject* CSimhit = (*ch)->getRawHit();
SimCalorimeterHit* CRawHit = dynamic_cast<SimCalorimeterHit*>(CSimhit) ;

This is only by convention - of course technically one could create CalorimeterHit objects where the pointer to a raw hit is
in facta SimCalorimeterHit (clearly not a raw hit...).

The basic idea is that there is no direct link between MC Truth objects (MCParticle, SimCalorimeterHit, SimTrackerHit) and the higher level objects, such as Cluster, CalorimeterHit etc. but that rather LCRelation is used between the MC Truth hits (SimCalorimeterHit ) and the data hits ( CalorimeterHit ).

The following is a code snippet from the cluster cheater in MarlinReco (where the digitizer module has created the LCRelation collection beforehand):

 relcol = evt->getCollection("RelationCaloHit");

 LCRelationNavigator navigate(relcol); 

for (unsigned int j=0; j < col->getNumberOfElements(); ++j) 
{
  CalorimeterHit * calhit = dynamic_cast<CalorimeterHit*>(col->getElementAt(j));
  
  const LCObjectVec& objectVec = navigate.getRelatedToObjects(calhit);
  
  if (objectVec.size() > 0) {
    
    SimCalorimeterHit * simhit=dynamic_cast<SimCalorimeterHit*>( objectVec[0] );


    // use simhit ...

  }
}


I hope this helps.

Cheers, Frank.


PS: Guilherme, I don't think your suggestion can work since dynamic_cast<SimCaloHit*> will allways be 0 for anything that is not a SimCaloHit such as CaloHit...


 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic:Problem with Marlin 0.9.4
Next Topic:org.lcsim Tracking Examples
Goto Forum:
  


Current Time: Wed Oct 17 07:04:20 Pacific Daylight Time 2018
.:: Contact :: Home ::.

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