Closed WenjieWu-Sci closed 1 year ago
Some investigations...
I suppose the second issue comes from: https://github.com/WenjieWu-Sci/FLArE/blob/main/src/AnalysisManager.cc#L340-L360
// find all the tracks originate from the final state lepton, include FSL itself (TID=1)
tracksFromFSL.insert(1);
for (auto x : allTracksPTPair) {
if (tracksFromFSL.find(x.first) != tracksFromFSL.end()) {
tracksFromFSL.insert(x.second);
}
}
Here FSL is basically defined as the track with TID = 1
. This is true for GENIE interactions, but the vertex created with particle gun sets the track id as 1 as well, causing the pion to be considered a FSL. We should add here a proper PDG check on the TID = 1
track and skip if failed.
The issue with nPrimaryParticle
comes from where it gets updated (https://github.com/WenjieWu-Sci/FLArE/blob/main/src/AnalysisManager.cc#L328), since just above primary_particle_info->Print();
is called only once for the correct primary.
// update number of primary particles
// including decay products from tau and pizero
nPrimaryParticle = countPrimaryParticle;
In a test I ran, I see that these wrong primaries have PID=3
, so looking at the various ways countPrimaryParticle
is set (https://github.com/WenjieWu-Sci/FLArE/blob/main/src/AnalysisManager.cc#L574 and onwards) I believe they are probably coming from being considered FSL secondaries of some kind... so they might be a consequence of the wrong FSL track list.
I think I've found a workaround, validating with some examples. I'll update as soon as the validation looks reasonable.
While producing plots for #14 I noticed a different error related to nPrimaryParticle
happening when the starting position of the muon is in the world
volume. In this case nPrimaryParticle=0
.
PrimaryParticleInformation: PDG code 13
Particle unique ID : 0
MC momentum : (0,0,5104.564987832) MeV
MC vertex : (0,0,30000) mm
number of primary vertices : 1
Recorded tracks : 21
Tracks from FSL : 19
Tracks from FSL (2nd) : 0
number of primary particles : 0 , in which number of particles from fsl : 0
Can't find the primary particle of the hit, something is wrong 13 edep(0.652446) TID(1) PID(0) creator process (PrimaryParticle) position(0.033951,0.053436,34502.102168)
Can't find the primary particle of the hit, something is wrong 13 edep(1.091510) TID(1) PID(0) creator process (PrimaryParticle) position(0.034705,0.053354,34507.102168)
Can't find the primary particle of the hit, something is wrong 13 edep(2.339208) TID(1) PID(0) creator process (PrimaryParticle) position(0.022532,0.215490,34725.000000)
Can't find the primary particle of the hit, something is wrong 13 edep(1.148989) TID(1) PID(0) creator process (PrimaryParticle) position(-0.030680,0.200767,34943.794435)
Can't find the primary particle of the hit, something is wrong 13 edep(0.713474) TID(1) PID(0) creator process (PrimaryParticle) position(-0.026756,0.206044,34948.794435)
...
I will investigate if the fix also solves this... tomorrow :)
It won't be solved by this fix.
countPrimaryParticle
. If all events are generated within the detector it should be fine. But we might need to deal with it eventually because we're going to study backgrounds generated outside the detector. One workaround I can think of for now is changing this line to:
if (countPrimaryParticle != 0) nPrimaryParticle = countPrimaryParticle;
In this way, if the particle is generated outside a SD, nPrimaryParticle would be assigned directly by count_particles from the generator. I'll give it a try.One workaround I can think of for now is changing this line to:
if (countPrimaryParticle != 0) nPrimaryParticle = countPrimaryParticle;
In this way, if the particle is generated outside a SD, nPrimaryParticle would be assigned directly by count_particles from the generator. I'll give it a try.
No, this can't resolve this issue. I think the way to do this is via a UserSteppingAction. Either way, we probably should open another issue for this. It's another problem rather than the issue in this thread.
Run the program with single pion (pi+) generator (macros/single_particle/LAr_piplus.mac), the output is
nPrimaryParticle
,tracksFromFSL
are incorrectly assigned. Anything related to FSL should only work with neutrino interaction generator, not for single particle generator. Needs to find a way to fix this.