Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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.2</version>
<version>2.3</version>
<packaging>jar</packaging>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,9 @@ public static void main(String[] args){
parser.getOptionParser("-process").addOption("-time" , "0", "make time residual histograms (1=true, 0=false)");
parser.getOptionParser("-process").addOption("-residuals", "2", "fit residuals with double gaussian (2), single gaussian (1), or use mean (0)");
parser.getOptionParser("-process").addOption("-vertfit" , "5", "fit vertex plots with:\n" +
"\t\t- RG-E layout (10), dual target, \n" +
"\t\t- RG-A Spring18 layout (9)\n" +
"\t\t- RG-K layout (8), new cryotarget, \n" +
"\t\t- RG-D layout (7), new cryotarget, \n" +
"\t\t- RG-C layout (6),\n" +
"\t\t- 4 gaussians (5),\n" +
Expand Down Expand Up @@ -1176,6 +1179,9 @@ public static void main(String[] args){
parser.getOptionParser("-analyze").addOption("-shifts" , "0", "use event-by-event subtraction for unit shifts (1=on, 0=off)");
parser.getOptionParser("-analyze").addOption("-residuals", "2", "fit residuals (2), use mean (1), or use existing fit available (0)");
parser.getOptionParser("-analyze").addOption("-vertfit" , "5", "fit vertex plots with:\n" +
"\t\t- RG-E layout (10), dual target, \n" +
"\t\t- RG-A Spring18 layout (9)\n" +
"\t\t- RG-K layout (8), new cryotarget, \n" +
"\t\t- RG-D layout (7), new cryotarget,\n" +
"\t\t- RG-C layout (6),\n" +
"\t\t- 4 gaussians (5),\n" +
Expand Down Expand Up @@ -1207,6 +1213,9 @@ public static void main(String[] args){
parser.getOptionParser("-fit").addOption("-shifts" , "0", "use event-by-event subtraction for unit shifts (1=on, 0=off)");
parser.getOptionParser("-fit").addOption("-sector" , "1", "sector-dependent derivatives (1) or average (0)");
parser.getOptionParser("-fit").addOption("-vertfit" , "5", "fit vertex plots with:\n" +
"\t\t- RG-E layout (10), dual target, \n" +
"\t\t- RG-A Spring18 layout (9)\n" +
"\t\t- RG-K layout (8), new cryotarget, \n" +
"\t\t- RG-D layout (7), new cryotarget, \n" +
"\t\t- RG-C layout (6),\n" +
"\t\t- 4 gaussians (5),\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ public class Constants {
public static int NPARS = 18;

// size of unit shift (cm for ri_xyz, deg for ri_cxyz
// public static double[] UNITSHIFT = { 0.1, 0.8, 0.2, 0.2, 0.2, 0.4,
// 0.05, 0.4, 0.1, 0.2, 0.1, 0.2,
// 0.1, 0.8, 0.2, 0.2, 0.1, 0.4};
// public static double[] UNITSHIFT = { 0.05, 0.4, 0.1, 0.1, 0.1, 0.1,
// 0.025, 0.2, 0.05, 0.05, 0.05, 0.05,
// 0.05, 0.4, 0.1, 0.05, 0.05, 0.05};
public static double[] UNITSHIFT = { 0.1, 0.8, 0.2, 0.2, 0.2, 0.2,
0.1, 0.8, 0.2, 0.2, 0.2, 0.2,
0.1, 0.8, 0.2, 0.2, 0.2, 0.2};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,9 @@ private static boolean fitVertex(int mode, H1F histo) {
case 9:
Histo.fitRGKVertex(histo);
break;
case 10:
Histo.fitRGEVertex(histo);
break;
default:
if(histo.getFunction()!=null) {
if(histo.getFunction().getChiSquare()>0)
Expand Down Expand Up @@ -1552,6 +1555,75 @@ public static void fitRGAS18Vertex(H1F histo) {
// if(f1_vtx.getParameter(6)<f1_vtx.getParameter(0)/4) f1_vtx.setParameter(6, 0);
}


/**
* 5-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 wide Gaussians to account for target residual gas and the air
* outside the scattering chamber
* @param histo
*/
public static void fitRGEVertex(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])+"
+ "[ampw]*gaus(x,[exw]+[wd],[sigma])+"
+ "[ampw]*gaus(x,[exw]+[wd]*2,[sigma])/3+"
+ "[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("111111111111111");
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, amp);
f1_vtx.setParameter(6, Constants.WINDOWDIST);
f1_vtx.setParLimits(6, Constants.WINDOWDIST*0.9, Constants.WINDOWDIST*1.1);
f1_vtx.setParameter(7, bg);
f1_vtx.setParameter(8, sc);
f1_vtx.setParameter(9, scw);
f1_vtx.setParLimits(9, (Constants.SCEXIT)*0.7, (Constants.SCEXIT)*1.3);
f1_vtx.setParameter(10, air);
f1_vtx.setParameter(11, sigma*3);
f1_vtx.setParLimits(11, 0, sigma*8);
f1_vtx.setParameter(12, 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);
}

//This was a previous version of fitting the z vertex peaks
public static void fitVertex(H1F histo) {
double mean = histo.getDataX(histo.getMaximumBin());
Expand Down
Loading