Print

Print


Commit in lcdd on MAIN
include/CalorimeterHitProcessor.hh+25added 1.1
       /CellReadout.hh+64added 1.1
src/CalorimeterHitProcessor.cc+72added 1.1
+161
3 added files
some ideas for new segmentation classes; will eventually be moved from LCDD

lcdd/include
CalorimeterHitProcessor.hh added at 1.1
diff -N CalorimeterHitProcessor.hh
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ CalorimeterHitProcessor.hh	18 Jun 2013 19:56:18 -0000	1.1
@@ -0,0 +1,25 @@
+#ifndef lcdd_CalorimeterHitProcessor_hh
+#define lcdd_CalorimeterHitProcessor_hh 1
+
+// Geant4
+#include "G4Step.hh"
+
+// LCDD
+#include "CellReadout.hh"
+
+class CalorimeterHitProcessor
+{
+
+public:
+    CalorimeterHitProcessor(CellReadout*);
+    virtual ~CalorimeterHitProcessor();
+
+public:
+    bool processHits(G4Step*);
+
+private:
+    CellReadout* m_readout;
+};
+
+
+#endif

lcdd/include
CellReadout.hh added at 1.1
diff -N CellReadout.hh
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ CellReadout.hh	18 Jun 2013 19:56:18 -0000	1.1
@@ -0,0 +1,64 @@
+#ifndef lcdd_CellReadout_hh
+#define lcdd_CellReadout_hh 1
+
+#include <vector>
+#include <map>
+#include <string>
+
+/**
+ * Pure virtual base class for cell readouts to implement.
+ */
+class CellReadout
+{
+
+public:
+
+    /** A 2D position, which will usually be XY in the local coordinate system. */
+    typedef std::pair<double, double> Position2D;
+
+    /** A cell ID as a list of int values. */
+    typedef std::vector<int> CellId;
+
+    /** A list of a cell's neighbor IDs. */
+    typedef std::vector<CellId> Neighbors;
+
+    /** A list of the field names for this readout. */
+    typedef std::vector<std::string> FieldNames;
+
+public:
+
+    /**
+     * Class constructor.
+     */
+    CellReadout();
+
+    /**
+     * Class destructor.
+     */
+    virtual ~CellReadout();
+
+    /**
+     * Compute cell ID from local position.
+     */
+    virtual CellId cellId(Position2D) = 0;
+
+    /**
+     * Compute local position of a cell ID.
+     */
+    virtual Position2D position(CellId) = 0;
+
+    /**
+     * Create a list of neighbor cells from a cell ID.
+     */
+    virtual Neighbors neighbors(CellId) = 0;
+
+    /**
+     * Get the list of field names.
+     */
+    const FieldNames& fieldNames();
+
+protected:
+    FieldNames m_fieldNames;
+};
+
+#endif

lcdd/src
CalorimeterHitProcessor.cc added at 1.1
diff -N CalorimeterHitProcessor.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ CalorimeterHitProcessor.cc	18 Jun 2013 19:56:18 -0000	1.1
@@ -0,0 +1,72 @@
+#include "CalorimeterHitProcessor.hh"
+
+// STL
+#include <iostream>
+
+// Geant4
+#include "G4NavigationHistory.hh"
+
+CalorimeterHitProcessor::CalorimeterHitProcessor(CellReadout* readout)
+    : m_readout(readout)
+{
+}
+
+CalorimeterHitProcessor::~CalorimeterHitProcessor()
+{
+}
+
+bool CalorimeterHitProcessor::processHits(G4Step* step)
+{
+    // Compute step mid-point.
+    G4ThreeVector midpoint = (0.5 * (step->GetPreStepPoint()->GetPosition() + step->GetPostStepPoint()->GetPosition()));
+
+    // DEBUG
+    //std::cout << "midpoint(x,y,z) = " << midpoint.x() << ", " << midpoint.y() << ", " << midpoint.z() << std::endl;
+
+    // Get the touchable handle from the step.
+    G4TouchableHandle touchable = step->GetPreStepPoint()->GetTouchableHandle();
+
+    // Compute local position using global position and touchable.
+    G4ThreeVector localPosition = touchable->GetHistory()->GetTopTransform().TransformPoint(midpoint);
+
+    // DEBUG
+    //std::cout << "localPosition(x,y,z) = " << localPosition.x() << ", " << localPosition.y() << ", " << localPosition.z() << std::endl;
+
+    // Get the cell ID from the position.
+    CellReadout::Position2D readoutPosition;
+    readoutPosition.first = localPosition.x();
+    readoutPosition.second = localPosition.y();
+    CellReadout::CellId cellId = m_readout->cellId(readoutPosition);
+
+    // DEBUG: print neighbors
+    //CellReadout::Neighbors neighbors = m_readout->neighbors(cellId);
+    //std::cout << "# neighbors = " << neighbors.size() << std::endl;
+    //for (CellReadout::Neighbors::iterator it = neighbors.begin(); it != neighbors.end(); ++it) {
+    //    CellReadout::CellId neighborId = *it;
+    //    std::cout << "neighbor(x,y) = " << neighborId[0] << ", " << neighborId[1] << std::endl;
+    //}
+
+    // DEBUG: print cell ID
+    //std::cout << "cellId(x,y) = " << cellId[0] << ", " << cellId[1] << std::endl;
+
+    // Get the local cell position from the cell ID.
+    CellReadout::Position2D cellPosition = m_readout->position(cellId);
+
+    // DEBUG: print local cell position
+    //std::cout << "cellPosition = " << cellPosition.first << ", " << cellPosition.second << std::endl;
+
+    // Transform local cell position to global.
+    G4ThreeVector cellVec(cellPosition.first, cellPosition.second, 0);
+
+    // Compute global position using local point and touchable.
+    G4ThreeVector globalPos = touchable->GetHistory()->GetTopTransform().Inverse().TransformPoint(cellVec);
+
+    // DEBUG: print global position
+    //std::cout << "globalPosition(x,y,z) = " << globalPos.x() << ", " << globalPos.x() << ", " << globalPos.z() << std::endl;
+    //std::cout << std::endl;
+
+    // TODO: make and return or store hit data from id, position, energy, & time
+    //G4CalorimeterHit* hit = new G4CalorimeterHit();
+
+    return true;
+}
CVSspam 0.2.12


Use REPLY-ALL to reply to list

To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1