Skip to content

Commit

Permalink
Merge pull request #5 from shahor02/pr_fixCosm
Browse files Browse the repository at this point in the history
Fix memory corruption and ITS acceptance limits
  • Loading branch information
shahor02 authored Sep 14, 2020
2 parents b392d4f + 59a40c1 commit f0879f2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
10 changes: 3 additions & 7 deletions GeneratorCosmics/GeneratorCosmics.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
// Origin: [email protected]
// Modifications for O2: [email protected]

#include <TParticle.h>
#include <TRandom.h>
#include <TParticle.h>
#include <TVirtualMC.h>
#include <TGeoGlobalMagField.h>
#include "GeneratorCosmics.h"
Expand Down Expand Up @@ -53,10 +53,8 @@ void GeneratorCosmics::GenerateEvent()
if (!mFieldIsSet && !detectField()) {
throw std::runtime_error("Failed to fetch magnetic field");
}

fParticles->Clear();
fParticles->Clear();
int npart = 0;
std::unique_ptr<TParticle> part;
//
while (npart < mNPart) { // until needed numbe of muons generated
int trials = 0;
Expand Down Expand Up @@ -138,11 +136,9 @@ void GeneratorCosmics::GenerateEvent()
}

auto etot = std::sqrt(MuMass * MuMass + ptot * ptot);
part = std::make_unique<TParticle>(pdg, 1, -1, -1, -1, -1, p[0], p[1], p[2], etot, r[0], r[1], r[2], 0);
fParticles->Add( new TParticle(pdg, 1, -1, -1, -1, -1, p[0], p[1], p[2], etot, r[0], r[1], r[2], 0) );
break;
} while (1);

fParticles->Add(part.get());
npart++;
}
}
Expand Down
19 changes: 9 additions & 10 deletions GeneratorCosmics/GeneratorCosmics.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
// Origin: [email protected]
// Modifications for O2: [email protected]

#include "TGenerator.h"
#include "TClonesArray.h"
#include <TGenerator.h>
#include <TClonesArray.h>
#include <TF1.h>

// Generates requested number of cosmic muons per call, requiring them to pass through
Expand Down Expand Up @@ -72,19 +72,18 @@ class GeneratorCosmics : public TGenerator
mXAcc = x < 1 ? 1. : x;
mZAcc = z < 1 ? 1. : z;
}
void requireITS0() { requireXZAccepted(2.7, 27.1); }
void requireITS1() { requireXZAccepted(3.5, 27.1); }
void requireITS2() { requireXZAccepted(4.3, 27.1); }
void requireITS3() { requireXZAccepted(19.8, 84.3); }
void requireITS4() { requireXZAccepted(24.8, 84.3); }
void requireITS5() { requireXZAccepted(34.6, 147.5); }
void requireITS6() { requireXZAccepted(39.5, 147.5); }
void requireITS0() { requireXZAccepted(2.23, 15.56); }
void requireITS1() { requireXZAccepted(3.00, 15.56); }
void requireITS2() { requireXZAccepted(3.78, 15.56); }
void requireITS3() { requireXZAccepted(19.55, 43.77); }
void requireITS4() { requireXZAccepted(24.54, 43.77); }
void requireITS5() { requireXZAccepted(34.38, 75.08); }
void requireITS6() { requireXZAccepted(39.33, 75.08); }
void requireTPC() { requireXZAccepted(250, 250); }

bool getXZatOrigin(float& xpos, float& zpos, const float r[3], const float p[3], int q) const;

private:

bool detectField();

GenParamType mParam = GenParamType::ParamTPC;
Expand Down

0 comments on commit f0879f2

Please sign in to comment.