Print

Print


Commit in slicPandora/src on MAIN
SimCalorimeterHitProcessor.cpp+1-11.20 -> 1.21
SimpleTrackProcessor.cpp+70-11.14 -> 1.15
+71-2
2 modified files
add linking of MC particle information to tracks

slicPandora/src
SimCalorimeterHitProcessor.cpp 1.20 -> 1.21
diff -u -r1.20 -r1.21
--- SimCalorimeterHitProcessor.cpp	24 Sep 2010 07:22:50 -0000	1.20
+++ SimCalorimeterHitProcessor.cpp	6 Oct 2010 12:48:26 -0000	1.21
@@ -39,7 +39,7 @@
     //std::cout << "SimCalorimeterHitProcessor::processEvent" << std::endl;
 
     JobManager* mgr = getJobManager();
-    const pandora::Pandora& pandora = getJobManager()->getPandora();
+    const pandora::Pandora& pandora = mgr->getPandora();
 
     // Get the job's DetectorGeometry from the JobManager.
     DetectorGeometry* geom = mgr->getDetectorGeometry();

slicPandora/src
SimpleTrackProcessor.cpp 1.14 -> 1.15
diff -u -r1.14 -r1.15
--- SimpleTrackProcessor.cpp	1 Oct 2010 15:52:16 -0000	1.14
+++ SimpleTrackProcessor.cpp	6 Oct 2010 12:48:26 -0000	1.15
@@ -8,11 +8,15 @@
 #include "EVENT/Track.h"
 #include "EVENT/LCGenericObject.h"
 #include "EVENT/LCObject.h"
+#include "EVENT/MCParticle.h"
 #include "UTIL/LCRelationNavigator.h"
 
 // pandora
 #include "Objects/CartesianVector.h"
 #include "Api/PandoraApi.h"
+#include "Objects/Helix.h"
+#include "Objects/MCParticle.h"
+#include "Helpers/GeometryHelper.h"
 
 // stl
 #include <string>
@@ -105,7 +109,72 @@
 #endif       
 
         // Register object with Pandora.
-        PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::Track::Create(getJobManager()->getPandora(), trackParameters));
+        const pandora::Pandora& pandora = getJobManager()->getPandora();
+        PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::Track::Create(pandora, trackParameters));
+
+
+        pandora::GeometryHelper *pGeometryHelper = pandora::GeometryHelper::GetInstance();
+        const float magneticField(pGeometryHelper->GetBField());
+
+
+        // --- add MC information 
+        const EVENT::LCCollection *pMCRelationCollection = event->getCollection("HelicalTrackMCRelations");
+        UTIL::LCRelationNavigator navigate(pMCRelationCollection);
+
+
+        EVENT::TrackerHitVec trackHits = track->getTrackerHits();
+
+        try
+        {
+            EVENT::MCParticle *pBestMCParticle = NULL;
+            for (EVENT::TrackerHitVec::const_iterator itTh = trackHits.begin(), itThEnd = trackHits.end(); itTh != itThEnd; ++itTh )
+            {
+                EVENT::TrackerHit* trackerHit = (*itTh);
+                const EVENT::LCObjectVec &objectVec = navigate.getRelatedToObjects(trackerHit);
+
+                // Get reconstructed momentum at dca
+                const pandora::Helix helixFit(track->getPhi(), track->getD0(), track->getZ0(), track->getOmega(), track->getTanLambda(), magneticField);
+                const float recoMomentum(helixFit.GetMomentum().GetMagnitude());
+
+                // Use momentum magnitude to identify best mc particle
+                float bestDeltaMomentum(std::numeric_limits<float>::max());
+
+                for (EVENT::LCObjectVec::const_iterator itRel = objectVec.begin(), itRelEnd = objectVec.end(); itRel != itRelEnd; ++itRel)
+                {
+                    EVENT::MCParticle *pMCParticle = NULL;
+                    pMCParticle = dynamic_cast<EVENT::MCParticle *>(*itRel);
+
+                    if (NULL == pMCParticle)
+                        continue;
+
+                    const float trueMomentum(pandora::CartesianVector(pMCParticle->getMomentum()[0], pMCParticle->getMomentum()[1],
+                                                                      pMCParticle->getMomentum()[2]).GetMagnitude());
+
+                    const float deltaMomentum(std::fabs(recoMomentum - trueMomentum));
+
+                    if (deltaMomentum < bestDeltaMomentum)
+                    {
+                        pBestMCParticle = pMCParticle;
+                        bestDeltaMomentum = deltaMomentum;
+                    }
+                }
+            }
+
+            if (NULL == pBestMCParticle)
+                continue;
+
+            PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::SetTrackToMCParticleRelationship(pandora, track,
+                                                                                                          pBestMCParticle));
+        
+        }
+        catch (StatusCodeException &statusCodeException)
+        {
+            std::cout << "Failed to extract track to mc particle relationship: " << statusCodeException.ToString() << std::endl;
+        }
+        catch (EVENT::Exception &exception)
+        {
+            std::cout << "Failed to extract track to mc particle relationship: " << exception.what() << std::endl;
+        }
     }
 }
 
CVSspam 0.2.8