4 added + 26 modified, total 30 files
lcdd/include/lcdd/detectors
diff -N HitProcessor.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ HitProcessor.hh 11 Jul 2013 20:41:54 -0000 1.1
@@ -0,0 +1,34 @@
+#ifndef LCDD_DETECTORS_HITPROCESSOR_HH
+#define LCDD_DETECTORS_HITPROCESSOR_HH 1
+
+// Geant4
+#include "G4Step.hh"
+
+/**
+ * This is a pure virtual class defining an interface for processing hits within sensitive detectors.
+ */
+class HitProcessor
+{
+
+public:
+
+ /**
+ * Class destructor.
+ */
+ virtual ~HitProcessor();
+
+ /**
+ * Process G4Step to produce hits.
+ * @param[in] step A G4Step object.
+ */
+ virtual bool processHits(G4Step* step) = 0;
+
+protected:
+
+ /**
+ * Class constructor.
+ */
+ HitProcessor();
+};
+
+#endif
lcdd/include/lcdd/detectors
diff -N LegacyCalorimeterHitProcessor.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ LegacyCalorimeterHitProcessor.hh 11 Jul 2013 20:41:54 -0000 1.1
@@ -0,0 +1,31 @@
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/LegacyCalorimeterHitProcessor.hh,v 1.1 2013/07/11 20:41:54 jeremy Exp $
+
+#ifndef LCDD_DETECTORS_LEGACYCALORIMETERHITPROCESSOR
+#define LCDD_DETECTORS_LEGACYCALORIMETERHITPROCESSOR 1
+
+// LCDD
+#include "lcdd/detectors/CalorimeterHitProcessor.hh"
+
+class LegacyCalorimeterHitProcessor : public CalorimeterHitProcessor
+{
+
+public:
+
+ /**
+ * Class constructor.
+ */
+ LegacyCalorimeterHitProcessor(CalorimeterSD* calorimeter);
+
+ /**
+ * Class destructor.
+ */
+ virtual ~LegacyCalorimeterHitProcessor();
+
+ /**
+ * Process steps to produce hits.
+ * @param[in] step A G4Step object.
+ */
+ bool processHits(G4Step* step);
+};
+
+#endif
lcdd/include/lcdd/detectors
diff -u -r1.8 -r1.9
--- CalorimeterHitProcessor.hh 10 Jul 2013 22:56:53 -0000 1.8
+++ CalorimeterHitProcessor.hh 11 Jul 2013 20:41:53 -0000 1.9
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/CalorimeterHitProcessor.hh,v 1.8 2013/07/10 22:56:53 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/CalorimeterHitProcessor.hh,v 1.9 2013/07/11 20:41:53 jeremy Exp $
#ifndef LCDD_DETECTORS_CALORIMETERHITPROCESSOR_HH
#define LCDD_DETECTORS_CALORIMETERHITPROCESSOR_HH 1
@@ -7,15 +7,13 @@
#include "G4Step.hh"
// LCDD
-#include "lcdd/detectors/CellReadout.hh"
+#include "lcdd/detectors/HitProcessor.hh"
+#include "lcdd/detectors/CalorimeterSD.hh"
/**
- * @brief Used for logical separation of hit processing from the SD classes.
- * @note This class is not currently used in the code base.
- * @todo This class should implement a pure virtual class called HitProcessor.
- * @todo Change the name to something like DefaultCalorimeterHitProcessor as there will be additional, similar classes.
+ * Interface for processing step data to produce CalorimeterHits.
*/
-class CalorimeterHitProcessor
+class CalorimeterHitProcessor : public HitProcessor
{
public:
@@ -24,7 +22,7 @@
* Class constructor.
* @param[in] ro The CellReadout used by the processor.
*/
- CalorimeterHitProcessor(CellReadout* ro);
+ CalorimeterHitProcessor(CalorimeterSD* calorimeter);
/**
* Class destructor.
@@ -35,12 +33,12 @@
/**
* Process the step to make hits.
- * @param[in] The G4Step object of the energy deposition.
+ * @param[in] step The G4Step object of the energy deposition.
*/
- bool processHits(G4Step* aStep);
+ virtual bool processHits(G4Step* step) = 0;
-private:
- CellReadout* _readout;
+protected:
+ CalorimeterSD* _calorimeter;
};
#endif
lcdd/include/lcdd/detectors
diff -u -r1.5 -r1.6
--- CalorimeterSD.hh 10 Jul 2013 18:06:17 -0000 1.5
+++ CalorimeterSD.hh 11 Jul 2013 20:41:53 -0000 1.6
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/CalorimeterSD.hh,v 1.5 2013/07/10 18:06:17 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/CalorimeterSD.hh,v 1.6 2013/07/11 20:41:53 jeremy Exp $
#ifndef LCDD_DETECTORS_CALORIMETERSD_HH
#define LCDD_DETECTORS_CALORIMETERSD_HH 1
@@ -134,6 +134,12 @@
*/
CalorimeterHitList getCalorimeterHitList(G4int nHC);
+ /**
+ * Add a hit to this Calorimeter.
+ * @param[in] hit The hit to add.
+ */
+ void addHit(CalorimeterHit* hit);
+
protected:
/**
lcdd/include/lcdd/detectors
diff -u -r1.6 -r1.7
--- CellReadout2DSegmentation.hh 10 Jul 2013 18:06:17 -0000 1.6
+++ CellReadout2DSegmentation.hh 11 Jul 2013 20:41:53 -0000 1.7
@@ -35,7 +35,7 @@
* @param[in] The Geant4 step.
* @return The cell's 3D position.
*/
- G4ThreeVector getGlobalHitPos(const G4Step* step);
+ G4ThreeVector getGlobalHitPosition(const G4Step* step);
/**
* Compute the bin values from a Geant4 step.
lcdd/include/lcdd/detectors
diff -u -r1.5 -r1.6
--- GlobalGridXYSegmentation.hh 10 Jul 2013 18:06:17 -0000 1.5
+++ GlobalGridXYSegmentation.hh 11 Jul 2013 20:41:53 -0000 1.6
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/GlobalGridXYSegmentation.hh,v 1.5 2013/07/10 18:06:17 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/GlobalGridXYSegmentation.hh,v 1.6 2013/07/11 20:41:53 jeremy Exp $
#ifndef LCDD_DETECTORS_GLOBALGRIDXYSEGMENTATION_HH
#define LCDD_DETECTORS_GLOBALGRIDXYSEGMENTATION_HH 1
@@ -37,7 +37,7 @@
* @param[in] The G4Step object.
* @return The cell global position.
*/
- G4ThreeVector getGlobalHitPos(const G4Step* aStep);
+ G4ThreeVector getGlobalHitPosition(const G4Step* aStep);
/**
* Compute a local cell position from a local step position.
lcdd/include/lcdd/detectors
diff -u -r1.6 -r1.7
--- GridXYZSegmentation.hh 10 Jul 2013 22:39:26 -0000 1.6
+++ GridXYZSegmentation.hh 11 Jul 2013 20:41:53 -0000 1.7
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/GridXYZSegmentation.hh,v 1.6 2013/07/10 22:39:26 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/GridXYZSegmentation.hh,v 1.7 2013/07/11 20:41:53 jeremy Exp $
#ifndef LCDD_DETECTORS_G4GRIDXYZSEGMENTATION_HH
#define LCDD_DETECTORS_G4GRIDXYZSEGMENTATION_HH 1
@@ -37,7 +37,7 @@
* @param[in] aStep The G4Step object.
* @return The global hit position.
*/
- G4ThreeVector getGlobalHitPos(const G4Step* aStep);
+ G4ThreeVector getGlobalHitPosition(const G4Step* aStep);
/**
* Compute the bin values from a step.
lcdd/include/lcdd/detectors
diff -u -r1.6 -r1.7
--- NonprojectiveCylinderSegmentation.hh 10 Jul 2013 22:39:26 -0000 1.6
+++ NonprojectiveCylinderSegmentation.hh 11 Jul 2013 20:41:54 -0000 1.7
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/NonprojectiveCylinderSegmentation.hh,v 1.6 2013/07/10 22:39:26 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/NonprojectiveCylinderSegmentation.hh,v 1.7 2013/07/11 20:41:54 jeremy Exp $
#ifndef LCDD_DETECTORS_G4NONPROJECTIVECYLINDERSEGMENTATION
#define LCDD_DETECTORS_G4NONPROJECTIVECYLINDERSEGMENTATION 1
@@ -33,7 +33,7 @@
* @param[in] aStep The G4Step object.
* @return The global hit position for the step.
*/
- G4ThreeVector getGlobalHitPos(const G4Step* aStep);
+ G4ThreeVector getGlobalHitPosition(const G4Step* aStep);
/**
* Compute the global hit position a step point.
lcdd/include/lcdd/detectors
diff -u -r1.7 -r1.8
--- ProjectiveSegmentation.hh 10 Jul 2013 22:39:26 -0000 1.7
+++ ProjectiveSegmentation.hh 11 Jul 2013 20:41:54 -0000 1.8
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/ProjectiveSegmentation.hh,v 1.7 2013/07/10 22:39:26 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/ProjectiveSegmentation.hh,v 1.8 2013/07/11 20:41:54 jeremy Exp $
#ifndef LCDD_DETECTORS_PROJECTIVESEGMENTATION_HH
#define LCDD_DETECTORS_PROJECTIVESEGMENTATION_HH 1
@@ -34,7 +34,7 @@
* @param[in] aStep The G4Step object.
* @return The global hit position at the step.
*/
- G4ThreeVector getGlobalHitPos(const G4Step* aStep);
+ G4ThreeVector getGlobalHitPosition(const G4Step* aStep);
/**
* Compute the bin values from a step.
lcdd/include/lcdd/detectors
diff -u -r1.8 -r1.9
--- Segmentation.hh 10 Jul 2013 22:39:26 -0000 1.8
+++ Segmentation.hh 11 Jul 2013 20:41:54 -0000 1.9
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/Segmentation.hh,v 1.8 2013/07/10 22:39:26 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/Segmentation.hh,v 1.9 2013/07/11 20:41:54 jeremy Exp $
#ifndef LCDD_DETECTORS_SEGMENTATION_HH
#define LCDD_DETECTORS_SEGMENTATION_HH 1
@@ -50,7 +50,7 @@
* @param[in] aStep The Geant4 step.
* @return The hit's global position.
*/
- virtual G4ThreeVector getGlobalHitPos(const G4Step* aStep) = 0;
+ virtual G4ThreeVector getGlobalHitPosition(const G4Step* aStep) = 0;
/**
* Set the identifier bin values from a step.
@@ -69,7 +69,7 @@
* @todo n Move to G4OpticalCalorimeter.
* @warning Dummy method only. Specific Segmentation types must implement.
*/
- G4ThreeVector getLocalHitPos(const G4ThreeVector& localStepPos);
+ G4ThreeVector getLocalHitPosition(const G4ThreeVector& localStepPos);
/**
* Reset the bins values to all zero.
lcdd/include/lcdd/detectors
diff -u -r1.5 -r1.6
--- SensitiveDetector.hh 10 Jul 2013 22:39:26 -0000 1.5
+++ SensitiveDetector.hh 11 Jul 2013 20:41:54 -0000 1.6
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/SensitiveDetector.hh,v 1.5 2013/07/10 22:39:26 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/SensitiveDetector.hh,v 1.6 2013/07/11 20:41:54 jeremy Exp $
#ifndef LCDD_DETECTORS_SENSITIVEDETECTOR_HH
#define LCDD_DETECTORS_SENSITIVEDETECTOR_HH 1
@@ -9,6 +9,7 @@
// LCDD
#include "lcdd/detectors/StepReadout.hh"
+#include "lcdd/detectors/HitProcessor.hh"
#include "lcdd/id/IdSpec.hh"
#include "lcdd/id/Id64bit.hh"
@@ -36,6 +37,8 @@
static const std::string& calorimeterStr;
static const std::string& noneStr;
+ typedef std::vector<HitProcessor*> HitProcessors;
+
public:
/**
@@ -144,7 +147,7 @@
* Get the hit energy cut of this detector (GeV).
* @return The energy cut.
*/
- G4double getEcut();
+ G4double getEnergyCut();
/**
* Set the hit energy cut of this detector.
@@ -243,6 +246,25 @@
*/
virtual void clearHits();
+ /**
+ * Add a hit processor.
+ * @param[in] processor The hit processor.
+ */
+ void addHitProcessor(HitProcessor* processor);
+
+ /**
+ * Create a 64-bit identifier based on the current step information.
+ * @return A 64-bit identifier from the current step.
+ */
+ Id64bit makeId() const;
+
+ /**
+ * Create a 64-bit identifier based on the step information.
+ * @param[in] step A G4Step object.
+ * @return A 64-bit identifier from the current step.
+ */
+ Id64bit makeIdentifier(G4Step* step) const;
+
protected:
/**
@@ -258,12 +280,6 @@
G4VHitsCollection* getHitsCollection(G4int) const;
/**
- * Create a 64-bit identifier based on the current step information.
- * @return A 64-bit identifier from the current step.
- */
- Id64bit makeId() const;
-
- /**
* Set the Hits Collection ID.
* @param[in] The hit collection ID.
*/
@@ -300,6 +316,9 @@
// The Geant4 command messenger associated with this detector.
G4UImessenger* _messenger;
+
+ // List of hit processors to be called for each step.
+ HitProcessors _hitProcessors;
};
#endif
lcdd/include/lcdd/hits
diff -u -r1.7 -r1.8
--- CalorimeterHit.hh 10 Jul 2013 22:39:26 -0000 1.7
+++ CalorimeterHit.hh 11 Jul 2013 20:41:54 -0000 1.8
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/hits/CalorimeterHit.hh,v 1.7 2013/07/10 22:39:26 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/lcdd/hits/CalorimeterHit.hh,v 1.8 2013/07/11 20:41:54 jeremy Exp $
#ifndef LCDD_HITS_CALORIMETERHIT_HH
#define LCDD_HITS_CALORIMETERHIT_HH 1
@@ -112,7 +112,7 @@
* Increment the energy deposition by some amount.
* @param[in] edincr The amount to increment the energy (GeV).
*/
- void incrEdep(const G4double edincr);
+ void addEnergyDeposition(const G4double edincr);
/**
* Get the global position of the hit.
lcdd/include/lcdd/util
diff -u -r1.7 -r1.8
--- StoreInspector.hh 10 Jul 2013 18:06:19 -0000 1.7
+++ StoreInspector.hh 11 Jul 2013 20:41:54 -0000 1.8
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/util/StoreInspector.hh,v 1.7 2013/07/10 18:06:19 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/lcdd/util/StoreInspector.hh,v 1.8 2013/07/11 20:41:54 jeremy Exp $
#ifndef LCDD_UTIL_STOREINSPECTOR_HH
#define LCDD_UTIL_STOREINSPECTOR_HH 1
@@ -388,7 +388,7 @@
os << "HC: " << sd.getHCName() << endl;
os << "HCID: " << sd.getHCID() << endl;
os << "verbose: " << sd.getVerbose() << endl;
- os << "ecut: " << sd.getEcut() << endl;
+ os << "ecut: " << sd.getEnergyCut() << endl;
os << "hasIdSpec: " << sd.hasIdSpec() << endl;
os << "isEndcap: " << sd.getEndcapFlag() << endl;
os << "isActive: " << sd.isActive() << endl;
lcdd/src/lcdd/detectors
diff -N HitProcessor.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ HitProcessor.cc 11 Jul 2013 20:41:54 -0000 1.1
@@ -0,0 +1,9 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/HitProcessor.cc,v 1.1 2013/07/11 20:41:54 jeremy Exp $
+
+#include "lcdd/detectors/HitProcessor.hh"
+
+HitProcessor::HitProcessor()
+{}
+
+HitProcessor::~HitProcessor()
+{}
lcdd/src/lcdd/detectors
diff -N LegacyCalorimeterHitProcessor.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ LegacyCalorimeterHitProcessor.cc 11 Jul 2013 20:41:54 -0000 1.1
@@ -0,0 +1,78 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/LegacyCalorimeterHitProcessor.cc,v 1.1 2013/07/11 20:41:54 jeremy Exp $
+
+// LCDD
+#include "lcdd/detectors/LegacyCalorimeterHitProcessor.hh"
+
+// Geant4
+#include "G4Geantino.hh"
+#include "G4ChargedGeantino.hh"
+
+LegacyCalorimeterHitProcessor::LegacyCalorimeterHitProcessor(CalorimeterSD* calorimeter)
+ : CalorimeterHitProcessor(calorimeter)
+{}
+
+LegacyCalorimeterHitProcessor::~LegacyCalorimeterHitProcessor()
+{}
+
+bool LegacyCalorimeterHitProcessor::processHits(G4Step* step)
+{
+ // Get the energy deposition.
+ G4double edep = step->GetTotalEnergyDeposit();
+
+ // Check for Geantino particle type.
+ G4ParticleDefinition* def = step->GetTrack()->GetDefinition();
+ bool isGeantino = false;
+ if (def == G4Geantino::Definition() || def == G4ChargedGeantino::Definition()) {
+ isGeantino = true;
+ }
+
+ // Cut on energy deposition <= cut but allow Geantinos.
+ if (edep <= _calorimeter->getEnergyCut() && isGeantino == false) {
+ return false;
+ }
+
+ // Get the Segmentation from the CalorimeterSD.
+ Segmentation* segmentation = _calorimeter->getSegmentation();
+
+ // Get the global cell position from the Segmentation.
+ G4ThreeVector globalCellPos = segmentation->getGlobalHitPosition(step);
+
+ // Reset the Segmentation bin values.
+ // FIXME: This could be called from Segmentation::setBins() method.
+ segmentation->resetBins();
+
+ // Set the segmentation bin values from the step.
+ segmentation->setBins(step);
+
+ // Create a 64-bit ID from the step information.
+ Id64bit id = _calorimeter->makeIdentifier(step);
+
+ // Create a new hit.
+ CalorimeterHit* newHit = new CalorimeterHit(edep, globalCellPos);
+
+ // Set the ID on the new hit.
+ newHit->setId64bit(id.getId0(), id.getId1());
+
+ // Look for a matching hit.
+ CalorimeterHit* foundHit = 0;
+ if (!(foundHit = _calorimeter->findHit(newHit))) {
+ // Add a new hit to the SD.
+ _calorimeter->addHit(newHit);
+ } else {
+ // Delete the hit that was just created.
+ delete newHit;
+ newHit = 0;
+
+ // Increment the energy deposition of the found hit.
+ foundHit->addEnergyDeposition(edep);
+
+ // Set the previous hit pointer for adding a new energy contribution.
+ newHit = foundHit;
+ }
+
+ // Add an energy contribution to the hit.
+ newHit->addHitContribution(HitContribution(step));
+
+ // Return true, indicating that a hit was added or modified.
+ return true;
+}
lcdd/src/lcdd/detectors
diff -u -r1.3 -r1.4
--- CalorimeterHitProcessor.cc 10 Jul 2013 22:56:53 -0000 1.3
+++ CalorimeterHitProcessor.cc 11 Jul 2013 20:41:54 -0000 1.4
@@ -1,16 +1,17 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/CalorimeterHitProcessor.cc,v 1.3 2013/07/10 22:56:53 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/CalorimeterHitProcessor.cc,v 1.4 2013/07/11 20:41:54 jeremy Exp $
// LCDD
#include "lcdd/detectors/CalorimeterHitProcessor.hh"
+#include "lcdd/detectors/CalorimeterSD.hh"
// STL
-#include <iostream>
+//#include <iostream>
// Geant4
-#include "G4NavigationHistory.hh"
+//#include "G4NavigationHistory.hh"
-CalorimeterHitProcessor::CalorimeterHitProcessor(CellReadout* readout) :
- _readout(readout)
+CalorimeterHitProcessor::CalorimeterHitProcessor(CalorimeterSD* calorimeter) :
+ _calorimeter(calorimeter)
{
}
@@ -18,6 +19,7 @@
{
}
+/*
bool CalorimeterHitProcessor::processHits(G4Step* step)
{
// Compute the step's mid-point in global coordinates.
@@ -73,3 +75,4 @@
return true;
}
+*/
lcdd/src/lcdd/detectors
diff -u -r1.4 -r1.5
--- CalorimeterSD.cc 10 Jul 2013 16:49:47 -0000 1.4
+++ CalorimeterSD.cc 11 Jul 2013 20:41:54 -0000 1.5
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/CalorimeterSD.cc,v 1.4 2013/07/10 16:49:47 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/CalorimeterSD.cc,v 1.5 2013/07/11 20:41:54 jeremy Exp $
// LCDD
#include "lcdd/detectors/CalorimeterSD.hh"
@@ -26,8 +26,8 @@
SensitiveDetector(sdName, hcName, SensitiveDetector::eCalorimeter), _segmentation(sdSeg)
{
_hitsCollections.push_back(_collection);
- _hits.clear();
- _hitsVector.clear();
+ //_hits.clear();
+ //_hitsVector.clear();
_hitsVector.push_back(_hits);
if (compare == 0)
_hitCompare = new PositionComparator();
@@ -38,8 +38,8 @@
CalorimeterSD::CalorimeterSD(G4String sdName, const vector<G4String>& hcNames, Segmentation* sdSeg, HitComparator* compare) :
SensitiveDetector(sdName, hcNames, SensitiveDetector::eCalorimeter), _segmentation(sdSeg)
{
- _hits.clear();
- _hitsVector.clear();
+ //_hits.clear();
+ //_hitsVector.clear();
_hitsVector.push_back(_hits);
for (int i = 0; i < (int) hcNames.size(); i++) {
_hitsVector.push_back(_hits);
@@ -94,94 +94,7 @@
G4bool CalorimeterSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
{
-#ifdef G4VERBOSE
- if (getVerbose() > 0)
- {
- std::cout << "G4CalorimeterSD::ProcessHits - " << this->GetName() << std::endl;
- }
-#endif
-
- // set cached step
- SensitiveDetector::ProcessHits(aStep, 0);
-
- // get the edep
- G4double theEdep = edep();
-
- // This needs to be a <= comparison for cutting on 0,
- // Geantinos, which always have 0 edep, are allowed.
- if (theEdep <= getEcut() && !isGeantino()) {
-#ifdef G4VERBOSE
- if (getVerbose() > 2) {
- std::cout << "G4CalorimeterSD::ProcessHits - cut on edep " << theEdep << std::endl;
- }
-#endif
- return false;
- }
-
- // Get global cell pos from segmentation.
- G4ThreeVector globalCellPos = _segmentation->getGlobalHitPos(aStep);
-
- // Reset the segmentation bin values.
- _segmentation->resetBins();
-
- // Set the segmentation bin values from the step.
- _segmentation->setBins(aStep);
-
- // Create a 64-bit ID.
- Id64bit id64 = makeId();
-
- // DEBUG: Compute step midpoint and compare to the cell pos
-#ifdef G4VERBOSE
- if ( getVerbose() > 2 ) {
- G4ThreeVector globalMidPos = midPosition();
- std::cout << "globalMidPos " << globalMidPos << std::endl;
- std::cout << "globalCellPos - globalMidPos = " << globalCellPos - globalMidPos << std::endl;
- }
-#endif
-
- // find hit by simple lkp of new hit with above info
- CalorimeterHit* thisHit = new CalorimeterHit(theEdep, globalCellPos);
- thisHit->setId64bit(id64.getId0(), id64.getId1());
- CalorimeterHit* fndHit = 0;
-
- // hit is not found?
- if (!(fndHit = findHit(thisHit))) {
-
-#ifdef G4VERBOSE
- if (getVerbose() > 1) {
- std::cout << "G4CalorimeterSD::ProcessHits - new hit" << std::endl;
- }
-#endif
- // add it to lkp map
- _hitsVector[0].push_back(thisHit);
-
- // add to the HC
- _hitsCollections[0]->insert(thisHit);
- }
- // found a hit
- else {
-
-#ifdef G4VERBOSE
- if ( getVerbose() > 2 ) {
- std::cout << "G4CalorimeterSD::ProcessHits - existing hit" << std::endl;
- }
-#endif
-
- // don't need to insert thisHit, so delete it
- delete thisHit;
- thisHit = 0;
-
- // incr total edep of the hit
- fndHit->incrEdep(theEdep);
-
- // for setting contrib
- thisHit = fndHit;
- }
-
- // add McpHitContrib to this hit, setting info from step info
- thisHit->addHitContribution(HitContribution(aStep));
-
- return true;
+ return SensitiveDetector::ProcessHits(aStep, 0);
}
CalorimeterHit* CalorimeterSD::findHit(CalorimeterHit* aHit) const
@@ -276,3 +189,11 @@
return _hitsVector[nHC];
}
+void CalorimeterSD::addHit(CalorimeterHit* hit)
+{
+ // add it to lkp map
+ _hitsVector[0].push_back(hit);
+
+ // add to the HC
+ _hitsCollections[0]->insert(hit);
+}
lcdd/src/lcdd/detectors
diff -u -r1.3 -r1.4
--- CellReadout2DSegmentation.cc 10 Jul 2013 16:49:47 -0000 1.3
+++ CellReadout2DSegmentation.cc 11 Jul 2013 20:41:54 -0000 1.4
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/CellReadout2DSegmentation.cc,v 1.3 2013/07/10 16:49:47 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/CellReadout2DSegmentation.cc,v 1.4 2013/07/11 20:41:54 jeremy Exp $
// LCDD
#include "lcdd/detectors/CellReadout2DSegmentation.hh"
@@ -23,7 +23,7 @@
delete _readout;
}
-G4ThreeVector CellReadout2DSegmentation::getGlobalHitPos(const G4Step* aStep)
+G4ThreeVector CellReadout2DSegmentation::getGlobalHitPosition(const G4Step* aStep)
{
// TODO: implement me
}
lcdd/src/lcdd/detectors
diff -u -r1.3 -r1.4
--- GlobalGridXYSegmentation.cc 9 Jul 2013 18:51:54 -0000 1.3
+++ GlobalGridXYSegmentation.cc 11 Jul 2013 20:41:54 -0000 1.4
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/GlobalGridXYSegmentation.cc,v 1.3 2013/07/09 18:51:54 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/GlobalGridXYSegmentation.cc,v 1.4 2013/07/11 20:41:54 jeremy Exp $
// LCDD
#include "lcdd/detectors/GlobalGridXYSegmentation.hh"
@@ -24,7 +24,7 @@
addBinName("z");
}
-G4ThreeVector GlobalGridXYSegmentation::getGlobalHitPos(const G4Step* aStep)
+G4ThreeVector GlobalGridXYSegmentation::getGlobalHitPosition(const G4Step* aStep)
{
// Compute the midpoint of the global step.
G4ThreeVector globalStepPos = ReadoutUtil::computeMidPos(aStep);
lcdd/src/lcdd/detectors
diff -u -r1.3 -r1.4
--- GridXYZSegmentation.cc 9 Jul 2013 18:51:54 -0000 1.3
+++ GridXYZSegmentation.cc 11 Jul 2013 20:41:54 -0000 1.4
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/GridXYZSegmentation.cc,v 1.3 2013/07/09 18:51:54 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/GridXYZSegmentation.cc,v 1.4 2013/07/11 20:41:54 jeremy Exp $
// LCDD
#include "lcdd/detectors/GridXYZSegmentation.hh"
@@ -24,7 +24,7 @@
addBinName("z");
}
-G4ThreeVector GridXYZSegmentation::getGlobalHitPos(const G4Step* aStep)
+G4ThreeVector GridXYZSegmentation::getGlobalHitPosition(const G4Step* aStep)
{
// compute midpoint
G4ThreeVector globalStepPos = ReadoutUtil::computeMidPos(aStep);
lcdd/src/lcdd/detectors
diff -u -r1.4 -r1.5
--- NonprojectiveCylinderSegmentation.cc 10 Jul 2013 22:39:26 -0000 1.4
+++ NonprojectiveCylinderSegmentation.cc 11 Jul 2013 20:41:54 -0000 1.5
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/NonprojectiveCylinderSegmentation.cc,v 1.4 2013/07/10 22:39:26 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/NonprojectiveCylinderSegmentation.cc,v 1.5 2013/07/11 20:41:54 jeremy Exp $
// LCDD
#include "lcdd/detectors/NonprojectiveCylinderSegmentation.hh"
@@ -27,7 +27,7 @@
addBinName("z");
}
-G4ThreeVector NonprojectiveCylinderSegmentation::getGlobalHitPos(const G4Step* aStep)
+G4ThreeVector NonprojectiveCylinderSegmentation::getGlobalHitPosition(const G4Step* aStep)
{
// local cell pos
G4ThreeVector localCellPos = getLocalHitPos(aStep);
lcdd/src/lcdd/detectors
diff -u -r1.3 -r1.4
--- OpticalCalorimeterSD.cc 10 Jul 2013 16:49:47 -0000 1.3
+++ OpticalCalorimeterSD.cc 11 Jul 2013 20:41:54 -0000 1.4
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/OpticalCalorimeterSD.cc,v 1.3 2013/07/10 16:49:47 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/OpticalCalorimeterSD.cc,v 1.4 2013/07/11 20:41:54 jeremy Exp $
// LCDD
#include "lcdd/detectors/OpticalCalorimeterSD.hh"
@@ -105,7 +105,7 @@
delete thisHit;
thisHit = 0;
// incr total edep of the hit
- fndHit->incrEdep(theEdep);
+ fndHit->addEnergyDeposition(theEdep);
// for setting contrib
thisHit = fndHit;
}
@@ -124,7 +124,7 @@
G4ThreeVector localStepPos = ReadoutUtil::transformGlobalToLocal(aPreStepPoint, globalStepPos);
// Compute local cell pos.
- G4ThreeVector localCellPos = this->getSegmentation()->getLocalHitPos(localStepPos);
+ G4ThreeVector localCellPos = this->getSegmentation()->getLocalHitPosition(localStepPos);
// Compute global cell pos.
G4ThreeVector globalCellPos = ReadoutUtil::transformLocalToGlobal(aPreStepPoint, localCellPos);
lcdd/src/lcdd/detectors
diff -u -r1.5 -r1.6
--- ProjectiveSegmentation.cc 10 Jul 2013 22:01:21 -0000 1.5
+++ ProjectiveSegmentation.cc 11 Jul 2013 20:41:54 -0000 1.6
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/ProjectiveSegmentation.cc,v 1.5 2013/07/10 22:01:21 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/ProjectiveSegmentation.cc,v 1.6 2013/07/11 20:41:54 jeremy Exp $
// LCDD
#include "lcdd/detectors/ProjectiveSegmentation.hh"
@@ -28,7 +28,7 @@
addBinName("phi");
}
-G4ThreeVector ProjectiveSegmentation::getGlobalHitPos(const G4Step* aStep)
+G4ThreeVector ProjectiveSegmentation::getGlobalHitPosition(const G4Step* aStep)
{
// divide entire theta, phi range into bins; bins always positive
// theta, phi coord of step midpoint
lcdd/src/lcdd/detectors
diff -u -r1.5 -r1.6
--- Segmentation.cc 10 Jul 2013 22:01:21 -0000 1.5
+++ Segmentation.cc 11 Jul 2013 20:41:54 -0000 1.6
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/Segmentation.cc,v 1.5 2013/07/10 22:01:21 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/Segmentation.cc,v 1.6 2013/07/11 20:41:54 jeremy Exp $
// LCDD
#include "lcdd/detectors/Segmentation.hh"
@@ -49,7 +49,7 @@
// return aPreStepPoint->GetPosition();
//}
-G4ThreeVector Segmentation::getLocalHitPos(const G4ThreeVector& localStepPos)
+G4ThreeVector Segmentation::getLocalHitPosition(const G4ThreeVector& localStepPos)
{
return localStepPos;
}
lcdd/src/lcdd/detectors
diff -u -r1.4 -r1.5
--- SensitiveDetector.cc 10 Jul 2013 22:43:15 -0000 1.4
+++ SensitiveDetector.cc 11 Jul 2013 20:41:54 -0000 1.5
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/SensitiveDetector.cc,v 1.4 2013/07/10 22:43:15 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/SensitiveDetector.cc,v 1.5 2013/07/11 20:41:54 jeremy Exp $
// LCDD
#include "lcdd/detectors/SensitiveDetector.hh"
@@ -63,25 +63,38 @@
SensitiveDetector::~SensitiveDetector()
{
+ // Delete registered HitProcessors.
+ for (HitProcessors::iterator it = _hitProcessors.begin(); it != _hitProcessors.end(); it++) {
+ delete (*it);
+ }
}
-void SensitiveDetector::Initialize(G4HCofThisEvent *)
+void SensitiveDetector::Initialize(G4HCofThisEvent*)
{
// no-op
}
-void SensitiveDetector::EndOfEvent(G4HCofThisEvent *)
+void SensitiveDetector::EndOfEvent(G4HCofThisEvent*)
{
// no-op
}
G4bool SensitiveDetector::ProcessHits(G4Step* aStep, G4TouchableHistory*)
{
- // set cached step
+ // Set the cached step data.
setStep(aStep);
- // doesn't write a hit
- return false;
+ // Call the processHits() methods of the registered HitProcessors.
+ bool madeHits = false;
+ for (HitProcessors::iterator it = _hitProcessors.begin(); it != _hitProcessors.end(); it++) {
+ bool processorMadeHit = (*it)->processHits(aStep);
+ if (processorMadeHit == true && madeHits == false) {
+ madeHits = true;
+ }
+ }
+
+ // This will return true if at least one processor created a hit.
+ return madeHits;
}
const std::string& SensitiveDetector::getTypeString() const
@@ -132,6 +145,20 @@
return id64;
}
+Id64bit SensitiveDetector::makeIdentifier(G4Step* step) const
+{
+ Id64bit id64;
+ if (hasIdSpec()) {
+
+ // get idvec ordered by this idspec
+ const IdVec ids = IdFactory::createOrderedIdVec(step, this);
+
+ // pack into 64 bit cell id
+ id64 = IdFactory::createId64bit(ids, getIdSpec());
+ }
+ return id64;
+}
+
G4VHitsCollection* SensitiveDetector::getHitsCollection() const
{
G4VHitsCollection* hc = 0;
@@ -231,7 +258,7 @@
return _verbose;
}
-G4double SensitiveDetector::getEcut()
+G4double SensitiveDetector::getEnergyCut()
{
return _ecut;
}
@@ -298,3 +325,8 @@
}
_hcids[nHC] = hcid;
}
+
+void SensitiveDetector::addHitProcessor(HitProcessor* processor)
+{
+ _hitProcessors.push_back(processor);
+}
lcdd/src/lcdd/detectors
diff -u -r1.2 -r1.3
--- SensitiveDetectorFactory.cc 1 Jul 2013 21:00:45 -0000 1.2
+++ SensitiveDetectorFactory.cc 11 Jul 2013 20:41:54 -0000 1.3
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/SensitiveDetectorFactory.cc,v 1.2 2013/07/01 21:00:45 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/SensitiveDetectorFactory.cc,v 1.3 2013/07/11 20:41:54 jeremy Exp $
// LCDD
#include "lcdd/detectors/SensitiveDetectorFactory.hh"
@@ -8,54 +8,56 @@
#include "lcdd/detectors/OpticalCalorimeterSD.hh"
#include "lcdd/detectors/UnsegmentedCalorimeterSD.hh"
#include "lcdd/detectors/PositionComparator.hh"
+#include "lcdd/detectors/LegacyCalorimeterHitProcessor.hh"
#include "lcdd/id/IdComparator.hh"
#include "lcdd/util/StringUtil.hh"
SensitiveDetector* SensitiveDetectorFactory::createSensitiveDetector(const SAXObject* object)
{
- //std::cout << "create SD" << std::endl;
-
SensitiveDetector* sd = 0;
-
const SensitiveDetectorType* sdt = dynamic_cast<const SensitiveDetectorType*>(object);
+ // The SAXObject must extend SensitiveDetectorType.
if (sdt) {
+ // Get the SensitiveDetector's basic type string.
std::string sd_type = sdt->get_type();
- /* Create calorimeter subdetector. */
- // TODO Check if "calorimeter" in the sd_type.
- if (sd_type == "calorimeter" || sd_type == "optical_calorimeter" || sd_type == "unsegmented_calorimeter") {
- //std::cout << "creating calorimeter" << std::endl;
+ // Create calorimeter. Valid types have "calorimeter" in their element name.
+ if (std::string::npos != sd_type.find("calorimeter")) {
+
sd = createCalorimeterSD(object);
- }
- /* Create tracker subdetector. */
- else if (sd_type == "tracker") {
+
+ // Add the default HitProcessor.
+ sd->addHitProcessor(new LegacyCalorimeterHitProcessor(dynamic_cast<CalorimeterSD*>(sd)));
+ // Create tracker.
+ } else if (sd_type == "tracker") {
sd = createTrackerSD(object);
- }
- /* Create scorer subdetector. */
- else if (sd_type == "scorer") {
+ // Create scorer.
+ } else if (sd_type == "scorer") {
sd = createScorerSD(object);
+ // Something went wrong. Type is not good.
} else {
- /* Type not recognized. */
- G4cerr << "Invalid sd_type <" << sd_type << ">." << G4endl;
- G4Exception("", "", FatalException, "Unknown SD type. Check the LCDD file.");
+ // Type is not recognized.
+ G4cerr << "Invalid sensitive detector type: " << sd_type << G4endl;
+ G4Exception("", "", FatalException, "Unknown sensitive detector type.");
}
- // set ecut and verbose
+ // Set the energy cut and verbosity.
setBaseSensitiveDetectorAttributes(sd, sdt);
- // find idspec
+ // Find the IdSpec.
IdSpec* idspec = findIdSpec(sdt);
- // set idspec, if exists (null is ok)
+ // Set the IdSpec, if it exists.
if (idspec != 0) {
sd->setIdSpec(idspec);
}
- // register the SD
+ // Register the SensitiveDetector with LCDDProcessor.
std::string sdName = sd->GetName();
LCDDProcessor::instance()->addSensitiveDetector(sdName, sd);
+ // This should never really happen!
} else {
G4Exception("", "", FatalException, "Failed cast to SensitiveDetectorType.");
}
@@ -249,10 +251,9 @@
{
bool bad = false;
- // is size <= 1 ?
+ // Ss size <= 1 ?
if (s.size() <= 1) {
bad = true;
- //std::cerr << "HCName <" << s << "> is not enough characters." << std::endl;
} else {
LCDDProcessor* proc = LCDDProcessor::instance();
for (LCDDProcessor::SensitiveDetectors::const_iterator iter = proc->getSensitiveDetectorsBegin(); iter != proc->getSensitiveDetectorsBegin(); iter++) {
lcdd/src/lcdd/detectors
diff -u -r1.2 -r1.3
--- TrackerCombineSD.cc 10 Jul 2013 16:49:47 -0000 1.2
+++ TrackerCombineSD.cc 11 Jul 2013 20:41:54 -0000 1.3
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/TrackerCombineSD.cc,v 1.2 2013/07/10 16:49:47 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/TrackerCombineSD.cc,v 1.3 2013/07/11 20:41:54 jeremy Exp $
// LCDD
#include "lcdd/detectors/TrackerCombineSD.hh"
@@ -167,7 +167,7 @@
}
// total energy below cut
- if ( _edepTotal <= getEcut() && !isGeantino() ) {
+ if ( _edepTotal <= getEnergyCut() && !isGeantino() ) {
#ifdef G4VERBOSE
if ( getVerbose() > 0 ) {
std::cout << GetName() << " : cut this edep " << _edepTotal << std::endl;
lcdd/src/lcdd/detectors
diff -u -r1.2 -r1.3
--- TrackerSD.cc 10 Jul 2013 16:49:47 -0000 1.2
+++ TrackerSD.cc 11 Jul 2013 20:41:54 -0000 1.3
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/TrackerSD.cc,v 1.2 2013/07/10 16:49:47 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/TrackerSD.cc,v 1.3 2013/07/11 20:41:54 jeremy Exp $
// LCDD
#include "lcdd/id/IdManager.hh"
@@ -50,7 +50,7 @@
G4double e = edep();
// check edep < cut
- if (e <= getEcut() && !isGeantino()) {
+ if (e <= getEnergyCut() && !isGeantino()) {
return false;
}
lcdd/src/lcdd/detectors
diff -u -r1.4 -r1.5
--- UnsegmentedCalorimeterSD.cc 10 Jul 2013 22:39:26 -0000 1.4
+++ UnsegmentedCalorimeterSD.cc 11 Jul 2013 20:41:54 -0000 1.5
@@ -1,4 +1,4 @@
-// $Id: UnsegmentedCalorimeterSD.cc,v 1.4 2013/07/10 22:39:26 jeremy Exp $
+// $Id: UnsegmentedCalorimeterSD.cc,v 1.5 2013/07/11 20:41:54 jeremy Exp $
// LCDD
#include "lcdd/detectors/UnsegmentedCalorimeterSD.hh"
@@ -31,7 +31,7 @@
* This needs to be a <= comparison for cutting on 0,
* but it allows geantinos, which always have 0 edep.
*/
- if (theEdep <= getEcut() && !isGeantino()) {
+ if (theEdep <= getEnergyCut() && !isGeantino()) {
#ifdef G4VERBOSE
if ( getVerbose() > 2 )
{
lcdd/src/lcdd/hits
diff -u -r1.4 -r1.5
--- CalorimeterHit.cc 10 Jul 2013 20:49:06 -0000 1.4
+++ CalorimeterHit.cc 11 Jul 2013 20:41:54 -0000 1.5
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/hits/CalorimeterHit.cc,v 1.4 2013/07/10 20:49:06 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/hits/CalorimeterHit.cc,v 1.5 2013/07/11 20:41:54 jeremy Exp $
// LCDD
#include "lcdd/hits/CalorimeterHit.hh"
@@ -109,7 +109,7 @@
_edep = ed;
}
-void CalorimeterHit::incrEdep(const G4double edincr)
+void CalorimeterHit::addEnergyDeposition(const G4double edincr)
{
_edep += edincr;
}
CVSspam 0.2.12