projects/lcdd/branches/v00-00-01_LCDD-104-dev/include/lcdd/detectors
--- projects/lcdd/branches/v00-00-01_LCDD-104-dev/include/lcdd/detectors/CalorimeterSD.hh 2014-02-27 01:28:56 UTC (rev 3033)
+++ projects/lcdd/branches/v00-00-01_LCDD-104-dev/include/lcdd/detectors/CalorimeterSD.hh 2014-02-27 01:31:56 UTC (rev 3034)
@@ -12,7 +12,6 @@
/**
* @brief The implementation of a calorimeter that accumulates energy depositions by event.
- * @todo Rewrite print functions using new data structures. Old hit vector was removed.
*/
class CalorimeterSD: public SensitiveDetector {
@@ -44,14 +43,6 @@
CalorimeterSD(G4String sdName, const std::vector<G4String>& hcNames, Segmentation* sdSeg);
/**
- * 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();
@@ -60,19 +51,19 @@
* Check whether a given logical volume is valid for this detector.
* @return True if lv is valid; false if not.
*/
- virtual bool isValidVolume(G4LogicalVolume* lv);
+ bool isValidVolume(G4LogicalVolume* lv);
/**
* Implementation of Geant4's G4VSensitiveDetector::Initialize method.
* @param[in] hc The hit collection of the event.
*/
- virtual void Initialize(G4HCofThisEvent* hc);
+ void Initialize(G4HCofThisEvent* hc);
/**
* Implementation of Geant4's G4VSensitiveDetector::EndOfEvent method.
* @param[in] hc The hit collection of the event.
*/
- virtual void EndOfEvent(G4HCofThisEvent* hc);
+ void EndOfEvent(G4HCofThisEvent* hc);
/**
* Get the segmentation of this detector or 0 if unset.
@@ -85,53 +76,30 @@
* @param[in] os The output stream.
* @return The same output stream.
*/
- std::ostream& printHits(std::ostream& os);
+ //std::ostream& printHits(std::ostream& os);
/**
- * Clear the current list of hits.
- */
- void clearHits();
-
- /**
* Print the calorimeter's basic information.
* @param[in] os The output stream.
* @return The same output stream.
*/
- virtual std::ostream& printBasicInfo(std::ostream& os);
+ std::ostream& printBasicInfo(std::ostream& os);
/**
- * Get the total energy deposition in this detector.
- * @return The total energy deposition.
- */
- virtual double getEdep() const;
-
- /**
- * Get the total energy deposition in this detector by hits collection index.
- * @param[in] nhC The index of the hits collection.
- * @return The total energy deposition in the given hits collection.
- */
- virtual double getEdep(G4int nHC) const;
-
- /**
- * Add a hit to this Calorimeter.
- * @param[in] hit The hit to add.
- */
- 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.
* @todo Deprecated => remove.
*/
- void addHit(CalorimeterHit* hit, int collectionIndex);
+ void addHit(CalorimeterHit* hit, int collectionIndex = 0);
/**
* Find a CalorimeterHit by ID.
- * @param id The Id64bit to lookup.
+ * @param[in] id The Id64bit to lookup.
+ * @param[in] collectionIndex The index of the hits collection.
* @return A hit with matching ID or null if does not exist.
*/
- CalorimeterHit* findHit(const Id64bit& id);
+ CalorimeterHit* findHit(const Id64bit& id, int collectionIndex = 0);
protected:
@@ -147,11 +115,11 @@
// The calorimeter's virtual segmentation.
Segmentation* _segmentation;
- // Pointers to hits collections.
+ // Pointers to current hits collections.
std::vector<CalorimeterHitsCollection*> _hitsCollections;
- // Hit lookup map.
- CalorimeterHitMap _hitMap;
+ // A list of hit maps, one per hits collection.
+ std::vector<CalorimeterHitMap*> _hitMaps;
};
#endif
projects/lcdd/branches/v00-00-01_LCDD-104-dev/src/lcdd/detectors
--- projects/lcdd/branches/v00-00-01_LCDD-104-dev/src/lcdd/detectors/CalorimeterSD.cc 2014-02-27 01:28:56 UTC (rev 3033)
+++ projects/lcdd/branches/v00-00-01_LCDD-104-dev/src/lcdd/detectors/CalorimeterSD.cc 2014-02-27 01:31:56 UTC (rev 3034)
@@ -15,14 +15,14 @@
CalorimeterSD::CalorimeterSD(G4String sdName, G4String hcName, Segmentation* sdSeg) :
SensitiveDetector(sdName, hcName, SensitiveDetector::eCalorimeter), _segmentation(sdSeg) {
// Setup a dummy hits collection that will be overridden later.
- _hitsCollections.push_back(0);
+ _hitsCollections.push_back(NULL);
}
CalorimeterSD::CalorimeterSD(G4String sdName, const vector<G4String>& hcNames, Segmentation* sdSeg) :
SensitiveDetector(sdName, hcNames, SensitiveDetector::eCalorimeter), _segmentation(sdSeg) {
// 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(0);
+ _hitsCollections.push_back(NULL);
}
}
@@ -40,7 +40,6 @@
}
void CalorimeterSD::Initialize(G4HCofThisEvent *HCE) {
- clearHits();
// Loop over number of hits collections defined by this detector.
for (int i = 0; i < getNumberOfHitsCollections(); i++) {
@@ -52,13 +51,15 @@
// Set the HCID of the collection if it has not been set already.
if (getHCID(i) < 0) {
- //std::cout << "set HCID: " << GetCollectionID(i) << std::endl;
// This will set the HC ID in the list that is contained in SensitiveDetector parent class.
setHCID(GetCollectionID(i), i);
}
// Add the hits collection to the hits collections of the event.
HCE->AddHitsCollection(getHCID(i), _hitsCollections[i]);
+
+ // Add a hit map for this collection.
+ _hitMaps.push_back(new CalorimeterHitMap());
}
}
@@ -70,19 +71,8 @@
return SensitiveDetector::ProcessHits(aStep, 0);
}
-//CalorimeterHit* CalorimeterSD::findHit(CalorimeterHit* aHit)
-//{
-// return _hitMap.get(aHit->getId64bit());
-//}
-
-//CalorimeterHit* CalorimeterSD::findHit(CalorimeterHit* aHit, G4int nHC)
-//{
-// return _hitMap.get(aHit->getId64bit());
-//}
-
+/*
std::ostream& CalorimeterSD::printHits(std::ostream& os) {
- // FIXME: reimplement
- /*
for (int i = 0; i < getNumberOfHitsCollections(); i++) {
os << getHitsCollection(i)->GetName() << std::endl;
for (CalorimeterHitList::const_iterator iter = _hitsVector[i].begin(); iter != _hitsVector[i].end(); iter++) {
@@ -90,9 +80,9 @@
}
}
os << std::endl;
- */
return os;
}
+*/
void CalorimeterSD::EndOfEvent(G4HCofThisEvent *) {
#ifdef G4VERBOSE
@@ -101,7 +91,13 @@
}
#endif
- _hitMap.clear();
+ // Delete hit maps.
+ for (unsigned int i=0; i<_hitMaps.size(); i++) {
+ delete _hitMaps[i];
+ }
+
+ // Clear list of hit maps.
+ _hitMaps.clear();
}
std::ostream& CalorimeterSD::printBasicInfo(std::ostream& os) {
@@ -115,53 +111,11 @@
return os;
}
-double CalorimeterSD::getEdep() const {
- // FIXME: reimplement
- /*
- double edep = 0.0;
- for (CalorimeterHitList::const_iterator it = _hitsVector[0].begin(); it != _hitsVector[0].end(); it++) {
- edep += (*it)->getEdep();
- }
- return edep;
- */
- return 0.;
-}
-
-double CalorimeterSD::getEdep(G4int nHC) const {
- // FIXME: reimplement
- /*
- double edep = 0.0;
- for (CalorimeterHitList::const_iterator it = _hitsVector[nHC].begin(); it != _hitsVector[nHC].end(); it++) {
- edep += (*it)->getEdep();
- }
- return edep;
- */
- return 0.;
-}
-
-void CalorimeterSD::clearHits() {
- //for (int i = 0; i < getNumberOfHitsCollections(); i++) {
- // _hitsVector[i].clear();
- //}
-}
-
-void CalorimeterSD::addHit(CalorimeterHit* hit) {
- _hitsCollections[0]->insert(hit);
- _hitMap.add(hit);
-}
-
void CalorimeterSD::addHit(CalorimeterHit* hit, int collectionIndex) {
- //std::cout << "adding hit" << hit << " to collection " << collectionIndex << std::endl;
_hitsCollections[collectionIndex]->insert(hit);
- //std::cout << "adding hit to map" << std::endl;
- _hitMap.add(hit);
- //std::cout << "done adding hit" << std::endl;
+ _hitMaps[collectionIndex]->add(hit);
}
-//CalorimeterHit* CalorimeterSD::findHit(const Id64bit& id) {
-// return _hitMap.get(id);
-//}
-
-CalorimeterHit* CalorimeterSD::findHit(const Id64bit& id) {
- return _hitMap.get(id);
+CalorimeterHit* CalorimeterSD::findHit(const Id64bit& id, int collectionIndex) {
+ return _hitMaps[collectionIndex]->get(id);
}