Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3df1dc2
adding a couple of useful functions:
Nov 21, 2022
70ef913
bug fixes in decoding configuration
Nov 22, 2022
3a7eb76
AcquireLGENValues.m now uses the MachineRef repo
Nov 22, 2022
1e378b9
AcquireLGENValues.m and AcquireLGENValues.m now crunch also SYNCHRO PSs
Nov 22, 2022
73135d8
removing available mapping. It has been moved to MachineRefs repo
Nov 22, 2022
94b7c0e
adding a script to display LGEN values
Nov 22, 2022
811467d
removing unused declaration in CreateQAfiles.m
Nov 22, 2022
c0e2323
Adding a script which shows basic beam properties changing with range
Nov 23, 2022
ae9894b
Adding a title to the window of LGEN plots
Jan 31, 2023
eb54ebe
bug fix in comparing PSnames to write with all PS names + repeating a…
Jan 31, 2023
0875161
Merge branch 'CNAO:main' into CreateMapping
amereghe Jan 31, 2023
0ddfec9
Merge branch 'CNAO:main' into CreateMapping
amereghe Feb 23, 2023
e5baf04
Minor updates to operations/LGENvisualCheck.m:
Feb 23, 2023
9ce1458
Merge remote-tracking branch 'upstream/main' into CreateMapping
Oct 11, 2023
4a29ac8
adding Helium to particle DB
Oct 11, 2023
c599b00
cleared ShowMCS.m of particle-dependent variable names
Oct 11, 2023
d90f0c3
showing MCS and Bethe-Bloch/Landau-Vavilov also for He
Nov 2, 2023
b622dfe
creating a displayLib folder with functions used only by Display* scr…
Nov 6, 2023
0a51297
forgotten function in DisplayRefValues.m
Nov 6, 2023
9f870bc
bug fix concerning handling of time arrays when parsing beam profiles
Nov 15, 2023
30eb2e8
Extracting some general-purpose functions from Display scripts
Nov 15, 2023
52ff55d
implementing handling of reference spot sizes
Nov 15, 2023
0fe76e3
forgotten commit
Nov 15, 2023
a8fc73e
showing reference spot sizes when crunching CAM data
Nov 15, 2023
0568a58
path to libraries added only if variable is not defined
Nov 16, 2023
61e9415
adding possibility to load sphinx data
Dec 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 23 additions & 20 deletions CreateQAfiles.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,28 @@
pathToLibrary=".\";
addpath(genpath(pathToLibrary));
end
% - include MachineRefs
pathToLibrary="../MachineRefs";
addpath(genpath(pathToLibrary));

%% settings

% -------------------------------------------------------------------------
% USER's input data
kPath="S:\Accelerating-System\Accelerator-data";
% kPath="K:";

beamPart="CARBON";
machine="ISO3";
beamPart="PROTON";
config="TM"; % select configuration: TM, RFKO
% -------------------------------------------------------------------------

%% parse DBs
myConfig=sprintf("%s,%s,%s",machine,beamPart,config);

% - get PS mapping
clear PSmapping; PSmapping=readtable("PSmapping.xlsx");
clear PSmapping; FullFileName=ReturnDefFile("PSmapping",myConfig); PSmapping=readtable(FullFileName);

% - get TM values
clear cyCodesTM rangesTM EksTM BrhosTM currentsTM fieldsTM kicksTM psNamesTM FileNameCurrentsTM magNamesTM ;
[cyCodesTM,rangesTM,EksTM,BrhosTM,currentsTM,fieldsTM,kicksTM,psNamesTM,FileNameCurrentsTM]=AcquireLGENValues(beamPart,machine,config);
[cyCodesTM,rangesTM,EksTM,BrhosTM,currentsTM,fieldsTM,kicksTM,psNamesTM,FileNameCurrentsTM]=AcquireLGENValues(myConfig);
psNamesTM=string(psNamesTM);
cyCodesTM=upper(string(cyCodesTM));
magNamesTM=MagNames2LGENnames(psNamesTM,true,PSmapping);
Expand All @@ -48,20 +49,22 @@
% -------------------------------------------------------------------------
% USER's input data
% wrMagnetNames=[ "H2-012A-QUE" "H2-016A-QUE" "H2-022A-QUE" "HE-025A-QUE" ];
wrMagnetNames=[ "H2-012A-QUE" "H2-016A-QUE" "H2-022A-QUE" "HE-025A-QUE" ];
% wrMagnetNames=[ "H2-012A-QUE" "H2-016A-QUE" "H2-022A-QUE" "HE-025A-QUE" ];
% wrMagnetNames=[ "HE-018A-QUE" "HE-020A-QUE" "HE-023A-QUE" "HE-025A-QUE" ];
wrRange=[30 30 30 30]; % [mm]
wrMagnetNames=[ "HE-H07A-CEB" "HE-V07A-CEB" "HE-H27A-CEB" "HE-V27A-CEB" ];
wrRange=[320 320 320 320]; % [mm]
wrScan=["scanTM" "scanTM" "scanTM" "scanTM"];
wrDImin=[20 20 20 20 ]; % [A]
wrDImax=[20 20 20 20 ]; % [A]
wrDIdel=[1 1 1 1 ]; % [A]
wrNtimes=[ 1 1 1 1];
wrIbef=[5 5 5 5 ]; % [A]
wrNIbef=[3 3 3 3];
wrIaft=[350 350 350 350 ]; % [A]
wrDImin=[210 140 140 140 ]; % min current [A]
wrDImax=[ 70 140 140 140 ]; % max current [A]
wrDIdel=[ 70 70 70 70 ]; % delta current [A]
wrNtimes=[ 1 1 1 1 ]; % repeat scan N times
wrNpoints=[ 5 5 5 5 ]; % repeat each point N times
wrIbef=[ -150 -150 -150 -150 ]; % [A]
wrNIbef=[ 2 2 2 2 ];
wrIaft=[150 150 150 150 ]; % [A]
wrNIaft=[2 2 2 2];
wrImin=[ 5 5 5 5 ];
wrImax=[ 350 350 350 350];
wrImin=[ -150 -150 -150 -150 ];
wrImax=[ 150 150 150 150 ];
oFileName="test.xlsx";

% -------------------------------------------------------------------------
Expand All @@ -72,8 +75,8 @@
% echo TM values
rTM=find(rangesTM==wrRange(ii));
if ( isempty(rTM) ), error("Range %d mm not available in TM table!",wrRange(ii)); end
pTM=find(strcmpi(psNamesTM,string(PSmapping.LGEN(jj))));
if ( isempty(pTM) ), error("LGEN name %s not found in TM table!",PSmapping.LGEN(jj)); end
pTM=find(strcmpi(psNamesTM,wrPSnames(ii)));
if ( isempty(pTM) ), error("LGEN name %s not found in TM table!",wrPSnames(ii)); end
warning("...TM value of %s (aka %s) for %s at %d mm: %f A;",wrPSnames(ii),wrMagnetNames(ii),beamPart,wrRange(ii),currentsTM(rTM,pTM));
% array characteristics
switch upper(wrScan(ii))
Expand All @@ -88,7 +91,7 @@
Imax=currentsTM(rTM,pTM)+wrDImax(ii);
Idel=wrDIdel(ii);
end
tmpScan=(Imin:Idel:Imax)';
tmpScan=repelem(Imin:Idel:Imax,wrNpoints(ii))';
tmpScan=CorrectRange(tmpScan,wrImin(ii),wrImax(ii));
tmpScan=RepeatScan(tmpScan,wrNtimes(ii));
tmpScan=DecorateScan(tmpScan,wrIbef(ii),wrIaft(ii),wrNIbef(ii),wrNIaft(ii));
Expand Down
79 changes: 55 additions & 24 deletions DisplayBeamProfiles.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
% for CAMeretta/DDS/GIM only, the script also compares summary data
% against statistics data computed on profiles;

%% clean
clear all;
close all;

%% manual run
if (~exist("MonPaths","var"))
% script manually run by user
Expand All @@ -27,6 +31,8 @@
if (~exist("pathToLibrary","var"))
pathToLibrary=".\";
addpath(genpath(pathToLibrary));
pathToLibrary="../MachineRefs";
addpath(genpath(pathToLibrary));
end
% - clear settings
clear kPath myTit monTypes MonPaths myLabels
Expand All @@ -35,41 +41,33 @@
% USER's input data
% -------------------------------------------------------------------------
kPath="P:\Accelerating-System\Accelerator-data";
monTypes="CAMdumps"; % CAM/CAMdumps, DDS, GIM, QBM/QPP/PIB/PMM/SFH/SFM/SFP
monTypes="CAM"; % CAM/CAMdumps, DDS, GIM, QBM/QPP/PIB/PMM/SFH/SFM/SFP
myLabels=[...
"test 1: H scan (1E6 per spot)"
"test 2: grid (1E6 per spot)"
"test 3: V scan (1E6 per spot)"
"test 4: V scan (1.2E6 per spot)"
"test 5: V scan (1.2E6 per spot)"
"test 6: H scan (1.2E6 per spot)"
"test 7: H scan (1.2E6 per spot)"
"test 8: grid (1.2E6 per spot)"
"Sala1 (16-10-2023)"
"Sala2H (16-10-2023)"
"Sala2V (16-10-2023)"
"Sala3 (16-10-2023)"
];
% myLabels=monTypes;
lSkip=false; % DDS summary file: skip first 2 lines (in addition to header line)
myFigPath=".";
% part-dependent stuff
% - protoni
myFigName="Tests with DDS";
myTit="Tests with DDS";
myFigName="Machie Photos";
myTit="Machine Photos";
MonPaths=[...
"P:\Accelerating-System\Accelerator-data\scambio\Alessio\2023-08-21_testsOcchiConiglio\DumpProtSO1_LineT_Size10_22-08-2023_2213\"
"P:\Accelerating-System\Accelerator-data\scambio\Alessio\2023-08-21_testsOcchiConiglio\DumpProtSO1_LineT_Size10_22-08-2023_2219\"
"P:\Accelerating-System\Accelerator-data\scambio\Alessio\2023-08-21_testsOcchiConiglio\DumpProtSO1_LineT_Size10_22-08-2023_2222\"
"P:\Accelerating-System\Accelerator-data\scambio\Alessio\2023-08-21_testsOcchiConiglio\DumpProtSO1_LineT_Size10_22-08-2023_2225\"
"P:\Accelerating-System\Accelerator-data\scambio\Alessio\2023-08-21_testsOcchiConiglio\DumpProtSO1_LineT_Size10_22-08-2023_2227\"
"P:\Accelerating-System\Accelerator-data\scambio\Alessio\2023-08-21_testsOcchiConiglio\DumpProtSO1_LineT_Size10_22-08-2023_2229\"
"P:\Accelerating-System\Accelerator-data\scambio\Alessio\2023-08-21_testsOcchiConiglio\DumpProtSO1_LineT_Size10_22-08-2023_2231\"
"P:\Accelerating-System\Accelerator-data\scambio\Alessio\2023-08-21_testsOcchiConiglio\DumpProtSO1_LineT_Size10_22-08-2023_2233\"
"P:\Accelerating-System\Accelerator-data\Area dati MD\00Steering\SteeringPazienti\carbonio\sala1\2023\2023.10.16\CarbSO2_LineZ_Size6_16-10-2023_0800\"
"P:\Accelerating-System\Accelerator-data\Area dati MD\00Steering\SteeringPazienti\carbonio\sala2U\2023\2023.10.16\CarbSO2_LineU_Size6_16-10-2023_0219\"
"P:\Accelerating-System\Accelerator-data\Area dati MD\00Steering\SteeringPazienti\carbonio\sala2V\2023\2023.10.16\CarbSO2_LineV_Size6_16-10-2023_0908\"
"P:\Accelerating-System\Accelerator-data\Area dati MD\00Steering\SteeringPazienti\carbonio\sala3\2023\2023.10.15\CarbSO2_LineT_Size6_15-10-2023_2313\"
];
% % - carbonio
% myFigName="summary_carbonio_GIM_2023-05-09.10";
% myTit="summary 2023-05-09.10 - Carbonio";
% MonPaths=[...
% strcat(kPath,"\Area dati MD\00Summary\Carbonio\2023\Maggio\2023.05.09-10\Steering ridotti\GIM\PRC-544-230511-0028_H2-009B-GIM_AllTrig\")
% ];
vsX="ID"; % ["Ek"/"En"/"Energy","mm"/"r"/"range","ID"/"IDs"]
vsX="Ek"; % ["Ek"/"En"/"Energy","mm"/"r"/"range","ID"/"IDs"]
iNotShow=false(127,2);
iNotShow(1:2,1)=true; % do not show left-most fibers on hor plane (broken)
end
Expand Down Expand Up @@ -137,8 +135,8 @@
[tmpBARsProf,tmpFWHMsProf,tmpINTsProf]=StatDistributionsBDProcedure(tmpProfiles);
end
% - Eks,mms
tmpEksProf=ConvertCyCodes(tmpCyCodesProf,"Ek","MeVvsCyCo_P.xlsx");
tmpMmsProf=ConvertCyCodes(tmpCyCodesProf,"mm","MeVvsCyCo_P.xlsx");
tmpEksProf=MapCyCodes(tmpCyCodesProf,"Ek","SYNCHRO");
tmpMmsProf=MapCyCodes(tmpCyCodesProf,"Range","SYNCHRO");
% - store data
cyProgsProf=ExpandMat(cyProgsProf,tmpCyProgsProf);
cyCodesProf=ExpandMat(cyCodesProf,tmpCyCodesProf);
Expand All @@ -157,8 +155,8 @@
% - quick check of consistency of parsed data
if (length(tmpCyProgsSumm)~=length(tmpCyProgsProf)), error("...inconsistent data set between summary data and actual profiles"); end
% - Eks,mms
tmpEksSumm=ConvertCyCodes(tmpCyCodesSumm,"Ek","MeVvsCyCo_P.xlsx");
tmpMmsSumm=ConvertCyCodes(tmpCyCodesSumm,"mm","MeVvsCyCo_P.xlsx");
tmpEksSumm=MapCyCodes(tmpCyCodesSumm,"Ek","SYNCHRO");
tmpMmsSumm=MapCyCodes(tmpCyCodesSumm,"Range","SYNCHRO");
% - store data
cyProgsSumm=ExpandMat(cyProgsSumm,tmpCyProgsSumm);
cyCodesSumm=ExpandMat(cyCodesSumm,tmpCyCodesSumm);
Expand Down Expand Up @@ -222,6 +220,39 @@
end
end

%% show figures of merit
% - references
[refFWHM,refXVals]=Spots_LoadEffectiveSpecs("CARBON",vsX,"TM"); refLeg=["reference" "ref+" "ref-"];

% - FWHM
showYlabels=strings(nDataSets,1); showYlabels(:)="FWHM [mm]";
showXlabels=strings(nDataSets,1); showXlabels(:)=addLabel;
myTitles=strings(nDataSets+1,1); myTitles(1:end-1)=myLabels; myTitles(end)="FWHM";
xVals=NaN(size(addIndex,1),2,size(addIndex,2));
xVals(:,1,:)=addIndex; xVals(:,2,:)=addIndex;
myLeg=["HOR" "VER"];
ShowSeries(xVals,FWHMsProf,showXlabels,showYlabels,myLeg,myTitles,refFWHM,refXVals,refLeg);

% - xy-asymmetry
[FWHMprofGeoMean,profASYM]=Spots_MeritFWHM(FWHMsProf);
showYlabels=["[mm]" "[%]"];
showXlabels=strings(2,1); showXlabels(:)=addLabel;
myLeg=myLabels; myTitles=["FWHM_y-FWHM_x" "normalised: (FWHM_y-FWHM_x)/geoAve" "yx-asymmetry"];
xVals=NaN(size(addIndex,1),size(addIndex,2),2);
xVals(:,:,1)=addIndex; xVals(:,:,2)=addIndex;
yVals=NaN(size(addIndex,1),size(addIndex,2),2);
yVals(:,:,1)=profASYM; yVals(:,:,2)=profASYM./FWHMprofGeoMean*100;
ShowSeries(xVals,yVals,showXlabels,showYlabels,myLeg,myTitles);

% - BARicenters
showYlabels=strings(nDataSets,1); showYlabels(:)="BAR [mm]";
showXlabels=strings(nDataSets,1); showXlabels(:)=addLabel;
myTitles=strings(nDataSets+1,1); myTitles(1:end-1)=myLabels; myTitles(end)="BAR";
xVals=NaN(size(addIndex,1),2,size(addIndex,2));
xVals(:,1,:)=addIndex; xVals(:,2,:)=addIndex;
myLeg=["HOR" "VER"];
ShowSeries(xVals,BARsProf,showXlabels,showYlabels,myLeg,myTitles);

%% save summary data
% oFileName=strcat(kPath,"\scambio\Alessio\Carbonio_preSteering_summary-from-profiles.csv");
% SaveBeamProfileSummaryFile(oFileName,tmpBARsProf,tmpFWHMsProf,tmpINTsProf,tmpCyCodesProf,tmpCyProgsProf,"DDS");
81 changes: 81 additions & 0 deletions DisplayLGENs.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
% {}~

%% description
% this is a script which displays LGEN currents;

%% include libraries
% - include Matlab libraries
pathToLibrary="./";
addpath(genpath(pathToLibrary));
pathToLibrary="../MachineRefs";
addpath(genpath(pathToLibrary));

%% settings

% -------------------------------------------------------------------------
% USER's input data
machine=["Sala2H" "Sala2H"];%["ISO1" "ISO2" "ISO3" "ISO4" ]; % "ISO1" "ISO2" "ISO3" "ISO4"];
machine="ISO3";%["ISO1" "ISO2" "ISO3" "ISO4" ]; % "ISO1" "ISO2" "ISO3" "ISO4"];
% beamPart=["PROTON" "PROTON" "PROTON" "PROTON" ]; %"CARBON" "CARBON" "CARBON" "CARBON" ];
beamPart=["PROTON" "CARBON" ];
% machine="ISO2";
% beamPart=["PROTON" "CARBON" ];
config="TM"; % select configuration: TM, RFKO
myTitle="LGEN values";
% -------------------------------------------------------------------------

% -------------------------------------------------------------------------
% check of user input data
nSets=max([length(beamPart) length(machine) length(config)]);
beamPart=ConfigCheck(beamPart,nSets,"beamPart");
machine=ConfigCheck(machine,nSets,"machine");
config=ConfigCheck(config,nSets,"config");

%% clear variables
[cyCodes,ranges,Eks,Brhos,currents,fields,kicks,psNames,FileNameCurrents,magNames]=...
deal(missing(),missing(),missing(),missing(),missing(),missing(),missing(),missing(),missing(),missing());
clear PSmapping;
myLeg=strings(nSets,1);

%% parse DBs

% - get PS mapping
FullFileName=ReturnDefFile("PSmapping"); PSmapping=readtable(FullFileName);

% - get values
for iSet=1:nSets
clear tmpCyCodes tmpRanges tmpEks tmpBrhos tmpCurrents tmpFields tmpKicks tmpPsNames tmpFileNameCurrents tmpMagNames ;
myConfig=sprintf("%s,%s,%s",machine(iSet),beamPart(iSet),config(iSet));
[tmpCyCodes,tmpRanges,tmpEks,tmpBrhos,tmpCurrents,tmpFields,tmpKicks,tmpPsNames,tmpFileNameCurrents]=AcquireLGENValues(myConfig);
tmpPsNames=string(tmpPsNames);
tmpCyCodes=upper(string(tmpCyCodes));
tmpMagNames=MagNames2LGENnames(tmpPsNames,true,PSmapping);
myLeg(iSet)=myConfig; % comment me, if single data set
% - store data
cyCodes=ExpandMat(cyCodes,tmpCyCodes);
ranges=ExpandMat(ranges,tmpRanges);
Eks=ExpandMat(Eks,tmpEks);
Brhos=ExpandMat(Brhos,tmpBrhos);
currents=ExpandMat(currents,tmpCurrents);
fields=ExpandMat(fields,tmpFields);
kicks=ExpandMat(kicks,tmpKicks);
psNames=ExpandMat(psNames,tmpPsNames);
FileNameCurrents=ExpandMat(FileNameCurrents,tmpFileNameCurrents);
magNames=ExpandMat(magNames,tmpMagNames);
end

% - normalise currents to Brho
clear normCurrents; normCurrents=NaN(size(currents));
for iSet=1:nSets
normCurrents(:,:,iSet)=currents(:,:,iSet)./Brhos(:,iSet);
end

%% visual checks
LGENvisualCheck(psNames,Eks ,"Ek [MeV/u]",currents,"I [A]",magNames,myTitle,myLeg);
LGENvisualCheck(psNames,Eks ,"Ek [MeV/u]",normCurrents,"I/B\rho [A/Tm]",magNames,myTitle,myLeg);
LGENvisualCheck(psNames,ranges,"range [mm]",currents,"I [A]",magNames,myTitle,myLeg,"QUE");
LGENvisualCheck(psNames,ranges,"range [mm]",normCurrents,"I/B\rho [A/Tm]",magNames,myTitle,myLeg);
LGENvisualCheck(psNames,Brhos ,"B\rho [Tm]",currents,"I [A]",magNames,myTitle,myLeg);
LGENvisualCheck(psNames,Brhos ,"B\rho [Tm]",normCurrents,"I/B\rho [A/Tm]",magNames,myTitle,myLeg);

%% local functions
63 changes: 63 additions & 0 deletions DisplayRefValues.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
% {}~

%% description
% this is a script which displays basic beam properties which depend on beam energy;

%% include libraries
% - include Matlab libraries
pathToLibrary="./";
addpath(genpath(pathToLibrary));
pathToLibrary="../MachineRefs";
addpath(genpath(pathToLibrary));

%% settings

% -------------------------------------------------------------------------
% USER's input data
% what to load
machine="ISO1";
beamPart=["PROTON" "CARBON"];
% what to show
showX="range";
showXlabel="R [mm]";
showY=[ "beta" "gamma" "betagamma" "pc" "Brho" "Ek" ];
showYlabel=["\beta_{rel} []" "\gamma_{rel} []" "\beta_{rel}\gamma_{rel} []" "pc [MeV/c/u]" "B\rho [Tm]" "E_k [MeV/u]"];
nCoupled=3;
% -------------------------------------------------------------------------

% -------------------------------------------------------------------------
% check of user input data
nSets=max([length(beamPart) length(machine)]);
beamPart=ConfigCheck(beamPart,nSets,"beamPart");
machine=ConfigCheck(machine,nSets,"machine");
mSets=max([length(showX) length(showXlabel) length(showY) length(showYlabel)]);
showX=ConfigCheck(showX,mSets,"showX");
showXlabel=ConfigCheck(showXlabel,mSets,"showXlabel");
showY=ConfigCheck(showY,mSets,"showY");
showYlabel=ConfigCheck(showYlabel,mSets,"showYlabel");

%% clear variables
xVals=missing();
yVals=missing();

%% parse DBs

% - get values
myLeg=strings(nSets,1);
for iSet=1:nSets
clear EnData tmpDataX tmpDataY;
myConfig=sprintf("%s,%s",machine(iSet),beamPart(iSet));
FullFileName=ReturnDefFile("BRHO",myConfig); EnData=readtable(FullFileName);
myLeg(iSet)=myConfig;
% - store data
[tmpDataX,tmpDataY]=ExtractFromTable(EnData,showX,showY);
xVals=ExpandMat(xVals,tmpDataX);
yVals=ExpandMat(yVals,tmpDataY);
end
xVals=permute(xVals,[1 3 2]); % what to show is the outermost dimension
yVals=permute(yVals,[1 3 2]);

%% show stuff
ShowSeries(xVals,yVals,showXlabel,showYlabel,myLeg);

%% local functions
Loading