Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GFlash updated #30977

Merged
merged 2 commits into from Jul 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions SimG4CMS/Calo/interface/CaloSD.h
Expand Up @@ -69,6 +69,7 @@ class CaloSD : public SensitiveCaloDetector,

protected:
virtual double getEnergyDeposit(const G4Step* step);
virtual double EnergyCorrected(const G4Step& step, const G4Track*);
virtual bool getFromLibrary(const G4Step* step);

G4ThreeVector setToLocal(const G4ThreeVector&, const G4VTouchable*) const;
Expand Down
2 changes: 1 addition & 1 deletion SimG4CMS/Calo/interface/ECalSD.h
Expand Up @@ -16,7 +16,6 @@
#include "DataFormats/DetId/interface/DetId.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "G4String.hh"
#ifdef plotDebug
#include <TH2F.h>
#endif
Expand All @@ -42,6 +41,7 @@ class ECalSD : public CaloSD {
double getEnergyDeposit(const G4Step *) override;
int getTrackID(const G4Track *) override;
uint16_t getDepth(const G4Step *) override;
double EnergyCorrected(const G4Step &, const G4Track *) override;

private:
void initMap();
Expand Down
18 changes: 14 additions & 4 deletions SimG4CMS/Calo/src/CaloSD.cc
Expand Up @@ -185,14 +185,12 @@ G4bool CaloSD::ProcessHits(G4Step* aStep, G4TouchableHistory*) {
bool CaloSD::ProcessHits(G4GFlashSpot* aSpot, G4TouchableHistory*) {
edepositEM = edepositHAD = 0.f;
const G4Track* track = aSpot->GetOriginatorTrack()->GetPrimaryTrack();
if (!G4TrackToParticleID::isGammaElectronPositron(track)) {
return false;
}

double edep = aSpot->GetEnergySpot()->GetEnergy();
if (edep <= 0.0) {
return false;
}
edepositEM = edep;

G4Step fFakeStep;
G4StepPoint* fFakePreStepPoint = fFakeStep.GetPreStepPoint();
G4StepPoint* fFakePostStepPoint = fFakeStep.GetPostStepPoint();
Expand All @@ -202,6 +200,16 @@ bool CaloSD::ProcessHits(G4GFlashSpot* aSpot, G4TouchableHistory*) {
G4TouchableHandle fTouchableHandle = aSpot->GetTouchableHandle();
fFakePreStepPoint->SetTouchableHandle(fTouchableHandle);
fFakeStep.SetTotalEnergyDeposit(edep);
edep = EnergyCorrected(fFakeStep, track);
if (edep <= 0.0) {
return false;
}

if (G4TrackToParticleID::isGammaElectronPositron(track)) {
edepositEM = edep;
} else {
edepositHAD = edep;
}

unsigned int unitID = setDetUnitId(&fFakeStep);

Expand Down Expand Up @@ -241,6 +249,8 @@ bool CaloSD::ProcessHits(G4GFlashSpot* aSpot, G4TouchableHistory*) {

double CaloSD::getEnergyDeposit(const G4Step* aStep) { return aStep->GetTotalEnergyDeposit(); }

double CaloSD::EnergyCorrected(const G4Step& aStep, const G4Track*) { return aStep.GetTotalEnergyDeposit(); }

bool CaloSD::getFromLibrary(const G4Step*) { return false; }

void CaloSD::Initialize(G4HCofThisEvent* HCE) {
Expand Down
15 changes: 15 additions & 0 deletions SimG4CMS/Calo/src/ECalSD.cc
Expand Up @@ -212,6 +212,21 @@ double ECalSD::getEnergyDeposit(const G4Step* aStep) {
return edep;
}

double ECalSD::EnergyCorrected(const G4Step& step, const G4Track* track) {
double edep = step.GetTotalEnergyDeposit();
const G4StepPoint* hitPoint = step.GetPreStepPoint();
const G4LogicalVolume* lv = hitPoint->GetTouchable()->GetVolume(0)->GetLogicalVolume();

if (useWeight && !any(noWeight, lv)) {
currentLocalPoint = setToLocal(hitPoint->GetPosition(), hitPoint->GetTouchable());
auto ite = xtalLMap.find(lv);
crystalLength = (ite == xtalLMap.end()) ? 230.0 : std::abs(ite->second);
crystalDepth = (ite == xtalLMap.end()) ? 0.0 : (std::abs(0.5 * (ite->second) + currentLocalPoint.z()));
edep *= curve_LY(lv) * getResponseWt(track);
}
return edep;
}

int ECalSD::getTrackID(const G4Track* aTrack) {
int primaryID(0);
if (storeTrack && depth > 0) {
Expand Down