22 added + 20 removed + 20 modified, total 62 files
lcdd/include/lcdd/detectors
diff -N HitProcessorFactory.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ HitProcessorFactory.hh 14 Aug 2013 00:23:22 -0000 1.1.2.1
@@ -0,0 +1,40 @@
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/Attic/HitProcessorFactory.hh,v 1.1.2.1 2013/08/14 00:23:22 jeremy Exp $
+
+#ifndef LCDD_DETECTORS_HITPROCESSORFACTORY_HH
+#define LCDD_DETECTORS_HITPROCESSORFACTORY_HH
+
+// LCDD
+#include "lcdd/detectors/HitProcessor.hh"
+#include "lcdd/detectors/SensitiveDetector.hh"
+
+class HitProcessorFactory
+{
+public:
+
+ /**
+ * Class constructor.
+ */
+ HitProcessorFactory();
+
+ /**
+ * Class destructor.
+ */
+ virtual ~HitProcessorFactory();
+
+public:
+
+ /**
+ * Create a HitProcessor for the given SensitiveDetector.
+ * @param[in] sd The SensitiveDetector to which the HitProcessor will be added.
+ * @return The specific implementation of HitProcessor produced by this factory.
+ */
+ virtual HitProcessor* createHitProcessor(SensitiveDetector* sd) = 0;
+
+ /**
+ * Get the type of HitProcessor created by this factory e.g. name of the class.
+ * @return The name of the HitProcessor class produced by this factory.
+ */
+ virtual const std::string& handlesType() = 0;
+};
+
+#endif
lcdd/include/lcdd/detectors
diff -N HitProcessorManager.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ HitProcessorManager.hh 14 Aug 2013 00:23:22 -0000 1.1.2.1
@@ -0,0 +1,61 @@
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/Attic/HitProcessorManager.hh,v 1.1.2.1 2013/08/14 00:23:22 jeremy Exp $
+
+#ifndef LCDD_DETECTORS_HITPROCESSORMANAGER_HH
+#define LCDD_DETECTORS_HITPROCESSORMANAGER_HH 1
+
+// LCDD
+#include "lcdd/detectors/HitProcessorFactory.hh"
+
+class HitProcessorManager
+{
+
+private:
+
+ typedef std::map<std::string, HitProcessorFactory*> HitProcessorFactories;
+
+public:
+
+ /**
+ * Class destructor.
+ */
+ virtual ~HitProcessorManager();
+
+ /**
+ * Get a factory for creating a HitProcessor of a specific concrete type.
+ * @param[in] hitProcessorType The name of the HitProcessor type.
+ * @return The HitProcessorFactory for creating HitProcessors with the given type.
+ */
+ HitProcessorFactory* getFactory(const std::string& hitProcessorType);
+
+ /**
+ * Register a factory for creating HitProcessor objects with a certain type.
+ * @param[in] factory A pointer to the HitProcessorFactory which should be registered.
+ * @note The method HitProcessorFactory::handlesType will be used to get the name of the type.
+ */
+ void registerFactory(HitProcessorFactory* factory);
+
+ /**
+ * Get the singleton instance of this class.
+ * @return The singleton instance.
+ */
+ static HitProcessorManager* instance();
+
+private:
+
+ /**
+ * Class constructor.
+ */
+ HitProcessorManager();
+
+ /**
+ * Create and register the default set of factories for creating new HitProcessor objects.
+ */
+ void registerDefaultFactories();
+
+private:
+
+ HitProcessorFactories _factories;
+ static HitProcessorManager* _manager;
+};
+
+#endif
lcdd/include/lcdd/detectors
diff -N OpticalCalorimeterHitProcessor.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ OpticalCalorimeterHitProcessor.hh 14 Aug 2013 00:23:22 -0000 1.1.2.1
@@ -0,0 +1,80 @@
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/Attic/OpticalCalorimeterHitProcessor.hh,v 1.1.2.1 2013/08/14 00:23:22 jeremy Exp $
+
+#ifndef LCDD_DETECTORS_OPTICALCALORIMETERHITPROCESSOR_HH
+#define LCDD_DETECTORS_OPTICALCALORIMETERHITPROCESSOR_HH 1
+
+// LCDD
+#include "lcdd/detectors/CalorimeterHitProcessor.hh"
+#include "lcdd/detectors/Cerenkov.hh"
+#include "lcdd/detectors/HitProcessorFactory.hh"
+
+/**
+ * @brief HitProcessor to create CalorimeterHit objects in an optical calorimeter.
+ */
+class OpticalCalorimeterHitProcessor : public CalorimeterHitProcessor
+{
+public:
+
+ /**
+ * An enum for the two hit collections (cerenkov and edep).
+ */
+ enum HCType
+ {
+ eEdep = 0,
+ eCerenkov = 1
+ };
+
+public:
+
+ /**
+ * Class constructor.
+ * @param[in] calorimeter The calorimeter SD.
+ */
+ OpticalCalorimeterHitProcessor(CalorimeterSD* calorimeter);
+
+ /**
+ * Class destructor.
+ */
+ virtual ~OpticalCalorimeterHitProcessor();
+
+ /**
+ * Process steps to produce hits.
+ * @param[in] step The G4Step object.
+ */
+ bool processHits(G4Step* step);
+
+private:
+
+ /**
+ * Get the global hit position from a pre step point.
+ * @param[in] aPreStepPoint The pre step point.
+ */
+ G4ThreeVector getGlobalHitPosition(const G4StepPoint* aPreStepPoint);
+
+private:
+
+ Cerenkov* _cerenGenerator;
+};
+
+/**
+ * The factory for creating new OpticalCalorimeterHitProcessor objects.
+ */
+class OpticalCalorimeterHitProcessorFactory : public HitProcessorFactory
+{
+
+public:
+
+ HitProcessor* createHitProcessor(SensitiveDetector* sd)
+ {
+ return new OpticalCalorimeterHitProcessor(dynamic_cast<CalorimeterSD*>(sd));
+ }
+
+ const std::string& handlesType()
+ {
+ static std::string typeName = "OpticalCalorimeterHitProcessor";
+ return typeName;
+ }
+};
+
+
+#endif
lcdd/include/lcdd/detectors
diff -N ScoringTrackerHitProcessor.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ScoringTrackerHitProcessor.hh 14 Aug 2013 00:23:22 -0000 1.1.2.1
@@ -0,0 +1,60 @@
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/Attic/ScoringTrackerHitProcessor.hh,v 1.1.2.1 2013/08/14 00:23:22 jeremy Exp $
+
+#ifndef LCDD_DETECTORS_SCORINGTRACKERHITPROCESSOR_HH
+#define LCDD_DETECTORS_SCORINGTRACKERHITPROCESSOR_HH 1
+
+// LCDD
+#include "lcdd/detectors/TrackerHitProcessor.hh"
+#include "lcdd/detectors/HitProcessorFactory.hh"
+
+/**
+ * HitProcessor to implement scoring behavior, that only records a hit per track.
+ */
+class ScoringTrackerHitProcessor : public TrackerHitProcessor
+{
+
+public:
+
+ /**
+ * Class constructor.
+ * @param[in] tracker The tracker SD.
+ */
+ ScoringTrackerHitProcessor(TrackerSD* tracker);
+
+ /**
+ * Class destructor.
+ */
+ virtual ~ScoringTrackerHitProcessor();
+
+ /**
+ * Process steps to produce hits.
+ * @param[in] step The G4Step object.
+ */
+ bool processHits(G4Step* step);
+
+private:
+
+ int _currentTrackId;
+};
+
+/**
+ * The factory for creating new BasicTrackerHitProcessor objects.
+ */
+class ScoringTrackerHitProcessorFactory : public HitProcessorFactory
+{
+
+public:
+
+ HitProcessor* createHitProcessor(SensitiveDetector* sd)
+ {
+ return new ScoringTrackerHitProcessor(dynamic_cast<TrackerSD*>(sd));
+ }
+
+ const std::string& handlesType()
+ {
+ static std::string typeName = "ScoringTrackerHitProcessor";
+ return typeName;
+ }
+};
+
+#endif
lcdd/include/lcdd/detectors
diff -N UnsegmentedCalorimeterHitProcessor.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ UnsegmentedCalorimeterHitProcessor.hh 14 Aug 2013 00:23:22 -0000 1.1.2.1
@@ -0,0 +1,56 @@
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/Attic/UnsegmentedCalorimeterHitProcessor.hh,v 1.1.2.1 2013/08/14 00:23:22 jeremy Exp $
+
+#ifndef LCDD_DETECTORS_UNSEGMENTEDCALORIMETERHITPROCESSOR_HH
+#define LCDD_DETECTORS_UNSEGMENTEDCALORIMETERHITPROCESSOR_HH 1
+
+// LCDD
+#include "lcdd/detectors/CalorimeterHitProcessor.hh"
+#include "lcdd/detectors/HitProcessorFactory.hh"
+
+/**
+ * HitProcessor that produces CalorimeterHit objects with no virtual geometry segmentation.
+ */
+class UnsegmentedCalorimeterHitProcessor : public CalorimeterHitProcessor
+{
+
+public:
+
+ /**
+ * Class constructor.
+ * @param[in] calorimeter The calorimeter SD.
+ */
+ UnsegmentedCalorimeterHitProcessor(CalorimeterSD* calorimeter);
+
+ /**
+ * Class destructor.
+ */
+ virtual ~UnsegmentedCalorimeterHitProcessor();
+
+ /**
+ * Process steps to produce hits.
+ * @param[in] step The G4Step object.
+ */
+ bool processHits(G4Step* step);
+};
+
+/**
+ * The factory for creating new UnsegmentedCalorimeterHitProcessor objects.
+ */
+class UnsegmentedCalorimeterHitProcessorFactory : public HitProcessorFactory
+{
+
+public:
+
+ HitProcessor* createHitProcessor(SensitiveDetector* sd)
+ {
+ return new UnsegmentedCalorimeterHitProcessor(dynamic_cast<CalorimeterSD*>(sd));
+ }
+
+ const std::string& handlesType()
+ {
+ static std::string typeName = "UnsegmentedCalorimeterHitProcessor";
+ return typeName;
+ }
+};
+
+#endif
lcdd/include/lcdd/detectors
diff -u -r1.1 -r1.1.2.1
--- BasicTrackerHitProcessor.hh 11 Jul 2013 22:39:17 -0000 1.1
+++ BasicTrackerHitProcessor.hh 14 Aug 2013 00:23:21 -0000 1.1.2.1
@@ -1,10 +1,11 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/BasicTrackerHitProcessor.hh,v 1.1 2013/07/11 22:39:17 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/BasicTrackerHitProcessor.hh,v 1.1.2.1 2013/08/14 00:23:21 jeremy Exp $
#ifndef LCDD_DETECTORS_BASICTRACKERHITPROCESSOR_HH
#define LCDD_DETECTORS_BASICTRACKERHITPROCESSOR_HH 1
// LCDD
#include "lcdd/detectors/TrackerHitProcessor.hh"
+#include "lcdd/detectors/HitProcessorFactory.hh"
/**
* @brief Implements default TrackerSD hit processing behavior.
@@ -32,4 +33,25 @@
bool processHits(G4Step* step);
};
+/**
+ * The factory for creating new BasicTrackerHitProcessor objects.
+ */
+class BasicTrackerHitProcessorFactory : public HitProcessorFactory
+{
+
+public:
+
+ HitProcessor* createHitProcessor(SensitiveDetector* sd)
+ {
+ return new BasicTrackerHitProcessor(dynamic_cast<TrackerSD*>(sd));
+ }
+
+ const std::string& handlesType()
+ {
+ static std::string typeName = "BasicTrackerHitProcessor";
+ return typeName;
+ }
+};
+
+
#endif
lcdd/include/lcdd/detectors
diff -u -r1.10 -r1.10.2.1
--- CalorimeterHitProcessor.hh 11 Jul 2013 22:39:17 -0000 1.10
+++ CalorimeterHitProcessor.hh 14 Aug 2013 00:23:21 -0000 1.10.2.1
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/CalorimeterHitProcessor.hh,v 1.10 2013/07/11 22:39:17 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/CalorimeterHitProcessor.hh,v 1.10.2.1 2013/08/14 00:23:21 jeremy Exp $
#ifndef LCDD_DETECTORS_CALORIMETERHITPROCESSOR_HH
#define LCDD_DETECTORS_CALORIMETERHITPROCESSOR_HH 1
@@ -18,24 +18,27 @@
public:
- /**
- * Class constructor.
- * @param[in] ro The CellReadout used by the processor.
- */
- CalorimeterHitProcessor(CalorimeterSD* calorimeter);
-
/**
* Class destructor.
*/
virtual ~CalorimeterHitProcessor();
+protected:
+
+ /**
+ * Class constructor.
+ * @param[in] ro The CellReadout used by the processor.
+ */
+ CalorimeterHitProcessor(CalorimeterSD* calorimeter);
+
public:
/**
* Process steps to make hits.
* @param[in] step The G4Step object of the energy deposition.
+ * @todo This should really be pure virtual, but I can't get it to link correctly.
*/
- virtual bool processHits(G4Step* step) = 0;
+ virtual bool processHits(G4Step* step);
protected:
CalorimeterSD* _calorimeter;
lcdd/include/lcdd/detectors
diff -u -r1.6 -r1.6.2.1
--- CalorimeterSD.hh 11 Jul 2013 20:41:53 -0000 1.6
+++ CalorimeterSD.hh 14 Aug 2013 00:23:21 -0000 1.6.2.1
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/CalorimeterSD.hh,v 1.6 2013/07/11 20:41:53 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/CalorimeterSD.hh,v 1.6.2.1 2013/08/14 00:23:21 jeremy Exp $
#ifndef LCDD_DETECTORS_CALORIMETERSD_HH
#define LCDD_DETECTORS_CALORIMETERSD_HH 1
@@ -45,12 +45,19 @@
CalorimeterSD(G4String sdName, const std::vector<G4String>& hcNames, Segmentation* sdSeg, HitComparator* compare = 0);
/**
+ * Class constructor.
+ * @param[in] sdName The name of the sensitive detector.
+ * @param[in] hcName The name of the output hit collection.
+ * @param[in] sdSeg The detector's segmentation object for dividing into artificial cells.
+ * @param[in] compare The hit comparator to be used by this detector.
+ */
+ //CalorimeterSD(G4String sdName, Segmentation* sdSeg);
+
+ /**
* Class destructor.
*/
virtual ~CalorimeterSD();
-public:
-
/**
* Check whether a given logical volume is valid for this detector.
* @return True if lv is valid; false if not.
@@ -76,21 +83,6 @@
Segmentation* getSegmentation() const;
/**
- * Find a hit using the current HitComparator.
- * @param[in] The hit to find.
- * @return The found hit or 0 if not found.
- */
- CalorimeterHit* findHit(CalorimeterHit* aHit) const;
-
- /**
- * Find a hit in the given hit collection using the current HitComparator.
- * @param[in] The hit to find.
- * @param[in] The index of the hits collection.
- * @return The found hit or 0 if not found.
- */
- CalorimeterHit* findHit(CalorimeterHit* aHit, G4int nHC) const;
-
- /**
* Print out the hit data to an output stream.
* @param[in] os The output stream.
* @return The same output stream.
@@ -140,6 +132,28 @@
*/
void addHit(CalorimeterHit* hit);
+ /**
+ * Add a hit to one of this Calorimeter's hit collections.
+ * @param[in] hit The hit to add.
+ * @param[in] collectionIndex The index of the hit collection.
+ */
+ void addHit(CalorimeterHit* hit, int collectionIndex);
+
+ /**
+ * Find a hit using the current HitComparator.
+ * @param[in] The hit to find.
+ * @return The found hit or 0 if not found.
+ */
+ CalorimeterHit* findHit(CalorimeterHit* aHit) const;
+
+ /**
+ * Find a hit in the given hit collection using the current HitComparator.
+ * @param[in] The hit to find.
+ * @param[in] The index of the hits collection.
+ * @return The found hit or 0 if not found.
+ */
+ CalorimeterHit* findHit(CalorimeterHit* aHit, G4int nHC) const;
+
protected:
/**
@@ -150,12 +164,17 @@
virtual G4bool ProcessHits(G4Step* step, G4TouchableHistory* touchable);
protected:
+
Segmentation* _segmentation;
- G4CalorimeterHitsCollection* _collection;
- std::vector<G4CalorimeterHitsCollection*> _hitsCollections;
+ HitComparator* _hitCompare;
+
+ // TODO: Document these.
+ // FIXME: Are all of them really needed? Can be simplified?
+ CalorimeterHitsCollection* _collection;
+ std::vector<CalorimeterHitsCollection*> _hitsCollections;
CalorimeterHitList _hits;
std::vector<CalorimeterHitList> _hitsVector;
- HitComparator* _hitCompare;
+
};
#endif
lcdd/include/lcdd/detectors
diff -u -r1.2 -r1.2.2.1
--- HitProcessor.hh 11 Jul 2013 22:39:17 -0000 1.2
+++ HitProcessor.hh 14 Aug 2013 00:23:22 -0000 1.2.2.1
@@ -1,3 +1,5 @@
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/HitProcessor.hh,v 1.2.2.1 2013/08/14 00:23:22 jeremy Exp $
+
#ifndef LCDD_DETECTORS_HITPROCESSOR_HH
#define LCDD_DETECTORS_HITPROCESSOR_HH 1
@@ -5,11 +7,18 @@
#include "G4Step.hh"
/**
- * @brief Pure virtual class defining an interface for processing hits within sensitive detectors.
+ * @brief Pure virtual class defining an interface for processing hits from within sensitive detectors.
*/
class HitProcessor
{
+protected:
+
+ /**
+ * Class constructor.
+ */
+ HitProcessor();
+
public:
/**
@@ -23,13 +32,6 @@
* @return True if hits were created or modified; false if not.
*/
virtual bool processHits(G4Step* step) = 0;
-
-protected:
-
- /**
- * Class constructor.
- */
- HitProcessor();
};
#endif
lcdd/include/lcdd/detectors
diff -u -r1.2 -r1.2.2.1
--- LegacyCalorimeterHitProcessor.hh 11 Jul 2013 22:39:17 -0000 1.2
+++ LegacyCalorimeterHitProcessor.hh 14 Aug 2013 00:23:22 -0000 1.2.2.1
@@ -1,13 +1,16 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/LegacyCalorimeterHitProcessor.hh,v 1.2 2013/07/11 22:39:17 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/LegacyCalorimeterHitProcessor.hh,v 1.2.2.1 2013/08/14 00:23:22 jeremy Exp $
-#ifndef LCDD_DETECTORS_LEGACYCALORIMETERHITPROCESSOR
-#define LCDD_DETECTORS_LEGACYCALORIMETERHITPROCESSOR 1
+#ifndef LCDD_DETECTORS_LEGACYCALORIMETERHITPROCESSOR_HH
+#define LCDD_DETECTORS_LEGACYCALORIMETERHITPROCESSOR_HH 1
// LCDD
#include "lcdd/detectors/CalorimeterHitProcessor.hh"
+#include "lcdd/detectors/CalorimeterSD.hh"
+#include "lcdd/detectors/HitProcessorFactory.hh"
/**
* @brief Implementation of hit processing behavior for CalorimeterSD objects with Segmentation.
+ * @todo Change name to SegmentedCalorimeterHitProcessor.
*/
class LegacyCalorimeterHitProcessor : public CalorimeterHitProcessor
{
@@ -31,4 +34,24 @@
bool processHits(G4Step* step);
};
+/**
+ * The factory for creating new LegacyCalorimeterHitProcessor objects.
+ */
+class LegacyCalorimeterHitProcessorFactory : public HitProcessorFactory
+{
+
+public:
+
+ HitProcessor* createHitProcessor(SensitiveDetector* sd)
+ {
+ return new LegacyCalorimeterHitProcessor(dynamic_cast<CalorimeterSD*>(sd));
+ }
+
+ const std::string& handlesType()
+ {
+ static std::string typeName = "LegacyCalorimeterHitProcessor";
+ return typeName;
+ }
+};
+
#endif
lcdd/include/lcdd/detectors
diff -u -r1.6 -r1.6.2.1
--- SensitiveDetector.hh 11 Jul 2013 20:41:54 -0000 1.6
+++ SensitiveDetector.hh 14 Aug 2013 00:23:22 -0000 1.6.2.1
@@ -1,11 +1,11 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/SensitiveDetector.hh,v 1.6 2013/07/11 20:41:54 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/SensitiveDetector.hh,v 1.6.2.1 2013/08/14 00:23:22 jeremy Exp $
#ifndef LCDD_DETECTORS_SENSITIVEDETECTOR_HH
#define LCDD_DETECTORS_SENSITIVEDETECTOR_HH 1
// Geant4
#include "G4VSensitiveDetector.hh"
-#include "G4UnitsTable.hh"
+#include "G4THitsCollection.hh"
// LCDD
#include "lcdd/detectors/StepReadout.hh"
@@ -20,7 +20,6 @@
* @brief A basic implementation of G4VSensitiveDetector.
* @note Primary attributes include verbosity, energy cut,
* IdSpec,and hits collections.
- * @todo Move code to source file.
*/
class SensitiveDetector: public G4VSensitiveDetector, protected StepReadout
{
@@ -57,13 +56,18 @@
*/
SensitiveDetector(G4String sdName, const std::vector<G4String>& hcNames, EType sdType);
+ /**
+ * Class constructor.
+ * @param[in] sdName The name of the detector.
+ * @param[in] sdType The type of the detector.
+ */
+ //SensitiveDetector(G4String name, EType type);
+
/**
* Class destructor.
*/
virtual ~SensitiveDetector();
-public:
-
/**
* Geant4 initialization function called at beginning of event.
* @param[in] hce The hit collections of this event.
@@ -76,17 +80,6 @@
*/
virtual void EndOfEvent(G4HCofThisEvent* hce);
-protected:
-
- /**
- * Geant4 function to make hits from the step.
- * @param[in] step The G4Step object.
- * @param[in] touchable The touchable handle to the current geometry.
- */
- virtual G4bool ProcessHits(G4Step* step, G4TouchableHistory* touchable);
-
-public:
-
/**
* Get the type of this detector encoded as an enum.
* @return The type of this detector as an enum.
@@ -252,6 +245,8 @@
*/
void addHitProcessor(HitProcessor* processor);
+ void addHitProcessors(HitProcessors processors);
+
/**
* Create a 64-bit identifier based on the current step information.
* @return A 64-bit identifier from the current step.
@@ -265,9 +260,29 @@
*/
Id64bit makeIdentifier(G4Step* step) const;
+ /**
+ * Get the list of HitProcessors.
+ * @return The list of HitProcessors.
+ */
+ HitProcessors getHitProcessors();
+
+ /**
+ * Add a hits collection to the detector.
+ * @param[in] collectionName The name of the collection.
+ * @param[in] collection The collection to add.
+ */
+ //virtual void addHitsCollection(G4String collectionName);
+
protected:
/**
+ * Geant4 function to make hits from the step.
+ * @param[in] step The G4Step object.
+ * @param[in] touchable The touchable handle to the current geometry.
+ */
+ virtual G4bool ProcessHits(G4Step* step, G4TouchableHistory* touchable);
+
+ /**
* Get the (first) hit collection associated with this detector.
* @return The hit collection associated with this detector.
*/
lcdd/include/lcdd/detectors
diff -u -r1.4 -r1.4.2.1
--- SensitiveDetectorFactory.hh 10 Jul 2013 18:06:17 -0000 1.4
+++ SensitiveDetectorFactory.hh 14 Aug 2013 00:23:22 -0000 1.4.2.1
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/SensitiveDetectorFactory.hh,v 1.4 2013/07/10 18:06:17 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/SensitiveDetectorFactory.hh,v 1.4.2.1 2013/08/14 00:23:22 jeremy Exp $
#ifndef LCDD_DETECTORS_SENSITIVEDETECTORFACTORY_HH
#define LCDD_DETECTORS_SENSITIVEDETECTORFACTORY_HH 1
@@ -8,7 +8,6 @@
#include "lcdd/schema/SensitiveDetectorType.hh"
#include "lcdd/schema/calorimeter.hh"
#include "lcdd/schema/tracker.hh"
-#include "lcdd/schema/scorer.hh"
#include "lcdd/schema/IdSpecType.hh"
#include "lcdd/detectors/SensitiveDetector.hh"
#include "lcdd/detectors/SegmentationFactory.hh"
@@ -57,37 +56,19 @@
private:
/**
- * Create a CalorimeterSD object.
- * @param[in] object The SAXObject of the detector.
+ * Create a calorimeter SD from XML.
+ * @param[in] The SensitiveDetectorType object.
+ * @param[in] The object pointing to the calorimeter element.
+ * @param[in] The list of hits collection names.
+ * @return The CalorimeterSD as a generic SensitiveDetector.
*/
- static CalorimeterSD* createCalorimeterSD(const SAXObject* object);
+ static SensitiveDetector* createCalorimeter(const SAXObject* object, const std::vector<G4String>& hitsCollections);
/**
* Create a TrackerSD object.
* @param[in] object The SAXObject of the detector.
*/
- static TrackerSD* createTrackerSD(const SAXObject* object);
-
- /**
- * Create a ScorerSD object.
- * @param[in] object The SAXObject of the detector.
- */
- static ScorerSD* createScorerSD(const SAXObject* object);
-
- /**
- * Lookup the IdSpec of a detector SAX object based on the idspecref.
- * @param[id] sdt The SD type SAXObject.
- * @return The IdSpec of this detector, or null if one does not exist.
- * @throw G4Exception If the idspecref has a bad reference value.
- */
- static IdSpec* findIdSpec(const SensitiveDetectorType* sdt);
-
- /**
- * Set the base parameters of the sensitive detector.
- * @param[out] sd The target SD.
- * @param[in] sdt The SAXObject of the SD.
- */
- static void setBaseSensitiveDetectorAttributes(SensitiveDetector* sd, const SensitiveDetectorType* sdt);
+ static TrackerSD* createTracker(const SAXObject* object);
/**
* Compute the ecut for a detector.
@@ -109,13 +90,6 @@
* @return True if segmentation tag is valid; false if not.
*/
static bool isSegmentationTag(const std::string& s);
-
- /**
- * Check if a hit collection name is valid, e.g. contains all valid characters.
- * @param[in] s The hit collection name.
- * @return True if hit collection name is valid; false if not.
- */
- static bool checkHCName(const std::string& s);
};
#endif
lcdd/include/lcdd/detectors
diff -u -r1.1 -r1.1.2.1
--- StepCombiningTrackerHitProcessor.hh 11 Jul 2013 22:39:17 -0000 1.1
+++ StepCombiningTrackerHitProcessor.hh 14 Aug 2013 00:23:22 -0000 1.1.2.1
@@ -1,16 +1,17 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/StepCombiningTrackerHitProcessor.hh,v 1.1 2013/07/11 22:39:17 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/StepCombiningTrackerHitProcessor.hh,v 1.1.2.1 2013/08/14 00:23:22 jeremy Exp $
#ifndef LCDD_DETECTORS_STEPCOMBININGTRACKERHITPROCESSOR_HH
#define LCDD_DETECTORS_STEPCOMBININGTRACKERHITPROCESSOR_HH 1
// LCDD
#include "lcdd/detectors/TrackerHitProcessor.hh"
+#include "lcdd/detectors/HitProcessorFactory.hh"
// Geant4
#include "G4Track.hh"
/**
- * Implementation of TrackerHitProcessor that combines information from multiple steps
+ * TrackerHitProcessor that combines information from multiple steps
* into a single TrackerHit.
*/
class StepCombiningTrackerHitProcessor : public TrackerHitProcessor
@@ -74,4 +75,24 @@
G4Track* _currentTrack;
};
+/**
+ * The factory for creating new BasicTrackerHitProcessor objects.
+ */
+class StepCombiningTrackerHitProcessorFactory : public HitProcessorFactory
+{
+
+public:
+
+ HitProcessor* createHitProcessor(SensitiveDetector* sd)
+ {
+ return new StepCombiningTrackerHitProcessor(dynamic_cast<TrackerSD*>(sd));
+ }
+
+ const std::string& handlesType()
+ {
+ static std::string typeName = "StepCombiningTrackerHitProcessor";
+ return typeName;
+ }
+};
+
#endif
lcdd/include/lcdd/detectors
diff -u -r1.1 -r1.1.2.1
--- TrackerHitProcessor.hh 11 Jul 2013 22:39:17 -0000 1.1
+++ TrackerHitProcessor.hh 14 Aug 2013 00:23:22 -0000 1.1.2.1
@@ -1,10 +1,13 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/TrackerHitProcessor.hh,v 1.1 2013/07/11 22:39:17 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/TrackerHitProcessor.hh,v 1.1.2.1 2013/08/14 00:23:22 jeremy Exp $
#ifndef LCDD_DETECTORS_TRACKERHITPROCESSOR_HH
#define LCDD_DETECTORS_TRACKERHITPROCESSOR_HH 1
#include "lcdd/detectors/TrackerSD.hh"
+/**
+ * @brief The interface for hit processing in trackers.
+ */
class TrackerHitProcessor : public HitProcessor
{
public:
lcdd/include/lcdd/detectors
diff -u -r1.5 -r1.5.2.1
--- TrackerSD.hh 11 Jul 2013 22:39:17 -0000 1.5
+++ TrackerSD.hh 14 Aug 2013 00:23:22 -0000 1.5.2.1
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/TrackerSD.hh,v 1.5 2013/07/11 22:39:17 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/TrackerSD.hh,v 1.5.2.1 2013/08/14 00:23:22 jeremy Exp $
#ifndef LCDD_DETECTORS_TRACKERSD_HH
#define LCDD_DETECTORS_TRACKERSD_HH 1
@@ -26,6 +26,12 @@
TrackerSD(G4String sdName, G4String hcName);
/**
+ * Class constructor.
+ * @param[in] sdName The name of the sensitive detector.
+ */
+ //TrackerSD(G4String sdName);
+
+ /**
* Class destructor.
*/
virtual ~TrackerSD();
lcdd/include/lcdd/detectors
diff -N OpticalCalorimeterSD.hh
--- OpticalCalorimeterSD.hh 2 Jul 2013 22:57:42 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,62 +0,0 @@
-#ifndef LCDD_DETECTORS_OPTICALCALORIMETERSD_HH
-#define LCDD_DETECTORS_OPTICALCALORIMETERSD_HH
-
-// SLIC
-#include "lcdd/detectors/CalorimeterSD.hh"
-
-// STL
-#include <vector>
-
-class Cerenkov;
-
-/**
- * @brief Simulator implementation of a calorimeter SD that is sensitive to optical photons.
- */
-class OpticalCalorimeterSD: public CalorimeterSD
-{
-
-private:
- Cerenkov* CerenGenerator;
-
-public:
-
- //enum for the two Hit Collections (cerenkov and edep):
- enum HCType
- {
- eEdep = 0, eCerenkov = 1
- };
-
- /**
- * Class constructor.
- */
- OpticalCalorimeterSD(G4String sdName, G4String hcName, Segmentation* sdSeg, HitComparator* compare = 0);
-
- /**
- * Class constructor.
- */
- OpticalCalorimeterSD(G4String sdName, const std::vector<G4String>& hcNames, Segmentation* sdSeg, HitComparator* compare = 0);
-
- /**
- * Class destructor.
- */
- virtual ~OpticalCalorimeterSD();
-
-protected:
-
- /**
- * Process step to make one or more hits.
- * @param[in] step The G4Step object.
- * @param[in] touchable The touchable handle pointing at the current geometric volume.
- */
- G4bool ProcessHits(G4Step* step, G4TouchableHistory* touchable);
-
-private:
-
- /**
- * Compute the global hit position from the position of a G4StepPoint.
- * @param[in] aPreStepPoint The G4StepPoint object.
- */
- G4ThreeVector getGlobalHitPosPreStep(const G4StepPoint* aPreStepPoint);
-};
-
-#endif
lcdd/include/lcdd/detectors
diff -N ScorerSD.hh
--- ScorerSD.hh 10 Jul 2013 18:06:17 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,38 +0,0 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/ScorerSD.hh,v 1.3 2013/07/10 18:06:17 jeremy Exp $
-
-#ifndef LCDD_DETECTORS_SCORERSD_HH
-#define LCDD_DETECTORS_SCORERSD_HH 1
-
-// LCDD
-#include "TrackerSD.hh"
-
-/**
- * @brief A scoring plane detector which does not record energy, only hits.
- */
-class ScorerSD: public TrackerSD
-{
-
-public:
-
- /**
- * Class constructor.
- * @param[in] sdName The SD's name.
- * @param[in] hcName The name of the hit collection.
- */
- ScorerSD(G4String sdName, G4String hcName);
-
-protected:
-
- /**
- * Create hits from G4Step.
- * @param[in] aStep The G4Step object.
- * @param[in] theTouchable The touchable handle into the geometry.
- * @return True if created hits; false if not.
- */
- virtual G4bool ProcessHits(G4Step* aStep, G4TouchableHistory* theTouchable);
-
-protected:
- int _currentTrackID;
-};
-
-#endif
lcdd/include/lcdd/detectors
diff -N TrackerCombineSD.hh
--- TrackerCombineSD.hh 10 Jul 2013 18:06:17 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,82 +0,0 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/TrackerCombineSD.hh,v 1.4 2013/07/10 18:06:17 jeremy Exp $
-#ifndef LCDD_DETECTORS_TRACKERCOMBINESD_HH
-#define LCDD_DETECTORS_TRACKERCOMBINESD_HH 1
-
-#include "TrackerSD.hh"
-
-/**
- * @brief Tracker for combining multiple hits in the same tracker layer into a single hit.
- * @note Parts of the logic in this class are based on a refactoring of code from Mokka's TRKSD00.
- */
-class TrackerCombineSD: public TrackerSD
-{
-public:
-
- /**
- * Class constructor.
- * @param[in] sdName The name of the sensitive detector.
- * @param[in] hcName The name of the hit collection.
- */
- TrackerCombineSD(G4String sdName, G4String hcName);
-
- /**
- * Class destructor.
- */
- virtual ~TrackerCombineSD();
-
-public:
-
- /**
- * Perform end of event processing on the HC of this event.
- * @param[in] hce The HC of this event.
- */
- virtual void EndOfEvent(G4HCofThisEvent* hce);
-
-protected:
-
- /**
- * Create hits from step data.
- * @param[in] step The current G4Step object.
- * @param[in] touchable The current touchable handle into the geometry.
- */
- virtual G4bool ProcessHits(G4Step* step, G4TouchableHistory* touchable);
-
-private:
-
- /**
- * Start a new hit.
- * @param[in] aStepPoint The pre step point.
- */
- void startHit(G4StepPoint* aStepPoint);
-
- /**
- * Update an existing hit with current step data.
- */
- void updateHit();
-
- /**
- * Insert a new hit after all data is added.
- */
- bool insertHit();
-
- /**
- * Clear the current hit.
- */
- void clear();
-
-private:
-
- bool _combineHits;
- int _currentTrackID;
- G4VPhysicalVolume* _currentPV;
- G4ThreeVector _entryPoint;
- G4ThreeVector _exitPoint;
- G4ThreeVector _entryMomentum;
- G4ThreeVector _exitMomentum;
- G4double _edepTotal;
- G4double _minTime;
- bool _startedHit;
- G4Track* _currentTrack;
-};
-
-#endif
lcdd/include/lcdd/detectors
diff -N UnsegmentedCalorimeterSD.hh
--- UnsegmentedCalorimeterSD.hh 10 Jul 2013 22:39:26 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,39 +0,0 @@
-// $Id: UnsegmentedCalorimeterSD.hh,v 1.4 2013/07/10 22:39:26 jeremy Exp $
-
-#ifndef LCDD_DETECTORS_UNSEGMENTEDCALORIMETERSD_HH
-#define LCDD_DETECTORS_UNSEGMENTEDCALORIMETERSD_HH 1
-
-// LCDD
-#include "CalorimeterSD.hh"
-
-/**
- * @brief A SensitiveDetector that writes out a CalorimeterHit for each step.
- */
-class UnsegmentedCalorimeterSD: public CalorimeterSD
-{
-public:
-
- /**
- * Class constructor.
- * @param[in] sdName The name of the sensitive detector.
- * @param[in] hcName The name of the hit collection.
- * @param[in] seg The segmentation (ignored???).
- */
- UnsegmentedCalorimeterSD(G4String sdName, G4String hcName, Segmentation* seg);
-
- /**
- * Class destructor.
- */
- virtual ~UnsegmentedCalorimeterSD();
-
-protected:
-
- /**
- * Process steps to produce hits.
- * @param[in] step The current G4Step object.
- * @param[in] touchable A touchable handle pointing to current volume.
- */
- G4bool ProcessHits(G4Step* step, G4TouchableHistory* touchable);
-};
-
-#endif
lcdd/include/lcdd/hits
diff -u -r1.8 -r1.8.2.1
--- CalorimeterHit.hh 11 Jul 2013 20:41:54 -0000 1.8
+++ CalorimeterHit.hh 14 Aug 2013 00:23:22 -0000 1.8.2.1
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/hits/CalorimeterHit.hh,v 1.8 2013/07/11 20:41:54 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/lcdd/hits/CalorimeterHit.hh,v 1.8.2.1 2013/08/14 00:23:22 jeremy Exp $
#ifndef LCDD_HITS_CALORIMETERHIT_HH
#define LCDD_HITS_CALORIMETERHIT_HH 1
@@ -181,9 +181,9 @@
HitContributionList _particleList;
};
-typedef G4THitsCollection<CalorimeterHit> (G4CalorimeterHitsCollection);
+typedef G4THitsCollection<CalorimeterHit> (CalorimeterHitsCollection);
-extern G4Allocator<CalorimeterHit> G4CalorimeterHitAllocator;
+extern G4Allocator<CalorimeterHit> CalorimeterHitAllocator;
/**
* Implementation of custom new operator.
@@ -191,7 +191,7 @@
inline void* CalorimeterHit::operator new(size_t)
{
void* aHit;
- aHit = (void *) G4CalorimeterHitAllocator.MallocSingle();
+ aHit = (void*) CalorimeterHitAllocator.MallocSingle();
return aHit;
}
@@ -200,7 +200,7 @@
*/
inline void CalorimeterHit::operator delete(void *aHit)
{
- G4CalorimeterHitAllocator.FreeSingle((CalorimeterHit*) aHit);
+ CalorimeterHitAllocator.FreeSingle((CalorimeterHit*) aHit);
}
#endif
lcdd/include/lcdd/processes
diff -N hit_processorProcess.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ hit_processorProcess.hh 14 Aug 2013 00:23:22 -0000 1.1.2.1
@@ -0,0 +1,46 @@
+// $Header: /cvs/lcd/lcdd/include/lcdd/processes/Attic/hit_processorProcess.hh,v 1.1.2.1 2013/08/14 00:23:22 jeremy Exp $
+
+#ifndef LCDD_PROCESSES_HITPROCESSORPROCESS_HH
+#define LCDD_PROCESSES_HITPROCESSORPROCESS_HH 1
+
+// GDML
+#include "Saxana/SAXStateProcess.h"
+#include "Saxana/SAXObject.h"
+
+class hit_processorProcess : public SAXStateProcess
+{
+
+public:
+
+ hit_processorProcess();
+
+ hit_processorProcess(ProcessingContext* context);
+
+ virtual ~hit_processorProcess();
+
+ /**
+ * Start element processing.
+ */
+ virtual void StartElement(const std::string& name, const ASCIIAttributeList& attrs);
+
+ /**
+ * End element processing.
+ */
+ virtual void EndElement(const std::string&);
+
+ /**
+ * Process element character content.
+ */
+ virtual void Characters(const std::string&);
+
+ virtual void StackPopNotify(const std::string& name);
+
+ virtual const std::string& State() const;
+
+private:
+
+ SAXObject* _obj;
+
+};
+
+#endif
lcdd/include/lcdd/processes
diff -N hits_collectionProcess.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ hits_collectionProcess.hh 14 Aug 2013 00:23:22 -0000 1.1.2.1
@@ -0,0 +1,46 @@
+// $Header: /cvs/lcd/lcdd/include/lcdd/processes/Attic/hits_collectionProcess.hh,v 1.1.2.1 2013/08/14 00:23:22 jeremy Exp $
+
+#ifndef LCDD_PROCESSES_HITS_COLLECTIONPROCESS_HH
+#define LCDD_PROCESSES_HITS_COLLECTIONPROCESS_HH 1
+
+// GDML
+#include "Saxana/SAXStateProcess.h"
+#include "Saxana/SAXObject.h"
+
+class hits_collectionProcess : public SAXStateProcess
+{
+
+public:
+
+ hits_collectionProcess();
+
+ hits_collectionProcess(ProcessingContext* context);
+
+ virtual ~hits_collectionProcess();
+
+ /**
+ * Start element processing.
+ */
+ virtual void StartElement(const std::string& name, const ASCIIAttributeList& attrs);
+
+ /**
+ * End element processing.
+ */
+ virtual void EndElement(const std::string&);
+
+ /**
+ * Process element character content.
+ */
+ virtual void Characters(const std::string&);
+
+ virtual void StackPopNotify(const std::string& name);
+
+ virtual const std::string& State() const;
+
+private:
+
+ SAXObject* _obj;
+
+};
+
+#endif
lcdd/include/lcdd/processes
diff -u -r1.3 -r1.3.2.1
--- SensitiveDetectorTypeProcess.hh 3 Jul 2013 23:33:51 -0000 1.3
+++ SensitiveDetectorTypeProcess.hh 14 Aug 2013 00:23:22 -0000 1.3.2.1
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/processes/SensitiveDetectorTypeProcess.hh,v 1.3 2013/07/03 23:33:51 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/lcdd/processes/SensitiveDetectorTypeProcess.hh,v 1.3.2.1 2013/08/14 00:23:22 jeremy Exp $
#ifndef LCDD_PROCESSES_SENSITIVEDETECTORTYPEPROCESS_HH
#define LCDD_PROCESSES_SENSITIVEDETECTORTYPEPROCESS_HH 1
@@ -95,10 +95,12 @@
*/
virtual void StackPopNotify(const std::string& name)
{
+ std::cout << "SensitiveDetectorTypeProcess::StackPopNotify - " << name << std::endl;
+
SAXObject** so = Context()->GetTopObject();
SensitiveDetectorType* sdt = dynamic_cast<SensitiveDetectorType*>(_obj);
- // just push all content; could be idspecref or segmentation (for cal)
+ // Push all content.
sdt->add_content(name, *so);
}
lcdd/include/lcdd/schema
diff -N HitProcessorType.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ HitProcessorType.hh 14 Aug 2013 00:23:22 -0000 1.1.2.1
@@ -0,0 +1,32 @@
+// $Header: /cvs/lcd/lcdd/include/lcdd/schema/Attic/HitProcessorType.hh,v 1.1.2.1 2013/08/14 00:23:22 jeremy Exp $
+
+#ifndef LCDD_SCHEMA_HITPROCESSORTYPE_HH
+#define LCDD_SCHEMA_HITPROCESSORTYPE_HH 1
+
+// STL
+#include <string>
+
+// GDML
+#include "Schema/ContentGroup.h"
+
+class HitProcessorType
+{
+
+public:
+
+ HitProcessorType();
+
+ virtual ~HitProcessorType();
+
+ void set_type(const std::string& s);
+
+ const std::string& get_type() const;
+
+ void add_content(const std::string& tag, SAXObject* so);
+
+private:
+ std::string _type;
+ ContentSequence _sequence;
+};
+
+#endif
lcdd/include/lcdd/schema
diff -N HitsCollectionType.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ HitsCollectionType.hh 14 Aug 2013 00:23:22 -0000 1.1.2.1
@@ -0,0 +1,29 @@
+// $Header: /cvs/lcd/lcdd/include/lcdd/schema/Attic/HitsCollectionType.hh,v 1.1.2.1 2013/08/14 00:23:22 jeremy Exp $
+
+#ifndef LCDD_SCHEMA_HITSCOLLECTIONTYPE_HH
+#define LCDD_SCHEMA_HITSCOLLECTIONTYPE_HH 1
+
+// STL
+#include <string>
+
+// GDML
+#include "Schema/ContentGroup.h"
+
+class HitsCollectionType
+{
+
+public:
+
+ HitsCollectionType();
+
+ virtual ~HitsCollectionType();
+
+ void set_name(const std::string& s);
+
+ const std::string& get_name() const;
+
+private:
+ std::string _name;
+};
+
+#endif
lcdd/include/lcdd/schema
diff -N hit_processor.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ hit_processor.hh 14 Aug 2013 00:23:22 -0000 1.1.2.1
@@ -0,0 +1,24 @@
+// $Header: /cvs/lcd/lcdd/include/lcdd/schema/Attic/hit_processor.hh,v 1.1.2.1 2013/08/14 00:23:22 jeremy Exp $
+
+#ifndef LCDD_SCHEMA_HITPROCESSOR_HH
+#define LCDD_SCHEMA_HITPROCESSOR_HH 1
+
+// LCDD
+#include "lcdd/schema/HitProcessorType.hh"
+
+// GDML
+#include "Saxana/SAXObject.h"
+
+class hit_processor : public SAXObject, public HitProcessorType
+{
+
+public:
+
+ hit_processor();
+
+ virtual ~hit_processor();
+
+ virtual SAXObject::Type type();
+};
+
+#endif
lcdd/include/lcdd/schema
diff -N hits_collection.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ hits_collection.hh 14 Aug 2013 00:23:22 -0000 1.1.2.1
@@ -0,0 +1,24 @@
+// $Header: /cvs/lcd/lcdd/include/lcdd/schema/Attic/hits_collection.hh,v 1.1.2.1 2013/08/14 00:23:22 jeremy Exp $
+
+#ifndef LCDD_SCHEMA_HITS_COLLECTION_HH
+#define LCDD_SCHEMA_HITS_COLLECTION_HH 1
+
+// LCDD
+#include "lcdd/schema/HitsCollectionType.hh"
+
+// GDML
+#include "Saxana/SAXObject.h"
+
+class hits_collection : public SAXObject, public HitsCollectionType
+{
+
+public:
+
+ hits_collection();
+
+ virtual ~hits_collection();
+
+ virtual SAXObject::Type type();
+};
+
+#endif
lcdd/include/lcdd/schema
diff -N OpticalCalorimeterType.hh
--- OpticalCalorimeterType.hh 10 Jul 2013 18:06:18 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,32 +0,0 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/schema/OpticalCalorimeterType.hh,v 1.4 2013/07/10 18:06:18 jeremy Exp $
-
-#ifndef LCDD_SCHEMA_OPTICALCALORIMETERTYPE_HH
-#define LCDD_SCHEMA_OPTICALCALORIMETERTYPE_HH 1
-
-// GDML
-#include "Schema/ContentGroup.h"
-
-// LCDD
-#include "CalorimeterType.hh"
-
-// STL
-#include <iostream>
-
-/**
- * @brief The CalorimeterType from the schema.
- */
-class OpticalCalorimeterType: public CalorimeterType
-{
-
-public:
-
- OpticalCalorimeterType()
- {
- }
-
- virtual ~OpticalCalorimeterType()
- {
- }
-};
-
-#endif
lcdd/include/lcdd/schema
diff -N ScorerType.hh
--- ScorerType.hh 10 Jul 2013 18:06:18 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,41 +0,0 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/schema/ScorerType.hh,v 1.4 2013/07/10 18:06:18 jeremy Exp $
-
-#ifndef LCDD_SCHEMA_SCORERTYPE_HH
-#define LCDD_SCHEMA_SCORERTYPE_HH 1
-
-// LCDD
-#include "SensitiveDetectorType.hh"
-
-/**
- * @brief The ScorerType from the schema.
- */
-class ScorerType: public SensitiveDetectorType
-{
-
-public:
- ScorerType()
- {
- }
-
- virtual ~ScorerType()
- {
- }
-
- /*
- void set_kill_tracks(const std::string& k)
- {
- m_kill_tracks = k;
- }
-
- const std::string& get_kill_tracks()
- {
- return m_kill_tracks;
- }
-
- private:
- std::string m_kill_tracks;
- */
-
-};
-
-#endif
lcdd/include/lcdd/schema
diff -N UnsegmentedCalorimeterType.hh
--- UnsegmentedCalorimeterType.hh 10 Jul 2013 18:06:18 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,32 +0,0 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/schema/UnsegmentedCalorimeterType.hh,v 1.4 2013/07/10 18:06:18 jeremy Exp $
-
-#ifndef LCDD_SCHEMA_UNSEGMENTEDCALORIMETERTYPE_HH
-#define LCDD_SCHEMA_UNSEGMENTEDCALORIMETERTYPE_HH 1
-
-// GDML
-#include "Schema/ContentGroup.h"
-
-// lcdd
-#include "CalorimeterType.hh"
-
-// std
-#include <iostream>
-
-/**
- * @brief The UnsegmentedCalorimeterType from the schema.
- */
-class UnsegmentedCalorimeterType: public CalorimeterType
-{
-
-public:
-
- UnsegmentedCalorimeterType()
- {
- }
-
- virtual ~UnsegmentedCalorimeterType()
- {
- }
-};
-
-#endif
lcdd/include/lcdd/schema
diff -N optical_calorimeter.hh
--- optical_calorimeter.hh 10 Jul 2013 18:06:18 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,32 +0,0 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/schema/optical_calorimeter.hh,v 1.4 2013/07/10 18:06:18 jeremy Exp $
-
-#ifndef LCDD_SCHEMA_OPTICAL_CALORIMETER_HH
-#define LCDD_SCHEMA_OPTICAL_CALORIMETER_HH 1
-
-// GDML
-#include "Saxana/SAXObject.h"
-
-// LCDD
-#include "OpticalCalorimeterType.hh"
-
-/**
- * @brief The optical_calorimeter element from the schema.
- */
-class optical_calorimeter: public SAXObject, public OpticalCalorimeterType
-{
-public:
- optical_calorimeter()
- {
- }
-
- virtual ~optical_calorimeter()
- {
- }
-
- virtual SAXObject::Type type()
- {
- return SAXObject::element;
- }
-};
-
-#endif
lcdd/include/lcdd/schema
diff -N scorer.hh
--- scorer.hh 10 Jul 2013 18:06:18 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,31 +0,0 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/schema/scorer.hh,v 1.4 2013/07/10 18:06:18 jeremy Exp $
-
-#ifndef LCDD_SCHEMA_SCORER_HH
-#define LCDD_SCHEMA_SCORER_HH 1
-
-#include "ScorerType.hh"
-
-#include "Saxana/SAXObject.h"
-#include "SensitiveDetectorType.hh"
-
-/**
- * @brief The scorer element from the schema.
- */
-class scorer: public SAXObject, public ScorerType
-{
-public:
- scorer()
- {
- }
-
- virtual ~scorer()
- {
- }
-
- virtual SAXObject::Type type()
- {
- return SAXObject::element;
- }
-};
-
-#endif
lcdd/include/lcdd/schema
diff -N unsegmented_calorimeter.hh
--- unsegmented_calorimeter.hh 10 Jul 2013 18:06:18 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,32 +0,0 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/schema/unsegmented_calorimeter.hh,v 1.4 2013/07/10 18:06:18 jeremy Exp $
-
-#ifndef LCDD_SCHEMA_UNSEGMENTEDCALORIMETER_HH
-#define LCDD_SCHEMA_UNSEGMENTEDCALORIMETER_HH
-
-// GDML
-#include "Saxana/SAXObject.h"
-
-// LCDD
-#include "UnsegmentedCalorimeterType.hh"
-
-/**
- * @brief The unsegmented_calorimeter element from the schema.
- */
-class unsegmented_calorimeter: public SAXObject, public UnsegmentedCalorimeterType
-{
-public:
- unsegmented_calorimeter()
- {
- }
-
- virtual ~unsegmented_calorimeter()
- {
- }
-
- virtual SAXObject::Type type()
- {
- return SAXObject::element;
- }
-};
-
-#endif
lcdd/schemas/lcdd/1.0
diff -u -r1.8 -r1.8.2.1
--- lcdd_sensitive_detectors.xsd 30 May 2013 00:04:12 -0000 1.8
+++ lcdd_sensitive_detectors.xsd 14 Aug 2013 00:23:22 -0000 1.8.2.1
@@ -5,21 +5,33 @@
elementFormDefault="unqualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:lcdd="http://www.lcsim.org/schemas/lcdd/1.0/">
+
+ <xs:complexType name="HitProcessorType">
+ <xs:attribute name="type" type="xs:string" use="required"/>
+ </xs:complexType>
+
+ <xs:complexType name="HitsCollectionType">
+ <xs:attribute name="name" type="xs:string" use="required"/>
+ </xs:complexType>
<xs:complexType name="SensitiveDetectorType">
+
<xs:annotation>
<xs:documentation>
- Sensitive detector type with a name id, hits collection name
- and a list of sensitive volumes
+ Sensitive detector type with a name, ID, and hits collection
</xs:documentation>
</xs:annotation>
-
- <xs:choice>
+
+ <xs:sequence>
<xs:element minOccurs="0" maxOccurs="1" name="idspecref" type="ReferenceType" />
- </xs:choice>
+ <xs:choice maxOccurs="unbounded">
+ <xs:element name="hit_processor" type="HitProcessorType" />
+ <xs:element name="hits_collection" type="HitsCollectionType" />
+ </xs:choice>
+ </xs:sequence>
<xs:attribute name="name" type="xs:ID" use="required" />
- <xs:attribute name="hits_collection" type="xs:string" use="required" />
+ <!--<xs:attribute name="hits_collection" type="xs:string" use="required" />-->
<xs:attribute name="endcap_flag" type="xs:boolean" default="false" />
<xs:attribute name="ecut" type="xs:double" default="0.0" />
<xs:attribute name="eunit" type="xs:string" default="MeV" />
@@ -31,7 +43,7 @@
</xs:restriction>
</xs:simpleType>
</xs:attribute>
-
+
</xs:complexType>
<xs:element abstract="true" name="sd" type="SensitiveDetectorType">
@@ -83,29 +95,7 @@
</xs:extension>
</xs:complexContent>
</xs:complexType>
-
- <xs:complexType name="OpticalCalorimeterType">
- <xs:annotation>
- <xs:documentation>
- Optical calorimeter sensitive detector type
- </xs:documentation>
- </xs:annotation>
- <xs:complexContent>
- <xs:extension base="CalorimeterType"/>
- </xs:complexContent>
- </xs:complexType>
-
- <xs:complexType name="UnsegmentedCalorimeterType">
- <xs:annotation>
- <xs:documentation>
- Optical calorimeter sensitive detector type
- </xs:documentation>
- </xs:annotation>
- <xs:complexContent>
- <xs:extension base="CalorimeterType"/>
- </xs:complexContent>
- </xs:complexType>
-
+
<xs:element name="calorimeter" substitutionGroup="sd" type="CalorimeterType">
<xs:annotation>
<xs:documentation>
@@ -114,22 +104,6 @@
</xs:annotation>
</xs:element>
- <xs:element name="optical_calorimeter" substitutionGroup="sd" type="OpticalCalorimeterType">
- <xs:annotation>
- <xs:documentation>
- Optical calorimeter sensitive detector element
- </xs:documentation>
- </xs:annotation>
- </xs:element>
-
- <xs:element name="unsegmented_calorimeter" substitutionGroup="sd" type="UnsegmentedCalorimeterType">
- <xs:annotation>
- <xs:documentation>
- Optical calorimeter sensitive detector element
- </xs:documentation>
- </xs:annotation>
- </xs:element>
-
<xs:complexType name="TrackerType">
<xs:annotation>
<xs:documentation>
@@ -151,33 +125,6 @@
</xs:annotation>
</xs:element>
- <xs:complexType name="ScorerType">
- <xs:annotation>
- <xs:documentation>
- Scoring plane sensitive detector type.
- Assigned LV should be thin, e.g. a few micron, and close to Vacuum.
- </xs:documentation>
- </xs:annotation>
-
- <xs:complexContent>
- <xs:extension base="SensitiveDetectorType">
- <xs:annotation>
- <xs:documentation>
- This type of SD ignore the ecut attribute, because this will often be 0 in a vacuum.
- </xs:documentation>
- </xs:annotation>
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
-
- <xs:element name="scorer" substitutionGroup="sd" type="ScorerType">
- <xs:annotation>
- <xs:documentation>
- Scoring plane element
- </xs:documentation>
- </xs:annotation>
- </xs:element>
-
<xs:complexType name="SegmentationType">
<xs:annotation>
<xs:documentation>
lcdd/src/lcdd/core
diff -u -r1.2 -r1.2.2.1
--- LCDDLibLoad.cc 2 Jul 2013 21:19:44 -0000 1.2
+++ LCDDLibLoad.cc 14 Aug 2013 00:23:22 -0000 1.2.2.1
@@ -24,12 +24,13 @@
// SDs
LOAD_COMPONENT(calorimeterProcess);
- LOAD_COMPONENT(optical_calorimeterProcess);
- LOAD_COMPONENT(unsegmented_calorimeterProcess);
LOAD_COMPONENT(trackerProcess);
- LOAD_COMPONENT(scorerProcess);
LOAD_COMPONENT(sdrefProcess);
+ // hit_processor
+ LOAD_COMPONENT(hit_processorProcess);
+ LOAD_COMPONENT(hits_collectionProcess);
+
// segmentations
LOAD_COMPONENT(grid_xyzProcess);
LOAD_COMPONENT(projective_cylinderProcess);
@@ -82,10 +83,7 @@
// SDs
LOAD_COMPONENT(calorimeterSubscriber);
- LOAD_COMPONENT(optical_calorimeterSubscriber);
- LOAD_COMPONENT(unsegmented_calorimeterSubscriber);
LOAD_COMPONENT(trackerSubscriber);
- LOAD_COMPONENT(scorerSubscriber);
// Ids
LOAD_COMPONENT(idspecSubscriber);
lcdd/src/lcdd/detectors
diff -N HitProcessorFactory.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ HitProcessorFactory.cc 14 Aug 2013 00:23:22 -0000 1.1.2.1
@@ -0,0 +1,15 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/Attic/HitProcessorFactory.cc,v 1.1.2.1 2013/08/14 00:23:22 jeremy Exp $
+
+#include "lcdd/detectors/HitProcessorFactory.hh"
+
+HitProcessorFactory::HitProcessorFactory()
+{
+ // TODO Auto-generated constructor stub
+
+}
+
+HitProcessorFactory::~HitProcessorFactory()
+{
+ // TODO Auto-generated destructor stub
+}
+
lcdd/src/lcdd/detectors
diff -N HitProcessorManager.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ HitProcessorManager.cc 14 Aug 2013 00:23:22 -0000 1.1.2.1
@@ -0,0 +1,49 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/Attic/HitProcessorManager.cc,v 1.1.2.1 2013/08/14 00:23:22 jeremy Exp $
+
+// LCDD
+#include "lcdd/detectors/HitProcessorManager.hh"
+#include "lcdd/detectors/LegacyCalorimeterHitProcessor.hh"
+#include "lcdd/detectors/UnsegmentedCalorimeterHitProcessor.hh"
+#include "lcdd/detectors/OpticalCalorimeterHitProcessor.hh"
+#include "lcdd/detectors/BasicTrackerHitProcessor.hh"
+#include "lcdd/detectors/ScoringTrackerHitProcessor.hh"
+#include "lcdd/detectors/StepCombiningTrackerHitProcessor.hh"
+
+HitProcessorManager* HitProcessorManager::_manager = 0;
+
+HitProcessorManager::HitProcessorManager()
+{
+ registerDefaultFactories();
+}
+
+HitProcessorManager::~HitProcessorManager()
+{
+}
+
+HitProcessorManager* HitProcessorManager::instance()
+{
+ if (_manager == 0) {
+ _manager = new HitProcessorManager();
+ }
+ return _manager;
+}
+
+void HitProcessorManager::registerDefaultFactories()
+{
+ registerFactory(new LegacyCalorimeterHitProcessorFactory());
+ registerFactory(new UnsegmentedCalorimeterHitProcessorFactory());
+ registerFactory(new OpticalCalorimeterHitProcessorFactory());
+ registerFactory(new ScoringTrackerHitProcessorFactory());
+ registerFactory(new BasicTrackerHitProcessorFactory());
+ registerFactory(new StepCombiningTrackerHitProcessorFactory());
+}
+
+void HitProcessorManager::registerFactory(HitProcessorFactory* factory)
+{
+ _factories[factory->handlesType()] = factory;
+}
+
+HitProcessorFactory* HitProcessorManager::getFactory(const std::string& hitProcessorType)
+{
+ return _factories[hitProcessorType];
+}
lcdd/src/lcdd/detectors
diff -N OpticalCalorimeterHitProcessor.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ OpticalCalorimeterHitProcessor.cc 14 Aug 2013 00:23:23 -0000 1.1.2.1
@@ -0,0 +1,107 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/Attic/OpticalCalorimeterHitProcessor.cc,v 1.1.2.1 2013/08/14 00:23:23 jeremy Exp $
+
+// LCDD
+#include "lcdd/detectors/OpticalCalorimeterHitProcessor.hh"
+#include "lcdd/detectors/ReadoutUtil.hh"
+
+// Geant4
+#include "G4OpticalPhoton.hh"
+#include "G4TransportationManager.hh"
+#include "G4VProcess.hh"
+#include "G4Poisson.hh"
+
+OpticalCalorimeterHitProcessor::OpticalCalorimeterHitProcessor(CalorimeterSD* calorimeter)
+ : CalorimeterHitProcessor(calorimeter)
+{
+ _cerenGenerator = new Cerenkov();
+}
+
+OpticalCalorimeterHitProcessor::~OpticalCalorimeterHitProcessor()
+{
+ delete _cerenGenerator;
+}
+
+bool OpticalCalorimeterHitProcessor::processHits(G4Step* step)
+{
+ std::cout << "OpticalCalorimeterHitProcessor::processHits" << std::endl;
+
+ G4int NCerenPhotons = 0;
+ G4Track* theTrack = step->GetTrack();
+ const G4double charge = theTrack->GetDefinition()->GetPDGCharge();
+ G4StepPoint* pPreStepPoint = step->GetPreStepPoint();
+ G4StepPoint* pPostStepPoint = step->GetPostStepPoint();
+ G4double beta = 0.5 * (pPreStepPoint->GetBeta() + pPostStepPoint->GetBeta());
+ const G4VTouchable* touch = step->GetPreStepPoint()->GetTouchable();
+ G4String thematerial = touch->GetVolume()->GetLogicalVolume()->GetMaterial()->GetName();
+ G4double MeanNumberOfPhotons = _cerenGenerator->GetAverageNumberOfPhotons(charge, beta, thematerial);
+ if (MeanNumberOfPhotons > 0.0) {
+ G4double step_length = step->GetStepLength();
+ MeanNumberOfPhotons = MeanNumberOfPhotons * step_length;
+ NCerenPhotons = (G4int) G4Poisson(MeanNumberOfPhotons);
+ } else {
+ NCerenPhotons = 0;
+ }
+
+ if (NCerenPhotons <= 0) {
+ return CalorimeterHitProcessor::processHits(step);
+ } else {
+ //SensitiveDetector::ProcessHits(aStep, 0);
+ G4ThreeVector myPoint = step->GetPreStepPoint()->GetPosition();
+ G4StepPoint* apreStepPoint = step->GetPreStepPoint();
+ G4Navigator* theNavigator = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
+ G4VPhysicalVolume* myVolume = theNavigator->LocateGlobalPointAndSetup(myPoint);
+ //if (_calorimeter->getVerbose() > 2) {
+ // G4cout << "Physical volume = " << myVolume->GetName() << G4endl;
+ // G4cout << "Point of interaction = " << myPoint<< G4endl;
+ // G4cout << "sdname " << GetName() << " hcname " <<collectionName[0]<< G4endl;
+ //}
+ // total photon energy
+ // G4double theEdep = aTrack->GetTotalEnergy();
+ G4double theEdep = double(NCerenPhotons);
+ // get global cell pos from seg
+ G4ThreeVector globalCellPos = getGlobalHitPosition(apreStepPoint);
+ // reset the seg bins
+ _calorimeter->getSegmentation()->resetBins();
+ // set the seg bins
+ _calorimeter->getSegmentation()->setBins(step);
+ // create id and pack into 64
+ Id64bit id64 = _calorimeter->makeIdentifier(step);
+ // find hit by simple lkp of new hit with above info
+ CalorimeterHit* thisHit = new CalorimeterHit(theEdep, globalCellPos);
+ thisHit->setId64bit(id64.getId0(), id64.getId1());
+ CalorimeterHit* foundHit = 0;
+ // hit is not found?
+ if (!(foundHit = _calorimeter->findHit(thisHit, eCerenkov))) {
+ _calorimeter->addHit(foundHit, eCerenkov);
+ } else {
+ // found a hit
+ // don't need to insert thisHit, so delete it
+ delete thisHit;
+ thisHit = 0;
+ // incr total edep of the hit
+ foundHit->addEnergyDeposition(theEdep);
+ // for setting contrib
+ thisHit = foundHit;
+ }
+ // add McpHitContrib to this hit, setting info from step info
+ thisHit->addHitContribution(HitContribution(step));
+ return true;
+ } // end Cerenkov photon treatment
+}
+
+G4ThreeVector OpticalCalorimeterHitProcessor::getGlobalHitPosition(const G4StepPoint* aPreStepPoint)
+{
+ G4ThreeVector globalStepPos = aPreStepPoint->GetPosition();
+
+ // Figure out local step pos using touchable and global midpoint.
+ G4ThreeVector localStepPos = ReadoutUtil::transformGlobalToLocal(aPreStepPoint, globalStepPos);
+
+ // Compute local cell pos.
+ G4ThreeVector localCellPos = _calorimeter->getSegmentation()->getLocalHitPosition(localStepPos);
+
+ // Compute global cell pos.
+ G4ThreeVector globalCellPos = ReadoutUtil::transformLocalToGlobal(aPreStepPoint, localCellPos);
+
+ return globalCellPos;
+}
+
lcdd/src/lcdd/detectors
diff -N ScoringTrackerHitProcessor.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ScoringTrackerHitProcessor.cc 14 Aug 2013 00:23:23 -0000 1.1.2.1
@@ -0,0 +1,81 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/Attic/ScoringTrackerHitProcessor.cc,v 1.1.2.1 2013/08/14 00:23:23 jeremy Exp $
+
+// LCDD
+#include "lcdd/detectors/ScoringTrackerHitProcessor.hh"
+#include "lcdd/hits/TrackInformation.hh"
+
+// Geant4
+#include "G4ThreeVector.hh"
+
+ScoringTrackerHitProcessor::ScoringTrackerHitProcessor(TrackerSD* tracker)
+ : TrackerHitProcessor(tracker), _currentTrackId(-1)
+{
+}
+
+ScoringTrackerHitProcessor::~ScoringTrackerHitProcessor()
+{
+}
+
+bool ScoringTrackerHitProcessor::processHits(G4Step* step)
+{
+ bool sameTrack = false;
+
+ int trackId = step->GetTrack()->GetTrackID();
+
+ if ((_currentTrackId == -1) || (_currentTrackId != trackId)) {
+ _currentTrackId = trackId;
+ } else {
+ sameTrack = true;
+ }
+
+ if (!sameTrack) {
+
+ // edep
+ G4double e = step->GetTotalEnergyDeposit();
+
+ // get track information
+ TrackInformation* trkInfo = TrackInformation::getTrackInformation(step);
+
+ // set hit flag in trk info
+ trkInfo->setHasTrackerHit(true);
+
+ // hit data
+ G4int trkID = trackId;
+ G4double tdep = step->GetTrack()->GetGlobalTime();
+ G4ThreeVector prePosition = step->GetPreStepPoint()->GetPosition();
+ G4ThreeVector meanMomentum = 0.5 * (step->GetPreStepPoint()->GetPosition() + step->GetPostStepPoint()->GetPosition());
+
+ // create hit
+ TrackerHit* newHit = new TrackerHit();
+
+ // create id vector
+ Id64bit id64 = _tracker->makeIdentifier(step);
+
+ // Get the start position from the pre-step point.
+ G4ThreeVector start = step->GetPreStepPoint()->GetPosition();
+
+ // Get the end position from the post-step point.
+ G4ThreeVector end = step->GetPostStepPoint()->GetPosition();
+
+ // Compute the step's path length.
+ G4double length = sqrt(
+ pow(start.x() - end.x(), 2) +
+ pow(start.y() - end.y(), 2) +
+ pow(start.z() - end.z(), 2));
+
+ // Set the hit information.
+ newHit->setTrackID(trkID);
+ newHit->setEdep(e);
+ newHit->setPos(prePosition);
+ newHit->setMomentum(meanMomentum);
+ newHit->setTdep(tdep);
+ newHit->setId(id64.getId0());
+ newHit->setLength(length);
+
+ // Add hit to SD.
+ _tracker->addHit(newHit, false);
+ }
+ return true;
+}
+
+
lcdd/src/lcdd/detectors
diff -N UnsegmentedCalorimeterHitProcessor.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ UnsegmentedCalorimeterHitProcessor.cc 14 Aug 2013 00:23:23 -0000 1.1.2.1
@@ -0,0 +1,59 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/Attic/UnsegmentedCalorimeterHitProcessor.cc,v 1.1.2.1 2013/08/14 00:23:23 jeremy Exp $
+
+// LCDD
+#include "lcdd/detectors/UnsegmentedCalorimeterHitProcessor.hh"
+
+// Geant4
+#include "G4Geantino.hh"
+#include "G4ChargedGeantino.hh"
+
+UnsegmentedCalorimeterHitProcessor::UnsegmentedCalorimeterHitProcessor(CalorimeterSD* calorimeter)
+ : CalorimeterHitProcessor(calorimeter)
+{
+}
+
+UnsegmentedCalorimeterHitProcessor::~UnsegmentedCalorimeterHitProcessor()
+{
+}
+
+bool UnsegmentedCalorimeterHitProcessor::processHits(G4Step* step)
+{
+ // Get the energy deposition.
+ G4double theEdep = step->GetTotalEnergyDeposit();
+
+ // Check for Geantino particle type.
+ G4ParticleDefinition* def = step->GetTrack()->GetDefinition();
+ bool isGeantino = false;
+ if (def == G4Geantino::Definition() || def == G4ChargedGeantino::Definition()) {
+ isGeantino = true;
+ }
+
+ // This needs to be a <= comparison for cutting on 0,
+ // but it allows geantinos, which always have 0 edep.
+ if (theEdep <= _calorimeter->getEnergyCut() && isGeantino == false) {
+ return false;
+ }
+
+ // Get the step mid position.
+ G4ThreeVector hitPos = (0.5 * (step->GetPreStepPoint()->GetPosition() + step->GetPostStepPoint()->GetPosition()));
+
+ // Create a 64-bit ID.
+ Id64bit id64 = _calorimeter->makeIdentifier(step);
+
+ // Create a new hit.
+ CalorimeterHit* newHit = new CalorimeterHit(theEdep, hitPos);
+
+ // Set the 64-bit ID.
+ newHit->setId64bit(id64.getId0(), id64.getId1());
+
+ // Add the hit to the SD.
+ _calorimeter->addHit(newHit);
+
+ // Add an MCParticle contribution for this hit.
+ newHit->addHitContribution(HitContribution(step));
+
+ // Return true because added hit.
+ return true;
+
+}
+
lcdd/src/lcdd/detectors
diff -u -r1.4 -r1.4.2.1
--- CalorimeterHitProcessor.cc 11 Jul 2013 20:41:54 -0000 1.4
+++ CalorimeterHitProcessor.cc 14 Aug 2013 00:23:22 -0000 1.4.2.1
@@ -1,15 +1,9 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/CalorimeterHitProcessor.cc,v 1.4 2013/07/11 20:41:54 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/CalorimeterHitProcessor.cc,v 1.4.2.1 2013/08/14 00:23:22 jeremy Exp $
// LCDD
#include "lcdd/detectors/CalorimeterHitProcessor.hh"
#include "lcdd/detectors/CalorimeterSD.hh"
-// STL
-//#include <iostream>
-
-// Geant4
-//#include "G4NavigationHistory.hh"
-
CalorimeterHitProcessor::CalorimeterHitProcessor(CalorimeterSD* calorimeter) :
_calorimeter(calorimeter)
{
@@ -19,60 +13,7 @@
{
}
-/*
bool CalorimeterHitProcessor::processHits(G4Step* step)
{
- // Compute the step's mid-point in global coordinates.
- 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 the local position of the mid-point using its global position and the touchable handle into the geometry.
- 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 = _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 = _readout->position(cellId);
-
- // DEBUG: print local cell position
- //std::cout << "cellPosition = " << cellPosition.first << ", " << cellPosition.second << std::endl;
-
- // Transform the local cell position to global.
- G4ThreeVector cellVec(cellPosition.first, cellPosition.second, 0);
-
- // Compute the global position from local point and the touchable handle.
- 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 a hit from id, position, energy, & time
- //G4CalorimeterHit* hit = new G4CalorimeterHit();
-
- return true;
+ return false;
}
-*/
lcdd/src/lcdd/detectors
diff -u -r1.6 -r1.6.2.1
--- CalorimeterSD.cc 11 Jul 2013 22:39:17 -0000 1.6
+++ CalorimeterSD.cc 14 Aug 2013 00:23:22 -0000 1.6.2.1
@@ -1,19 +1,10 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/CalorimeterSD.cc,v 1.6 2013/07/11 22:39:17 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/CalorimeterSD.cc,v 1.6.2.1 2013/08/14 00:23:22 jeremy Exp $
// LCDD
#include "lcdd/detectors/CalorimeterSD.hh"
#include "lcdd/detectors/Segmentation.hh"
-//#include "lcdd/detectors/ReadoutUtil.hh"
#include "lcdd/detectors/PositionComparator.hh"
-//#include "lcdd/hits/HitContribution.hh"
-//#include "lcdd/id/IdFactory.hh"
-//#include "lcdd/id/IdManager.hh"
-
-// Geant4
-//#include "G4Track.hh"
-//#include "G4StepPoint.hh"
-//#include "G4Timer.hh"
-//#include "G4Geantino.hh"
+#include "lcdd/id/IdComparator.hh"
// STL
#include <iostream>
@@ -22,12 +13,18 @@
using std::vector;
-CalorimeterSD::CalorimeterSD(G4String sdName, G4String hcName, Segmentation* sdSeg, HitComparator* compare) :
- SensitiveDetector(sdName, hcName, SensitiveDetector::eCalorimeter), _segmentation(sdSeg)
+CalorimeterSD::CalorimeterSD(
+ G4String sdName,
+ G4String hcName,
+ Segmentation* sdSeg,
+ HitComparator* compare) :
+ SensitiveDetector(
+ sdName,
+ hcName,
+ SensitiveDetector::eCalorimeter),
+ _segmentation(sdSeg)
{
_hitsCollections.push_back(_collection);
- //_hits.clear();
- //_hitsVector.clear();
_hitsVector.push_back(_hits);
if (compare == 0)
_hitCompare = new PositionComparator();
@@ -35,12 +32,18 @@
_hitCompare = compare;
}
-CalorimeterSD::CalorimeterSD(G4String sdName, const vector<G4String>& hcNames, Segmentation* sdSeg, HitComparator* compare) :
- SensitiveDetector(sdName, hcNames, SensitiveDetector::eCalorimeter), _segmentation(sdSeg)
+CalorimeterSD::CalorimeterSD(
+ G4String sdName,
+ const vector<G4String>& hcNames,
+ Segmentation* sdSeg,
+ HitComparator* compare) :
+ SensitiveDetector(
+ sdName,
+ hcNames,
+ SensitiveDetector::eCalorimeter),
+ _segmentation(sdSeg)
{
- //_hits.clear();
- //_hitsVector.clear();
- _hitsVector.push_back(_hits);
+ _hitsVector.push_back(_hits); // What does this do???
for (int i = 0; i < (int) hcNames.size(); i++) {
_hitsVector.push_back(_hits);
_hitsVector[i].clear();
@@ -75,14 +78,15 @@
// new cal hits collection
for (int i = 0; i < getNumberOfHitsCollections(); i++) {
- _hitsCollections[i] = new G4CalorimeterHitsCollection(GetName(), collectionName[i]);
- // set HCID
+ _hitsCollections[i] = new CalorimeterHitsCollection(GetName(), collectionName[i]);
+
+ // Set HCID as it has a dummy value of zero by default.
if (getHCID(i) < 0) {
setHCID(GetCollectionID(i), i);
}
- // add collection to HC of event
+ // Add the hit collection to the hit collections of the event.
HCE->AddHitsCollection(getHCID(i), _hitsCollections[i]);
}
}
@@ -197,3 +201,9 @@
// add to the HC
_hitsCollections[0]->insert(hit);
}
+
+void CalorimeterSD::addHit(CalorimeterHit* hit, int collectionIndex)
+{
+ _hitsVector[collectionIndex].push_back(hit);
+ _hitsCollections[collectionIndex]->insert(hit);
+}
lcdd/src/lcdd/detectors
diff -u -r1.5 -r1.5.2.1
--- SensitiveDetector.cc 11 Jul 2013 20:41:54 -0000 1.5
+++ SensitiveDetector.cc 14 Aug 2013 00:23:23 -0000 1.5.2.1
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/SensitiveDetector.cc,v 1.5 2013/07/11 20:41:54 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/SensitiveDetector.cc,v 1.5.2.1 2013/08/14 00:23:23 jeremy Exp $
// LCDD
#include "lcdd/detectors/SensitiveDetector.hh"
@@ -26,8 +26,8 @@
const std::string& SensitiveDetector::calorimeterStr = "calorimeter";
const std::string& SensitiveDetector::noneStr = "none";
-SensitiveDetector::SensitiveDetector(G4String sdName, G4String hcName, EType sdType) :
- G4VSensitiveDetector(sdName), _idspec(0), _type(sdType)
+SensitiveDetector::SensitiveDetector(G4String sdName, G4String hcName, EType sdType)
+ : G4VSensitiveDetector(sdName), _idspec(0), _type(sdType)
{
// insert hits collection name into SD's name vector
collectionName.insert(hcName);
@@ -39,14 +39,14 @@
_messenger = new SensitiveDetectorMessenger(this);
// Only one HC
- _hcids.clear();
+ _hcids.clear(); // Is this needed???
_hcids.push_back(-1);
}
SensitiveDetector::SensitiveDetector(G4String sdName, const vector<G4String>& hcNames, EType sdType) :
G4VSensitiveDetector(sdName), _idspec(0), _type(sdType)
{
- _hcids.clear();
+ _hcids.clear(); // Is this needed???
for (int i = 0; i < (int) hcNames.size(); i++) {
// insert hits collection name into SD's name vector
@@ -61,6 +61,16 @@
_messenger = new SensitiveDetectorMessenger(this);
}
+//SensitiveDetector::SensitiveDetector(G4String name, EType type)
+// : G4VSensitiveDetector(name), _idspec(0), _type(type)
+//{
+ // register detector with G4SDManager
+// G4SDManager::GetSDMpointer()->AddNewDetector(this);
+
+ // Create the command messenger.
+// _messenger = new SensitiveDetectorMessenger(this);
+//}
+
SensitiveDetector::~SensitiveDetector()
{
// Delete registered HitProcessors.
@@ -81,12 +91,15 @@
G4bool SensitiveDetector::ProcessHits(G4Step* aStep, G4TouchableHistory*)
{
+ std::cout << "SensitiveDetector::ProcessHits" << std::endl;
+
// Set the cached step data.
setStep(aStep);
// Call the processHits() methods of the registered HitProcessors.
bool madeHits = false;
for (HitProcessors::iterator it = _hitProcessors.begin(); it != _hitProcessors.end(); it++) {
+ std::cout << "calling hits processor" << std::endl;
bool processorMadeHit = (*it)->processHits(aStep);
if (processorMadeHit == true && madeHits == false) {
madeHits = true;
@@ -330,3 +343,22 @@
{
_hitProcessors.push_back(processor);
}
+
+SensitiveDetector::HitProcessors SensitiveDetector::getHitProcessors()
+{
+ return _hitProcessors;
+}
+
+void SensitiveDetector::addHitProcessors(std::vector<HitProcessor*> processors)
+{
+ for (HitProcessors::iterator it = processors.begin(); it != processors.end(); it++) {
+ _hitProcessors.push_back(*it);
+ }
+}
+
+//void SensitiveDetector::addHitsCollection(G4String collectionName)
+//{
+// std::cout << "SensitiveDetector::addHitsCollection - " << collectionName << std::endl;
+// this->collectionName.insert(collectionName);
+// _hcids.push_back(-1);
+//}
lcdd/src/lcdd/detectors
diff -u -r1.4 -r1.4.2.1
--- SensitiveDetectorFactory.cc 11 Jul 2013 22:39:17 -0000 1.4
+++ SensitiveDetectorFactory.cc 14 Aug 2013 00:23:23 -0000 1.4.2.1
@@ -1,155 +1,185 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/SensitiveDetectorFactory.cc,v 1.4 2013/07/11 22:39:17 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/SensitiveDetectorFactory.cc,v 1.4.2.1 2013/08/14 00:23:23 jeremy Exp $
// LCDD
#include "lcdd/detectors/SensitiveDetectorFactory.hh"
-#include "lcdd/detectors/TrackerCombineSD.hh"
-#include "lcdd/detectors/ScorerSD.hh"
-#include "lcdd/detectors/TrackerSD.hh"
-#include "lcdd/detectors/OpticalCalorimeterSD.hh"
-#include "lcdd/detectors/UnsegmentedCalorimeterSD.hh"
+#include "lcdd/id/IdComparator.hh"
+#include "lcdd/util/StringUtil.hh"
#include "lcdd/detectors/PositionComparator.hh"
+#include "lcdd/detectors/HitProcessorManager.hh"
#include "lcdd/detectors/LegacyCalorimeterHitProcessor.hh"
#include "lcdd/detectors/BasicTrackerHitProcessor.hh"
-#include "lcdd/detectors/StepCombiningTrackerHitProcessor.hh"
-#include "lcdd/id/IdComparator.hh"
-#include "lcdd/util/StringUtil.hh"
+#include "lcdd/detectors/ScoringTrackerHitProcessor.hh"
+#include "lcdd/schema/hit_processor.hh"
+#include "lcdd/schema/hits_collection.hh"
SensitiveDetector* SensitiveDetectorFactory::createSensitiveDetector(const SAXObject* object)
{
- SensitiveDetector* sd = 0;
- const SensitiveDetectorType* sdt = dynamic_cast<const SensitiveDetectorType*>(object);
+ //std::cout << "SensitiveDetectorFactory::createSensitiveDetector" << std::endl;
+
+ const SensitiveDetectorType* sensitiveDetectorType = dynamic_cast<const SensitiveDetectorType*>(object);
+ SensitiveDetector* sensitiveDetector = 0;
+ IdSpec* idspec = 0;
+ std::vector<HitProcessor*> hitProcessors;
+ std::vector<G4String> hitsCollections;
// The SAXObject must extend SensitiveDetectorType.
- if (sdt) {
+ if (sensitiveDetectorType) {
// Get the SensitiveDetector's basic type string.
- std::string sd_type = sdt->get_type();
+ std::string sensitiveDetectorTypeName = sensitiveDetectorType->get_type();
- // Create calorimeter. Valid types have "calorimeter" in their element name.
- if (std::string::npos != sd_type.find("calorimeter")) {
+ // Process element content for objects that need to be created before the SD.
+ ContentSequence* seq = const_cast<ContentSequence*>(sensitiveDetectorType->get_content());
+ size_t count = seq->size();
+ for (size_t i = 0; i < count; i++) {
- sd = createCalorimeterSD(object);
+ std::string childTag = seq->content(i).tag;
- // Add the default HitProcessor.
- sd->addHitProcessor(new LegacyCalorimeterHitProcessor(dynamic_cast<CalorimeterSD*>(sd)));
- // Create tracker.
- } else if (sd_type == "tracker") {
- sd = createTrackerSD(object);
- // Create scorer.
- } else if (sd_type == "scorer") {
- sd = createScorerSD(object);
- // Something went wrong. Type is not good.
- } else {
- // Type is not recognized.
- G4cerr << "Invalid sensitive detector type: " << sd_type << G4endl;
- G4Exception("", "", FatalException, "Unknown sensitive detector type.");
+ // Process idspecref child tag.
+ if (childTag == "idspecref") {
+
+ // Cast the SAXObject to appropriate element type.
+ IdSpecType::idspecref* ref = dynamic_cast<IdSpecType::idspecref*>(seq->content(i).object);
+
+ // Get the idspec pointed to by the idspecref.
+ idspec = IdManager::instance()->getIdSpec(ref->get_ref());
+
+ // Check if the IdSpec exists.
+ if (idspec == 0) {
+ G4cerr << "IdSpec <" << ref->get_ref() << "> referenced by detector <" << sensitiveDetectorType->get_name() << "> does not exist." << G4endl;
+ G4Exception("", "", FatalException, "IdSpec does not exist.");
+ }
+
+ // Process hit_processor child tag.
+ } else if (childTag == "hit_processor") {
+
+ // Cast object to appropriate element type.
+ const hit_processor* hitProcessor = dynamic_cast<const hit_processor*>(seq->content(i).object);
+
+ // Get the type of the HitProcessor.
+ std::string type = hitProcessor->get_type();
+
+ // Lookup the HitProcessor type using the manager.
+ HitProcessorFactory* hitProcessorFactory = HitProcessorManager::instance()->getFactory(type);
+ if (hitProcessorFactory == 0) {
+ std::cerr << "HitProcessorFactory was not found for type: " << hitProcessor->get_type() << std::endl;
+ G4Exception("", "", FatalException, "HitProcessor not found");
+ }
+ HitProcessor* processor = hitProcessorFactory->createHitProcessor(sensitiveDetector);
+
+ // Add the HitProcessor to the list.
+ hitProcessors.push_back(processor);
+
+ // Process hits_collection child tag.
+ } else if (childTag == "hits_collection") {
+
+ // Cast object to appropriate element type.
+ const hits_collection* hitsCollection = dynamic_cast<const hits_collection*>(seq->content(i).object);
+
+ // Get the name of the hits collection.
+ const std::string& name = hitsCollection->get_name();
+
+ //std::cout << "adding hits collection: " << name << std::endl;
+
+ // Add hits collection to the list.
+ hitsCollections.push_back(name);
+ }
}
- // Set the energy cut and verbosity.
- setBaseSensitiveDetectorAttributes(sd, sdt);
+ // Add the default HitsCollection, which is the name of the SD, if none were specified in the XML.
+ if (hitsCollections.size() == 0) {
+ hitsCollections.push_back(sensitiveDetectorType->get_name());
+ }
- // Find the IdSpec.
- IdSpec* idspec = findIdSpec(sdt);
+ // Create the SD object based on its type of calorimeter or tracker.
+ if (sensitiveDetectorTypeName == "calorimeter") {
+ // Create calorimeter SD.
+ sensitiveDetector = createCalorimeter(object, hitsCollections);
+ } else if (sensitiveDetectorTypeName == "tracker") {
+ // Create tracker SD.
+ sensitiveDetector = createTracker(object);
+ } else {
+ // Type is not recognized. This shouldn't happen!
+ G4cerr << "Invalid sensitive detector type: " << sensitiveDetectorTypeName << G4endl;
+ G4Exception("", "", FatalException, "Unknown sensitive detector type.");
+ }
- // Set the IdSpec, if it exists.
- if (idspec != 0) {
- sd->setIdSpec(idspec);
+ // Set the base attributes.
+ sensitiveDetector->setEcut(SensitiveDetectorFactory::computeEcut(sensitiveDetectorType));
+ sensitiveDetector->setVerbose(SensitiveDetectorFactory::convertVerbose(sensitiveDetectorType));
+ sensitiveDetector->setEndcapFlag(StringUtil::toBool(sensitiveDetectorType->get_endcap_flag()));
+
+ // Set the IdSpec.
+ sensitiveDetector->setIdSpec(idspec);
+
+ // Add the HitProcessors from the list.
+ if (hitProcessors.size() == 0) {
+ // Add HitProcessors created from XML.
+ sensitiveDetector->addHitProcessors(hitProcessors);
+ } else {
+ // Need to add default HitProcessors because none were specified.
+ if (sensitiveDetectorTypeName == "tracker") {
+ // Default TrackerHitProcessor.
+ HitProcessorManager::instance()->getFactory("BasicTrackerHitProcessor")->createHitProcessor(sensitiveDetector);
+ } else if (sensitiveDetectorTypeName == "calorimeter" ) {
+ // Default CalorimeterHitProcessor.
+ HitProcessorManager::instance()->getFactory("LegacyCalorimeterHitProcessor")->createHitProcessor(sensitiveDetector);
+ }
}
- // Register the SensitiveDetector with LCDDProcessor.
- std::string sdName = sd->GetName();
- LCDDProcessor::instance()->addSensitiveDetector(sdName, sd);
- // This should never really happen!
+ // Register the SensitiveDetector with the LCDDProcessor.
+ std::string sensitiveDetectorName = sensitiveDetector->GetName();
+ std::cout << "registering SD: " << sensitiveDetectorName << std::endl;
+ LCDDProcessor::instance()->addSensitiveDetector(sensitiveDetectorName, sensitiveDetector);
} else {
+ // This should never really happen.
G4Exception("", "", FatalException, "Failed cast to SensitiveDetectorType.");
}
- return sd;
+ return sensitiveDetector;
}
-CalorimeterSD* SensitiveDetectorFactory::createCalorimeterSD(const SAXObject* object)
+SensitiveDetector* SensitiveDetectorFactory::createCalorimeter(const SAXObject* object, const std::vector<G4String>& hitsCollections)
{
- CalorimeterSD* sd = 0;
- Segmentation* seg = 0;
-
- const SensitiveDetectorType* sdt = dynamic_cast<const SensitiveDetectorType*>(object);
-
- std::string sd_type = sdt->get_type();
-
+ const SensitiveDetectorType* sensitiveDetectorType = dynamic_cast<const SensitiveDetectorType*>(object);
+ Segmentation* segmentation = 0;
// Create the segmentation.
- ContentSequence* seq = const_cast<ContentSequence*>(sdt->get_content());
+ ContentSequence* seq = const_cast<ContentSequence*>(sensitiveDetectorType->get_content());
size_t count = seq->size();
-
- // Look for segmentation tag.
bool fnd_seg = false;
for (size_t i = 0; i < count; i++) {
std::string child_tag = seq->content(i).tag;
const ContentGroup::ContentItem& segitem = seq->content(i);
-
// Create segmentation using factory.
if (isSegmentationTag(child_tag)) {
- seg = SegmentationFactory::createSegmentation(segitem.object, segitem.tag);
+ segmentation = SegmentationFactory::createSegmentation(segitem.object, segitem.tag);
fnd_seg = true;
break;
}
}
-
// Get the calorimeter XML object.
const calorimeter* cal = dynamic_cast<const calorimeter*>(object);
- // Find out hit aggregation algorithm.
+ // Determine the hit aggregation class to assign.
const std::string& hitCompareStr = cal->get_compare();
-
- // Comparison algorithm to be used for combining hits, to be determined from SD.
HitComparator* hitCompare = 0;
-
- // Find the IdSpec.
- IdSpec* idspec = findIdSpec(sdt);
-
- if (hitCompareStr != "id" && hitCompareStr != "position") {
- G4cerr << "Invalid selection for hit comparison <" << hitCompareStr << ">, for calorimeter <" << sdt->get_name() << ">." << G4endl;
- G4Exception("", "", FatalException, "Invalid selection for hit comparison.");
- }
-
- // Compare on IDs.
if (hitCompareStr == "id") {
- if (idspec) {
- hitCompare = new IdComparator();
- } else {
- std::cerr << "WARNING: IdSpec for <" << sdt->get_name() << "> does not exist! Position comparison will be used for hit aggregation instead of id." << std::endl;
- }
- }
-
- // Compare on position.
- if (!hitCompare) {
+ // Compare by ID, which is the default via the XML schema.
+ hitCompare = new IdComparator();
+ } else if (hitCompareStr == "position") {
+ // Compare by position.
hitCompare = new PositionComparator();
- }
-
- if (sd_type == "calorimeter") {
- sd = new CalorimeterSD(sdt->get_name(), sdt->get_hitsCollectionName(), seg, hitCompare);
- } else if (sd_type == "optical_calorimeter") {
- //
- // in case of optical alorimeter there are 2 hit collections
- //
- //G4String hcnames[2];
- // TODO Fix hardcoded collection names.
- std::vector<G4String> hcnames;
- hcnames.push_back("Edep_" + sdt->get_hitsCollectionName());
- hcnames.push_back("Ceren_" + sdt->get_hitsCollectionName());
-
- sd = new OpticalCalorimeterSD(sdt->get_name(), hcnames, seg, hitCompare);
- } else if (sd_type == "unsegmented_calorimeter") {
- // Segmentation could be null but that is fine for this type of calorimeter.
- sd = new UnsegmentedCalorimeterSD(sdt->get_name(), sdt->get_hitsCollectionName(), seg);
} else {
- G4cerr << "Unknown sensitive detector type: " << sd_type << G4endl;
- G4Exception("SensitiveDetectorFactory", "", FatalException, "Unknown sensitive detector type.");
+ // Invalid comparison algorithm was given.
+ G4cerr << "SensitiveDetectorFactory::createCalorimeter - invalid hit comparison algorithm <" << hitCompareStr << "> specified for calorimeter <" << sensitiveDetectorType->get_name() << ">" << G4endl;
+ G4Exception("", "", FatalException, "Invalid selection for hit comparison.");
}
- return sd;
+ // Create the calorimeter SD.
+ return new CalorimeterSD(sensitiveDetectorType->get_name(), hitsCollections, segmentation, hitCompare);
}
-TrackerSD* SensitiveDetectorFactory::createTrackerSD(const SAXObject* object)
+TrackerSD* SensitiveDetectorFactory::createTracker(const SAXObject* object)
{
// Cast the SAXObject to tracker element.
const tracker* trackerElement = dynamic_cast<const tracker*>(object);
@@ -157,81 +187,15 @@
// Get the name of the SensitiveDetector.
std::string name = trackerElement->get_name();
- // Get the name of the hit collection.
+ // Get the name of the hits collection.
std::string hitCollection = trackerElement->get_hitsCollectionName();
- // Check if the hit collection name is valid.
- if (checkHCName(hitCollection)) {
- G4cerr << "invalid hit collection name: " << hitCollection << G4endl;
- G4Exception("SensitiveDetectorFactory", "", FatalException, "Name of the hits collection is invalid.");
- }
-
// Create the basic TrackerSD.
TrackerSD* sd = new TrackerSD(name, hitCollection);
- // Check for hit aggregation setting and set the HitProcessor accordingly.
- bool combineHits = StringUtil::toBool(trackerElement->get_combine_hits());
- if (combineHits) {
- // Add the StepCombiningTrackerHitProcessor which will aggregate hits.
- sd->addHitProcessor(new StepCombiningTrackerHitProcessor(sd));
- } else {
- // Add the BasicTrackerHitProcessor.
- sd->addHitProcessor(new BasicTrackerHitProcessor(sd));
- }
-
- return sd;
-}
-
-ScorerSD* SensitiveDetectorFactory::createScorerSD(const SAXObject* object)
-{
- const scorer * scr = dynamic_cast<const scorer*>(object);
-
- ScorerSD* sd = 0;
-
- std::string nm = scr->get_name();
- std::string hc = scr->get_hitsCollectionName();
-
- if (checkHCName(hc)) {
- G4Exception("SensitiveDetectorFactory", "", FatalException, "Name of the hits collections is invalid.");
- }
-
- sd = new ScorerSD(nm, hc);
return sd;
}
-IdSpec* SensitiveDetectorFactory::findIdSpec(const SensitiveDetectorType* sdt)
-{
- IdSpec* idspec = 0;
- ContentSequence* seq = const_cast<ContentSequence*>(sdt->get_content());
- size_t count = seq->size();
- for (size_t i = 0; i < count; i++) {
-
- std::string child_tag = seq->content(i).tag;
-
- // find idspec
- if (child_tag == "idspecref") {
- IdSpecType::idspecref* id_ref = dynamic_cast<IdSpecType::idspecref*>(seq->content(i).object);
-
- idspec = IdManager::instance()->getIdSpec(id_ref->get_ref());
-
- if (idspec == 0) {
- G4cerr << "IdSpec <" << id_ref->get_ref() << "> referenced by detector <" << sdt->get_name() << "> does not exist." << G4endl;
- G4Exception("", "", FatalException, "IdSpec does not exist.");
- }
-
- break;
- }
- }
- return idspec;
-}
-
-void SensitiveDetectorFactory::setBaseSensitiveDetectorAttributes(SensitiveDetector* sd, const SensitiveDetectorType* sdt)
-{
- sd->setEcut(SensitiveDetectorFactory::computeEcut(sdt));
- sd->setVerbose(SensitiveDetectorFactory::convertVerbose(sdt));
- sd->setEndcapFlag(StringUtil::toBool(sdt->get_endcap_flag()));
-}
-
double SensitiveDetectorFactory::computeEcut(const SensitiveDetectorType* sdt)
{
GDMLExpressionEvaluator* calc = GDMLProcessor::GetInstance()->GetEvaluator();
@@ -249,29 +213,15 @@
return verbose;
}
-// NOTE: New segmentations must appear here!
bool SensitiveDetectorFactory::isSegmentationTag(const std::string& s)
{
- // @todo Fix this to know all segmentation types automatically somehow. (schema?)
- return (s == "projective_cylinder" || s == "grid_xyz" || s == "global_grid_xy" || s == "nonprojective_cylinder" || s == "projective_zplane" || s == "cell_readout_2d");
-}
-
-bool SensitiveDetectorFactory::checkHCName(const std::string& s)
-{
- bool bad = false;
-
- // Ss size <= 1 ?
- if (s.size() <= 1) {
- bad = true;
- } else {
- LCDDProcessor* proc = LCDDProcessor::instance();
- for (LCDDProcessor::SensitiveDetectors::const_iterator iter = proc->getSensitiveDetectorsBegin(); iter != proc->getSensitiveDetectorsBegin(); iter++) {
- if (iter->second->getHCName() == s) {
- bad = true;
- //std::cerr << "HCName <" << s << "> already assigned to SD <" << iter->second->GetName() << ">." << std::endl;
- break;
- }
- }
- }
- return bad;
+ // FIXME This should automatically know all segmentation types somehow.
+ // Can this be read from the schema?
+ // http://xerces-c.sourcearchive.com/documentation/3.1.1-1/SchemaGrammar_8hpp_source.html
+ return (s == "projective_cylinder" ||
+ s == "grid_xyz" ||
+ s == "global_grid_xy" ||
+ s == "nonprojective_cylinder" ||
+ s == "projective_zplane" ||
+ s == "cell_readout_2d");
}
lcdd/src/lcdd/detectors
diff -u -r1.4 -r1.4.2.1
--- TrackerSD.cc 11 Jul 2013 22:39:17 -0000 1.4
+++ TrackerSD.cc 14 Aug 2013 00:23:23 -0000 1.4.2.1
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/TrackerSD.cc,v 1.4 2013/07/11 22:39:17 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/TrackerSD.cc,v 1.4.2.1 2013/08/14 00:23:23 jeremy Exp $
// LCDD
//#include "lcdd/id/IdManager.hh"
@@ -21,6 +21,12 @@
_hits.clear();
}
+//TrackerSD::TrackerSD(G4String sdName) :
+// SensitiveDetector(sdName, SensitiveDetector::eTracker), _HC(0)
+//{
+// _hits.clear();
+//}
+
TrackerSD::~TrackerSD()
{
}
lcdd/src/lcdd/detectors
diff -N OpticalCalorimeterSD.cc
--- OpticalCalorimeterSD.cc 11 Jul 2013 20:41:54 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,134 +0,0 @@
-// $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"
-#include "lcdd/detectors/ReadoutUtil.hh"
-#include "lcdd/detectors/Segmentation.hh"
-#include "lcdd/detectors/Cerenkov.hh"
-
-// Geant4
-#include "G4OpticalPhoton.hh"
-#include "G4TransportationManager.hh"
-#include "G4VProcess.hh"
-#include "G4Poisson.hh"
-
-using std::vector;
-
-/**
- * Constructor for the case only one Hit Collection is given.
- * In this case the only the energy deposited by aborbed Cerenkov
- * photons is stored. Probably this will be dropped in the
- * near future.
- */
-OpticalCalorimeterSD::OpticalCalorimeterSD(G4String sdName, G4String hcName, Segmentation* sdSeg, HitComparator* compare) :
- CalorimeterSD(sdName, hcName, sdSeg, compare)
-{
- CerenGenerator = 0;
-}
-
-/**
- * Constructor for multiple Hit Collections.
- *
- * The current implementation uses the first Hit Collection for the
- * Cerenkov Photons and the second Collection to store the ionization losses.
- * If more than 2 collections are given the additional Hit collections will
- * be ignored.
- */
-OpticalCalorimeterSD::OpticalCalorimeterSD(G4String sdName, const vector<G4String>& hcNames, Segmentation* sdSeg, HitComparator* compare) :
- CalorimeterSD(sdName, hcNames, sdSeg, compare)
-{
- CerenGenerator = 0;
-}
-
-OpticalCalorimeterSD::~OpticalCalorimeterSD()
-{
-}
-
-G4bool OpticalCalorimeterSD::ProcessHits(G4Step* aStep, G4TouchableHistory* tahis)
-{
- if (!CerenGenerator)
- CerenGenerator = new Cerenkov();
- G4int NCerenPhotons = 0;
- G4Track* theTrack = aStep->GetTrack();
- const G4double charge = theTrack->GetDefinition()->GetPDGCharge();
- G4StepPoint* pPreStepPoint = aStep->GetPreStepPoint();
- G4StepPoint* pPostStepPoint = aStep->GetPostStepPoint();
- G4double beta = 0.5 * (pPreStepPoint->GetBeta() + pPostStepPoint->GetBeta());
- const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
- G4String thematerial = touch->GetVolume()->GetLogicalVolume()->GetMaterial()->GetName();
- G4double MeanNumberOfPhotons = CerenGenerator->GetAverageNumberOfPhotons(charge, beta, thematerial);
- if (MeanNumberOfPhotons > 0.0) {
- G4double step_length = aStep->GetStepLength();
- MeanNumberOfPhotons = MeanNumberOfPhotons * step_length;
- NCerenPhotons = (G4int) G4Poisson(MeanNumberOfPhotons);
- } else {
- NCerenPhotons = 0;
- }
-
- if (NCerenPhotons <= 0) {
- return CalorimeterSD::ProcessHits(aStep, tahis);
- } else {
- SensitiveDetector::ProcessHits(aStep, 0);
- G4ThreeVector myPoint = aStep->GetPreStepPoint()->GetPosition();
- G4StepPoint* apreStepPoint = aStep->GetPreStepPoint();
- G4Navigator* theNavigator = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
- G4VPhysicalVolume* myVolume = theNavigator->LocateGlobalPointAndSetup(myPoint);
- if (getVerbose() > 2) {
- G4cout << "Physical volume = " << myVolume->GetName() << G4endl;
- G4cout << "Point of interaction = " << myPoint<< G4endl;
- G4cout << "sdname " << GetName() << " hcname " <<collectionName[0]<< G4endl;
- }
- // total photon energy
- // G4double theEdep = aTrack->GetTotalEnergy();
- G4double theEdep = double(NCerenPhotons);
- // get global cell pos from seg
- G4ThreeVector globalCellPos = getGlobalHitPosPreStep(apreStepPoint);
- // reset the seg bins
- _segmentation->resetBins();
- // set the seg bins
- _segmentation->setBins(aStep);
- // create id and pack into 64
- Id64bit id64 = makeId();
- // 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, eCerenkov))) {
- // add it to lkp map
- _hitsVector[eCerenkov].push_back(thisHit);
- // add to the HC
- _hitsCollections[eCerenkov]->insert(thisHit);
- } else {
- // found a hit
- // don't need to insert thisHit, so delete it
- delete thisHit;
- thisHit = 0;
- // incr total edep of the hit
- fndHit->addEnergyDeposition(theEdep);
- // for setting contrib
- thisHit = fndHit;
- }
- // add McpHitContrib to this hit, setting info from step info
- thisHit->addHitContribution(HitContribution(aStep));
- // aTrack->SetTrackStatus(fStopAndKill); // don't step photon any further
- return true;
- } // end Cerenkov photon treatment
-}
-
-G4ThreeVector OpticalCalorimeterSD::getGlobalHitPosPreStep(const G4StepPoint* aPreStepPoint)
-{
- G4ThreeVector globalStepPos = aPreStepPoint->GetPosition();
-
- // Figure out local step pos using touchable and global midpoint.
- G4ThreeVector localStepPos = ReadoutUtil::transformGlobalToLocal(aPreStepPoint, globalStepPos);
-
- // Compute local cell pos.
- G4ThreeVector localCellPos = this->getSegmentation()->getLocalHitPosition(localStepPos);
-
- // Compute global cell pos.
- G4ThreeVector globalCellPos = ReadoutUtil::transformLocalToGlobal(aPreStepPoint, localCellPos);
-
- return globalCellPos;
-}
-
lcdd/src/lcdd/detectors
diff -N ScorerSD.cc
--- ScorerSD.cc 10 Jul 2013 18:06:19 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,98 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/ScorerSD.cc,v 1.4 2013/07/10 18:06:19 jeremy Exp $
-
-// LCDD
-#include "lcdd/detectors/ScorerSD.hh"
-#include "lcdd/detectors/ReadoutUtil.hh"
-#include "lcdd/hits/TrackInformation.hh"
-
-ScorerSD::ScorerSD(G4String sdName, G4String hcName) :
- TrackerSD(sdName, hcName), _currentTrackID(-1)
-{
-}
-
-G4bool ScorerSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
-{
-#ifdef G4VERBOSE
- if ( _verbose > 1 ) {
- std::cout << "G4ScorerSD::ProcessHits() - " << this->GetName() << std::endl;
- }
-#endif
-
- SensitiveDetector::ProcessHits(aStep, 0);
-
- bool sameTrack = false;
-
-#ifdef G4VERBOSE
- if ( _verbose > 3 ) {
- std::cout << "current trackID <" << _currentTrackID << ">" << std::endl;
- }
-#endif
-
- if ((_currentTrackID == -1) || (_currentTrackID != trackID())) {
-
-#ifdef G4VERBOSE
- if ( _verbose > 2 ) {
- std::cout << "new track <" << trackID() << ">" << std::endl;
- }
-#endif
-
- _currentTrackID = trackID();
- } else {
-#ifdef G4VERBOSE
- if ( _verbose > 2 ) {
- std::cout << "old track <" << trackID() << ">" << std::endl;
- }
-#endif
-
- sameTrack = true;
- }
-
- if (!sameTrack) {
-
-#ifdef G4VERBOSE
- if ( _verbose > 2 ) {
- std::cout << "writing hit" << std::endl;
- }
-#endif
-
- // edep
- G4double e = edep();
-
- // get track information
- TrackInformation* trkInfo = trackInformation();
-
- // set hit flag in trk info
- trkInfo->setHasTrackerHit(true);
-
- // hit data
- G4int trkID = trackID();
- G4double tdep = globalTime();
- G4ThreeVector prepos = prePosition();
- G4ThreeVector meanmom = meanMomentum();
-
- // create hit
- TrackerHit* trkHit = new TrackerHit();
-
- // create id vector
- Id64bit id64 = makeId();
-
- // set track hit info
- trkHit->setTrackID(trkID);
- trkHit->setEdep(e);
- trkHit->setPos(prepos);
- trkHit->setMomentum(meanmom);
- trkHit->setTdep(tdep);
- trkHit->setId(id64.getId0());
- trkHit->setLength(ReadoutUtil::computeDistance(aStep));
-
- // add to HC
- _HC->insert(trkHit);
- } else {
-#ifdef G4VERBOSE
- if ( _verbose > 0 ) {
- std::cout << "Skipping hit from track <" << _currentTrackID << ">." << std::endl;
- }
-#endif
- }
- return true;
-}
lcdd/src/lcdd/detectors
diff -N TrackerCombineSD.cc
--- TrackerCombineSD.cc 11 Jul 2013 20:41:54 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,260 +0,0 @@
-// $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"
-#include "lcdd/detectors/ReadoutUtil.hh"
-#include "lcdd/hits/TrackInformation.hh"
-
-TrackerCombineSD::TrackerCombineSD(G4String sdName, G4String hcName) :
- TrackerSD(sdName, hcName), _combineHits(false), _currentTrackID(-1), _currentPV(0), _edepTotal(0), _minTime(0), _startedHit(false), _currentTrack(false)
-{
-}
-
-TrackerCombineSD::~TrackerCombineSD()
-{
-}
-
-void TrackerCombineSD::EndOfEvent(G4HCofThisEvent *hce)
-{
- TrackerSD::EndOfEvent(hce);
- clear();
-}
-
-G4bool TrackerCombineSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
-{
- // set cached step
- SensitiveDetector::ProcessHits(aStep, 0);
-
-#ifdef G4VERBOSE
- if (getVerbose() > 0) {
- G4cout << "G4TrackerCombineSD::ProcessHits - " << GetName() << G4endl;
- G4cout << "trackID - " << trackID() << G4endl;
- G4cout << "particle - " << track()->GetDefinition()->GetParticleName() << G4endl;
- G4cout << "edep - " << step()->GetTotalEnergyDeposit() << G4endl;
- G4cout << "pre-physvol=" << aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetName() << G4endl;
- G4cout << "post-physvol=" << aStep->GetPostStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetName() << G4endl;
- if ( prePV() != postPV() ) {
- G4cout << "post-pv != pre-pv" << G4endl;
- }
- }
-#endif
-
- // Return value indicating whether a hit was inserted.
- bool r = false;
-
- // Started a hit already?
- if (!_startedHit) {
-
- // If no hit, then start a new hit on the pre-step.
- startHit(pre());
- }
-
- // Check if the cached trackID is valid.
- if (_currentTrackID != -1) {
-
- // Is this step's trackID different from the cached trackID?
- if (trackID() != _currentTrackID) {
-
-#ifdef G4VERBOSE
- if ( getVerbose() > 0 ) {
- G4cout << "new track ID this step!" << G4endl;
- }
-#endif
-
- // Insert the hit on the old track.
- r = insertHit();
-
- // Start a new hit on the pre-step.
- startHit(pre());
- }
- }
-#ifdef G4DEBUG
- else {
- std::cout << GetName() << "::WARNING : current TrackID == -1" << std::endl;
- }
-#endif
-
- // Update the hit, checking if the call to this function is applicable.
- updateHit();
-
- // Entering a new PV on this step?
- if (prePV() != postPV()) {
-
-#ifdef G4VERBOSE
- if ( getVerbose() > 0 ) {
- G4cerr << "new physvol this step!" << G4endl;
- }
-#endif
-
- // Insert the current hit.
- r = insertHit();
-
- // Check if pre and post steps have the same detector.
- if (hasSameSD()) {
-
- // Start a new hit for the adjacent tracker layer.
- startHit(post());
- }
- }
- // Special case where the track status is StopAndKill.
- // If so, we won't see it again, so need to insert the hit.
- else if (_currentTrack->GetTrackStatus() == fStopAndKill) {
- r = insertHit();
- }
-
-#ifdef G4VERBOSE
- if ( getVerbose() > 0 ) {
- G4cerr << "----" << G4endl;
- }
-#endif
-
- return r;
-}
-
-void TrackerCombineSD::updateHit()
-{
-
-#ifdef G4VERBOSE
- if ( getVerbose() > 1 ) {
- G4cout << "updateHit" << G4endl;
- }
-#endif
-
- // can only update if started hit
- if (_startedHit) {
-
- // incr edep
- _edepTotal += edep();
-
- // first time only
- if (_minTime == 0) {
- _minTime = globalTime();
- }
-
- // exit point and momentum
- _exitPoint = postPosition();
- _exitMomentum = postMomentum();
- }
-}
-
-void TrackerCombineSD::clear()
-{
-#ifdef G4VERBOSE
- if ( getVerbose() > 1 ) {
- G4cout << "clear" << G4endl;
- }
-#endif
-
- _minTime = 0;
- _edepTotal = 0;
- _currentPV = 0;
- _currentTrackID = -1;
- _startedHit = false;
-}
-
-bool TrackerCombineSD::insertHit()
-{
-#ifdef G4VERBOSE
- if ( getVerbose() > 1 ) {
- G4cout << "insertHit" << G4endl;
- }
-#endif
-
- // never started another hit after clearing
- if (!_startedHit) {
- G4cerr << "never started hit!" << G4endl;
- return false;
- }
-
- // total energy below cut
- if ( _edepTotal <= getEnergyCut() && !isGeantino() ) {
-#ifdef G4VERBOSE
- if ( getVerbose() > 0 ) {
- std::cout << GetName() << " : cut this edep " << _edepTotal << std::endl;
- }
-
-#endif
- clear();
- return false;
- }
-
- // compute mid point
- G4ThreeVector midPoint =
- ReadoutUtil::computeThreeVectorMean(_entryPoint, _exitPoint);
-
- // compute mean momentum
- G4ThreeVector meanMom =
- ReadoutUtil::computeThreeVectorMean(_entryMomentum, _exitMomentum);
-
- // compute distance from start to entry
- G4double pathlength = ReadoutUtil::computeDistance(_entryPoint, _exitPoint);
-
- // hit data
- TrackerHit* trkhit = new TrackerHit();
- trkhit->setTdep(_minTime);
- trkhit->setEdep(_edepTotal);
- trkhit->setPos(midPoint);
- trkhit->setMomentum(meanMom);
- trkhit->setTrackID(_currentTrackID);
- trkhit->setLength(pathlength);
-
- // set id
- Id64bit id64 = makeId();
- trkhit->setId(id64.getId0());
-
-#ifdef G4VERBOSE
- if ( getVerbose() > 1 ) {
- std::cout << GetName() << " : inserting new tracker hit" << std::endl;
- std::cout << *trkhit << std::endl;
- std::cout << "entryPoint = " << _entryPoint << std::endl;
- std::cout << "entryPointR = " << _entryPoint.mag() << std::endl;
- std::cout << "midPoint = " << midPoint << std::endl;
- std::cout << "midPointR = " << midPoint.mag() << std::endl;
- std::cout << "exitPoint = " << _exitPoint << std::endl;
- std::cout << "exitPointR = " << _exitPoint.mag() << std::endl;
- std::cout << "(exitPointR - entryPointR) / 2 = " << (_exitPoint.mag() - _entryPoint.mag()) / 2 << std::endl;
- std::cout << std::endl;
- }
-#endif
-
- _HC->insert(trkhit);
-
- TrackInformation::getTrackInformation( _currentTrack )->setHasTrackerHit( true );
-
- // clear cached data
- clear();
-
-#ifdef G4VERBOSE
- if ( getVerbose() > 0 ) {
- G4cout << G4endl;
- }
-#endif
-
- return true;
- }
-
-void TrackerCombineSD::startHit(G4StepPoint* aStepPoint)
-{
-#ifdef G4VERBOSE
- if ( getVerbose() > 0 ) {
- G4cout << "startHit" << G4endl;
- }
-#endif
-
- _currentTrack = step()->GetTrack();
- _currentPV = aStepPoint->GetPhysicalVolume();
- _entryPoint = _exitPoint = aStepPoint->GetPosition();
- _entryMomentum = _exitMomentum = aStepPoint->GetMomentum();
- _currentTrackID = trackID();
- _startedHit = true;
-
-#ifdef G4VERBOSE
- if ( getVerbose() > 2 ) {
- std::cout << GetName() << " : starting new hit" << std::endl;
- std::cout << "volume = " << _currentPV->GetName() << std::endl;
- std::cout << "trackID = " << _currentTrackID << std::endl;
- std::cout << "entry point = " << _entryPoint << std::endl;
- }
-#endif
-}
-
lcdd/src/lcdd/detectors
diff -N UnsegmentedCalorimeterSD.cc
--- UnsegmentedCalorimeterSD.cc 11 Jul 2013 20:41:54 -0000 1.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,74 +0,0 @@
-// $Id: UnsegmentedCalorimeterSD.cc,v 1.5 2013/07/11 20:41:54 jeremy Exp $
-
-// LCDD
-#include "lcdd/detectors/UnsegmentedCalorimeterSD.hh"
-
-UnsegmentedCalorimeterSD::UnsegmentedCalorimeterSD(G4String sdName, G4String hcName, Segmentation* seg) :
- CalorimeterSD(sdName, hcName, seg)
-{
-}
-
-UnsegmentedCalorimeterSD::~UnsegmentedCalorimeterSD()
-{
-}
-
-G4bool UnsegmentedCalorimeterSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
-{
-#ifdef G4VERBOSE
- if ( getVerbose() > 0 )
- {
- std::cout << "G4UnsegmentedCalorimeterSD::ProcessHits - " << this->GetName() << std::endl;
- }
-#endif
-
- /* Cache the step information. */
- SensitiveDetector::ProcessHits(aStep, 0);
-
- /* Get the energy deposition. */
- G4double theEdep = edep();
-
- /*
- * This needs to be a <= comparison for cutting on 0,
- * but it allows geantinos, which always have 0 edep.
- */
- if (theEdep <= getEnergyCut() && !isGeantino()) {
-#ifdef G4VERBOSE
- if ( getVerbose() > 2 )
- {
- std::cout << "G4UnsegmentedCalorimeterSD::ProcessHits - cut on edep " << theEdep << std::endl;
- }
-#endif
- return false;
- }
-
- /* Get the step mid position. */
- G4ThreeVector hitPos = midPosition();
-
- //std::cout << "hit at " << hitPos << std::endl;
-
- /* Reset the segmentation bins. */
- //m_segmentation->resetBins();
- /* Set the segmentation bins. */
- //m_segmentation->setBins( aStep );
- /* Create a 64-bit ID. */
- Id64bit id64 = makeId();
-
- /* Create a new hit. */
- CalorimeterHit* thisHit = new CalorimeterHit(theEdep, hitPos);
-
- /* Set the 64-bit ID. */
- thisHit->setId64bit(id64.getId0(), id64.getId1());
-
- /* Add hit to lookup map. */
- _hitsVector[0].push_back(thisHit);
-
- /* Add hit to the HC. */
- _hitsCollections[0]->insert(thisHit);
-
- /* Add an MCParticle contribution for this hit. */
- thisHit->addHitContribution(HitContribution(aStep));
-
- /* Success. */
- return true;
-}
-
lcdd/src/lcdd/hits
diff -u -r1.5 -r1.5.2.1
--- CalorimeterHit.cc 11 Jul 2013 20:41:54 -0000 1.5
+++ CalorimeterHit.cc 14 Aug 2013 00:23:23 -0000 1.5.2.1
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/hits/CalorimeterHit.cc,v 1.5 2013/07/11 20:41:54 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/hits/CalorimeterHit.cc,v 1.5.2.1 2013/08/14 00:23:23 jeremy Exp $
// LCDD
#include "lcdd/hits/CalorimeterHit.hh"
@@ -12,7 +12,7 @@
#include "G4Transform3D.hh"
#endif
-G4Allocator<CalorimeterHit> G4CalorimeterHitAllocator;
+G4Allocator<CalorimeterHit> CalorimeterHitAllocator;
CalorimeterHit::CalorimeterHit() :
G4VHit(), _edep(0)
lcdd/src/lcdd/processes
diff -N hit_processorProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ hit_processorProcess.cc 14 Aug 2013 00:23:23 -0000 1.1.2.1
@@ -0,0 +1,58 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/processes/Attic/hit_processorProcess.cc,v 1.1.2.1 2013/08/14 00:23:23 jeremy Exp $
+
+// LCDD
+#include "lcdd/processes/hit_processorProcess.hh"
+#include "lcdd/schema/hit_processor.hh"
+
+// GDML
+#include "Saxana/ProcessingContext.h"
+#include "Saxana/SAXComponentFactory.h"
+
+hit_processorProcess::hit_processorProcess()
+ : SAXStateProcess(0), _obj(0)
+{}
+
+hit_processorProcess::hit_processorProcess(ProcessingContext* context)
+ : SAXStateProcess(context), _obj(0)
+{
+
+}
+
+hit_processorProcess::~hit_processorProcess()
+{
+
+}
+
+void hit_processorProcess::StartElement(const std::string& name, const ASCIIAttributeList& attrs)
+{
+ SAXObject** obj = Context()->GetTopObject();
+ hit_processor* hitProcessor = new hit_processor;
+
+ hitProcessor->set_type(attrs.getValue("type"));
+
+ _obj = hitProcessor;
+ *obj = hitProcessor;
+}
+
+void hit_processorProcess::EndElement(const std::string&)
+{}
+
+void hit_processorProcess::Characters(const std::string&)
+{}
+
+void hit_processorProcess::StackPopNotify(const std::string& name)
+{
+ SAXObject** so = Context()->GetTopObject();
+ HitProcessorType* hitProcessorType = dynamic_cast<HitProcessorType*>(_obj);
+
+ // Push child elements into type object.
+ hitProcessorType->add_content(name, *so);
+}
+
+const std::string& hit_processorProcess::State() const
+{
+ static std::string tag = "hit_processor";
+ return tag;
+}
+
+DECLARE_PROCESS_FACTORY(hit_processorProcess)
lcdd/src/lcdd/processes
diff -N hits_collectionProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ hits_collectionProcess.cc 14 Aug 2013 00:23:23 -0000 1.1.2.1
@@ -0,0 +1,54 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/processes/Attic/hits_collectionProcess.cc,v 1.1.2.1 2013/08/14 00:23:23 jeremy Exp $
+
+// LCDD
+#include "lcdd/processes/hits_collectionProcess.hh"
+#include "lcdd/schema/hits_collection.hh"
+
+// GDML
+#include "Saxana/ProcessingContext.h"
+#include "Saxana/SAXComponentFactory.h"
+
+hits_collectionProcess::hits_collectionProcess()
+ : SAXStateProcess(0), _obj(0)
+{
+}
+
+hits_collectionProcess::hits_collectionProcess(ProcessingContext* context)
+ : SAXStateProcess(context), _obj(0)
+{
+}
+
+hits_collectionProcess::~hits_collectionProcess()
+{
+}
+
+void hits_collectionProcess::StartElement(const std::string& name, const ASCIIAttributeList& attrs)
+{
+ SAXObject** obj = Context()->GetTopObject();
+ hits_collection* hitsCollection = new hits_collection;
+
+ std::cout << "setting hits_collection name: " << attrs.getValue("name") << std::endl;
+
+ hitsCollection->set_name(attrs.getValue("name"));
+
+ _obj = hitsCollection;
+ *obj = hitsCollection;
+}
+
+void hits_collectionProcess::EndElement(const std::string&)
+{}
+
+void hits_collectionProcess::Characters(const std::string&)
+{}
+
+void hits_collectionProcess::StackPopNotify(const std::string& name)
+{
+}
+
+const std::string& hits_collectionProcess::State() const
+{
+ static std::string tag = "hits_collection";
+ return tag;
+}
+
+DECLARE_PROCESS_FACTORY(hits_collectionProcess)
lcdd/src/lcdd/processes
diff -N optical_calorimeterProcess.cc
--- optical_calorimeterProcess.cc 27 Jun 2013 00:05:58 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,43 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/processes/optical_calorimeterProcess.cc,v 1.1 2013/06/27 00:05:58 jeremy Exp $
-
-// GDML
-#include "Saxana/ProcessingConfigurator.h"
-#include "Saxana/ProcessingContext.h"
-#include "Saxana/SAXProcessor.h"
-#include "Saxana/StateStack.h"
-#include "Saxana/SAXProcessingState.h"
-#include "Saxana/SAXStateProcess.h"
-#include "Saxana/SAXComponentFactory.h"
-
-// LCDD
-#include "lcdd/schema/optical_calorimeter.hh"
-#include "lcdd/processes/calorimeterProcess.hh"
-
-// STL
-#include <iostream>
-
-/**
- @class optical_calorimeterProcess
- @brief SAX process for optical_calorimeter element.
- @note Calls SAX processor for SensitiveDetectorTypeProcess parent class.
- */
-class optical_calorimeterProcess: public calorimeterProcess
-{
-public:
- optical_calorimeterProcess(const ProcessingContext* context = 0) :
- calorimeterProcess(context)
- {
- }
-
- virtual ~optical_calorimeterProcess()
- {
- }
-
- virtual const std::string& State() const
- {
- static std::string tag = "optical_calorimeter";
- return tag;
- }
-};
-
-DECLARE_PROCESS_FACTORY(optical_calorimeterProcess)
lcdd/src/lcdd/processes
diff -N scorerProcess.cc
--- scorerProcess.cc 3 Jul 2013 23:33:51 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,71 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/processes/scorerProcess.cc,v 1.2 2013/07/03 23:33:51 jeremy Exp $
-
-// GDML
-#include "Saxana/ProcessingConfigurator.h"
-#include "Saxana/ProcessingContext.h"
-#include "Saxana/SAXProcessor.h"
-#include "Saxana/StateStack.h"
-#include "Saxana/SAXProcessingState.h"
-#include "Saxana/SAXStateProcess.h"
-#include "Saxana/SAXComponentFactory.h"
-
-// LCDD
-#include "lcdd/schema/scorer.hh"
-#include "lcdd/processes/SensitiveDetectorTypeProcess.hh"
-
-// STL
-#include <iostream>
-
-/**
- * @brief SAX process for scorer element.
- */
-class scorerProcess: public SensitiveDetectorTypeProcess
-{
-
-public:
- scorerProcess(const ProcessingContext* context = 0) :
- SensitiveDetectorTypeProcess(context)
- {
- }
-
- virtual ~scorerProcess()
- {
- }
-
- virtual void StartElement(const std::string& name, const ASCIIAttributeList& attrs)
- {
- //std::cout << "PROCESS::START OF TAG : " << name << std::endl;
-
- SAXObject** obj = Context()->GetTopObject();
-
- scorer* scr = new scorer;
- /*
- scr->set_kill_tracks(attrs.getValue("kill_tracks") );
- */
-
- _obj = scr;
- *obj = scr;
-
- SensitiveDetectorTypeProcess::StartElement(name, attrs);
- }
-
- virtual void EndElement(const std::string&)
- {
- //std::cout << "PROCESS::END OF TAG : " << name << " " << std::endl;
-
- //SensitiveDetectorTypeProcess::EndElement( name );
- }
-
- virtual void StackPopNotify(const std::string& name)
- {
- SensitiveDetectorTypeProcess::StackPopNotify(name);
- }
-
- virtual const std::string& State() const
- {
- static std::string tag = "scorer";
- return tag;
- }
-};
-
-DECLARE_PROCESS_FACTORY(scorerProcess)
lcdd/src/lcdd/processes
diff -N unsegmented_calorimeterProcess.cc
--- unsegmented_calorimeterProcess.cc 27 Jun 2013 00:05:58 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,35 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/processes/unsegmented_calorimeterProcess.cc,v 1.1 2013/06/27 00:05:58 jeremy Exp $
-
-// LCDD
-#include "lcdd/processes/calorimeterProcess.hh"
-#include "lcdd/schema/unsegmented_calorimeter.hh"
-
-// GDML
-#include "Saxana/ProcessingContext.h"
-#include "Saxana/SAXComponentFactory.h"
-
-#include <iostream>
-
-/**
- * @brief SAX process for unsegmented_calorimeter element.@note Calls SAX processor for SensitiveDetectorTypeProcess parent class.
- */
-class unsegmented_calorimeterProcess: public calorimeterProcess
-{
-public:
- unsegmented_calorimeterProcess(const ProcessingContext* context = 0) :
- calorimeterProcess(context)
- {
- }
-
- virtual ~unsegmented_calorimeterProcess()
- {
- }
-
- virtual const std::string& State() const
- {
- static std::string tag = "unsegmented_calorimeter";
- return tag;
- }
-};
-
-DECLARE_PROCESS_FACTORY(unsegmented_calorimeterProcess)
lcdd/src/lcdd/schema
diff -N HitProcessorType.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ HitProcessorType.cc 14 Aug 2013 00:23:23 -0000 1.1.2.1
@@ -0,0 +1,27 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/Attic/HitProcessorType.cc,v 1.1.2.1 2013/08/14 00:23:23 jeremy Exp $
+
+#include "lcdd/schema/HitProcessorType.hh"
+
+HitProcessorType::HitProcessorType()
+{
+}
+
+HitProcessorType::~HitProcessorType()
+{
+}
+
+void HitProcessorType::set_type(const std::string& s)
+{
+ _type = s;
+}
+
+const std::string& HitProcessorType::get_type() const
+{
+ return _type;
+}
+
+void HitProcessorType::add_content(const std::string& tag, SAXObject* saxObject)
+{
+ ContentGroup::ContentItem contentItem = { tag, saxObject };
+ _sequence.add_content(contentItem);
+}
lcdd/src/lcdd/schema
diff -N HitsCollectionType.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ HitsCollectionType.cc 14 Aug 2013 00:23:23 -0000 1.1.2.1
@@ -0,0 +1,20 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/Attic/HitsCollectionType.cc,v 1.1.2.1 2013/08/14 00:23:23 jeremy Exp $
+
+// LCDD
+#include "lcdd/schema/HitsCollectionType.hh"
+
+HitsCollectionType::HitsCollectionType()
+{}
+
+HitsCollectionType::~HitsCollectionType()
+{}
+
+void HitsCollectionType::set_name(const std::string& s)
+{
+ _name = s;
+}
+
+const std::string& HitsCollectionType::get_name() const
+{
+ return _name;
+}
lcdd/src/lcdd/schema
diff -N hit_processor.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ hit_processor.cc 14 Aug 2013 00:23:23 -0000 1.1.2.1
@@ -0,0 +1,18 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/Attic/hit_processor.cc,v 1.1.2.1 2013/08/14 00:23:23 jeremy Exp $
+
+// LCDD
+#include "lcdd/schema/hit_processor.hh"
+
+hit_processor::hit_processor()
+{
+}
+
+hit_processor::~hit_processor()
+{
+}
+
+SAXObject::Type hit_processor::type()
+{
+ return SAXObject::element;
+}
+
lcdd/src/lcdd/schema
diff -N hits_collection.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ hits_collection.cc 14 Aug 2013 00:23:23 -0000 1.1.2.1
@@ -0,0 +1,17 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/Attic/hits_collection.cc,v 1.1.2.1 2013/08/14 00:23:23 jeremy Exp $
+
+#include "lcdd/schema/hits_collection.hh"
+
+hits_collection::hits_collection()
+{
+}
+
+hits_collection::~hits_collection()
+{
+}
+
+SAXObject::Type hits_collection::type()
+{
+ return SAXObject::element;
+}
+
lcdd/src/lcdd/subscribers
diff -N optical_calorimeterSubscriber.cc
--- optical_calorimeterSubscriber.cc 10 Jul 2013 18:06:20 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,49 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/subscribers/optical_calorimeterSubscriber.cc,v 1.3 2013/07/10 18:06:20 jeremy Exp $
-
-// GDML
-#include "Saxana/SAXSubscriber.h"
-#include "Saxana/SAXComponentFactory.h"
-#include "G4Processor/GDMLProcessor.h"
-
-// LCDD
-#include "lcdd/schema/calorimeter.hh"
-#include "lcdd/core/LCDDProcessor.hh"
-#include "lcdd/detectors/CalorimeterSD.hh"
-#include "lcdd/detectors/SegmentationFactory.hh"
-#include "lcdd/detectors/SensitiveDetectorFactory.hh"
-#include "lcdd/id/IdManager.hh"
-#include "lcdd/id/IdSpec.hh"
-
-// STL
-#include <iostream>
-#include <sstream>
-
-/**
- * @brief Creates OpticalCalorimeterSD objects from optical_calorimeter elements.
- * @note Delegates to SensitiveDetectorFactory.
- */
-class optical_calorimeterSubscriber: virtual public SAXSubscriber
-{
-public:
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
-public:
- optical_calorimeterSubscriber()
- {
- Subscribe("optical_calorimeter");
- }
-
- virtual ~optical_calorimeterSubscriber()
- {
- }
-
- virtual void Activate(const SAXObject* object)
- {
- SensitiveDetectorFactory::createSensitiveDetector(object);
- }
-};
-
-DECLARE_SUBSCRIBER_FACTORY(optical_calorimeterSubscriber)
lcdd/src/lcdd/subscribers
diff -N scorerSubscriber.cc
--- scorerSubscriber.cc 10 Jul 2013 18:06:20 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,48 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/subscribers/scorerSubscriber.cc,v 1.3 2013/07/10 18:06:20 jeremy Exp $
-
-// GDML
-#include "Saxana/SAXSubscriber.h"
-#include "Saxana/SAXComponentFactory.h"
-
-// LCDD
-#include "lcdd/core/LCDDProcessor.hh"
-#include "lcdd/schema/scorer.hh"
-#include "lcdd/detectors/SensitiveDetector.hh"
-#include "lcdd/detectors/ScorerSD.hh"
-#include "lcdd/detectors/SensitiveDetectorFactory.hh"
-
-// STL
-#include <iostream>
-
-/**
- * @brief Creates ScorerSD objects from scorer elements.
- * @note Delegates to SensitiveDetectorFactory.
- */
-class scorerSubscriber: virtual public SAXSubscriber
-{
-
-public:
-
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
-public:
-
- scorerSubscriber()
- {
- Subscribe("scorer");
- }
-
- virtual ~scorerSubscriber()
- {
- }
-
- virtual void Activate(const SAXObject* object)
- {
- SensitiveDetectorFactory::createSensitiveDetector(object);
- }
-};
-
-DECLARE_SUBSCRIBER_FACTORY(scorerSubscriber)
lcdd/src/lcdd/subscribers
diff -N unsegmented_calorimeterSubscriber.cc
--- unsegmented_calorimeterSubscriber.cc 10 Jul 2013 18:06:20 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,40 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/subscribers/unsegmented_calorimeterSubscriber.cc,v 1.2 2013/07/10 18:06:20 jeremy Exp $
-
-// GDML
-#include "Saxana/SAXSubscriber.h"
-#include "Saxana/SAXComponentFactory.h"
-
-// LCDD
-#include "lcdd/detectors/SensitiveDetectorFactory.hh"
-
-/**
- * @brief Creates UnsegmentedCalorimeter objects from unsegmented_calorimeter elements.
- * @note Delegates to SensitiveDetectorFactory.
- */
-class unsegmented_calorimeterSubscriber: virtual public SAXSubscriber
-{
-public:
-
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
-public:
-
- unsegmented_calorimeterSubscriber()
- {
- Subscribe("unsegmented_calorimeter");
- }
-
- virtual ~unsegmented_calorimeterSubscriber()
- {
- }
-
- virtual void Activate(const SAXObject* object)
- {
- SensitiveDetectorFactory::createSensitiveDetector(object);
- }
-};
-
-DECLARE_SUBSCRIBER_FACTORY(unsegmented_calorimeterSubscriber)
CVSspam 0.2.12