Skip to content

Commit febca98

Browse files
committed
Fix issue with free() index. Added min track length
1 parent 4449d4c commit febca98

4 files changed

Lines changed: 34 additions & 28 deletions

File tree

EsbGeometry/EsbSuperFGD/EsbConfig/fgdconfig

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ number_cubes_Z=100
1111

1212
#magnetic field [1 kGauss = 0.1 T]
1313
magField_X=0 #in [kG]
14-
magField_Y=20 #in [kG]
14+
magField_Y=10 #in [kG]
1515
magField_Z=0 #in [kG]
1616

1717
#visualization
@@ -37,17 +37,20 @@ searchneighborhood=0
3737
# setting for lower photon limit
3838
errPhotoLimit=0
3939

40+
#exclude tracks below minimum track Lenght
41+
min_track_lenght=15
42+
4043
# The belog settings for graph traversal
4144

4245
# The grad in angle is calculated as the angle between two vectors.
4346
# 1st vector is the vector distance between 2 cubes at gradDist apart
4447
# 2nd vector is the vector distance between 2 cubes shifter gradIntervalDist number of cubes from the 1st one
45-
gradDist=7 # Distance in number of cubes for track to calculate the grad
46-
gradIntervalDist=4 # Interval between two distance vectors to calculate grad
48+
gradDist=6 # Distance in number of cubes for track to calculate the grad
49+
gradIntervalDist=3 # Interval between two distance vectors to calculate grad
4750
gradDiff=25 # Allowable difference between grad to consider a different track
4851

4952
# Calculate momentum from the segment with length 'momTrackSegment' by averaging the calculated momentum from 3 points (the 1st of the segment,
5053
# the second and for each point in between). Since the are energy losses and the momentum decreases, take the particle momentum from as the average from the
5154
# first'avgTrackMomentum' points
52-
momTrackSegment=15
53-
avgTrackMomentum=3
55+
momTrackSegment=11
56+
avgTrackMomentum=5

EsbGeometry/EsbSuperFGD/EsbFgdDetectorParameters.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ namespace DP
4747
static const string FGD_MC_LEPTON_RECONSTRUCTION_BRANCH = "FgdMCLeptonStatsBranch";
4848
static const string FGD_MC_LEPTON_RECONSTRUCTION_ROOT_FILE = "FgdMCLeptonStatsRootFile";
4949

50+
static const string FGD_MIN_TRACK_LENGTH = "min_track_lenght";
51+
5052
static const string FGD_GRAD_DIST = "gradDist";
5153
static const string FGD_GRAD_INTERVAL_DIST = "gradIntervalDist";
5254
static const string FGD_GRAD_ALLOWABLE_DIFF = "gradDiff";

EsbReconstruction/EsbSuperFGD/FgdGraphStats.cxx

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ FgdGraphStats::FgdGraphStats(const char* name
8383
, double debugLlv) :
8484
FairTask(name, verbose)
8585
, fgdConstructor(geoConfigFile)
86+
, fMinTrackLenght(0)
8687
{
8788
fpdgDB = make_shared<TDatabasePDG>();
8889
fParams.LoadPartParams(geoConfigFile);
@@ -94,7 +95,11 @@ FgdGraphStats::FgdGraphStats(const char* name
9495
// ----- Destructor ----------------------------------------------------
9596
FgdGraphStats::~FgdGraphStats()
9697
{
97-
98+
if(fHitArray)
99+
{
100+
fHitArray->Delete();
101+
}
102+
delete fHitArray;
98103
}
99104
// -------------------------------------------------------------------------
100105

@@ -120,6 +125,8 @@ InitStatus FgdGraphStats::Init()
120125
f_total_Y = f_step_Y * f_bin_Y;
121126
f_total_Z = f_step_Z * f_bin_Z;
122127

128+
fMinTrackLenght = fParams.ParamAsInt(esbroot::geometry::superfgd::DP::FGD_MIN_TRACK_LENGTH);
129+
123130
// Get RootManager
124131
FairRootManager* manager = FairRootManager::Instance();
125132
if ( !manager ) {
@@ -159,14 +166,17 @@ void FgdGraphStats::Exec(Option_t* opt)
159166

160167
std::vector<ReconHit> allGRhits;
161168
std::vector<std::vector<ReconHit*>> foundGRTracks;
169+
162170
rc = rc && GetGraphHits(allGRhits);
163171

172+
164173
if(!rc) LOG(info) << " Could not get graph hits";
165174

166175
if(rc)
167176
{
168177
LOG(debug) <<" MC Hits to retrieve stats from " << allMChits.size();
169-
SplitMCTrack(allMChits, foundMCTracks);
178+
//SplitMCTrack(allMChits, foundMCTracks);
179+
SplitMCTrack(allGRhits, foundMCTracks);
170180
}
171181

172182

@@ -199,46 +209,45 @@ void FgdGraphStats::Exec(Option_t* opt)
199209

200210
void FgdGraphStats::CompareTracks(std::vector<std::vector<ReconHit>>& mcTracks, std::vector<std::vector<ReconHit*>>& grTracks)
201211
{
202-
static int TRACK_MIN_SIZE = 3;
203212
// 1. Calculate number of trakcs in Graph
204-
int numOfGRTracksBigThan3 = 0;
213+
int numOfGRTracksBigThanLimit = 0;
205214
for(Int_t grInd = 0 ; grInd < grTracks.size(); ++grInd)
206215
{
207216
std::vector<ReconHit*>& track = grTracks[grInd];
208-
if(track.size() > TRACK_MIN_SIZE) numOfGRTracksBigThan3++;
217+
if(track.size() > fMinTrackLenght) numOfGRTracksBigThanLimit++;
209218
}
210219

211220
// 2. Calculate number of tracks in MC (charged particles only)
212-
int numOfMCTracksBigThan3 = 0;
221+
int numOfMCTracksBigThanLimit = 0;
213222
for(Int_t mcInd = 0 ; mcInd < mcTracks.size(); ++mcInd)
214223
{
215224
std::vector<ReconHit> track = mcTracks[mcInd];
216-
if(track.size() > TRACK_MIN_SIZE
225+
if(track.size() > fMinTrackLenght
217226
&& IsChargedParticle(track[0]))
218227
{
219-
numOfMCTracksBigThan3++;
228+
numOfMCTracksBigThanLimit++;
220229
}
221230
}
222231

223232
LOG(info) << "+++++++++++++++++++++++++++++++++";
224-
LOG(info) << " Graph tracks [3 cubes at least] = " << numOfGRTracksBigThan3;
225-
LOG(info) << " MC tracks [3 cubes at least/ charge is not zero of the particle] = " << numOfMCTracksBigThan3;
226-
LOG(info) << " Number of Graph tracks / Number of MC tracks = " << (1.0 * numOfGRTracksBigThan3) / numOfMCTracksBigThan3;
233+
LOG(info) << " Graph tracks ["<< fMinTrackLenght <<" cubes at least] = " << numOfGRTracksBigThanLimit;
234+
LOG(info) << " MC tracks ["<< fMinTrackLenght <<" cubes at least/ charge is not zero of the particle] = " << numOfMCTracksBigThanLimit;
235+
LOG(info) << " Number of Graph tracks / Number of MC tracks = " << (1.0 * numOfGRTracksBigThanLimit) / numOfMCTracksBigThanLimit;
227236
LOG(info) << "+++++++++++++++++++++++++++++++++";
228237

229238
// 3. Calculate the best match for GR track to MC track
230239
for(Int_t grInd = 0 ; grInd < grTracks.size(); ++grInd)
231240
{
232241
std::vector<ReconHit*>& grtrack = grTracks[grInd];
233-
if(grtrack.size() <= TRACK_MIN_SIZE) continue;
242+
if(grtrack.size() <= fMinTrackLenght) continue;
234243

235244
Double_t maxFit = 0;
236245
Int_t indOfMcMaxFit = 0;
237246

238247
for(Int_t mcInd = 0 ; mcInd < mcTracks.size(); ++mcInd)
239248
{
240249
std::vector<ReconHit> mctrack = mcTracks[mcInd];
241-
if(mctrack.size() > TRACK_MIN_SIZE
250+
if(mctrack.size() > fMinTrackLenght
242251
&& IsChargedParticle(mctrack[0]))
243252
{
244253
Double_t res = CmpGrToMCTrack(mctrack, grtrack);
@@ -347,6 +356,7 @@ Bool_t FgdGraphStats::GetGraphHits(std::vector<ReconHit>& allHits)
347356
for(Int_t i =0; i < fHitArray->GetEntries() ; i++)
348357
{
349358
data::superfgd::FgdHit* hit = (data::superfgd::FgdHit*)fHitArray->At(i);
359+
350360
TVector3 photoE = hit->GetPhotoE();
351361
TVector3 mppcLoc = hit->GetMppcLoc();
352362

@@ -363,11 +373,6 @@ Bool_t FgdGraphStats::GetGraphHits(std::vector<ReconHit>& allHits)
363373
if(visited[ind])
364374
{
365375
// If already exists, add the photons
366-
ReconHit toFind;
367-
toFind.fmppcLoc = mppcLoc;
368-
std::vector<ReconHit>::iterator recHit = find(allHits.begin(), allHits.end(), toFind);
369-
ReconHit& foundHit = *recHit;
370-
foundHit.fphotons = foundHit.fphotons + photoE;
371376
continue;
372377
}
373378
visited[ind] = true;

EsbReconstruction/EsbSuperFGD/FgdGraphStats.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,8 @@ class FgdGraphStats : public FairTask
121121
/** Path to the used media.geo file - containing definitions of materials **/
122122
std::string fmediaFile;//!<!
123123

124-
/** Path to the events file containing Monte carlo simulation data - pdg codes, momentums etc. **/
125-
std::string feventFile;//!<!
124+
Int_t fMinTrackLenght;
126125

127-
Int_t fminGenFitInterations;
128-
Int_t fmaxGenFitIterations;
129-
Int_t fminHits;
130126

131127
/** Are materials already defined **/
132128
bool isDefinedMaterials;

0 commit comments

Comments
 (0)