// File: /workspace/github_cpp_makefile_star2_O3/kebwi[P]Trifid/src/ImageProcs.cpp
// Function: luxToPPFD(double, double, double, double, double)
Float_t luxToPPFD(
	Float_t lux,
	Float_t lensFocalLength,	//Unused in the current PPFD calculation, remnant of an earlier version
	Float_t lensFnumber,
	Float_t pixelPitchMicrons,
	Float_t fullWellCapacity
)
{
	cout.precision(15);
	
	cout << setw(40) << left << "  lux:" << lux << endl;
	Float_t luxAfterLensTransmission = lux * .9;
	cout << setw(40) << left << "  luxAfterLensTransmission:" << luxAfterLensTransmission << endl;
	cout << setw(40) << left << "  lensFnumber:" << lensFnumber << endl;
	Float_t luxAtImagePlane = luxAfterLensTransmission / pow(lensFnumber, 2);
	cout << setw(40) << left << "  luxAtImagePlane:" << luxAtImagePlane << endl;
	Float_t photoSensitivePixelPitchMicrons = pixelPitchMicrons - .25;	// half of a .5u width dead zone between pixels
	cout << setw(40) << left << "  photoSensitivePixelPitchMicrons:" << photoSensitivePixelPitchMicrons << endl;
	Float_t photoSensitivePixelAreaM = pow((photoSensitivePixelPitchMicrons / 1000000), 2);
	cout << setw(40) << left << "  photoSensitivePixelAreaM:" << photoSensitivePixelAreaM << endl;
	Float_t lumensPerPixel = luxAtImagePlane * photoSensitivePixelAreaM;
	cout << setw(40) << left << "  lumensPerPixel:" << lumensPerPixel << endl;
	Float_t ppfdPerPixel = lumensPerPixel * .0185;
	cout << setw(40) << left << "  ppfdPerPixel:" << ppfdPerPixel << endl;
	Float_t photonsPerPixelPerSec = ppfdPerPixel * 6.0221415e17;
	cout << setw(40) << left << "  photonsPerPixelPerSec:" << photonsPerPixelPerSec << endl;
	
	Float_t saturationTime = fullWellCapacity / photonsPerPixelPerSec;
	cout << setw(40) << left << "  saturationTime at 100% reflectance:" << saturationTime << endl;
	
	cout.precision(6);
	return photonsPerPixelPerSec;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x28, %rsp
movsd %xmm4, 0x18(%rsp)
movsd %xmm3, 0x8(%rsp)
movsd %xmm2, 0x20(%rsp)
movsd %xmm0, 0x10(%rsp)
movq 0x233f1(%rip), %rbx     # 0x36fd0
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movq $0xf, 0x8(%rbx,%rcx)
movq -0x18(%rax), %rcx
movl $0x28, %r15d
movq %r15, 0x10(%rbx,%rcx)
movq -0x18(%rax), %rax
movl $0xffffff4f, %ebp       # imm = 0xFFFFFF4F
movl 0x18(%rbx,%rax), %ecx
andl %ebp, %ecx
orl $0x20, %ecx
movl %ecx, 0x18(%rbx,%rax)
leaq 0x1832b(%rip), %rsi     # 0x2bf46
movl $0x6, %edx
movq %rbx, %rdi
callq 0x3360
movq %rbx, %rdi
movsd 0x10(%rsp), %xmm0
callq 0x3480
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31f0
movsd 0x10(%rsp), %xmm0
mulsd 0x17f9a(%rip), %xmm0    # 0x2bc08
movsd %xmm0, 0x10(%rsp)
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movq %r15, 0x10(%rbx,%rcx)
movq -0x18(%rax), %rax
movl 0x18(%rbx,%rax), %ecx
andl %ebp, %ecx
orl $0x20, %ecx
movl %ecx, 0x18(%rbx,%rax)
leaq 0x182b5(%rip), %rsi     # 0x2bf4d
movl $0x1b, %edx
movq %rbx, %rdi
callq 0x3360
movq %rbx, %rdi
movsd 0x10(%rsp), %xmm0
callq 0x3480
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31f0
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movq %r15, 0x10(%rbx,%rcx)
movq -0x18(%rax), %rax
movl 0x18(%rbx,%rax), %ecx
andl %ebp, %ecx
orl $0x20, %ecx
movl %ecx, 0x18(%rbx,%rax)
leaq 0x18268(%rip), %rsi     # 0x2bf69
movl $0xe, %edx
movq %rbx, %rdi
callq 0x3360
movq %rbx, %rdi
movsd 0x20(%rsp), %xmm0
callq 0x3480
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31f0
movsd 0x20(%rsp), %xmm1
mulsd %xmm1, %xmm1
movsd 0x10(%rsp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movq %r15, 0x10(%rbx,%rcx)
movq -0x18(%rax), %rax
movl 0x18(%rbx,%rax), %ecx
andl %ebp, %ecx
orl $0x20, %ecx
movl %ecx, 0x18(%rbx,%rax)
leaq 0x181f4(%rip), %rsi     # 0x2bf78
movl $0x12, %edx
movq %rbx, %rdi
callq 0x3360
movq %rbx, %rdi
movsd 0x10(%rsp), %xmm0
callq 0x3480
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31f0
movsd 0x8(%rsp), %xmm0
addsd 0x17e39(%rip), %xmm0    # 0x2bc10
movsd %xmm0, 0x8(%rsp)
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movq %r15, 0x10(%rbx,%rcx)
movq -0x18(%rax), %rax
movl 0x18(%rbx,%rax), %ecx
andl %ebp, %ecx
orl $0x20, %ecx
movl %ecx, 0x18(%rbx,%rax)
leaq 0x1818a(%rip), %rsi     # 0x2bf8b
movl $0x22, %edx
movq %rbx, %rdi
callq 0x3360
movq %rbx, %rdi
movsd 0x8(%rsp), %xmm0
callq 0x3480
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31f0
movsd 0x8(%rsp), %xmm0
divsd 0x17dc4(%rip), %xmm0    # 0x2bc18
mulsd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movq %r15, 0x10(%rbx,%rcx)
movq -0x18(%rax), %rax
movl 0x18(%rbx,%rax), %ecx
andl %ebp, %ecx
orl $0x20, %ecx
movl %ecx, 0x18(%rbx,%rax)
leaq 0x1812c(%rip), %rsi     # 0x2bfae
movl $0x1b, %edx
movq %rbx, %rdi
callq 0x3360
movq %rbx, %rdi
movsd 0x8(%rsp), %xmm0
callq 0x3480
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31f0
movsd 0x8(%rsp), %xmm0
mulsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movq %r15, 0x10(%rbx,%rcx)
movq -0x18(%rax), %rax
movl 0x18(%rbx,%rax), %ecx
andl %ebp, %ecx
orl $0x20, %ecx
movl %ecx, 0x18(%rbx,%rax)
leaq 0x180cd(%rip), %rsi     # 0x2bfca
movl $0x11, %edx
movq %rbx, %rdi
callq 0x3360
movq %rbx, %rdi
movsd 0x8(%rsp), %xmm0
callq 0x3480
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31f0
movsd 0x8(%rsp), %xmm0
mulsd 0x17cd0(%rip), %xmm0    # 0x2bc20
movsd %xmm0, 0x8(%rsp)
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movq %r15, 0x10(%rbx,%rcx)
movq -0x18(%rax), %rax
movl 0x18(%rbx,%rax), %ecx
andl %ebp, %ecx
orl $0x20, %ecx
movl %ecx, 0x18(%rbx,%rax)
leaq 0x18062(%rip), %rsi     # 0x2bfdc
movl $0xf, %edx
movq %rbx, %rdi
callq 0x3360
movq %rbx, %rdi
movsd 0x8(%rsp), %xmm0
callq 0x3480
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31f0
movsd 0x8(%rsp), %xmm0
mulsd 0x17c5b(%rip), %xmm0    # 0x2bc28
movsd %xmm0, 0x8(%rsp)
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movq %r15, 0x10(%rbx,%rcx)
movq -0x18(%rax), %rax
movl 0x18(%rbx,%rax), %ecx
andl %ebp, %ecx
orl $0x20, %ecx
movl %ecx, 0x18(%rbx,%rax)
leaq 0x17ff5(%rip), %rsi     # 0x2bfec
movl $0x18, %edx
movq %rbx, %rdi
callq 0x3360
movq %rbx, %rdi
movsd 0x8(%rsp), %xmm0
callq 0x3480
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31f0
movsd 0x18(%rsp), %xmm0
divsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movq %r15, 0x10(%rbx,%rcx)
movq -0x18(%rax), %rax
andl 0x18(%rbx,%rax), %ebp
orl $0x20, %ebp
movl %ebp, 0x18(%rbx,%rax)
leaq 0x17f95(%rip), %rsi     # 0x2c005
movl $0x25, %edx
movq %rbx, %rdi
callq 0x3360
movq %rbx, %rdi
movsd 0x18(%rsp), %xmm0
callq 0x3480
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31f0
movq (%rbx), %rax
movq -0x18(%rax), %rax
movq $0x6, 0x8(%rbx,%rax)
movsd 0x8(%rsp), %xmm0
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq