CMS 3D CMS Logo

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

void clear () override
 
void clearHits () override
 
void DrawAll () override
 
void EndOfEvent (G4HCofThisEvent *eventHC) override
 
void fillHits (edm::PCaloHitContainer &, const std::string &) override
 
 HFWedgeSD (const std::string &, const SensitiveDetectorCatalog &clg, const SimTrackManager *)
 
void Initialize (G4HCofThisEvent *HCE) override
 
void PrintAll () override
 
bool ProcessHits (G4Step *step, G4TouchableHistory *tHistory) override
 
uint32_t setDetUnitId (const G4Step *) override
 
 ~HFWedgeSD () override
 
- Public Member Functions inherited from SensitiveCaloDetector
virtual void reset ()
 
 SensitiveCaloDetector (const std::string &iname, const SensitiveDetectorCatalog &clg)
 
- Public Member Functions inherited from SensitiveDetector
void EndOfEvent (G4HCofThisEvent *eventHC) override
 
const std::vector< std::string > & getNames () const
 
void Initialize (G4HCofThisEvent *eventHC) override
 
bool isCaloSD () const
 
 SensitiveDetector (const std::string &iname, const SensitiveDetectorCatalog &, bool calo)
 
 ~SensitiveDetector () override
 

Protected Member Functions

HFShowerG4HitcreateNewHit ()
 
G4bool hitExists ()
 
void updateHit (HFShowerG4Hit *)
 
- Protected Member Functions inherited from SensitiveDetector
TrackInformationcmsTrackInformation (const G4Track *aTrack)
 
Local3DPoint ConvertToLocal3DPoint (const G4ThreeVector &point) const
 
Local3DPoint FinalStepPosition (const G4Step *step, coordinates) const
 
Local3DPoint InitialStepPosition (const G4Step *step, coordinates) const
 
Local3DPoint LocalPostStepPosition (const G4Step *step) const
 
Local3DPoint LocalPreStepPosition (const G4Step *step) const
 
void NaNTrap (const G4Step *step) const
 
void setNames (const std::vector< std::string > &)
 

Private Attributes

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

Additional Inherited Members

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

Detailed Description

Definition at line 20 of file HFWedgeSD.h.

Constructor & Destructor Documentation

◆ HFWedgeSD()

HFWedgeSD::HFWedgeSD ( const std::string &  iname,
const SensitiveDetectorCatalog clg,
const SimTrackManager manager 
)
explicit

Definition at line 21 of file HFWedgeSD.cc.

24  : SensitiveCaloDetector(iname, clg), hcID(-1), theHC(nullptr), currentHit(nullptr) {
25  edm::LogVerbatim("FiberSim") << "HFWedgeSD : Instantiated for " << iname;
26 }

◆ ~HFWedgeSD()

HFWedgeSD::~HFWedgeSD ( )
override

Definition at line 28 of file HFWedgeSD.cc.

28 { delete theHC; }

References theHC.

Member Function Documentation

◆ clear()

void HFWedgeSD::clear ( void  )
override

Definition at line 65 of file HFWedgeSD.cc.

65 {}

Referenced by EndOfEvent().

◆ clearHits()

void HFWedgeSD::clearHits ( )
overridevirtual

Implements SensitiveDetector.

Definition at line 118 of file HFWedgeSD.cc.

118  {
119  hitMap.erase(hitMap.begin(), hitMap.end());
120  previousID = -1;
121 }

References hitMap, and previousID.

Referenced by Initialize().

◆ createNewHit()

HFShowerG4Hit * HFWedgeSD::createNewHit ( )
protected

Definition at line 87 of file HFWedgeSD.cc.

87  {
88 #ifdef EDM_ML_DEBUG
89  edm::LogVerbatim("FiberSim") << "HFWedgeSD::CreateNewHit for ID " << currentID << " Track " << trackID
90  << " Edep: " << edep / CLHEP::MeV << " MeV; Time: " << time << " ns; Position (local) "
91  << localPos << " (global ) " << globalPos << " direction " << momDir;
92 #endif
93  HFShowerG4Hit* aHit = new HFShowerG4Hit;
94  aHit->setHitId(currentID);
95  aHit->setTrackId(trackID);
96  aHit->setTime(time);
97  aHit->setLocalPos(localPos);
98  aHit->setGlobalPos(globalPos);
99  aHit->setPrimMomDir(momDir);
100  updateHit(aHit);
101 
102  theHC->insert(aHit);
103  hitMap.insert(std::pair<int, HFShowerG4Hit*>(previousID, aHit));
104 
105  return aHit;
106 }

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

Referenced by ProcessHits().

◆ DrawAll()

void HFWedgeSD::DrawAll ( )
override

Definition at line 67 of file HFWedgeSD.cc.

67 {}

◆ EndOfEvent()

void HFWedgeSD::EndOfEvent ( G4HCofThisEvent *  eventHC)
override

Definition at line 60 of file HFWedgeSD.cc.

60  {
61  edm::LogVerbatim("FiberSim") << "HFWedgeSD: Sees" << theHC->entries() << " hits";
62  clear();
63 }

References clear(), and theHC.

◆ fillHits()

void HFWedgeSD::fillHits ( edm::PCaloHitContainer ,
const std::string &   
)
overridevirtual

Implements SensitiveCaloDetector.

Definition at line 128 of file HFWedgeSD.cc.

128 {}

◆ hitExists()

G4bool HFWedgeSD::hitExists ( )
protected

Definition at line 71 of file HFWedgeSD.cc.

71  {
72  // Update if in the same detector, time-slice and for same track
73  if (currentID == previousID) {
75  return true;
76  }
77 
78  std::map<int, HFShowerG4Hit*>::const_iterator it = hitMap.find(currentID);
79  if (it != hitMap.end()) {
81  return true;
82  }
83 
84  return false;
85 }

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

Referenced by ProcessHits().

◆ Initialize()

void HFWedgeSD::Initialize ( G4HCofThisEvent *  HCE)
override

Definition at line 30 of file HFWedgeSD.cc.

30  {
31  edm::LogVerbatim("FiberSim") << "HFWedgeSD : Initialize called for " << GetName() << " in collection " << HCE;
32  theHC = new HFShowerG4HitsCollection(GetName(), collectionName[0]);
33  if (hcID < 0)
34  hcID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
35  HCE->AddHitsCollection(hcID, theHC);
36  edm::LogVerbatim("FiberSim") << "HFWedgeSD : Add hit collectrion for " << collectionName[0] << ":" << hcID << ":" << theHC;
37 
38  clearHits();
39 }

References clearHits(), bysipixelclustmulteventfilter_cfi::collectionName, hcID, and theHC.

◆ PrintAll()

void HFWedgeSD::PrintAll ( )
override

Definition at line 69 of file HFWedgeSD.cc.

69 {}

◆ ProcessHits()

G4bool HFWedgeSD::ProcessHits ( G4Step *  step,
G4TouchableHistory *  tHistory 
)
overridevirtual

Implements SensitiveDetector.

Definition at line 41 of file HFWedgeSD.cc.

41  {
42  G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
43  const G4VTouchable* touch = preStepPoint->GetTouchable();
44  currentID = setDetUnitId(aStep);
45  trackID = aStep->GetTrack()->GetTrackID();
46  edep = aStep->GetTotalEnergyDeposit();
47  time = (preStepPoint->GetGlobalTime()) / ns;
48 
49  globalPos = preStepPoint->GetPosition();
50  localPos = touch->GetHistory()->GetTopTransform().TransformPoint(globalPos);
51  const G4DynamicParticle* particle = aStep->GetTrack()->GetDynamicParticle();
52  momDir = particle->GetMomentumDirection();
53 
54  if (hitExists() == false && edep > 0.)
56 
57  return true;
58 }

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

◆ setDetUnitId()

uint32_t HFWedgeSD::setDetUnitId ( const G4Step *  aStep)
overridevirtual

Implements SensitiveDetector.

Definition at line 123 of file HFWedgeSD.cc.

123  {
124  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
125  return (touch->GetReplicaNumber(0));
126 }

Referenced by ProcessHits().

◆ updateHit()

void HFWedgeSD::updateHit ( HFShowerG4Hit aHit)
protected

Definition at line 108 of file HFWedgeSD.cc.

108  {
109  if (edep != 0) {
110  aHit->updateEnergy(edep);
111 #ifdef EDM_ML_DEBUG
112  edm::LogVerbatim("FiberSim") << "HFWedgeSD: Add energy deposit in " << currentID << " edep " << edep / CLHEP::MeV << " MeV";
113 #endif
114  }
116 }

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

Referenced by createNewHit(), and hitExists().

Member Data Documentation

◆ currentHit

HFShowerG4Hit* HFWedgeSD::currentHit
private

Definition at line 51 of file HFWedgeSD.h.

Referenced by hitExists(), and ProcessHits().

◆ currentID

int HFWedgeSD::currentID
private

Definition at line 48 of file HFWedgeSD.h.

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

◆ edep

double HFWedgeSD::edep
private

Definition at line 49 of file HFWedgeSD.h.

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

◆ globalPos

G4ThreeVector HFWedgeSD::globalPos
private

Definition at line 50 of file HFWedgeSD.h.

Referenced by createNewHit(), and ProcessHits().

◆ hcID

int HFWedgeSD::hcID
private

Definition at line 44 of file HFWedgeSD.h.

Referenced by Initialize().

◆ hitMap

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

Definition at line 46 of file HFWedgeSD.h.

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

◆ localPos

G4ThreeVector HFWedgeSD::localPos
private

Definition at line 50 of file HFWedgeSD.h.

Referenced by createNewHit(), and ProcessHits().

◆ momDir

G4ThreeVector HFWedgeSD::momDir
private

Definition at line 50 of file HFWedgeSD.h.

Referenced by createNewHit(), and ProcessHits().

◆ previousID

int HFWedgeSD::previousID
private

Definition at line 48 of file HFWedgeSD.h.

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

◆ theHC

HFShowerG4HitsCollection* HFWedgeSD::theHC
private

Definition at line 45 of file HFWedgeSD.h.

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

◆ time

double HFWedgeSD::time
private

Definition at line 49 of file HFWedgeSD.h.

Referenced by createNewHit(), and ProcessHits().

◆ trackID

int HFWedgeSD::trackID
private

Definition at line 48 of file HFWedgeSD.h.

Referenced by createNewHit(), and ProcessHits().

HFWedgeSD::hitMap
std::map< int, HFShowerG4Hit * > hitMap
Definition: HFWedgeSD.h:46
HFShowerG4Hit::setPrimMomDir
void setPrimMomDir(const G4ThreeVector &xyz)
Definition: HFShowerG4Hit.h:44
HFWedgeSD::edep
double edep
Definition: HFWedgeSD.h:49
HFWedgeSD::createNewHit
HFShowerG4Hit * createNewHit()
Definition: HFWedgeSD.cc:87
HFShowerG4HitsCollection
G4THitsCollection< HFShowerG4Hit > HFShowerG4HitsCollection
Definition: HFShowerG4Hit.h:55
HFWedgeSD::hcID
int hcID
Definition: HFWedgeSD.h:44
HFShowerG4Hit::setLocalPos
void setLocalPos(const G4ThreeVector &xyz)
Definition: HFShowerG4Hit.h:42
HFWedgeSD::hitExists
G4bool hitExists()
Definition: HFWedgeSD.cc:71
MeV
const double MeV
HFShowerG4Hit
Definition: HFShowerG4Hit.h:15
HFWedgeSD::setDetUnitId
uint32_t setDetUnitId(const G4Step *) override
Definition: HFWedgeSD.cc:123
HFWedgeSD::momDir
G4ThreeVector momDir
Definition: HFWedgeSD.h:50
bysipixelclustmulteventfilter_cfi.collectionName
collectionName
Definition: bysipixelclustmulteventfilter_cfi.py:5
HFWedgeSD::time
double time
Definition: HFWedgeSD.h:49
HFWedgeSD::currentHit
HFShowerG4Hit * currentHit
Definition: HFWedgeSD.h:51
HFWedgeSD::updateHit
void updateHit(HFShowerG4Hit *)
Definition: HFWedgeSD.cc:108
HFShowerG4Hit::setGlobalPos
void setGlobalPos(const G4ThreeVector &xyz)
Definition: HFShowerG4Hit.h:43
HFShowerG4Hit::setTrackId
void setTrackId(G4int trackId)
Definition: HFShowerG4Hit.h:38
HFShowerG4Hit::setTime
void setTime(G4double t)
Definition: HFShowerG4Hit.h:41
HFWedgeSD::clear
void clear() override
Definition: HFWedgeSD.cc:65
HFWedgeSD::clearHits
void clearHits() override
Definition: HFWedgeSD.cc:118
HFWedgeSD::globalPos
G4ThreeVector globalPos
Definition: HFWedgeSD.h:50
SensitiveCaloDetector::SensitiveCaloDetector
SensitiveCaloDetector(const std::string &iname, const SensitiveDetectorCatalog &clg)
Definition: SensitiveCaloDetector.h:12
HFWedgeSD::localPos
G4ThreeVector localPos
Definition: HFWedgeSD.h:50
HFShowerG4Hit::setHitId
void setHitId(G4int hitId)
Definition: HFShowerG4Hit.h:37
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
HFWedgeSD::currentID
int currentID
Definition: HFWedgeSD.h:48
HFWedgeSD::trackID
int trackID
Definition: HFWedgeSD.h:48
HFWedgeSD::previousID
int previousID
Definition: HFWedgeSD.h:48
HFWedgeSD::theHC
HFShowerG4HitsCollection * theHC
Definition: HFWedgeSD.h:45
HFShowerG4Hit::updateEnergy
void updateEnergy(G4double edep)
Definition: HFShowerG4Hit.h:40