Lab moderna: add p14 R script
Change-Id: If7c1358de4b3738f52cc4da462dae6a19fa348f5
diff --git a/quad12/labmoderna/p14/data.txt b/quad12/labmoderna/p14/data.txt
new file mode 100644
index 0000000..cb8951e
--- /dev/null
+++ b/quad12/labmoderna/p14/data.txt
@@ -0,0 +1,92 @@
+Longitud VSenseMostra VA VB
+800 3.103 0.00048 0.00121
+805 3.193 0.00049 0.00124
+810 3.281 0.00049 0.00127
+815 3.383 0.0005 0.00106
+820 3.487 0.00051 0.00115
+825 3.602 0.00051 0.00109
+830 3.712 0.00052 0.00118
+835 3.861 0.00053 0.00119
+840 3.995 0.00055 0.00121
+845 4.161 0.00056 0.00104
+850 4.329 0.00058 0.00099
+855 4.522 0.00061 0.001
+860 4.736 0.00063 0.001
+865 4.944 0.00069 0.001
+870 5.146 0.00079 0.00099
+875 5.371 0.00111 0.00098
+880 5.6 0.00883 0.00108
+885 5.841 0.11948 0.00108
+890 6.137 0.33096 0.00108
+895 6.381 0.57896 0.00101
+900 6.732 0.67296 0.00104
+905 7.016 0.71896 0.00105
+910 7.234 0.75896 0.00116
+915 7.504 0.79296 0.00116
+920 7.764 0.82796 0.00118
+925 8.058 0.86096 0.00122
+930 8.311 0.89596 0.00125
+935 8.565 0.92396 0.00136
+940 8.779 0.95396 0.00149
+945 9.034 0.98596 0.00177
+950 9.153 1.02296 0.00214
+955 9.401 1.04996 0.00297
+960 9.676 1.08096 0.00442
+965 9.903 1.11096 0.00643
+970 10.219 1.14996 0.01053
+975 10.433 1.17496 0.0156
+980 10.564 1.19596 0.02481
+985 10.629 1.20496 0.03544
+990 10.634 1.20996 0.05124
+995 10.597 1.20496 0.07234
+1000 10.507 1.20196 0.10012
+1005 10.491 1.18796 0.13594
+1010 10.285 1.17296 0.17823
+1015 10.023 1.14896 0.22896
+1020 9.702 1.11496 0.28796
+1025 9.311 1.07096 0.35596
+1030 8.927 1.02296 0.41896
+1035 8.422 0.97196 0.50196
+1040 7.818 0.90396 0.55796
+1045 7.289 0.81996 0.63596
+1050 6.71 0.75896 0.67096
+1055 6.037 0.69696 0.69796
+1060 5.402 0.61496 0.70596
+1065 4.929 0.54896 0.69596
+1070 4.595 0.50696 0.68096
+1075 4.142 0.46096 0.65896
+1080 3.856 0.42696 0.63296
+1085 3.589 0.38896 0.60496
+1090 3.258 0.35396 0.57296
+1095 2.986 0.31496 0.53396
+1100 2.735 0.28296 0.49696
+1105 2.513 0.25896 0.46096
+1110 2.304 0.23296 0.42996
+1115 2.1 0.20396 0.38696
+1120 1.912 0.18396 0.35096
+1125 1.743 0.15896 0.31696
+1130 1.583 0.13796 0.28196
+1135 1.43 0.12096 0.24696
+1140 1.3 0.10496 0.21296
+1145 1.174 0.08596 0.17796
+1150 1.062 0.07196 0.15196
+1155 0.969 0.05796 0.12196
+1160 0.871 0.04396 0.09596
+1165 0.803 0.03296 0.07196
+1170 0.731 0.02396 0.05396
+1175 0.672 0.01296 0.02796
+1180 0.636 0.00738 0.01596
+1185 0.634 0.00509 0.01096
+1190 0.638 0.00389 0.00849
+1195 0.646 0.00327 0.00726
+1200 0.652 0.00262 0.00604
+1205 0.661 0.00218 0.00506
+1210 0.669 0.0018 0.00426
+1215 0.678 0.00158 0.0036
+1220 0.69 0.00136 0.00318
+1225 0.699 0.0012 0.00274
+1230 0.707 0.00107 0.00246
+1235 0.719 0.00093 0.00219
+1240 0.727 0.00082 0.002
+1245 0.737 0.00074 0.00175
+1250 0.747 0.0007 0.00169
diff --git a/quad12/labmoderna/p14/main.r b/quad12/labmoderna/p14/main.r
new file mode 100644
index 0000000..621a461
--- /dev/null
+++ b/quad12/labmoderna/p14/main.r
@@ -0,0 +1,32 @@
+file_path <- 'data.txt'
+
+xA <- 100
+xB <- 500
+
+c <- 299792458 # m/s
+h <- 6.62607015e-34 # m^2 kg s^{-1}
+
+data <- read.table(file_path, sep="\t", header=TRUE)
+data$TA <- data$VA / data$VSenseMostra
+data$TB <- data$VB / data$VSenseMostra
+tmaxA <- max(data$TA)
+tmaxB <- max(data$TB)
+data$AlphaASquared <- ((1/xA)*log(tmaxA/data$TA))^2
+data$AlphaBSqrt <- sqrt((1/xB)*log(tmaxB/data$TB))
+data$E <- h*c/(data$Longitud * 1e-9) * 6.242e18 # eV
+
+dataFitA = data[16:18,]
+dataFitB1 <- data[56:62,]
+dataFitB2 <- data[33:55,]
+
+fitA = lm(AlphaASquared~E, data = dataFitA)
+summary(fitA)
+
+fitB1 = lm(AlphaBSqrt~E, data = dataFitB1)
+summary(fitB1)
+
+fitB2 = lm(AlphaBSqrt~E, data = dataFitB2)
+summary(fitB2)
+
+plot(dataFitA$E, dataFitA$AlphaASquared)
+