Home | News | Documentation | Download

How to simulate a beam of particles?

Hi,

As the title suggests, I’m looking for a way to simulate a beam going through a proportional counter. Based on what I know about Garfield so far, it seems like the only way to do this is by calling NewTrack() as many times as you need. Is there a more efficient way to do this?

Hi,
calling NewTrack multiple times is indeed the way to go.

Hi @hschindl ,

I have a follow-up question. At the moment, this is how I am simulating a track from the incident beam:

  TrackHeed track;
  track.SetSensor(&sensor);
  track.SetParticle("proton");
  track.SetKineticEnergy(20.e6);

  double xc = 0., yc = 0., zc = 0., tc = 0., ec = 0., extra = 0.;
  int nc = 0;
  std::vector<double> electrons;
  double xe = 0., ye = 0., ze = 0., te = 0., ee = 0.;
  double dx = 0., dy = 0., dz = 0.;
  int left=0, right = 0;
  int NofProton = 100;  
  for (int i = 0; i < NofProton; i++) {
    // Simulate a track
    track.NewTrack(-x, 1.0, -x, 100., 1., 0., 1.); //45 degrees
		while (track.GetCluster(xc, yc, zc, tc, nc, ec, extra)) {
			for (int k = 0; k < nc; ++k) {
			  track.GetElectron(k, xe, ye, ze, te, ee, dx, dy, dz);
			  electrons.push_back(xe);
			  electrons.push_back(ye);
			  electrons.push_back(ze);
			  electrons.push_back(te);
			}
		}
  }

When NofProton = 1, I get a rather straight track, like below:
image

However, when NofProton = 100, the track becomes this
image

Can you please explain to me why this is happening?

Note: each tick mark corresponds to 1 cm.

Hi,
nice plot! I think it’s just statistical fluctuations and the little sprigs you see on the plot are the secondaries created by delta electrons.

Hi,

That makes sense! Thanks.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.