00001 #include <stdio.h>
00002 #include <math.h>
00003 #include <lal/LALDetectors.h>
00004 #include <lal/DetResponse.h>
00005
00006
00007 struct detectors {
00008 LALDetector *detector;
00009 int n;
00010 };
00011
00012
00013 static double point_source_average(struct detectors detectors, double ra, double dec)
00014 {
00015 const int N = 1000;
00016 double integral = 0;
00017 int i, j;
00018 double gmst;
00019
00020 for(gmst = i = 0; gmst < LAL_TWOPI; gmst = ++i * LAL_TWOPI / N) {
00021 double fsquared = 1;
00022
00023 for(j = 0; j < detectors.n; j++) {
00024 double fp, fc;
00025 XLALComputeDetAMResponse(&fp, &fc, detectors.detector[j].response, ra, dec, 0, gmst);
00026 fsquared *= fp * fp + fc * fc;
00027 }
00028
00029 integral += fsquared * LAL_TWOPI / N;
00030 }
00031
00032 return integral / LAL_TWOPI;
00033 }
00034
00035
00036 static double all_sky_average(struct detectors detectors)
00037 {
00038 const int N = 1000;
00039 double integral = 0;
00040 double ra, dec;
00041 int i, j, k;
00042
00043 for(ra = i = 0; ra < LAL_TWOPI; ra = ++i * LAL_TWOPI / N)
00044 for(dec = (-N / 2 + (j = 0)) * LAL_PI / N; dec < LAL_PI_2; dec = (-N / 2 + ++j) * LAL_PI / N) {
00045 double fsquared = 1;
00046
00047 for(k = 0; k < detectors.n; k++) {
00048 double fp, fc;
00049 XLALComputeDetAMResponse(&fp, &fc, detectors.detector[k].response, ra, dec, 0, 0);
00050 fsquared *= fp * fp + fc * fc;
00051 }
00052
00053 integral += fsquared * sin(LAL_PI_2 + dec) * (LAL_PI / N) * (LAL_TWOPI / N);
00054 }
00055
00056 return integral / (4 * LAL_PI);
00057 }
00058
00059
00060 int main(int argc, char *argv[])
00061 {
00062 struct detectors detectors;
00063
00064 double ra = 2.0318570464121519;
00065 double dec = -0.50628171572274738;
00066
00067
00068
00069 int i;
00070
00071 detectors.n = 3;
00072 detectors.detector = malloc(detectors.n * sizeof(*detectors.detector));
00073
00074 detectors.detector[0] = lalCachedDetectors[LAL_LHO_4K_DETECTOR];
00075 detectors.detector[1] = lalCachedDetectors[LAL_LHO_2K_DETECTOR];
00076 detectors.detector[2] = lalCachedDetectors[LAL_LLO_4K_DETECTOR];
00077
00078 printf("\nAverage of product of (F+^2 + Fx^2)\n-----------------------------------\n");
00079 printf("\nDetectors: ");
00080 for(i = 0; i < detectors.n; i++)
00081 printf(" %s", detectors.detector[i].frDetector.prefix);
00082
00083 printf("\npoint source @ ra = %.16g, dec = %.16g:\n\t%.16g\n", ra, dec, point_source_average(detectors, ra, dec));
00084 printf("all sky:\n\t%.16g\n\n", all_sky_average(detectors));
00085
00086 return 0;
00087 }