20 #include <lal/LALStdlib.h>
21 #include <lal/LALConstants.h>
24 #include <lal/DetectorSite.h>
427 #define LAL_CAT(x,y) x ## y
428 #define LAL_XCAT(x,y) LAL_CAT(x,y)
431 #define LAL_DETECTOR_CONSTANT(d,c) LAL_XCAT(LAL_XCAT(LAL_,d),LAL_XCAT(_,c))
434 #define LAL_DETECTOR_LOCATION(d) \
436 LAL_DETECTOR_CONSTANT(d,VERTEX_LOCATION_X_SI),\
437 LAL_DETECTOR_CONSTANT(d,VERTEX_LOCATION_Y_SI),\
438 LAL_DETECTOR_CONSTANT(d,VERTEX_LOCATION_Z_SI) \
442 #define LAL_ARM_X(d,c) LAL_DETECTOR_CONSTANT(d,LAL_XCAT(ARM_X_DIRECTION_,c))
445 #define LAL_ARM_Y(d,c) LAL_DETECTOR_CONSTANT(d,LAL_XCAT(ARM_Y_DIRECTION_,c))
448 #define LAL_AXIS(d,c) LAL_DETECTOR_CONSTANT(d,LAL_XCAT(AXIS_DIRECTION_,c))
451 #define LAL_DETECTOR_RESPONSE_IFODIFF(d) \
454 0.5*( LAL_ARM_X(d,X) * LAL_ARM_X(d,X) - LAL_ARM_Y(d,X) * LAL_ARM_Y(d,X) ), \
455 0.5*( LAL_ARM_X(d,X) * LAL_ARM_X(d,Y) - LAL_ARM_Y(d,X) * LAL_ARM_Y(d,Y) ), \
456 0.5*( LAL_ARM_X(d,X) * LAL_ARM_X(d,Z) - LAL_ARM_Y(d,X) * LAL_ARM_Y(d,Z) ) \
459 0.5*( LAL_ARM_X(d,Y) * LAL_ARM_X(d,X) - LAL_ARM_Y(d,Y) * LAL_ARM_Y(d,X) ), \
460 0.5*( LAL_ARM_X(d,Y) * LAL_ARM_X(d,Y) - LAL_ARM_Y(d,Y) * LAL_ARM_Y(d,Y) ), \
461 0.5*( LAL_ARM_X(d,Y) * LAL_ARM_X(d,Z) - LAL_ARM_Y(d,Y) * LAL_ARM_Y(d,Z) ) \
464 0.5*( LAL_ARM_X(d,Z) * LAL_ARM_X(d,X) - LAL_ARM_Y(d,Z) * LAL_ARM_Y(d,X) ), \
465 0.5*( LAL_ARM_X(d,Z) * LAL_ARM_X(d,Y) - LAL_ARM_Y(d,Z) * LAL_ARM_Y(d,Y) ), \
466 0.5*( LAL_ARM_X(d,Z) * LAL_ARM_X(d,Z) - LAL_ARM_Y(d,Z) * LAL_ARM_Y(d,Z) ) \
471 #define LAL_DETECTOR_RESPONSE_IFOCOMM(d) \
474 0.5*( LAL_ARM_X(d,X) * LAL_ARM_X(d,X) + LAL_ARM_Y(d,X) * LAL_ARM_Y(d,X) ), \
475 0.5*( LAL_ARM_X(d,X) * LAL_ARM_X(d,Y) + LAL_ARM_Y(d,X) * LAL_ARM_Y(d,Y) ), \
476 0.5*( LAL_ARM_X(d,X) * LAL_ARM_X(d,Z) + LAL_ARM_Y(d,X) * LAL_ARM_Y(d,Z) ) \
479 0.5*( LAL_ARM_X(d,Y) * LAL_ARM_X(d,X) + LAL_ARM_Y(d,Y) * LAL_ARM_Y(d,X) ), \
480 0.5*( LAL_ARM_X(d,Y) * LAL_ARM_X(d,Y) + LAL_ARM_Y(d,Y) * LAL_ARM_Y(d,Y) ), \
481 0.5*( LAL_ARM_X(d,Y) * LAL_ARM_X(d,Z) + LAL_ARM_Y(d,Y) * LAL_ARM_Y(d,Z) ) \
484 0.5*( LAL_ARM_X(d,Z) * LAL_ARM_X(d,X) + LAL_ARM_Y(d,Z) * LAL_ARM_Y(d,X) ), \
485 0.5*( LAL_ARM_X(d,Z) * LAL_ARM_X(d,Y) + LAL_ARM_Y(d,Z) * LAL_ARM_Y(d,Y) ), \
486 0.5*( LAL_ARM_X(d,Z) * LAL_ARM_X(d,Z) + LAL_ARM_Y(d,Z) * LAL_ARM_Y(d,Z) ) \
491 #define LAL_DETECTOR_RESPONSE_IFOXARM(d) \
494 0.5 * LAL_ARM_X(d,X) * LAL_ARM_X(d,X), \
495 0.5 * LAL_ARM_X(d,X) * LAL_ARM_X(d,Y), \
496 0.5 * LAL_ARM_X(d,X) * LAL_ARM_X(d,Z) \
499 0.5 * LAL_ARM_X(d,Y) * LAL_ARM_X(d,X), \
500 0.5 * LAL_ARM_X(d,Y) * LAL_ARM_X(d,Y), \
501 0.5 * LAL_ARM_X(d,Y) * LAL_ARM_X(d,Z) \
504 0.5 * LAL_ARM_X(d,Z) * LAL_ARM_X(d,X), \
505 0.5 * LAL_ARM_X(d,Z) * LAL_ARM_X(d,Y), \
506 0.5 * LAL_ARM_X(d,Z) * LAL_ARM_X(d,Z) \
511 #define LAL_DETECTOR_RESPONSE_IFOYARM(d) \
514 0.5 * LAL_ARM_Y(d,X) * LAL_ARM_Y(d,X), \
515 0.5 * LAL_ARM_Y(d,X) * LAL_ARM_Y(d,Y), \
516 0.5 * LAL_ARM_Y(d,X) * LAL_ARM_Y(d,Z) \
519 0.5 * LAL_ARM_Y(d,Y) * LAL_ARM_Y(d,X), \
520 0.5 * LAL_ARM_Y(d,Y) * LAL_ARM_Y(d,Y), \
521 0.5 * LAL_ARM_Y(d,Y) * LAL_ARM_Y(d,Z) \
524 0.5 * LAL_ARM_Y(d,Z) * LAL_ARM_Y(d,X), \
525 0.5 * LAL_ARM_Y(d,Z) * LAL_ARM_Y(d,Y), \
526 0.5 * LAL_ARM_Y(d,Z) * LAL_ARM_Y(d,Z) \
531 #define LAL_DETECTOR_RESPONSE_CYLBAR(d) \
534 LAL_AXIS(d,X) * LAL_AXIS(d,X), \
535 LAL_AXIS(d,X) * LAL_AXIS(d,Y), \
536 LAL_AXIS(d,X) * LAL_AXIS(d,Z) \
539 LAL_AXIS(d,Y) * LAL_AXIS(d,X), \
540 LAL_AXIS(d,Y) * LAL_AXIS(d,Y), \
541 LAL_AXIS(d,Y) * LAL_AXIS(d,Z) \
544 LAL_AXIS(d,Z) * LAL_AXIS(d,X), \
545 LAL_AXIS(d,Z) * LAL_AXIS(d,Y), \
546 LAL_AXIS(d,Z) * LAL_AXIS(d,Z) \
550 #define LAL_FR_STREAM_DETECTOR_STRUCT(d) \
552 LAL_DETECTOR_CONSTANT(d,DETECTOR_NAME), \
553 LAL_DETECTOR_CONSTANT(d,DETECTOR_PREFIX), \
554 LAL_DETECTOR_CONSTANT(d,DETECTOR_LONGITUDE_RAD), \
555 LAL_DETECTOR_CONSTANT(d,DETECTOR_LATITUDE_RAD), \
556 LAL_DETECTOR_CONSTANT(d,DETECTOR_ELEVATION_SI), \
557 LAL_DETECTOR_CONSTANT(d,DETECTOR_ARM_X_ALTITUDE_RAD), \
558 LAL_DETECTOR_CONSTANT(d,DETECTOR_ARM_X_AZIMUTH_RAD), \
559 LAL_DETECTOR_CONSTANT(d,DETECTOR_ARM_Y_ALTITUDE_RAD), \
560 LAL_DETECTOR_CONSTANT(d,DETECTOR_ARM_Y_AZIMUTH_RAD), \
561 LAL_DETECTOR_CONSTANT(d,DETECTOR_ARM_X_MIDPOINT_SI), \
562 LAL_DETECTOR_CONSTANT(d,DETECTOR_ARM_Y_MIDPOINT_SI) \
565 #define LAL_DETECTOR_RESPONSE(d,t) \
566 LAL_XCAT( LAL_DETECTOR_RESPONSE_, t )(d)
568 #define LAL_DETECTOR_STRUCT(d,t) \
570 LAL_DETECTOR_LOCATION(d), \
571 LAL_DETECTOR_RESPONSE(d,t), \
572 LAL_XCAT(LALDETECTORTYPE_,t), \
573 LAL_FR_STREAM_DETECTOR_STRUCT(d) \
608 REAL8 uNorth = cosAlt * cosAz;
609 REAL8 uEast = cosAlt * sinAz;
611 REAL8 uRho = - sinLat * uNorth + cosLat * sinAlt;
614 #if LALDETECTORSH_PRINTF
615 printf(
"uNorth = %g\n",uNorth);
616 printf(
"uEast = %g\n",uEast);
617 printf(
"uUp = %g\n",sinAlt);
618 printf(
"uRho = %g\n",uRho);
621 u[0] = cosLon * uRho - sinLon * uEast;
622 u[1] = sinLon * uRho + cosLon * uEast;
623 u[2] = cosLat * uNorth + sinLat * sinAlt;
635 REAL8 latRad, lonRad;
636 REAL8 cosLat, sinLat, cosLon, sinLon;
637 REAL8 locationRho, ellipsoidalDenominator;
638 REAL4 xArm[3], yArm[3];
643 detector =
LALCalloc( 1,
sizeof( *detector ) );
652 detector->
type = type;
660 detectorPtr < detectorStopPtr;
663 if ( type == detectorPtr->
type
668 *detector = *detectorPtr;
678 #if LALDETECTORSH_PRINTF
679 printf(
"LAT = %g radians, LON = %g radians\n", latRad, lonRad);
682 cosLat = cos(latRad); sinLat = sin(latRad);
683 #if LALDETECTORSH_PRINTF
684 printf(
"cos(LAT) = %g, sin(LAT) = %g\n", cosLat, sinLat);
686 cosLon = cos(lonRad); sinLon = sin(lonRad);
687 #if LALDETECTORSH_PRINTF
688 printf(
"cos(LON) = %g, sin(LON) = %g\n", cosLon, sinLon);
693 * (sinLat * sinLat) );
698 detector->
location[0] = locationRho * cosLon;
699 detector->
location[1] = locationRho * sinLon;
704 #if LALDETECTORSH_PRINTF
715 cosLat, sinLat, cosLon, sinLon );
717 #if LALDETECTORSH_PRINTF
718 printf(
"xArm = (%g, %g, %g)\n", xArm[0], xArm[1], xArm[2]);
729 cosLat, sinLat, cosLon, sinLon );
731 #if LALDETECTORSH_PRINTF
732 printf(
"yArm = (%g, %g, %g)\n", yArm[0], yArm[1], yArm[2]);
740 for ( i=0; i<3; ++i )
743 = ( xArm[i] * xArm[i] - yArm[i] * yArm[i] ) / 2;
744 for ( j=i+1; j<3; ++j )
747 = ( xArm[i] * xArm[j] - yArm[i] * yArm[j] ) / 2;
752 for ( i=0; i<3; ++i )
755 = ( xArm[i] * xArm[i] ) / 2;
756 for ( j=i+1; j<3; ++j )
759 = ( xArm[i] * xArm[j] ) / 2;
764 for ( i=0; i<3; ++i )
767 = ( yArm[i] * yArm[i] ) / 2;
768 for ( j=i+1; j<3; ++j )
771 = ( yArm[i] * yArm[j] ) / 2;
776 for ( i=0; i<3; ++i )
779 = ( xArm[i] * xArm[i] + yArm[i] * yArm[i] ) / 2;
780 for ( j=i+1; j<3; ++j )
783 = ( xArm[i] * xArm[j] + yArm[i] * yArm[j] ) / 2;
788 for ( i=0; i<3; ++i )
792 for ( j=i+1; j<3; ++j )
804 detector->
type = type;
LALDetector * XLALCreateDetector(LALDetector *detector, const LALFrDetector *frDetector, LALDetectorType type)
UNDOCUMENTED.
static void getCartesianComponents(REAL4 u[3], REAL8 cosAlt, REAL8 sinAlt, REAL8 cosAz, REAL8 sinAz, REAL8 cosLat, REAL8 sinLat, REAL8 cosLon, REAL8 sinLon)
const LALDetector lalCachedDetectors[LAL_NUM_DETECTORS]
Pre-existing detectors.
#define LAL_DETECTOR_STRUCT(d, t)
#define LAL_BWGS84_SI
Semiminor axis of WGS-84 Reference Ellipsoid, m.
#define LAL_AWGS84_SI
Semimajor axis of WGS-84 Reference Ellipsoid, m.
double REAL8
Double precision real floating-point number (8 bytes).
int16_t INT2
Two-byte signed integer.
float REAL4
Single precision real floating-point number (4 bytes).
LALDetectorType
Detector type, which determines how the detector response is determined.
@ LALDETECTORTYPE_CYLBAR
Cylindrical bar.
@ LALDETECTORTYPE_IFOCOMM
IFO in common mode.
@ LALDETECTORTYPE_IFOYARM
IFO in one-armed mode (Y arm)
@ LALDETECTORTYPE_IFOXARM
IFO in one-armed mode (X arm)
@ LALDETECTORTYPE_IFODIFF
IFO in differential mode.
#define XLAL_ERROR_NULL(...)
Macro to invoke a failure from a XLAL routine returning a pointer.
@ XLAL_ENOMEM
Memory allocation error.
@ XLAL_EINVAL
Invalid argument.
REAL4 response[3][3]
The Earth-fixed Cartesian components of the detector's response tensor .
LALDetectorType type
The type of the detector (e.g., IFO in differential mode, cylindrical bar, etc.)
REAL8 location[3]
The three components, in an Earth-fixed Cartesian coordinate system, of the position vector from the ...
LALFrDetector frDetector
The original LALFrDetector structure from which this was created.
Detector frame data structure Structure to contain the data that appears in a FrDetector structure in...
REAL8 vertexLongitudeRadians
The geodetic longitude of the vertex in radians.
REAL8 vertexLatitudeRadians
The geodetic latitude of the vertex in radians.
REAL4 vertexElevation
The height of the vertex above the reference ellipsoid in meters.
REAL4 xArmAzimuthRadians
The angle clockwise from North to the projection of the X arm (or bar's cylidrical axis) into the lo...
REAL4 yArmAltitudeRadians
The angle up from the local tangent plane of the reference ellipsoid to the Y arm in radians (unused...
REAL4 yArmAzimuthRadians
The angle clockwise from North to the projection of the Y arm into the local tangent plane of the re...
REAL4 xArmAltitudeRadians
The angle up from the local tangent plane of the reference ellipsoid to the X arm (or bar's cylidric...
CHAR name[LALNameLength]
A unique identifying string.