src/correlation/photon_gn.c
photon_gn_t *photon_gn_alloc(int const mode, int const order, 
		int const channels, size_t const queue_size,
		limits_t const *time_limits, limits_t const *pulse_limits) {
	photon_gn_t *gn = NULL;
	long long min_time_distance, max_time_distance;
	long long min_pulse_distance, max_pulse_distance;

	gn = (photon_gn_t *)malloc(sizeof(photon_gn_t));

	if ( gn == NULL ) {
		return(gn);
	}

	min_time_distance = time_limits->lower < 0 ? 0 :
			(long long)floor(time_limits->lower);
	max_time_distance = (long long)ceil(
			max(fabs(time_limits->lower), fabs(time_limits->upper)));
	min_pulse_distance = pulse_limits->lower < 0 ? 0 :
			(long long)floor(pulse_limits->lower);
	max_pulse_distance = (long long)ceil(
			max(fabs(pulse_limits->lower), fabs(pulse_limits->upper)));

	debug("Limits: time: (%lld, %lld); pulse: (%lld, %lld)\n",
			min_time_distance, max_time_distance,
			min_pulse_distance, max_pulse_distance);

	gn->correlator = correlator_alloc(mode, order, 
			queue_size, false,
			min_time_distance, max_time_distance,
			min_pulse_distance, max_pulse_distance);
	gn->histogram = histogram_gn_alloc(mode, order, channels,
			SCALE_LINEAR, time_limits,
			SCALE_LINEAR, pulse_limits);

	if ( gn->correlator == NULL || gn->histogram == NULL ) {
		photon_gn_free(&gn);
		return(gn);
	}

	return(gn);
}
/* 
 * For correlation we typically need to join several operations together.
 * At minimum, we must send the photons to the correlator and the correlations
 * to the histogrammer, but for diagnostic purposes it is often desirable
 * to send photons to an intensity measurement or other routine. As such, this
 * procedure is meant to push photons to all of the different measurements
 * desired, such that a single pass through the stream is sufficient for 
 * performing all calculations. This in principle enables real-time processing
 * but in practice just makes the whole act of processing simpler.
 */
For correlation we typically need to join several operations together.
At minimum, we must send the photons to the correlator and the correlations
to the histogrammer, but for diagnostic purposes it is often desirable
to send photons to an intensity measurement or other routine. As such, this
procedure is meant to push photons to all of the different measurements
desired, such that a single pass through the stream is sufficient for
performing all calculations. This in principle enables real-time processing
but in practice just makes the whole act of processing simpler.
For correlation we typically need to join several operations together . At minimum we must send the photons to the correlator and the correlations to the histogrammer but for diagnostic purposes it is often desirable to send photons to an intensity measurement or other routine . As such this procedure is meant to push photons to all of the different measurements desired such that a single pass through the stream is sufficient for performing all calculations . This in principle enables real - time processing but in practice just makes the whole act of processing simpler .
photon_gn_t *photon_gn_alloc(int const mode, int const order, 
		int const channels, size_t const queue_size,
		limits_t const *time_limits, limits_t const *pulse_limits) {
	photon_gn_t *gn = NULL;
	long long min_time_distance, max_time_distance;
	long long min_pulse_distance, max_pulse_distance;
	gn = (photon_gn_t *)malloc(sizeof(photon_gn_t));
	if ( gn == NULL ) {
		return(gn);
	}
	min_time_distance = time_limits->lower < 0 ? 0 :
			(long long)floor(time_limits->lower);
	max_time_distance = (long long)ceil(
			max(fabs(time_limits->lower), fabs(time_limits->upper)));
	min_pulse_distance = pulse_limits->lower < 0 ? 0 :
			(long long)floor(pulse_limits->lower);
	max_pulse_distance = (long long)ceil(
			max(fabs(pulse_limits->lower), fabs(pulse_limits->upper)));
	debug("Limits: time: (%lld, %lld); pulse: (%lld, %lld)\n",
			min_time_distance, max_time_distance,
			min_pulse_distance, max_pulse_distance);
	gn->correlator = correlator_alloc(mode, order, 
			queue_size, false,
			min_time_distance, max_time_distance,
			min_pulse_distance, max_pulse_distance);
	gn->histogram = histogram_gn_alloc(mode, order, channels,
			SCALE_LINEAR, time_limits,
			SCALE_LINEAR, pulse_limits);
	if ( gn->correlator == NULL || gn->histogram == NULL ) {
		photon_gn_free(&gn);
		return(gn);
	}
	return(gn);
}
photon_gn_t * photon_gn_alloc ( int const mode , int const order , int const channels , size_t const queue_size , limits_t const * time_limits , limits_t const * pulse_limits ) { photon_gn_t * gn = NULL ; long long min_time_distance , max_time_distance ; long long min_pulse_distance , max_pulse_distance ; gn = ( photon_gn_t * ) malloc ( sizeof ( photon_gn_t ) ) ; if ( gn == NULL ) { return ( gn ) ; } min_time_distance = time_limits -> lower < 0 ? 0 : ( long long ) floor ( time_limits -> lower ) ; max_time_distance = ( long long ) ceil ( max ( fabs ( time_limits -> lower ) , fabs ( time_limits -> upper ) ) ) ; min_pulse_distance = pulse_limits -> lower < 0 ? 0 : ( long long ) floor ( pulse_limits -> lower ) ; max_pulse_distance = ( long long ) ceil ( max ( fabs ( pulse_limits -> lower ) , fabs ( pulse_limits -> upper ) ) ) ; debug ( " \n " , min_time_distance , max_time_distance , min_pulse_distance , max_pulse_distance ) ; gn -> correlator = correlator_alloc ( mode , order , queue_size , false , min_time_distance , max_time_distance , min_pulse_distance , max_pulse_distance ) ; gn -> histogram = histogram_gn_alloc ( mode , order , channels , SCALE_LINEAR , time_limits , SCALE_LINEAR , pulse_limits ) ; if ( gn -> correlator == NULL || gn -> histogram == NULL ) { photon_gn_free ( & gn ) ; return ( gn ) ; } return ( gn ) ; }
For correlation we typically need to join several operations together.
For correlation we typically need to join several operations together .