diff --git a/VeikonKone.dox b/VeikonKone.dox
index 57425b784af33783518d4ad90fefe835e48d15fd..00957094131304ba0bd8087b1eb1e3ce3d4579a9 100644
--- a/VeikonKone.dox
+++ b/VeikonKone.dox
@@ -753,7 +753,7 @@ WARN_LOGFILE           =
 # spaces.
 # Note: If this tag is empty the current directory is searched.
 
-INPUT                  = /home/oliskir/Desktop/f20/VeikonKone/include/
+INPUT                  = /home/oliskir/Desktop/f20/sim/VeikonKone/include/
 
 # This tag can be used to specify the character encoding of the source files
 # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
@@ -2087,7 +2087,7 @@ HIDE_UNDOC_RELATIONS   = YES
 # set to NO
 # The default value is: NO.
 
-HAVE_DOT               = NO
+HAVE_DOT               = YES
 
 # The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed
 # to run in parallel. When set to 0 doxygen will base this on the number of
@@ -2259,7 +2259,7 @@ INTERACTIVE_SVG        = YES
 # found. If left blank, it is assumed the dot tool can be found in the path.
 # This tag requires that the tag HAVE_DOT is set to YES.
 
-DOT_PATH               = 
+DOT_PATH               = /usr/bin
 
 # The DOTFILE_DIRS tag can be used to specify one or more directories that
 # contain dot files that are included in the documentation (see the \dotfile
@@ -2347,4 +2347,4 @@ GENERATE_LEGEND        = YES
 # The default value is: YES.
 # This tag requires that the tag HAVE_DOT is set to YES.
 
-DOT_CLEANUP            = YES
\ No newline at end of file
+DOT_CLEANUP            = YES
diff --git a/compile.sh b/compile.sh
index 0226cae77c0fdbf30306298548a8418b99f39a13..a161863d50ab5a09fe0f210b2e565c6c2de53059 100755
--- a/compile.sh
+++ b/compile.sh
@@ -2,10 +2,10 @@ rm -f CMakeCache.txt
 rm -rf CMakeFiles
 
 #@carbonoli
-cmake -DCMAKE_BUILD_TYPE=DEBUG -DGeant4_DIR=/home/oliskir/src/geant-4.10/geant4.10.3-install/lib/Geant4-10.3.0 $pwd
+#cmake -DCMAKE_BUILD_TYPE=DEBUG -DGeant4_DIR=/home/oliskir/src/geant-4.10/geant4.10.3-install/lib/Geant4-10.3.0 $pwd
 
 #@squamish
-#cmake -DCMAKE_BUILD_TYPE=DEBUG -DGeant4_DIR=/home/oliskir/src/geant4/geant4.10.2-install/lib/Geant4-10.2.0 $pwd -DCMAKE_BUILD_TYPE=DEBUG
+cmake -DCMAKE_BUILD_TYPE=DEBUG -DGeant4_DIR=/home/oliskir/src/geant4/geant4.10.2-install/lib/Geant4-10.2.0 $pwd -DCMAKE_BUILD_TYPE=DEBUG
 
 #@stkernfys
 #cmake -DCMAKE_BUILD_TYPE=DEBUG -DGeant4_DIR=/home/kernadmin/geant4/geant4.10.2-install/lib/Geant4-10.2.2/ $pwd -DCMAKE_BUILD_TYPE=DEBUG
diff --git a/allowed.mac b/mac/allowed.mac
similarity index 100%
rename from allowed.mac
rename to mac/allowed.mac
diff --git a/anygamma.mac b/mac/anygamma.mac
similarity index 100%
rename from anygamma.mac
rename to mac/anygamma.mac
diff --git a/betaplus.mac b/mac/betaplus.mac
similarity index 100%
rename from betaplus.mac
rename to mac/betaplus.mac
diff --git a/bi207.mac b/mac/bi207.mac
similarity index 100%
rename from bi207.mac
rename to mac/bi207.mac
diff --git a/cerenkov.mac b/mac/cerenkov.mac
similarity index 100%
rename from cerenkov.mac
rename to mac/cerenkov.mac
diff --git a/defaults.mac b/mac/defaults.mac
similarity index 100%
rename from defaults.mac
rename to mac/defaults.mac
diff --git a/electron.mac b/mac/electron.mac
similarity index 100%
rename from electron.mac
rename to mac/electron.mac
diff --git a/mac/f20scan.mac b/mac/f20scan.mac
new file mode 100644
index 0000000000000000000000000000000000000000..ab1783d8bb0fc06e5efb27eb27a899bce0246f2d
--- /dev/null
+++ b/mac/f20scan.mac
@@ -0,0 +1,73 @@
+
+/control/execute mac/init.mac
+
+# magnetic field strength
+/VK/field/maxbfield 0.48 tesla
+
+# source dimensions
+/VK/source/diskShapedSource true
+/VK/source/innerDiameter 0 cm
+/VK/source/outerDiameter 6 mm
+
+# radiation
+/gps/particle e-
+/gps/position 0 0 -299.5 mm
+/gps/ang/type iso
+/gps/ang/mintheta  90 deg
+/gps/ang/maxtheta 180 deg
+
+# energy spectrum
+/VK/source/betaSpectrum true
+/VK/source/betaEndPoint 5.40 MeV
+/VK/source/betaMinEnergy 0.00 MeV
+/VK/source/betaMaxEnergy 5.40 MeV
+
+# output 
+/VK/output/zeroSuppression true
+/VK/storeTrajectoryData false
+
+# run simulations
+
+/VK/field/maxbfield 0.10 tesla
+/VK/output/openFile output/f20scan/070617/b10.root                
+/run/beamOn 10000
+
+/VK/field/maxbfield 0.15 tesla
+/VK/output/openFile output/f20scan/070617/b15.root                
+/run/beamOn 10000
+
+/VK/field/maxbfield 0.20 tesla
+/VK/output/openFile output/f20scan/070617/b20.root                
+/run/beamOn 10000
+
+/VK/field/maxbfield 0.25 tesla
+/VK/output/openFile output/f20scan/070617/b25.root                
+/run/beamOn 10000
+
+/VK/field/maxbfield 0.30 tesla
+/VK/output/openFile output/f20scan/070617/b30.root                
+/run/beamOn 10000
+
+/VK/field/maxbfield 0.35 tesla
+/VK/output/openFile output/f20scan/070617/b35.root                
+/run/beamOn 10000
+
+/VK/field/maxbfield 0.40 tesla
+/VK/output/openFile output/f20scan/070617/b40.root                
+/run/beamOn 10000
+
+/VK/field/maxbfield 0.44 tesla
+/VK/output/openFile output/f20scan/070617/b44.root                
+/run/beamOn 10000
+
+/VK/field/maxbfield 0.46 tesla
+/VK/output/openFile output/f20scan/070617/b46.root                
+/run/beamOn 10000
+
+/VK/field/maxbfield 0.48 tesla
+/VK/output/openFile output/f20scan/070617/b48.root                
+/run/beamOn 10000
+
+/VK/field/maxbfield 0.50 tesla
+/VK/output/openFile output/f20scan/070617/b50.root                
+/run/beamOn 10000
diff --git a/forbidden.mac b/mac/forbidden.mac
similarity index 100%
rename from forbidden.mac
rename to mac/forbidden.mac
diff --git a/gamma.mac b/mac/gamma.mac
similarity index 100%
rename from gamma.mac
rename to mac/gamma.mac
diff --git a/gui.mac b/mac/gui.mac
similarity index 100%
rename from gui.mac
rename to mac/gui.mac
diff --git a/icons.mac b/mac/icons.mac
similarity index 100%
rename from icons.mac
rename to mac/icons.mac
diff --git a/init.mac b/mac/init.mac
similarity index 100%
rename from init.mac
rename to mac/init.mac
diff --git a/leadBlock.mac b/mac/leadBlock.mac
similarity index 100%
rename from leadBlock.mac
rename to mac/leadBlock.mac
diff --git a/muon.mac b/mac/muon.mac
similarity index 100%
rename from muon.mac
rename to mac/muon.mac
diff --git a/photon.mac b/mac/photon.mac
similarity index 100%
rename from photon.mac
rename to mac/photon.mac
diff --git a/reviewEvent.mac b/mac/reviewEvent.mac
similarity index 100%
rename from reviewEvent.mac
rename to mac/reviewEvent.mac
diff --git a/run.mac b/mac/run.mac
similarity index 100%
rename from run.mac
rename to mac/run.mac
diff --git a/scinttest.mac b/mac/scinttest.mac
similarity index 100%
rename from scinttest.mac
rename to mac/scinttest.mac
diff --git a/vis.mac b/mac/vis.mac
similarity index 100%
rename from vis.mac
rename to mac/vis.mac
diff --git a/wls.mac b/mac/wls.mac
similarity index 100%
rename from wls.mac
rename to mac/wls.mac
diff --git a/output/f20scan/ScanF20.C b/output/f20scan/BetaSpec.C
similarity index 96%
rename from output/f20scan/ScanF20.C
rename to output/f20scan/BetaSpec.C
index 40cd60df2000a4ff4e50f352ef7f392e73a3d787..1f3e3125080467fcd14602d6e879a1fbda566e8a 100644
--- a/output/f20scan/ScanF20.C
+++ b/output/f20scan/BetaSpec.C
@@ -4,7 +4,7 @@
  * experimental background spectrum superimposed.
  */
 
-void ScanF20(double hours = 1, double rate = 30E3, int binWidth = 25, double ROImin = 1500, double ROImax = 7000)
+void BetaSpec(double hours = 1, double rate = 30E3, int binWidth = 25, double ROImin = 1500, double ROImax = 7000)
 {
     Double_t seconds = hours*3600;
 
diff --git a/output/f20scan/ExpScanF20.C b/output/f20scan/BetaSpecExp.C
similarity index 98%
rename from output/f20scan/ExpScanF20.C
rename to output/f20scan/BetaSpecExp.C
index 12a5386c58f0a11fefee5ae3f22870b7ddb24741..8def1b5fa663ca2190a32f3b65192d5e20072447 100644
--- a/output/f20scan/ExpScanF20.C
+++ b/output/f20scan/BetaSpecExp.C
@@ -5,7 +5,7 @@
  * 1.6-MeV gamma-ray line is used for normalisation.
  */
 
-void ExpScanF20(int binWidth = 50, double ROImin = 1500, double ROImax = 7000, double gEff = 0.00296E-2)
+void BetaSpecExp(int binWidth = 50, double ROImin = 1500, double ROImax = 7000, double gEff = 0.00296E-2)
 {
     const double emin = 0;
     const double emax = 8E3;
diff --git a/output/f20scan/TransmissionExp.C b/output/f20scan/TransmissionExp.C
new file mode 100644
index 0000000000000000000000000000000000000000..a785330833456abc37410af0ab81ce50d539e83a
--- /dev/null
+++ b/output/f20scan/TransmissionExp.C
@@ -0,0 +1,196 @@
+
+/* 
+ * Get duration in hours.
+ */
+
+double GetDuration(TChain * chain) 
+{
+    // branches
+    UInt_t M0, M1, M2;
+    chain->SetBranchAddress("M0", &M0);
+    chain->SetBranchAddress("M1", &M1);
+    chain->SetBranchAddress("M2", &M2);
+    vector<ULong64_t> T0(10), T1(10), T2(10);
+    chain->SetBranchAddress("T0", T0.data());
+    chain->SetBranchAddress("T1", T1.data());
+    chain->SetBranchAddress("T2", T2.data());
+
+    // find tmin and tmax
+    int shifts = 0;
+    double shift = 0;
+    double Tp = 0, TFirst = 0, TLast = 0;    
+    for (int i=0; i<chain->GetEntries(); i++) 
+    {
+        chain->GetEntry(i);
+
+        double T00 = 0, T10 = 0, T20 = 0;
+        if (M0 > 0) T00 = T0[0];  
+        if (M1 > 0) T10 = T1[0]; 
+        if (M2 > 0) T20 = T2[0];  
+
+        double T = TMath::Max(T00, TMath::Max(T10, T20));
+
+        if (Tp > T) {
+            shift += Tp;
+            shifts++;
+        }
+        if (i == 0) TFirst = T + shift;
+        if (i == chain->GetEntries() - 1) TLast = T + shift;
+        Tp = T;
+    }
+
+    double seconds = (TLast - TFirst) * 1E-8;
+    double minutes = seconds / 60.;
+    double hours = minutes / 60.;
+
+    return hours;
+}
+
+/* 
+ * Locate and fit 1.6-MeV gamma peak
+ */
+
+void FitGammaPeak(TH1D * h, double& counts, double& e0, double& sigma) 
+{
+}
+
+
+/* 
+ * Plot transmission as a function of magnetic-field setting.
+ */
+
+void TransmissionExp(bool veto = false)
+{
+    // directories
+    TString expdir = "/home/oliskir/Desktop/f20/data/sorted/new/";
+    TString simdir = "070617/";
+
+    // gamma detection efficiency
+    const double gammaEff = 0.54E-6;
+
+    // beta spectrum integration limits
+    const double emin = 100;
+    const double emax = 5400;
+    const int bins = 530;
+    
+    // number of magnetic field settings
+    const int N = 10;
+    vector<int> bmax = {15, 20, 25, 30, 35, 40, 44, 46, 48, 50};
+
+    // runs at each setting
+    vector<int> runs[N];
+    runs[0] = {366};
+    runs[1] = {332};
+    runs[2] = {367};
+    runs[3] = {333};
+    runs[4] = {368};
+    runs[5] = {334};
+    runs[6] = {369};
+    runs[7] = {360};
+    runs[8] = {361, 362, 363, 364, 365, 370, 371, 372, 373, 374, 375, 376, 379, 380};
+    runs[9] = {358};
+
+    // background run (337)
+    int rBackgr = 337;
+    TChain * cBackgr = new TChain("data");    
+    cBackgr->Add(expdir+Form("*0%i*", rBackgr));    
+    TH1F * hBackgr0 = new TH1F("hBackgr0", "hBackgr0", bins, emin, emax);
+    cBackgr->Draw("E0 >> hBackgr0", "Z0 != 10");
+    double hoursBackgr = GetDuration(cBackgr);
+    
+    cout << endl;
+    cout << " Background run:" << endl;
+    cout << Form(" * Run:      %i", rBackgr) << endl;
+    cout << Form(" * Entries:  %lli", cBackgr->GetEntries()) << endl;
+    cout << Form(" * Duration: %.1f hours", hoursBackgr) << endl;
+    cout << endl;
+
+    // canvas
+    TCanvas * c1 = new TCanvas("c1");
+
+    // loop over magnetic field settings
+    int i = 0;
+    for (auto& b : bmax) 
+    {
+        cout << " Bmax: " << 0.01*b << " T" << endl;
+    
+        // add files
+        TChain * cExp = new TChain("data");    
+        for (auto& r : runs[i]) {
+            TString fname = expdir + Form("*0%i*", r);
+            cExp->Add(fname);    
+        }
+        
+        // duration of experimental run
+        double hours = GetDuration(cExp);
+        cout << Form(" Duration: %.1f", hours) << endl; 
+
+        // scale background spectrum
+        TH1D * hBackgr = (TH1D*)hBackgr0->Clone("hBackgr");
+        hBackgr->Scale(hours/hoursBackgr);
+
+        // integrate background spectrum
+        int binx1     = hBackgr->GetXaxis()->FindBin(emin);
+        int binx2     = hBackgr->GetXaxis()->FindBin(emax);
+        double backgr = hBackgr->Integral(binx1, binx2);
+
+        // singles histograms
+        TString nb = Form("hb%i", i);        
+        TH1D * hb  = new TH1D(nb, nb, bins, emin, emax);
+        TString ng = Form("hg%i", i);        
+        TH1D * hg  = new TH1D(ng, ng, 1000, 0, 3000);
+
+        // draw
+        cExp->Draw("E0 >> " + nb,  "Z0 != 10");
+        cExp->Draw("E2 >> " + ng,  "Z2 != 10");
+        
+        // integrate beta spectrum
+        double betas = hb->Integral(binx1, binx2);
+        betas -= backgr;
+        
+        // integrate 1.6-MeV peak in singles spectrum
+        double gammas, centroid, sigma;
+        FitGammaPeak(hg, gammas, centroid, sigma);
+
+        // coincidence histogram
+        TString nbg = Form("hbg%i", i);        
+        TH1F * hbg  = new TH1F(nbg, nbg, 1000, 0, 3000);
+        
+        // draw
+        double egmin = centroid - 3*sigma;
+        double egmax = centroid + 3*sigma;
+        cExp->Draw("E0 >> " + nbg, Form("Z0 != 10 && Z2 != 10 && E2 >= %f && E2 <= %f", egmin, egmax));
+
+        // integrate coincidence beta spectrum
+        double coincidences = hbg->Integral(binx1, binx2);
+
+        // simulated beta spectrum
+        TString fname = simdir + Form("b%i.root", b);
+        TFile * fSim = new TFile(fname, "READ");
+        TTree * tSim = (TTree*)fSim->Get("Detector");
+
+        // histogram 
+        TString nbSim = Form("hbSim%i", i);        
+        TH1D * hbSim  = new TH1D(nbSim, nbSim, bins, emin, emax);
+
+        // draw
+        tSim->Draw("EDepSignal >> " + nbSim,  "");
+
+        // scaling factor
+        double decays = gammas / gammaEff;
+        double norm   = ((TParameter<double>*)(tSim->GetUserInfo()->FindObject("NORMALIZATION")))->GetVal(); 
+        hbSim->Scale(decays/norm);        
+        
+        // integrate
+        double betasSim = hbSim->Integral(binx1, binx2);
+
+        cout << Form(" Background:   %.0f", backgr) << endl; 
+        cout << Form(" Betas:        %.0f", betas) << endl; 
+        cout << Form(" Gammas:       %.0f", gammas) << endl; 
+        cout << Form(" Coincidences: %.0f", coincidences) << endl; 
+        cout << Form(" Simulated betas: %.0f", betasSim) << endl; 
+
+        cin.get();
+        i++;
+    }
+}