Author: [log in to unmask]
Date: Mon Jan 12 16:20:09 2015
New Revision: 3489
Log:
Merge v05-00-00-dev branch into trunk.
Added:
projects/lcdd/trunk/examples/segmentation/CartesianGridXY.lcdd
- copied unchanged from r3487, projects/lcdd/branches/v05-00-00-dev/examples/segmentation/CartesianGridXY.lcdd
projects/lcdd/trunk/examples/segmentation/CartesianGridXYZ.lcdd
- copied unchanged from r3487, projects/lcdd/branches/v05-00-00-dev/examples/segmentation/CartesianGridXYZ.lcdd
projects/lcdd/trunk/examples/segmentation/CartesianGridXZ.lcdd
- copied unchanged from r3487, projects/lcdd/branches/v05-00-00-dev/examples/segmentation/CartesianGridXZ.lcdd
projects/lcdd/trunk/examples/segmentation/ProjectiveCylinder.lcdd
- copied unchanged from r3487, projects/lcdd/branches/v05-00-00-dev/examples/segmentation/ProjectiveCylinder.lcdd
projects/lcdd/trunk/include/lcdd/detectors/DDSegmentationCalorimeterHitProcessor.hh
- copied unchanged from r3487, projects/lcdd/branches/v05-00-00-dev/include/lcdd/detectors/DDSegmentationCalorimeterHitProcessor.hh
projects/lcdd/trunk/include/lcdd/schema/CartesianGridXYType.hh
- copied unchanged from r3487, projects/lcdd/branches/v05-00-00-dev/include/lcdd/schema/CartesianGridXYType.hh
projects/lcdd/trunk/include/lcdd/schema/CartesianGridXYZType.hh
- copied unchanged from r3487, projects/lcdd/branches/v05-00-00-dev/include/lcdd/schema/CartesianGridXYZType.hh
projects/lcdd/trunk/include/lcdd/schema/CartesianGridXZType.hh
- copied unchanged from r3487, projects/lcdd/branches/v05-00-00-dev/include/lcdd/schema/CartesianGridXZType.hh
projects/lcdd/trunk/include/lcdd/schema/ProjectiveCylinderType.hh
- copied unchanged from r3487, projects/lcdd/branches/v05-00-00-dev/include/lcdd/schema/ProjectiveCylinderType.hh
projects/lcdd/trunk/include/lcdd/schema/cartesian_grid_xy.hh
- copied unchanged from r3487, projects/lcdd/branches/v05-00-00-dev/include/lcdd/schema/cartesian_grid_xy.hh
projects/lcdd/trunk/include/lcdd/schema/cartesian_grid_xyz.hh
- copied unchanged from r3487, projects/lcdd/branches/v05-00-00-dev/include/lcdd/schema/cartesian_grid_xyz.hh
projects/lcdd/trunk/include/lcdd/schema/cartesian_grid_xz.hh
- copied unchanged from r3487, projects/lcdd/branches/v05-00-00-dev/include/lcdd/schema/cartesian_grid_xz.hh
projects/lcdd/trunk/include/lcdd/schema/projective_cylinder.hh
- copied unchanged from r3487, projects/lcdd/branches/v05-00-00-dev/include/lcdd/schema/projective_cylinder.hh
projects/lcdd/trunk/include/lcdd/schema/projective_cylinder_old.hh
- copied unchanged from r3487, projects/lcdd/branches/v05-00-00-dev/include/lcdd/schema/projective_cylinder_old.hh
projects/lcdd/trunk/schemas/lcdd/2.0/
- copied from r3487, projects/lcdd/branches/v05-00-00-dev/schemas/lcdd/2.0/
projects/lcdd/trunk/src/lcdd/detectors/DDSegmentationCalorimeterHitProcessor.cc
- copied unchanged from r3487, projects/lcdd/branches/v05-00-00-dev/src/lcdd/detectors/DDSegmentationCalorimeterHitProcessor.cc
projects/lcdd/trunk/src/lcdd/processes/cartesian_grid_xyProcess.cc
- copied unchanged from r3487, projects/lcdd/branches/v05-00-00-dev/src/lcdd/processes/cartesian_grid_xyProcess.cc
projects/lcdd/trunk/src/lcdd/processes/cartesian_grid_xyzProcess.cc
- copied unchanged from r3487, projects/lcdd/branches/v05-00-00-dev/src/lcdd/processes/cartesian_grid_xyzProcess.cc
projects/lcdd/trunk/src/lcdd/processes/cartesian_grid_xzProcess.cc
- copied unchanged from r3487, projects/lcdd/branches/v05-00-00-dev/src/lcdd/processes/cartesian_grid_xzProcess.cc
projects/lcdd/trunk/src/lcdd/processes/projective_cylinderProcess.cc
- copied unchanged from r3487, projects/lcdd/branches/v05-00-00-dev/src/lcdd/processes/projective_cylinderProcess.cc
projects/lcdd/trunk/src/lcdd/processes/projective_cylinder_oldProcess.cc
- copied unchanged from r3487, projects/lcdd/branches/v05-00-00-dev/src/lcdd/processes/projective_cylinder_oldProcess.cc
Modified:
projects/lcdd/trunk/ (props changed)
projects/lcdd/trunk/CMakeLists.txt
projects/lcdd/trunk/include/lcdd/detectors/CalorimeterSD.hh
projects/lcdd/trunk/include/lcdd/detectors/CurrentTrackState.hh
projects/lcdd/trunk/include/lcdd/detectors/SensitiveDetectorFactory.hh
projects/lcdd/trunk/include/lcdd/hits/CalorimeterHit.hh
projects/lcdd/trunk/include/lcdd/hits/CalorimeterHitMap.hh
projects/lcdd/trunk/include/lcdd/id/IdFactory.hh
projects/lcdd/trunk/include/lcdd/util/TimerUtil.hh
projects/lcdd/trunk/src/lcdd/core/LCDDLibLoad.cc
projects/lcdd/trunk/src/lcdd/detectors/BasicTrackerHitProcessor.cc
projects/lcdd/trunk/src/lcdd/detectors/CalorimeterSD.cc
projects/lcdd/trunk/src/lcdd/detectors/CurrentTrackState.cc
projects/lcdd/trunk/src/lcdd/detectors/HitProcessorManager.cc
projects/lcdd/trunk/src/lcdd/detectors/ScoringTrackerHitProcessor.cc
projects/lcdd/trunk/src/lcdd/detectors/SensitiveDetectorFactory.cc
projects/lcdd/trunk/src/lcdd/hits/CalorimeterHit.cc
projects/lcdd/trunk/src/lcdd/hits/CalorimeterHitMap.cc
projects/lcdd/trunk/src/lcdd/id/IdFactory.cc
projects/lcdd/trunk/src/lcdd/segmentation/SegmentationFactory.cc
Modified: projects/lcdd/trunk/CMakeLists.txt
=============================================================================
--- projects/lcdd/trunk/CMakeLists.txt (original)
+++ projects/lcdd/trunk/CMakeLists.txt Mon Jan 12 16:20:09 2015
@@ -50,6 +50,14 @@
MESSAGE( STATUS "Found GDML: ${GDML_DIR}" )
ENDIF()
+# find DDSegmentation
+FIND_PACKAGE(DDSegmentation REQUIRED)
+if ( NOT DDSegmentation_FOUND )
+ MESSAGE( FATAL_ERROR "DDSegmentation was not found! Define DDSegmentation_DIR when calling cmake." )
+ELSE()
+ MESSAGE( STATUS "Found DDSegmentation: ${DDSegmentation_DIR}" )
+ENDIF()
+
# local includes
SET( LCDD_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include )
INCLUDE_DIRECTORIES( ${LCDD_INCLUDE_DIR} )
@@ -65,13 +73,13 @@
ADD_DEFINITIONS( ${Geant4_DEFINITIONS} )
# include directories
-INCLUDE_DIRECTORIES( ${XERCES_INCLUDE_DIR} ${Geant4_INCLUDE_DIRS} ${GDML_INCLUDE_DIRS} )
+INCLUDE_DIRECTORIES( ${XERCES_INCLUDE_DIR} ${Geant4_INCLUDE_DIRS} ${GDML_INCLUDE_DIRS} ${DDSegmentation_INCLUDE_DIRS} )
# add GDML link directory
-LINK_DIRECTORIES( ${GDML_LIBRARY_DIR} )
+LINK_DIRECTORIES( ${GDML_LIBRARY_DIR} ${DDSegmentation_LIBRARY_DIR} )
# libraries
-LINK_LIBRARIES( ${XERCES_LIBRARY} ${Geant4_LIBRARIES} ${GDML_LIBRARY} )
+LINK_LIBRARIES( ${XERCES_LIBRARY} ${Geant4_LIBRARIES} ${GDML_LIBRARY} ${DDSegmentation_LIBRARIES} )
# output shared library
ADD_LIBRARY( lcdd SHARED ${library_sources} )
Modified: projects/lcdd/trunk/include/lcdd/detectors/CalorimeterSD.hh
=============================================================================
--- projects/lcdd/trunk/include/lcdd/detectors/CalorimeterSD.hh (original)
+++ projects/lcdd/trunk/include/lcdd/detectors/CalorimeterSD.hh Mon Jan 12 16:20:09 2015
@@ -7,6 +7,11 @@
#include "lcdd/hits/CalorimeterHit.hh"
#include "lcdd/hits/CalorimeterHitMap.hh"
#include "lcdd/segmentation/Segmentation.hh"
+
+// DD4HEP
+#include "DDSegmentation/Segmentation.h"
+
+#include <vector>
/**
* @brief The implementation of a calorimeter that accumulates energy depositions by event.
@@ -29,7 +34,7 @@
* @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, G4String hcName, Segmentation* sdSeg);
+ CalorimeterSD(G4String sensitiveDetectorName, G4String hitsCollectionName, Segmentation* segmentation);
/**
* Class constructor.
@@ -38,7 +43,7 @@
* @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, const std::vector<G4String>& hcNames, Segmentation* sdSeg);
+ CalorimeterSD(G4String sensitiveDetectorName, const std::vector<G4String>& hitsCollectionName, Segmentation* segmentation);
/**
* Class destructor.
@@ -70,11 +75,16 @@
Segmentation* getSegmentation() const;
/**
- * Print out the hit data to an output stream.
- * @param[in] os The output stream.
- * @return The same output stream.
+ * Set the DD4hep Segmentation of this Calorimeter.
+ * @param[in] segmentation The Segmentation object.
*/
- //std::ostream& printHits(std::ostream& os);
+ void setDDSegmentation(DD4hep::DDSegmentation::Segmentation* segmentation);
+
+ /**
+ * Get the DD4HEP Segmentation of this CalorimeterSD.
+ * @return The DD4HEP Segmentation or NULL if not set.
+ */
+ DD4hep::DDSegmentation::Segmentation* getDDSegmentation() const;
/**
* Print the calorimeter's basic information.
@@ -99,6 +109,12 @@
*/
CalorimeterHit* findHit(const Id64bit& id, int collectionIndex = 0);
+ /**
+ * Get a CalorimeterHitMap by collection index.
+ * @return The CalorimeterHitMap by collection index.
+ */
+ CalorimeterHitMap* getCalorimeterHitMap(int index);
+
protected:
/**
@@ -113,6 +129,8 @@
// The calorimeter's virtual segmentation.
Segmentation* _segmentation;
+ DD4hep::DDSegmentation::Segmentation* _ddsegmentation;
+
// Pointers to current hits collections.
std::vector<CalorimeterHitsCollection*> _hitsCollections;
Modified: projects/lcdd/trunk/include/lcdd/detectors/CurrentTrackState.hh
=============================================================================
--- projects/lcdd/trunk/include/lcdd/detectors/CurrentTrackState.hh (original)
+++ projects/lcdd/trunk/include/lcdd/detectors/CurrentTrackState.hh Mon Jan 12 16:20:09 2015
@@ -21,22 +21,22 @@
_currentTrackID = trackID;
}
- static void setCurrentPrimaryID(G4int trackID) {
- _currentPrimaryID = trackID;
- }
+ //static void setCurrentPrimaryID(G4int trackID) {
+ // _currentPrimaryID = trackID;
+ //}
static G4int getCurrentTrackID() {
return _currentTrackID;
}
- static G4int getCurrentPrimaryID() {
- return _currentPrimaryID;
- }
+ //static G4int getCurrentPrimaryID() {
+ // return _currentPrimaryID;
+ //}
public:
static G4int _currentTrackID;
- static G4int _currentPrimaryID;
+ //static G4int _currentPrimaryID;
};
#endif
Modified: projects/lcdd/trunk/include/lcdd/detectors/SensitiveDetectorFactory.hh
=============================================================================
--- projects/lcdd/trunk/include/lcdd/detectors/SensitiveDetectorFactory.hh (original)
+++ projects/lcdd/trunk/include/lcdd/detectors/SensitiveDetectorFactory.hh Mon Jan 12 16:20:09 2015
@@ -85,6 +85,14 @@
* @return True if segmentation tag is valid; false if not.
*/
static bool isSegmentationTag(const std::string& s);
+
+ /**
+ * Create a DDSegmentation Segmentation object, if found in the XML content,
+ * and register it with the CalorimeterSD.
+ * @param[in] calorimeter The CalorimeterSD which will use the Segmentation.
+ * @param[in] seq The XML content of the calorimeter element.
+ */
+ static void createDDSegmentation(CalorimeterSD* calorimeter, ContentSequence* seq);
};
#endif
Modified: projects/lcdd/trunk/include/lcdd/hits/CalorimeterHit.hh
=============================================================================
--- projects/lcdd/trunk/include/lcdd/hits/CalorimeterHit.hh (original)
+++ projects/lcdd/trunk/include/lcdd/hits/CalorimeterHit.hh Mon Jan 12 16:20:09 2015
@@ -142,18 +142,6 @@
*/
const Id64bit& getId64bit() const;
- /**
- * Set the endcap flag.
- * @param[in] ec The endcap flag.
- */
- void setEndcapFlag(bool ec = true);
-
- /**
- * Get the endcap flag.
- * @return The endcap flag.
- */
- bool getEndcapFlag();
-
private:
// 64-bit id.
@@ -164,9 +152,6 @@
// Position.
G4ThreeVector _pos;
-
- // Endcap flag.
- bool _endcap;
// List of contributions by MCParticle.
HitContributionList _particleList;
Modified: projects/lcdd/trunk/include/lcdd/hits/CalorimeterHitMap.hh
=============================================================================
--- projects/lcdd/trunk/include/lcdd/hits/CalorimeterHitMap.hh (original)
+++ projects/lcdd/trunk/include/lcdd/hits/CalorimeterHitMap.hh Mon Jan 12 16:20:09 2015
@@ -47,6 +47,8 @@
*/
CalorimeterHit* get(const Id64bit& id);
+ CalorimeterHit* get(Id64bit::ValueType);
+
/**
* Get the size of the map.
* @return The size of the map.
Modified: projects/lcdd/trunk/include/lcdd/id/IdFactory.hh
=============================================================================
--- projects/lcdd/trunk/include/lcdd/id/IdFactory.hh (original)
+++ projects/lcdd/trunk/include/lcdd/id/IdFactory.hh Mon Jan 12 16:20:09 2015
@@ -8,6 +8,9 @@
// STL
#include <iostream>
#include <vector>
+
+// DD4HEP
+#include "DDSegmentation/Segmentation.h"
// LCDD
class Segmentation;
@@ -61,6 +64,8 @@
*/
static IdVec createOrderedIdVec(G4Step* aStep, const SensitiveDetector* sd);
+ static DD4hep::DDSegmentation::VolumeID createVolumeId(G4Step*, IdSpec*);
+
private:
/*
Modified: projects/lcdd/trunk/include/lcdd/util/TimerUtil.hh
=============================================================================
--- projects/lcdd/trunk/include/lcdd/util/TimerUtil.hh (original)
+++ projects/lcdd/trunk/include/lcdd/util/TimerUtil.hh Mon Jan 12 16:20:09 2015
@@ -8,7 +8,7 @@
#include <mach/mach_time.h>
#define CLOCK_REALTIME 0
#define CLOCK_MONOTONIC 0
-int clock_gettime(int clk_id, struct timespec *t){
+inline int clock_gettime(int clk_id, struct timespec *t){
mach_timebase_info_data_t timebase;
mach_timebase_info(&timebase);
uint64_t time;
Modified: projects/lcdd/trunk/src/lcdd/core/LCDDLibLoad.cc
=============================================================================
--- projects/lcdd/trunk/src/lcdd/core/LCDDLibLoad.cc (original)
+++ projects/lcdd/trunk/src/lcdd/core/LCDDLibLoad.cc Mon Jan 12 16:20:09 2015
@@ -9,38 +9,44 @@
*/
void LCDDLoadProcesses() {
- // header
+ // Header
LOAD_COMPONENT (headerProcess);
LOAD_COMPONENT (detectorProcess);
LOAD_COMPONENT (authorProcess);
LOAD_COMPONENT (generatorProcess);
LOAD_COMPONENT (commentProcess);
- // volume extended
+ // Volume extended
LOAD_COMPONENT (volumeExtendedProcess);
LOAD_COMPONENT (physvolidProcess);
- // SDs
+ // Sensitive Detectors
LOAD_COMPONENT (calorimeterProcess);
LOAD_COMPONENT (trackerProcess);
LOAD_COMPONENT (sdrefProcess);
- // hit_processor
+ // Hit Processors
LOAD_COMPONENT (hit_processorProcess);
- // segmentations
+ // Segmentations (legacy)
LOAD_COMPONENT (grid_xyzProcess);
LOAD_COMPONENT (projective_cylinderProcess);
LOAD_COMPONENT (projective_zplaneProcess);
LOAD_COMPONENT (global_grid_xyProcess);
LOAD_COMPONENT (cell_readout_2dProcess);
- // Ids
+ // New DD4hep Segmentations
+ LOAD_COMPONENT (cartesian_grid_xyProcess);
+ LOAD_COMPONENT (cartesian_grid_xzProcess);
+ LOAD_COMPONENT (cartesian_grid_xyzProcess);
+ LOAD_COMPONENT (projective_cylinderProcess);
+
+ // Identifiers
LOAD_COMPONENT (idspecProcess);
LOAD_COMPONENT (idfieldProcess);
LOAD_COMPONENT (idspecrefProcess);
- // field
+ // B-fields
LOAD_COMPONENT (fieldrefProcess);
LOAD_COMPONENT (global_fieldProcess);
LOAD_COMPONENT (solenoidProcess);
@@ -51,36 +57,36 @@
LOAD_COMPONENT (box_dipoleProcess);
LOAD_COMPONENT (field_map_3dProcess)
- // region
+ // Region
LOAD_COMPONENT (regionProcess);
LOAD_COMPONENT (regionrefProcess);
- // display
+ // Visualization
LOAD_COMPONENT (visProcess);
LOAD_COMPONENT (visrefProcess);
LOAD_COMPONENT (colorProcess);
- // limit
+ // Physics limits
LOAD_COMPONENT (limitsetProcess);
LOAD_COMPONENT (limitsetrefProcess);
LOAD_COMPONENT (limitProcess);
}
/**
- * Function for loading LCDD subscribers.
+ * Function for loading LCDD subscribers to create runtime objects.
*/
void LCDDLoadSubscribers() {
- // subscribers
+ // Header
LOAD_COMPONENT (headerSubscriber);
- // SDs
+ // Sensitive Detectors
LOAD_COMPONENT (calorimeterSubscriber);
LOAD_COMPONENT (trackerSubscriber);
- // Ids
+ // Identifiers
LOAD_COMPONENT (idspecSubscriber);
- // field
+ // B-fields
LOAD_COMPONENT (solenoidSubscriber);
LOAD_COMPONENT (rz_field_mapSubscriber);
LOAD_COMPONENT (dipoleSubscriber);
@@ -88,13 +94,13 @@
LOAD_COMPONENT (global_fieldSubscriber);
LOAD_COMPONENT (field_map_3dSubscriber);
- // region
+ // Regions
LOAD_COMPONENT (regionSubscriber);
- // display
+ // Visualization
LOAD_COMPONENT (visSubscriber);
- // limit
+ // Physics limits
LOAD_COMPONENT (limitsetSubscriber);
}
Modified: projects/lcdd/trunk/src/lcdd/detectors/BasicTrackerHitProcessor.cc
=============================================================================
--- projects/lcdd/trunk/src/lcdd/detectors/BasicTrackerHitProcessor.cc (original)
+++ projects/lcdd/trunk/src/lcdd/detectors/BasicTrackerHitProcessor.cc Mon Jan 12 16:20:09 2015
@@ -16,6 +16,8 @@
}
bool BasicTrackerHitProcessor::processHits(G4Step* step) {
+
+ //G4cout << "BasicTrackerHitProcessor::processHits" << G4endl;
TrackerSD* tracker = getTracker();
@@ -36,6 +38,8 @@
// Get the track.
G4Track* track = step->GetTrack();
+
+ //G4cout << " trackID: " << track->GetTrackID() << G4endl;
// Get the pre-step point.
G4StepPoint* pre = step->GetPreStepPoint();
@@ -80,8 +84,23 @@
// Create the hit's identifier.
Id64bit id64 = tracker->makeIdentifier(step);
+ VUserTrackInformation* trackInformation =
+ dynamic_cast<VUserTrackInformation*>(step->GetTrack()->GetUserInformation());
+
+ // If there is a user track info object, then flag it as having a hit.
+ //if (trackInformation)
+ // trackInformation->setHasTrackerHit();
+
// Set the hit information from above.
- hit->setTrackID(trackID);
+ if (trackInformation != NULL) {
+ trackInformation->setHasTrackerHit();
+
+ // Use the ID from this track, as it has track info for creating the TrackSummary.
+ hit->setTrackID(trackID);
+ } else {
+ // In the case where there is no track info, then we use the current global track ID.
+ hit->setTrackID(CurrentTrackState::getCurrentTrackID());
+ }
hit->setEdep(edep);
hit->setPosition(mid);
hit->setMomentum(momentum);
@@ -92,12 +111,10 @@
// Add the hit to the TrackerSD.
tracker->addHit(hit, _collectionIndex);
- // Get the TrackInformation and flag track as having a tracker hit.
- VUserTrackInformation* trackInformation = dynamic_cast<VUserTrackInformation*>(step->GetTrack()->GetUserInformation());
- if (trackInformation)
- trackInformation->setHasTrackerHit();
- else
- G4Exception("BasicTrackerHitProcessor::processHits", "", FatalException, "Missing required VUserTrackInformation.");
+ //G4cout << " CurrentTrackState::getCurrentTrackID: "
+ // << CurrentTrackState::getCurrentTrackID() << G4endl;
+ //else
+ // G4Exception("BasicTrackerHitProcessor::processHits", "", FatalException, "Missing required VUserTrackInformation.");
// Return true because created new hit.
return true;
Modified: projects/lcdd/trunk/src/lcdd/detectors/CalorimeterSD.cc
=============================================================================
--- projects/lcdd/trunk/src/lcdd/detectors/CalorimeterSD.cc (original)
+++ projects/lcdd/trunk/src/lcdd/detectors/CalorimeterSD.cc Mon Jan 12 16:20:09 2015
@@ -12,18 +12,30 @@
using std::vector;
CalorimeterSD::CalorimeterSD(G4String sdName, G4String hcName, Segmentation* sdSeg) :
- SensitiveDetector(sdName, hcName, SensitiveDetector::eCalorimeter), _segmentation(sdSeg) {
+ SensitiveDetector(sdName, hcName, SensitiveDetector::eCalorimeter), _segmentation(sdSeg), _ddsegmentation(NULL) {
// Setup a dummy hits collection that will be overridden later.
_hitsCollections.push_back(NULL);
}
CalorimeterSD::CalorimeterSD(G4String sdName, const vector<G4String>& hcNames, Segmentation* sdSeg) :
- SensitiveDetector(sdName, hcNames, SensitiveDetector::eCalorimeter), _segmentation(sdSeg) {
+ SensitiveDetector(sdName, hcNames, SensitiveDetector::eCalorimeter), _segmentation(sdSeg), _ddsegmentation(NULL) {
// Setup entries for each hits collection. These null pointers will be overridden later.
for (int i = 0; i < (int) hcNames.size(); i++) {
_hitsCollections.push_back(NULL);
}
}
+
+/*
+CalorimeterSD::CalorimeterSD(
+ G4String sensitiveDetectorName,
+ const vector<G4String>& hitsCollectionNames,
+ DD4hep::DDSegmentation::Segmentation* segmentation) :
+ SensitiveDetector(sensitiveDetectorName, hitsCollectionNames, SensitiveDetector::eCalorimeter), _ddsegmentation(segmentation) {
+ for (int i = 0; i < (int) hitsCollectionNames.size(); i++) {
+ _hitsCollections.push_back(NULL);
+ }
+}
+*/
CalorimeterSD::~CalorimeterSD() {
}
@@ -62,8 +74,16 @@
}
}
+void CalorimeterSD::setDDSegmentation(DD4hep::DDSegmentation::Segmentation* ddsegmentation) {
+ _ddsegmentation = ddsegmentation;
+}
+
Segmentation* CalorimeterSD::getSegmentation() const {
return _segmentation;
+}
+
+DD4hep::DDSegmentation::Segmentation* CalorimeterSD::getDDSegmentation() const {
+ return _ddsegmentation;
}
G4bool CalorimeterSD::ProcessHits(G4Step* aStep, G4TouchableHistory*) {
@@ -100,3 +120,7 @@
CalorimeterHit* CalorimeterSD::findHit(const Id64bit& id, int collectionIndex) {
return _hitMaps[collectionIndex]->get(id);
}
+
+CalorimeterHitMap* CalorimeterSD::getCalorimeterHitMap(int collectionIndex) {
+ return _hitMaps[collectionIndex];
+}
Modified: projects/lcdd/trunk/src/lcdd/detectors/CurrentTrackState.cc
=============================================================================
--- projects/lcdd/trunk/src/lcdd/detectors/CurrentTrackState.cc (original)
+++ projects/lcdd/trunk/src/lcdd/detectors/CurrentTrackState.cc Mon Jan 12 16:20:09 2015
@@ -1,4 +1,4 @@
#include "lcdd/detectors/CurrentTrackState.hh"
int CurrentTrackState::_currentTrackID = -1;
-int CurrentTrackState::_currentPrimaryID = -1;
+//int CurrentTrackState::_currentPrimaryID = -1;
Modified: projects/lcdd/trunk/src/lcdd/detectors/HitProcessorManager.cc
=============================================================================
--- projects/lcdd/trunk/src/lcdd/detectors/HitProcessorManager.cc (original)
+++ projects/lcdd/trunk/src/lcdd/detectors/HitProcessorManager.cc Mon Jan 12 16:20:09 2015
@@ -4,6 +4,7 @@
#include "lcdd/detectors/BasicCalorimeterHitProcessor.hh"
#include "lcdd/detectors/BasicTrackerHitProcessor.hh"
#include "lcdd/detectors/ScoringTrackerHitProcessor.hh"
+#include "lcdd/detectors/DDSegmentationCalorimeterHitProcessor.hh"
HitProcessorManager* HitProcessorManager::_manager = 0;
@@ -25,6 +26,8 @@
registerFactory(new BasicCalorimeterHitProcessorFactory());
registerFactory(new ScoringTrackerHitProcessorFactory());
registerFactory(new BasicTrackerHitProcessorFactory());
+
+ registerFactory(new DDSegmentationCalorimeterHitProcessorFactory());
}
void HitProcessorManager::registerFactory(HitProcessorFactory* factory) {
Modified: projects/lcdd/trunk/src/lcdd/detectors/ScoringTrackerHitProcessor.cc
=============================================================================
--- projects/lcdd/trunk/src/lcdd/detectors/ScoringTrackerHitProcessor.cc (original)
+++ projects/lcdd/trunk/src/lcdd/detectors/ScoringTrackerHitProcessor.cc Mon Jan 12 16:20:09 2015
@@ -2,6 +2,7 @@
// LCDD
#include "lcdd/core/VUserTrackInformation.hh"
+#include "lcdd/detectors/CurrentTrackState.hh"
// Geant4
#include "G4ThreeVector.hh"
@@ -53,8 +54,15 @@
// Compute the step's path length.
G4double length = sqrt(pow(startPosition.x() - endPosition.x(), 2) + pow(startPosition.y() - endPosition.y(), 2) + pow(startPosition.z() - endPosition.z(), 2));
+ VUserTrackInformation* trackInformation = dynamic_cast<VUserTrackInformation*>(step->GetTrack()->GetUserInformation());
+
// Set the hit information.
- newHit->setTrackID(trackID);
+ if (trackInformation != NULL) {
+ trackInformation->setHasTrackerHit();
+ newHit->setTrackID(trackID);
+ } else {
+ newHit->setTrackID(CurrentTrackState::getCurrentTrackID());
+ }
newHit->setEdep(edep);
newHit->setPosition(midPoint);
newHit->setMomentum(step->GetPreStepPoint()->GetMomentum());
@@ -63,11 +71,11 @@
newHit->setLength(length);
// Get the TrackInformation and flag track as having a tracker hit.
- VUserTrackInformation* trackInformation = dynamic_cast<VUserTrackInformation*>(step->GetTrack()->GetUserInformation());
- if (trackInformation)
- trackInformation->setHasTrackerHit();
- else
- G4Exception("ScoringTrackerHitProcessor::processHits", "", FatalException, "Missing required VUserTrackInformation.");
+
+ //if (trackInformation)
+ // trackInformation->setHasTrackerHit();
+ //else
+ // G4Exception("ScoringTrackerHitProcessor::processHits", "", FatalException, "Missing required VUserTrackInformation.");
// Add hit to detector.
getTracker()->addHit(newHit, getCollectionIndex());
Modified: projects/lcdd/trunk/src/lcdd/detectors/SensitiveDetectorFactory.cc
=============================================================================
--- projects/lcdd/trunk/src/lcdd/detectors/SensitiveDetectorFactory.cc (original)
+++ projects/lcdd/trunk/src/lcdd/detectors/SensitiveDetectorFactory.cc Mon Jan 12 16:20:09 2015
@@ -9,8 +9,27 @@
#include "lcdd/detectors/BasicTrackerHitProcessor.hh"
#include "lcdd/detectors/ScoringTrackerHitProcessor.hh"
#include "lcdd/schema/hit_processor.hh"
+#include "lcdd/schema/cartesian_grid_xy.hh"
+#include "lcdd/schema/cartesian_grid_xz.hh"
+#include "lcdd/schema/cartesian_grid_xyz.hh"
+#include "lcdd/schema/projective_cylinder.hh"
+
+// GDML
+#include "G4Evaluator/GDMLExpressionEvaluator.h"
+
+// DD4hep
+#include "DDSegmentation/CartesianGridXY.h"
+#include "DDSegmentation/CartesianGridXZ.h"
+#include "DDSegmentation/CartesianGridXYZ.h"
+#include "DDSegmentation/ProjectiveCylinder.h"
+
+using DD4hep::DDSegmentation::CartesianGridXY;
+using DD4hep::DDSegmentation::CartesianGridXZ;
+using DD4hep::DDSegmentation::CartesianGridXYZ;
+using DD4hep::DDSegmentation::ProjectiveCylinder;
#include <algorithm>
+#include <exception>
SensitiveDetector* SensitiveDetectorFactory::createSensitiveDetector(const SAXObject* object) {
@@ -121,8 +140,13 @@
// Set the IdSpec.
sensitiveDetector->setIdSpec(idspec);
+ // Create DDSegmentation if exists, which requires idspec and SensitiveDetector to be instantiated beforehand.
+ // FIXME: This is a weird place for this to happen I guess.
+ if (dynamic_cast<CalorimeterSD*>(sensitiveDetector) != NULL)
+ createDDSegmentation((CalorimeterSD*)sensitiveDetector, seq);
+
// Add the list of HitProcessors. This will automatically cause the HitProcessor setup code
- // to be called to configure it for this SD.
+ // to be called in order to configure it for this SD.
sensitiveDetector->addHitProcessors(hitProcessors);
// Register the SensitiveDetector with the LCDDProcessor.
@@ -136,6 +160,133 @@
return sensitiveDetector;
}
+// FIXME: The grid size calculations should apply a length unit.
+void SensitiveDetectorFactory::createDDSegmentation(CalorimeterSD* calorimeter, ContentSequence* seq) {
+
+ GDMLExpressionEvaluator* calc = GDMLProcessor::GetInstance()->GetEvaluator();
+
+ size_t count = seq->size();
+ for (size_t i = 0; i < count; i++) {
+ std::string childTag = seq->content(i).tag;
+ const ContentGroup::ContentItem& segitem = seq->content(i);
+ DD4hep::DDSegmentation::Segmentation* segmentation = NULL;
+ if (childTag == "cartesian_grid_xy") {
+
+ cartesian_grid_xy* element = dynamic_cast<cartesian_grid_xy*>(segitem.object);
+ CartesianGridXY* cartesianGridXY = new CartesianGridXY(calorimeter->getIdSpec()->getFieldDescription());
+
+ double gridSizeX, gridSizeY, offsetX, offsetY;
+ gridSizeX = gridSizeY = offsetX = offsetY = 0;
+ std::string rawValue = element->get_grid_size_x();
+ gridSizeX = calc->Eval(rawValue);
+
+ rawValue = element->get_grid_size_y();
+ gridSizeY = calc->Eval(rawValue);
+
+ rawValue = element->get_offset_x();
+ offsetX = calc->Eval(rawValue);
+
+ rawValue = element->get_offset_y();
+ offsetY = calc->Eval(rawValue);
+
+ cartesianGridXY->setGridSizeX(gridSizeX);
+ cartesianGridXY->setGridSizeY(gridSizeY);
+ cartesianGridXY->setOffsetX(offsetX);
+ cartesianGridXY->setOffsetY(offsetY);
+
+ segmentation = cartesianGridXY;
+
+ } else if (childTag == "cartesian_grid_xyz") {
+ cartesian_grid_xyz* element = dynamic_cast<cartesian_grid_xyz*>(segitem.object);
+ CartesianGridXYZ* cartesianGridXYZ = new CartesianGridXYZ(calorimeter->getIdSpec()->getFieldDescription());
+
+ double gridSizeX, gridSizeY, gridSizeZ, offsetX, offsetY, offsetZ;
+ gridSizeX = gridSizeY = gridSizeZ = offsetX = offsetY = offsetZ = 0;
+
+ std::string rawValue = element->get_grid_size_x();
+ gridSizeX = calc->Eval(rawValue);
+
+ rawValue = element->get_grid_size_y();
+ gridSizeY = calc->Eval(rawValue);
+
+ rawValue = element->get_grid_size_z();
+ gridSizeZ = calc->Eval(rawValue);
+
+ rawValue = element->get_offset_x();
+ offsetX = calc->Eval(rawValue);
+
+ rawValue = element->get_offset_y();
+ offsetY = calc->Eval(rawValue);
+
+ rawValue = element->get_offset_z();
+ offsetZ = calc->Eval(rawValue);
+
+ cartesianGridXYZ->setGridSizeX(gridSizeX);
+ cartesianGridXYZ->setGridSizeY(gridSizeY);
+ cartesianGridXYZ->setGridSizeZ(gridSizeZ);
+ cartesianGridXYZ->setOffsetX(offsetX);
+ cartesianGridXYZ->setOffsetY(offsetY);
+ cartesianGridXYZ->setOffsetZ(offsetZ);
+
+ segmentation = cartesianGridXYZ;
+ } else if (childTag == "cartesian_grid_xz") {
+ cartesian_grid_xz* element = dynamic_cast<cartesian_grid_xz*>(segitem.object);
+ CartesianGridXZ* cartesianGridXZ = new CartesianGridXZ(calorimeter->getIdSpec()->getFieldDescription());
+
+ double gridSizeX, gridSizeZ, offsetX, offsetZ;
+ gridSizeX = gridSizeZ = offsetX = offsetZ = 0;
+
+ std::string rawValue = element->get_grid_size_x();
+ gridSizeX = calc->Eval(rawValue);
+
+ rawValue = element->get_grid_size_z();
+ gridSizeZ = calc->Eval(rawValue);
+
+ rawValue = element->get_offset_x();
+ offsetX = calc->Eval(rawValue);
+
+ rawValue = element->get_offset_z();
+ offsetZ = calc->Eval(rawValue);
+
+ cartesianGridXZ->setGridSizeX(gridSizeX);
+ cartesianGridXZ->setGridSizeZ(gridSizeZ);
+ cartesianGridXZ->setOffsetX(offsetX);
+ cartesianGridXZ->setOffsetZ(offsetZ);
+
+ segmentation = cartesianGridXZ;
+ } else if (childTag == "projective_cylinder") {
+
+ projective_cylinder* element = dynamic_cast<projective_cylinder*>(segitem.object);
+ ProjectiveCylinder* projectiveCylinder = new ProjectiveCylinder(calorimeter->getIdSpec()->getFieldDescription());
+
+ double thetaBins, phiBins, offsetTheta, offsetPhi;
+ thetaBins = phiBins = offsetTheta = offsetPhi;
+
+ std::string rawValue = element->get_theta_bins();
+ thetaBins = calc->Eval(rawValue);
+
+ rawValue = element->get_phi_bins();
+ phiBins = calc->Eval(rawValue);
+
+ rawValue = element->get_offset_theta();
+ offsetTheta = calc->Eval(rawValue);
+
+ rawValue = element->get_offset_phi();
+ offsetPhi = calc->Eval(rawValue);
+
+ projectiveCylinder->setThetaBins(thetaBins);
+ projectiveCylinder->setPhiBins(phiBins);
+ projectiveCylinder->setOffsetTheta(offsetTheta);
+ projectiveCylinder->setOffsetPhi(offsetPhi);
+
+ segmentation = projectiveCylinder;
+ }
+
+ if (segmentation != NULL)
+ calorimeter->setDDSegmentation(segmentation);
+ }
+}
+
SensitiveDetector* SensitiveDetectorFactory::createCalorimeter(const SAXObject* object, const std::vector<G4String>& hitsCollections) {
const SensitiveDetectorType* sensitiveDetectorType = dynamic_cast<const SensitiveDetectorType*>(object);
Segmentation* segmentation = 0;
@@ -143,20 +294,21 @@
// Create the segmentation child object prior to the calorimeter.
ContentSequence* seq = const_cast<ContentSequence*>(sensitiveDetectorType->get_content());
size_t count = seq->size();
- 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)) {
segmentation = SegmentationFactory::createSegmentation(segitem.object, segitem.tag);
- fnd_seg = true;
break;
}
}
- // Create the calorimeter SD.
- return new CalorimeterSD(sensitiveDetectorType->get_name(), hitsCollections, segmentation);
+ // Create the CalorimeterSD object.
+ CalorimeterSD* calorimeter = new CalorimeterSD(sensitiveDetectorType->get_name(), hitsCollections, segmentation);
+
+ // Return the detector that was created.
+ return calorimeter;
}
TrackerSD* SensitiveDetectorFactory::createTracker(const SAXObject* object, const std::vector<G4String>& hitsCollections) {
@@ -185,8 +337,12 @@
}
bool SensitiveDetectorFactory::isSegmentationTag(const std::string& s) {
- // FIXME This should automatically know all segmentation types somehow.
- // Can this be read from the schema?
+ // FIXME This should automatically know all segmentation types.
+ // Can they 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 == "projective_zplane" || s == "cell_readout_2d");
-}
+ return (s == "projective_cylinder_old" ||
+ s == "grid_xyz" ||
+ s == "global_grid_xy" ||
+ s == "projective_zplane" ||
+ s == "cell_readout_2d");
+}
Modified: projects/lcdd/trunk/src/lcdd/hits/CalorimeterHit.cc
=============================================================================
--- projects/lcdd/trunk/src/lcdd/hits/CalorimeterHit.cc (original)
+++ projects/lcdd/trunk/src/lcdd/hits/CalorimeterHit.cc Mon Jan 12 16:20:09 2015
@@ -12,11 +12,11 @@
G4Allocator<CalorimeterHit> CalorimeterHitAllocator;
CalorimeterHit::CalorimeterHit() :
- G4VHit(), _edep(0), _endcap(false) {
+ G4VHit(), _edep(0) {
}
CalorimeterHit::CalorimeterHit(Id64bit id, G4double edep, G4ThreeVector globalCellPos) :
- G4VHit(), _edep(edep), _pos(globalCellPos), _endcap(false), _id(id) {
+ G4VHit(), _edep(edep), _pos(globalCellPos), _id(id) {
}
CalorimeterHit::~CalorimeterHit() {
@@ -27,7 +27,6 @@
_edep = right._edep;
_pos = right._pos;
_id = right._id;
- _endcap = right._endcap;
}
const CalorimeterHit& CalorimeterHit::operator=(const CalorimeterHit &right) {
@@ -114,11 +113,3 @@
const Id64bit& CalorimeterHit::getId64bit() const {
return _id;
}
-
-void CalorimeterHit::setEndcapFlag(bool ec) {
- _endcap = ec;
-}
-
-bool CalorimeterHit::getEndcapFlag() {
- return _endcap;
-}
Modified: projects/lcdd/trunk/src/lcdd/hits/CalorimeterHitMap.cc
=============================================================================
--- projects/lcdd/trunk/src/lcdd/hits/CalorimeterHitMap.cc (original)
+++ projects/lcdd/trunk/src/lcdd/hits/CalorimeterHitMap.cc Mon Jan 12 16:20:09 2015
@@ -15,6 +15,10 @@
return _map[id.getValue()];
}
+CalorimeterHit* CalorimeterHitMap::get(Id64bit::ValueType value) {
+ return _map[value];
+}
+
void CalorimeterHitMap::clear() {
_map.clear();
}
Modified: projects/lcdd/trunk/src/lcdd/id/IdFactory.cc
=============================================================================
--- projects/lcdd/trunk/src/lcdd/id/IdFactory.cc (original)
+++ projects/lcdd/trunk/src/lcdd/id/IdFactory.cc Mon Jan 12 16:20:09 2015
@@ -381,3 +381,21 @@
return fnd;
}
+
+DD4hep::DDSegmentation::VolumeID IdFactory::createVolumeId(G4Step* aStep, IdSpec* idspec) {
+ IdVec idvec;
+ for (IdSpec::IdFields::const_iterator iter = idspec->IdFieldsBegin(); iter != idspec->IdFieldsEnd(); iter++) {
+ IdField* field = *iter;
+ std::vector<G4VPhysicalVolume*> pvolumes = ReadoutUtil::getPhysVolList(aStep);
+ if (hasPhysVolId(pvolumes, field->getLabel())) {
+ int pvolId = findIdInPhysVols(pvolumes, field->getLabel());
+ idvec.addFieldValue(pvolId);
+ } else {
+ idvec.addFieldValue(0);
+ }
+ }
+ Id64bit id = IdFactory::createIdentifier(idvec, idspec);
+ id.encode();
+ Id64bit::ValueType volId = id.getValue();
+ return (DD4hep::DDSegmentation::VolumeID)volId;
+}
Modified: projects/lcdd/trunk/src/lcdd/segmentation/SegmentationFactory.cc
=============================================================================
--- projects/lcdd/trunk/src/lcdd/segmentation/SegmentationFactory.cc (original)
+++ projects/lcdd/trunk/src/lcdd/segmentation/SegmentationFactory.cc Mon Jan 12 16:20:09 2015
@@ -3,7 +3,7 @@
// LCDD
#include "lcdd/schema/grid_xyz.hh"
#include "lcdd/schema/global_grid_xy.hh"
-#include "lcdd/schema/projective_cylinder.hh"
+#include "lcdd/schema/projective_cylinder_old.hh"
#include "lcdd/schema/projective_zplane.hh"
#include "lcdd/schema/cell_readout_2d.hh"
#include "lcdd/segmentation/Segmentation.hh"
@@ -29,7 +29,7 @@
GDMLExpressionEvaluator* calc = GDMLProcessor::GetInstance()->GetEvaluator();
if (tag == "projective_cylinder") {
- projective_cylinder* prj = dynamic_cast<projective_cylinder*>(obj);
+ projective_cylinder_old* prj = dynamic_cast<projective_cylinder_old*>(obj);
if (prj) {
int ntheta, nphi;
std::string sval = prj->get_ntheta();
@@ -127,7 +127,7 @@
std::cerr << "Unknown child tag for calorimeter: " << tag << "." << std::endl;
}
- if (seg == 0) {
+ if (seg == NULL) {
G4Exception("", "", FatalException, "Failed to create segmentation.");
}
########################################################################
Use REPLY-ALL to reply to list
To unsubscribe from the LCDET-SVN list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCDET-SVN&A=1
|