9 modified files
lcdd/include
diff -u -r1.13 -r1.14
--- G4CalorimeterSD.hh 10 Dec 2007 17:26:35 -0000 1.13
+++ G4CalorimeterSD.hh 12 Dec 2007 03:19:00 -0000 1.14
@@ -29,12 +29,9 @@
HitComparator* compare = 0);
G4CalorimeterSD(G4String sdName,
- G4String hcName[],
- G4int NrofHC,
+ const std::vector<G4String>& hcNames,
G4Segmentation* sdSeg,
HitComparator* compare = 0);
-
-
virtual ~G4CalorimeterSD();
@@ -53,8 +50,6 @@
std::ostream& printHits(std::ostream& os);
void clearHits();
- void clearHits(G4int nHC);
- void clearallHits();
virtual std::ostream& printBasicInfo(std::ostream& os);
@@ -71,9 +66,9 @@
protected:
G4Segmentation* m_segmentation;
G4CalorimeterHitsCollection* m_collection;
- std::vector< G4CalorimeterHitsCollection*> HC_vector;
+ std::vector<G4CalorimeterHitsCollection*> m_hitsCollections;
G4CalorimeterHitList m_hits;
- std::vector< G4CalorimeterHitList > hits_vector;
+ std::vector<G4CalorimeterHitList> hits_vector;
HitComparator* m_hitCompare;
};
lcdd/include
diff -u -r1.2 -r1.3
--- G4OpticalCalorimeterSD.hh 10 Dec 2007 17:26:35 -0000 1.2
+++ G4OpticalCalorimeterSD.hh 12 Dec 2007 03:19:00 -0000 1.3
@@ -4,32 +4,34 @@
// slic
#include "G4CalorimeterSD.hh"
+// stl
+#include <vector>
+
/**
@class G4OpticalCalorimeterSD
- @brief Simulator implementation of a calorimeter-type SD that is sensitive to optical photons, only.
+ @brief Simulator implementation of a calorimeter SD that is sensitive to optical photons.
*/
class G4OpticalCalorimeterSD : public G4CalorimeterSD
{
-public:
-//enum for the two Hit Collections (cerenkov and edep):
- enum HCType { eCerenkov=0, eEdep=1};
-
- G4OpticalCalorimeterSD(G4String sdName,
- G4String hcName,
- G4Segmentation* sdSeg,
- HitComparator* compare = 0);
-
- G4OpticalCalorimeterSD(G4String sdName,
- G4String hcName[],
- G4int NrofReadouts,
- G4Segmentation* sdSeg,
- HitComparator* compare = 0);
-
- virtual ~G4OpticalCalorimeterSD();
-
-protected:
- virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*);
+ public:
+ //enum for the two Hit Collections (cerenkov and edep):
+ enum HCType { eCerenkov=0, eEdep=1};
+
+ G4OpticalCalorimeterSD(G4String sdName,
+ G4String hcName,
+ G4Segmentation* sdSeg,
+ HitComparator* compare = 0);
+
+ G4OpticalCalorimeterSD(G4String sdName,
+ const std::vector<G4String>& hcNames,
+ G4Segmentation* sdSeg,
+ HitComparator* compare = 0);
+
+ virtual ~G4OpticalCalorimeterSD();
+
+ protected:
+ virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*);
};
#endif
lcdd/include
diff -u -r1.19 -r1.20
--- G4SensitiveDetector.hh 11 Dec 2007 20:56:55 -0000 1.19
+++ G4SensitiveDetector.hh 12 Dec 2007 03:19:00 -0000 1.20
@@ -16,319 +16,290 @@
/**
* @class G4SensitiveDetector
* @brief Basic implementation of G4VSensitiveDetector.
- * @note Primary settings include verbosity, energy cut,
- * IdSpec, and HC ID.
+ * @note Primary attributes include verbosity, energy cut,
+ * IdSpec,and hits collections.
*/
class G4SensitiveDetector : public G4VSensitiveDetector, protected StepReadout
{
-public:
+ public:
- /**
- * EType indicates the basic type of detector, e.g. tracker or calorimeter.
- */
- enum EType { eNone=0, eTracker=1, eCalorimeter=2 };
-
- static const std::string& trackerStr;
- static const std::string& calorimeterStr;
- static const std::string& noneStr;
-
-public:
- G4SensitiveDetector(G4String sdName,
- G4String hcName,
- EType sdType);
-
- G4SensitiveDetector(G4String sdName,
- G4String hcName[],
- G4int NrofHC,
- EType sdType);
-
- virtual ~G4SensitiveDetector();
-
-public:
-
- /**
- * Geant4 initialization function called at beginning of event.
- */
- virtual void Initialize(G4HCofThisEvent *);
-
- /**
- * Geant4 EndOfEvent hook.
- */
- virtual void EndOfEvent(G4HCofThisEvent *);
-
-protected:
-
- /**
- * Geant4 function to make hits from the step.
- */
- virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*);
-
-public:
-
- /**
- * Return the type of this detector encoded as an int.
- */
- inline G4SensitiveDetector::EType getType() const
- {
- return m_type;
- }
-
- /**
- * Return the type of this detector encoded as a string.
- */
- inline const std::string& getTypeString() const;
-
- /**
- * Return the hits collection ID associated with this detector.
- */
- inline G4int getHCID() const
- {
- return HCID_vector[0];
- }
-
- inline G4int getHCID(G4int nHC) const
- {
- if (nHC>m_NrofHC+1||nHC<0){
- G4cout << this->GetName() << "getHCID Nr of HC"<< nHC << "not valid"<< G4endl;
- return -1;
- }
- return HCID_vector[nHC];
- }
- inline G4int getNrofHC() const
- {
- return m_NrofHC;
- }
-
-
- /**
- * Check whether the G4LogicalVolume can be readout by this detector.
- * Base function just returns if the volume was assigned to this detector.
- */
- inline virtual bool isValidVolume(G4LogicalVolume* lv)
- {
- return lv != 0;
- //&& lv->GetSensitiveDetector() == this;
- }
-
- /**
- * Return the hits collection name associated with this detector.
- */
- inline const std::string& getHCName() const
- {
- return collectionName[0];
- }
-
- inline const std::string& getHCName(G4int nHC) const
- {
- return collectionName[nHC];
- }
-
- /**
- * Set the verbosity level of this detector.
- */
- inline void setVerbose(unsigned int v)
- {
- std::cout << "setVerbose " << v << std::endl;
- m_verbose = v;
- }
-
- /**
- * Get the verbosity level of this detector.
- */
- inline const unsigned int getVerbose() const
- {
- return m_verbose;
- }
-
- /**
- * Return the hit energy cut of this detector.
- */
- inline G4double getEcut()
- {
- return ecut_vector[0];
- }
- inline G4double getEcut(G4int nHC)
- {
- return ecut_vector[nHC];
- }
-
- /**
- * Set the hit energy cut of this detector.
- */
- inline void setEcut(G4double ec)
- {
- G4cout << this->GetName() << " - hit energy cut for HC 0 set to " << ec << G4endl;
- ecut_vector[0]=ec;
- }
-
- inline void setEcut(G4double ec,G4int nHC)
- {
- if (nHC>m_NrofHC+1||nHC<0){
- G4cout << this->GetName() << "setEcut Nr of HC"<< nHC << "not valid"<< G4endl;
- }
- G4cout << this->GetName() << " - hit energy cut for HC: "<< nHC<<" set to " << ec << G4endl;
- ecut_vector[nHC]=ec;
- }
-
-
- /**
- * Set the identifier specification for this detector.
- */
- inline void setIdSpec(IdSpec* idspec)
- {
- idspec_vector[0] = idspec;
- }
-
- inline void setIdSpec(IdSpec* idspec,G4int nHC)
- {
- if (nHC>m_NrofHC+1||nHC<0){
- G4cout << this->GetName() << " setIdSpec Nr of HC"<< nHC << "not valid"<< G4endl;
- }
-
- idspec_vector[nHC] = idspec;
- }
-
-
-
-
- /**
- * Return the identifier specification for this detector.
- */
- inline IdSpec* getIdSpec() const
- {
- return idspec_vector[0];
- }
- inline IdSpec* getIdSpec(G4int nHC) const
- {
- return idspec_vector[nHC];
- }
-
- /**
- * Returns whether or not this detector has an associated identifier specification.
- */
- inline bool hasIdSpec() const
- {
- return ( idspec_vector[0] != 0 );
- }
-
- /**
- * Create a 64-bit identifier based on the current step information.
- */
- Id64bit makeId() const;
-
- /**
- * Set the endcap flag.
- */
- inline void setEndcapFlag( bool ec = true )
- {
- m_endcap = ec;
- }
-
- /**
- * Return the endcap flag.
- */
- inline bool getEndcapFlag()
- {
- return m_endcap;
- }
-
- /**
- * Print basic information about this detector to the output stream.
- */
- virtual std::ostream& printBasicInfo(std::ostream& os);
-
- /**
- * Print the number of hits to the output stream.
- */
- virtual std::ostream& printNumberOfHits(std::ostream& os);
-
- /**
- * Print the number of hits to the output stream.
- */
- virtual std::ostream& printEdep(std::ostream& os);
-
- /**
- * Print the names of volumes associated to this detector.
- */
- virtual std::ostream& printVolumes(std::ostream& os);
-
- /**
- * Print the list of hits. Subclasses must implement this.
- */
- virtual std::ostream& printHits(std::ostream& os) { return os; }
-
- /**
- * Retrieve the hits collection associated with this detector,
- * using the hits collection ID (HCID).
- */
- G4VHitsCollection* getHitsCollection() const;
- G4VHitsCollection* getHitsCollection(G4int) const;
-
- /**
- * Return the number of hits. The m_nhits variable should
- * be set by a subclass for this value to have any meaning.
- */
- inline int getNumberOfHits() const { return nhits_vector[0];}
- inline int getNumberOfHits(G4int nHC) const { return nhits_vector[nHC];}
- /**
- * Return the total energy deposition from the hits of this detector.
- * Requires access to concrete hit types, so this function must be
- * implemented by subclasses.
- */
- virtual double getEdep() const { return 0.0;}
-
- /**
- * Return a list of G4LogicalVolume objects that have been assigned
- * this sensitive detector.
- */
- std::vector<G4LogicalVolume*> getLogicalVolumes() const;
-
-protected:
-
- /**
- * Set the hits collection ID corresponding to this detector.
- */
- inline void setHCID(G4int hcid)
- {
- HCID_vector[0]=hcid;
- }
-
- inline void setHCID(G4int hcid,G4int nHC)
- {
- if (nHC>m_NrofHC+1||nHC<0){
- G4cout << this->GetName() << "setHCID Nr of HC"<< nHC << "not valid"<< G4endl;
- }
- HCID_vector[nHC]=hcid;
- }
-
-protected:
- // Number of Hit Collections
- G4int m_NrofHC;
- // vector containing Hit Collection ID's
- std::vector<G4int> HCID_vector;
- // vector containing ecuts for the various collections
- std::vector<G4double> ecut_vector;
- // verbosity
- unsigned int m_verbose;
-
- // endcap flag for LCIO's CHBIT_BARREL bit
- bool m_endcap;
-
- // vector containing pointer to IdSpec
- std::vector<IdSpec*> idspec_vector;
-
-private:
-
- // type = calorimeter or tracker
- EType m_type;
-
- // The Geant4 command messenger associated with this detector.
- G4UImessenger* m_messenger;
-
-protected:
- // Hit counter.
- // vector containing Hit Counters
- std::vector<int> nhits_vector;
+ /**
+ * EType indicates the basic type of detector, e.g. tracker or calorimeter.
+ */
+ enum EType { eNone=0, eTracker=1, eCalorimeter=2 };
+
+ static const std::string& trackerStr;
+ static const std::string& calorimeterStr;
+ static const std::string& noneStr;
+
+ public:
+
+ G4SensitiveDetector(G4String sdName,
+ G4String hcName,
+ EType sdType);
+
+ G4SensitiveDetector(G4String sdName,
+ const std::vector<G4String>& hcNames,
+ EType sdType);
+
+ virtual ~G4SensitiveDetector();
+
+ public:
+
+ /**
+ * Geant4 initialization function called at beginning of event.
+ */
+ virtual void Initialize(G4HCofThisEvent *);
+
+ /**
+ * Geant4 EndOfEvent hook.
+ */
+ virtual void EndOfEvent(G4HCofThisEvent *);
+
+ protected:
+
+ /**
+ * Geant4 function to make hits from the step.
+ */
+ virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*);
+
+ public:
+
+ /**
+ * Return the type of this detector encoded as an int.
+ */
+ inline G4SensitiveDetector::EType getType() const
+ {
+ return m_type;
+ }
+
+ /**
+ * Return the type of this detector encoded as a string.
+ */
+ inline const std::string& getTypeString() const;
+
+ /**
+ * Return the hits collection ID associated with this detector.
+ */
+ inline G4int getHCID() const
+ {
+ return m_hcids[0];
+ }
+
+ inline G4int getHCID(G4int nHC) const
+ {
+ if ( nHC > getNumberOfHitsCollections() + 1 || nHC < 0 ) {
+ G4cerr << "The index " << nHC << " is not valid for SD " << this->GetName() << "." << G4endl;
+ G4Exception("Invalid index.");
+ }
+ return m_hcids[nHC];
+ }
+
+ /**
+ * Check whether the G4LogicalVolume can be readout by this detector.
+ * Base function just returns if the volume was assigned to this detector.
+ */
+ inline virtual bool isValidVolume(G4LogicalVolume* lv)
+ {
+ return lv != 0;
+ }
+
+ /**
+ * Return the hits collection name associated with this detector.
+ */
+ inline const std::string& getHCName() const
+ {
+ return collectionName[0];
+ }
+
+ inline const std::string& getHCName(G4int nHC) const
+ {
+ return collectionName[nHC];
+ }
+
+ /**
+ * Set the verbosity level of this detector.
+ */
+ inline void setVerbose(unsigned int v)
+ {
+ m_verbose = v;
+ }
+
+ /**
+ * Get the verbosity level of this detector.
+ */
+ inline const unsigned int getVerbose() const
+ {
+ return m_verbose;
+ }
+
+ /**
+ * Return the hit energy cut of this detector.
+ */
+ inline G4double getEcut()
+ {
+ return m_ecut;
+ }
+
+ /**
+ * Set the hit energy cut of this detector.
+ */
+ inline void setEcut(G4double ecut)
+ {
+ m_ecut = ecut;
+ }
+
+ /**
+ * Set the identifier specification for this detector.
+ */
+ inline void setIdSpec(IdSpec* idspec)
+ {
+ m_idspec = idspec;
+ }
+
+ /**
+ * Return the identifier specification for this detector.
+ */
+ inline IdSpec* getIdSpec() const
+ {
+ return m_idspec;
+ }
+
+ /**
+ * Returns whether or not this detector has an associated identifier specification.
+ */
+ inline bool hasIdSpec() const
+ {
+ return m_idspec != 0;
+ }
+
+ /**
+ * Create a 64-bit identifier based on the current step information.
+ */
+ Id64bit makeId() const;
+
+ /**
+ * Set the endcap flag.
+ */
+ inline void setEndcapFlag( bool ec = true )
+ {
+ m_endcap = ec;
+ }
+
+ /**
+ * Return the endcap flag.
+ */
+ inline bool getEndcapFlag()
+ {
+ return m_endcap;
+ }
+
+ /**
+ * Print basic information about this detector to the output stream.
+ */
+ virtual std::ostream& printBasicInfo(std::ostream& os);
+
+ /**
+ * Print the number of hits to the output stream.
+ */
+ virtual std::ostream& printNumberOfHits(std::ostream& os);
+
+ /**
+ * Print the number of hits to the output stream.
+ */
+ virtual std::ostream& printEdep(std::ostream& os);
+
+ /**
+ * Print the names of volumes associated to this detector.
+ */
+ virtual std::ostream& printVolumes(std::ostream& os);
+
+ /**
+ * Print the list of hits. Subclasses must implement this.
+ */
+ virtual std::ostream& printHits(std::ostream& os) { return os; }
+
+ /**
+ * Get single (first) HC associated with this detector.
+ */
+ G4VHitsCollection* getHitsCollection() const;
+
+ /**
+ * Retrieve the hits collection associated with this detector,
+ * using the hits collection ID (HCID).
+ */
+ G4VHitsCollection* getHitsCollection(G4int) const;
+
+ /**
+ * Get the number of hits collections in this SD.
+ */
+ inline int getNumberOfHitsCollections() const { return m_hcids.size(); }
+
+ /**
+ * Return the total energy deposition from the hits of this detector.
+ * Requires access to concrete hit types, so this function must be
+ * implemented by subclasses.
+ */
+ virtual double getEdep() const { return 0.0;}
+
+ /**
+ * Return a list of G4LogicalVolume objects that have been assigned
+ * this sensitive detector.
+ */
+ std::vector<G4LogicalVolume*> getLogicalVolumes() const;
+
+ /**
+ * Subclasses need to implement this method.
+ */
+ virtual void clearHits() {;}
+
+ protected:
+
+ /**
+ * Set the Hits Collection ID for a single collection.
+ */
+ inline void setHCID(G4int hcid)
+ {
+ m_hcids[0] = hcid;
+ }
+
+ /**
+ * Set the Hits Collection ID for a given collection.
+ */
+ inline void setHCID(G4int hcid, G4int nHC)
+ {
+ if ( nHC > getNumberOfHitsCollections() + 1 || nHC < 0)
+ {
+ G4cerr << this->GetName() << "setHCID Nr of HC"<< nHC << "not valid"<< G4endl;
+ G4Exception("Bad HC index.");
+ }
+ m_hcids[nHC] = hcid;
+ }
+
+ protected:
+
+ // vector containing Hit Collection ID's
+ std::vector<G4int> m_hcids;
+
+ // verbosity
+ unsigned int m_verbose;
+
+ // endcap flag for LCIO's CHBIT_BARREL bit
+ bool m_endcap;
+
+ // energy cut
+ double m_ecut;
+
+ // identifier field description
+ IdSpec* m_idspec;
+
+ private:
+
+ // type = calorimeter or tracker
+ EType m_type;
+
+ // The Geant4 command messenger associated with this detector.
+ G4UImessenger* m_messenger;
};
#endif
lcdd/include
diff -u -r1.17 -r1.18
--- G4TrackerSD.hh 12 Jul 2007 23:48:37 -0000 1.17
+++ G4TrackerSD.hh 12 Dec 2007 03:19:00 -0000 1.18
@@ -7,38 +7,37 @@
/**
@class G4TrackerSD
- @brief Geant4-based class for a tracker-type SD.
+ @brief Geant4 binding for a tracker-type SD.
*/
class G4TrackerSD : public G4SensitiveDetector
{
+ public:
+
+ typedef std::vector<G4TrackerHit*> G4TrackerHitList;
+
+ public:
+ G4TrackerSD(G4String sdName,
+ G4String hcName);
+
+ virtual ~G4TrackerSD();
+
+ public:
+ virtual void Initialize(G4HCofThisEvent *);
+ virtual void EndOfEvent(G4HCofThisEvent *);
+ std::ostream& printHits(std::ostream& os);
-public:
+ double getEdep() const;
- typedef std::vector<G4TrackerHit*> G4TrackerHitList;
+ void clearHits();
-public:
- G4TrackerSD(G4String sdName,
- G4String hcName);
-
- virtual ~G4TrackerSD();
-
-public:
- virtual void Initialize(G4HCofThisEvent *);
- virtual void EndOfEvent(G4HCofThisEvent *);
- std::ostream& printHits(std::ostream& os);
-
- double getEdep() const;
-
- void clearHits();
-
- G4TrackerHitList getTrackerHitList();
+ G4TrackerHitList getTrackerHitList();
-protected:
- virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*);
+ protected:
+ virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*);
-protected:
- G4TrackerHitsCollection* m_HC;
- G4TrackerHitList m_hits;
+ protected:
+ G4TrackerHitsCollection* m_HC;
+ G4TrackerHitList m_hits;
};
#endif
lcdd/src
diff -u -r1.36 -r1.37
--- G4CalorimeterSD.cc 10 Dec 2007 17:24:22 -0000 1.36
+++ G4CalorimeterSD.cc 12 Dec 2007 03:19:01 -0000 1.37
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/G4CalorimeterSD.cc,v 1.36 2007/12/10 17:24:22 wenzel Exp $
+// $Header: /cvs/lcd/lcdd/src/G4CalorimeterSD.cc,v 1.37 2007/12/12 03:19:01 jeremy Exp $
#include "G4CalorimeterSD.hh"
// lcdd
@@ -20,47 +20,46 @@
#include <string>
#include <vector>
+using std::vector;
+
G4CalorimeterSD::G4CalorimeterSD(G4String sdName,
- G4String hcName,
- G4Segmentation* sdSeg,
- HitComparator* compare)
-: G4SensitiveDetector(sdName,
- hcName,
- G4SensitiveDetector::eCalorimeter),
- m_segmentation(sdSeg) {
- HC_vector.push_back(m_collection);
+ G4String hcName,
+ G4Segmentation* sdSeg,
+ HitComparator* compare)
+ : G4SensitiveDetector(sdName,
+ hcName,
+ G4SensitiveDetector::eCalorimeter),
+ m_segmentation(sdSeg)
+{
+ m_hitsCollections.push_back(m_collection);
m_hits.clear();
hits_vector.clear();
hits_vector.push_back(m_hits);
- if ( compare == 0 ) {
+ if ( compare == 0 )
m_hitCompare = new PositionComparator();
- }
- else {
+ else
m_hitCompare = compare;
- }
}
-
G4CalorimeterSD::G4CalorimeterSD(G4String sdName,
- G4String hcName[],
- G4int NrofHC,
- G4Segmentation* sdSeg,
- HitComparator* compare )
-: G4SensitiveDetector(sdName,
- hcName,
- NrofHC,
- G4SensitiveDetector::eCalorimeter),
- m_segmentation(sdSeg) {
+ const vector<G4String>& hcNames,
+ G4Segmentation* sdSeg,
+ HitComparator* compare )
+ : G4SensitiveDetector(sdName,
+ hcNames,
+ G4SensitiveDetector::eCalorimeter),
+ m_segmentation(sdSeg)
+{
m_hits.clear();
hits_vector.clear();
hits_vector.push_back(m_hits);
- for (int i = 0;i<m_NrofHC;i++) {
+ for (int i = 0; i < (int)hcNames.size(); i++)
+ {
hits_vector.push_back(m_hits);
hits_vector[i].clear();
- HC_vector.push_back(m_collection);
-// hits_vector[i].push_back(m_hits);
+ m_hitsCollections.push_back(m_collection);
}
-
+
if ( compare == 0 ) {
m_hitCompare = new PositionComparator();
}
@@ -73,52 +72,57 @@
G4CalorimeterSD::~G4CalorimeterSD()
{}
-bool G4CalorimeterSD::isValidVolume(G4LogicalVolume* lv) {
+bool G4CalorimeterSD::isValidVolume(G4LogicalVolume* lv)
+{
bool valid = G4SensitiveDetector::isValidVolume(lv);
-
+
if ( valid ) {
valid = m_segmentation->isValidSolid( lv->GetSolid() );
}
-
+
return valid;
}
-void G4CalorimeterSD::Initialize(G4HCofThisEvent *HCE) {
-
- clearallHits();
- //clearHits();
+void G4CalorimeterSD::Initialize(G4HCofThisEvent *HCE)
+{
+ clearHits();
+
// new cal hits collection
- for(int i= 0; i < m_NrofHC; i++) {
- HC_vector[i]=new G4CalorimeterHitsCollection( GetName(), collectionName[i] );
+ for(int i= 0; i < getNumberOfHitsCollections(); i++)
+ {
+ m_hitsCollections[i] = new G4CalorimeterHitsCollection( GetName(), collectionName[i] );
+
// set HCID
if ( getHCID(i) < 0) {
setHCID( GetCollectionID(i), i );
}
// add collection to HC of event
- HCE->AddHitsCollection( getHCID(i), HC_vector[i] );
+ HCE->AddHitsCollection( getHCID(i), m_hitsCollections[i] );
}
}
-G4Segmentation* G4CalorimeterSD::getSegmentation() const {
+G4Segmentation* G4CalorimeterSD::getSegmentation() const
+{
return m_segmentation;
}
-G4bool G4CalorimeterSD::ProcessHits(G4Step* aStep, G4TouchableHistory*) {
+G4bool G4CalorimeterSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
+{
#ifdef G4VERBOSE
if ( getVerbose() > 0 ) {
std::cout << "G4CalorimeterSD::ProcessHits - " << this->GetName() << std::endl;
}
#endif
-// set cached step
+ // set cached step
G4SensitiveDetector::ProcessHits(aStep, 0);
-// get the edep
+ // get the edep
G4double theEdep = edep();
-// This needs to be a <= comparison for cutting on 0.
-// Allow passthrough of geantinos w/ 0 edep.
+ // This needs to be a <= comparison for cutting on 0,
+ // but it allows geantinos, which always have 0 edep.
if ( theEdep <= getEcut() && !isGeantino() ) {
#ifdef G4VERBOSE
if ( getVerbose() > 2 ) {
@@ -128,19 +132,19 @@
return false;
}
-// get global cell pos from seg
+ // get global cell pos from seg
G4ThreeVector globalCellPos = m_segmentation->getGlobalHitPos( aStep );
-// reset the seg bins
+ // reset the seg bins
m_segmentation->resetBins();
-// set the seg bins
+ // set the seg bins
m_segmentation->setBins( aStep );
-// create id and pack into 64
+ // create id and pack into 64
Id64bit id64 = makeId();
-// DEBUG: Compute step midpoint and compare to the cell pos
+ // DEBUG: Compute step midpoint and compare to the cell pos
#ifdef G4VERBOSE
if ( getVerbose() > 2 ) {
G4ThreeVector globalMidPos = midPosition();
@@ -149,12 +153,12 @@
}
#endif
-// find hit by simple lkp of new hit with above info
+ // find hit by simple lkp of new hit with above info
G4CalorimeterHit* thisHit = new G4CalorimeterHit(theEdep, globalCellPos);
thisHit->setId64bit( id64.getId0(), id64.getId1() );
G4CalorimeterHit* fndHit = 0;
-// hit is not found?
+ // hit is not found?
if ( !( fndHit = findHit( thisHit ) ) ) {
#ifdef G4VERBOSE
@@ -162,13 +166,14 @@
std::cout << "G4CalorimeterSD::ProcessHits - new hit" << std::endl;
}
#endif
-// add it to lkp map
+ // add it to lkp map
hits_vector[0].push_back(thisHit);
-// add to the HC
+
// add to the HC
- HC_vector[0]->insert(thisHit);
+ // add to the HC
+ m_hitsCollections[0]->insert(thisHit);
}
-// found a hit
+ // found a hit
else {
#ifdef G4VERBOSE
@@ -177,28 +182,29 @@
}
#endif
-// don't need to insert thisHit, so delete it
+ // don't need to insert thisHit, so delete it
delete thisHit;
thisHit = 0;
-// incr total edep of the hit
+ // incr total edep of the hit
fndHit->incrEdep(theEdep);
-// for setting contrib
+ // for setting contrib
thisHit = fndHit;
}
-// add McpHitContrib to this hit, setting info from step info
+ // add McpHitContrib to this hit, setting info from step info
thisHit->addMcpHitContrib( McpHitContrib( aStep ) );
return true;
}
-G4CalorimeterHit* G4CalorimeterSD::findHit(G4CalorimeterHit* aHit) const {
+G4CalorimeterHit* G4CalorimeterSD::findHit(G4CalorimeterHit* aHit) const
+{
G4CalorimeterHit* fndHit = 0;
for (G4CalorimeterHitList::const_iterator iter = hits_vector[0].begin();
- iter != hits_vector[0].end();
- iter++) {
+ iter != hits_vector[0].end();
+ iter++) {
if ( m_hitCompare->compare(**iter, *aHit) ) {
fndHit = *iter;
break;
@@ -207,11 +213,12 @@
return fndHit;
}
-G4CalorimeterHit* G4CalorimeterSD::findHit(G4CalorimeterHit* aHit, G4int nHC) const {
+G4CalorimeterHit* G4CalorimeterSD::findHit(G4CalorimeterHit* aHit, G4int nHC) const
+{
G4CalorimeterHit* fndHit = 0;
for (G4CalorimeterHitList::const_iterator iter = hits_vector[nHC].begin();
- iter != hits_vector[nHC].end();
- iter++) {
+ iter != hits_vector[nHC].end();
+ iter++) {
if ( m_hitCompare->compare(**iter, *aHit) ) {
fndHit = *iter;
break;
@@ -220,34 +227,31 @@
return fndHit;
}
-std::ostream& G4CalorimeterSD::printHits(std::ostream& os) {
- for(int i= 0; i < m_NrofHC; i++) {
- os << "Hit collection Nr.: "<< i<< std::endl;
+std::ostream& G4CalorimeterSD::printHits(std::ostream& os)
+{
+ for(int i= 0; i < getNumberOfHitsCollections(); i++) {
+ os << getHitsCollection(i)->GetName() << std::endl;
for (G4CalorimeterHitList::const_iterator iter = hits_vector[i].begin();
- iter != hits_vector[i].end();
- iter++ ) {
- os << **iter;
+ iter != hits_vector[i].end();
+ iter++ ) {
+ os << " " << **iter;
}
}
os << std::endl;
return os;
}
-void G4CalorimeterSD::EndOfEvent(G4HCofThisEvent *) {
- // Store the number of hits for interactive printing.
- nhits_vector[0] = HC_vector[0]->GetSize();
-
+void G4CalorimeterSD::EndOfEvent(G4HCofThisEvent *)
+{
#ifdef G4VERBOSE
- if ( getVerbose() > 0 ) {
- std::cout << GetName() << " has " << HC_vector[0]->GetSize() << " hits." << std::endl;
- }
if ( getVerbose() > 1 ) {
printHits( std::cout );
}
#endif
}
-std::ostream& G4CalorimeterSD::printBasicInfo(std::ostream& os) {
+std::ostream& G4CalorimeterSD::printBasicInfo(std::ostream& os)
+{
G4SensitiveDetector::printBasicInfo( os );
os << "segmentation type: " << m_segmentation->getTypeString() << std::endl;
@@ -255,8 +259,8 @@
os << "segmentation bins:";
for ( std::vector<std::string>::const_iterator it = m_segmentation->getBinNames().begin();
- it != m_segmentation->getBinNames().end();
- it++ ) {
+ it != m_segmentation->getBinNames().end();
+ it++ ) {
os << " " << *it;
}
@@ -265,53 +269,43 @@
return os;
}
-double G4CalorimeterSD::getEdep() const {
+double G4CalorimeterSD::getEdep() const
+{
double edep=0.0;
for ( G4CalorimeterHitList::const_iterator it = hits_vector[0].begin();
- it != hits_vector[0].end();
- it++ ) {
+ it != hits_vector[0].end();
+ it++ ) {
edep += (*it)->getEdep();
}
return edep;
}
-double G4CalorimeterSD::getEdep(G4int nHC) const {
+double G4CalorimeterSD::getEdep(G4int nHC) const
+{
double edep=0.0;
for ( G4CalorimeterHitList::const_iterator it = hits_vector[nHC].begin();
- it != hits_vector[nHC].end();
- it++ ) {
+ it != hits_vector[nHC].end();
+ it++ ) {
edep += (*it)->getEdep();
}
return edep;
}
-void G4CalorimeterSD::clearallHits() {
- for(int i= 0; i < m_NrofHC; i++) {
+void G4CalorimeterSD::clearHits()
+{
+ for(int i= 0; i < getNumberOfHitsCollections(); i++)
+ {
hits_vector[i].clear();
- nhits_vector[i]=0;
}
}
-
-void G4CalorimeterSD::clearHits() {
- hits_vector[0].clear();
- nhits_vector[0]=0;
-}
-
-
-void G4CalorimeterSD::clearHits(G4int nHC) {
-
- hits_vector[nHC].clear();
- nhits_vector[nHC]=0;
-
-}
-
-
-G4CalorimeterSD::G4CalorimeterHitList G4CalorimeterSD::getCalorimeterHitList() {
+G4CalorimeterSD::G4CalorimeterHitList G4CalorimeterSD::getCalorimeterHitList()
+{
return hits_vector[0];
}
-G4CalorimeterSD::G4CalorimeterHitList G4CalorimeterSD::getCalorimeterHitList(G4int nHC) {
+G4CalorimeterSD::G4CalorimeterHitList G4CalorimeterSD::getCalorimeterHitList(G4int nHC)
+{
return hits_vector[nHC];
}
lcdd/src
diff -u -r1.2 -r1.3
--- G4OpticalCalorimeter.cc 10 Dec 2007 17:24:22 -0000 1.2
+++ G4OpticalCalorimeter.cc 12 Dec 2007 03:19:01 -0000 1.3
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/G4OpticalCalorimeter.cc,v 1.2 2007/12/10 17:24:22 wenzel Exp $
+// $Header: /cvs/lcd/lcdd/src/G4OpticalCalorimeter.cc,v 1.3 2007/12/12 03:19:01 jeremy Exp $
#include "G4OpticalCalorimeterSD.hh"
@@ -9,216 +9,227 @@
// lcdd
#include "G4Segmentation.hh"
-//
-// 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
-//
+
+using std::vector;
+
+/**
+ * Constructor for the case only one Hit Collection is given.
+ * In this case the only the energy deposited by aborbed Cerenkov
+ * hotons is stored. Probably this will be dropped in the
+ * near future.
+ */
G4OpticalCalorimeterSD::G4OpticalCalorimeterSD(G4String sdName,
- G4String hcName,
- G4Segmentation* sdSeg,
- HitComparator* compare)
- : G4CalorimeterSD(sdName,
- hcName,
- sdSeg,
- compare)
+ G4String hcName,
+ G4Segmentation* sdSeg,
+ HitComparator* compare)
+ : G4CalorimeterSD(sdName,
+ hcName,
+ sdSeg,
+ compare)
{
- }
-//
-// 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
-//
+}
+
+/**
+ * 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.
+ */
G4OpticalCalorimeterSD::G4OpticalCalorimeterSD(G4String sdName,
- G4String hcName[],
- G4int NrofReadouts,
- G4Segmentation* sdSeg,
- HitComparator* compare)
- : G4CalorimeterSD(sdName,
- hcName,
- NrofReadouts,
- sdSeg,
- compare)
+ const vector<G4String>& hcNames,
+ G4Segmentation* sdSeg,
+ HitComparator* compare)
+ : G4CalorimeterSD(sdName,
+ hcNames,
+ sdSeg,
+ compare)
{
-
- }
+}
G4OpticalCalorimeterSD::~G4OpticalCalorimeterSD()
{}
G4bool G4OpticalCalorimeterSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
{
- // set cached step
- G4SensitiveDetector::ProcessHits(aStep, 0);
- G4Track * aTrack = aStep->GetTrack();
+ // set cached step
+ G4SensitiveDetector::ProcessHits(aStep, 0);
+ G4Track * aTrack = aStep->GetTrack();
- if(aTrack->GetCreatorProcess()==0)
- {
- return false;
- }
-
-
- // check that particle is optical photon:
- if(aTrack->GetDefinition() == G4OpticalPhoton::OpticalPhotonDefinition()) {
- if(aTrack->GetParentID()==0) {
- // particle is primary
- aTrack->SetTrackStatus(fStopAndKill);
- return false;
- }
-
- // particle is secondary
- G4String processname = aTrack->GetCreatorProcess()->G4VProcess::GetProcessName();
- // deal only with Cerenkov photons
- if(processname != "Cerenkov") {
- aTrack->SetTrackStatus(fStopAndKill);
- return false;
- }
-
- G4ThreeVector myPoint = aStep->GetPreStepPoint()->GetPosition();
- 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;
+ if(aTrack->GetCreatorProcess()==0)
+ {
+ return false;
}
+
+ // check that particle is optical photon:
+ if(aTrack->GetDefinition() == G4OpticalPhoton::OpticalPhotonDefinition())
+ {
+ if(aTrack->GetParentID()==0) {
+ // particle is primary
+ aTrack->SetTrackStatus(fStopAndKill);
+ return false;
+ }
+
+ // particle is secondary
+ G4String processname = aTrack->GetCreatorProcess()->G4VProcess::GetProcessName();
+
+ // deal only with Cerenkov photons
+ if(processname != "Cerenkov")
+ {
+ aTrack->SetTrackStatus(fStopAndKill);
+ return false;
+ }
+
+ G4ThreeVector myPoint = aStep->GetPreStepPoint()->GetPosition();
+ 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 = aTrack->GetTotalEnergy();// total photon energy
- // get global cell pos from seg
- G4ThreeVector globalCellPos = m_segmentation->getGlobalHitPos( aStep );
+ // get global cell pos from seg
+ G4ThreeVector globalCellPos = m_segmentation->getGlobalHitPos( aStep );
- // reset the seg bins
- m_segmentation->resetBins();
+ // reset the seg bins
+ m_segmentation->resetBins();
- // set the seg bins
- m_segmentation->setBins( aStep );
+ // set the seg bins
+ m_segmentation->setBins(aStep);
- // create id and pack into 64
- Id64bit id64 = makeId();
+ // create id and pack into 64
+ Id64bit id64 = makeId();
- // find hit by simple lkp of new hit with above info
- G4CalorimeterHit* thisHit = new G4CalorimeterHit(theEdep, globalCellPos);
- thisHit->setId64bit( id64.getId0(), id64.getId1() );
- G4CalorimeterHit* fndHit = 0;
- // hit is not found?
- if ( !( fndHit = findHit( thisHit,eCerenkov ) ) ) {
-
- // add it to lkp map
- hits_vector[eCerenkov].push_back(thisHit);
+ // find hit by simple lkp of new hit with above info
+ G4CalorimeterHit* thisHit = new G4CalorimeterHit(theEdep, globalCellPos);
+ thisHit->setId64bit( id64.getId0(), id64.getId1() );
+ G4CalorimeterHit* fndHit = 0;
+
+ // hit is not found?
+ if (!(fndHit = findHit(thisHit, eCerenkov)))
+ {
+ // add it to lkp map
+ hits_vector[eCerenkov].push_back(thisHit);
+
+ // add to the HC
+ m_hitsCollections[eCerenkov]->insert(thisHit);
+
+ }
+ // found a hit
+ else
+ {
+ // don't need to insert thisHit, so delete it
+ delete thisHit;
+ thisHit = 0;
- // add to the HC
- HC_vector[eCerenkov]->insert(thisHit);
- }
- // found a hit
- else {
+ // incr total edep of the hit
+ fndHit->incrEdep(theEdep);
- // don't need to insert thisHit, so delete it
- delete thisHit;
- thisHit = 0;
-
- // incr total edep of the hit
- fndHit->incrEdep(theEdep);
-
- // for setting contrib
- thisHit = fndHit;
- }
-
- // add McpHitContrib to this hit, setting info from step info
- thisHit->addMcpHitContrib( McpHitContrib( aStep ) );
- aTrack->SetTrackStatus(fStopAndKill); // don't step photon any further
-
- return true;
- } // end optical photon treatment
- else if (m_NrofHC>1) {
- // here we deal with everything but the optical photon.
- // get the edep
-
- G4double theEdep = edep();
- // This needs to be a <= comparison for cutting on 0.
- // Allow passthrough of geantinos w/ 0 edep.
- if ( theEdep <= getEcut() && !isGeantino() ) {
+ // for setting contrib
+ thisHit = fndHit;
+ }
+
+ // add McpHitContrib to this hit, setting info from step info
+ thisHit->addMcpHitContrib( McpHitContrib( aStep ) );
+ aTrack->SetTrackStatus(fStopAndKill); // don't step photon any further
+
+ return true;
+ } // end optical photon treatment
+ else if ( getNumberOfHitsCollections() > 1)
+ {
+ // here we deal with everything but the optical photon.
+ // get the edep
+
+ G4double theEdep = edep();
+
+ // This needs to be a <= comparison for cutting on 0.
+ // Allow passthrough of geantinos w/ 0 edep.
+ if ( theEdep <= getEcut() && !isGeantino() ) {
#ifdef G4VERBOSE
- if ( getVerbose() > 2 ) {
- std::cout << "G4CalorimeterSD::ProcessHits - cut on edep " << theEdep << std::endl;
- }
+ if ( getVerbose() > 2 ) {
+ std::cout << "G4CalorimeterSD::ProcessHits - cut on edep " << theEdep << std::endl;
+ }
#endif
- return false;
- }
+ return false;
+ }
+
+ // get global cell pos from seg
+ G4ThreeVector globalCellPos = m_segmentation->getGlobalHitPos( aStep );
- // get global cell pos from seg
- G4ThreeVector globalCellPos = m_segmentation->getGlobalHitPos( aStep );
- // reset the seg bins
- m_segmentation->resetBins();
+ // reset the seg bins
+ m_segmentation->resetBins();
- // set the seg bins
- m_segmentation->setBins( aStep );
+ // set the seg bins
+ m_segmentation->setBins( aStep );
- // create id and pack into 64
- Id64bit id64 = makeId();
+ // create id and pack into 64
+ Id64bit id64 = makeId();
- // DEBUG: Compute step midpoint and compare to the cell pos
+ // DEBUG: Compute step midpoint and compare to the cell pos
#ifdef G4VERBOSE
- if ( getVerbose() > 2 ) {
- G4ThreeVector globalMidPos = midPosition();
- std::cout << "globalMidPos " << globalMidPos << std::endl;
- std::cout << "globalCellPos - globalMidPos = " << globalCellPos - globalMidPos << std::endl;
- }
+ if ( getVerbose() > 2 ) {
+ G4ThreeVector globalMidPos = midPosition();
+ std::cout << "globalMidPos " << globalMidPos << std::endl;
+ std::cout << "globalCellPos - globalMidPos = " << globalCellPos - globalMidPos << std::endl;
+ }
#endif
- // find hit by simple lkp of new hit with above info
- G4CalorimeterHit* thisHit = new G4CalorimeterHit(theEdep, globalCellPos);
- thisHit->setId64bit( id64.getId0(), id64.getId1() );
- G4CalorimeterHit* fndHit = 0;
-
- // hit is not found?
- if ( !( fndHit = findHit( thisHit,eEdep ) ) ) {
+ // find hit by simple lkp of new hit with above info
+ G4CalorimeterHit* thisHit = new G4CalorimeterHit(theEdep, globalCellPos);
+ thisHit->setId64bit( id64.getId0(), id64.getId1() );
+ G4CalorimeterHit* fndHit = 0;
+
+ // hit is not found?
+ if ( !( fndHit = findHit( thisHit,eEdep ) ) )
+ {
#ifdef G4VERBOSE
- if ( getVerbose() > 1 ) {
- std::cout << "G4CalorimeterSD::ProcessHits - new hit" << std::endl;
- }
+ if ( getVerbose() > 1 ) {
+ std::cout << "G4CalorimeterSD::ProcessHits - new hit" << std::endl;
+ }
#endif
- // add it to lkp map
- hits_vector[eEdep].push_back(thisHit);
- // add to the HC
- HC_vector[eEdep]->insert(thisHit);
-
- }
- // found a hit
- else {
+ // add it to lkp map
+ hits_vector[eEdep].push_back(thisHit);
+
+ // add to the HC
+ m_hitsCollections[eEdep]->insert(thisHit);
+ }
+ // found a hit
+ else
+ {
#ifdef G4VERBOSE
- if ( getVerbose() > 2 ) {
- std::cout << "G4CalorimeterSD::ProcessHits - existing hit" << std::endl;
- }
+ if ( getVerbose() > 2 ) {
+ std::cout << "G4CalorimeterSD::ProcessHits - existing hit" << std::endl;
+ }
#endif
- // don't need to insert thisHit, so delete it
- delete thisHit;
- thisHit = 0;
-
- // incr total edep of the hit
- fndHit->incrEdep(theEdep);
-
- // for setting contrib
- thisHit = fndHit;
- }
-
- // add McpHitContrib to this hit, setting info from step info
- thisHit->addMcpHitContrib( McpHitContrib( aStep ) );
- return true;
- }
- else
- {
- return false;
- }
+ // don't need to insert thisHit, so delete it
+ delete thisHit;
+ thisHit = 0;
+
+ // incr total edep of the hit
+ fndHit->incrEdep(theEdep);
+
+ // for setting contrib
+ thisHit = fndHit;
+ }
+
+ // add McpHitContrib to this hit, setting info from step info
+ thisHit->addMcpHitContrib( McpHitContrib( aStep ) );
+ return true;
+ }
+ else
+ {
+ return false;
+ }
}
lcdd/src
diff -u -r1.14 -r1.15
--- G4SensitiveDetector.cc 10 Dec 2007 17:24:22 -0000 1.14
+++ G4SensitiveDetector.cc 12 Dec 2007 03:19:01 -0000 1.15
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/G4SensitiveDetector.cc,v 1.14 2007/12/10 17:24:22 wenzel Exp $
+// $Header: /cvs/lcd/lcdd/src/G4SensitiveDetector.cc,v 1.15 2007/12/12 03:19:01 jeremy Exp $
#include "G4SensitiveDetector.hh"
@@ -19,178 +19,188 @@
// stl
#include <iostream>
+#include <vector>
+
+using std::vector;
const std::string& G4SensitiveDetector::trackerStr = "tracker";
const std::string& G4SensitiveDetector::calorimeterStr = "calorimeter";
const std::string& G4SensitiveDetector::noneStr = "none";
G4SensitiveDetector::G4SensitiveDetector(G4String sdName,
- G4String hcName,
- EType sdType)
- : G4VSensitiveDetector(sdName),
- m_NrofHC(1),
- m_type(sdType){
- // insert hits collection name into SD's name vector
- collectionName.insert(hcName);
-
- // register detector with G4SDManager
- G4SDManager::GetSDMpointer()->AddNewDetector(this);
-
- // Create the command messenger.
- m_messenger = new SensitiveDetectorMessenger(this);
-
- // Only one element in the vectors:
-
- HCID_vector.clear();
- nhits_vector.clear();
- idspec_vector.clear();
- ecut_vector.clear();
-
- HCID_vector.push_back(-1);
- nhits_vector.push_back(-1);
- ecut_vector.push_back(0);
- idspec_vector.push_back(NULL);
- }
-
- G4SensitiveDetector::G4SensitiveDetector(G4String sdName,
- G4String hcName[],
- G4int NrofHC,
- EType sdType)
- : G4VSensitiveDetector(sdName),
- m_NrofHC(NrofHC),
- m_type(sdType) {
- HCID_vector.clear();
- nhits_vector.clear();
- idspec_vector.clear();
- ecut_vector.clear();
- for(int i= 0; i < m_NrofHC; i++) {
- // insert hits collection name into SD's name vector
- collectionName.insert(hcName[i]);
- HCID_vector.push_back(-1);
- nhits_vector.push_back(-1);
- ecut_vector.push_back(0);
- idspec_vector.push_back(NULL);
- }
-
- // register detector with G4SDManager
- G4SDManager::GetSDMpointer()->AddNewDetector(this);
-
- // Create the command messenger.
- m_messenger = new SensitiveDetectorMessenger(this);
- }
- G4SensitiveDetector::~G4SensitiveDetector()
- {}
-
- void G4SensitiveDetector::Initialize(G4HCofThisEvent *) {
- // no-op
- }
-
- void G4SensitiveDetector::EndOfEvent(G4HCofThisEvent *) {
- // no-op
- }
-
- G4bool G4SensitiveDetector::ProcessHits(G4Step* aStep, G4TouchableHistory*) {
- // set cached step
- setStep(aStep);
-
- // doesn't write a hit
- return false;
- }
-
- const std::string& G4SensitiveDetector::getTypeString() const {
- if ( m_type == eTracker ) {
- return trackerStr;
- }
- else if ( m_type == eCalorimeter ) {
- return calorimeterStr;
- }
- return noneStr;
- }
-
- std::ostream& G4SensitiveDetector::printBasicInfo(std::ostream& os) {
- os << "name: " << GetName() << std::endl;
- os << "type: " << m_type << std::endl;
- os << "hits collection: " << this->getHCName() << std::endl;
- os << "hits collection ID: " << HCID_vector[0]<< std::endl;
- os << "energy cut: " << G4BestUnit( ecut_vector[0], "Energy" ) << std::endl;
- os << "endcap flag: " << m_endcap << std::endl;
- os << "verbose level: " << m_verbose << std::endl;
-
- if ( idspec_vector[0] != 0 ) {
- os << "id spec: " << idspec_vector[0]->getName() << std::endl;
- os << "id fields:";
- for ( IdSpec::IdFields::const_iterator it = idspec_vector[0]->IdFieldsBegin();
- it != idspec_vector[0]->IdFieldsEnd();
- it++ ) {
- os << " " << (*it)->getLabel();
- }
- os << std::endl;
- }
- else {
- os << "no id spec" << std::endl;
- }
-
- return os;
- }
-
- Id64bit G4SensitiveDetector::makeId() const {
- Id64bit id64;
+ G4String hcName,
+ EType sdType)
+ : G4VSensitiveDetector(sdName),
+ m_type(sdType)
+{
+ // insert hits collection name into SD's name vector
+ collectionName.insert(hcName);
+
+ // register detector with G4SDManager
+ G4SDManager::GetSDMpointer()->AddNewDetector(this);
+
+ // Create the command messenger.
+ m_messenger = new SensitiveDetectorMessenger(this);
+
+ // Only one HC
+ m_hcids.clear();
+ m_hcids.push_back(-1);
+}
+
+G4SensitiveDetector::G4SensitiveDetector(G4String sdName,
+ const vector<G4String>& hcNames,
+ EType sdType)
+ : G4VSensitiveDetector(sdName),
+ m_type(sdType)
+{
+ m_hcids.clear();
+
+ for (int i=0; i < (int)hcNames.size(); i++)
+ {
+ // insert hits collection name into SD's name vector
+ collectionName.insert(hcNames[i]);
+ m_hcids.push_back(-1);
+ }
+
+ // register detector with G4SDManager
+ G4SDManager::GetSDMpointer()->AddNewDetector(this);
+
+ // Create the command messenger.
+ m_messenger = new SensitiveDetectorMessenger(this);
+}
+
+G4SensitiveDetector::~G4SensitiveDetector()
+{}
+
+void G4SensitiveDetector::Initialize(G4HCofThisEvent *)
+{
+ // no-op
+}
+
+void G4SensitiveDetector::EndOfEvent(G4HCofThisEvent *)
+{
+ // no-op
+}
+
+G4bool G4SensitiveDetector::ProcessHits(G4Step* aStep, G4TouchableHistory*)
+{
+ // set cached step
+ setStep(aStep);
+
+ // doesn't write a hit
+ return false;
+}
+
+const std::string& G4SensitiveDetector::getTypeString() const
+{
+ if ( m_type == eTracker ) {
+ return trackerStr;
+ }
+ else if ( m_type == eCalorimeter ) {
+ return calorimeterStr;
+ }
+ return noneStr;
+}
+
+std::ostream& G4SensitiveDetector::printBasicInfo(std::ostream& os)
+{
+ os << "name: " << GetName() << std::endl;
+ os << "type: " << m_type << std::endl;
+ os << "hits collection: " << this->getHCName() << std::endl;
+ os << "hits collection ID: " << m_hcids[0]<< std::endl;
+ os << "energy cut: " << G4BestUnit( m_ecut, "Energy" ) << std::endl;
+ os << "endcap flag: " << m_endcap << std::endl;
+ os << "verbose level: " << m_verbose << std::endl;
+
+ if ( m_idspec != 0 )
+ {
+ os << "id spec: " << m_idspec->getName() << std::endl;
+ os << "id fields:";
+ for ( IdSpec::IdFields::const_iterator it = m_idspec->IdFieldsBegin();
+ it != m_idspec->IdFieldsEnd();
+ it++ ) {
+ os << " " << (*it)->getLabel();
+ }
+ os << std::endl;
+ }
+ else
+ {
+ os << "idspec points to null!" << std::endl;
+ }
+
+ return os;
+}
+
+Id64bit G4SensitiveDetector::makeId() const
+{
+ Id64bit id64;
- if ( hasIdSpec() ) {
+ if ( hasIdSpec() ) {
- // get idvec ordered by this idspec
- const IdVec ids = IdFactory::createOrderedIdVec( step(), this );
+ // get idvec ordered by this idspec
+ const IdVec ids = IdFactory::createOrderedIdVec( step(), this );
- // pack into 64 bit cell id
- id64 = IdFactory::createId64bit( ids, getIdSpec() );
- }
-
- return id64;
- }
-
- G4VHitsCollection* G4SensitiveDetector::getHitsCollection() const {
- G4VHitsCollection* hc = 0;
- if ( this->getHCID() != -1 ) {
- hc = G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetHCofThisEvent()->GetHC( this->getHCID() );
- }
- return hc;
- }
- G4VHitsCollection* G4SensitiveDetector::getHitsCollection(G4int nHC) const {
- G4VHitsCollection* hc = 0;
- if ( this->getHCID(nHC) != -1 ) {
- hc = G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetHCofThisEvent()->GetHC( this->getHCID(nHC) );
- }
- return hc;
- }
- std::ostream& G4SensitiveDetector::printNumberOfHits(std::ostream& os) {
- os << "number of hits: " << this->getNumberOfHits() << std::endl;
- return os;
- }
-
- std::ostream& G4SensitiveDetector::printEdep(std::ostream& os) {
- os << "total edep: " << G4BestUnit( this->getEdep(), "Energy" ) << std::endl;
- return os;
- }
-
- std::vector<G4LogicalVolume*> G4SensitiveDetector::getLogicalVolumes() const {
- std::vector<G4LogicalVolume*> volumes;
- for ( G4LogicalVolumeStore::const_iterator it = G4LogicalVolumeStore::GetInstance()->begin();
- it != G4LogicalVolumeStore::GetInstance()->end();
- it++ ) {
- if ( (*it)->GetSensitiveDetector() == this ) {
- volumes.push_back( *it );
- }
- }
- return volumes;
- }
-
- std::ostream& G4SensitiveDetector::printVolumes(std::ostream& os) {
- std::vector<G4LogicalVolume*> volumes = this->getLogicalVolumes();
-
- for ( std::vector<G4LogicalVolume*>::const_iterator it = volumes.begin();
- it != volumes.end();
- it++ ) {
- std::cout << (*it)->GetName() << std::endl;
- }
- return os;
- }
+ // pack into 64 bit cell id
+ id64 = IdFactory::createId64bit( ids, getIdSpec() );
+ }
+
+ return id64;
+}
+
+G4VHitsCollection* G4SensitiveDetector::getHitsCollection() const
+{
+ G4VHitsCollection* hc = 0;
+ if ( this->getHCID() != -1 ) {
+ hc = G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetHCofThisEvent()->GetHC( this->getHCID() );
+ }
+ return hc;
+}
+
+G4VHitsCollection* G4SensitiveDetector::getHitsCollection(G4int nHC) const
+{
+ G4VHitsCollection* hc = 0;
+ if ( this->getHCID(nHC) != -1 ) {
+ hc = G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetHCofThisEvent()->GetHC( this->getHCID(nHC) );
+ }
+ return hc;
+}
+
+std::ostream& G4SensitiveDetector::printNumberOfHits(std::ostream& os)
+{
+ for (int i = 0; i < getNumberOfHitsCollections(); i++)
+ {
+ os << getHitsCollection(i)->GetName() << " " << getHitsCollection(i)->GetSize() << std::endl;
+ }
+ return os;
+}
+
+std::ostream& G4SensitiveDetector::printEdep(std::ostream& os)
+{
+ os << "total edep: " << G4BestUnit( this->getEdep(), "Energy" ) << std::endl;
+ return os;
+}
+
+std::vector<G4LogicalVolume*> G4SensitiveDetector::getLogicalVolumes() const
+{
+ std::vector<G4LogicalVolume*> volumes;
+ for ( G4LogicalVolumeStore::const_iterator it = G4LogicalVolumeStore::GetInstance()->begin();
+ it != G4LogicalVolumeStore::GetInstance()->end();
+ it++ ) {
+ if ( (*it)->GetSensitiveDetector() == this ) {
+ volumes.push_back( *it );
+ }
+ }
+ return volumes;
+}
+
+std::ostream& G4SensitiveDetector::printVolumes(std::ostream& os)
+{
+ std::vector<G4LogicalVolume*> volumes = this->getLogicalVolumes();
+
+ for ( std::vector<G4LogicalVolume*>::const_iterator it = volumes.begin();
+ it != volumes.end();
+ it++ ) {
+ std::cout << (*it)->GetName() << std::endl;
+ }
+ return os;
+}
lcdd/src
diff -u -r1.37 -r1.38
--- G4TrackerSD.cc 10 Dec 2007 17:24:22 -0000 1.37
+++ G4TrackerSD.cc 12 Dec 2007 03:19:01 -0000 1.38
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/G4TrackerSD.cc,v 1.37 2007/12/10 17:24:22 wenzel Exp $
+// $Header: /cvs/lcd/lcdd/src/G4TrackerSD.cc,v 1.38 2007/12/12 03:19:01 jeremy Exp $
// LCDD
#include "IdManager.hh"
@@ -105,9 +105,6 @@
void G4TrackerSD::EndOfEvent(G4HCofThisEvent *)
{
- // Store the number of hits for possible interactive printing.
- nhits_vector[0] = m_hits.size();
-
#ifdef G4VERBOSE
if ( getVerbose() > 0 ) {
std::cout << GetName() << " has " << m_HC->GetSize() << " hits." << std::endl;
@@ -133,7 +130,6 @@
void G4TrackerSD::clearHits()
{
m_hits.clear();
- nhits_vector[0]=0;
}
G4TrackerSD::G4TrackerHitList G4TrackerSD::getTrackerHitList()
lcdd/src
diff -u -r1.17 -r1.18
--- SensitiveDetectorFactory.cc 10 Dec 2007 23:05:02 -0000 1.17
+++ SensitiveDetectorFactory.cc 12 Dec 2007 03:19:01 -0000 1.18
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/SensitiveDetectorFactory.cc,v 1.17 2007/12/10 23:05:02 wenzel Exp $
+// $Header: /cvs/lcd/lcdd/src/SensitiveDetectorFactory.cc,v 1.18 2007/12/12 03:19:01 jeremy Exp $
#include "SensitiveDetectorFactory.hh"
// lcdd
@@ -140,14 +140,13 @@
//
// in case of optical alorimeter there are 2 hit collections
//
- int NrofReadouts=2;
- G4String hcnames[2];
- hcnames[0] = "Ceren_"+sdt->get_hitsCollectionName();
- hcnames[1] = "Edep_"+sdt->get_hitsCollectionName();
- std::cout<< " now creating optical calorimeter"<<std::endl;
+ //G4String hcnames[2];
+ std::vector<G4String> hcnames;
+ hcnames.push_back("Ceren_"+sdt->get_hitsCollectionName());
+ hcnames.push_back("Edep_"+sdt->get_hitsCollectionName());
+ //std::cout<< " now creating optical calorimeter"<<std::endl;
sd = new G4OpticalCalorimeterSD(sdt->get_name(),
hcnames,
- NrofReadouts,
seg,
hitCompare);
}
CVSspam 0.2.8