function p = ParticleTypeCalculator(ScriptVar, particle_index)
    % Calculates the type of the particle in question (default = 1)
    % Output - 
    %    p = particle type
    %
    % Inputs - 
    %    ScriptVar - parameters container map
    %    particle_index - particle whose type is in question
    
    N_Particles = ScriptVar('N_Particles');
    p = zeros(length(particle_index),1);
    for k = 1:length(p)
        if particle_index(k) <= N_Particles(1)
            p(k) = 1;
        elseif particle_index(k) > N_Particles(1) &&...
               particle_index(k) <= N_Particles(1)+N_Particles(2)
            p(k) = 2;
        end
        if length(N_Particles) >= 3
            for i = 3:length(N_Particles)
               sum_until_i_minus_2 = sum(N_Particles(1:i-2));
               if particle_index(k) > sum_until_i_minus_2+N_Particles(i-1) && ...
                       particle_index(k) <= sum_until_i_minus_2+N_Particles(i-1)+N_Particles(i)
                   p(k) = i;
               end
            end
        end
    end
end   