Skip to content

Commit

Permalink
add source list with fixed number per source, source start time
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienDoerner committed Nov 8, 2024
1 parent b66c369 commit f2879d3
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
33 changes: 33 additions & 0 deletions include/crpropa/Source.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,20 @@ class SourceList: public SourceInterface {
std::string getDescription() const;
};

/**
@class SourceListNumbered
@brief List of sources with a fixed number of candidates emitted per source
class SourceListNumbered: public SourceInterface {
private:
std::vector<ref_ptr<Source> > sources; //
int nSource; //< number of candidates from each source
int alreadyDrawn; //< number of candidates which have already been drawn
public:
void add(Source* source);
ref_ptr<Candidate> getCandidate() const;
};*/

/**
@class SourceParticleType
Expand Down Expand Up @@ -952,6 +966,25 @@ class SourceMassDistribution: public SourceFeature {
std::string getDescription();
};

class SourceStartTime: public SourceFeature {
private:
double time; //< starting time for the particle

public:
SourceStartTime(double time);
void prepareCandidate(Candidate& cand) const;
};

class SourceAddProperty: public SourceFeature {
private:
std::string key; //< property key
int value; //< property

public:
SourceAddProperty(std::string key, int value);
void prepareCandidate(Candidate& cand) const;
};

/** @} */ // end of group SourceFeature

} // namespace crpropa
Expand Down
16 changes: 16 additions & 0 deletions src/Source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1204,4 +1204,20 @@ std::string SourceMassDistribution::getDescription() {
return ss.str();
}

// ----------------------------------------------------------------------------

SourceStartTime::SourceStartTime(double time) : time(time) {}

void SourceStartTime::prepareCandidate(Candidate& cand) const {
cand.setTrajectoryLength(time);
}

// ----------------------------------------------------------------------------

SourceAddProperty::SourceAddProperty(std::string key, int value) : key(key), value(value) {}

void SourceAddProperty::prepareCandidate(Candidate& cand) const {
cand.setProperty(key, value);
}

} // namespace crpropa

0 comments on commit f2879d3

Please sign in to comment.