CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
HFChamberSD Class Reference

#include <HFChamberSD.h>

Inheritance diagram for HFChamberSD:
SensitiveCaloDetector SensitiveDetector

Public Member Functions

void clear () override
 
void clearHits () override
 
void DrawAll () override
 
void EndOfEvent (G4HCofThisEvent *HCE) override
 
void fillHits (edm::PCaloHitContainer &, const std::string &) override
 
 HFChamberSD (const std::string &, const SensitiveDetectorCatalog &, const SimTrackManager *)
 
void Initialize (G4HCofThisEvent *HCE) override
 
void PrintAll () override
 
G4bool ProcessHits (G4Step *aStep, G4TouchableHistory *ROhist) override
 
uint32_t setDetUnitId (const G4Step *) override
 
 ~HFChamberSD () override
 
- Public Member Functions inherited from SensitiveCaloDetector
virtual void reset ()
 
 SensitiveCaloDetector (const std::string &iname, const SensitiveDetectorCatalog &clg, const std::string &newcollname="")
 
- 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, const std::string &newcollname="")
 
 ~SensitiveDetector () override
 

Private Attributes

HFShowerG4HitsCollectiontheHC
 
G4int theHCID
 
int theNSteps
 

Additional Inherited Members

- Protected Types inherited from SensitiveDetector
enum  coordinates { WorldCoordinates, LocalCoordinates }
 
- 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 > &)
 

Detailed Description

Definition at line 21 of file HFChamberSD.h.

Constructor & Destructor Documentation

◆ HFChamberSD()

HFChamberSD::HFChamberSD ( const std::string &  name,
const SensitiveDetectorCatalog clg,
const SimTrackManager manager 
)
explicit

Definition at line 21 of file HFChamberSD.cc.

References Skims_PA_cff::name.

22  : SensitiveCaloDetector(name, clg), theHCID(-1), theHC(nullptr), theNSteps(0) {
23  edm::LogVerbatim("FiberSim") << "HFChamberSD : Instantiated for " << name;
24 }
Log< level::Info, true > LogVerbatim
SensitiveCaloDetector(const std::string &iname, const SensitiveDetectorCatalog &clg, const std::string &newcollname="")
HFShowerG4HitsCollection * theHC
Definition: HFChamberSD.h:39
G4int theHCID
Definition: HFChamberSD.h:38

◆ ~HFChamberSD()

HFChamberSD::~HFChamberSD ( )
override

Definition at line 26 of file HFChamberSD.cc.

References theHC.

26 { delete theHC; }
HFShowerG4HitsCollection * theHC
Definition: HFChamberSD.h:39

Member Function Documentation

◆ clear()

void HFChamberSD::clear ( void  )
override

Definition at line 80 of file HFChamberSD.cc.

References theNSteps.

Referenced by EndOfEvent().

80 { theNSteps = 0; }

◆ clearHits()

void HFChamberSD::clearHits ( )
overridevirtual

Implements SensitiveDetector.

Definition at line 86 of file HFChamberSD.cc.

86 {}

◆ DrawAll()

void HFChamberSD::DrawAll ( )
override

Definition at line 82 of file HFChamberSD.cc.

82 {}

◆ EndOfEvent()

void HFChamberSD::EndOfEvent ( G4HCofThisEvent *  HCE)
override

Definition at line 75 of file HFChamberSD.cc.

References clear(), and theHC.

75  {
76  edm::LogVerbatim("FiberSim") << "HFChamberSD: Finds " << theHC->entries() << " hits";
77  clear();
78 }
Log< level::Info, true > LogVerbatim
void clear() override
Definition: HFChamberSD.cc:80
HFShowerG4HitsCollection * theHC
Definition: HFChamberSD.h:39

◆ fillHits()

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

Implements SensitiveCaloDetector.

Definition at line 93 of file HFChamberSD.cc.

93 {}

◆ Initialize()

void HFChamberSD::Initialize ( G4HCofThisEvent *  HCE)
override

Definition at line 28 of file HFChamberSD.cc.

References bysipixelclustmulteventfilter_cfi::collectionName, theHC, and theHCID.

28  {
29  edm::LogVerbatim("FiberSim") << "HFChamberSD : Initialize called for " << GetName() << " in collection " << HCE;
30  theHC = new HFShowerG4HitsCollection(GetName(), collectionName[0]);
31  if (theHCID < 0)
32  theHCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
33  HCE->AddHitsCollection(theHCID, theHC);
34  edm::LogVerbatim("FiberSim") << "HFChamberSD : Add hit collectrion for " << collectionName[0] << ":" << theHCID << ":"
35  << theHC;
36 }
Log< level::Info, true > LogVerbatim
HFShowerG4HitsCollection * theHC
Definition: HFChamberSD.h:39
G4int theHCID
Definition: HFChamberSD.h:38
G4THitsCollection< HFShowerG4Hit > HFShowerG4HitsCollection
Definition: HFShowerG4Hit.h:55

◆ PrintAll()

void HFChamberSD::PrintAll ( )
override

Definition at line 84 of file HFChamberSD.cc.

84 {}

◆ ProcessHits()

G4bool HFChamberSD::ProcessHits ( G4Step *  aStep,
G4TouchableHistory *  ROhist 
)
overridevirtual

Implements SensitiveDetector.

Definition at line 38 of file HFChamberSD.cc.

References ALCARECOTkAlJpsiMuMu_cff::charge, setDetUnitId(), HFShowerG4Hit::setGlobalPos(), HFShowerG4Hit::setLocalPos(), HFShowerG4Hit::setPrimMomDir(), theHC, theNSteps, and hcalRecHitTable_cff::time.

38  {
39  //do not process hits other than primary particle hits:
40  double charge = aStep->GetTrack()->GetDefinition()->GetPDGCharge();
41  int trackID = aStep->GetTrack()->GetTrackID();
42  if (charge == 0. || trackID != 1 || aStep->GetTrack()->GetParentID() != 0 ||
43  aStep->GetTrack()->GetCreatorProcess() != nullptr)
44  return false;
45  ++theNSteps;
46  //if(theNSteps>1)return false;
47 
48  G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
49  const G4VTouchable* touch = preStepPoint->GetTouchable();
50  int detID = setDetUnitId(aStep);
51 
52  double edep = aStep->GetTotalEnergyDeposit();
53  double time = (preStepPoint->GetGlobalTime()) / ns;
54 
55  const G4ThreeVector& globalPos = preStepPoint->GetPosition();
56  G4ThreeVector localPos = touch->GetHistory()->GetTopTransform().TransformPoint(globalPos);
57  const G4DynamicParticle* particle = aStep->GetTrack()->GetDynamicParticle();
58  const G4ThreeVector& momDir = particle->GetMomentumDirection();
59 
60  HFShowerG4Hit* aHit = new HFShowerG4Hit(detID, trackID, edep, time);
61  aHit->setLocalPos(localPos);
62  aHit->setGlobalPos(globalPos);
63  aHit->setPrimMomDir(momDir);
64 
65 #ifdef EDM_ML_DEBUG
66  edm::LogVerbatim("FiberSim") << "HFChamberSD: Hit created in (" << touch->GetVolume(0)->GetLogicalVolume()->GetName()
67  << ") ID " << detID << " Track " << trackID << " Edep: " << edep / CLHEP::MeV
68  << " MeV; Time: " << time << " ns; Position (local) " << localPos << " (global ) "
69  << globalPos << " direction " << momDir;
70 #endif
71  theHC->insert(aHit);
72  return true;
73 }
Log< level::Info, true > LogVerbatim
void setLocalPos(const G4ThreeVector &xyz)
Definition: HFShowerG4Hit.h:42
uint32_t setDetUnitId(const G4Step *) override
Definition: HFChamberSD.cc:88
HFShowerG4HitsCollection * theHC
Definition: HFChamberSD.h:39
void setPrimMomDir(const G4ThreeVector &xyz)
Definition: HFShowerG4Hit.h:44
void setGlobalPos(const G4ThreeVector &xyz)
Definition: HFShowerG4Hit.h:43

◆ setDetUnitId()

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

Implements SensitiveDetector.

Definition at line 88 of file HFChamberSD.cc.

Referenced by ProcessHits().

88  {
89  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
90  return (touch->GetReplicaNumber(0));
91 }

Member Data Documentation

◆ theHC

HFShowerG4HitsCollection* HFChamberSD::theHC
private

Definition at line 39 of file HFChamberSD.h.

Referenced by EndOfEvent(), Initialize(), ProcessHits(), and ~HFChamberSD().

◆ theHCID

G4int HFChamberSD::theHCID
private

Definition at line 38 of file HFChamberSD.h.

Referenced by Initialize().

◆ theNSteps

int HFChamberSD::theNSteps
private

Definition at line 40 of file HFChamberSD.h.

Referenced by clear(), and ProcessHits().