CMS 3D CMS Logo

HFChamberSD.cc
Go to the documentation of this file.
3 
4 #include "G4VPhysicalVolume.hh"
5 #include "G4PVPlacement.hh"
6 #include "G4HCofThisEvent.hh"
7 #include "G4TouchableHistory.hh"
8 #include "G4Track.hh"
9 #include "G4Step.hh"
10 #include "G4VSolid.hh"
11 #include "G4DynamicParticle.hh"
12 #include "G4ParticleDefinition.hh"
13 #include "G4SDManager.hh"
14 #include "G4ios.hh"
15 
16 #include "G4PhysicalConstants.hh"
17 #include "G4SystemOfUnits.hh"
18 
20  const edm::EventSetup& es,
21  const SensitiveDetectorCatalog& clg,
22  edm::ParameterSet const& p,
23  const SimTrackManager* manager)
24  : SensitiveCaloDetector(name, es, clg, p), m_trackManager(manager), theHCID(-1), theHC(nullptr), theNSteps(0) {}
25 
27 
28 void HFChamberSD::Initialize(G4HCofThisEvent* HCE) {
29  LogDebug("FiberSim") << "HFChamberSD : Initialize called for " << GetName();
30  theHC = new HFShowerG4HitsCollection(GetName(), collectionName[0]);
31  if (theHCID < 0)
32  theHCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
33  HCE->AddHitsCollection(theHCID, theHC);
34 }
35 
36 G4bool HFChamberSD::ProcessHits(G4Step* aStep, G4TouchableHistory*) {
37  //do not process hits other than primary particle hits:
38  double charge = aStep->GetTrack()->GetDefinition()->GetPDGCharge();
39  int trackID = aStep->GetTrack()->GetTrackID();
40  if (charge == 0. || trackID != 1 || aStep->GetTrack()->GetParentID() != 0 ||
41  aStep->GetTrack()->GetCreatorProcess() != nullptr)
42  return false;
43  ++theNSteps;
44  //if(theNSteps>1)return false;
45 
46  G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
47  const G4VTouchable* touch = preStepPoint->GetTouchable();
48  int detID = setDetUnitId(aStep);
49 
50  double edep = aStep->GetTotalEnergyDeposit();
51  double time = (preStepPoint->GetGlobalTime()) / ns;
52 
53  const G4ThreeVector& globalPos = preStepPoint->GetPosition();
54  G4ThreeVector localPos = touch->GetHistory()->GetTopTransform().TransformPoint(globalPos);
55  const G4DynamicParticle* particle = aStep->GetTrack()->GetDynamicParticle();
56  const G4ThreeVector& momDir = particle->GetMomentumDirection();
57 
58  HFShowerG4Hit* aHit = new HFShowerG4Hit(detID, trackID, edep, time);
59  aHit->setLocalPos(localPos);
60  aHit->setGlobalPos(globalPos);
61  aHit->setPrimMomDir(momDir);
62 
63  LogDebug("FiberSim") << "HFChamberSD: Hit created in (" << touch->GetVolume(0)->GetLogicalVolume()->GetName() << ") "
64  << " ID " << detID << " Track " << trackID << " Edep: " << edep / MeV << " MeV; Time: " << time
65  << " ns; Position (local) " << localPos << " (global ) " << globalPos << " direction " << momDir;
66 
67  theHC->insert(aHit);
68  return true;
69 }
70 
71 void HFChamberSD::EndOfEvent(G4HCofThisEvent* HCE) {
72  LogDebug("FiberSim") << "HFChamberSD: Sees" << theHC->entries() << " hits";
73  clear();
74 }
75 
77 
79 
81 
83 
84 uint32_t HFChamberSD::setDetUnitId(const G4Step* aStep) {
85  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
86  return (touch->GetReplicaNumber(0));
87 }
88 
HFChamberSD::clearHits
void clearHits() override
Definition: HFChamberSD.cc:82
HFShowerG4Hit::setPrimMomDir
void setPrimMomDir(const G4ThreeVector &xyz)
Definition: HFShowerG4Hit.h:44
SimTrackManager
Definition: SimTrackManager.h:35
HFShowerG4HitsCollection
G4THitsCollection< HFShowerG4Hit > HFShowerG4HitsCollection
Definition: HFShowerG4Hit.h:55
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
HFShowerG4Hit::setLocalPos
void setLocalPos(const G4ThreeVector &xyz)
Definition: HFShowerG4Hit.h:42
MeV
const double MeV
HFShowerG4Hit
Definition: HFShowerG4Hit.h:15
SensitiveCaloDetector
Definition: SensitiveCaloDetector.h:10
HFChamberSD::~HFChamberSD
~HFChamberSD() override
Definition: HFChamberSD.cc:26
HFChamberSD::Initialize
void Initialize(G4HCofThisEvent *HCE) override
Definition: HFChamberSD.cc:28
SensitiveDetectorCatalog
Definition: SensitiveDetectorCatalog.h:10
HFChamberSD::theHC
HFShowerG4HitsCollection * theHC
Definition: HFChamberSD.h:43
bysipixelclustmulteventfilter_cfi.collectionName
collectionName
Definition: bysipixelclustmulteventfilter_cfi.py:5
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
HFChamberSD::setDetUnitId
uint32_t setDetUnitId(const G4Step *) override
Definition: HFChamberSD.cc:84
HFChamberSD::fillHits
void fillHits(edm::PCaloHitContainer &, const std::string &) override
Definition: HFChamberSD.cc:89
HFChamberSD::theHCID
G4int theHCID
Definition: HFChamberSD.h:42
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
HFShowerG4Hit::setGlobalPos
void setGlobalPos(const G4ThreeVector &xyz)
Definition: HFShowerG4Hit.h:43
edm::ParameterSet
Definition: ParameterSet.h:47
HFChamberSD.h
edm::EventSetup
Definition: EventSetup.h:57
HFChamberSD::theNSteps
int theNSteps
Definition: HFChamberSD.h:44
HFChamberSD::DrawAll
void DrawAll() override
Definition: HFChamberSD.cc:78
HFChamberSD::PrintAll
void PrintAll() override
Definition: HFChamberSD.cc:80
Point3D.h
edm::PCaloHitContainer
std::vector< PCaloHit > PCaloHitContainer
Definition: PCaloHitContainer.h:8
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
HFChamberSD::ProcessHits
G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *ROhist) override
Definition: HFChamberSD.cc:36
HFChamberSD::EndOfEvent
void EndOfEvent(G4HCofThisEvent *HCE) override
Definition: HFChamberSD.cc:71
HFChamberSD::clear
void clear() override
Definition: HFChamberSD.cc:76
ntuplemaker.time
time
Definition: ntuplemaker.py:310
HFChamberSD::HFChamberSD
HFChamberSD(const std::string &, const edm::EventSetup &, const SensitiveDetectorCatalog &, const edm::ParameterSet &, const SimTrackManager *)
Definition: HFChamberSD.cc:19