CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Private Attributes
HFWedgeSD Class Reference

#include <HFWedgeSD.h>

Inheritance diagram for HFWedgeSD:
SensitiveCaloDetector SensitiveDetector

Public Member Functions

virtual void clear ()
 
virtual void DrawAll ()
 
virtual void EndOfEvent (G4HCofThisEvent *eventHC)
 
 HFWedgeSD (std::string name, const DDCompactView &cpv, SensitiveDetectorCatalog &clg, edm::ParameterSet const &p, const SimTrackManager *)
 
virtual void Initialize (G4HCofThisEvent *HCE)
 
virtual void PrintAll ()
 
virtual bool ProcessHits (G4Step *step, G4TouchableHistory *tHistory)
 
virtual ~HFWedgeSD ()
 
- Public Member Functions inherited from SensitiveCaloDetector
 SensitiveCaloDetector (std::string &iname, const DDCompactView &cpv, SensitiveDetectorCatalog &clg, edm::ParameterSet const &p)
 
- Public Member Functions inherited from SensitiveDetector
virtual void AssignSD (std::string &vname)
 
Local3DPoint ConvertToLocal3DPoint (G4ThreeVector point)
 
Local3DPoint FinalStepPosition (G4Step *s, coordinates)
 
virtual std::vector< std::string > getNames ()
 
Local3DPoint InitialStepPosition (G4Step *s, coordinates)
 
std::string nameOfSD ()
 
void NaNTrap (G4Step *step)
 
void Register ()
 
 SensitiveDetector (std::string &iname, const DDCompactView &cpv, SensitiveDetectorCatalog &, edm::ParameterSet const &p)
 
virtual ~SensitiveDetector ()
 

Protected Member Functions

virtual void clearHits ()
 
HFShowerG4HitcreateNewHit ()
 
virtual void fillHits (edm::PCaloHitContainer &, std::string)
 
G4bool hitExists ()
 
virtual uint32_t setDetUnitId (G4Step *)
 
void updateHit (HFShowerG4Hit *)
 

Private Attributes

HFShowerG4HitcurrentHit
 
int currentID
 
double edep
 
G4ThreeVector globalPos
 
int hcID
 
std::map< int, HFShowerG4Hit * > hitMap
 
G4ThreeVector localPos
 
const SimTrackManagerm_trackManager
 
G4ThreeVector momDir
 
int previousID
 
HFShowerG4HitsCollectiontheHC
 
std::string theName
 
double time
 
int trackID
 

Additional Inherited Members

- Public Types inherited from SensitiveDetector
enum  coordinates { WorldCoordinates, LocalCoordinates }
 

Detailed Description

Definition at line 22 of file HFWedgeSD.h.

Constructor & Destructor Documentation

HFWedgeSD::HFWedgeSD ( std::string  name,
const DDCompactView cpv,
SensitiveDetectorCatalog clg,
edm::ParameterSet const &  p,
const SimTrackManager manager 
)

Definition at line 16 of file HFWedgeSD.cc.

References SensitiveDetector::AssignSD(), ecaldqm::collectionName, LogDebug, SensitiveDetectorCatalog::logicalNames(), and SensitiveDetector::Register().

18  :
19  SensitiveCaloDetector(name, cpv, clg, p), theName(name),
20  m_trackManager(manager), hcID(-1), theHC(0), currentHit(0) {
21 
22  collectionName.insert(name);
23  LogDebug("FiberSim") << "***************************************************"
24  << "\n"
25  << "* *"
26  << "\n"
27  << "* Constructing a HFWedgeSD with name " << GetName()
28  << "\n"
29  << "* *"
30  << "\n"
31  << "***************************************************";
32  //
33  // Now attach the right detectors (LogicalVolumes) to me
34  //
35  std::vector<std::string> lvNames = clg.logicalNames(name);
36  this->Register();
37  for (std::vector<std::string>::iterator it=lvNames.begin();
38  it !=lvNames.end(); it++){
39  this->AssignSD(*it);
40  LogDebug("FiberSim") << "HFWedgeSD : Assigns SD to LV " << (*it);
41  }
42 }
#define LogDebug(id)
std::vector< std::string > logicalNames(std::string &readoutName)
int hcID
Definition: HFWedgeSD.h:54
std::string const collectionName[nCollections]
Definition: Collections.h:39
const SimTrackManager * m_trackManager
Definition: HFWedgeSD.h:52
HFShowerG4HitsCollection * theHC
Definition: HFWedgeSD.h:55
HFShowerG4Hit * currentHit
Definition: HFWedgeSD.h:61
virtual void AssignSD(std::string &vname)
SensitiveCaloDetector(std::string &iname, const DDCompactView &cpv, SensitiveDetectorCatalog &clg, edm::ParameterSet const &p)
std::string theName
Definition: HFWedgeSD.h:51
HFWedgeSD::~HFWedgeSD ( )
virtual

Definition at line 44 of file HFWedgeSD.cc.

References theHC.

44  {
45  if (theHC) delete theHC;
46 }
HFShowerG4HitsCollection * theHC
Definition: HFWedgeSD.h:55

Member Function Documentation

void HFWedgeSD::clear ( void  )
virtual

Definition at line 85 of file HFWedgeSD.cc.

Referenced by EndOfEvent().

85 {}
void HFWedgeSD::clearHits ( )
protectedvirtual

Implements SensitiveDetector.

Definition at line 140 of file HFWedgeSD.cc.

References hitMap, and previousID.

Referenced by Initialize().

140  {
141  hitMap.erase (hitMap.begin(), hitMap.end());
142  previousID = -1;
143 }
int previousID
Definition: HFWedgeSD.h:58
std::map< int, HFShowerG4Hit * > hitMap
Definition: HFWedgeSD.h:56
HFShowerG4Hit * HFWedgeSD::createNewHit ( )
protected

Definition at line 108 of file HFWedgeSD.cc.

References currentID, edep, globalPos, hitMap, localPos, LogDebug, momDir, previousID, HFShowerG4Hit::setGlobalPos(), HFShowerG4Hit::setHitId(), HFShowerG4Hit::setLocalPos(), HFShowerG4Hit::setPrimMomDir(), HFShowerG4Hit::setTime(), HFShowerG4Hit::setTrackId(), theHC, time, trackID, and updateHit().

Referenced by ProcessHits().

108  {
109 
110  LogDebug("FiberSim") << "HFWedgeSD::CreateNewHit for ID " << currentID
111  << " Track " << trackID << " Edep: " << edep/MeV
112  << " MeV; Time: " << time << " ns; Position (local) "
113  << localPos << " (global ) " << globalPos
114  << " direction " << momDir;
115  HFShowerG4Hit* aHit = new HFShowerG4Hit;
116  aHit->setHitId(currentID);
117  aHit->setTrackId(trackID);
118  aHit->setTime(time);
119  aHit->setLocalPos(localPos);
120  aHit->setGlobalPos(globalPos);
121  aHit->setPrimMomDir(momDir);
122  updateHit(aHit);
123 
124  theHC->insert(aHit);
125  hitMap.insert(std::pair<int,HFShowerG4Hit*>(previousID,aHit));
126 
127  return aHit;
128 }
#define LogDebug(id)
int previousID
Definition: HFWedgeSD.h:58
void updateHit(HFShowerG4Hit *)
Definition: HFWedgeSD.cc:130
G4ThreeVector momDir
Definition: HFWedgeSD.h:60
void setPrimMomDir(G4ThreeVector xyz)
Definition: HFShowerG4Hit.h:49
double edep
Definition: HFWedgeSD.h:59
void setTrackId(G4int trackId)
Definition: HFShowerG4Hit.h:43
int trackID
Definition: HFWedgeSD.h:58
G4ThreeVector localPos
Definition: HFWedgeSD.h:60
void setHitId(G4int hitId)
Definition: HFShowerG4Hit.h:42
void setTime(G4double t)
Definition: HFShowerG4Hit.h:46
HFShowerG4HitsCollection * theHC
Definition: HFWedgeSD.h:55
void setGlobalPos(G4ThreeVector xyz)
Definition: HFShowerG4Hit.h:48
double time
Definition: HFWedgeSD.h:59
void setLocalPos(G4ThreeVector xyz)
Definition: HFShowerG4Hit.h:47
int currentID
Definition: HFWedgeSD.h:58
std::map< int, HFShowerG4Hit * > hitMap
Definition: HFWedgeSD.h:56
G4ThreeVector globalPos
Definition: HFWedgeSD.h:60
void HFWedgeSD::DrawAll ( )
virtual

Definition at line 87 of file HFWedgeSD.cc.

87 {}
void HFWedgeSD::EndOfEvent ( G4HCofThisEvent *  eventHC)
virtual

Reimplemented from SensitiveDetector.

Definition at line 79 of file HFWedgeSD.cc.

References clear(), LogDebug, and theHC.

79  {
80 
81  LogDebug("FiberSim") << "HFWedgeSD: Sees" << theHC->entries() << " hits";
82  clear();
83 }
#define LogDebug(id)
virtual void clear()
Definition: HFWedgeSD.cc:85
HFShowerG4HitsCollection * theHC
Definition: HFWedgeSD.h:55
void HFWedgeSD::fillHits ( edm::PCaloHitContainer ,
std::string   
)
protectedvirtual

Implements SensitiveCaloDetector.

Definition at line 150 of file HFWedgeSD.cc.

150 {}
G4bool HFWedgeSD::hitExists ( )
protected

Definition at line 91 of file HFWedgeSD.cc.

References currentHit, currentID, hitMap, previousID, and updateHit().

Referenced by ProcessHits().

91  {
92 
93  // Update if in the same detector, time-slice and for same track
94  if (currentID == previousID) {
96  return true;
97  }
98 
99  std::map<int,HFShowerG4Hit*>::const_iterator it = hitMap.find(currentID);
100  if (it != hitMap.end()) {
102  return true;
103  }
104 
105  return false;
106 }
int previousID
Definition: HFWedgeSD.h:58
void updateHit(HFShowerG4Hit *)
Definition: HFWedgeSD.cc:130
HFShowerG4Hit * currentHit
Definition: HFWedgeSD.h:61
int currentID
Definition: HFWedgeSD.h:58
std::map< int, HFShowerG4Hit * > hitMap
Definition: HFWedgeSD.h:56
void HFWedgeSD::Initialize ( G4HCofThisEvent *  HCE)
virtual

Reimplemented from SensitiveDetector.

Definition at line 48 of file HFWedgeSD.cc.

References clearHits(), ecaldqm::collectionName, hcID, LogDebug, and theHC.

48  {
49 
50  LogDebug("FiberSim") << "HFWedgeSD : Initialize called for " << GetName();
51  theHC = new HFShowerG4HitsCollection(GetName(), collectionName[0]);
52  if (hcID<0)
53  hcID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
54  HCE->AddHitsCollection(hcID, theHC);
55 
56  clearHits();
57 }
#define LogDebug(id)
virtual void clearHits()
Definition: HFWedgeSD.cc:140
int hcID
Definition: HFWedgeSD.h:54
std::string const collectionName[nCollections]
Definition: Collections.h:39
HFShowerG4HitsCollection * theHC
Definition: HFWedgeSD.h:55
G4THitsCollection< HFShowerG4Hit > HFShowerG4HitsCollection
Definition: HFShowerG4Hit.h:60
void HFWedgeSD::PrintAll ( )
virtual

Definition at line 89 of file HFWedgeSD.cc.

89 {}
G4bool HFWedgeSD::ProcessHits ( G4Step *  step,
G4TouchableHistory *  tHistory 
)
virtual

Implements SensitiveDetector.

Definition at line 59 of file HFWedgeSD.cc.

References createNewHit(), currentHit, currentID, edep, globalPos, hitExists(), localPos, momDir, setDetUnitId(), time, and trackID.

59  {
60 
61  G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
62  const G4VTouchable* touch = preStepPoint->GetTouchable();
63  currentID = setDetUnitId(aStep);
64  trackID = aStep->GetTrack()->GetTrackID();
65  edep = aStep->GetTotalEnergyDeposit();
66  time = (preStepPoint->GetGlobalTime())/ns;
67 
68  globalPos = preStepPoint->GetPosition();
69  localPos = touch->GetHistory()->GetTopTransform().TransformPoint(globalPos);
70  const G4DynamicParticle* particle = aStep->GetTrack()->GetDynamicParticle();
71  momDir = particle->GetMomentumDirection();
72 
73  if (hitExists() == false && edep>0.)
75 
76  return true;
77 }
G4ThreeVector momDir
Definition: HFWedgeSD.h:60
virtual uint32_t setDetUnitId(G4Step *)
Definition: HFWedgeSD.cc:145
double edep
Definition: HFWedgeSD.h:59
int trackID
Definition: HFWedgeSD.h:58
G4bool hitExists()
Definition: HFWedgeSD.cc:91
G4ThreeVector localPos
Definition: HFWedgeSD.h:60
HFShowerG4Hit * currentHit
Definition: HFWedgeSD.h:61
double time
Definition: HFWedgeSD.h:59
HFShowerG4Hit * createNewHit()
Definition: HFWedgeSD.cc:108
int currentID
Definition: HFWedgeSD.h:58
G4ThreeVector globalPos
Definition: HFWedgeSD.h:60
uint32_t HFWedgeSD::setDetUnitId ( G4Step *  aStep)
protectedvirtual

Implements SensitiveDetector.

Definition at line 145 of file HFWedgeSD.cc.

Referenced by ProcessHits().

145  {
146  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
147  return (touch->GetReplicaNumber(0));
148 }
void HFWedgeSD::updateHit ( HFShowerG4Hit aHit)
protected

Definition at line 130 of file HFWedgeSD.cc.

References currentID, edep, LogDebug, previousID, and HFShowerG4Hit::updateEnergy().

Referenced by createNewHit(), and hitExists().

130  {
131 
132  if (edep != 0) {
133  aHit->updateEnergy(edep);
134  LogDebug("FiberSim") << "HFWedgeSD: Add energy deposit in " << currentID
135  << " edep " << edep/MeV << " MeV";
136  }
138 }
#define LogDebug(id)
int previousID
Definition: HFWedgeSD.h:58
double edep
Definition: HFWedgeSD.h:59
void updateEnergy(G4double edep)
Definition: HFShowerG4Hit.h:45
int currentID
Definition: HFWedgeSD.h:58

Member Data Documentation

HFShowerG4Hit* HFWedgeSD::currentHit
private

Definition at line 61 of file HFWedgeSD.h.

Referenced by hitExists(), and ProcessHits().

int HFWedgeSD::currentID
private

Definition at line 58 of file HFWedgeSD.h.

Referenced by createNewHit(), hitExists(), ProcessHits(), and updateHit().

double HFWedgeSD::edep
private

Definition at line 59 of file HFWedgeSD.h.

Referenced by createNewHit(), ProcessHits(), and updateHit().

G4ThreeVector HFWedgeSD::globalPos
private

Definition at line 60 of file HFWedgeSD.h.

Referenced by createNewHit(), and ProcessHits().

int HFWedgeSD::hcID
private

Definition at line 54 of file HFWedgeSD.h.

Referenced by Initialize().

std::map<int,HFShowerG4Hit*> HFWedgeSD::hitMap
private

Definition at line 56 of file HFWedgeSD.h.

Referenced by clearHits(), createNewHit(), and hitExists().

G4ThreeVector HFWedgeSD::localPos
private

Definition at line 60 of file HFWedgeSD.h.

Referenced by createNewHit(), and ProcessHits().

const SimTrackManager* HFWedgeSD::m_trackManager
private

Definition at line 52 of file HFWedgeSD.h.

G4ThreeVector HFWedgeSD::momDir
private

Definition at line 60 of file HFWedgeSD.h.

Referenced by createNewHit(), and ProcessHits().

int HFWedgeSD::previousID
private

Definition at line 58 of file HFWedgeSD.h.

Referenced by clearHits(), createNewHit(), hitExists(), and updateHit().

HFShowerG4HitsCollection* HFWedgeSD::theHC
private

Definition at line 55 of file HFWedgeSD.h.

Referenced by createNewHit(), EndOfEvent(), Initialize(), and ~HFWedgeSD().

std::string HFWedgeSD::theName
private

Definition at line 51 of file HFWedgeSD.h.

double HFWedgeSD::time
private

Definition at line 59 of file HFWedgeSD.h.

Referenced by createNewHit(), and ProcessHits().

int HFWedgeSD::trackID
private

Definition at line 58 of file HFWedgeSD.h.

Referenced by createNewHit(), and ProcessHits().