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 edm::EventSetup &cpv, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p, 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 edm::EventSetup &es, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p)
 
- 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 edm::EventSetup &es, const SensitiveDetectorCatalog &, edm::ParameterSet const &p, 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
 
const SimTrackManagerm_trackManager
 
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 18 of file HFWedgeSD.h.

Constructor & Destructor Documentation

HFWedgeSD::HFWedgeSD ( const std::string &  iname,
const edm::EventSetup cpv,
const SensitiveDetectorCatalog clg,
edm::ParameterSet const &  p,
const SimTrackManager manager 
)
explicit

Definition at line 19 of file HFWedgeSD.cc.

24  : SensitiveCaloDetector(iname, es, clg, p),
25  m_trackManager(manager),
26  hcID(-1),
27  theHC(nullptr),
28  currentHit(nullptr) {}
int hcID
Definition: HFWedgeSD.h:46
SensitiveCaloDetector(const std::string &iname, const edm::EventSetup &es, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p)
const SimTrackManager * m_trackManager
Definition: HFWedgeSD.h:44
HFShowerG4HitsCollection * theHC
Definition: HFWedgeSD.h:47
HFShowerG4Hit * currentHit
Definition: HFWedgeSD.h:53
HFWedgeSD::~HFWedgeSD ( )
override

Definition at line 30 of file HFWedgeSD.cc.

References theHC.

30 { delete theHC; }
HFShowerG4HitsCollection * theHC
Definition: HFWedgeSD.h:47

Member Function Documentation

void HFWedgeSD::clear ( void  )
override

Definition at line 66 of file HFWedgeSD.cc.

Referenced by EndOfEvent().

66 {}
void HFWedgeSD::clearHits ( )
overridevirtual

Implements SensitiveDetector.

Definition at line 115 of file HFWedgeSD.cc.

References hitMap, and previousID.

Referenced by Initialize().

115  {
116  hitMap.erase(hitMap.begin(), hitMap.end());
117  previousID = -1;
118 }
int previousID
Definition: HFWedgeSD.h:50
std::map< int, HFShowerG4Hit * > hitMap
Definition: HFWedgeSD.h:48
HFShowerG4Hit * HFWedgeSD::createNewHit ( )
protected

Definition at line 88 of file HFWedgeSD.cc.

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

Referenced by ProcessHits().

88  {
89  LogDebug("FiberSim") << "HFWedgeSD::CreateNewHit for ID " << currentID << " Track " << trackID
90  << " Edep: " << edep / MeV << " MeV; Time: " << time << " ns; Position (local) " << localPos
91  << " (global ) " << globalPos << " direction " << momDir;
92  HFShowerG4Hit* aHit = new HFShowerG4Hit;
93  aHit->setHitId(currentID);
94  aHit->setTrackId(trackID);
95  aHit->setTime(time);
96  aHit->setLocalPos(localPos);
97  aHit->setGlobalPos(globalPos);
98  aHit->setPrimMomDir(momDir);
99  updateHit(aHit);
100 
101  theHC->insert(aHit);
102  hitMap.insert(std::pair<int, HFShowerG4Hit*>(previousID, aHit));
103 
104  return aHit;
105 }
#define LogDebug(id)
int previousID
Definition: HFWedgeSD.h:50
void updateHit(HFShowerG4Hit *)
Definition: HFWedgeSD.cc:107
G4ThreeVector momDir
Definition: HFWedgeSD.h:52
void setLocalPos(const G4ThreeVector &xyz)
Definition: HFShowerG4Hit.h:42
const double MeV
std::map< int, HFShowerG4Hit * > hitMap
Definition: HFWedgeSD.h:48
double edep
Definition: HFWedgeSD.h:51
void setTrackId(G4int trackId)
Definition: HFShowerG4Hit.h:38
int trackID
Definition: HFWedgeSD.h:50
G4ThreeVector localPos
Definition: HFWedgeSD.h:52
void setHitId(G4int hitId)
Definition: HFShowerG4Hit.h:37
void setTime(G4double t)
Definition: HFShowerG4Hit.h:41
HFShowerG4HitsCollection * theHC
Definition: HFWedgeSD.h:47
void setPrimMomDir(const G4ThreeVector &xyz)
Definition: HFShowerG4Hit.h:44
void setGlobalPos(const G4ThreeVector &xyz)
Definition: HFShowerG4Hit.h:43
double time
Definition: HFWedgeSD.h:51
int currentID
Definition: HFWedgeSD.h:50
G4ThreeVector globalPos
Definition: HFWedgeSD.h:52
void HFWedgeSD::DrawAll ( )
override

Definition at line 68 of file HFWedgeSD.cc.

68 {}
void HFWedgeSD::EndOfEvent ( G4HCofThisEvent *  eventHC)
override

Definition at line 61 of file HFWedgeSD.cc.

References clear(), LogDebug, and theHC.

61  {
62  LogDebug("FiberSim") << "HFWedgeSD: Sees" << theHC->entries() << " hits";
63  clear();
64 }
#define LogDebug(id)
HFShowerG4HitsCollection * theHC
Definition: HFWedgeSD.h:47
void clear() override
Definition: HFWedgeSD.cc:66
void HFWedgeSD::fillHits ( edm::PCaloHitContainer ,
const std::string &   
)
overridevirtual

Implements SensitiveCaloDetector.

Definition at line 125 of file HFWedgeSD.cc.

125 {}
G4bool HFWedgeSD::hitExists ( )
protected

Definition at line 72 of file HFWedgeSD.cc.

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

Referenced by ProcessHits().

72  {
73  // Update if in the same detector, time-slice and for same track
74  if (currentID == previousID) {
76  return true;
77  }
78 
79  std::map<int, HFShowerG4Hit*>::const_iterator it = hitMap.find(currentID);
80  if (it != hitMap.end()) {
82  return true;
83  }
84 
85  return false;
86 }
int previousID
Definition: HFWedgeSD.h:50
void updateHit(HFShowerG4Hit *)
Definition: HFWedgeSD.cc:107
std::map< int, HFShowerG4Hit * > hitMap
Definition: HFWedgeSD.h:48
HFShowerG4Hit * currentHit
Definition: HFWedgeSD.h:53
int currentID
Definition: HFWedgeSD.h:50
void HFWedgeSD::Initialize ( G4HCofThisEvent *  HCE)
override

Definition at line 32 of file HFWedgeSD.cc.

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

32  {
33  LogDebug("FiberSim") << "HFWedgeSD : Initialize called for " << GetName();
34  theHC = new HFShowerG4HitsCollection(GetName(), collectionName[0]);
35  if (hcID < 0)
36  hcID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
37  HCE->AddHitsCollection(hcID, theHC);
38 
39  clearHits();
40 }
#define LogDebug(id)
int hcID
Definition: HFWedgeSD.h:46
void clearHits() override
Definition: HFWedgeSD.cc:115
HFShowerG4HitsCollection * theHC
Definition: HFWedgeSD.h:47
G4THitsCollection< HFShowerG4Hit > HFShowerG4HitsCollection
Definition: HFShowerG4Hit.h:55
void HFWedgeSD::PrintAll ( )
override

Definition at line 70 of file HFWedgeSD.cc.

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

Implements SensitiveDetector.

Definition at line 42 of file HFWedgeSD.cc.

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

42  {
43  G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
44  const G4VTouchable* touch = preStepPoint->GetTouchable();
45  currentID = setDetUnitId(aStep);
46  trackID = aStep->GetTrack()->GetTrackID();
47  edep = aStep->GetTotalEnergyDeposit();
48  time = (preStepPoint->GetGlobalTime()) / ns;
49 
50  globalPos = preStepPoint->GetPosition();
51  localPos = touch->GetHistory()->GetTopTransform().TransformPoint(globalPos);
52  const G4DynamicParticle* particle = aStep->GetTrack()->GetDynamicParticle();
53  momDir = particle->GetMomentumDirection();
54 
55  if (hitExists() == false && edep > 0.)
57 
58  return true;
59 }
G4ThreeVector momDir
Definition: HFWedgeSD.h:52
double edep
Definition: HFWedgeSD.h:51
int trackID
Definition: HFWedgeSD.h:50
G4bool hitExists()
Definition: HFWedgeSD.cc:72
G4ThreeVector localPos
Definition: HFWedgeSD.h:52
uint32_t setDetUnitId(const G4Step *) override
Definition: HFWedgeSD.cc:120
HFShowerG4Hit * currentHit
Definition: HFWedgeSD.h:53
double time
Definition: HFWedgeSD.h:51
HFShowerG4Hit * createNewHit()
Definition: HFWedgeSD.cc:88
int currentID
Definition: HFWedgeSD.h:50
G4ThreeVector globalPos
Definition: HFWedgeSD.h:52
uint32_t HFWedgeSD::setDetUnitId ( const G4Step *  aStep)
overridevirtual

Implements SensitiveDetector.

Definition at line 120 of file HFWedgeSD.cc.

Referenced by ProcessHits().

120  {
121  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
122  return (touch->GetReplicaNumber(0));
123 }
void HFWedgeSD::updateHit ( HFShowerG4Hit aHit)
protected

Definition at line 107 of file HFWedgeSD.cc.

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

Referenced by createNewHit(), and hitExists().

107  {
108  if (edep != 0) {
109  aHit->updateEnergy(edep);
110  LogDebug("FiberSim") << "HFWedgeSD: Add energy deposit in " << currentID << " edep " << edep / MeV << " MeV";
111  }
113 }
#define LogDebug(id)
int previousID
Definition: HFWedgeSD.h:50
const double MeV
double edep
Definition: HFWedgeSD.h:51
void updateEnergy(G4double edep)
Definition: HFShowerG4Hit.h:40
int currentID
Definition: HFWedgeSD.h:50

Member Data Documentation

HFShowerG4Hit* HFWedgeSD::currentHit
private

Definition at line 53 of file HFWedgeSD.h.

Referenced by hitExists(), and ProcessHits().

int HFWedgeSD::currentID
private

Definition at line 50 of file HFWedgeSD.h.

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

double HFWedgeSD::edep
private

Definition at line 51 of file HFWedgeSD.h.

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

G4ThreeVector HFWedgeSD::globalPos
private

Definition at line 52 of file HFWedgeSD.h.

Referenced by createNewHit(), and ProcessHits().

int HFWedgeSD::hcID
private

Definition at line 46 of file HFWedgeSD.h.

Referenced by Initialize().

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

Definition at line 48 of file HFWedgeSD.h.

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

G4ThreeVector HFWedgeSD::localPos
private

Definition at line 52 of file HFWedgeSD.h.

Referenced by createNewHit(), and ProcessHits().

const SimTrackManager* HFWedgeSD::m_trackManager
private

Definition at line 44 of file HFWedgeSD.h.

G4ThreeVector HFWedgeSD::momDir
private

Definition at line 52 of file HFWedgeSD.h.

Referenced by createNewHit(), and ProcessHits().

int HFWedgeSD::previousID
private

Definition at line 50 of file HFWedgeSD.h.

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

HFShowerG4HitsCollection* HFWedgeSD::theHC
private

Definition at line 47 of file HFWedgeSD.h.

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

double HFWedgeSD::time
private

Definition at line 51 of file HFWedgeSD.h.

Referenced by createNewHit(), and ProcessHits().

int HFWedgeSD::trackID
private

Definition at line 50 of file HFWedgeSD.h.

Referenced by createNewHit(), and ProcessHits().