CMS 3D CMS Logo

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

#include <HFChamberSD.h>

Inheritance diagram for HFChamberSD:
SensitiveCaloDetector SensitiveDetector

Public Member Functions

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

Protected Member Functions

void clearHits () override
 
void fillHits (edm::PCaloHitContainer &, std::string) override
 
uint32_t setDetUnitId (G4Step *) override
 

Private Attributes

const SimTrackManagerm_trackManager
 
HFShowerG4HitsCollectiontheHC
 
G4int theHCID
 
std::string theName
 
int theNSteps
 

Additional Inherited Members

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

Detailed Description

Definition at line 19 of file HFChamberSD.h.

Constructor & Destructor Documentation

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

Definition at line 19 of file HFChamberSD.cc.

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

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

Definition at line 47 of file HFChamberSD.cc.

References theHC.

47  {
48  if (theHC) delete theHC;
49 }
HFShowerG4HitsCollection * theHC
Definition: HFChamberSD.h:46

Member Function Documentation

void HFChamberSD::clear ( void  )
override

Definition at line 104 of file HFChamberSD.cc.

References theNSteps.

Referenced by EndOfEvent().

104  {
105  theNSteps = 0;
106 }
void HFChamberSD::clearHits ( )
overrideprotectedvirtual

Implements SensitiveDetector.

Definition at line 112 of file HFChamberSD.cc.

112 {}
void HFChamberSD::DrawAll ( )
override

Definition at line 108 of file HFChamberSD.cc.

108 {}
void HFChamberSD::EndOfEvent ( G4HCofThisEvent *  HCE)
override

Definition at line 98 of file HFChamberSD.cc.

References clear(), LogDebug, and theHC.

98  {
99 
100  LogDebug("FiberSim") << "HFChamberSD: Sees" << theHC->entries() << " hits";
101  clear();
102 }
#define LogDebug(id)
void clear() override
Definition: HFChamberSD.cc:104
HFShowerG4HitsCollection * theHC
Definition: HFChamberSD.h:46
void HFChamberSD::fillHits ( edm::PCaloHitContainer ,
std::string   
)
overrideprotectedvirtual

Implements SensitiveCaloDetector.

Definition at line 119 of file HFChamberSD.cc.

119 {}
void HFChamberSD::Initialize ( G4HCofThisEvent *  HCE)
override

Definition at line 51 of file HFChamberSD.cc.

References ecaldqm::collectionName, LogDebug, theHC, and theHCID.

51  {
52 
53  LogDebug("FiberSim") << "HFChamberSD : Initialize called for " << GetName();
54  theHC = new HFShowerG4HitsCollection(GetName(), collectionName[0]);
55  if (theHCID<0)
56  theHCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
57  HCE->AddHitsCollection(theHCID, theHC);
58 
59 }
#define LogDebug(id)
HFShowerG4HitsCollection * theHC
Definition: HFChamberSD.h:46
std::string const collectionName[nCollections]
Definition: Collections.h:47
G4int theHCID
Definition: HFChamberSD.h:45
G4THitsCollection< HFShowerG4Hit > HFShowerG4HitsCollection
Definition: HFShowerG4Hit.h:59
void HFChamberSD::PrintAll ( )
override

Definition at line 110 of file HFChamberSD.cc.

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

Implements SensitiveDetector.

Definition at line 61 of file HFChamberSD.cc.

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

61  {
62 
63  //do not process hits other than primary particle hits:
64  double charge = aStep->GetTrack()->GetDefinition()->GetPDGCharge();
65  int trackID = aStep->GetTrack()->GetTrackID();
66  if(charge == 0. || trackID != 1 ||aStep->GetTrack()->GetParentID() != 0 || aStep->GetTrack()->GetCreatorProcess() != nullptr) return false;
67  ++theNSteps;
68  //if(theNSteps>1)return false;
69 
70  G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
71  const G4VTouchable* touch = preStepPoint->GetTouchable();
72  int detID = setDetUnitId(aStep);
73 
74  double edep = aStep->GetTotalEnergyDeposit();
75  double time = (preStepPoint->GetGlobalTime())/ns;
76 
77  const G4ThreeVector& globalPos = preStepPoint->GetPosition();
78  G4ThreeVector localPos = touch->GetHistory()->GetTopTransform().TransformPoint(globalPos);
79  const G4DynamicParticle* particle = aStep->GetTrack()->GetDynamicParticle();
80  const G4ThreeVector& momDir = particle->GetMomentumDirection();
81 
82  HFShowerG4Hit *aHit = new HFShowerG4Hit(detID, trackID, edep, time);
83  aHit->setLocalPos(localPos);
84  aHit->setGlobalPos(globalPos);
85  aHit->setPrimMomDir(momDir);
86 
87  LogDebug("FiberSim") << "HFChamberSD: Hit created in ("
88  << touch->GetVolume(0)->GetLogicalVolume()->GetName()
89  << ") " << " ID " << detID << " Track " << trackID
90  << " Edep: " << edep/MeV << " MeV; Time: " << time
91  << " ns; Position (local) " << localPos << " (global ) "
92  << globalPos << " direction " << momDir;
93 
94  theHC->insert(aHit);
95  return true;
96 }
#define LogDebug(id)
void setLocalPos(const G4ThreeVector &xyz)
Definition: HFShowerG4Hit.h:46
uint32_t setDetUnitId(G4Step *) override
Definition: HFChamberSD.cc:114
const double MeV
HFShowerG4HitsCollection * theHC
Definition: HFChamberSD.h:46
void setPrimMomDir(const G4ThreeVector &xyz)
Definition: HFShowerG4Hit.h:48
void setGlobalPos(const G4ThreeVector &xyz)
Definition: HFShowerG4Hit.h:47
uint32_t HFChamberSD::setDetUnitId ( G4Step *  aStep)
overrideprotectedvirtual

Implements SensitiveDetector.

Definition at line 114 of file HFChamberSD.cc.

Referenced by ProcessHits().

114  {
115  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
116  return (touch->GetReplicaNumber(0));
117 }

Member Data Documentation

const SimTrackManager* HFChamberSD::m_trackManager
private

Definition at line 43 of file HFChamberSD.h.

HFShowerG4HitsCollection* HFChamberSD::theHC
private

Definition at line 46 of file HFChamberSD.h.

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

G4int HFChamberSD::theHCID
private

Definition at line 45 of file HFChamberSD.h.

Referenced by Initialize().

std::string HFChamberSD::theName
private

Definition at line 42 of file HFChamberSD.h.

int HFChamberSD::theNSteps
private

Definition at line 47 of file HFChamberSD.h.

Referenced by clear(), and ProcessHits().