Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
bf00c2c
added beam offset analysis
raffaelladevita Oct 16, 2023
7668543
used moment at R1
raffaelladevita Oct 16, 2023
cf00117
saving new offset histograms to the histogram file
raffaelladevita Oct 17, 2023
f0bb2b2
improving offset fit and reverting to use track vertex variables
raffaelladevita Oct 20, 2023
2cd262a
added theta threshold function with offset
raffaelladevita Oct 20, 2023
21db196
changing function names to be sector dependent
raffaelladevita Oct 30, 2023
d35c8c5
restore time residual plots, update to skimming script
raffaelladevita Dec 8, 2023
2b9341e
restore time residual plots, attempt2
raffaelladevita Dec 8, 2023
7d628e1
restoring writing of time residuals to file
raffaelladevita Dec 11, 2023
b8a43eb
reading time histograms when reanalyzing or refitting
raffaelladevita Dec 13, 2023
3ad3db0
restoring vertex constraint
raffaelladevita Dec 18, 2023
90540c2
set a 10 count threshold on the scattering chamber exit window peak f…
raffaelladevita Dec 20, 2023
4176492
improved vertex fit for new cryotarget
raffaelladevita Feb 9, 2024
9c561b0
added time residuals calibration plots, switched to newer coatjava ve…
raffaelladevita Feb 12, 2024
9f5dcee
modified reading and writing of histogram file to save fitted functions
raffaelladevita Feb 13, 2024
7599aea
added fit of integrated vertex distribution, setting of residual stat…
raffaelladevita Feb 16, 2024
fdaadb9
renamed histograms
raffaelladevita Feb 16, 2024
9ae06af
disabled jminuit log during histogram fitting
raffaelladevita Feb 16, 2024
09c0ab9
added checks on histograms fit convergence and code cleanups
raffaelladevita Feb 17, 2024
bea1709
restored log file
raffaelladevita Feb 17, 2024
ad30c3d
now selecting status=0 hits, added wire plots
raffaelladevita Feb 19, 2024
4b61569
r1 translations are now global, changing theta to traj point
raffaelladevita Feb 26, 2024
03553c2
bug fix
raffaelladevita Feb 26, 2024
21f7e84
added option to initialize misalignment fit from CCDB table (-init), …
raffaelladevita Feb 27, 2024
2e807e6
added command-line options to choose frame and global/loval R1 transl…
raffaelladevita Feb 27, 2024
0d57efb
cleanup
raffaelladevita Feb 27, 2024
c6a9071
increased R3 residual error by x2 and added alpha plots
raffaelladevita Feb 27, 2024
ad416c2
changed alpha to reducedalpha
raffaelladevita Feb 27, 2024
bf68daf
fix to global transformation handling and more time plots
raffaelladevita Feb 29, 2024
dde4810
more plots and improved fitting
raffaelladevita Mar 2, 2024
7420fa8
improved DC skimming scripts
raffaelladevita Mar 8, 2024
3335dc9
restoring time residual bins for angular bins
raffaelladevita Mar 8, 2024
724bb1d
Merge branch 'dcDev7' of github.com:JeffersonLab/clas12alignment into…
raffaelladevita Mar 8, 2024
b66da57
adding doca cuts
raffaelladevita Mar 22, 2024
a30c954
improving hit selection
raffaelladevita Mar 22, 2024
68c3301
added alpha cuts on hits and double gaussian fit of residuals
raffaelladevita Mar 22, 2024
cecd83e
Merge branch 'dcDev7' of github.com:JeffersonLab/clas12alignment into…
raffaelladevita Mar 22, 2024
a7d313a
improving hit selection again
raffaelladevita Mar 22, 2024
967a918
redo failed fits
raffaelladevita Mar 25, 2024
d8bbd43
Merge branch 'dcDev7' of github.com:JeffersonLab/clas12alignment into…
raffaelladevita Mar 25, 2024
56796a1
added command line options to turn hit cuts on/off
raffaelladevita Mar 26, 2024
29114c4
Merge branch 'dcDev7' of github.com:JeffersonLab/clas12alignment into…
raffaelladevita Mar 26, 2024
8ae55e9
fix setting of doca cuts and added more logging
raffaelladevita Mar 27, 2024
dea57ba
added command line option to set the ecal cut, plotting pulls instead…
raffaelladevita Apr 9, 2024
6066359
added vertex fit for Spring18
raffaelladevita Apr 12, 2024
3377be7
fixing the target length in the RG-A Spring18 fits
raffaelladevita Apr 15, 2024
fee2a99
changing moller cone distance to FTon
raffaelladevita Apr 18, 2024
55a4883
added angular plot of time residuals
raffaelladevita May 3, 2024
dace5bb
do not refit time residual if fit is stored
raffaelladevita May 16, 2024
1f97e24
creating timeValues array even if tres is false
raffaelladevita May 17, 2024
d92163f
version bump
raffaelladevita May 31, 2024
54d5b5b
added time residuals for left right hits
raffaelladevita Jun 17, 2024
3c0035a
making LR time residual plots layer dependent
raffaelladevita Jun 18, 2024
2212d5d
saving LR time residuals to the histogram file
raffaelladevita Jun 18, 2024
f50d04a
saving LR time residuals to the histogram file
raffaelladevita Jun 18, 2024
66625bb
added region-by-region before/after plots
raffaelladevita Jun 20, 2024
b27a189
file name now shown in the jframe title and code cleanups
raffaelladevita Jul 15, 2024
77ca9df
more vertex plots in kinematics.groovy
raffaelladevita Jul 26, 2024
6d3698e
added RG-K vertex fit function, excluding measurements with failed fi…
raffaelladevita Aug 23, 2024
34877bd
now really switching -fit parser options to use inputlist
raffaelladevita Aug 27, 2024
7a1e6e6
merged master
raffaelladevita Aug 27, 2024
129551f
updated .gitignore with dc specific files
raffaelladevita Aug 27, 2024
b5bd993
plot only non empty graphs when running only with r0
raffaelladevita Aug 29, 2024
dd7c746
fixed issue with skim script
raffaelladevita Sep 6, 2024
cd89fd5
version bump
raffaelladevita Dec 12, 2024
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
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ target/
*.class
*.jar

# DC-specific files.
dc/java/dc-alignment/*.hipo
dc/java/dc-alignment/dc-alignment.log*
dc/java/dc-alignment/*.sqlite
dc/java/dc-alignment/*.txt
dc/utilities/*.hipo

# FMT-specific files.
fmt/*.hipo
fmt/error_report.txt
2 changes: 1 addition & 1 deletion dc/java/dc-alignment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.clas.detector</groupId>
<artifactId>dc-alignment</artifactId>
<version>2.1</version>
<version>2.2</version>
<packaging>jar</packaging>

<properties>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class Constants {
public static int VDFBINS = 200;
public static double VDFMIN = -5.0;
public static double VDFMAX = 5.0;
public static double CHI2MAX = 2.5;


// global fit
Expand Down Expand Up @@ -74,6 +75,7 @@ public class Constants {


// measurements weight
public static double[][][][] MEASWEIGHTS = null;
public static double[] MEASWEIGHT = { 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1,
Expand Down
139 changes: 126 additions & 13 deletions dc/java/dc-alignment/src/main/java/org/clas/dc/alignment/Histo.java
Original file line number Diff line number Diff line change
Expand Up @@ -516,9 +516,8 @@ private void processEvent(Event event, Event shifted) {
else
this.leftright[sector-1][it][ip].getH1F("hi-lL" + hit.layer).fill(hit.time);
}
}
this.vertex[it][ip].getH1F("hi-S" + sector).fill(vz);

}
this.vertex[it][ip].getH1F("hi-S" + sector).fill(vz);
}
}
}
Expand Down Expand Up @@ -650,6 +649,9 @@ public void analyzeHisto(int fit, int vertexFit) {
// if(l>24) this.parErrors[is][it][ip][l] *= 2;
}
}
else {
Constants.MEASWEIGHTS[is][it][ip][l]=0;
}
System.out.print("\r");
}
H1F hvtx = vertex[it][ip].getH1F("hi-S"+s);
Expand All @@ -669,18 +671,29 @@ public void analyzeHisto(int fit, int vertexFit) {
if(hvtx.getFunction().parameter(i).name().equals("sc")) isc = i;
if(hvtx.getFunction().parameter(i).name().equals("scw")) iscw = i;
}
if(isc>=0 && iscw>=0 && hvtx.getFunction().getParameter(isc)>10) {
if(isc>=0 && iscw>=0 && hvtx.getFunction().getParameter(isc)>0) {
this.parValues[is][it][ip][nLayer+nTarget-1] = (hvtx.getFunction().getParameter(iscw)-Constants.SCEXIT)*Constants.SCALE;
this.parErrors[is][it][ip][nLayer+nTarget-1] = Math.max(hvtx.getFunction().parameter(iscw).error()*Constants.SCALE, Constants.SCALE*dx);
this.parSigmas[is][it][ip][nLayer+nTarget-1] = hvtx.getFunction().getParameter(2)*Constants.SCALE;
}
if(itl>=0 && hvtx.getFunction().getParameter(0)>10) {
else {
Constants.MEASWEIGHTS[is][it][ip][nLayer+nTarget-1]=0;
}
if(itl>=0 && hvtx.getFunction().getParameter(0)>0) {
this.parValues[is][it][ip][nLayer+nTarget-2] = (hvtx.getFunction().getParameter(itl)-Constants.TARGETLENGTH)*Constants.SCALE;
this.parErrors[is][it][ip][nLayer+nTarget-2] = Math.max(hvtx.getFunction().parameter(itl).error()*Constants.SCALE, Constants.SCALE*dx);
this.parSigmas[is][it][ip][nLayer+nTarget-2] = hvtx.getFunction().getParameter(2)*Constants.SCALE;
}
else {
Constants.MEASWEIGHTS[is][it][ip][nLayer+nTarget-2]=0;
}
}
}
else {
Constants.MEASWEIGHTS[is][it][ip][0]=0;
Constants.MEASWEIGHTS[is][it][ip][nLayer+nTarget-2]=0;
Constants.MEASWEIGHTS[is][it][ip][nLayer+nTarget-1]=0;
}
}
}
}
Expand Down Expand Up @@ -714,12 +727,14 @@ public void getFailedFitStats() {
!residuals[is][it][ip].getH1F("hi-L"+l).getFunction().isFitValid()) {
nfailed++;
LOGGER.log(Level.WARNING, String.format("\tResidual fit for sector=%1d theta bin=%1d phi bin=%1d layer=%2d FAILED",is+1,it,ip,l));
residuals[is][it][ip].getH1F("hi-L"+l).getFunction().setChiSquare(-Math.abs(residuals[is][it][ip].getH1F("hi-L"+l).getFunction().getChiSquare()));
}
}
if(vertex[it][ip].getH1F("hi-S"+(is+1)).getFunction()!=null &&
!vertex[it][ip].getH1F("hi-S"+(is+1)).getFunction().isFitValid()) {
nfailed++;
LOGGER.log(Level.WARNING, String.format("\tVertex fit for sector=%1d theta bin=%1d phi bin=%1d FAILED",is+1,it,ip));
vertex[it][ip].getH1F("hi-S"+(is+1)).getFunction().setChiSquare(-Math.abs(vertex[it][ip].getH1F("hi-S"+(is+1)).getFunction().getChiSquare()));
}
}
}
Expand Down Expand Up @@ -756,7 +771,7 @@ public double[] getParValues(String parameter, int sector, int itheta, int iphi)
else if(parameter.equals("LR"))
return this.lrValues[sector-1][itheta][iphi];
else
return this.parValues[sector-1][itheta][iphi];
return this.getWeightedParValues(sector, itheta, iphi);
}

public double[] getParErrors(String parameter, int sector, int itheta, int iphi) {
Expand All @@ -771,7 +786,7 @@ public double[] getParErrors(String parameter, int sector, int itheta, int iphi)
else if(parameter.equals("LR"))
return this.zeroes[sector-1][itheta][iphi];
else
return this.parErrors[sector-1][itheta][iphi];
return this.getWeightedParErrors(sector, itheta, iphi);
}

public double[] getParSigmas(String parameter, int sector, int itheta, int iphi) {
Expand All @@ -789,6 +804,22 @@ else if(parameter.equals("LR"))
return this.parSigmas[sector-1][itheta][iphi];
}

private double[] getWeightedParValues(int sector, int itheta, int iphi) {
double[] wpars = new double[parValues[sector-1][itheta][iphi].length];
for(int il=0; il<wpars.length; il++) {
wpars[il] = parValues[sector-1][itheta][iphi][il]*Constants.MEASWEIGHTS[sector-1][itheta][iphi][il];
}
return wpars;
}

private double[] getWeightedParErrors(int sector, int itheta, int iphi) {
double[] wpars = new double[parErrors[sector-1][itheta][iphi].length];
for(int il=0; il<wpars.length; il++) {
wpars[il] = parErrors[sector-1][itheta][iphi][il]*Constants.MEASWEIGHTS[sector-1][itheta][iphi][il];
}
return wpars;
}

public EmbeddedCanvasTabbed getElectronPlots() {
EmbeddedCanvasTabbed canvas = new EmbeddedCanvasTabbed("electron", "binning", "offset");
canvas.getCanvas("electron").draw(electron);
Expand Down Expand Up @@ -903,14 +934,27 @@ private static boolean fitVertex(int mode, H1F histo) {
case 8:
Histo.fitRGAS18Vertex(histo);
break;
case 9:
Histo.fitRGKVertex(histo);
break;
default:
if(histo.getFunction()!=null)
histo.getFunction().setFitValid(true);
if(histo.getFunction()!=null) {
if(histo.getFunction().getChiSquare()>0)
histo.getFunction().setFitValid(true);
else
histo.getFunction().setFitValid(false);
}
break;
}
histo.getFunction().setStatBoxFormat("%.2f");
histo.getFunction().setStatBoxErrorFormat("%.2f");
return histo.getFunction().isFitValid();
if(histo.getFunction()!=null) {
if(histo.getFunction().getChiSquare()/histo.getFunction().getNDF()>Constants.CHI2MAX)
histo.getFunction().setFitValid(false);
histo.getFunction().setStatBoxFormat("%.2f");
histo.getFunction().setStatBoxErrorFormat("%.2f");
return histo.getFunction().isFitValid();
}
else
return false;
}


Expand Down Expand Up @@ -992,7 +1036,10 @@ else if(fit>0) {
}
}
else if(histo.getFunction()!=null) {
histo.getFunction().setFitValid(true);
if(histo.getFunction().getChiSquare()>0)
histo.getFunction().setFitValid(true);
else
histo.getFunction().setFitValid(false);
}
histo.getFunction().setStatBoxFormat("%.1f");
histo.getFunction().setStatBoxErrorFormat("%.1f");
Expand Down Expand Up @@ -1384,6 +1431,72 @@ public static void fitRGDVertex(H1F histo) {
}

/**
<<<<<<< HEAD
* 3-peaks vertex fitting function
* Peaks correspond to: target windows and scattering chamber exit window
* Initialized according to:
* - chosen target length (TARGETLENGTH),
* - target exit window position (TARGETPOS)
* - distance between target exit window and insulation foil (WINDOWDIST)
* - distance between the scattering chamber exit window and the target center (SCEXIT)
* Includes two wide Gaussians to account for target residual gas
* and the air outside the scattering chamber
* @param histo
*/
public static void fitRGKVertex(H1F histo) {
int nbin = histo.getData().length;
double dx = histo.getDataX(1)-histo.getDataX(0);
//find downstream window
int ibin0 = Histo.getMaximumBinBetween(histo, histo.getDataX(0), (Constants.TARGETPOS+Constants.SCEXIT)/2);
//check if the found maximum is the first or second peak, ibin is tentative upstream window
int ibin1 = Math.max(0, ibin0 - (int)(Constants.TARGETLENGTH/dx));
int ibin2 = Math.min(nbin-1, ibin0 + (int)(Constants.TARGETLENGTH/dx));
if(histo.getBinContent(ibin1)<histo.getBinContent(ibin2)) {
ibin1 = ibin0;
ibin0 = ibin2;
}
int ibinsc = Histo.getMaximumBinBetween(histo, (Constants.SCEXIT+Constants.TARGETCENTER)*0.8, (Constants.SCEXIT+Constants.TARGETCENTER)*1.2);

double mean = histo.getDataX(ibin0);
double amp = histo.getBinContent(ibin0);
double sigma = 0.5;
double sc = histo.getBinContent(ibinsc);
double air = histo.getBinContent(ibinsc + ((int) (sigma*6/dx)));
double scw = Constants.SCEXIT;
if(sc>10) scw = histo.getDataX(ibinsc)-mean+Constants.TARGETLENGTH/2;
double bg = histo.getBinContent((ibin1+ibin0)/2);
String function = "[ampU]*gaus(x,[exw]-[tl],[sigma])+"
+ "[ampD]*gaus(x,[exw],[sigma])+"
+ "[bg]*gaus(x,[exw]-[tl]/2,[tl]*0.6)+"
+ "[sc]*gaus(x,[exw]+[scw]-[tl]/2,[sigma])+"
+ "[air]*gaus(x,[exw]+[scw]-[tl]/2+[adelta],[asigma])";
F1D f1_vtx = new F1D("f"+histo.getName(), function, -10, 10);
f1_vtx.setLineColor(2);
f1_vtx.setLineWidth(2);
f1_vtx.setOptStat("1111111111111");
f1_vtx.setParameter(0, amp);
f1_vtx.setParameter(1, mean);
f1_vtx.setParameter(2, Constants.TARGETLENGTH);
f1_vtx.setParLimits(2, Constants.TARGETLENGTH*0.9, Constants.TARGETLENGTH*1.1);
f1_vtx.setParameter(3, sigma);
f1_vtx.setParameter(4, amp);
f1_vtx.setParameter(5, bg);
f1_vtx.setParameter(6, sc);
f1_vtx.setParameter(7, scw);
f1_vtx.setParLimits(7, (Constants.SCEXIT)*0.7, (Constants.SCEXIT)*1.3);
f1_vtx.setParameter(8, air);
f1_vtx.setParameter(9, sigma*3);
f1_vtx.setParLimits(9, 0, sigma*8);
f1_vtx.setParameter(10, sigma*8);
f1_vtx.setRange(mean-Constants.TARGETLENGTH*2.0,Constants.SCEXIT+Constants.TARGETLENGTH*0.6);
// histo.setFunction(f1_vtx);
DataFitter.fit(f1_vtx, histo, "Q"); //No options uses error for sigma
// if(f1_vtx.getParameter(6)<f1_vtx.getParameter(0)/4) f1_vtx.setParameter(6, 0);
}

/**
=======
>>>>>>> master
* 4-peaks vertex fitting function
* Peaks correspond to: target windows and scattering chamber exit window
* Initialized according to:
Expand Down
2 changes: 1 addition & 1 deletion dc/utilities/createSkims.csh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ else
set vars = "r0 r1_x r1_y r1_z r1_cy r1_cz r2_x r2_y r2_z r2_cy r2_cz r3_x r3_y r3_z r3_cy r3_cz"
endif

set schema = `ls $indir/r0`
set schema = `ls $indir/r0/*/recon/README.json | awk -F"$indir/r0/" '{print $2}' | awk -F"/" '{print $1}'`

echo
echo reading input files from $indir with subdirectory $schema
Expand Down
31 changes: 28 additions & 3 deletions dc/utilities/kinematics.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,24 @@ public class Kinematics {
private Map<String, DataGroup> histos = new LinkedHashMap<>();


public Kinematics(double energy) {
public Kinematics(double energy, String vertex) {
this.initGraphics();
this.initVertexPar(vertex);
this.setEbeam(energy);
}

private void initVertexPar(String pars) {
if(!pars.isEmpty()) {
double[] parValues = new double[pars.split(":").length];
for(int i=0; i<parValues.length; i++) {
parValues[i] = Double.parseDouble(pars.split(":")[i]);
}
if(parValues.length>0) targetPos = parValues[0];
if(parValues.length>1) targetLength = parValues[1];
if(parValues.length>2) scWindow = parValues[2]+targetPos;
}
}

public double getEbeam() {
return ebeam;
}
Expand Down Expand Up @@ -724,12 +737,22 @@ public class Kinematics {
parser.getOptionParser("-process").addOption("-beam" ,"10.6", "beam energy in GeV");
parser.getOptionParser("-process").addOption("-display" ,"1", "display histograms (0/1)");
parser.getOptionParser("-process").addOption("-stats" ,"", "histogram stat option");
parser.getOptionParser("-process").addOption("-vertpar" , "", "comma-separated vertex function parameters, default values are for Spring19 cryotarget with:\n" +
"\t\t- -3.5: target cell exit window position,\n" +
"\t\t- 5.0: target length,\n" +
"\t\t- 27.3: distance between the scattering chamber exit window and the target center,\n" +
"\t\t leave empty to use defaults; units are cm");

// valid options for histogram-base analysis
parser.addCommand("-plot", "plot histogram files");
parser.getOptionParser("-plot").addOption("-beam" ,"10.6", "beam energy in GeV");
parser.getOptionParser("-plot").addOption("-display" ,"1", "display histograms (0/1)");
parser.getOptionParser("-plot").addOption("-stats" ,"", "set histogram stat option");
parser.getOptionParser("-plot").addOption("-vertpar" , "", "comma-separated vertex function parameters, default values are for Spring19 cryotarget with:\n" +
"\t\t- -3.5: target cell exit window position,\n" +
"\t\t- 5.0: target length,\n" +
"\t\t- 27.3: distance between the scattering chamber exit window and the target center,\n" +
"\t\t leave empty to use defaults; units are cm");

parser.parse(args);

Expand All @@ -742,6 +765,7 @@ public class Kinematics {
if(parser.getCommand().equals("-process")) {
int maxEvents = parser.getOptionParser("-process").getOption("-nevent").intValue();
double beamEnergy = parser.getOptionParser("-process").getOption("-beam").doubleValue();
String vertexPar = parser.getOptionParser("-process").getOption("-vertpar").stringValue();
String namePrefix = parser.getOptionParser("-process").getOption("-o").stringValue();
String histoName = "histo.hipo";
if(!namePrefix.isEmpty()) {
Expand All @@ -758,7 +782,7 @@ public class Kinematics {
System.exit(0);
}

analysis = new Kinematics(beamEnergy);
analysis = new Kinematics(beamEnergy, vertexPar);

ProgressPrintout progress = new ProgressPrintout();

Expand Down Expand Up @@ -790,6 +814,7 @@ public class Kinematics {

if(parser.getCommand().equals("-plot")) {
double beamEnergy = parser.getOptionParser("-plot").getOption("-beam").doubleValue();
String vertexPar = parser.getOptionParser("-plot").getOption("-vertpar").stringValue();
optStats = parser.getOptionParser("-plot").getOption("-stats").stringValue();
openWindow = parser.getOptionParser("-plot").getOption("-display").intValue()!=0;
if(!openWindow) System.setProperty("java.awt.headless", "true");
Expand All @@ -801,7 +826,7 @@ public class Kinematics {
System.exit(0);
}

analysis = new Kinematics(beamEnergy);
analysis = new Kinematics(beamEnergy, vertexPar);
analysis.readHistos(inputList.get(0));
analysis.analyzeHistos();
}
Expand Down
Loading