Commit in slicPandora on MAIN
include/CalorimeterHitMaker.h+25added 1.1
       /PfoConstructionAlgorithm.h+45added 1.1
       /SlicPandoraPFANewProcessor.h+108added 1.1
src/CalorimeterHitMaker.cpp+96added 1.1
   /PfoConstructionAlgorithm.cpp+49added 1.1
   /SlicPandoraPFANewProcessor.cpp+433added 1.1
tests/PandoraSettings.xml+55added 1.1
     /main.cpp+158added 1.1
+969
8 added files
First working release.

slicPandora/include
CalorimeterHitMaker.h added at 1.1
diff -N CalorimeterHitMaker.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ CalorimeterHitMaker.h	8 Jan 2010 22:55:34 -0000	1.1
@@ -0,0 +1,25 @@
+/* 
+ * File:   CalorimeterHitMaker.h
+ * Author: ngraf
+ *
+ * Created on December 2, 2009, 5:45 AM
+ */
+
+#ifndef _CALORIMETERHITMAKER_H
+#define	_CALORIMETERHITMAKER_H
+
+#include "lcio.h"
+
+class CalorimeterHitMaker
+{
+public:
+    CalorimeterHitMaker();
+    CalorimeterHitMaker(const CalorimeterHitMaker& orig);
+    virtual ~CalorimeterHitMaker();
+    void processEvent(lcio::LCEvent* event);
+private:
+
+};
+
+#endif	/* _CALORIMETERHITMAKER_H */
+

slicPandora/include
PfoConstructionAlgorithm.h added at 1.1
diff -N PfoConstructionAlgorithm.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ PfoConstructionAlgorithm.h	8 Jan 2010 22:55:34 -0000	1.1
@@ -0,0 +1,45 @@
+/**
+ *  @file   PandoraPFANew/include/Algorithms/PfoConstructionAlgorithm.h
+ * 
+ *  @brief  Header file for the pfo construction algorithm class.
+ * 
+ *  $Log: PfoConstructionAlgorithm.h,v $
+ *  Revision 1.1  2010/01/08 22:55:34  ngraf
+ *  First working release.
+ *
+ */
+#ifndef PFO_CONSTRUCTION_ALGORITHM_H
+#define PFO_CONSTRUCTION_ALGORITHM_H 1
+
+#include "Algorithms/Algorithm.h"
+
+/**
+ *  @brief  PfoConstructionAlgorithm class
+ */
+class PfoConstructionAlgorithm : public pandora::Algorithm
+{
+public:
+    /**
+     *  @brief  Factory class for instantiating algorithm
+     */
+    class Factory : public pandora::AlgorithmFactory
+    {
+    public:
+        Algorithm *CreateAlgorithm() const;
+    };
+
+private:
+    StatusCode Run();
+    StatusCode ReadSettings(const TiXmlHandle xmlHandle);
+
+    // Member variables here
+};
+
+//------------------------------------------------------------------------------------------------------------------------------------------
+
+inline pandora::Algorithm *PfoConstructionAlgorithm::Factory::CreateAlgorithm() const
+{
+    return new PfoConstructionAlgorithm();
+}
+
+#endif // #ifndef PFO_CONSTRUCTION_ALGORITHM_H

slicPandora/include
SlicPandoraPFANewProcessor.h added at 1.1
diff -N SlicPandoraPFANewProcessor.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SlicPandoraPFANewProcessor.h	8 Jan 2010 22:55:34 -0000	1.1
@@ -0,0 +1,108 @@
+/* 
+ * File:   SlicPandoraPFANewProcessor.h
+ * Author: ngraf
+ *
+ * Created on December 1, 2009, 5:59 AM
+ */
+
+#ifndef _SLICPANDORAPFANEWPROCESSOR_H
+#define	_SLICPANDORAPFANEWPROCESSOR_H
+
+#include "EVENT/CalorimeterHit.h"
+#include "EVENT/SimCalorimeterHit.h"
+#include "EVENT/CalorimeterHit.h"
+#include "EVENT/Track.h"
+
+#include "StatusCodes.h"
+#include "Api/PandoraApi.h"
+#include "Objects/CartesianVector.h"
+#include "lcio.h"
+
+namespace pandora
+{
+    class Pandora;
+}
+using namespace EVENT;
+
+// namespace pandora {class Pandora;}
+
+class SlicPandoraPFANewProcessor
+{
+public:
+    typedef std::vector<std::string> StringVector;
+
+    /**
+     *  @brief  Settings class
+     */
+    class Settings
+    {
+    public:
+        std::string m_pandoraSettingsXmlFile; ///< The pandora settings xml file
+
+        StringVector m_trackCollections; ///< The reconstructed track collections
+        StringVector m_v0VertexCollections; ///< The v0 vertex collections
+        StringVector m_eCalCaloHitCollections; ///< The ecal calorimeter hit collections
+        StringVector m_hCalCaloHitCollections; ///< The hcal calorimeter hit collections
+        StringVector m_mcParticleCollections; ///< The mc particle collections
+        StringVector m_lcCaloHitRelationCollections; ///< The SimCaloHit to CaloHit particle relations
+        StringVector m_lcTrackRelationCollections; ///< The SimTrackerHit to TrackerHit particle relations
+        std::string m_pfoCollectionName; ///< The name of the PFO output collection
+        float m_absorberRadiationLength; ///< The absorber radation length
+        float m_absorberInteractionLength; ///< The absorber interaction length
+        float m_eCalToMip; ///< The calibration from deposited ECal energy to mip
+        float m_hCalToMip; ///< The calibration from deposited HCal energy to mip
+        float m_eCalMipThreshold; ///< Threshold for creating calo hits in the ECal, units mip
+        float m_hCalMipThreshold; ///< Threshold for creating calo hits in the HCal, units mip
+
+        float m_eCalToEMGeV; ///< The calibration from deposited ECal energy to EM energy
+        float m_hCalToEMGeV; ///< The calibration from deposited HCal energy to EM energy
+        float m_eCalToHadGeV; ///< The calibration from deposited ECal energy to hadronic energy
+        float m_hCalToHadGeV; ///< The calibration from deposited HCal energy to hadronic energy
+        int m_nHitsForHelixFits; ///< The number of hits to be used in helix fits at start/end of tracks
+
+        int m_useEndTrackHelixForECalProjection; ///< Use end track fit or full track helix for ECal projection
+        int m_useDcaAsReferencePointForProjection; ///< Use DCA as helix reference point for ECal projection
+    };
+
+    /**
+     *  @brief  Default constructor
+     */
+    SlicPandoraPFANewProcessor(std::string xmlFileName);
+    /**
+     *  @brief  Initialize, called at startup
+     */
+    virtual void init(std::string xmlFileName);
+    StatusCode registerUserAlgorithmFactories();
+
+    void SetDefaultSubDetectorParameters(PandoraApi::GeometryParameters::SubDetectorParameters &subDetectorParameters) const;
+    void SetEcalEndcapDetectorParameters(PandoraApi::GeometryParameters::SubDetectorParameters &subDetectorParameters) const;
+    void SetHcalBarrelDetectorParameters(PandoraApi::GeometryParameters::SubDetectorParameters &subDetectorParameters) const;
+
+    void processEvent(lcio::LCEvent* pLCEvent);
+    void processParticleFlowObjects( lcio::LCEvent* pLCEvent);
+    void CreateECalCaloHits(const LCEvent* const pLCEvent);
+
+private: // methods
+    StatusCode createGeometry();
+    PandoraApi::CaloHit::Parameters getCalHitParameters(CalorimeterHit* const hit) const;
+    void printSimCalorimeterHit(SimCalorimeterHit* hit);
+    void printCalorimeterHit(CalorimeterHit* hit);
+
+private: // attributes
+    typedef std::vector<CalorimeterHit *> CalorimeterHitVector;
+    typedef std::vector<Track *> TrackVector;
+
+    pandora::Pandora *m_pPandora; ///< Address of the pandora instance
+    Settings m_settings; ///< The settings for the pandora pfa new processor
+    std::string m_detectorName; ///< The detector name
+    unsigned int m_nRun; ///< The run number
+    unsigned int m_nEvent; ///< The event number
+    CalorimeterHitVector m_calorimeterHitVector; ///< The calorimeter hit vector
+    TrackVector m_trackVector; ///< The track vector
+
+    // cache the barrel normal vectors
+    std::vector<pandora::CartesianVector*> _normalVectors;
+};
+
+#endif	/* _SLICPANDORAPFANEWPROCESSOR_H */
+

slicPandora/src
CalorimeterHitMaker.cpp added at 1.1
diff -N CalorimeterHitMaker.cpp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ CalorimeterHitMaker.cpp	8 Jan 2010 22:55:34 -0000	1.1
@@ -0,0 +1,96 @@
+/* 
+ * File:   CalorimeterHitMaker.cpp
+ * Author: Norman A. Graf
+ * 
+ * Created on December 2, 2009, 5:45 AM
+ */
+
+#include "CalorimeterHitMaker.h"
+
+#include "EVENT/LCIO.h"
+#include "EVENT/LCCollection.h"
+#include "IMPL/LCCollectionVec.h"
+#include "IMPL/CalorimeterHitImpl.h"
+#include "IMPL/LCRelationImpl.h"
+#include "IMPL/LCFlagImpl.h" 
+#include "Event/SimCalorimeterHit.h"
+
+
+using lcio::LCCollection;
+using lcio::LCIO;
+using lcio::SimCalorimeterHit;
+using IMPL::LCCollectionVec;
+using IMPL::CalorimeterHitImpl;
+using IMPL::LCRelationImpl;
+using IMPL::LCFlagImpl;
+
+using std::cout;
+using std::endl;
+
+CalorimeterHitMaker::CalorimeterHitMaker()
+{
+}
+
+CalorimeterHitMaker::CalorimeterHitMaker(const CalorimeterHitMaker& orig)
+{
+}
+
+CalorimeterHitMaker::~CalorimeterHitMaker()
+{
+}
+
+void CalorimeterHitMaker::processEvent(lcio::LCEvent* event)
+{
+    double SF1 = .0175;
+    double SF2 = .00936;
+    // get the input SimCalorimeterHits
+    LCCollection* simCalHits = event->getCollection("EcalBarrelHits");
+    cout << " event has " << simCalHits->getNumberOfElements() << " SimCalorimeterHits";
+    //create a container for the output CalorimeterHits
+    LCCollectionVec* calHits = new LCCollectionVec(LCIO::CALORIMETERHIT);
+    // set the flag to indicate that the position will be stored with the hit.
+    LCFlagImpl chFlag(0);
+    chFlag.setBit(LCIO::CHBIT_LONG);
+
+    calHits->setFlag(chFlag.getFlag());
+
+
+    // now convert...
+    LCCollectionVec* scRel = new LCCollectionVec(LCIO::LCRELATION);
+    scRel->parameters().setValue("RelationFromType", LCIO::CALORIMETERHIT);
+    scRel->parameters().setValue("RelationToType", LCIO::SIMCALORIMETERHIT);
+
+    int nSimHits = simCalHits->getNumberOfElements();
+    for (int j = 0; j < nSimHits; j++)
+    {
+
+        CalorimeterHitImpl* calHit = new CalorimeterHitImpl;
+        SimCalorimeterHit* simcalHit = dynamic_cast<SimCalorimeterHit*> (simCalHits->getElementAt(j));
+
+        //      std::cout << " adding new calorimeter hit and relation : " << j << " : "  << calHit << " - " << simcalHit << std::endl ;
+        int layer = (simcalHit->getCellID0() >> 13) & 0x7f;
+        double cfac = (layer < 21 ? SF1 : SF2);
+        calHit->setEnergy(simcalHit->getEnergy() / cfac);
+        calHit->setCellID0(simcalHit->getCellID0());
+        calHit->setCellID1(simcalHit->getCellID1());
+        calHit->setTime(simcalHit->getTimeCont(0));
+        calHit->setPosition(simcalHit->getPosition());
+
+        //       scRel->addRelation( calHit , simcalHit , 0.5 ) ;
+        //       scRel->addRelation( calHit , simcalHit , 0.5 ) ;
+        scRel->addElement(new LCRelationImpl(calHit, simcalHit, 0.5));
+        scRel->addElement(new LCRelationImpl(calHit, simcalHit, 0.5));
+        scRel->addElement(new LCRelationImpl(calHit, simcalHit, 0.5));
+        calHits->addElement(calHit);
+
+        //       // create a copy of sim hit and modify it
+        //       SimCalorimeterHitImpl* mSimHit = new SimCalorimeterHitImpl( *simcalHit ) ;
+        //       mSimHit->setEnergy(  mSimHit->getEnergy() * 1000. ) ;
+        //       modifiedSimCalHits->addElement( mSimHit ) ;
+
+    }
+    event->addCollection(calHits, "CalorimeterHits");
+
+}
+
+

slicPandora/src
PfoConstructionAlgorithm.cpp added at 1.1
diff -N PfoConstructionAlgorithm.cpp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ PfoConstructionAlgorithm.cpp	8 Jan 2010 22:55:34 -0000	1.1
@@ -0,0 +1,49 @@
+/**
+ *  @file   PandoraPFANew/src/Algorithms/PfoConstructionAlgorithm.cc
+ * 
+ *  @brief  Implementation of the pfo construction algorithm class.
+ * 
+ *  $Log: PfoConstructionAlgorithm.cpp,v $
+ *  Revision 1.1  2010/01/08 22:55:34  ngraf
+ *  First working release.
+ *
+ */
+
+#include "Algorithms/PfoConstructionAlgorithm.h"
+
+using namespace pandora;
+
+StatusCode PfoConstructionAlgorithm::Run()
+{
+    // Algorithm code here
+    const ClusterList *pClusterList = NULL;
+    PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentClusterList(*this, pClusterList));
+
+    for (ClusterList::const_iterator iter = pClusterList->begin(), iterEnd = pClusterList->end(); iter != iterEnd; ++iter)
+    {
+        Cluster *pCluster = *iter;
+
+        PandoraContentApi::ParticleFlowObjectParameters particleFlowObjectParameters;
+
+        particleFlowObjectParameters.m_particleId = 1;                          // DUMMY PARAMETERS
+        particleFlowObjectParameters.m_chargeSign = -1;                         // DUMMY PARAMETERS
+        particleFlowObjectParameters.m_mass = 1.;                               // DUMMY PARAMETERS
+        particleFlowObjectParameters.m_energy = 1.;                             // DUMMY PARAMETERS
+        particleFlowObjectParameters.m_momentum = CartesianVector(1, 2, 3);     // DUMMY PARAMETERS
+
+        particleFlowObjectParameters.m_clusterList.insert(pCluster);            // Make new pfo for every cluster
+
+        PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::Create(*this, particleFlowObjectParameters));
+    }
+
+    return STATUS_CODE_SUCCESS;
+}
+
+//------------------------------------------------------------------------------------------------------------------------------------------
+
+StatusCode PfoConstructionAlgorithm::ReadSettings(const TiXmlHandle xmlHandle)
+{
+    // Read settings from xml file here
+
+    return STATUS_CODE_SUCCESS;
+}

slicPandora/src
SlicPandoraPFANewProcessor.cpp added at 1.1
diff -N SlicPandoraPFANewProcessor.cpp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SlicPandoraPFANewProcessor.cpp	8 Jan 2010 22:55:34 -0000	1.1
@@ -0,0 +1,433 @@
+#include "SlicPandoraPFANewProcessor.h"
+
+#include "EVENT/LCCollection.h"
+#include "EVENT/SimCalorimeterHit.h"
+#include "EVENT/CalorimeterHit.h"
+#include "IMPL/LCCollectionVec.h"
+#include "IMPL/ReconstructedParticleImpl.h"
+#include "IMPL/ClusterImpl.h"
+#include "IMPL/LCFlagImpl.h" 
+#include "PfoConstructionAlgorithm.h"
+
+#include <cmath>
+
+using std::cout;
+using std::endl;
+
+using IMPL::LCCollectionVec;
+using IMPL::ReconstructedParticleImpl;
+using IMPL::ClusterImpl;
+using IMPL::LCFlagImpl;
+
+SlicPandoraPFANewProcessor::SlicPandoraPFANewProcessor(std::string xmlFileName)
+{
+    std::cout << "SlicPandoraPFANewProcessor" << std::endl;
+    init(xmlFileName);
+}
+
+void SlicPandoraPFANewProcessor::init(std::string xmlFileName)
+{
+    m_pPandora = new pandora::Pandora();
+
+    PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->createGeometry());
+    PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->registerUserAlgorithmFactories());
+    PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::ReadSettings(*m_pPandora, xmlFileName));
+}
+
+StatusCode SlicPandoraPFANewProcessor::createGeometry()
+{
+    cout << "*****************" << endl << "Creating Geometry" << endl;
+    //    try
+    //    {
+    //        // Insert user code here ...
+    PandoraApi::Geometry::Parameters geometryParameters;
+    //
+    //        const gear::TPCParameters &tpcParameters    = marlin::Global::GEAR->getTPCParameters();
+    //        const gear::PadRowLayout2D &tpcPadLayout    = tpcParameters.getPadLayout();
+    geometryParameters.m_mainTrackerInnerRadius = 12.;
+    geometryParameters.m_mainTrackerOuterRadius = 1264.;
+    geometryParameters.m_mainTrackerZExtent = 1656.;
+    //
+    //        const gear::GearParameters &coilParameters  = marlin::Global::GEAR->getGearParameters("CoilParameters");
+    geometryParameters.m_coilInnerRadius = 2591.;
+    geometryParameters.m_coilOuterRadius = 3000.;
+    geometryParameters.m_coilZExtent = 2933.;
+    geometryParameters.m_bField = 5.0;
+    //
+    geometryParameters.m_nRadLengthsInZGap = 0;
+    geometryParameters.m_nIntLengthsInZGap = 0;
+    geometryParameters.m_nRadLengthsInRadialGap = 0;
+    geometryParameters.m_nIntLengthsInRadialGap = 0;
+    //
+    //   EM Calorimeter Barrel
+    //
+    int nSides = 12;
+    double EcalBarrel_rmin = 1265.;
+    geometryParameters.m_eCalBarrelParameters.m_innerRCoordinate = 1265.;
+    geometryParameters.m_eCalBarrelParameters.m_innerZCoordinate = 1765.;
+    geometryParameters.m_eCalBarrelParameters.m_innerPhiCoordinate = 0.;
+    geometryParameters.m_eCalBarrelParameters.m_innerSymmetryOrder = nSides;
+    // 126.5 + (.032 + .005 + .030 + .033) + ((.25 + .025 + .032 + .005 + .030 + .033) * 20) + ((.5 + .025 + .032 + .005 + .030 + .033) * 10)
+    geometryParameters.m_eCalBarrelParameters.m_outerRCoordinate = 1403.5;
+    geometryParameters.m_eCalBarrelParameters.m_outerZCoordinate = 1765.;
+    geometryParameters.m_eCalBarrelParameters.m_outerPhiCoordinate = 0.;
+    geometryParameters.m_eCalBarrelParameters.m_outerSymmetryOrder = nSides;
+    geometryParameters.m_eCalBarrelParameters.m_nLayers = 31;
+
+    // layer 0
+
+    int tLayer = 0;
+
+    PandoraApi::Geometry::Parameters::LayerParameters layerParameters;
+    layerParameters.m_closestDistanceToIp = EcalBarrel_rmin + .032 / 2.;
+    layerParameters.m_nRadiationLengths = 0.;
+    layerParameters.m_nInteractionLengths = 0.;
+    geometryParameters.m_eCalBarrelParameters.m_layerParametersList.push_back(layerParameters);
+    cout << "layer: " << tLayer++ << " radius " << layerParameters.m_closestDistanceToIp.Get() << endl;
+    // thin absorbers
+    double offset = EcalBarrel_rmin + .032 + .005 + .030 + .033;
+    for (int i = 0; i < 20; ++i)
+    {
+        PandoraApi::Geometry::Parameters::LayerParameters layerParameters;
+        offset += 2.5 + .025 + .032 / 2.; // tungsten + air gap + half silicon thickness
+        layerParameters.m_closestDistanceToIp = offset;
+        cout << "layer: " << tLayer++ << " radius " << layerParameters.m_closestDistanceToIp.Get() << endl;
+
+        offset += .032 / 2. + .005 + .030 + .033; // half silicon thickness + copper + kapton + air gap
+        layerParameters.m_nRadiationLengths = 0.636;
+        layerParameters.m_nInteractionLengths = 0.023;
+        geometryParameters.m_eCalBarrelParameters.m_layerParametersList.push_back(layerParameters);
+    }
+
+    // thick absorbers
+    for (int i = 0; i < 10; ++i)
+    {
+        PandoraApi::Geometry::Parameters::LayerParameters layerParameters;
+        offset += 5.0 + .025 + .032 / 2.; // tungsten + air gap + half silicon thickness
+        layerParameters.m_closestDistanceToIp = offset;
+        cout << "layer: " << tLayer++ << " radius " << layerParameters.m_closestDistanceToIp.Get() << endl;
+
+        offset += .032 / 2. + .005 + .030 + .033; // half silicon thickness + copper + kapton + air gap
+        layerParameters.m_closestDistanceToIp = offset;
+        layerParameters.m_nRadiationLengths = 1.27;
+        layerParameters.m_nInteractionLengths = 0.046;
+        geometryParameters.m_eCalBarrelParameters.m_layerParametersList.push_back(layerParameters);
+    }
+
+    cout << "layer list size " << geometryParameters.m_eCalBarrelParameters.m_layerParametersList.size() << endl;
+
+    // set up the normal vectors by module
+    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;
+        _normalVectors.push_back(new pandora::CartesianVector(cos(phi), sin(phi), 0.));
+        phi += dphi;
+    }
+    //TODO repeat for EM endcap, Had barrel &  Had endcap.
+    SetEcalEndcapDetectorParameters(geometryParameters.m_eCalEndCapParameters);
+    SetHcalBarrelDetectorParameters(geometryParameters.m_hCalBarrelParameters);
+    SetDefaultSubDetectorParameters(geometryParameters.m_hCalEndCapParameters);
+
+
+    //        // Non-default values (and those missing from GEAR parameters file)...
+    geometryParameters.m_eCalEndCapParameters.m_innerSymmetryOrder = 12;
+    geometryParameters.m_hCalBarrelParameters.m_outerPhiCoordinate = 0.;
+    geometryParameters.m_hCalBarrelParameters.m_outerSymmetryOrder = 12;
+    //
+    //        // Addition subdetectors
+    //        this->SetAdditionalSubDetectorParameters(geometryParameters);
+    //
+    cout << "done" << endl;
+    PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::Geometry::Create(*m_pPandora, geometryParameters));
+    //    }
+    //    catch (gear::UnknownParameterException &e)
+    //    {
+    //        streamlog_out(ERROR) << "Failed to extract geometry information from gear." << std::endl;
+    //        return STATUS_CODE_FAILURE;
+    //    }
+    //
+    //    return STATUS_CODE_SUCCESS;
+    cout << "returning" << endl;
+    return STATUS_CODE_SUCCESS;
+}
+
+void SlicPandoraPFANewProcessor::processEvent(lcio::LCEvent* event)
+{
+    std::cout << "processing event " << event->getEventNumber() << std::endl;
+    CreateECalCaloHits(event);
+    StatusCode stat = PandoraApi::ProcessEvent(*m_pPandora);
+    if (stat == STATUS_CODE_SUCCESS)
+    {
+        cout << "Bingo!" << endl;
+        processParticleFlowObjects(event);
+    }
+    //    PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::ProcessEvent(*m_pPandora));
+    //stat = PandoraApi::Reset(*m_pPandora);
+}
+
+void SlicPandoraPFANewProcessor::processParticleFlowObjects(lcio::LCEvent* pLCEvent)
+{
+    // first a container for the clusters...
+    LCCollectionVec* clusterVec = new LCCollectionVec(LCIO::CLUSTER);
+    // if we want to point back to the hits we need to set the flag
+    LCFlagImpl clusterFlag(0);
+    clusterFlag.setBit(LCIO::CLBIT_HITS);
+    clusterVec->setFlag(clusterFlag.getFlag());
+
+    // get the particle flow objects
+    pandora::ParticleFlowObjectList particleFlowObjectList;
+    PANDORA_THROW_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraApi::GetParticleFlowObjects(*m_pPandora,
+            particleFlowObjectList));
+
+    LCCollectionVec* pReconstructedParticleCollection = new LCCollectionVec(LCIO::RECONSTRUCTEDPARTICLE);
+
+    // get particle flow objects and create "reconstructed particles"
+    for (pandora::ParticleFlowObjectList::iterator itPFO = particleFlowObjectList.begin(), itPFOEnd = particleFlowObjectList.end();
+            itPFO != itPFOEnd; ++itPFO)
+    {
+        ReconstructedParticleImpl *pReconstructedParticle = new ReconstructedParticleImpl();
+
+        pandora::ClusterAddressList clusterAddressList = (*itPFO)->GetClusterAddressList();
+        cout << "Found " << clusterAddressList.size() << " clusters." << endl;
+        pandora::TrackAddressList trackAddressList = (*itPFO)->GetTrackAddressList();
+
+        // make LCIO clusters
+        for (pandora::ClusterAddressList::iterator itCluster = clusterAddressList.begin(), itClusterEnd = clusterAddressList.end();
+                itCluster != itClusterEnd; ++itCluster)
+        {
+            ClusterImpl *pCluster = new ClusterImpl();
+            
+            double clusterEnergy = 0.;
+            float* clusterPosition;
+            double maxE = 0;
+            for (pandora::CaloHitAddressList::iterator itHit = (*itCluster).begin(), itHitEnd = (*itCluster).end(); itHit != itHitEnd; ++itHit)
+            {
+              
+                clusterEnergy += ((CalorimeterHit*) (*itHit))->getEnergy();
+                if(((CalorimeterHit*) (*itHit))->getEnergy()>maxE)
+                {
+                    maxE = ((CalorimeterHit*) (*itHit))->getEnergy();
+                    //avert your gaze...
+                    clusterPosition = const_cast<float*>(((CalorimeterHit*) (*itHit))->getPosition());
+                }
+                pCluster->addHit((CalorimeterHit*) (*itHit), 1.0); // transform from Uid (=void*) to a CalorimeterHit*
+            }
+            pCluster->setEnergy(clusterEnergy);
+            pCluster->setPosition(clusterPosition);
+            cout << "Cluster contains " << pCluster->getCalorimeterHits().size() << " hits" << endl;
+            // add this cluster to the collection
+            clusterVec->addElement(pCluster);
+            pReconstructedParticle->addCluster(pCluster);
+        }
+
+        // add tracks
+        for (pandora::TrackAddressList::iterator itTrack = trackAddressList.begin(), itTrackEnd = trackAddressList.end(); itTrack != itTrackEnd;
+                ++itTrack)
+        {
+            pReconstructedParticle->addTrack((Track*) (*itTrack));
+        }
+
+        float momentum[3] = {(*itPFO)->GetMomentum().GetX(), (*itPFO)->GetMomentum().GetY(), (*itPFO)->GetMomentum().GetZ()};
+        pReconstructedParticle->setMomentum(momentum);
+        pReconstructedParticle->setEnergy((*itPFO)->GetEnergy());
+        pReconstructedParticle->setMass((*itPFO)->GetMass());
+        pReconstructedParticle->setCharge((*itPFO)->GetChargeSign());
+        pReconstructedParticle->setType((*itPFO)->GetParticleId());
+
+        pReconstructedParticleCollection->addElement(pReconstructedParticle);
+    }
+    // add the list of clusters to the event
+    pLCEvent->addCollection(clusterVec, "SomeClusters");
+            cout << "end of loop over pandora outpout" << endl;
+    pLCEvent->addCollection(pReconstructedParticleCollection, "PandoraPFOCollection");
+    cout << "added pfo objects to event" << endl;
+}
+
+PandoraApi::CaloHit::Parameters SlicPandoraPFANewProcessor::getCalHitParameters(CalorimeterHit * const hit) const
+{
+    unsigned int layer = ((hit->getCellID0() >> 13) & 0x7f);
+    int module = ((hit->getCellID0() >> 9) & 0xF);
+    const float* pos(hit->getPosition());
+
+    PandoraApi::CaloHit::Parameters params;
+    //        pandora::InputCartesianVector   m_positionVector;           ///< Position vector of center of calorimeter cell, units mm
+    params.m_positionVector = pandora::CartesianVector(pos[0], pos[1], pos[2]);
+
+    //        pandora::InputCartesianVector   m_normalVector;             ///< Unit normal to sampling layer, pointing outwards from the origin
+    params.m_normalVector = *(_normalVectors.at(module));
+
+    //        pandora::InputFloat             m_cellSizeU;                ///< Dimension of cell (up in ENDCAP, along beam in BARREL), units mm
+    params.m_cellSizeU = 3.5;
+
+    //        pandora::InputFloat             m_cellSizeV;                ///< Dimension of cell (perpendicular to u and thickness), units mm
+    params.m_cellSizeV = 3.5;
+
+    //        pandora::InputFloat             m_cellThickness;            ///< Thickness of cell, units mm
+    params.m_cellThickness = .32; // TODO check that this is meant to be the readout thickness.
+
+    //        pandora::InputFloat             m_nRadiationLengths;        ///< Absorber material in front of cell, units radiation lengths
+    params.m_nRadiationLengths = (layer < 21 ? 0.636 : 1.27);
+
+    //        pandora::InputFloat             m_nInteractionLengths;      ///< Absorber material in front of cell, units interaction lengths
+    params.m_nInteractionLengths = (layer < 21 ? 0.023 : 0.046);
+
+    //        pandora::InputFloat             m_time;                     ///< Time of (earliest) energy deposition in this cell, units ns
+    params.m_time = hit->getTime();
+
+    //        pandora::InputFloat             m_inputEnergy;              ///< Corrected energy of calorimeter cell in user framework, units GeV
+    params.m_inputEnergy = hit->getEnergy(); //TODO apply sampling fraction
+
+    //        pandora::InputFloat             m_mipEquivalentEnergy;      ///< The calibrated mip equivalent energy, units mip
+    params.m_mipEquivalentEnergy = 1.0; //TODO calibrate to muon signal
+
+    //        pandora::InputFloat             m_electromagneticEnergy;    ///< The calibrated electromagnetic energy measure, units GeV
+    params.m_electromagneticEnergy = hit->getEnergy();
+
+    //        pandora::InputFloat             m_hadronicEnergy;           ///< The calibrated hadronic energy measure, units GeV
+    params.m_hadronicEnergy = hit->getEnergy();
+
+    //        pandora::InputBool              m_isDigital;                ///< Whether cell should be treated as digital
+    params.m_isDigital = false;
+
+    //        pandora::InputHitType           m_hitType;                  ///< The type of calorimeter hit
+    params.m_hitType = pandora::ECAL;
+
+    //        pandora::InputDetectorRegion    m_detectorRegion;           ///< Region of the detector in which the calo hit is located
+    params.m_detectorRegion = pandora::BARREL;
+
+    //        pandora::InputUInt              m_layer;                    ///< The subdetector readout layer number
+    params.m_layer = layer;
+
+    //        pandora::InputAddress           m_pParentAddress;           ///< Address of the parent calo hit in the user framework
+    params.m_pParentAddress = hit; //TODO make sure this doesn't break anything since it is SimCalorimeterHit, not CalorimeterHit
+
+    return params;
+}
+
+void SlicPandoraPFANewProcessor::CreateECalCaloHits(const LCEvent * const pLCEvent)
+{
+    std::string collectionToFetch = "CalorimeterHits";
+    //    std::string collectionToFetch = "EcalBarrelHits";
+    const LCCollection *pCaloHitCollection = pLCEvent->getCollection(collectionToFetch);
+    int nHits = pCaloHitCollection->getNumberOfElements();
+    std::cout << collectionToFetch << " contains " << nHits << " hits" << std::endl;
+    for (int i = 0; i < pCaloHitCollection->getNumberOfElements(); ++i)
+    {
+        CalorimeterHit *pCaloHit = dynamic_cast<CalorimeterHit*> (pCaloHitCollection->getElementAt(i));
+        //           m_calorimeterHitVector.push_back(pCaloHit);
+        //printSimCalorimeterHit(pCaloHit);
+        //printCalorimeterHit(pCaloHit);
+        PandoraApi::CaloHit::Parameters caloHitParameters = getCalHitParameters(pCaloHit);
+        //std::cout << "hit layer " << caloHitParameters.m_layer.Get() << std::endl;
+        PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::CaloHit::Create(*m_pPandora, caloHitParameters));
+    }
+}
+
+void SlicPandoraPFANewProcessor::printSimCalorimeterHit(SimCalorimeterHit* hit)
+{
+    cout << endl;
+    cout << "    ID0    " << hit->getCellID0() << endl;
+    cout << "    ID1    " << hit->getCellID1() << endl;
+    cout << "    Energy " << hit->getEnergy() << endl;
+    const float* pos(hit->getPosition());
+    cout << "    Pos    " << pos[0] << " " << pos[1] << " " << pos[2] << endl;
+    cout << "    Time   " << hit->getTimeCont(0) << endl;
+    cout << "    Layer  " << ((hit->getCellID0() >> 13) & 0x7f) << endl;
+    cout << "    Module " << ((hit->getCellID0() >> 9) & 0xF) << endl;
+}
+
+void SlicPandoraPFANewProcessor::printCalorimeterHit(CalorimeterHit* hit)
+{
+    cout << endl;
+    cout << "    ID0    " << hit->getCellID0() << endl;
+    cout << "    ID1    " << hit->getCellID1() << endl;
+    cout << "    Energy " << hit->getEnergy() << endl;
+    const float* pos(hit->getPosition());
+    cout << "    Pos    " << pos[0] << " " << pos[1] << " " << pos[2] << endl;
+    cout << "    Time   " << hit->getTime() << endl;
+    cout << "    Layer  " << ((hit->getCellID0() >> 13) & 0x7f) << endl;
+    cout << "    Module " << ((hit->getCellID0() >> 9) & 0xF) << endl;
+}
+
+void SlicPandoraPFANewProcessor::SetDefaultSubDetectorParameters(PandoraApi::GeometryParameters::SubDetectorParameters &subDetectorParameters) const
+{
+    int nLayers = 1;
+    subDetectorParameters.m_innerRCoordinate = 0.;
+    subDetectorParameters.m_innerZCoordinate = 0.;
+    subDetectorParameters.m_innerPhiCoordinate = 0.;
+    subDetectorParameters.m_innerSymmetryOrder = 0;
+    subDetectorParameters.m_outerRCoordinate = 0.;
+    subDetectorParameters.m_outerZCoordinate = 0.;
+    subDetectorParameters.m_outerPhiCoordinate = 0.;
+    subDetectorParameters.m_outerSymmetryOrder = 0;
+    subDetectorParameters.m_nLayers = nLayers;
+
+    for (int i = 0; i < nLayers; ++i)
+    {
+        PandoraApi::Geometry::Parameters::LayerParameters layerParameters;
+        layerParameters.m_closestDistanceToIp = 0.;
+        layerParameters.m_nRadiationLengths = 0.;
+        layerParameters.m_nInteractionLengths = 0.;
+        subDetectorParameters.m_layerParametersList.push_back(layerParameters);
+    }
+}
+
+void SlicPandoraPFANewProcessor::SetEcalEndcapDetectorParameters(PandoraApi::GeometryParameters::SubDetectorParameters &subDetectorParameters) const
+{
+    int nLayers = 1;
+    subDetectorParameters.m_innerRCoordinate = 0.;
+    subDetectorParameters.m_innerZCoordinate = 1657.0;
+    subDetectorParameters.m_innerPhiCoordinate = 0.;
+    subDetectorParameters.m_innerSymmetryOrder = 0;
+    subDetectorParameters.m_outerRCoordinate = 0.;
+    subDetectorParameters.m_outerZCoordinate = 0.;
+    subDetectorParameters.m_outerPhiCoordinate = 0.;
+    subDetectorParameters.m_outerSymmetryOrder = 0;
+    subDetectorParameters.m_nLayers = nLayers;
+
+    for (int i = 0; i < nLayers; ++i)
+    {
+        PandoraApi::Geometry::Parameters::LayerParameters layerParameters;
+        layerParameters.m_closestDistanceToIp = 0.;
+        layerParameters.m_nRadiationLengths = 0.;
+        layerParameters.m_nInteractionLengths = 0.;
+        subDetectorParameters.m_layerParametersList.push_back(layerParameters);
+    }
+}
+
+void SlicPandoraPFANewProcessor::SetHcalBarrelDetectorParameters(PandoraApi::GeometryParameters::SubDetectorParameters &subDetectorParameters) const
+{
+    int nLayers = 40;
+    subDetectorParameters.m_innerRCoordinate = 1419.0;
+    subDetectorParameters.m_innerZCoordinate = 3018.0;
+    subDetectorParameters.m_innerPhiCoordinate = 0.;
+    subDetectorParameters.m_innerSymmetryOrder = 12;
+    subDetectorParameters.m_outerRCoordinate = 2495.0; //40*(18.9+1.1+1.2+1.1+3.0+1.6)+1419
+    subDetectorParameters.m_outerZCoordinate = 3018.0;
+    subDetectorParameters.m_outerPhiCoordinate = 0.;
+    subDetectorParameters.m_outerSymmetryOrder = 12;
+    subDetectorParameters.m_nLayers = nLayers;
+
+    double layerThickness = 18.9 + 1.1 + 1.2 + 1.1 + 3.0 + 1.6; // 26.9 Steel+glass+gas+glass+g10+air
+    double offset = 1419.0 + 18.9 + 1.1 + 1.2 / 2.; // rmin + steel + glass + half gas thickness
+    for (int i = 0; i < nLayers; ++i)
+    {
+        PandoraApi::Geometry::Parameters::LayerParameters layerParameters;
+        layerParameters.m_closestDistanceToIp = offset;
+        offset += layerThickness;
+        layerParameters.m_nRadiationLengths = 1.0; //TODO fix this
+        layerParameters.m_nInteractionLengths = 1.0; //TODO fix this
+        subDetectorParameters.m_layerParametersList.push_back(layerParameters);
+    }
+}
+
+StatusCode SlicPandoraPFANewProcessor::registerUserAlgorithmFactories()
+{
+    pandora::AlgorithmFactory* pfac = new PfoConstructionAlgorithm::Factory();
+    PandoraApi::RegisterAlgorithmFactory(*m_pPandora, "PFO_Construction", pfac);
+    return STATUS_CODE_SUCCESS;
+}

slicPandora/tests
PandoraSettings.xml added at 1.1
diff -N PandoraSettings.xml
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ PandoraSettings.xml	8 Jan 2010 22:55:34 -0000	1.1
@@ -0,0 +1,55 @@
+<!-- Pandora settings xml file -->
+
+<pandora>
+
+    <!-- Select the tracks to use for clustering -->
+    <algorithm type = "TrackSelection">
+    </algorithm>
+
+    <!-- Photon clustering algorithm runs Clustering algorithm and saves a photon cluster list under a specified name-->
+    <algorithm type = "PhotonClustering">
+        <algorithm type = "Clustering" description = "ClusterFormation">
+        </algorithm>
+        <algorithm type = "TopologicalAssociation" description = "ClusterAssociation">
+        </algorithm>
+        <photonClusterListName> PhotonClusterList </photonClusterListName>
+    </algorithm>
+
+    <!-- Primary clustering algorithm runs Clustering algorithm -->
+    <algorithm type = "PrimaryClustering">
+        <algorithm type = "Clustering" description = "ClusterFormation">
+        </algorithm>
+        <algorithm type = "TopologicalAssociation" description = "ClusterAssociation">
+        </algorithm>
+        <clusterListName> PrimaryClusterList </clusterListName>
+    </algorithm>
+
+    <!-- Reclustering algorithm runs multiple Clustering algorithms -->
+    <algorithm type = "Reclustering">
+        <clusteringAlgorithms>
+            <algorithm type = "Clustering">
+            </algorithm>
+
+            <algorithm type = "Clustering">
+            </algorithm>
+
+            <algorithm type = "Clustering">
+            </algorithm>
+
+            <algorithm type = "Clustering">
+            </algorithm>
+        </clusteringAlgorithms>
+
+        <algorithm type = "TopologicalAssociation" description = "ClusterAssociation">
+        </algorithm>
+    </algorithm>
+
+    <!-- Perform fragment removal -->
+    <algorithm type = "FragmentRemoval">
+    </algorithm>
+
+    <!-- Create the final particle flow objects -->
+    <algorithm type = "PFO_Construction">
+    </algorithm>
+
+</pandora>
\ No newline at end of file

slicPandora/tests
main.cpp added at 1.1
diff -N main.cpp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ main.cpp	8 Jan 2010 22:55:34 -0000	1.1
@@ -0,0 +1,158 @@
+/* 
+ * File:   main.cpp
+ * Author: ngraf
+ *
+ * Created on December 1, 2009, 2:18 AM
+ */
+
+#include <stdlib.h>
+#include <iostream>
+
+#include "lcio.h"
+
+#include "IO/LCReader.h"
+#include "IO/LCWriter.h"
+#include "IMPL/LCTOOLS.h"
+#include "EVENT/LCRunHeader.h"
+
+
+#include "SlicPandoraPFANewProcessor.h"
+#include "CalorimeterHitMaker.h"
+
+static std::vector<std::string> FILEN;
+
+using namespace std;
+using namespace lcio;
+
+/*
+ * 
+ */
+int main(int argc, char** argv)
+{
+    cout << "Hello from sidPandora" << endl;
+
+
+    // read file names from command line (only argument)
+    if (argc < 2)
+    {
+        cout << " usage:  slicpandoramain <input-file1> <pandora settings xml file>" << endl;
+        exit(1);
+    }
+    //    for (int i = 1; i < argc; i++)
+    //    {
+    FILEN.push_back(argv[1]);
+    string xmlFileName = argv[2];
+    cout << "Processing file " << argv[1] << endl;
+    cout << "using " << xmlFileName << endl;
+    //    }
+    int nFiles = 1;
+
+    LCReader* lcReader = LCFactory::getInstance()->createLCReader();
+
+    LCWriter* lcWriter = LCFactory::getInstance()->createLCWriter();
+    try
+    {
+        lcWriter->setCompressionLevel(9);
+        lcWriter->open("reco.slcio", LCIO::WRITE_NEW);
+    } catch (IOException& e)
+    {
+        cout << "[RunEventProcessor()] Can't open file for writing -  "
+                << e.what() << endl;
+        exit(1);
+    }
+
+
+    // first we read the run information
+
+    cout << "creating processors" << endl;
+    CalorimeterHitMaker chitmaker;
+    SlicPandoraPFANewProcessor processor(xmlFileName);
+
+    //    PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::ReadSettings(_pandora, "C:/work/ilc/software/C++/PandoraPFA/PandoraSettings.xml"));
+    // for reading from one file only use sth. like:
+    //  const char* FILEN = "recjob.slcio" ;
+    //    cout << " will open and read from files: " << endl;
+    //    for (int i = 0; i < nFiles; i++)
+    //    {
+    //        cout << "     " << FILEN[i] << endl;
+    //    }
+
+    int maxNumberOfEvents = 1;
+    int events = 0;
+
+    //
+    //    lcReader->open(FILEN);
+    //    LCRunHeader *runHdr;
+    //
+    //    // use a try catch block here: if sth. went wrong with reading the run data we
+    //    // still can try and read the event data - see below
+    //    try
+    //    {
+    //        // loop over all run headers
+    //        while ((runHdr = lcReader->readNextRunHeader()) != 0)
+    //        {
+    //            LCTOOLS::dumpRunHeader(runHdr);
+    //            //       cout << "  Run : " << runHdr->getRunNumber()
+    //            //         << " - "      << runHdr->getDetectorName()
+    //            //         << ":  "      << runHdr->getDescription()  << endl ;
+    //
+    ////        PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->CreateTracks(pLCEvent));
+    ////        PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->CreateCaloHits(pLCEvent));
+    ////        PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::ProcessEvent(m_pandora));
+    ////        PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->ProcessParticleFlowObjects(pLCEvent));
+    ////        PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::Reset(m_pandora));
+    //            if(++events >= maxNumberOfEvents) break;
+    //        }
+    //
+    //    } catch (IOException& e)
+    //    {
+    //        cout << " io error when reading run data : " << e.what() << endl;
+    //    }
+    //    cout << endl;
+    //
+    //    lcReader->close();
+
+
+    // now loop over the file again and dump event data
+
+    lcReader->open(FILEN);
+
+    //  cout << " reopened " << FILEN << " for reading " << endl ;
+    cout << " will open and read from files: " << endl;
+    for (int i = 0; i < nFiles; i++)
+    {
+        cout << "     " << FILEN[i] << endl;
+    }
+
+    LCEvent* evt;
+    int nEvents = 0;
+
+    //----------- the event loop -----------
+    while ((evt = lcReader->readNextEvent()) != 0)
+    {
+        LCTOOLS::dumpEvent(evt);
+        // create CalorimeterHits...
+        chitmaker.processEvent(evt);
+        // run pandoraPFA...
+        processor.processEvent(evt);
+        cout << " done with processing this event" << endl;
+        // print out the contents of the reconstruction
+        LCTOOLS::dumpEvent(evt);
+        lcWriter->writeEvent(evt);
+        if (++nEvents >= maxNumberOfEvents) break;
+
+    }
+    // -------- end of event loop -----------
+
+    cout << endl << "  " << nEvents << " events read from files: " << endl;
+    for (int i = 0; i < nFiles; i++)
+    {
+        cout << "     " << FILEN[i] << endl;
+    }
+
+    lcReader->close();
+    lcWriter->close();
+
+    delete lcReader;
+    return (EXIT_SUCCESS);
+}
CVSspam 0.2.8