2 added + 6 modified, total 8 files
slicPandora/src
diff -N IDDecoder.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ IDDecoder.cpp 24 Feb 2010 01:13:49 -0000 1.1
@@ -0,0 +1,24 @@
+#include "IDDecoder.h"
+
+int IDDecoder::getFieldValue(int index, long id)
+{
+ IDField* field = m_indexMap[index];
+ int start = field->getStart();
+ int length = field->getLength();
+ int mask = (1<<length) - 1;
+ int result = (int) ((id >> start) & mask);
+ if (field->isSigned())
+ {
+ int signBit = 1<<(length-1);
+ if ((result & signBit) != 0) result -= (1<<length);
+ }
+ return result;
+}
+
+int IDDecoder::getFieldValue(const std::string& name, long id)
+{
+ return getFieldValue(getFieldIndex(name), id);
+}
+
+
+
slicPandora/src
diff -u -r1.1 -r1.2
--- DetectorGeometry.cpp 23 Feb 2010 02:27:26 -0000 1.1
+++ DetectorGeometry.cpp 24 Feb 2010 01:13:49 -0000 1.2
@@ -1,9 +1,14 @@
#include "DetectorGeometry.h"
+// slicPandora
+#include "IDDecoder.h"
+
+// stl
#include <stdexcept>
#include <cstdio>
#include <cstring>
+// tinyxml
#include "tinyxml.h"
using namespace std;
@@ -160,6 +165,11 @@
printf("\n" );
}
+PandoraApi::GeometryParameters::SubDetectorParameters* DetectorGeometry::getSubDetectorFromType(const std::string& subdetType)
+{
+ return getSubDetectorFromType(subdetType.c_str());
+}
+
PandoraApi::GeometryParameters::SubDetectorParameters* DetectorGeometry::getSubDetectorFromType(const char* subdetType)
{
if ( strcmp( subdetType, "EM_BARREL" ) == 0 )
slicPandora/src
diff -u -r1.1 -r1.2
--- JobManager.cpp 23 Feb 2010 02:27:26 -0000 1.1
+++ JobManager.cpp 24 Feb 2010 01:13:49 -0000 1.2
@@ -77,6 +77,11 @@
return STATUS_CODE_SUCCESS;
}
+DetectorGeometry* JobManager::getDetectorGeometry()
+{
+ return m_detectorGeometry;
+}
+
StatusCode JobManager::run()
{
initialize();
slicPandora/src
diff -u -r1.1 -r1.2
--- SimCalorimeterHitProcessor.cpp 23 Feb 2010 02:27:26 -0000 1.1
+++ SimCalorimeterHitProcessor.cpp 24 Feb 2010 01:13:49 -0000 1.2
@@ -1,7 +1,12 @@
#include "SimCalorimeterHitProcessor.h"
+// pandora
+#include "Api/PandoraApi.h"
+
+// slicPandora
#include "JobManager.h"
#include "JobConfig.h"
+#include "DetectorGeometry.h"
SimCalorimeterHitProcessor::SimCalorimeterHitProcessor()
: EventProcessor("SimCalorimeterHitProcessor")
@@ -11,68 +16,19 @@
{;}
void SimCalorimeterHitProcessor::processEvent(EVENT::LCEvent* event)
-{
+{
+ JobManager* mgr = getJobManager();
+ DetectorGeometry* geom = mgr->getDetectorGeometry();
+ DetectorGeometry::ExtraSubDetectorParametersMap* subdetExtras = geom->getExtraParameters();
JobConfig::CalorimeterTypes calTypes = getJobManager()->getJobConfig()->getCalorimeterTypes();
for (JobConfig::CalorimeterTypes::iterator iter = calTypes.begin();
iter != calTypes.end();
iter++)
{
-
+ PandoraApi::GeometryParameters::SubDetectorParameters* subdet = geom->getSubDetectorFromType((*iter));
+ const DetectorGeometry::ExtraSubDetectorParameters& subdetX = subdetExtras->at((*iter));
+
}
}
-/*
-void SimCalorimeterHitProcessor::processEvent(EVENT::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/include
diff -N IDDecoder.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ IDDecoder.h 24 Feb 2010 01:13:49 -0000 1.1
@@ -0,0 +1,107 @@
+#ifndef IDDecoder_h
+#define IDDecoder_h 1
+
+#include <string>
+#include <vector>
+#include <map>
+
+/**
+ * This class extracts field values from 64-bit identifiers based on an identifier
+ * description. It provides similar functionality to the GeomConverter Java class
+ * org.lcsim.geometry.util.IDDecoder (NOT the org.lcsim.geometry.IDDecoder interface).
+ */
+class IDDecoder
+{
+
+public:
+
+ class IDField
+ {
+ public:
+
+ IDField(const std::string& name, int start, int length, bool isSigned)
+ : m_name(name), m_start(start), m_length(length), m_signed(isSigned)
+ {;}
+
+ virtual ~IDField()
+ {;}
+
+ const std::string& getName()
+ {
+ return m_name;
+ }
+
+ const int getStart()
+ {
+ return m_start;
+ }
+
+ const int getLength()
+ {
+ return m_length;
+ }
+
+ const bool isSigned()
+ {
+ return m_signed;
+ }
+
+ private:
+ std::string m_name;
+ int m_start;
+ int m_length;
+ bool m_signed;
+ };
+
+public:
+
+ typedef std::vector<IDField*> IDFields;
+ typedef std::map<int,IDField*> IndexedFieldMap;
+ typedef std::map<std::string,IDField*> NamedFieldMap;
+ typedef std::map<std::string,int> Name2IndexMap;
+
+ IDDecoder(IDFields fields)
+ : m_fields(fields)
+ {
+ // Setup the field maps.
+ int i=0;
+ for (IDFields::iterator iter = fields.begin();
+ iter != fields.end();
+ iter++)
+ {
+ m_indexMap[i] = (*iter);
+ m_nameMap[(*iter)->getName()] = (*iter);
+ m_name2IndexMap[(*iter)->getName()] = i;
+ i++;
+ }
+ }
+
+ virtual ~IDDecoder()
+ {;}
+
+ int getFieldValue(int index, long id);
+ int getFieldValue(const std::string& name, long id);
+
+ IDField* getField(int index)
+ {
+ return m_indexMap[index];
+ }
+
+ IDField* getField(const std::string& name)
+ {
+ return m_nameMap[name];
+ }
+
+ int getFieldIndex(const std::string& name)
+ {
+ return m_name2IndexMap[name];
+ }
+
+private:
+ IDFields m_fields;
+ IndexedFieldMap m_indexMap;
+ NamedFieldMap m_nameMap;
+ Name2IndexMap m_name2IndexMap;
+};
+
+#endif
slicPandora/include
diff -u -r1.2 -r1.3
--- DetectorGeometry.h 23 Feb 2010 02:27:26 -0000 1.2
+++ DetectorGeometry.h 24 Feb 2010 01:13:49 -0000 1.3
@@ -3,6 +3,8 @@
#include "Api/PandoraApi.h"
+class IDDecoder;
+
class DetectorGeometry
{
@@ -15,6 +17,7 @@
pandora::InputFloat m_cellSizeU;
pandora::InputFloat m_cellSizeV;
std::string m_collection;
+ IDDecoder* m_decoder;
};
typedef std::map<std::string, ExtraSubDetectorParameters> ExtraSubDetectorParametersMap;
@@ -40,8 +43,8 @@
void printOut(const char* subdetType, PandoraApi::GeometryParameters::SubDetectorParameters* subdet);
-private:
- PandoraApi::GeometryParameters::SubDetectorParameters* getSubDetectorFromType( const char* );
+ PandoraApi::GeometryParameters::SubDetectorParameters* getSubDetectorFromType(const char*);
+ PandoraApi::GeometryParameters::SubDetectorParameters* getSubDetectorFromType(const std::string&);
private:
PandoraApi::Geometry::Parameters geom;
slicPandora/include
diff -u -r1.1 -r1.2
--- JobManager.h 23 Feb 2010 02:27:27 -0000 1.1
+++ JobManager.h 24 Feb 2010 01:13:49 -0000 1.2
@@ -25,6 +25,8 @@
void addEventProcessor(EventProcessor*);
+ DetectorGeometry* getDetectorGeometry();
+
StatusCode run();
private:
slicPandora/tests
diff -u -r1.1 -r1.2
--- JobManagerTest.cpp 23 Feb 2010 02:27:27 -0000 1.1
+++ JobManagerTest.cpp 24 Feb 2010 01:13:49 -0000 1.2
@@ -1,20 +1,25 @@
+// $Id: JobManagerTest.cpp,v 1.2 2010/02/24 01:13:49 jeremy Exp $
+
#include "JobConfig.h"
#include "JobManager.h"
#include "DummyProcessor.h"
+#include "SimCalorimeterHitProcessor.h"
int main(int argc, char** argv)
{
JobConfig* config = new JobConfig();
config->setPandoraSettingsXmlFile("./tests/PandoraSettings.xml");
config->setGeometryFile("./examples/sidloi2_pandora.xml");
+ config->useDefaultCalorimeterTypes();
config->addInputFile("./input.slcio");
config->setOutputFile("pandoraRecon.slcio");
config->setNumberOfEvents(1);
- config->setSkipEvents(0);
+ config->setSkipEvents(0);
JobManager* mgr = new JobManager();
mgr->setJobConfig(config);
mgr->addEventProcessor(new DummyProcessor());
+ mgr->addEventProcessor(new SimCalorimeterHitProcessor());
mgr->run();
}
CVSspam 0.2.8