Program Listing for File Observer.h
↰ Return to documentation for file (include/crpropa/module/Observer.h)
#ifndef CRPROPA_OBSERVER_H
#define CRPROPA_OBSERVER_H
#include <fstream>
#include <limits>
#include <string>
#include <vector>
#include "../Candidate.h"
#include "../Module.h"
#include "../Referenced.h"
#include "../Vector3.h"
#include "../Geometry.h"
namespace crpropa {
enum DetectionState {
DETECTED, VETO, NOTHING
};
class ObserverFeature: public Referenced {
protected:
std::string description;
public:
virtual DetectionState checkDetection(Candidate *candidate) const;
virtual void onDetection(Candidate *candidate) const;
virtual std::string getDescription() const;
};
class Observer: public Module {
std::string flagKey;
std::string flagValue;
private:
std::vector<ref_ptr<ObserverFeature> > features;
ref_ptr<Module> detectionAction;
bool clone;
bool makeInactive;
public:
Observer();
void add(ObserverFeature *feature);
void onDetection(Module *action, bool clone = false);
void process(Candidate *candidate) const;
std::string getDescription() const;
void setFlag(std::string key, std::string value);
void setDeactivateOnDetection(bool deactivate);
};
class ObserverDetectAll: public ObserverFeature {
public:
DetectionState checkDetection(Candidate *candidate) const;
std::string getDescription() const;
};
class ObserverSurface: public ObserverFeature {
private:
ref_ptr<Surface> surface;
public:
ObserverSurface(Surface* surface);
DetectionState checkDetection(Candidate *candidate) const;
std::string getDescription() const;
};
class ObserverTracking: public ObserverFeature {
private:
Vector3d center;
double radius;
double stepSize;
public:
ObserverTracking(Vector3d center, double radius, double stepSize = 0);
DetectionState checkDetection(Candidate *candidate) const;
std::string getDescription() const;
};
class Observer1D: public ObserverFeature {
public:
DetectionState checkDetection(Candidate *candidate) const;
std::string getDescription() const;
};
class ObserverRedshiftWindow: public ObserverFeature {
private:
double zmin, zmax;
public:
ObserverRedshiftWindow(double zmin = 0, double zmax = 0.1);
DetectionState checkDetection(Candidate *candidate) const;
std::string getDescription() const;
};
class ObserverInactiveVeto: public ObserverFeature {
public:
DetectionState checkDetection(Candidate *candidate) const;
std::string getDescription() const;
};
class ObserverNucleusVeto: public ObserverFeature {
public:
DetectionState checkDetection(Candidate *candidate) const;
std::string getDescription() const;
};
class ObserverNeutrinoVeto: public ObserverFeature {
public:
DetectionState checkDetection(Candidate *candidate) const;
std::string getDescription() const;
};
class ObserverPhotonVeto: public ObserverFeature {
public:
DetectionState checkDetection(Candidate *candidate) const;
std::string getDescription() const;
};
class ObserverElectronVeto: public ObserverFeature {
public:
DetectionState checkDetection(Candidate *candidate) const;
std::string getDescription() const;
};
class ObserverParticleIdVeto: public ObserverFeature {
private:
int vetoParticleId;
public:
ObserverParticleIdVeto(int id);
DetectionState checkDetection(Candidate *candidate) const;
std::string getDescription() const;
};
class ObserverTimeEvolution: public ObserverFeature {
protected:
int nIntervals; // number of time invervals
bool isLogarithmicScaling = false; // enables or disables logarithmic scaling for the intervals
bool doDetListConstruction = true; // enables the construction of detList in the relevant functions (addTime, addTimeRange)
double minimum; // the minimum time
double maximum; // the maximum time
std::vector<double> detList;
mutable std::vector<double> tempDetList;
public:
ObserverTimeEvolution();
ObserverTimeEvolution(double min, double dist, double numb);
ObserverTimeEvolution(double min, double max, double numb, bool log);
ObserverTimeEvolution(const std::vector<double> &detList);
~ObserverTimeEvolution(){}
void constructDetListIfEmpty();
DetectionState checkDetection(Candidate *candidate) const;
void clear();
bool empty(){return detList.empty();}
// setter functions:
void addTime(const double &time);
void addTimeRange(double min, double max, double numb, bool log = false);
void setTimes(const std::vector<double> &detList);
void setMinimum(double min);
void setMaximum(double max){this->maximum = max;}
void setNIntervals(int numb){this->nIntervals = numb;}
void setIsLogarithmicScaling(bool log){this->isLogarithmicScaling = log;}
// getter functions:
virtual double getTime(std::size_t index) const;
double getMinimum() const {return minimum;}
double getMaximum() const {return maximum;}
int getNIntervals() const {return nIntervals;}
bool getIsLogarithmicScaling() const {return isLogarithmicScaling;}
const std::vector<double>& getTimes() const;
std::string getDescription() const;
};
}
#endif // CRPROPA_OBSERVER_H