BgMaps.hh
1 |
#ifndef ROOT_BgMaps
|
---|---|
2 |
#define ROOT_BgMaps
|
3 |
|
4 |
#include <sash/EnvelopeEntry.hh> |
5 |
#include <sash/HESSArray.hh> |
6 |
#include <plotters/SkyHist.hh> |
7 |
|
8 |
namespace Background {
|
9 |
|
10 |
// BgMaps contains fEnergyBound, which is of the type EnergyBound.
|
11 |
// The first parameter is the lower energy bound of an energy range,
|
12 |
// the second is the upper bound.
|
13 |
typedef std::pair<Double_t,Double_t> EnergyBound;
|
14 |
|
15 |
|
16 |
/**
|
17 |
* \brief Data class containing all 2D background output.
|
18 |
*
|
19 |
* This, along with a list of RunStats objects,
|
20 |
* is the primary output of a BgMaker.
|
21 |
*
|
22 |
* BgMaps provides:
|
23 |
*
|
24 |
* - storage of "fine-binned" raw maps generated by BgMakers
|
25 |
*
|
26 |
* - methods for combining these maps to produce e.g. a
|
27 |
* significance or excess map
|
28 |
*
|
29 |
* - all the logic needed to accumulate
|
30 |
*
|
31 |
* - a series of BgMaps for each run. BgMaps may be added which do
|
32 |
* not have the same geometry (System, field-of-view, center, or
|
33 |
* binsize ) as the target, and in that case the various maps are
|
34 |
* resampled and transformed. Note that this may introduce some
|
35 |
* binning errors or coordinate distortion on small scales.
|
36 |
*
|
37 |
*
|
38 |
* For example, you can combine a list of BgMaps into a final
|
39 |
* "summed" BgMap via the following:
|
40 |
*
|
41 |
* \code
|
42 |
* Background::BgMaps totals;
|
43 |
* totals.Init( center, binsize, fov_x, fov_y );
|
44 |
*
|
45 |
*
|
46 |
* Background::BgMaps *maps;
|
47 |
* maps = hess->Get<Background::BgMaps>("RingBgMaker_CurrentMaps"),
|
48 |
*
|
49 |
* for (int ii=0; ii<RunResult->GetEntries(); ii++) {
|
50 |
* RunResult->GetEntry(ii);
|
51 |
* totals.AddMapsFrom( *maps );
|
52 |
* }
|
53 |
*
|
54 |
* totals.MakeSignificanceMap( sqrt(0.05) )->Draw();
|
55 |
* \endcode
|
56 |
*
|
57 |
* \note Exposure is the *background exposure* and is defined as:
|
58 |
* Expected number of events at a particular position, given the
|
59 |
* acceptance at that point, such that the integral of the exposure
|
60 |
* map excluding exclusions == total number of ON events. I.e., the
|
61 |
* exposure map is equivalent to the FOV background map. The alpha
|
62 |
* value (used in calculating significance and excess) is defined as
|
63 |
* the OnExposureMap/OffExposureMap. ExposureON/OFF should be
|
64 |
* filled always by the BgMaker base class, with an option to use
|
65 |
* real events to make the exposure maps. TemplateBgMaker will have
|
66 |
* to fill these in a differnt way, since these exposure maps assume
|
67 |
* gamma-ray-like events.
|
68 |
*
|
69 |
* \ingroup background
|
70 |
*/
|
71 |
class BgMaps : public Sash::MonitorBase |
72 |
{ |
73 |
// used by FluxMapFillFunction
|
74 |
enum FluxMapType { FLUX_POINTLIKE, UPPER_LIMIT_POINTLIKE,
|
75 |
SENSITIVITY_POINTLIKE, |
76 |
SURFACE_BRIGHTNESS, FLUX_EXTENDED, |
77 |
UPPER_LIMIT_EXTENDED, SENSITIVITY_EXTENDED, |
78 |
UPPER_LIMIT_EXTENDED_AVG }; |
79 |
|
80 |
|
81 |
public:
|
82 |
|
83 |
BgMaps(Sash::HESSArray& hessarray |
84 |
#if defined(__CINT__) || defined(CINTOBJECT)
|
85 |
= hessdummy |
86 |
#endif
|
87 |
,const char * name=""); |
88 |
|
89 |
//this constructors allows creation of a fully initilized copy with a different name
|
90 |
BgMaps(Sash::HESSArray& hessarray, const BgMaps &maps, const char * name); |
91 |
|
92 |
// this constructor allows to inherited classes
|
93 |
BgMaps(const std::string &handle, |
94 |
Sash::HESSArray& hessarray |
95 |
#if defined(__CINT__) || defined(CINTOBJECT)
|
96 |
= hessdummy |
97 |
#endif
|
98 |
,const char * name=""); |
99 |
|
100 |
void Clear(Option_t *option=""); |
101 |
|
102 |
// \todo make it virtual and const
|
103 |
void print(std::ostream& os) const; |
104 |
|
105 |
|
106 |
// sub-classes may add new features to these methods
|
107 |
virtual void Init(Stash::Coordinate center, double binsize, |
108 |
double fov_x, double fov_y, bool strictlyKeepFov); |
109 |
virtual void AddMapsFrom( BgMaps &maps ); |
110 |
virtual void ReplaceMapsFrom( const BgMaps &maps ); |
111 |
virtual void Rebin( int factor ); |
112 |
virtual void CutAwayBorders( double radius, Stash::Coordinate ¢erpos ); |
113 |
|
114 |
static void InitSkyHist(Plotters::SkyHist& hist, const char* name, |
115 |
Stash::Coordinate centre, double binsize,
|
116 |
double fov_x, double fov_y, bool strictlyKeepFov); |
117 |
bool InitFluxMap();
|
118 |
|
119 |
GETMEMBER( OnMap, Plotters::SkyHist); |
120 |
GETMEMBER( OffMap, Plotters::SkyHist); |
121 |
GETMEMBER( OnExposureMap, Plotters::SkyHist); |
122 |
GETMEMBER( OffExposureMap, Plotters::SkyHist); |
123 |
GETMEMBER( ExclusionMap, Plotters::SkyHist); |
124 |
GETMEMBER( OffMapIsCorrelated, Bool_t); |
125 |
|
126 |
GETMEMBER( IsFluxMap, Bool_t); |
127 |
GETMEMBER( ExpGammaMap, Plotters::SkyHist); |
128 |
GETMEMBER( EnergyBounds, EnergyBound); |
129 |
GETMEMBER( ExpGammaMapInfoString, std::string);
|
130 |
GETMEMBER( AssumedRefIndex, Double_t ); |
131 |
|
132 |
Plotters::SkyHist* MakeSignificanceMap( double correlation_radius,
|
133 |
bool exclusions=false, |
134 |
std::string name="Significance"); |
135 |
Plotters::SkyHist* MakeExtendedSignificanceMap( double correlation_radius); // test |
136 |
Plotters::SkyHist* MakeExcludedSignificanceMap(double correlation_radius,
|
137 |
std::string name="Significance_Excluded"); |
138 |
Plotters::SkyHist* MakeExcessMap(); |
139 |
Plotters::SkyHist* MakeExposureCorrectedExcessMap(); |
140 |
Plotters::SkyHist* MakeAlphaMap( double correlation_radius=0.0, bool exclusions = false ); |
141 |
Plotters::SkyHist* MakeBackgroundMapExcessStyle(); |
142 |
Plotters::SkyHist* MakeBackgroundMapSignificanceStyle(double correlation_radius);
|
143 |
|
144 |
Plotters::SkyHist* MakePointsourceFluxMap(double E1 = 1.0, double E2 = 0., double maxSensitivity = 0.0); |
145 |
Plotters::SkyHist* MakePointsourceSensitivityMap(double threshold = 5.0, double E1 = 1.0, double E2 = 0.); |
146 |
Plotters::SkyHist* MakePointsourceUpperLimitMap( double confidenceLevel = 0.95, |
147 |
double E1 = 1.0, double E2 = 0., double maxSensitivity = 0.0); |
148 |
|
149 |
Plotters::SkyHist* MakeSurfaceBrightnessMap(double E1 = 1.0, double E2 = 0., |
150 |
double maxSensitivity = 0.0, double correlationRadius = 0.1); |
151 |
|
152 |
Plotters::SkyHist* MakeExtendedFluxMap(double radius, double E1 = 1.0, double E2 = 0., double maxSensitivity = 0.0); |
153 |
Plotters::SkyHist* MakeExtendedSensitivityMap(double radius, double threshold = 5.0, double E1 = 1.0, double E2 = 0.); |
154 |
Plotters::SkyHist* MakeExtendedUpperLimitMap(double radius, double confidenceLevel = 0.95, |
155 |
double E1 = 1.0, double E2 = 0., double maxSensitivity = 0.0); |
156 |
Plotters::SkyHist* MakeExtendedUpperLimitAvgMap(double radius, double confidenceLevel = 0.95, |
157 |
double E1 = 1.0, double E2 = 0.); |
158 |
|
159 |
|
160 |
void SaveAsFITS( std::string basename ); |
161 |
|
162 |
int GetResampleFactor() const { return fResampleFactor; } |
163 |
void SetResampleFactor(int factor=-1) { fResampleFactor=factor; } |
164 |
|
165 |
void FillExclusionMap( Tools::Compound &exclusionregion, bool init = true ); |
166 |
|
167 |
private:
|
168 |
|
169 |
Plotters::SkyHist* FluxMapFillFunction(double radius, double E1, double E2, |
170 |
FluxMapType maptype, |
171 |
std::string mapname = "dummy", |
172 |
std::string maptitle = "dummy", |
173 |
std::string zaxis = "dummy", |
174 |
double confidence_level = 0.95); |
175 |
protected:
|
176 |
|
177 |
Plotters::SkyHist fOnMap; //< Event map with independent bins
|
178 |
Plotters::SkyHist fOffMap; //< Event map with independent bins
|
179 |
Plotters::SkyHist fOnExposureMap; //< ON exposure
|
180 |
Plotters::SkyHist fOffExposureMap; //< OFF exposure
|
181 |
/// Exclusion regions map -
|
182 |
/// definition: data from a set bin (eq. 1)
|
183 |
/// has been used to calculate the Off data.
|
184 |
/// In constrast, the information whether
|
185 |
/// the Off map (or On map) contains data
|
186 |
/// is stored in the Exposure map. The ring
|
187 |
/// background is a good example for this
|
188 |
/// definition. The Off map includes data
|
189 |
/// at the excluded region.
|
190 |
Plotters::SkyHist fExclusionMap; |
191 |
|
192 |
/// Optionally filled by ExposureMapMaker
|
193 |
/// calculated such that you can get
|
194 |
/// Norm = (Excess / ExpGamma)
|
195 |
/// ExpGamma is the expected Excess from a
|
196 |
/// source with the fixed reference flux fully
|
197 |
/// contained in the On region used to
|
198 |
/// calculate the Excess.
|
199 |
Plotters::SkyHist fExpGammaMap; |
200 |
|
201 |
/// Energy cuts can be applied to
|
202 |
/// Excess and ExpGamma to reduce
|
203 |
/// systematic errors near the safe
|
204 |
/// energy thresholds:
|
205 |
EnergyBound fEnergyBounds; |
206 |
|
207 |
std::string fExpGammaMapInfoString; //< pair=value string containing info needed for flux map calculation |
208 |
|
209 |
/// Spectral index assumed for filling of ExpGammaMap
|
210 |
Double_t fAssumedRefIndex; |
211 |
|
212 |
|
213 |
Bool_t fOffMapIsCorrelated; /// set if fOffMap is correlated (--> RingBg)
|
214 |
|
215 |
Bool_t fIsFluxMap; /// flag will be set when fExpGammaMap is initialised in InitFluxMap.
|
216 |
|
217 |
int fResampleFactor; //! subpixel resampling factor used when adding (default -1) |
218 |
|
219 |
|
220 |
ClassDef(Background::BgMaps,6);
|
221 |
}; |
222 |
|
223 |
|
224 |
} |
225 |
|
226 |
#endif
|