Skip to content

Commit 4de36b1

Browse files
Add variable to track if electron originates from primary electron (#22)
1 parent 84d5811 commit 4de36b1

8 files changed

Lines changed: 55 additions & 6 deletions

File tree

Pinpoint/include/AnalysisManager.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ class AnalysisManager {
189189
// std::vector<G4bool> fPixelFromPrimaryPizero;
190190
// std::vector<G4bool> fPixelFromFSLPizero;
191191
std::vector<G4bool> fPixelFromPrimaryLepton;
192+
std::vector<G4bool> fPixelFromPrimaryEMShower;
192193

193194
// Truth position of hit in x, y, z
194195
std::vector<Float_t> fPixelTruthX;

Pinpoint/include/PixelHit.hh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class PixelHit : public G4VHit
1212
{
1313
public:
1414
PixelHit() = default;
15-
PixelHit(G4double edep, G4int rowID, G4int colID, G4int layerId, G4int trackID, G4int parentID, G4int pdgc, G4bool isPrim);
15+
PixelHit(G4double edep, G4int rowID, G4int colID, G4int layerId, G4int trackID, G4int parentID, G4int pdgc, G4bool isPrim, G4bool isEMShower);
1616
PixelHit(const PixelHit&) = default;
1717
~PixelHit() override = default;
1818

@@ -44,6 +44,7 @@ public:
4444
// void SetFromPrimaryPizero(G4bool fromPrimaryPizero) { fFromPrimaryPizero = fromPrimaryPizero; }
4545
// void SetFromFSLPizero(G4bool fromFSLPizero) { fFromFSLPizero = fromFSLPizero; }
4646
void SetFromPrimaryLepton(G4bool fromPrimaryLepton) { fFromPrimaryLepton = fromPrimaryLepton; }
47+
void SetFromPrimaryEMShower(G4bool fromPrimaryEMShower) { fFromPrimaryEMShower = fromPrimaryEMShower; }
4748
// void SetTruthHitPos(G4ThreeVector pos) { fTruthHitPos = pos; }
4849

4950
G4int GetPDGCode() const { return fPDGCode; }
@@ -65,6 +66,7 @@ public:
6566
// G4bool GetFromPrimaryPizero() const { return fFromPrimaryPizero; }
6667
// G4bool GetFromFSLPizero() const { return fFromFSLPizero; }
6768
G4bool GetFromPrimaryLepton() const { return fFromPrimaryLepton; }
69+
G4bool GetFromPrimaryEMShower() const { return fFromPrimaryEMShower; }
6870

6971
private:
7072
G4int fTrackID = -1;
@@ -76,6 +78,7 @@ private:
7678
G4int fLayerID = -1;
7779
// G4int fCharge = 0;
7880
G4bool fFromPrimaryLepton = false;
81+
G4bool fFromPrimaryEMShower = false;
7982
// G4bool fFromPrimaryPizero = false;
8083
// G4bool fFromFSLPizero = false;
8184
// G4ThreeVector fTruthHitPos;

Pinpoint/include/TrackInformation.hh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ class TrackInformation : public G4VUserTrackInformation
2424
inline void SetTrackIsFromPrimaryPizero(G4int i) {fFromPrimaryPizero = i;}
2525
inline void SetTrackIsFromFSLPizero(G4int i) {fFromFSLPizero = i;}
2626
inline void SetTrackIsFromPrimaryLepton(G4int i) {fFromPrimaryLepton = i;}
27+
inline void SetTrackIsFromPrimaryEMShower(G4int i) {fFromPrimaryEMShower = i;}
2728
inline G4int IsTrackFromPrimaryPizero() const {return fFromPrimaryPizero;}
2829
inline G4int IsTrackFromFSLPizero() const {return fFromFSLPizero;}
2930
inline G4int IsTrackFromPrimaryLepton() const {return fFromPrimaryLepton;}
31+
inline G4int IsTrackFromPrimaryEMShower() const {return fFromPrimaryEMShower;}
3032

3133
inline void InsertHit(G4long hitIndex) {
3234
if (!fHitIndices) {
@@ -40,7 +42,7 @@ class TrackInformation : public G4VUserTrackInformation
4042
G4int fFromPrimaryPizero;
4143
G4int fFromFSLPizero;
4244
G4int fFromPrimaryLepton;
43-
45+
G4int fFromPrimaryEMShower;
4446
std::shared_ptr<std::vector<G4long>> fHitIndices;
4547

4648
// std::vector<G4long>* fHitIndices; //TODO: Make this a smart pointer?

Pinpoint/src/AnalysisManager.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ void AnalysisManager::bookHitsTrees()
198198
// fPixelHitsTree->Branch("hit_fromPrimaryPizero", &fPixelFromPrimaryPizero);
199199
// fPixelHitsTree->Branch("hit_fromFSLPizero", &fPixelFromFSLPizero);
200200
fPixelHitsTree->Branch("hit_fromPrimaryLepton", &fPixelFromPrimaryLepton);
201+
fPixelHitsTree->Branch("hit_fromPrimaryEMShower", &fPixelFromPrimaryEMShower);
201202

202203
// if (fSaveTruthHits)
203204
// {
@@ -310,6 +311,7 @@ void AnalysisManager::BeginOfEvent()
310311
// fPixelFromPrimaryPizero.clear();
311312
// fPixelFromFSLPizero.clear();
312313
fPixelFromPrimaryLepton.clear();
314+
fPixelFromPrimaryEMShower.clear();
313315
// fPixelTruthX.clear();
314316
// fPixelTruthY.clear();
315317
// fPixelTruthZ.clear();
@@ -581,6 +583,7 @@ void AnalysisManager::FillHitsOutput()
581583
// fPixelFromPrimaryPizero.push_back(hit->GetFromPrimaryPizero());
582584
// fPixelFromFSLPizero.push_back(hit->GetFromFSLPizero());
583585
fPixelFromPrimaryLepton.push_back(hit->GetFromPrimaryLepton());
586+
fPixelFromPrimaryEMShower.push_back(hit->GetFromPrimaryEMShower());
584587

585588
// if (fSaveTruthHits)
586589
// {

Pinpoint/src/PixelHit.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void PixelHit::Print()
4141
<< G4endl;
4242
}
4343

44-
PixelHit::PixelHit(G4double edep, G4int rowID, G4int colID, G4int layerID, G4int trackID, G4int parentID, G4int pdgc, G4bool isPrim)
45-
: fEnergyDeposit{edep}, fRowID{rowID}, fColID{colID}, fLayerID{layerID}, fTrackID{trackID}, fParentID{parentID}, fPDGCode{pdgc}, fFromPrimaryLepton{isPrim}
44+
PixelHit::PixelHit(G4double edep, G4int rowID, G4int colID, G4int layerID, G4int trackID, G4int parentID, G4int pdgc, G4bool isPrim, G4bool isEMShower)
45+
: fEnergyDeposit{edep}, fRowID{rowID}, fColID{colID}, fLayerID{layerID}, fTrackID{trackID}, fParentID{parentID}, fPDGCode{pdgc}, fFromPrimaryLepton{isPrim}, fFromPrimaryEMShower{isEMShower}
4646
{
4747
}

Pinpoint/src/PixelSD.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ G4bool PixelHitAccumulator::AddHit(G4Step* step)
8686
const auto* info =static_cast<const TrackInformation*>(track->GetUserInformation());
8787
G4bool fromPrimaryLepton = info && info->IsTrackFromPrimaryLepton() || parentID ==0;
8888
fromPrimaryLepton = fromPrimaryLepton && (std::abs(pdgid) == 11 || std::abs(pdgid) == 13 || std::abs(pdgid) == 15);
89+
G4bool fromPrimaryEMShower = info && info->IsTrackFromPrimaryEMShower();
8990

9091
assert(rowID < fNPixelsY);
9192
assert(colID < fNPixelsX);
@@ -106,7 +107,7 @@ G4bool PixelHitAccumulator::AddHit(G4Step* step)
106107
} else {
107108
fPixelHits.push_back(
108109
new PixelHit(edep, rowID, colID, layerID,
109-
trackID, parentID, pdgid, fromPrimaryLepton)
110+
trackID, parentID, pdgid, fromPrimaryLepton, fromPrimaryEMShower)
110111
);
111112
}
112113

Pinpoint/src/TrackInformation.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ TrackInformation::TrackInformation()
99
fFromPrimaryPizero = 0;
1010
fFromFSLPizero = 0;
1111
fFromPrimaryLepton = 0;
12+
fFromPrimaryEMShower = 0;
1213
fHitIndices = std::make_shared<std::vector<G4long>>();
1314
}
1415

@@ -18,6 +19,7 @@ TrackInformation::TrackInformation(const G4Track* aTrack)
1819
fFromPrimaryPizero = 0;
1920
fFromFSLPizero = 0;
2021
fFromPrimaryLepton = 0;
22+
fFromPrimaryEMShower = 0;
2123
fHitIndices = std::make_shared<std::vector<G4long>>();
2224
}
2325

@@ -30,7 +32,7 @@ ::operator =(const TrackInformation& aTrackInfo)
3032
fFromPrimaryPizero = aTrackInfo.fFromPrimaryPizero;
3133
fFromFSLPizero = aTrackInfo.fFromFSLPizero;
3234
fFromPrimaryLepton = aTrackInfo.fFromPrimaryLepton;
33-
35+
fFromPrimaryEMShower = aTrackInfo.fFromPrimaryEMShower;
3436
return *this;
3537
}
3638

@@ -39,5 +41,6 @@ void TrackInformation::Print() const
3941
G4cout << "Is from primary pizero " << fFromPrimaryPizero << G4endl;
4042
G4cout << "Is from final state lepton decay pizero " << fFromFSLPizero << G4endl;
4143
G4cout << "Is from primary lepton (tau or muon) " << fFromPrimaryLepton << G4endl;
44+
G4cout << "Is from primary EM shower " << fFromPrimaryEMShower << G4endl;
4245
}
4346

Pinpoint/src/TrackingAction.cc

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,42 @@ void TrackingAction::PostUserTrackingAction(const G4Track* aTrack)
7171
}
7272
}
7373

74+
if (aTrack->GetTrackID()==1 && abs(aTrack->GetParticleDefinition()->GetPDGEncoding())==11)
75+
{
76+
const auto* info =static_cast<const TrackInformation*>(aTrack->GetUserInformation());
77+
TrackInformation* newInfo = new TrackInformation();
78+
if (info) {
79+
newInfo->SetTrackIsFromPrimaryPizero(info->IsTrackFromPrimaryPizero());
80+
newInfo->SetTrackIsFromFSLPizero(info->IsTrackFromFSLPizero());
81+
newInfo->SetTrackIsFromPrimaryLepton(info->IsTrackFromPrimaryLepton());
82+
}
83+
newInfo->SetTrackIsFromPrimaryEMShower(1);
84+
aTrack->SetUserInformation(newInfo);
85+
}
86+
87+
const auto* info =static_cast<const TrackInformation*>(aTrack->GetUserInformation());
88+
G4bool fromPrimaryEMShower = info && info->IsTrackFromPrimaryEMShower();
89+
90+
if (fromPrimaryEMShower &&
91+
(abs(aTrack->GetParticleDefinition()->GetPDGEncoding())==11 ||
92+
abs(aTrack->GetParticleDefinition()->GetPDGEncoding())==22))
93+
{
94+
G4TrackVector* secondaries = fpTrackingManager->GimmeSecondaries();
95+
if (secondaries)
96+
{
97+
size_t nSeco = secondaries->size();
98+
if (nSeco>0)
99+
{
100+
for (size_t i=0; i<nSeco; ++i)
101+
{
102+
TrackInformation* info = new TrackInformation();
103+
info->SetTrackIsFromPrimaryEMShower(1);
104+
(*secondaries)[i]->SetUserInformation(info);
105+
}
106+
}
107+
}
108+
}
109+
74110
if (aTrack->GetParentID()==1 && aTrack->GetCreatorProcess()->GetProcessName()=="Decay")
75111
{
76112
// in case of tau decay pizero

0 commit comments

Comments
 (0)