10 modified files
slicPandora/src
diff -u -r1.1 -r1.2
--- CalorimeterHitProcessor.cpp 5 Mar 2010 01:35:48 -0000 1.1
+++ CalorimeterHitProcessor.cpp 8 Mar 2010 23:00:53 -0000 1.2
@@ -1,14 +1,65 @@
-// $Id: CalorimeterHitProcessor.cpp,v 1.1 2010/03/05 01:35:48 jeremy Exp $
+// $Id: CalorimeterHitProcessor.cpp,v 1.2 2010/03/08 23:00:53 jeremy Exp $
#include "CalorimeterHitProcessor.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::CalorimeterHit;
+using EVENT::LCCollection;
-void CalorimeterHitProcessor::processEvent(EVENT::LCEvent*)
+#define CALO_PARAMS_DEBUG 1
+
+void CalorimeterHitProcessor::processEvent(EVENT::LCEvent* event)
{
+ std::cout << "CalorimeterHitProcessor::processEvent" << std::endl;
+
+ const pandora::Pandora& pandora = getJobManager()->getPandora();
+ DetectorGeometry* geom = getJobManager()->getDetectorGeometry();
+ JobConfig::CalorimeterTypes calTypes = getJobManager()->getJobConfig()->getCalorimeterTypes();
+ for (JobConfig::CalorimeterTypes::const_iterator iter = calTypes.begin();
+ iter != calTypes.end();
+ iter++)
+ {
+ std::string calType = *iter;
+
+ //std::cout << "converting collection: " << calType << std::endl;
+
+ // Get the SubDetector parameters.
+ PandoraApi::GeometryParameters::SubDetectorParameters* subdet = geom->getSubDetectorFromType(calType);
+ DetectorGeometry::ExtraSubDetectorParameters* xsubdet = geom->getExtraSubDetectorParametersFromType(calType);
+
+ const LCCollection* caloHits = event->getCollection(*iter);
+ int nhits = caloHits->getNumberOfElements();
+
+#ifdef CALO_PARAMS_DEBUG
+ std::cout << "COLLECTION: " << calType << std::endl;
+#endif
+ for (int i=0; i<nhits; i++)
+ {
+ CalorimeterHit* calHit = dynamic_cast<CalorimeterHit*> (caloHits->getElementAt(i));
+ PandoraApi::CaloHit::Parameters caloHitParams = makeCaloHitParameters(subdet, xsubdet, calHit);
+
+#ifdef CALO_PARAMS_DEBUG
+ printCaloHitParameters(caloHitParams);
+#endif
+
+ PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::CaloHit::Create(pandora, caloHitParams));
+ }
+#ifdef CALO_PARAMS_DEBUG
+ std::cout << "-----------------------------------------------------" << std::endl;
+#endif
+ }
}
@@ -37,27 +88,90 @@
// Create a new, empty CaloHit Parameters.
PandoraApi::CaloHit::Parameters params;
- // Fill in the CaloHit Parameters data fields.
- params.m_layer = layer;
+ // Get the hit position.
+ const float* pos(hit->getPosition());
+
+ //
+ // Setup a CaloHit::Parameters object for this CalorimeterHit.
+ //
+
+ // Position in mm.
+ params.m_positionVector = pandora::CartesianVector(pos[0], pos[1], pos[2]);
+
+ // Hit energy in GeV.
+ params.m_inputEnergy = hit->getEnergy();
+
+ // EM energy in GeV.
params.m_electromagneticEnergy = hit->getEnergy();
+
+ // HAD energy in GeV.
params.m_hadronicEnergy = hit->getEnergy();
- params.m_mipEquivalentEnergy = 1.0; // FIXME: dummy value
- params.m_isDigital = false; // FIXME: hard-coded value
+
+ // MIP equivalent energy.
+ // FIXME: Hard-coded to 1.0.
+ // TODO: Calculate MIP equivalent energy. (How?)
+ params.m_mipEquivalentEnergy = 1.0;
+
+ // Digital calorimeter.
+ // FIXME: Hard-coded to false.
+ // TODO: Read digital setting from the sampling fraction conditions file for the collection (Ron).
+ params.m_isDigital = false;
+
+ // Layer number.
+ params.m_layer = layer;
+
+ // Hit time in ns.
params.m_time = hit->getTime();
- params.m_inputEnergy = hit->getEnergy();
+
+ // Pointer to the source hit.
params.m_pParentAddress = hit;
+
+ // Cell size U in mm.
params.m_cellSizeU = xsubdet->m_cellSizeU;
+
+ // Cell size V in mm.
params.m_cellSizeV = xsubdet->m_cellSizeV;
+
+ // Cell thickness in mm.
params.m_cellThickness = xlayerParams.m_cellThickness;
+
+ // Number of radiation lengths in layer.
params.m_nRadiationLengths = layerParams.m_nRadiationLengths;
+
+ // Number of interaction lengths in layer.
params.m_nInteractionLengths = layerParams.m_nInteractionLengths;
-/*
- params.m_positionVector = pandora::CartesianVector(pos[0], pos[1], pos[2]);
- params.m_normalVector = *(_normalVectors.at(module));
- params.m_hitType = pandora::ECAL;
- params.m_detectorRegion = pandora::BARREL;
-*/
+ // Type of hit.
+ params.m_hitType = xsubdet->m_inputHitType;
+
+ // Type of detector region.
+ params.m_detectorRegion = xsubdet->m_inputDetectorRegion;
+ // Barrel case uses module.
+ if (xsubdet->m_inputDetectorRegion.Get() == pandora::BARREL)
+ {
+ params.m_normalVector = *(xsubdet->m_normalVectors.at(module));
+ }
+ // Endcap case is computed.
+ else
+ {
+ params.m_normalVector = pandora::CartesianVector(0., 0., pos[2]/fabs(pos[2]));
+ }
+
return params;
}
+
+
+void CalorimeterHitProcessor::printCaloHitParameters(const PandoraApi::CaloHit::Parameters& params)
+{
+ std::cout << params.m_positionVector.Get() << " [mm]" << std::endl;
+ std::cout << " energy: " << params.m_inputEnergy.Get() << " [GeV]" << std::endl;
+ std::cout << " layer: " << params.m_layer.Get() << std::endl;
+ std::cout << " time: " << params.m_time.Get() << " [ns]" << std::endl;
+ std::cout << " cell sizes: " << params.m_cellSizeU.Get() << ", " << params.m_cellSizeV.Get() << " [mm]" << std::endl;
+ std::cout << " cell thick: " << params.m_cellThickness.Get() << " [mm]" << std::endl;
+ std::cout << " radLengths: " << params.m_nRadiationLengths.Get() << std::endl;
+ std::cout << " intLengths: " << params.m_nInteractionLengths.Get() << std::endl;
+ std::cout << " normalVec: " << params.m_normalVector.Get() << std::endl;
+
+}
slicPandora/src
diff -u -r1.5 -r1.6
--- DetectorGeometry.cpp 5 Mar 2010 01:35:48 -0000 1.5
+++ DetectorGeometry.cpp 8 Mar 2010 23:00:53 -0000 1.6
@@ -1,5 +1,8 @@
#include "DetectorGeometry.h"
+// pandora
+#include "Pandora/PandoraInputTypes.h"
+
// slicPandora
#include "IDDecoder.h"
@@ -7,6 +10,7 @@
#include <stdexcept>
#include <cstdio>
#include <cstring>
+#include <cmath>
// tinyxml
#include "tinyxml.h"
@@ -22,6 +26,8 @@
void DetectorGeometry::loadFromFile(std::string filename)
{
+ //std::cout << "DetectorGeometry::loadFromFile()" << std::endl;
+
// Load doc and check if valid.
TiXmlDocument doc(filename.c_str());
if (!doc.LoadFile())
@@ -167,9 +173,39 @@
// Make an IDDecoder for this calorimeter.
IDDecoder* decoder = new IDDecoder(fields);
+
+ // Set extra subdetector parameters.
extras.m_decoder = decoder;
+ extras.m_inputHitType = getHitType(subdetType);
+ extras.m_inputDetectorRegion = getDetectorRegion(subdetType);
+
+ if (innerSym != outerSym)
+ {
+ std::cerr << "Inner and outer symmetry are different. Don't know how to handle this case!" << std::endl;
+ exit(1);
+ }
- // Insert the extra subdetector information.
+ // Calculate the subdetector normal vectors for a barrel region.
+ if (extras.m_inputDetectorRegion.Get() == pandora::BARREL)
+ {
+ int nSides = innerSym;
+ double pi(std::acos(-1.));
+ double dphi = -2 * pi / nSides;
+ double phi0 = pi / 2.;
+ double phi = phi0;
+ for (int i = 0; i < nSides; ++i)
+ {
+ //cout << " Module " << i << " x " << cos(phi) << " y " << sin(phi) << endl;
+ float x = cos(phi);
+ float y = sin(phi);
+ if (std::fabs(x) < 1e-10) x=0;
+ if (std::fabs(y) < 1e-10) y=0;
+ extras.m_normalVectors.push_back(new pandora::CartesianVector(x, y, 0.));
+ phi += dphi;
+ }
+ }
+
+ // Insert the extra subdetector information into the data map.
std::string subdetTypeStr(subdetType);
subdetExtras[subdetTypeStr] = extras;
@@ -192,11 +228,11 @@
#ifdef DETECTOR_GEOMETRY_DEBUG
// Print tracking.
- printf("Tracking: \n");
- printf(" mainTrackerInnerRadius: %f\n", geom.m_mainTrackerInnerRadius.Get());
- printf(" mainTrackerOuterRadius: %f\n", geom.m_mainTrackerOuterRadius.Get());
- printf(" mainTrackerZExtent: %f\n", geom.m_mainTrackerZExtent.Get());
- printf("\n" );
+ std::cout << "Tracking:" << std::endl;
+ std::cout << " mainTrackerInnerRadius: " << geom.m_mainTrackerInnerRadius.Get() << std::endl;
+ std::cout << " mainTrackerOuterRadius: " << geom.m_mainTrackerOuterRadius.Get() << std::endl;
+ std::cout << " mainTrackerZExtent: " << geom.m_mainTrackerZExtent.Get() << std::endl;
+ std::cout << std::endl;
#endif
// Coil and B-field.
@@ -212,14 +248,20 @@
geom.m_coilZExtent = cz;
geom.m_bField = bfield;
+ // FIXME: Next four are just dummy parameters for the moment.
+ geom.m_nRadLengthsInZGap = 0.;
+ geom.m_nIntLengthsInZGap = 0.;
+ geom.m_nRadLengthsInRadialGap = 0.;
+ geom.m_nIntLengthsInRadialGap = 0.;
+
#ifdef DETECTOR_GEOMETRY_DEBUG
// Print coil and field.
- printf("Coil: \n");
- printf(" coilInnerRadius: %f\n", geom.m_coilInnerRadius.Get());
- printf(" coilOuterRadius: %f\n", geom.m_coilOuterRadius.Get());
- printf(" coilZExtent: %f\n", geom.m_coilZExtent.Get());
- printf(" bField: %f\n", geom.m_bField.Get());
- printf("\n" );
+ std::cout << "Coil:" << std::endl;
+ std::cout << " coilInnerRadius: " << geom.m_coilInnerRadius.Get() << std::endl;
+ std::cout << " coilOuterRadius: " << geom.m_coilOuterRadius.Get() << std::endl;
+ std::cout << " coilZExtent: " << geom.m_coilZExtent.Get() << std::endl;
+ std::cout << " bField: " << geom.m_bField.Get() << std::endl;
+ std::cout << std::endl;
#endif
}
@@ -291,3 +333,29 @@
printf("\n");
}
+
+pandora::InputHitType DetectorGeometry::getHitType(const std::string& calType) const
+{
+ if (calType == "EM_BARREL" || calType == "EM_ENDCAP")
+ {
+ return pandora::ECAL;
+ }
+ else if (calType == "HAD_BARREL" || calType == "HAD_ENDCAP")
+ {
+ return pandora::HCAL;
+ }
+}
+
+inline pandora::InputDetectorRegion DetectorGeometry::getDetectorRegion(const std::string& calType) const
+{
+ if (calType == "EM_BARREL" || calType == "HAD_BARREL")
+ {
+ return pandora::BARREL;
+ }
+ else if (calType == "EM_ENDCAP" || calType == "HAD_ENDCAP")
+ {
+ return pandora::ENDCAP;
+ }
+}
+
+
slicPandora/src
diff -u -r1.3 -r1.4
--- JobManager.cpp 5 Mar 2010 01:35:48 -0000 1.3
+++ JobManager.cpp 8 Mar 2010 23:00:53 -0000 1.4
@@ -39,11 +39,20 @@
void JobManager::initialize()
{
+ // Create new Pandora instance.
m_pandora = new pandora::Pandora();
- PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, createGeometry());
- PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, registerUserAlgorithmFactories());
- PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::ReadSettings(*m_pandora, m_config->getPandoraSettingsXmlFile()));
+ // Create the slicPandora DetectorGeometry.
+ PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, createGeometry());
+
+ // Create the GeometryParameters within Pandora.
+ PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::Geometry::Create(*m_pandora, *m_detectorGeometry->getGeometryParameters()));
+
+ // Register the the user algorithm factories with Pandora.
+ PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, registerUserAlgorithmFactories());
+
+ // Read the run control settings into Pandora.
+ PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::ReadSettings(*m_pandora, m_config->getPandoraSettingsXmlFile()));
}
void JobManager::setJobConfig(JobConfig* config)
@@ -111,6 +120,7 @@
while (event != 0)
{
processEvent(event);
+ writer->writeEvent(event);
if (nread >= ntoread)
{
std::cout << "Read <" << ntoread << "> events. Stopping run!" << std::endl;
@@ -119,6 +129,9 @@
event = reader->readNextEvent();
++nread;
}
+ reader->close();
+ writer->flush();
+ writer->close();
return STATUS_CODE_SUCCESS;
}
slicPandora/src
diff -u -r1.1 -r1.2
--- PandoraProcessor.cpp 5 Mar 2010 01:35:48 -0000 1.1
+++ PandoraProcessor.cpp 8 Mar 2010 23:00:53 -0000 1.2
@@ -9,6 +9,7 @@
void PandoraProcessor::processEvent(EVENT::LCEvent*)
{
+ std::cout << "PandoraProcessor::processEvent" << std::endl;
StatusCode stat = PandoraApi::ProcessEvent(getJobManager()->getPandora());
if (stat != STATUS_CODE_SUCCESS)
{
slicPandora/src
diff -u -r1.1 -r1.2
--- PfoProcessor.cpp 5 Mar 2010 01:35:48 -0000 1.1
+++ PfoProcessor.cpp 8 Mar 2010 23:00:53 -0000 1.2
@@ -1,4 +1,4 @@
-// $Id: PfoProcessor.cpp,v 1.1 2010/03/05 01:35:48 jeremy Exp $
+// $Id: PfoProcessor.cpp,v 1.2 2010/03/08 23:00:53 jeremy Exp $
#include "PfoProcessor.h"
// lcio
@@ -24,7 +24,10 @@
void PfoProcessor::processEvent(EVENT::LCEvent*)
{
+ std::cout << "PfoProcessor::processEvent" << std::endl;
+
// Setup cluster collection.
+ /*
LCCollectionVec* clusterVec = new LCCollectionVec(EVENT::LCIO::CLUSTER);
LCFlagImpl clusterFlag(0);
clusterFlag.setBit(EVENT::LCIO::CLBIT_HITS);
@@ -34,6 +37,7 @@
PANDORA_THROW_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraApi::GetParticleFlowObjects(getJobManager()->getPandora(),
particleFlowObjectList));
LCCollectionVec* pReconstructedParticleCollection = new LCCollectionVec(EVENT::LCIO::RECONSTRUCTEDPARTICLE);
+ */
}
slicPandora/src
diff -u -r1.4 -r1.5
--- SimCalorimeterHitProcessor.cpp 5 Mar 2010 01:35:48 -0000 1.4
+++ SimCalorimeterHitProcessor.cpp 8 Mar 2010 23:00:53 -0000 1.5
@@ -34,6 +34,8 @@
void SimCalorimeterHitProcessor::processEvent(EVENT::LCEvent* event)
{
+ std::cout << "SimCalorimeterHitProcessor::processEvent" << std::endl;
+
JobManager* mgr = getJobManager();
// Get the job's DetectorGeometry from the JobManager.
slicPandora/include
diff -u -r1.1 -r1.2
--- CalorimeterHitProcessor.h 5 Mar 2010 01:35:48 -0000 1.1
+++ CalorimeterHitProcessor.h 8 Mar 2010 23:00:54 -0000 1.2
@@ -44,6 +44,8 @@
PandoraApi::GeometryParameters::SubDetectorParameters* subdet,
DetectorGeometry::ExtraSubDetectorParameters* xsubdet,
CalorimeterHit*);
+
+ void printCaloHitParameters(const PandoraApi::CaloHit::Parameters&);
};
#endif
slicPandora/include
diff -u -r1.5 -r1.6
--- DetectorGeometry.h 5 Mar 2010 01:35:48 -0000 1.5
+++ DetectorGeometry.h 8 Mar 2010 23:00:54 -0000 1.6
@@ -1,8 +1,12 @@
#ifndef DetectorGeometry_h
#define DetectorGeometry_h 1
+// pandora
#include "Api/PandoraApi.h"
+// stl
+#include <vector>
+
class IDDecoder;
class DetectorGeometry
@@ -30,10 +34,10 @@
std::string m_collection;
IDDecoder* m_decoder;
ExtraLayerParametersList m_extraLayerParams;
- // TODO: Add module normal vectors.
- // TODO: Add hitType, e.g. pandora::ECAL.
- // TODO: Add detectorRegion, e.g. pandora::BARREL.
- // TODO: Add isDigital.
+ pandora::InputHitType m_inputHitType;
+ pandora::InputDetectorRegion m_inputDetectorRegion;
+ std::vector<pandora::CartesianVector*> m_normalVectors;
+ // TODO: Add isDigital setting here.
};
typedef std::map<std::string, ExtraSubDetectorParameters> ExtraSubDetectorParametersMap;
@@ -45,23 +49,57 @@
virtual ~DetectorGeometry() {;}
+ /**
+ * Load geometry from an XML input file produced by GeomConverter in the "pandora" format.
+ */
void loadFromFile(std::string);
+ /**
+ * Get the PandoraApi's GeometryParameters.
+ */
PandoraApi::Geometry::Parameters* getGeometryParameters()
{
return &geom;
}
+ /**
+ * Get the map of ExtraSubDetectorParameters.
+ */
ExtraSubDetectorParametersMap* getExtraParameters()
{
return &subdetExtras;
}
+ ExtraSubDetectorParameters* getExtraSubDetectorParametersFromType(const std::string& calType)
+ {
+ return &(subdetExtras[calType]);
+ }
+
+ /**
+ * Print SubDetectorParameters to cout.
+ */
void printOut(const char* subdetType, PandoraApi::GeometryParameters::SubDetectorParameters* subdet);
+ /**
+ * Get the SubDetectorParameters for a given calorimeter type string.
+ */
PandoraApi::GeometryParameters::SubDetectorParameters* getSubDetectorFromType(const char*);
+
+ /**
+ * Get the SubDetectorParameters for a given calorimeter type string.
+ */
PandoraApi::GeometryParameters::SubDetectorParameters* getSubDetectorFromType(const std::string&);
+ /**
+ * Simple utility method to return the InputDetectorRegion from the calorimeter type.
+ */
+ inline pandora::InputDetectorRegion getDetectorRegion(const std::string& calType) const;
+
+ /**
+ * Simple utility method to return the InputHitType from the calorimeter type.
+ */
+ inline pandora::InputHitType getHitType(const std::string& calType) const;
+
private:
PandoraApi::Geometry::Parameters geom;
ExtraSubDetectorParametersMap subdetExtras;
slicPandora/include
diff -u -r1.3 -r1.4
--- JobManager.h 5 Mar 2010 01:35:48 -0000 1.3
+++ JobManager.h 8 Mar 2010 23:00:54 -0000 1.4
@@ -55,8 +55,7 @@
DetectorGeometry* getDetectorGeometry();
/**
- * Get the Pandora PFA instance as a const ref. This is the argument
- * signature for PandoraPFANew methods.
+ * Get the Pandora PFA instance.
*/
const pandora::Pandora& getPandora();
@@ -79,6 +78,9 @@
StatusCode registerUserAlgorithmFactories();
+ /**
+ * Create the geometry from the XML geometry file.
+ */
StatusCode createGeometry();
private:
slicPandora/tests
diff -u -r1.3 -r1.4
--- JobManagerTest.cpp 5 Mar 2010 01:35:48 -0000 1.3
+++ JobManagerTest.cpp 8 Mar 2010 23:00:54 -0000 1.4
@@ -1,4 +1,4 @@
-// $Id: JobManagerTest.cpp,v 1.3 2010/03/05 01:35:48 jeremy Exp $
+// $Id: JobManagerTest.cpp,v 1.4 2010/03/08 23:00:54 jeremy Exp $
// slicPandora
#include "JobConfig.h"
@@ -7,33 +7,49 @@
#include "PfoProcessor.h"
#include "PandoraProcessor.h"
#include "SimCalorimeterHitProcessor.h"
+#include "CalorimeterHitProcessor.h"
/**
- * This runs a complete Pandora job on example input.
+ * This main function runs a complete Pandora job on example input using the JobManager.
+ * It MUST be run from the slicPandora root directory using this command.
+ *
+ * ./bin/JobManagerTest
+ *
+ * If this program is called from another directory, it will not be able to find the
+ * input data files and will crash.
+ *
+ * The user must provide an input LCIO file called input.slcio containing a slic event.
+ * This can be a sym link or an actual LCIO file.
*/
int main(int argc, char** argv)
{
- // Create the example job configuration.
+ // Create an example job configuration.
JobConfig* config = new JobConfig();
config->setPandoraSettingsXmlFile("./tests/PandoraSettings.xml");
config->setGeometryFile("./examples/sidloi2_pandora.xml");
//config->useDefaultCalorimeterTypes();
- config->addCalorimeterType("EM_BARREL"); // Just test on single collection for now.
+ config->addCalorimeterType("EM_BARREL"); // DEBUG: Just use EM_BARREL collection.
config->addInputFile("./input.slcio");
config->setOutputFile("pandoraRecon.slcio");
config->setNumberOfEvents(1);
config->setSkipEvents(0);
+ // Make a new job manager.
JobManager* mgr = new JobManager();
- // Set the job configuration.
+ // Set the JobManager's configuration.
mgr->setJobConfig(config);
- // Add the event processors in the correct order.
- mgr->addEventProcessor(new DummyProcessor());
+ // Add a processor to convert LCIO SimCalorimeterHits to LCIO CalorimeterHits.
mgr->addEventProcessor(new SimCalorimeterHitProcessor());
- // TODO: add converter to CaloHitParams here
+
+ // Add a processor to convert LCIO CalorimeterHits to Pandora CaloHit::Parameters.
+ mgr->addEventProcessor(new CalorimeterHitProcessor());
+
+ // Add a processor to automatically run the registered Pandora algorithms.
mgr->addEventProcessor(new PandoraProcessor());
+
+ // Add a processor to create LCIO PFO objects, including clusters and ReconParticles.
mgr->addEventProcessor(new PfoProcessor());
// Run the job.
CVSspam 0.2.8