Lab moderna: add p4

Change-Id: I56673d05625f628fbb33acfad3b482e3158cbb42
diff --git a/quad12/labmoderna/p4b/dades/dades.txt b/quad12/labmoderna/p4b/dades/dades.txt
new file mode 100644
index 0000000..1ba0141
--- /dev/null
+++ b/quad12/labmoderna/p4b/dades/dades.txt
@@ -0,0 +1,24 @@
+CampMagnetic	IntensitatReal
+20	2.722222222
+40	6.622222222
+50	8.042222222
+55	9.112222222
+60	9.642222222
+62.5	10.31222222
+65	10.35222222
+67.5	10.08222222
+70	10.19222222
+72.5	10.40222222
+75	10.68222222
+77.5	10.74222222
+80	10.23222222
+82.5	10.09222222
+85	10.33222222
+87.5	9.812222222
+90	9.722222222
+95	9.512222222
+100	9.032222222
+105	8.552222222
+110	7.972222222
+120	6.512222222
+140	4.292222222
diff --git a/quad12/labmoderna/p4b/output/.gitignore b/quad12/labmoderna/p4b/output/.gitignore
new file mode 100644
index 0000000..e9575a3
--- /dev/null
+++ b/quad12/labmoderna/p4b/output/.gitignore
@@ -0,0 +1,3 @@
+*.png
+*.svg
+*.pdf
diff --git a/quad12/labmoderna/p4b/r/main.r b/quad12/labmoderna/p4b/r/main.r
new file mode 100644
index 0000000..5d079db
--- /dev/null
+++ b/quad12/labmoderna/p4b/r/main.r
@@ -0,0 +1,29 @@
+mec2 <- 510.999
+r <- 0.05
+ee <- 1.60e-19
+c <- 299792348
+eV <- 6.24e18
+
+table <- read.table('dades/dades.txt', sep="\t", dec='.', header=TRUE)
+table$LogIntensitatReal <- log(table$IntensitatReal)
+table$CampMagneticSq <- table$CampMagnetic^2
+table$E <- (sqrt((ee*c*(table$CampMagnetic/1000)*r*eV/1000)^2 + mec2^2) - mec2)/1000
+table$ESq <- table$E^2
+
+tablefit <- table[8:17,]
+
+fit <- lm(IntensitatReal ~ E + ESq, data = tablefit)
+summary(fit)
+fit_coef <- coef(fit)
+
+svg(file='output/p1b.svg', width=6, height=5)
+plot(table$E, table$IntensitatReal, xlab="Energia (MeV)", ylab="Intensitat (s^-1)")
+curve(fit_coef[1] + fit_coef[2]*x + fit_coef[3]*x*x, col = "mediumorchid2", add = TRUE)
+dev.off()
+
+svg(file='output/p1b2.svg', width=6, height=5)
+plot(table$CampMagnetic, table$E, xlab="Camp magnètic (mT)", ylab="Energia (MeV)")
+dev.off()
+
+Emax <- -fit_coef[2]/(2*fit_coef[3])
+Emax