2 added + 5 modified, total 7 files
slicPandora/include
diff -N MCParticleProcessor.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ MCParticleProcessor.h 24 Sep 2010 07:22:50 -0000 1.1
@@ -0,0 +1,70 @@
+#ifndef MCPARTICLEPROCESSOR_H
+#define MCPARTICLEPROCESSOR_H 1
+
+// pandora
+#include "Api/PandoraApi.h"
+
+// slicPandora
+#include "EventProcessor.h"
+#include "DetectorGeometry.h"
+
+// lcio
+#include "EVENT/MCParticle.h"
+
+using EVENT::MCParticle;
+
+/**
+ * This is an event processor that converts collections of MCParticles
+ * to Pandora MCParticle::Parameters and registers them with the current
+ * Pandora instance.
+ */
+class MCParticleProcessor : public EventProcessor
+{
+public:
+
+ /**
+ * Standard ctor.
+ */
+ MCParticleProcessor()
+ : EventProcessor("MCParticleProcessor")
+ {;}
+
+ /**
+ * Standard dtor.
+ */
+ virtual ~MCParticleProcessor()
+ {;}
+
+public:
+
+ /**
+ * This method converts LCIO MCParticles into Pandora CalHit::Parameters.
+ */
+ void processEvent(EVENT::LCEvent*);
+
+private:
+
+/* /\** */
+/* * Make a 64-bit ID from the two 32-bit cell IDs of a MCParticle. */
+/* *\/ */
+/* inline long long makeId64(MCParticle* hit) const */
+/* { */
+/* return ((long long)hit->getCellID1())<<32 | hit->getCellID0(); */
+/* } */
+
+ /**
+ * Convert an LCIO MCParticle into a PandoraPFANew MCParticle Parameters.
+ */
+ PandoraApi::MCParticle::Parameters makeMCParticleParameters(MCParticle*);
+
+ /**
+ * Print the given MCParticle::Parameters to cout.
+ */
+ void printMCParticleParameters(const PandoraApi::MCParticle::Parameters&);
+
+private:
+ static std::string mcParticleCollectionName;
+
+};
+
+#endif
slicPandora/include
diff -u -r1.3 -r1.4
--- DefaultProcessors.h 8 Jun 2010 22:12:41 -0000 1.3
+++ DefaultProcessors.h 24 Sep 2010 07:22:50 -0000 1.4
@@ -13,5 +13,6 @@
#include "ResetPandoraProcessor.h"
#include "SimCalorimeterHitProcessor.h"
#include "SimpleTrackProcessor.h"
+#include "MCParticleProcessor.h"
#endif
slicPandora/src
diff -N MCParticleProcessor.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ MCParticleProcessor.cpp 24 Sep 2010 07:22:50 -0000 1.1
@@ -0,0 +1,95 @@
+// $Id: MCParticleProcessor.cpp,v 1.1 2010/09/24 07:22:50 speckmay Exp $
+
+#include "MCParticleProcessor.h"
+
+// lcio
+#include "EVENT/LCCollection.h"
+
+// slicPandora
+#include "IDDecoder.h"
+#include "JobManager.h"
+#include "JobConfig.h"
+#include "DetectorGeometry.h"
+
+// stl
+#include <cmath>
+
+using std::fabs;
+using EVENT::MCParticle;
+using EVENT::LCCollection;
+
+std::string MCParticleProcessor::mcParticleCollectionName = "MCParticle";
+
+void MCParticleProcessor::processEvent(EVENT::LCEvent* event)
+{
+ const pandora::Pandora& pandora = getJobManager()->getPandora();
+
+ const LCCollection* mcParticles;
+
+ // Check again if collection exists. If not, could be okay so skip and move on.
+ try
+ {
+ mcParticles = event->getCollection(mcParticleCollectionName);
+ }
+ catch (...)
+ {
+ std::cout << "No MCParticle collection '" << mcParticleCollectionName << "' found. " << std::endl;
+ return;
+ }
+
+ int nptcl = mcParticles->getNumberOfElements();
+
+ for (int i=0; i<nptcl; i++)
+ {
+ MCParticle* mcParticle = dynamic_cast<MCParticle*> (mcParticles->getElementAt(i));
+ PandoraApi::MCParticle::Parameters mcParticleParams = makeMCParticleParameters( mcParticle);
+
+#ifdef MCPARTICLE_PARAMS_DEBUG
+ printCaloHitParameters(mcParticleParams);
+#endif
+
+ PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::MCParticle::Create(pandora, mcParticleParams));
+ }
+#ifdef MCPARTICLE_PARAMS_DEBUG
+ std::cout << "-----------------------------------------------------" << std::endl;
+#endif
+}
+
+
+PandoraApi::MCParticle::Parameters MCParticleProcessor::makeMCParticleParameters( MCParticle* pMcParticle )
+{
+ const pandora::Pandora& pandora = getJobManager()->getPandora();
+
+ PandoraApi::MCParticle::Parameters mcParticleParameters;
+ mcParticleParameters.m_energy = pMcParticle->getEnergy();
+ mcParticleParameters.m_particleId = pMcParticle->getPDG();
+ mcParticleParameters.m_pParentAddress = pMcParticle;
+ mcParticleParameters.m_momentum = pandora::CartesianVector(pMcParticle->getMomentum()[0], pMcParticle->getMomentum()[1],
+ pMcParticle->getMomentum()[2]);
+ mcParticleParameters.m_vertex = pandora::CartesianVector(pMcParticle->getVertex()[0], pMcParticle->getVertex()[1],
+ pMcParticle->getVertex()[2]);
+ mcParticleParameters.m_endpoint = pandora::CartesianVector(pMcParticle->getEndpoint()[0], pMcParticle->getEndpoint()[1],
+ pMcParticle->getEndpoint()[2]);
+
+ PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::MCParticle::Create(pandora, mcParticleParameters));
+
+ // Create parent-daughter relationships
+ for(std::vector<MCParticle*>::const_iterator itDaughter = pMcParticle->getDaughters().begin(),
+ itDaughterEnd = pMcParticle->getDaughters().end(); itDaughter != itDaughterEnd; ++itDaughter)
+ {
+ PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::SetMCParentDaughterRelationship(pandora, pMcParticle,
+ *itDaughter));
+ }
+
+ return mcParticleParameters;
+}
+
+
+void MCParticleProcessor::printMCParticleParameters(const PandoraApi::MCParticle::Parameters& params)
+{
+ std::cout << params.m_vertex.Get() << " [mm]" << std::endl;
+ std::cout << params.m_endpoint.Get() << " [mm]" << std::endl;
+ std::cout << " energy: " << params.m_energy.Get() << " [GeV]" << std::endl;
+ std::cout << params.m_momentum.Get() << " [GeV/c]" << std::endl;
+ std::cout << " particleID: " << params.m_particleId.Get() << " " << std::endl;
+}
slicPandora/src
diff -u -r1.4 -r1.5
--- JobConfig.cpp 16 Aug 2010 17:51:58 -0000 1.4
+++ JobConfig.cpp 24 Sep 2010 07:22:50 -0000 1.5
@@ -9,6 +9,7 @@
defaultCalTypes.push_back(std::string("HAD_ENDCAP"));
defaultCalTypes.push_back(std::string("MUON_BARREL"));
defaultCalTypes.push_back(std::string("MUON_ENDCAP"));
+// defaultCalTypes.push_back(std::string("HCAL_PLUG"));
return defaultCalTypes;
}
slicPandora/src
diff -u -r1.19 -r1.20
--- SimCalorimeterHitProcessor.cpp 27 Aug 2010 17:35:36 -0000 1.19
+++ SimCalorimeterHitProcessor.cpp 24 Sep 2010 07:22:50 -0000 1.20
@@ -25,6 +25,8 @@
using IMPL::LCRelationImpl;
using EVENT::SimCalorimeterHit;
+using EVENT::MCParticle;
+
SimCalorimeterHitProcessor::SimCalorimeterHitProcessor()
: EventProcessor("SimCalorimeterHitProcessor")
{;}
@@ -37,6 +39,7 @@
//std::cout << "SimCalorimeterHitProcessor::processEvent" << std::endl;
JobManager* mgr = getJobManager();
+ const pandora::Pandora& pandora = getJobManager()->getPandora();
// Get the job's DetectorGeometry from the JobManager.
DetectorGeometry* geom = mgr->getDetectorGeometry();
@@ -52,6 +55,12 @@
scRel->parameters().setValue("RelationFromType", EVENT::LCIO::CALORIMETERHIT);
scRel->parameters().setValue("RelationToType", EVENT::LCIO::SIMCALORIMETERHIT);
+
+ typedef std::map<MCParticle *, float> MCParticleToEnergyWeightMap;
+ MCParticleToEnergyWeightMap mcParticleToEnergyWeightMap;
+
+
+
// Loop over calorimeter types.
for (JobConfig::CalorimeterTypes::iterator iter = calTypes.begin();
iter != calTypes.end();
@@ -158,6 +167,25 @@
// Setup the relation between CalHit and SimHit.
scRel->addElement(new LCRelationImpl(calHit, simCalHit, 0.5));
+
+ // TODO, PROBLEM: the program gets never here if the Calorimeter collection has been created already before running SlicPandora
+ // -------- add link to MCParticle
+ mcParticleToEnergyWeightMap.clear();
+
+ for (int iCont = 0, iEnd = simCalHit->getNMCContributions(); iCont < iEnd; ++iCont)
+ {
+ mcParticleToEnergyWeightMap[simCalHit->getParticleCont(iCont)] += simCalHit->getEnergyCont(iCont);
+ }
+
+ for (MCParticleToEnergyWeightMap::const_iterator mcParticleIter = mcParticleToEnergyWeightMap.begin(),
+ mcParticleIterEnd = mcParticleToEnergyWeightMap.end(); mcParticleIter != mcParticleIterEnd; ++mcParticleIter)
+ {
+ PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::SetCaloHitToMCParticleRelationship(pandora, calHit , mcParticleIter->first, mcParticleIter->second));
+ }
+ // -------- add link to MCParticle --- end
+
+
+
// Add the created CalorimeterHit to the collection.
calHits->addElement(calHit);
}
slicPandora/src
diff -u -r1.12 -r1.13
--- SimpleTrackProcessor.cpp 16 Aug 2010 17:51:58 -0000 1.12
+++ SimpleTrackProcessor.cpp 24 Sep 2010 07:22:50 -0000 1.13
@@ -33,7 +33,16 @@
void SimpleTrackProcessor::processEvent(EVENT::LCEvent* event)
{
- LCCollection* trackCollection = event->getCollection(trackCollectionName);
+ LCCollection* trackCollection = NULL;
+ try
+ {
+ trackCollection = event->getCollection(trackCollectionName);
+ }
+ catch(...)
+ {
+ std::cout << "no track collection with the name '" << trackCollectionName << "' found." << std::endl;
+ return;
+ }
int ntracks = trackCollection->getNumberOfElements();
for (int i=0; i<ntracks; i++)
slicPandora/tests
diff -u -r1.3 -r1.4
--- PandoraFrontend.cpp 17 Mar 2010 02:13:04 -0000 1.3
+++ PandoraFrontend.cpp 24 Sep 2010 07:22:50 -0000 1.4
@@ -1,4 +1,4 @@
-//$Id: PandoraFrontend.cpp,v 1.3 2010/03/17 02:13:04 jeremy Exp $
+//$Id: PandoraFrontend.cpp,v 1.4 2010/09/24 07:22:50 speckmay Exp $
/**
* This is a simple frontend to run slicPandora. It takes an ordered list of arguments. (See usage method.)
@@ -75,6 +75,9 @@
// Add a processor to mark beginning of event processing.
mgr->addEventProcessor(new EventMarkerProcessor());
+ // Add a processor to convert LCIO MCParticles to Pandora MCParticle::Parameters.
+ mgr->addEventProcessor(new MCParticleProcessor());
+
// Add a processor to convert LCIO SimCalorimeterHits to LCIO CalorimeterHits.
mgr->addEventProcessor(new SimCalorimeterHitProcessor());
CVSspam 0.2.8