// File: 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
movq %rsp, %rbp
subq $0xc0, %rsp
movsd %xmm0, -0x8(%rbp)
movsd %xmm1, -0x10(%rbp)
movsd %xmm2, -0x18(%rbp)
movsd %xmm3, -0x20(%rbp)
movsd %xmm4, -0x28(%rbp)
movq 0x3a085(%rip), %rax     # 0x59fd0
movq (%rax), %rax
movq 0x3a07b(%rip), %rdi     # 0x59fd0
addq -0x18(%rax), %rdi
movl $0xf, %esi
callq 0xf310
movl $0x28, %edi
callq 0xe410
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %esi
movq 0x3a056(%rip), %rdi     # 0x59fd0
callq 0x4430
movq %rax, %rdi
leaq -0x11b59(%rip), %rsi    # 0xe430
callq 0x4110
movq %rax, %rdi
leaq 0x2b01e(%rip), %rsi     # 0x4afb6
callq 0x4390
movq %rax, %rdi
movsd -0x8(%rbp), %xmm0
callq 0x4670
movq %rax, %rdi
movq 0x3a004(%rip), %rsi     # 0x59fb8
callq 0x43d0
movsd 0x2acff(%rip), %xmm0    # 0x4acc0
mulsd -0x8(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movl $0x28, %edi
callq 0xe410
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %esi
movq 0x39fee(%rip), %rdi     # 0x59fd0
callq 0x4430
movq %rax, %rdi
leaq -0x11bc1(%rip), %rsi    # 0xe430
callq 0x4110
movq %rax, %rdi
leaq 0x2afbd(%rip), %rsi     # 0x4afbd
callq 0x4390
movq %rax, %rdi
movsd -0x38(%rbp), %xmm0
callq 0x4670
movq %rax, %rdi
movq 0x39f9c(%rip), %rsi     # 0x59fb8
callq 0x43d0
movl $0x28, %edi
callq 0xe410
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %esi
movq 0x39f98(%rip), %rdi     # 0x59fd0
callq 0x4430
movq %rax, %rdi
leaq -0x11c17(%rip), %rsi    # 0xe430
callq 0x4110
movq %rax, %rdi
leaq 0x2af83(%rip), %rsi     # 0x4afd9
callq 0x4390
movq %rax, %rdi
movsd -0x18(%rbp), %xmm0
callq 0x4670
movq %rax, %rdi
movq 0x39f46(%rip), %rsi     # 0x59fb8
callq 0x43d0
movsd -0x38(%rbp), %xmm0
movsd %xmm0, -0xb8(%rbp)
movsd -0x18(%rbp), %xmm0
movl $0x2, %edi
callq 0x258f0
movaps %xmm0, %xmm1
movsd -0xb8(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movl $0x28, %edi
callq 0xe410
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %esi
movq 0x39f12(%rip), %rdi     # 0x59fd0
callq 0x4430
movq %rax, %rdi
leaq -0x11c9d(%rip), %rsi    # 0xe430
callq 0x4110
movq %rax, %rdi
leaq 0x2af0c(%rip), %rsi     # 0x4afe8
callq 0x4390
movq %rax, %rdi
movsd -0x48(%rbp), %xmm0
callq 0x4670
movq %rax, %rdi
movq 0x39ec0(%rip), %rsi     # 0x59fb8
callq 0x43d0
movsd -0x20(%rbp), %xmm0
movsd 0x2ab96(%rip), %xmm1    # 0x4aca0
subsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
movl $0x28, %edi
callq 0xe410
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %esi
movq 0x39ea6(%rip), %rdi     # 0x59fd0
callq 0x4430
movq %rax, %rdi
leaq -0x11d09(%rip), %rsi    # 0xe430
callq 0x4110
movq %rax, %rdi
leaq 0x2aeb3(%rip), %rsi     # 0x4affb
callq 0x4390
movq %rax, %rdi
movsd -0x58(%rbp), %xmm0
callq 0x4670
movq %rax, %rdi
movq 0x39e54(%rip), %rsi     # 0x59fb8
callq 0x43d0
movsd -0x58(%rbp), %xmm0
movsd 0x2ab42(%rip), %xmm1    # 0x4acb8
divsd %xmm1, %xmm0
movl $0x2, %edi
callq 0x258f0
movsd %xmm0, -0x68(%rbp)
movl $0x28, %edi
callq 0xe410
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %esi
movq 0x39e30(%rip), %rdi     # 0x59fd0
callq 0x4430
movq %rax, %rdi
leaq -0x11d7f(%rip), %rsi    # 0xe430
callq 0x4110
movq %rax, %rdi
leaq 0x2ae60(%rip), %rsi     # 0x4b01e
callq 0x4390
movq %rax, %rdi
movsd -0x68(%rbp), %xmm0
callq 0x4670
movq %rax, %rdi
movq 0x39dde(%rip), %rsi     # 0x59fb8
callq 0x43d0
movsd -0x48(%rbp), %xmm0
mulsd -0x68(%rbp), %xmm0
movsd %xmm0, -0x78(%rbp)
movl $0x28, %edi
callq 0xe410
movl %eax, -0x7c(%rbp)
movl -0x7c(%rbp), %esi
movq 0x39dcb(%rip), %rdi     # 0x59fd0
callq 0x4430
movq %rax, %rdi
leaq -0x11de4(%rip), %rsi    # 0xe430
callq 0x4110
movq %rax, %rdi
leaq 0x2ae17(%rip), %rsi     # 0x4b03a
callq 0x4390
movq %rax, %rdi
movsd -0x78(%rbp), %xmm0
callq 0x4670
movq %rax, %rdi
movq 0x39d79(%rip), %rsi     # 0x59fb8
callq 0x43d0
movsd 0x2aa64(%rip), %xmm0    # 0x4acb0
mulsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
movl $0x28, %edi
callq 0xe410
movl %eax, -0x8c(%rbp)
movl -0x8c(%rbp), %esi
movq 0x39d5a(%rip), %rdi     # 0x59fd0
callq 0x4430
movq %rax, %rdi
leaq -0x11e55(%rip), %rsi    # 0xe430
callq 0x4110
movq %rax, %rdi
leaq 0x2adb8(%rip), %rsi     # 0x4b04c
callq 0x4390
movq %rax, %rdi
movsd -0x88(%rbp), %xmm0
callq 0x4670
movq %rax, %rdi
movq 0x39d05(%rip), %rsi     # 0x59fb8
callq 0x43d0
movsd 0x2a9e8(%rip), %xmm0    # 0x4aca8
mulsd -0x88(%rbp), %xmm0
movsd %xmm0, -0x98(%rbp)
movl $0x28, %edi
callq 0xe410
movl %eax, -0x9c(%rbp)
movl -0x9c(%rbp), %esi
movq 0x39ce3(%rip), %rdi     # 0x59fd0
callq 0x4430
movq %rax, %rdi
leaq -0x11ecc(%rip), %rsi    # 0xe430
callq 0x4110
movq %rax, %rdi
leaq 0x2ad51(%rip), %rsi     # 0x4b05c
callq 0x4390
movq %rax, %rdi
movsd -0x98(%rbp), %xmm0
callq 0x4670
movq %rax, %rdi
movq 0x39c8e(%rip), %rsi     # 0x59fb8
callq 0x43d0
movsd -0x28(%rbp), %xmm0
divsd -0x98(%rbp), %xmm0
movsd %xmm0, -0xa8(%rbp)
movl $0x28, %edi
callq 0xe410
movl %eax, -0xac(%rbp)
movl -0xac(%rbp), %esi
movq 0x39c6f(%rip), %rdi     # 0x59fd0
callq 0x4430
movq %rax, %rdi
leaq -0x11f40(%rip), %rsi    # 0xe430
callq 0x4110
movq %rax, %rdi
leaq 0x2acf6(%rip), %rsi     # 0x4b075
callq 0x4390
movq %rax, %rdi
movsd -0xa8(%rbp), %xmm0
callq 0x4670
movq %rax, %rdi
movq 0x39c1a(%rip), %rsi     # 0x59fb8
callq 0x43d0
movq 0x39c26(%rip), %rax     # 0x59fd0
movq (%rax), %rax
movq 0x39c1c(%rip), %rdi     # 0x59fd0
addq -0x18(%rax), %rdi
movl $0x6, %esi
callq 0xf310
movsd -0x98(%rbp), %xmm0
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)