15 modified files
lcdd/include/lcdd/detectors
diff -u -r1.8 -r1.9
--- CalorimeterSD.hh 10 Sep 2013 21:57:32 -0000 1.8
+++ CalorimeterSD.hh 14 Sep 2013 02:06:34 -0000 1.9
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/CalorimeterSD.hh,v 1.8 2013/09/10 21:57:32 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/CalorimeterSD.hh,v 1.9 2013/09/14 02:06:34 jeremy Exp $
#ifndef LCDD_DETECTORS_CALORIMETERSD_HH
#define LCDD_DETECTORS_CALORIMETERSD_HH 1
@@ -7,6 +7,7 @@
#include "lcdd/detectors/SensitiveDetector.hh"
#include "lcdd/detectors/HitComparator.hh"
#include "lcdd/hits/CalorimeterHit.hh"
+#include "lcdd/hits/CalorimeterHitMap.hh"
#include "lcdd/segmentation/Segmentation.hh"
/**
@@ -33,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, HitComparator* compare = 0);
+ CalorimeterSD(G4String sdName, G4String hcName, Segmentation* sdSeg);
/**
* Class constructor.
@@ -42,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, HitComparator* compare = 0);
+ CalorimeterSD(G4String sdName, const std::vector<G4String>& hcNames, Segmentation* sdSeg);
/**
* Class constructor.
@@ -115,18 +116,6 @@
virtual double getEdep(G4int nHC) const;
/**
- * Get a list of CalorimeterHit objects created by this detector.
- * @return The list of CalorimeterHit objects.
- */
- CalorimeterHitList getCalorimeterHitList();
-
- /**
- * Get a list of CalorimeterHit objects by hits collection index.
- * @param[in] nHC The index of the hit collection.
- */
- CalorimeterHitList getCalorimeterHitList(G4int nHC);
-
- /**
* Add a hit to this Calorimeter.
* @param[in] hit The hit to add.
*/
@@ -144,7 +133,7 @@
* @param[in] The hit to find.
* @return The found hit or 0 if not found.
*/
- CalorimeterHit* findHit(CalorimeterHit* aHit) const;
+ CalorimeterHit* findHit(CalorimeterHit* aHit);
/**
* Find a hit in the given hit collection using the current HitComparator.
@@ -152,7 +141,14 @@
* @param[in] The index of the hits collection.
* @return The found hit or 0 if not found.
*/
- CalorimeterHit* findHit(CalorimeterHit* aHit, G4int nHC) const;
+ CalorimeterHit* findHit(CalorimeterHit* aHit, G4int nHC);
+
+ /**
+ * Find a CalorimeterHit by ID.
+ * @param id The Id64bit to lookup.
+ * @return A hit with matching ID or null if does not exist.
+ */
+ CalorimeterHit* findHit(const Id64bit& id);
protected:
@@ -165,16 +161,15 @@
protected:
+ // The calorimeter's virtual segmentation.
Segmentation* _segmentation;
- HitComparator* _hitCompare;
- // TODO: Document these variables.
- // FIXME: Are all of them really needed? Can this be simplified with refactoring?
- CalorimeterHitsCollection* _collection;
+ // Pointers to hits collections.
+ CalorimeterHitsCollection* _collection; // TODO: Remove and use the _hitsCollections instead?
std::vector<CalorimeterHitsCollection*> _hitsCollections;
- CalorimeterHitList _hits;
- std::vector<CalorimeterHitList> _hitsVector;
+ // Hit lookup map.
+ CalorimeterHitMap _hitMap;
};
#endif
lcdd/include/lcdd/detectors
diff -u -r1.7 -r1.8
--- SensitiveDetector.hh 22 Aug 2013 22:32:16 -0000 1.7
+++ SensitiveDetector.hh 14 Sep 2013 02:06:34 -0000 1.8
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/SensitiveDetector.hh,v 1.7 2013/08/22 22:32:16 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/SensitiveDetector.hh,v 1.8 2013/09/14 02:06:34 jeremy Exp $
#ifndef LCDD_DETECTORS_SENSITIVEDETECTOR_HH
#define LCDD_DETECTORS_SENSITIVEDETECTOR_HH 1
@@ -56,13 +56,6 @@
*/
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.
*/
@@ -245,18 +238,16 @@
*/
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.
+ * Add a list of hit processors.
+ * @param processors The list of hit processors.
*/
- Id64bit makeId() const;
+ void addHitProcessors(HitProcessors processors);
/**
* Create a 64-bit identifier based on the step information.
* @param[in] step A G4Step object.
- * @return A 64-bit identifier from the current step.
+ * @return A 64-bit identifier generated from the step information.
*/
Id64bit makeIdentifier(G4Step* step) const;
@@ -266,13 +257,6 @@
*/
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:
/**
@@ -326,7 +310,7 @@
private:
- // type = calorimeter or tracker
+ // detector type
EType _type;
// The Geant4 command messenger associated with this detector.
lcdd/include/lcdd/hits
diff -u -r1.9 -r1.10
--- CalorimeterHit.hh 22 Aug 2013 22:32:16 -0000 1.9
+++ CalorimeterHit.hh 14 Sep 2013 02:06:35 -0000 1.10
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/hits/CalorimeterHit.hh,v 1.9 2013/08/22 22:32:16 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/lcdd/hits/CalorimeterHit.hh,v 1.10 2013/09/14 02:06:35 jeremy Exp $
#ifndef LCDD_HITS_CALORIMETERHIT_HH
#define LCDD_HITS_CALORIMETERHIT_HH 1
@@ -18,8 +18,8 @@
#include <iostream>
/**
- * @brief Implements G4VHit for calorimeter type hits.
- * @todo Move code to source file.
+ * @brief This class is an implementation of G4VHit for calorimeter hits.
+ * @todo The endcap flag should be on the collection only, not individual hits.
*/
class CalorimeterHit: public G4VHit
{
@@ -43,10 +43,11 @@
/**
* Qualified constructor.
- * @param[in] edep The hit's energy deposition.
- * @param[in] globalCellPos The hit's global position.
+ * @param[in] id The 64-bit id.
+ * @param[in] edep The energy deposition.
+ * @param[in] globalCellPos The global position.
*/
- CalorimeterHit(G4double edep, G4ThreeVector globalCellPos);
+ CalorimeterHit(Id64bit id, G4double edep, G4ThreeVector globalCellPos);
/**
* Operator overloading for setting contents from another hit.
@@ -76,13 +77,13 @@
* Print the hit contributions.
* @param[in] os The output stream.
*/
- void printMcpHitContribs(std::ostream& os);
+ void printHitContributions(std::ostream& os);
/**
* Print the hit contribution header.
* @param[in] os The output stream.
*/
- void printMcpHitContribsHeader(std::ostream&);
+ void printHitContributionsHeader(std::ostream&);
/**
* Print the contents of this hit.
@@ -100,25 +101,25 @@
* Set the hit's position.
* @param[in] posXYZ The hit's global position.
*/
- void setPos(const G4ThreeVector& posXYZ);
+ void setPosition(const G4ThreeVector& posXYZ);
/**
* Set the energy deposition.
- * @param[in] ed The energy deposition (GeV).
+ * @param[in] e The energy deposition (GeV).
*/
- void setEdep(const G4double ed);
+ void setEdep(const G4double e);
/**
* Increment the energy deposition by some amount.
- * @param[in] edincr The amount to increment the energy (GeV).
+ * @param[in] e The amount to increment the energy (GeV).
*/
- void addEnergyDeposition(const G4double edincr);
+ void addEdep(const G4double e);
/**
* Get the global position of the hit.
* @return The global position of the hit.
*/
- G4ThreeVector getPos() const;
+ G4ThreeVector getPosition() const;
/**
* Get the energy deposition of this hit.
@@ -139,13 +140,6 @@
const HitContributionList& getHitContributions() const;
/**
- * Set the value of the 64-bit ID.
- * @param[in] id0 The first 32 bits of the ID.
- * @param[in] id1 The second 32 bits of the ID.
- */
- void setId64bit(Id64bit::ElementType id0, Id64bit::ElementType id1);
-
- /**
* Get the 64-bit ID.
* @return The 64-bit ID.
*/
@@ -166,7 +160,7 @@
private:
// 64-bit id.
- Id64bit _id64;
+ Id64bit _id;
// Energy deposition.
G4double _edep;
lcdd/include/lcdd/id
diff -u -r1.6 -r1.7
--- Id64bit.hh 22 Aug 2013 22:32:16 -0000 1.6
+++ Id64bit.hh 14 Sep 2013 02:06:35 -0000 1.7
@@ -1,20 +1,27 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/id/Id64bit.hh,v 1.6 2013/08/22 22:32:16 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/lcdd/id/Id64bit.hh,v 1.7 2013/09/14 02:06:35 jeremy Exp $
#ifndef LCDD_ID64BIT_HH
#define LCDD_ID64BIT_HH 1
+// STL
+#include <stdint.h>
+
/**
* @brief A 64-bit ID composed of two 32-bit halves.
- * @todo Add method for getting long value of this ID.
- * @todo Make a fully qualified constructor and then remove the setId0 and setId1 methods.
*/
class Id64bit
{
public:
+ /**
+ * The type definition for a 32 bit half of the ID.
+ */
typedef int ElementType;
- //typedef long ValueType; // Will this always be 64 bit on 32 and 64 bit platforms???
+ /**
+ * The type definition for the 64 bit value of this ID.
+ */
+ typedef uint64_t ValueType;
public:
@@ -24,14 +31,19 @@
Id64bit();
/**
- * Class destructor.
+ * Fully qualified class constructor.
*/
- virtual ~Id64bit();
+ Id64bit(ElementType id0, ElementType id1);
/**
- * Set to default values.
+ * Copy constructor.
*/
- void resetIds();
+ Id64bit(const Id64bit &right);
+
+ /**
+ * Class destructor.
+ */
+ virtual ~Id64bit();
/**
* Set the first 32 bits of the ID.
@@ -58,20 +70,29 @@
ElementType getId1() const;
/**
- * Get the value of the ID, defined as a long.
- * @return The value of the ID defined as a long.
+ * Overloaded equals operator.
*/
- //ValueType getValue() const;
+ bool operator==(const Id64bit& right) const;
/**
- * Overloaded equals operator.
+ * Get the value of the ID, defined as a 64-bit int.
+ * @return The value of the ID.
*/
- bool operator==(const Id64bit& right) const;
+ ValueType getValue() const;
+
+ /**
+ * Set the current value by bit packing the 32-bit int values into a 64-bit value.
+ */
+ void encode();
+
+ /**
+ * Set to default values.
+ */
+ void resetIds();
private:
ElementType _ids[2];
-
- //ValueType _value;
+ ValueType _value;
};
#endif
lcdd/include/lcdd/id
diff -u -r1.5 -r1.6
--- IdFactory.hh 10 Jul 2013 22:39:26 -0000 1.5
+++ IdFactory.hh 14 Sep 2013 02:06:35 -0000 1.6
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/id/IdFactory.hh,v 1.5 2013/07/10 22:39:26 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/lcdd/id/IdFactory.hh,v 1.6 2013/09/14 02:06:35 jeremy Exp $
#ifndef LCDD_IDFACTORY_HH
#define LCDD_IDFACTORY_HH 1
@@ -55,7 +55,7 @@
* @param[in] idvec The vector of field values.
* @param[in] idspec The identifier specification.
*/
- static Id64bit createId64bit(const IdVec& idvec, IdSpec* idspec);
+ static Id64bit createIdentifier(const IdVec& idvec, IdSpec* idspec);
/**
* Create an IdVec ordered by the SD's idspec, or an empty vec if the SD does not have one.
lcdd/src/lcdd/detectors
diff -u -r1.8 -r1.9
--- CalorimeterSD.cc 10 Sep 2013 21:57:33 -0000 1.8
+++ CalorimeterSD.cc 14 Sep 2013 02:06:35 -0000 1.9
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/CalorimeterSD.cc,v 1.8 2013/09/10 21:57:33 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/CalorimeterSD.cc,v 1.9 2013/09/14 02:06:35 jeremy Exp $
// LCDD
#include "lcdd/detectors/CalorimeterSD.hh"
@@ -15,55 +15,34 @@
CalorimeterSD::CalorimeterSD(
G4String sdName,
G4String hcName,
- Segmentation* sdSeg,
- HitComparator* compare) :
+ Segmentation* sdSeg) :
SensitiveDetector(
sdName,
hcName,
SensitiveDetector::eCalorimeter),
_segmentation(sdSeg)
{
-
- _hitsVector.clear();
_hitsCollections.clear();
-
_hitsCollections.push_back(_collection);
- _hitsVector.push_back(_hits);
-
- if (compare == 0)
- _hitCompare = new PositionComparator();
- else
- _hitCompare = compare;
}
CalorimeterSD::CalorimeterSD(
G4String sdName,
const vector<G4String>& hcNames,
- Segmentation* sdSeg,
- HitComparator* compare) :
+ Segmentation* sdSeg) :
SensitiveDetector(
sdName,
hcNames,
SensitiveDetector::eCalorimeter),
_segmentation(sdSeg)
{
-
- _hitsVector.clear();
_hitsCollections.clear();
- _hitsVector.push_back(_hits);
-
+ // I think this is only setting up the hits collections in a "dummy" way for G4.
+ // The actual pointers to the collections are overridden later in Initialize.
for (int i = 0; i < (int) hcNames.size(); i++) {
- _hitsVector.push_back(_hits);
- _hitsVector[i].clear();
_hitsCollections.push_back(_collection);
}
-
- if (compare == 0) {
- _hitCompare = new PositionComparator();
- } else {
- _hitCompare = compare;
- }
}
CalorimeterSD::~CalorimeterSD()
@@ -85,22 +64,22 @@
{
clearHits();
- // new cal hits collectithe loss of habitat hits even harderon
+ // Loop over number of hits collections defined by this detector.
for (int i = 0; i < getNumberOfHitsCollections(); i++) {
//std::cout << "initializing hits collection: " << collectionName[i] << std::endl;
- // This overwrites the existing dummy collection that was added in the constructor.
+ // Overwrite pointer to the dummy collection that was added in the constructor.
_hitsCollections[i] = new CalorimeterHitsCollection(GetName(), collectionName[i]);
- // Set the HCID as it has a dummy value of zero by default.
+ // 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 hit collection to the hit collections of the event.
+ // Add the hits collection to the hits collections of the event.
HCE->AddHitsCollection(getHCID(i), _hitsCollections[i]);
// FIXME: Should _hitsVector also be setup here?
@@ -117,8 +96,9 @@
return SensitiveDetector::ProcessHits(aStep, 0);
}
-CalorimeterHit* CalorimeterSD::findHit(CalorimeterHit* aHit) const
+CalorimeterHit* CalorimeterSD::findHit(CalorimeterHit* aHit)
{
+ /*
CalorimeterHit* fndHit = 0;
for (CalorimeterHitList::const_iterator iter = _hitsVector[0].begin(); iter != _hitsVector[0].end(); iter++) {
if (_hitCompare->compare(**iter, *aHit)) {
@@ -127,10 +107,13 @@
}
}
return fndHit;
+ */
+ return _hitMap.get(aHit->getId64bit());
}
-CalorimeterHit* CalorimeterSD::findHit(CalorimeterHit* aHit, G4int nHC) const
+CalorimeterHit* CalorimeterSD::findHit(CalorimeterHit* aHit, G4int nHC)
{
+ /*
CalorimeterHit* foundHit = 0;
for (CalorimeterHitList::const_iterator it = _hitsVector[nHC].begin();
it != _hitsVector[nHC].end();
@@ -141,10 +124,13 @@
}
}
return foundHit;
+ */
+ return _hitMap.get(aHit->getId64bit());
}
std::ostream& CalorimeterSD::printHits(std::ostream& os)
{
+ /*
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++) {
@@ -152,6 +138,7 @@
}
}
os << std::endl;
+ */
return os;
}
@@ -162,6 +149,8 @@
printHits( std::cout );
}
#endif
+
+ _hitMap.clear();
}
std::ostream& CalorimeterSD::printBasicInfo(std::ostream& os)
@@ -178,50 +167,48 @@
double CalorimeterSD::getEdep() const
{
+ /*
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
{
+ /*
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();
- }
-}
-
-CalorimeterSD::CalorimeterHitList CalorimeterSD::getCalorimeterHitList()
-{
- return _hitsVector[0];
-}
-
-CalorimeterSD::CalorimeterHitList CalorimeterSD::getCalorimeterHitList(G4int nHC)
-{
- return _hitsVector[nHC];
+ //for (int i = 0; i < getNumberOfHitsCollections(); i++) {
+ // _hitsVector[i].clear();
+ //}
}
void CalorimeterSD::addHit(CalorimeterHit* hit)
{
- // add it to lkp map
- _hitsVector[0].push_back(hit);
-
- // add to the HC
_hitsCollections[0]->insert(hit);
+ _hitMap.add(hit);
}
void CalorimeterSD::addHit(CalorimeterHit* hit, int collectionIndex)
{
- _hitsVector[collectionIndex].push_back(hit);
_hitsCollections[collectionIndex]->insert(hit);
+ _hitMap.add(hit);
+}
+
+CalorimeterHit* CalorimeterSD::findHit(const Id64bit& id)
+{
+ return _hitMap.get(id);
}
lcdd/src/lcdd/detectors
diff -u -r1.2 -r1.3
--- LegacyCalorimeterHitProcessor.cc 22 Aug 2013 22:32:17 -0000 1.2
+++ LegacyCalorimeterHitProcessor.cc 14 Sep 2013 02:06:35 -0000 1.3
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/LegacyCalorimeterHitProcessor.cc,v 1.2 2013/08/22 22:32:17 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/LegacyCalorimeterHitProcessor.cc,v 1.3 2013/09/14 02:06:35 jeremy Exp $
// LCDD
#include "lcdd/detectors/LegacyCalorimeterHitProcessor.hh"
@@ -7,12 +7,14 @@
#include "G4Geantino.hh"
#include "G4ChargedGeantino.hh"
-LegacyCalorimeterHitProcessor::LegacyCalorimeterHitProcessor(CalorimeterSD* calorimeter)
- : CalorimeterHitProcessor(calorimeter)
-{}
+LegacyCalorimeterHitProcessor::LegacyCalorimeterHitProcessor(CalorimeterSD* calorimeter) :
+ CalorimeterHitProcessor(calorimeter)
+{
+}
LegacyCalorimeterHitProcessor::~LegacyCalorimeterHitProcessor()
-{}
+{
+}
bool LegacyCalorimeterHitProcessor::processHits(G4Step* step)
{
@@ -22,7 +24,8 @@
// Check for Geantino particle type.
G4ParticleDefinition* def = step->GetTrack()->GetDefinition();
bool isGeantino = false;
- if (def == G4Geantino::Definition() || def == G4ChargedGeantino::Definition()) {
+ if (def == G4Geantino::Definition()
+ || def == G4ChargedGeantino::Definition()) {
isGeantino = true;
}
@@ -35,11 +38,11 @@
Segmentation* segmentation = _calorimeter->getSegmentation();
// Get the global cell position from the Segmentation.
- G4ThreeVector globalCellPos = segmentation->getGlobalHitPosition(step);
+ G4ThreeVector globalCellPosition = segmentation->getGlobalHitPosition(step);
// Reset the Segmentation bin values.
// FIXME: This could be called from Segmentation::setBins() method.
- segmentation->resetBins();
+ //segmentation->resetBins();
// Set the segmentation bin values from the step.
segmentation->setBins(step);
@@ -47,32 +50,40 @@
// Create a 64-bit ID from the step information.
Id64bit id = _calorimeter->makeIdentifier(step);
- // Create a new hit.
- CalorimeterHit* newHit = new CalorimeterHit(edep, globalCellPos);
+ // Check for an existing hit with this identifier.
+ CalorimeterHit* hit = _calorimeter->findHit(id);
+
+ // Was there a hit found with this identifier?
+ if (hit == 0) {
+
+ // No hit was found, so a new one is created.
+ hit = new CalorimeterHit(id, edep, globalCellPosition);
- // Set the ID on the new hit.
- newHit->setId64bit(id.getId0(), id.getId1());
+ // Add the new hit to the calorimeter.
+ _calorimeter->addHit(hit);
+
+ // Debug print new hit information.
+ if (_calorimeter->getVerbose() > 0) {
+ std::cout << "new hit: " << std::hex << hit->getId64bit().getId0()
+ << "|" << hit->getId64bit().getId1() << std::endl;
+ }
- // Look for a matching hit.
- CalorimeterHit* foundHit = _calorimeter->findHit(newHit);
- if (foundHit == 0) {
- // Add a new hit to the SD.
- _calorimeter->addHit(newHit);
} else {
- // Delete the hit that was just created.
- delete newHit;
- newHit = 0;
+ // Add energy deposition to an existing hit.
+ hit->addEdep(edep);
- // Increment the energy deposition of the found hit.
- foundHit->addEnergyDeposition(edep);
+ // Debug print existing hit information.
+ if (_calorimeter->getVerbose() > 0) {
+ std::cout << "added " << edep << " GeV to hit: " << std::hex
+ << hit->getId64bit().getId0() << "|"
+ << hit->getId64bit().getId1() << std::endl;
+ }
- // Set the previous hit pointer for adding a new energy contribution.
- newHit = foundHit;
}
- // Add an energy contribution to the hit.
- newHit->addHitContribution(HitContribution(step));
+ // Add hit contribution to the hit.
+ hit->addHitContribution(HitContribution(step));
// Return true, indicating that a hit was added or modified.
return true;
lcdd/src/lcdd/detectors
diff -u -r1.2 -r1.3
--- OpticalCalorimeterHitProcessor.cc 22 Aug 2013 22:32:17 -0000 1.2
+++ OpticalCalorimeterHitProcessor.cc 14 Sep 2013 02:06:35 -0000 1.3
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/OpticalCalorimeterHitProcessor.cc,v 1.2 2013/08/22 22:32:17 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/OpticalCalorimeterHitProcessor.cc,v 1.3 2013/09/14 02:06:35 jeremy Exp $
// LCDD
#include "lcdd/detectors/OpticalCalorimeterHitProcessor.hh"
@@ -62,8 +62,7 @@
// 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* thisHit = new CalorimeterHit(id64, theEdep, globalCellPos);
CalorimeterHit* foundHit = _calorimeter->findHit(thisHit, eCerenkov);
// hit is not found?
if (foundHit == 0) {
@@ -74,7 +73,7 @@
delete thisHit;
thisHit = 0;
// incr total edep of the hit
- foundHit->addEnergyDeposition(theEdep);
+ foundHit->addEdep(theEdep);
// for setting contrib
thisHit = foundHit;
}
lcdd/src/lcdd/detectors
diff -u -r1.1 -r1.2
--- PositionComparator.cc 9 Jul 2013 18:53:30 -0000 1.1
+++ PositionComparator.cc 14 Sep 2013 02:06:35 -0000 1.2
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/PositionComparator.cc,v 1.1 2013/07/09 18:53:30 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/PositionComparator.cc,v 1.2 2013/09/14 02:06:35 jeremy Exp $
// LCDD
@@ -14,6 +14,6 @@
bool PositionComparator::compare(const CalorimeterHit& hit1, const CalorimeterHit& hit2) const
{
- return (hit1.getPos() == hit2.getPos());
+ return (hit1.getPosition() == hit2.getPosition());
}
lcdd/src/lcdd/detectors
diff -u -r1.6 -r1.7
--- SensitiveDetector.cc 22 Aug 2013 22:32:17 -0000 1.6
+++ SensitiveDetector.cc 14 Sep 2013 02:06:35 -0000 1.7
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/SensitiveDetector.cc,v 1.6 2013/08/22 22:32:17 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/SensitiveDetector.cc,v 1.7 2013/09/14 02:06:35 jeremy Exp $
// LCDD
#include "lcdd/detectors/SensitiveDetector.hh"
@@ -141,6 +141,7 @@
return os;
}
+/*
Id64bit SensitiveDetector::makeId() const
{
Id64bit id64;
@@ -150,10 +151,11 @@
const IdVec ids = IdFactory::createOrderedIdVec(step(), this);
// pack into 64 bit cell id
- id64 = IdFactory::createId64bit(ids, getIdSpec());
+ Id64bit id64 = IdFactory::createId64bit(ids, getIdSpec());
}
return id64;
}
+*/
Id64bit SensitiveDetector::makeIdentifier(G4Step* step) const
{
@@ -164,8 +166,9 @@
const IdVec ids = IdFactory::createOrderedIdVec(step, this);
// pack into 64 bit cell id
- id64 = IdFactory::createId64bit(ids, getIdSpec());
+ id64 = IdFactory::createIdentifier(ids, getIdSpec());
}
+
return id64;
}
lcdd/src/lcdd/detectors
diff -u -r1.5 -r1.6
--- SensitiveDetectorFactory.cc 22 Aug 2013 22:32:17 -0000 1.5
+++ SensitiveDetectorFactory.cc 14 Sep 2013 02:06:35 -0000 1.6
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/SensitiveDetectorFactory.cc,v 1.5 2013/08/22 22:32:17 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/SensitiveDetectorFactory.cc,v 1.6 2013/09/14 02:06:35 jeremy Exp $
// LCDD
#include "lcdd/detectors/SensitiveDetectorFactory.hh"
@@ -157,7 +157,8 @@
{
const SensitiveDetectorType* sensitiveDetectorType = dynamic_cast<const SensitiveDetectorType*>(object);
Segmentation* segmentation = 0;
- // Create the segmentation.
+
+ // 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;
@@ -171,26 +172,12 @@
break;
}
}
+
// Get the calorimeter XML object.
const calorimeter* cal = dynamic_cast<const calorimeter*>(object);
- // Determine the hit aggregation class to assign.
- const std::string& hitCompareStr = cal->get_compare();
- HitComparator* hitCompare = 0;
- if (hitCompareStr == "id") {
- // Compare by ID, which is the default via the XML schema.
- hitCompare = new IdComparator();
- } else if (hitCompareStr == "position") {
- // Compare by position.
- hitCompare = new PositionComparator();
- } else {
- // 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.");
- }
-
// Create the calorimeter SD.
- return new CalorimeterSD(sensitiveDetectorType->get_name(), hitsCollections, segmentation, hitCompare);
+ return new CalorimeterSD(sensitiveDetectorType->get_name(), hitsCollections, segmentation);
}
TrackerSD* SensitiveDetectorFactory::createTracker(const SAXObject* object, const std::vector<G4String>& hitsCollections)
@@ -202,9 +189,6 @@
//std::string name = trackerElement->get_name();
std::string hitsCollectionName = hitsCollections[0];
- // Create the basic TrackerSD.
- //std::cout << "creating new tracker: " << trackerElement->get_name() << std::endl;
- //std::cout << " HC: " << hitsCollectionName << std::endl;
TrackerSD* sd = new TrackerSD(trackerElement->get_name(), hitsCollectionName);
return sd;
lcdd/src/lcdd/detectors
diff -u -r1.2 -r1.3
--- UnsegmentedCalorimeterHitProcessor.cc 22 Aug 2013 22:32:17 -0000 1.2
+++ UnsegmentedCalorimeterHitProcessor.cc 14 Sep 2013 02:06:35 -0000 1.3
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/UnsegmentedCalorimeterHitProcessor.cc,v 1.2 2013/08/22 22:32:17 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/UnsegmentedCalorimeterHitProcessor.cc,v 1.3 2013/09/14 02:06:35 jeremy Exp $
// LCDD
#include "lcdd/detectors/UnsegmentedCalorimeterHitProcessor.hh"
@@ -19,7 +19,7 @@
bool UnsegmentedCalorimeterHitProcessor::processHits(G4Step* step)
{
// Get the energy deposition.
- G4double theEdep = step->GetTotalEnergyDeposit();
+ G4double edep = step->GetTotalEnergyDeposit();
// Check for Geantino particle type.
G4ParticleDefinition* def = step->GetTrack()->GetDefinition();
@@ -30,21 +30,18 @@
// 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) {
+ if (edep <= _calorimeter->getEnergyCut() && isGeantino == false) {
return false;
}
// Get the step mid position.
- G4ThreeVector hitPos = (0.5 * (step->GetPreStepPoint()->GetPosition() + step->GetPostStepPoint()->GetPosition()));
+ G4ThreeVector position = (0.5 * (step->GetPreStepPoint()->GetPosition() + step->GetPostStepPoint()->GetPosition()));
// Create a 64-bit ID.
- Id64bit id64 = _calorimeter->makeIdentifier(step);
+ Id64bit id = _calorimeter->makeIdentifier(step);
// Create a new hit.
- CalorimeterHit* newHit = new CalorimeterHit(theEdep, hitPos);
-
- // Set the 64-bit ID.
- newHit->setId64bit(id64.getId0(), id64.getId1());
+ CalorimeterHit* newHit = new CalorimeterHit(id, edep, position);
// Add the hit to the SD.
_calorimeter->addHit(newHit);
lcdd/src/lcdd/hits
diff -u -r1.6 -r1.7
--- CalorimeterHit.cc 22 Aug 2013 22:32:17 -0000 1.6
+++ CalorimeterHit.cc 14 Sep 2013 02:06:35 -0000 1.7
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/hits/CalorimeterHit.cc,v 1.6 2013/08/22 22:32:17 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/hits/CalorimeterHit.cc,v 1.7 2013/09/14 02:06:35 jeremy Exp $
// LCDD
#include "lcdd/hits/CalorimeterHit.hh"
@@ -15,20 +15,17 @@
G4Allocator<CalorimeterHit> CalorimeterHitAllocator;
CalorimeterHit::CalorimeterHit() :
- G4VHit(), _edep(0)
+ G4VHit(), _edep(0), _endcap(false)
{
- ;
}
-CalorimeterHit::CalorimeterHit(G4double edep, G4ThreeVector globalCellPos) :
- G4VHit(), _edep(edep), _pos(globalCellPos)
+CalorimeterHit::CalorimeterHit(Id64bit id , G4double edep, G4ThreeVector globalCellPos) :
+ G4VHit(), _edep(edep), _pos(globalCellPos), _endcap(false), _id(id)
{
- ;
}
CalorimeterHit::~CalorimeterHit()
{
- ;
}
CalorimeterHit::CalorimeterHit(const CalorimeterHit &right) :
@@ -36,6 +33,8 @@
{
_edep = right._edep;
_pos = right._pos;
+ _id = right._id;
+ _endcap = right._endcap;
}
const CalorimeterHit& CalorimeterHit::operator=(const CalorimeterHit &right)
@@ -71,16 +70,16 @@
}
#endif
-void CalorimeterHit::printMcpHitContribs(std::ostream& os)
+void CalorimeterHit::printHitContributions(std::ostream& os)
{
- printMcpHitContribsHeader(os);
+ printHitContributionsHeader(os);
for (HitContributionList::iterator iter = _particleList.begin(); iter != _particleList.end(); iter++) {
(*iter).printOut(os);
}
}
-void CalorimeterHit::printMcpHitContribsHeader(std::ostream& os)
+void CalorimeterHit::printHitContributionsHeader(std::ostream& os)
{
os << "McpHitContribs" << std::endl;
os << "trackID" << '\t' << "edep" << '\t' << '\t' << "PdgId" << '\t' << "time" << std::endl;
@@ -93,12 +92,12 @@
std::ostream& operator<<(std::ostream &os, const CalorimeterHit& hit)
{
- os << hit.getPos() << " " << G4BestUnit(hit.getEdep(), "Energy") << std::endl;
+ os << hit.getPosition() << " " << G4BestUnit(hit.getEdep(), "Energy") << std::endl;
return os;
}
-void CalorimeterHit::setPos(const G4ThreeVector& posXYZ)
+void CalorimeterHit::setPosition(const G4ThreeVector& posXYZ)
{
_pos = posXYZ;
}
@@ -109,13 +108,13 @@
_edep = ed;
}
-void CalorimeterHit::addEnergyDeposition(const G4double edincr)
+void CalorimeterHit::addEdep(const G4double edincr)
{
_edep += edincr;
}
-G4ThreeVector CalorimeterHit::getPos() const
+G4ThreeVector CalorimeterHit::getPosition() const
{
return _pos;
}
@@ -138,16 +137,17 @@
}
-void CalorimeterHit::setId64bit(Id64bit::ElementType id0, Id64bit::ElementType id1)
-{
- _id64.setId0(id0);
- _id64.setId1(id1);
-}
+//void CalorimeterHit::setId64bit(Id64bit::ElementType id0, Id64bit::ElementType id1)
+//{
+// _id.setId0(id0);
+// _id.setId1(id1);
+// _id.encode();
+//}
const Id64bit& CalorimeterHit::getId64bit() const
{
- return _id64;
+ return _id;
}
void CalorimeterHit::setEndcapFlag(bool ec)
lcdd/src/lcdd/id
diff -u -r1.1 -r1.2
--- Id64bit.cc 10 Jul 2013 20:49:06 -0000 1.1
+++ Id64bit.cc 14 Sep 2013 02:06:35 -0000 1.2
@@ -1,31 +1,42 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/id/Id64bit.cc,v 1.1 2013/07/10 20:49:06 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/id/Id64bit.cc,v 1.2 2013/09/14 02:06:35 jeremy Exp $
#include "lcdd/id/Id64bit.hh"
+#include <iostream>
Id64bit::Id64bit()
+ : _value(0)
{
- resetIds();
+ _ids[0] = 0;
+ _ids[1] = 0;
+ encode();
}
-
-Id64bit::~Id64bit()
+Id64bit::Id64bit(ElementType id0, ElementType id1)
+ : _value(0)
{
+ _ids[0] = id0;
+ _ids[1] = id1;
+ encode();
}
-void Id64bit::resetIds()
+Id64bit::Id64bit(const Id64bit &right)
+ : _value(0)
{
- _ids[0] = 0;
- _ids[1] = 0;
+ _ids[0] = right._ids[0];
+ _ids[1] = right._ids[1];
+ encode();
}
+Id64bit::~Id64bit()
+{
+}
void Id64bit::setId0(ElementType id0)
{
_ids[0] = id0;
}
-
void Id64bit::setId1(ElementType id1)
{
_ids[1] = id1;
@@ -46,3 +57,20 @@
{
return (_ids[0] == right._ids[0] && _ids[1] == right._ids[1]);
}
+
+void Id64bit::encode()
+{
+ // Encode the first 32 bits contained in id0.
+ _value |= _ids[0];
+
+ // Create value for second int in id1.
+ ValueType id1 = _ids[1];
+
+ // Encode id1 into second 32 bits.
+ _value |= (id1 << 32);
+}
+
+Id64bit::ValueType Id64bit::getValue() const
+{
+ return _value;
+}
lcdd/src/lcdd/id
diff -u -r1.4 -r1.5
--- IdFactory.cc 10 Sep 2013 21:57:33 -0000 1.4
+++ IdFactory.cc 14 Sep 2013 02:06:35 -0000 1.5
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/id/IdFactory.cc,v 1.4 2013/09/10 21:57:33 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/id/IdFactory.cc,v 1.5 2013/09/14 02:06:35 jeremy Exp $
// Uncomment to enable verbose debug output from this class.
//#define ID_DEBUG 1
@@ -20,123 +20,124 @@
IdFactory::Bits const IdFactory::MASK_ON = 0xFFFFFFFF;
-Id64bit IdFactory::createId64bit(const IdVec& idvec, IdSpec* idspec)
+Id64bit IdFactory::createIdentifier(const IdVec& idVec, IdSpec* idSpec)
{
+/*
#ifdef ID_DEBUG
G4cout << G4endl;
G4cout.setf( ios::hex );
G4cout << "IdFactory::createId64bit()" << G4endl;
- G4cout << "idvec size: " << idvec.size() << G4endl;
- G4cout << "idspec numFields: " << idspec->getNumFields() << G4endl;
- G4cout << "idspec bitLength: " << idspec->getBitLength() << G4endl;
+ G4cout << "idvec size: " << idVec.size() << G4endl;
+ G4cout << "idspec numFields: " << idSpec->getNumFields() << G4endl;
+ G4cout << "idspec bitLength: " << idSpec->getBitLength() << G4endl;
#endif
+*/
/* IdVec (expanded id) size must equal IdSpec size or die. */
- if (idvec.size() != idspec->getNumFields()) {
+ if (idVec.size() != idSpec->getNumFields()) {
G4Exception("", "", FatalException, "idspec size != idvec size.");
}
- /* Make a 64-bit id to return. */
- Id64bit id64;
-
/* A 2 member array for cell ids 1 & 2 (2x32-bit int). */
- Bits id64_val[2] = { 0, 0 };
- size_t id64_val_idx = 0;
+ Bits values[2] = {0, 0};
+ size_t valueIndex = 0;
/* Ptr to value of current idx. */
- Bits* id64_val_ptr = &id64_val[id64_val_idx];
+ Bits* valueP = &values[valueIndex];
/* Ptr to the current idfield. */
- IdField* id_field = 0;
+ IdField* field = 0;
/* Flag indicating that next 32-bit id has been reached. */
- bool next_id = false;
+ bool nextId = false;
/* loop vars */
- IdField::SizeType field_bit_len = 0;
+ IdField::SizeType fieldLength = 0;
Bits curr_bit = 0;
IdSpec::SizeType idspec_idx = 0;
- /* Loop over the IdVec, packing its values into the 64-bit Id
- using information from the IdSpec. */
- for (IdVec::ElementVector::const_iterator iter = idvec.getFieldsBegin(); iter != idvec.getFieldsEnd(); iter++) {
+ /* Loop over the IdVec, packing its values into the 64-bit Id using information from the IdSpec. */
+ for (IdVec::ElementVector::const_iterator iter = idVec.getFieldsBegin(); iter != idVec.getFieldsEnd(); iter++) {
/* field ptr from idspec */
- id_field = idspec->getIdField(idspec_idx);
- assert(id_field);
+ field = idSpec->getIdField(idspec_idx);
+ assert(field);
/* id value of field */
Id64bit::ElementType field_val = (Id64bit::ElementType) *iter;
/* field length */
- field_bit_len = id_field->getLength();
+ fieldLength = field->getLength();
/* field start */
- Bits field_start = id_field->getStart();
+ Bits fieldStart = field->getStart();
/* Don't allow crossing of 32-bit boundary.
FIXME: See http://jira.slac.stanford.edu/browse/LCDD-21
*/
- if ((field_start < 32) && (field_start + field_bit_len > 32)) {
- G4cerr << "Field <" << id_field->getLabel() << "> crosses the 32-bit boundary." << G4endl;
+ if ((fieldStart < 32) && (fieldStart + fieldLength > 32)) {
+ G4cerr << "Field <" << field->getLabel() << "> crosses the 32-bit boundary." << G4endl;
G4Exception("", "", FatalException, "Fields are not allowed to cross the 32-bit boundary.");
- }
- /* check if on 2nd dbl word. */
- else if (field_start >= 32) {
+ /* Check if on 2nd int. */
+ } else if (fieldStart >= 32) {
/* If 1st time, set id val pntr. */
- if (!next_id) {
+ if (!nextId) {
#ifdef ID_DEBUG
G4cout << "setting ptr to next id" << G4endl;
#endif
- ++id64_val_idx;
- id64_val_ptr = &id64_val[id64_val_idx];
- next_id = true;
+ ++valueIndex;
+ valueP = &values[valueIndex];
+ nextId = true;
}
/* Adjust start idx for position in next 32-bit id. */
- field_start -= 32;
+ fieldStart -= 32;
}
- Bits field_mask = makeBitMask(field_bit_len);
+ Bits mask = makeBitMask(fieldLength);
+/*
#ifdef ID_DEBUG
G4cout << "idspec_idx: " << dec << idspec_idx << G4endl;
- G4cout << "shifting left: " << dec << field_bit_len << G4endl;
+ G4cout << "shifting left: " << dec << fieldLength << G4endl;
G4cout << "curr_bit: " << dec << curr_bit << G4endl;
- G4cout << "field_label: " << id_field->getLabel() << G4endl;
- G4cout << "field_start: " << field_start << G4endl;
+ G4cout << "field_label: " << field->getLabel() << G4endl;
+ G4cout << "field_start: " << fieldStart << G4endl;
G4cout << "field_val (dec): " << dec << field_val << G4endl;
G4cout << "field_val (hex): " << hex << field_val << G4endl;
- G4cout << "field_bit_len: " << dec << field_bit_len << G4endl;
- G4cout << "field_mask: " << hex << field_mask << G4endl;
+ G4cout << "field_bit_len: " << dec << fieldLength << G4endl;
+ G4cout << "field_mask: " << hex << mask << G4endl;
#endif
+*/
/* For positive values, check that this value doesn't overflow the assigned length. */
// if ( field_val > 0 ) {
- if (checkOverflow(field_val, field_mask) != 0) {
- G4cerr << "Value <" << field_val << "> is too big for the field <" << id_field->getLabel() << ">, len <" << field_bit_len << ">." << G4endl;
+ if (checkOverflow(field_val, mask) != 0) {
+ G4cerr << "Value <" << field_val << "> is too big for the field <" << field->getLabel() << ">, len <" << fieldLength << ">." << G4endl;
G4Exception("", "", FatalException, "Value too large for field.");
}
// }
// else {
// }
+/*
#ifdef ID_DEBUG
- G4cout << "field_mask: " << hex << field_mask << G4endl;
+ G4cout << "field_mask: " << hex << mask << G4endl;
#endif
+*/
/* Apply bit mask and shift to proper left pos. */
- Bits field_val_shifted_masked = (field_val & field_mask) << field_start;
+ Bits field_val_shifted_masked = (field_val & mask) << fieldStart;
/* AND into the current id val. */
- (*id64_val_ptr) = (*id64_val_ptr) | field_val_shifted_masked;
+ (*valueP) = (*valueP) | field_val_shifted_masked;
/* Set current bit to next start pos. */
- curr_bit += id_field->getLength();
+ curr_bit += field->getLength();
#ifdef ID_DEBUG
- G4cout << "id64_val (hex): " << hex << *id64_val_ptr << G4endl;
+ G4cout << "id64_val (hex): " << hex << *valueP << G4endl;
G4cout << G4endl;
#endif
@@ -146,17 +147,24 @@
#ifdef ID_DEBUG
G4cout << "end curr_bit: " << dec << curr_bit << G4endl;
- G4cout << "end id64[0]: " << hex << id64_val[0] << G4endl;
- G4cout << "end id64[1]: " << hex << id64_val[1] << G4endl;
+ G4cout << "end id64[0]: " << hex << values[0] << G4endl;
+ G4cout << "end id64[1]: " << hex << values[1] << G4endl;
G4cout.unsetf( ios::hex );
G4cout << G4endl << G4endl;
#endif
- /* Set the two 32-bit ids in the packed id to return. */
- id64.setId0(id64_val[0]);
- id64.setId1(id64_val[1]);
+ /* Make a 64-bit id to return. */
+ Id64bit id(values[0], values[1]);
+
+ // DEBUG
+ //size_t oldWidth = cout.width();
+ //std::cout.width(8);
+ //std::cout << "created Id64bit: " << hex << id.getValue() << std::endl;
+ //std::cout << " id0: " << hex << id.getId0() << std::endl;
+ //std::cout << " id1: " << hex << id.getId1() << std::endl;
+ //std::cout.width(oldWidth);
- return id64;
+ return id;
}
inline IdFactory::Bits IdFactory::makeBitMask(IdField::SizeType len)
CVSspam 0.2.12