modified: sx3cal/EXFit.C

modified:   sx3cal/LRFit.C
This commit is contained in:
Vignesh Sitaraman 2026-03-30 09:52:31 -04:00
parent e0f2fa192c
commit 68efdadc8f
35 changed files with 1303 additions and 8 deletions

View File

@ -70,6 +70,7 @@
{
"name": "VigneshROG",
"includePath": [
"/home/vsitaraman/**",
"${workspaceFolder}/**",
"/home/vsitaraman/root/include/**"
],

0
ELoss/Eloss_17F Normal file → Executable file
View File

0
ELoss/Eloss_27Al Normal file → Executable file
View File

0
ELoss/Eloss_alpha Normal file → Executable file
View File

0
ELoss/Eloss_p Normal file → Executable file
View File

41
gmsx3/func1.h Executable file
View File

@ -0,0 +1,41 @@
#include "TF1.h"
double model2(double *x, double *par) {
/* 'Potential Well' of width 2a from from xx-a to xx+a
xx is coordinate about the point of origin, set at x=center
v0 is the y-offset of the potential
k is the 'steepness' of the potential
continuous across xx-a and xx+a, and differentiable
*/
double center= par[3];
double xx = x[0]-center;
double a = TMath::Abs(par[0]);
double k = TMath::Abs(par[1]);
double v0 = par[2];
if(xx < -a)
return k*(xx+a)*(xx+a) + v0;
else if(xx > a)
return k*(xx-a)*(xx-a) + v0;
else
return v0;
}
void func1() {
//TF1 f1("bowl",model,-2.,2.,2);
TCanvas c("c1","c1",800,600);
TF1 f1("bowl",model2,-10.,10.,4);
f1.SetMaximum(10);
for(int i=-4; i<4; i++) {
f1.SetParameters(.4,100,2,i); //a, k, v0, center
f1.SetNpx(100000);
if(i==-4) f1.Draw("L");
f1.DrawCopy("L SAME");
c.Modified(); c.Update();
//c.SaveAs(Form("%d.png",out));
while(c.WaitPrimitive());
}
}

216
gmsx3/intgm_sx3.h Executable file
View File

@ -0,0 +1,216 @@
#include "../Armory/HistPlotter.h"
#include <Minuit2/FCNBase.h>
#include <Math/Minimizer.h>
#include <Math/Factory.h>
#include <Math/Functor.h>
#include <TMath.h>
#include <TPad.h>
#include <cassert>
#include <vector>
#include <array>
#include <iostream>
#include <TF1.h>
#include "func1.h"
static long iters=0;
//class intgm_sx3 : public ROOT::Minuit2::FCNBase {
class intgm_sx3 {
int N;
//L.at(0).at(3).at(n) is front strip = 0, back pad = 3, nth datapoint
std::array<std::array<std::vector<double>,4>,4> L,R,B;
//std::array<std::array<double,5>,4> stripedge; //stripedge.at(i).at(j) is the jth edge of the ith strip. there are five edges for the four strips 'i'=0 to 3, (0,1) (1,2) (2,3) (3,4) for each
//the edges are at -2a, -a, 0, a, 2a respectively so we enforce four ratios in the chi2 value - 'a' can be held constant, no need to fit it.
//assume z = M*(aL-bR)
//stripedge[i][1] = max(z) when pad==0 = min(z) when pad==1 this should be -1
//stripedge[i][2] = max(z) when pad==1 = min(z) when pad==2. this should be 0
//stripedge[i][3] = max(z) when pad==2 = min(z) when pad==3. this should be 1
//i.e. stripedge[i][j] = max(z) when pad == j-1, min(z) when pad==j, for i= 1,2,3
//ncounts.at(frontch).at(backch) is the number of (L,R,B) tuples we've filled (frontch,backch) coordinates in the detector
std::array<std::array<long,4>,4> ncounts;
TH1F *localhists[4][4]; //one histogram for each fc, bc combination
HistPlotter *plotter;
TF1 *pos_weight[4];
TF1 *energywell;
public:
intgm_sx3() {
for(int bc=0; bc<4; bc++) {
for(int fc=0; fc<4; fc++) {
L[fc][bc].reserve(1000);
R[fc][bc].reserve(1000);
B[fc][bc].reserve(1000);
//localhists[fc][bc] = new TH1F(Form("h_%d_%d",fc,bc),Form("h_%d_%d",fc,bc),1000,-4.,4.);
ncounts[fc][bc] = 0;
}
pos_weight[bc] = new TF1(Form("b_strip%d",bc),model2,-10,10,4); //from -10, to 10, 4 parameters
pos_weight[bc]->SetParameters(1.0,10,1.,3-2*bc); //centers at 1, 3.,5,7 Width 2a with a=1.0
pos_weight[bc]->SetNpx(1'000'000);
}
energywell = new TF1("ewell",model2,0,2000,4); //0 to 2000 channels, 4 params
energywell->SetParameters(1000,20,1,1500); //center the back E values at 1500 +/- 500
energywell->SetNpx(1'000'000);
N=0;
}
void set_plotter(HistPlotter *p) {plotter=p;}
void set_iters(long i) { iters=i;}
intgm_sx3(HistPlotter *p) : plotter(p) {
for(int bc=0; bc<4; bc++) {
for(int fc=0; fc<4; fc++) {
L[fc][bc].reserve(1000);
R[fc][bc].reserve(1000);
B[fc][bc].reserve(1000);
//localhists[fc][bc] = new TH1F(Form("h_%d_%d",fc,bc),Form("h_%d_%d",fc,bc),1000,-4.,4.);
ncounts[fc][bc] = 0;
}
pos_weight[bc] = new TF1(Form("b_strip%d",bc),model2,-10,10,4); //from -10, to 10, 4 parameters
//a/2, k, v0, center
pos_weight[bc]->SetParameters(0.92,10,1.,-1.*(3-2*bc)); //centers at 7, 5.,3,1 Width 2a with a=1.0
pos_weight[bc]->SetNpx(1'000'000);
}
energywell = new TF1("ewell",model2,0,8000,4); //0 to 2000 channels, 4 params
// energywell->SetParameters(60,10,0,1430); //center the back E values at 1430 +/- 60
energywell->SetParameters(400,10,0,5246); //center the back E values at 5486 +/- 600
energywell->SetNpx(1'000'000);
N=0;
}
inline void fill(int fc, int bc, double leftE, double rightE, double backE) {
/*
*
*/
assert(fc>=0 && fc<=3 && "Front channels should fit the range 0 to 3 inclusive!");
assert(bc>=0 && bc<=3 && "Back channels should fit the range 0 to 3 inclusive!");
if(leftE>0 && rightE >0 && backE>0) {
L[fc][bc].emplace_back(leftE);
R[fc][bc].emplace_back(rightE);
B[fc][bc].emplace_back(backE);
ncounts[fc][bc]+=1;
N+=1;
}
}
inline void print() {
for(int i=0; i<16; i++) {
std::cout << ncounts[i%4][i/4] << std::endl;
}
}
inline void plot(std::string comment, const double* params) {
std::array<double,4> l,r,b,bo,ro,lo,offset,stretch; //aliases to help with book-keeping
std::array<std::array<double,4>,4> back_gains;// back_gains[fc][bc] are for fc,bc firing in combo
for(int ctr=0; ctr<4; ctr++) {
r[ctr] = params[ctr];
}
for(int ctr=4; ctr<20; ctr++) {
int bch = (ctr-4)%4;
int fch = (ctr-4)/4;
back_gains[bch][fch] = params[ctr];
}
for(int ctr=20; ctr<24; ctr++) {
stretch[ctr-20] = params[ctr];
}
for(int ctr=24; ctr<28; ctr++) {
l[ctr-24] = params[ctr];
}
for(int fc=0; fc<4; fc++) {
for(int bc=0; bc<4; bc++) {
for(int n=0; n<ncounts[fc][bc]; n++) {
if(plotter) {
double left = l[fc]*L[fc][bc].at(n);
double right = r[fc]*R[fc][bc].at(n);
double back = back_gains[bc][fc]*B[fc][bc].at(n);
//double zpos = (left - right)/(left+right);
double zpos = stretch[fc]*(left - right)/(left+right);// + offset[fc]; //back;
plotter->Fill2D(Form("normlf_fc%d_%d_%s",fc,bc,comment.c_str()),800,0,1.,800,0,1.,left/back, right/back,"l_vs_r");
plotter->Fill2D(Form("normlf_all_%s",comment.c_str()),800, 0, 1., 800, 0, 1.,left/back, right/back);
plotter->Fill2D(Form("case_f%d_b%d_%s",fc,bc,comment.c_str()),800,0,8192,800,0,8192,left+right,back,"l_vs_r");
plotter->Fill2D(Form("case_all_%s",comment.c_str()),800,0,8192,800,0,8192,left+right,back);
//plotter->Fill2D(Form("z_vs_backe_f%d_b%d_%s",fc,bc,comment.c_str()),800,-10,10,800,0,8192,zpos,back,"z_vs_be");
plotter->Fill2D(Form("z_vs_backe_all_%s",comment.c_str()),800,-10,10,800,0,8192,zpos,back);
} //end if plotter
}// end for-n
}//end for-bc
}//end for-fc
}//end plot()
// double operator()(const std::vector<double>& params) const override{
double eval(const double* params) const {
iters+=1;
std::array<double,4> l,r,b,bo,ro,lo, offset, stretch; //aliases to help with book-keeping
std::array<std::array<double,4>,4> back_gains;// back_gains[fc][bc] are for fc,bc firing in combo
for(int ctr=0; ctr<16; ctr++) {
int bch = (ctr)%4;
int fch = (ctr)/4;
back_gains[bch][fch] = params[ctr];
}
for(int ctr=16; ctr<20; ctr++) {
r[ctr-16] = params[ctr];
l[ctr-16] = 1.0;
}
for(int ctr=20; ctr<24; ctr++) {
stretch[ctr-20] = params[ctr];
}
double result=0, sumcount=0;
for(int fc=0; fc<4; fc++) {
for(int bc=0; bc<4; bc++) {
//if(bc >= 1 || fc >= 1 ) continue;
if(ncounts[fc][bc] == 0 && iters ==0) {
std::cout << "Missing any data in front:" << fc << " back:" << bc << " combination." << std::endl;
}
for(int n=0; n<ncounts[fc][bc] ; n++) {
//double left = l[fc]*L[fc][bc].at(n) + lo[fc];
//double right = r[fc]*R[fc][bc].at(n) + ro[fc];
//double back = b[bc]*B[fc][bc].at(n) + bo[bc];
//double add = TMath::Power(left + right - back,2);
if(B[fc][bc].at(n)<100) continue;//ignore events too close to noise threshold
double left = l[fc]*L[fc][bc].at(n);
double right = r[fc]*R[fc][bc].at(n);
double back = back_gains[bc][fc]*B[fc][bc].at(n);
double lnorm = left/B[fc][bc].at(n);
double rnorm = right/B[fc][bc].at(n);
//double add = TMath::Power(left/back + right/back - 1.0,2);
double add = TMath::Power(left + right - back,2);
double zpos = stretch[fc]*(left - right)/(left+right); //back;
std::cout << zpos << " " << pos_weight[bc]->Eval(zpos) << " " << bc << std::endl;
double add_position = pos_weight[bc]->Eval(zpos);
double eback_align_penalty = energywell->Eval(back);
/* if(back>1000) zmid[fc][bc] += zpos;
if(back>1000 && zpos < zmin[fc][bc]) zmin[fc][bc] = zpos;
if(back> 1000 && zpos > zmax[fc][bc]) zmax[fc][bc] = zpos;
if(back>1000) {
localhists[fc][bc]->Fill(zpos);
}*/
result += add_position;
//result += add;
result += eback_align_penalty;
sumcount+=1;
//if(bc==0) std::cout << add << " " << add_position << " " << zpos << std::endl;
//To avoid drift towards (0,0,0) trivial solution. This value ~1 close to (1,1,1)
//result+=(1e-3/(TMath::Power(l[fc],2)+TMath::Power(r[fc],2)+TMath::Power(b[bc],2)+1e-9));
//result+=(1e-3/(TMath::Power(l[fc],2)+TMath::Power(r[fc],2)+TMath::Power(b[bc],2)+1e-9));
} //end for-n
} //end for-bc
} //end for-fc
result/=sumcount; //normalize, so the value doesn't scream
if(iters%1'000==0) {
std::cout << "iters : " << iters << " params: " << std::endl ;
for(int i=0 ; i< 10; i++) std::cout << params[i] << " " << std::flush;
std::cout<< std::endl;
for(int i=10 ; i< 20; i++) std::cout << params[i] << " " << std::flush;
std::cout << std::endl << " result: " << result << std::endl;
} //end if
return result;
} //end eval()
//double Up() const override { return 1.0; } // Required by minuit2 FCBase
};

338
gmsx3/utilities_orr.h Executable file
View File

@ -0,0 +1,338 @@
#ifndef UTILS_ORR_H
#define UTILS_ORR_H
#include "datatypes.h"
#include "HistPlotter.h"
#include "Geometry_orr.h" //contains orruba geometry constants
#include <cassert>
#include <stdio.h>
#include <cassert>
#include <cstdint>
#include <fcntl.h>
#include <unistd.h>
#include <vector>
//#include <cstring>
#include <string>
#include <fstream>
#include <sstream>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <set>
#include <sys/stat.h>
#include "TMath.h"
#include "counters.h"
static named_counter oc("named orruba counters");
inline float get_filesize(std::string filename) {
struct stat st;
stat(filename.c_str(), &st);
return st.st_size;
}
class orruba_params {
/*
*
*/
public:
int chnum=DEFAULT_NULL; //!< global channel number
std::string type = "-";
int id=DEFAULT_NULL;
int layer=DEFAULT_NULL;
int frontback=DEFAULT_NULL;
int updown=DEFAULT_NULL;
int subid=DEFAULT_NULL;
int leftright=DEFAULT_NULL;
float ped=DEFAULT_NULL;
float offset=DEFAULT_NULL;
float gain=DEFAULT_NULL;
float gain2=DEFAULT_NULL; //for use with sx3's
};
class sx3_geometry_scalefactors {
public:
//If sx3 has L, R being the left and right extremities, we choose add, stretch here such that
// x_mm = (x_raw+add)*stretch; so add=abs(L), stretch=75/(abs(L)+R)
float add[4];
float stretch[4];
};
class qqq5_finegains {
public:
std::array<std::pair<float,float>,32> front;
//front.at(30).first = slope at clkpos 0, ring 30 for E front layer
//front.at(30).second = intercept for the same as above
std::array<std::pair<float,float>,4> back;
};
class sx3_fbgains {
public:
//Order of indices is [pad][strip]
float padoffsets[4][4];
float padgains[4][4];
float stripLoffsets[4][4];
float stripLgains[4][4];
float stripRoffsets[4][4];
float stripRgains[4][4];
};
//Metadata ORRUBA needs to know about itself, to be configured at the start
extern std::array<orruba_params,MAX_ORRUBA_CHANS> o_params;
extern std::array<sx3_fbgains,24> sx3_xtalk_gains; //every sx3 needs to be gainmatched as a frontL-back, frontR-back pair (pad strip pair)
extern std::array<sx3_geometry_scalefactors,24> sx3gs;
extern std::array<qqq5_finegains,4> qqq5_fg_dE, qqq5_fg_E;
class type19Raw {
public:
long int timestamp;
std::vector<unsigned short> ch;
std::vector<unsigned short> val;
type19Raw() : timestamp(0), ch(50,0), val(50,0) {} //Reserve 50 for size of these vectors, initial value of zero
void print() const {
/*
print()
Prints type19Raw's contents to stdout for monitoring
*/
std::cout << "------" << std::endl;
for(unsigned int ii=0; ii<ch.size(); ii++) {
std::cout << ch.at(ii) << " " << val.at(ii) << std::endl;
}
}
};
class sx3 {
public:
//TODO: Convert to std::array
//Holds all information in an event, including ped subtraction+scaling. back[2].at(0) will have the largest energy seen in ch2, if any
std::vector<float> back[4];
std::vector<float> frontL[4];
std::vector<float> frontR[4];
double ts = DEFAULT_NULL;
//Easy lookup of final calibrated event. Only filled for valid cases, assumed for now to be 1L, 1R, 1B
float frontX=DEFAULT_NULL;
float frontXmm=DEFAULT_NULL;
float frontE=DEFAULT_NULL;
float backE=DEFAULT_NULL;
int stripF=DEFAULT_NULL;
int stripB=DEFAULT_NULL;
float frontEL=DEFAULT_NULL;
float frontER=DEFAULT_NULL;
float phi=DEFAULT_NULL; //
std::set<int> valid_front_chans;
std::set<int> valid_back_chans;
std::set<int> unmatched_front_chans; //every front channel is unmatched and invalid at first. when it gets matched, it gets removed and sent to valid
bool foundevent=false;
bool valid=false;//valid will be set to false in all cases where we have ambiguity
int flags=-1;//flags settable to different types of values to indicate different invalid situations
void fillevent(const std::string& position, const int subchannel, const float value); //make 'const' what functions don't need to change, helps with performance
void validate(const sx3_fbgains&, const sx3_geometry_scalefactors&);
};
class qqq5 {
public:
//Holds all information in an event, including ped subtraction+scaling. front[2].at(0) will have the largest energy seen in ch2, if any
//TODO: Convert to std::array
std::vector<float> back[4];
std::vector<float> front[32];
double ts = DEFAULT_NULL;
float selftheta=DEFAULT_NULL,selfrho=DEFAULT_NULL;
//Easy lookup of the final calibrated event. Only filled for valid cases.
double frontE=DEFAULT_NULL;
double backE=DEFAULT_NULL;
int frontch;
int backch;
std::pair<int,int> adj_front_strips = {-1,-1};
std::pair<int,int> adj_back_strips = {-1,-1};
std::set<int> valid_front_chans; //list of channels that fire. can inspect size() of these to see if there are front/back events
std::set<int> valid_back_chans; // we use std::set since it makes for very readable code
bool foundevent=false;
bool valid=false; //valid will be set to false in all cases where we have ambiguity
int flags=-1; //flags settable to different types of values to indicate different invalid situations
void fillevent(const std::string& position, const int subchannel, const float value); //make 'const' what functions don't need to change, helps with performance
void validate();
};
struct orrubaevent {
//Every clean, valid charged-particle event will have these four parts
float dE=DEFAULT_NULL; //!< true energy-loss in the dE layer. Found by gainmatching ADC readout to alpha data
float E=DEFAULT_NULL; //!< energy deposited in the E layer. When summed with dE, gives true energy in keV deposited by the particle in ORRUBA
float dE_PID = DEFAULT_NULL; //!< dE scaled for dE-layer's thickness, reducing the spread due to angular straggling by explicitly accounting for it. This will give a sharper pid plot that can be gated on better
float dE_linPID = DEFAULT_NULL; //!< dE_PID, but linearized using the prescription described in, say, PhysRevC.90.034601 (2014). dE_linPID = ((dE+E)^a-E^a)^(1/a) where a ~ 1.68 is chosen empirically
float Theta=DEFAULT_NULL; //!< Laboratory polar angle of event in radians, deprecated
float Phi=DEFAULT_NULL; //!< Lab azimuthal angle of event in radians, deprecated
//Helpful indices to make dE-E plots
std::string type; //!< "endcap" vs "barrel"
//!< Identify the position of the detector in the barrel, usually in accordance with the channel map: say we might learn detector is at "Quad 4" or "clk_pos 10", together with 'type'. Useful with HistPlotter class
int position=DEFAULT_NULL;
int subchdE_1=DEFAULT_NULL, subchdE_2=DEFAULT_NULL; //!< Identify the subchannels corresponding to the two sides of the dE detector. To avoid confusion, 1=strip(sx3), ring(qqq) and 2=pad(sx3), wedge(qqq)
int subchE_1=DEFAULT_NULL, subchE_2=DEFAULT_NULL; //!< Identify the subchannels corresponding to the two sides of the E detector. Same convention as above
float x=DEFAULT_NULL,y=DEFAULT_NULL,z=DEFAULT_NULL; //!< Laboratory x,y,z coordinates of the event from the E layer
float r0=DEFAULT_NULL,theta0=DEFAULT_NULL,phi0=DEFAULT_NULL; //!< vector elements from hit to origin for E layer
float r1=DEFAULT_NULL,theta1=DEFAULT_NULL,phi1=DEFAULT_NULL; //!< vector elements from hit to origin for dE layer
};
/*TODO:
* There will be some use for a class such that it stores
PhysicsEvent = <Ex, Brho, THeta4, ...orrubaevent >
* Once the 'orrubaevent' structs are made, it should be callable. like
std::vector<PhysicsEvent> getPhysicsFromVertices(Kinematics dpkin, std::vector<orrubaevent> orvec);?
* should the physics just go sit in orrubaevent? maybe orruba2024 class can have a kinematics object in it?
*/
class orruba2024 {
private:
//Class expected to be changed for each version of the analysis code
public:
bool found_trk, found_trkpresc, found_tdcq, found_s800e1, found_s800trg,
found_rf, found_gt, found_si, found_siup;
bool found_de, found_e, found_qqq, found_sx3;//orruba
long long timestamp=DEFAULT_NULL;
std::vector<type19Raw> o_rawvec;
std::array<qqq5,4> uendcapE;
std::array<qqq5,4> uendcapdE;
std::array<sx3,12> ubarrelE;
std::array<sx3,12> ubarreldE;
std::array<sx3,2> dbarrelE;
//Results after post-processing, including possible multiplicities
std::vector<orrubaevent> events;
double target_z_offset;
//void initialize(const std::string & filename1, const std::string& filename2, const std::string& filename3);
float tdc_trk = DEFAULT_NULL;
float tdc_trksi = DEFAULT_NULL; //trackerpr+si stops are combined into one channel
float tdc_trkp = DEFAULT_NULL;
float tdc_q = DEFAULT_NULL;
float tdc_s800e1 = DEFAULT_NULL;
float tdc_s800trg = DEFAULT_NULL;
float tdc_rf = DEFAULT_NULL;
float tdc_rf_unwrap = DEFAULT_NULL;
float tdc_gt = DEFAULT_NULL;
float tdc_si = DEFAULT_NULL;
float tdc_siup = DEFAULT_NULL;
orruba2024(const std::vector<type19Raw>& orvec);
void postprocess(); //generates 'events', and performs validations on freshly entered data. performs fine gainmatching for front-back-pairs
void print() const {
std::cout << Form("TDCs\n trk:%1.4f\ntrkp:%1.4f\nq:%1.4f\ns800e1:%1.4f\ns800trg:%1.4f\nrf:%1.4f\nrfuw:%1.4f\ngt:%1.4f\nsi:%1.4f\nsiup:%1.4f\n-----\nevents_size:%lu\ntimestamp:%lld\nfound_de:%d, found_e:%d\n-------\n-------\n",
tdc_trk, tdc_trkp, tdc_q, tdc_s800e1, tdc_s800trg, tdc_rf, tdc_rf_unwrap, tdc_gt, tdc_si, tdc_siup, events.size(), timestamp, found_de, found_e) << std::endl;
}
};
class trackingdet {
public:
double timestamp=DEFAULT_NULL;
//TODO: Convert all to std::array
std::vector<float> xwires[MAXNWIRES_TRACK];
std::vector<float> ywires[MAXNWIRES_TRACK];
std::vector<float> xwiresf[MAXNWIRES_TRACK];
std::vector<float> ywiresf[MAXNWIRES_TRACK];
std::vector<float> xwiresf_nn[MAXNWIRES_TRACK];
std::vector<float> ywiresf_nn[MAXNWIRES_TRACK];
std::vector<float> xtimes[MAXNWIRES_TRACK];
std::vector<float> ytimes[MAXNWIRES_TRACK];
std::vector<float> xtimesf[MAXNWIRES_TRACK];
std::vector<float> ytimesf[MAXNWIRES_TRACK];
std::vector<float> cathode;
int multx; //how many x-wires fired?
int multy; //how many y-wires fired?
int multxf; //how many filtered x-wires fired?
int multyf; //how many filtered y-wires fired?
int multxt; //how many x-tdcwires fired?
int multyt; //how many y-tdcwires fired?
int multxtf; //how many x-tdcwires fired in window?
int multytf; //how many y-tdcwires fired in window?
float tot_cathode=0;
float tot_x=0;
float tot_y=0;
float tot_anode=0;
//list of x and y wires fired above energy threshold, within timing gate window
std::set<int> list_ywires;
std::set<int> list_xwires;
std::set<int> list_ytwires;
std::set<int> list_xtwires;
//position of the vertex estimated by up to 2 neighbouring wires firing together within window
double xpos=DEFAULT_NULL;
double ypos=DEFAULT_NULL;
bool clean_event = false;
int maxnx=-124, maxny=-124;
int nnx = 0; //nearest neighbour x wires set this to +/- 1 if present w.r.t. wire maxnx
int nny = 0; //nearest neighbour y wires set this to +/- 1 if present w.r.t wire maxny
bool clean_event_no_timing = false;
bool clean_single_xy_event = false;
bool clean_single_xy_event_no_timing = false;
void Reset() {
/***
Resets all data members.
**/
cathode.clear();
for(int i=0; i<MAXNWIRES_TRACK; i++) {
xwires[i].clear();
ywires[i].clear();
xwiresf[i].clear();
ywiresf[i].clear();
xwiresf_nn[i].clear();
ywiresf_nn[i].clear();
xtimes[i].clear();
ytimes[i].clear();
xtimesf[i].clear();
ytimesf[i].clear();
}
list_xwires.clear();
list_ywires.clear();
list_xtwires.clear();
list_ytwires.clear();
nnx = 0;
nny = 0;
clean_event_no_timing = false;
clean_event = false; //x, y both fire above thresh, xt, yt present within broad coinc window
xpos=DEFAULT_NULL;
ypos=DEFAULT_NULL;
maxnx=-124;
maxny=-124;
multx=0; //how many x-wires fired?
multy=0; //how many y-wires fired?
multxf=0; //how many filt x-wires fired?
multyf=0; //how many filt y-wires fired?
multxt=0; //how many tdc x-wires fired?
multyt=0; //how many tdc y-wires fired?
multxtf=0; //how many tdc x-wires fired?
multytf=0; //how many tdc y-wires fired?
}
trackingdet() {
Reset();
};
trackingdet(const std::vector<type19Raw>& orvec);
};
const float alpha = 0.0;
int matchchantype(unsigned short chan, const std::array<orruba_params,MAX_ORRUBA_CHANS>& index, const std::string& label);
void initialize_orruba(const std::string & filename1, const std::string& filename2, const std::string& filename3, const std::string& filename4);//,
int parse_orruba_data(const unsigned short* buffer, int32_t length, type19Raw& oraw_event);
#endif

67
pccal/anode_gainmatch.C Executable file
View File

@ -0,0 +1,67 @@
void anode_gainmatch(){
TFile *f = new TFile("../results_run16.root");
TH2F *pc_index_h2d = (TH2F*)(f->Get("hRawPC/PC_Index_Vs_Energy"));
std::cout << pc_index_h2d << std::endl;
TCanvas c("c1","c1",0,0,1600,800);
//TCanvas c_g("cg","cg",0,900,400,400);
c.Divide(2,1);
auto c1=c.cd(1);
pc_index_h2d->Draw("COLZ");
pc_index_h2d->GetYaxis()->SetRangeUser(240,5000);
auto c2=c.cd(2);
c2->SetLogy();
TH1F *h_1d=NULL;
int bin_index=1;
std::vector<std::vector<double>> all_peaks;
std::vector<int> found_wire_list;
while(bin_index<=24) {
h_1d=(TH1F*)(pc_index_h2d->ProjectionY("_py",bin_index,bin_index));
auto c1 = c.cd(1);
TBox box(pc_index_h2d->GetXaxis()->GetBinLowEdge(bin_index),0,pc_index_h2d->GetXaxis()->GetBinUpEdge(bin_index),pc_index_h2d->GetYaxis()->GetXmax());
box.SetFillColorAlpha(kYellow+3,0.3);
box.Draw("SAME");
c1->Modified(); c1->Update();
//while(c1->WaitPrimitive());
TSpectrum s;
auto c2 = c.cd(2);
h_1d->Draw();
c2->Modified(); c2->Update();
int npeaks = s.Search(h_1d,8,"",0.02); std::cout << npeaks << std::endl;
if(npeaks>=3) {
std::vector<double> xpeaks(s.GetPositionX(),s.GetPositionX()+npeaks);
std::sort(xpeaks.begin(),xpeaks.end(),std::greater());
found_wire_list.push_back((int)pc_index_h2d->GetXaxis()->GetBinCenter(bin_index));
all_peaks.push_back(xpeaks);
}
while(c2->WaitPrimitive());
bin_index++;
}
c.cd(2)->SetLogy(kFALSE);
gStyle->SetOptFit(1111);
std::ofstream outfile("anode_gm_coeffs.dat");
outfile << found_wire_list.at(0) << " "
<< 1.0 << " "
<< 0.0 << std::endl;
for(int i=0; i<all_peaks.size(); i++){
if(i==1) continue;
TGraph g(all_peaks.at(i).size(), all_peaks.at(i).data(), all_peaks.at(1).data());
auto c2 = c.cd(2);
g.SetMarkerStyle(20);
//g.Print();
g.Draw("AP");
g.Fit("pol1");
outfile << found_wire_list.at(i) << " "
<< ((TF1*)g.FindObject("pol1"))->GetParameter(1) << " "
<< ((TF1*)g.FindObject("pol1"))->GetParameter(0) << std::endl;
c2->Modified();
c2->Update();
while(c2->WaitPrimitive());
}
outfile.close();
f->Close();
return;
}

24
pccal/anode_gm_coeffs.dat Executable file
View File

@ -0,0 +1,24 @@
0 1 0
0 0.937314 -16.871
2 0.965461 -1.54376
3 0.926501 -3.27662
4 0.905634 2.54577
5 0.905634 -11.0387
6 0.853919 6.23079
7 0.945588 -9.54044
8 0.884454 -11.8262
9 0.922501 -3.42538
10 0.903053 9.28069
11 0.914653 9.87642
12 0.965332 13.2526
13 0.923847 -3.41775
14 0.93845 25.9901
15 0.955424 12.324
16 0.95116 4.99595
17 0.910745 2.86648
18 0.941376 4.57217
19 0.871622 932.111
20 1.00624 7.86358
21 0.969834 -45.001
22 0.89304 -31.5635
23 0.933226 4.02193

69
pccal/cathode_gainmatch.C Executable file
View File

@ -0,0 +1,69 @@
void cathode_gainmatch(){
TFile *f = new TFile("../results_run17.root");
TH2F *pc_index_h2d = (TH2F*)(f->Get("hRawPC/PC_Index_Vs_Energy"));
std::cout << pc_index_h2d << std::endl;
TCanvas c("c1","c1",0,0,1600,800);
//TCanvas c_g("cg","cg",0,900,400,400);
c.Divide(2,1);
auto c1=c.cd(1);
pc_index_h2d->Draw("COLZ");
pc_index_h2d->GetYaxis()->SetRangeUser(600,pc_index_h2d->GetYaxis()->GetXmax());
auto c2=c.cd(2);
c2->SetLogy();
TH1F *h_1d=NULL;
int bin_index=25;
std::vector<double> pulser_heights = {0.01,0.05,0.1,0.15,0.2,0.25,0.3,0.5};
std::vector<std::vector<double>> all_peaks;
std::vector<int> found_wire_list;
while(bin_index<=48) {
h_1d=(TH1F*)(pc_index_h2d->ProjectionY("_py",bin_index,bin_index));
auto c1 = c.cd(1);
TBox box(pc_index_h2d->GetXaxis()->GetBinLowEdge(bin_index),0,pc_index_h2d->GetXaxis()->GetBinUpEdge(bin_index),pc_index_h2d->GetYaxis()->GetXmax());
box.SetFillColorAlpha(kYellow+3,0.3);
box.Draw("SAME");
c1->Modified(); c1->Update();
//while(c1->WaitPrimitive());
TSpectrum s;
auto c2 = c.cd(2);
h_1d->Draw();
c2->Modified(); c2->Update();
int npeaks = s.Search(h_1d,20,"",0.1); std::cout << npeaks << std::endl;
if(npeaks==8) {
std::vector<double> xpeaks(s.GetPositionX(),s.GetPositionX()+npeaks);
for(int i=0; i<8; i++) {
std::cout << pc_index_h2d->GetXaxis()->GetBinCenter(bin_index) << " " << xpeaks.at(i) << " " << xpeaks.at(i)/pulser_heights.at(i) << std::endl;
}
std::sort(xpeaks.begin(),xpeaks.end(),std::greater());
found_wire_list.push_back((int)pc_index_h2d->GetXaxis()->GetBinCenter(bin_index));
all_peaks.push_back(xpeaks);
}
while(c2->WaitPrimitive());
bin_index++;
}
c.cd(2)->SetLogy(kFALSE);
gStyle->SetOptFit(1111);
std::ofstream outfile("cathode_gm_coeffs.dat");
outfile << found_wire_list.at(0) << " "
<< 1.0 << " "
<< 0.0 << std::endl;
for(int i=1; i<all_peaks.size(); i++){
TGraph g(all_peaks.at(i).size(), all_peaks.at(i).data(), all_peaks.at(0).data());
auto c2 = c.cd(2);
g.SetMarkerStyle(20);
//g.Print();
g.Draw("AP");
g.Fit("pol1");
outfile << found_wire_list.at(i) << " "
<< ((TF1*)g.FindObject("pol1"))->GetParameter(1) << " "
<< ((TF1*)g.FindObject("pol1"))->GetParameter(0) << std::endl;
c2->Modified();
c2->Update();
while(c2->WaitPrimitive());
}
outfile.close();
f->Close();
return;
}

21
pccal/cathode_gm_coeffs.dat Executable file
View File

@ -0,0 +1,21 @@
24 1 0
25 0.941896 6.16135
26 0.980284 2.86886
27 0.983166 -3.82952
28 0.978704 -2.89713
29 0.964947 2.25786
30 0.94514 0.925074
31 0.977231 1.6493
32 0.919527 5.82742
33 0.972243 2.88061
34 0.928892 7.61384
35 0.947376 -0.644223
36 0.875342 6.066
38 0.970953 6.262
40 0.918408 -3.27891
41 0.913619 4.11288
42 0.954083 2.21261
43 0.993037 5.48924
45 0.926406 -19.719
46 1.00459 5.14574
47 0.942483 5.54183

49
pccal/pc_gm_coeffs.dat Executable file
View File

@ -0,0 +1,49 @@
#Histogram Number Slope Intercept
0 0.937314 -16.871
1 0 0
2 0.965461 -1.54376
3 0.926501 -3.27662
4 0.905634 2.54577
5 0.905634 -11.0387
6 0.853919 6.23079
7 0.945588 -9.54044
8 0.884454 -11.8262
9 0.922501 -3.42538
10 0.903053 9.28069
11 0.914653 9.87642
12 0.965332 13.2526
13 0.923847 -3.41775
14 0.93845 25.9901
15 0.955424 12.324
16 0.95116 4.99595
17 0.910745 2.86648
18 0.941376 4.57217
19 0.871622 932.111
20 1.00624 7.86358
21 0.969834 -45.001
22 0.89304 -31.5635
23 0.933226 4.02193
24 0 0
25 0.941896 6.16135
26 0.980284 2.86886
27 0.983166 -3.82952
28 0.978704 -2.89713
29 0.964947 2.25786
30 0.94514 0.925074
31 0.977231 1.6493
32 0.919527 5.82742
33 0.972243 2.88061
34 0.928892 7.61384
35 0.947376 -0.644223
36 0.875342 6.066
37 0 0
38 0.970953 6.262
39 0 0
40 0.918408 -3.27891
41 0.913619 4.11288
42 0.954083 2.21261
43 0.993037 5.48924
44 0 0
45 0.926406 -19.719
46 1.00459 5.14574
47 0.942483 5.54183

50
pccal/slope_intercept_26Al.dat Executable file
View File

@ -0,0 +1,50 @@
#Histogram Number Slope Intercept
#Histogram Number Slope Intercept
0 0.931015 -1.35431
1 1 -1.87356e-10
2 0.964185 1.49989
3 0.92638 -1.30621
4 0.905569 1.00834
5 0.901182 0.470903
6 0.853932 3.32687
7 0.942785 1.08887
8 0.878904 -0.0107433
9 0.922662 -2.32259
10 0.903343 8.38332
11 0.914227 6.56108
12 0.961008 23.0982
13 0.920976 5.22104
14 0.936584 31.5073
15 0.959044 5.43267
16 0.95263 -0.404053
17 0.90953 4.82833
18 0.940277 10.3629
19 0.86746 -17.8678
20 1.00683 4.76371
21 0.968342 -43.9496
22 0.892882 -32.0742
23 0.933615 1.10704
24 1 -2.89219e-10
25 0.942098 -0.105169
26 0.980862 -0.732032
27 0.982975 -2.22704
28 0.978815 -1.51477
29 0.965245 -2.19515
30 0.945384 -0.892599
31 0.977408 -0.908592
32 0.919546 3.25464
33 0.972194 2.44956
34 0.92852 5.44745
35 0.947098 1.40531
36 0.875491 -1.13145
37 1 0
38 0.970862 2.86019
39 1 0
40 0.91793 -3.80615
41 0.913897 -2.12964
42 0.954014 -0.760604
43 0.993616 -1.40278
44 1 0
45 0.926169 -21.2016
46 1.00577 -2.14281
47 0.943312 -1.26464

23
sx3cal/17F/backgains.dat Executable file
View File

@ -0,0 +1,23 @@
1 front 1 back 2 4.4094
1 front 1 back 1 4.4094
1 front 2 back 2 4.4832
1 front 3 back 2 4.52103
1 front 3 back 1 4.5210
3 front 1 back 2 3.63215
3 front 1 back 1 3.70756
3 front 2 back 2 3.68208
3 front 2 back 1 3.86817
3 front 3 back 2 3.7334
3 front 3 back 1 3.70756
7 front 1 back 2 3.60769
7 front 1 back 1 3.46759
7 front 2 back 2 3.58356
7 front 2 back 1 3.49018
7 front 3 back 2 3.60769
7 front 3 back 1 3.46759
9 front 1 back 2 3.58356
9 front 1 back 1 3.44529
9 front 2 back 2 3.58356
9 front 2 back 1 3.46759
9 front 3 back 2 3.63215
9 front 3 back 1 3.46759

96
sx3cal/17F/backgains.dat.unity Executable file
View File

@ -0,0 +1,96 @@
1 0 0 1.
1 1 0 1.
1 2 0 1.
1 3 0 1.
1 0 1 1.
1 1 1 1.
1 2 1 1.
1 3 1 1.
1 0 2 1.
1 1 2 1.
1 2 2 1.
1 3 2 1.
1 0 3 1.
1 1 3 1.
1 2 3 1.
1 3 3 1.
7 0 0 1.
7 1 0 1.
7 2 0 1.
7 3 0 1.
7 0 1 1.
7 1 1 1.
7 2 1 1.
7 3 1 1.
7 0 2 1.
7 1 2 1.
7 2 2 1.
7 3 2 1.
7 0 3 1.
7 1 3 1.
7 2 3 1.
7 3 3 1.
0 0 0 1.
0 1 0 1.
0 2 0 1.
0 3 0 1.
0 0 1 1.
0 1 1 1.
0 2 1 1.
0 3 1 1.
0 0 2 1.
0 1 2 1.
0 2 2 1.
0 3 2 1.
0 0 3 1.
0 1 3 1.
0 2 3 1.
0 3 3 1.
2 0 0 1.
2 1 0 1.
2 2 0 1.
2 3 0 1.
2 0 1 1.
2 1 1 1.
2 2 1 1.
2 3 1 1.
2 0 2 1.
2 1 2 1.
2 2 2 1.
2 3 2 1.
2 0 3 1.
2 1 3 1.
2 2 3 1.
2 3 3 1.
9 0 0 1.
9 1 0 1.
9 2 0 1.
9 3 0 1.
9 0 1 1.
9 1 1 1.
9 2 1 1.
9 3 1 1.
9 0 2 1.
9 1 2 1.
9 2 2 1.
9 3 2 1.
9 0 3 1.
9 1 3 1.
9 2 3 1.
9 3 3 1.
3 0 0 1.
3 1 0 1.
3 2 0 1.
3 3 0 1.
3 0 1 1.
3 1 1 1.
3 2 1 1.
3 3 1 1.
3 0 2 1.
3 1 2 1.
3 2 2 1.
3 3 2 1.
3 0 3 1.
3 1 3 1.
3 2 3 1.
3 3 3 1.

12
sx3cal/17F/frontgains.dat Executable file
View File

@ -0,0 +1,12 @@
1 lengthcal front 1 1.5121 60.4839
1 lengthcal front 2 -1.5625 62.5
1 lengthcal front 3 2.72177 60.4839
3 lengthcal front 1 -0.595088 59.5088
3 lengthcal front 2 -4.53935 58.5723
3 lengthcal front 3 4.08107 60.4603
7 lengthcal front 1 1.14329 45.7317
7 lengthcal front 2 0.115661 46.2646
7 lengthcal front 3 2.90179 44.6429
9 lengthcal front 1 0.115732 46.2928
9 lengthcal front 2 0.799176 45.6672
9 lengthcal front 3 1.68159 48.0453

24
sx3cal/17F/frontgains.dat.unity Executable file
View File

@ -0,0 +1,24 @@
9 temp temp 0 0. 1.
9 temp temp 1 0. 1.
9 temp temp 2 0. 1.
9 temp temp 3 0. 1.
7 temp temp 0 0. 1.
7 temp temp 1 0. 1.
7 temp temp 2 0. 1.
7 temp temp 3 0. 1.
1 temp temp 0 0. 1.
1 temp temp 1 0. 1.
1 temp temp 2 0. 1.
1 temp temp 3 0. 1.
2 temp temp 0 0. 1.
2 temp temp 1 0. 1.
2 temp temp 2 0. 1.
2 temp temp 3 0. 1.
0 temp temp 0 0. 1.
0 temp temp 1 0. 1.
0 temp temp 2 0. 1.
0 temp temp 3 0. 1.
3 temp temp 0 0. 1.
3 temp temp 1 0. 1.
3 temp temp 2 0. 1.
3 temp temp 3 0. 1.

16
sx3cal/17F/rightgains.dat Executable file
View File

@ -0,0 +1,16 @@
1 0 1678.38 1.0
1 1 1678.38 1.07163
1 2 1693.99 1.1035
1 3 1667.9 0.975015
3 0 1597.96 1.0
3 1 1597.96 1.02536
3 2 1821.48 1.29182
3 3 1607.52 0.928543
7 0 1773.34 1.
7 1 1773.34 1.14263
7 2 1573.79 1.06715
7 3 1542.41 0.956475
9 0 1555.08 1.
9 1 1555.08 0.998252
9 2 1559.36 1.00299
9 3 1585.79 1.01582

24
sx3cal/17F/rightgains.dat.unity Executable file
View File

@ -0,0 +1,24 @@
9 0 1000 1.0
9 1 1000 1.0
9 2 1000 1.0
9 3 1000 1.0
7 0 1000 1.0
7 1 1000 1.0
7 2 1000 1.0
7 3 1000 1.0
2 0 1000 1.0
2 1 1000 1.0
2 2 1000 1.0
2 3 1000 1.0
0 0 1000 1.0
0 1 1000 1.0
0 2 1000 1.0
0 3 1000 1.0
1 0 1000 1.0
1 1 1000 1.0
1 2 1000 1.0
1 3 1000 1.0
3 0 1000 1.0
3 1 1000 1.0
3 2 1000 1.0
3 3 1000 1.0

28
sx3cal/26Al/backgains.dat Executable file
View File

@ -0,0 +1,28 @@
1 front 0 back 2 4.03168
1 front 1 back 2 4.03168
1 front 2 back 2 4.11533
1 front 3 back 2 4.17315
7 front 0 back 2 4.26886
7 front 0 back 1 3.44529
7 front 1 back 2 4.26886
7 front 1 back 1 3.44529
7 front 2 back 2 4.26886
7 front 2 back 1 3.46759
7 front 3 back 2 4.26886
7 front 3 back 1 3.44529
9 front 0 back 2 3.63215
9 front 0 back 1 3.42327
9 front 1 back 2 3.63215
9 front 1 back 1 3.42327
9 front 2 back 2 3.65694
9 front 2 back 1 3.46759
9 front 3 back 2 3.68208
9 front 3 back 1 3.42327
3 front 0 back 2 3.
3 front 0 back 1 3.
3 front 1 back 2 3.65694
3 front 1 back 1 3.68208
3 front 2 back 2 3.70756
3 front 2 back 1 3.78616
3 front 3 back 2 3.7334
3 front 3 back 1 3.68208

96
sx3cal/26Al/backgains.dat.unity Executable file
View File

@ -0,0 +1,96 @@
1 0 0 1.
1 1 0 1.
1 2 0 1.
1 3 0 1.
1 0 1 1.
1 1 1 1.
1 2 1 1.
1 3 1 1.
1 0 2 1.
1 1 2 1.
1 2 2 1.
1 3 2 1.
1 0 3 1.
1 1 3 1.
1 2 3 1.
1 3 3 1.
7 0 0 1.
7 1 0 1.
7 2 0 1.
7 3 0 1.
7 0 1 1.
7 1 1 1.
7 2 1 1.
7 3 1 1.
7 0 2 1.
7 1 2 1.
7 2 2 1.
7 3 2 1.
7 0 3 1.
7 1 3 1.
7 2 3 1.
7 3 3 1.
0 0 0 1.
0 1 0 1.
0 2 0 1.
0 3 0 1.
0 0 1 1.
0 1 1 1.
0 2 1 1.
0 3 1 1.
0 0 2 1.
0 1 2 1.
0 2 2 1.
0 3 2 1.
0 0 3 1.
0 1 3 1.
0 2 3 1.
0 3 3 1.
2 0 0 1.
2 1 0 1.
2 2 0 1.
2 3 0 1.
2 0 1 1.
2 1 1 1.
2 2 1 1.
2 3 1 1.
2 0 2 1.
2 1 2 1.
2 2 2 1.
2 3 2 1.
2 0 3 1.
2 1 3 1.
2 2 3 1.
2 3 3 1.
9 0 0 1.
9 1 0 1.
9 2 0 1.
9 3 0 1.
9 0 1 1.
9 1 1 1.
9 2 1 1.
9 3 1 1.
9 0 2 1.
9 1 2 1.
9 2 2 1.
9 3 2 1.
9 0 3 1.
9 1 3 1.
9 2 3 1.
9 3 3 1.
3 0 0 1.
3 1 0 1.
3 2 0 1.
3 3 0 1.
3 0 1 1.
3 1 1 1.
3 2 1 1.
3 3 1 1.
3 0 2 1.
3 1 2 1.
3 2 2 1.
3 3 2 1.
3 0 3 1.
3 1 3 1.
3 2 3 1.
3 3 3 1.

16
sx3cal/26Al/frontgains.dat Executable file
View File

@ -0,0 +1,16 @@
1 lengthcal front 0 0.878906 58.5938
1 lengthcal front 1 1.42045 56.8182
1 lengthcal front 2 -2.55682 56.8182
1 lengthcal front 3 2.55682 56.8182
7 lengthcal front 0 0.425806 42.5806
7 lengthcal front 1 1.92004 45.1774
7 lengthcal front 2 1.11607 44.6429
7 lengthcal front 3 3.45909 44.6334
9 lengthcal front 0 1.82872 45.7181
9 lengthcal front 1 1.01649 45.1774
9 lengthcal front 2 1.46827 45.1774
9 lengthcal front 3 2.54513 46.2751
3 lengthcal front 0 0. 50.
3 lengthcal front 1 1.1713 58.5652
3 lengthcal front 2 -3.07505 58.5723
3 lengthcal front 3 4.0726 60.3348

View File

@ -0,0 +1,20 @@
9 temp temp 0 0. 1.
9 temp temp 1 0. 1.
9 temp temp 2 0. 1.
9 temp temp 3 0. 1.
7 temp temp 0 0. 1.
7 temp temp 1 0. 1.
7 temp temp 2 0. 1.
7 temp temp 3 0. 1.
1 temp temp 0 0. 1.
1 temp temp 1 0. 1.
1 temp temp 2 0. 1.
1 temp temp 3 0. 1.
2 temp temp 0 0. 1.
2 temp temp 1 0. 1.
2 temp temp 2 0. 1.
2 temp temp 3 0. 1.
0 temp temp 0 0. 1.
0 temp temp 1 0. 1.
0 temp temp 2 0. 1.
0 temp temp 3 0. 1.

16
sx3cal/26Al/rightgains.dat Executable file
View File

@ -0,0 +1,16 @@
1 0 1221.23 0.648782
1 1 1819.66 1.06196
1 2 1860.02 1.11979
1 3 1825.44 0.964989
7 0 1609.63 1.04668
7 1 1734.45 1.12285
7 2 1538.97 1.0486
7 3 1524.57 0.951587
9 0 1672.38 1.11321
9 1 1542.13 1.01442
9 2 1540.38 0.967847
9 3 1560.42 0.969022
3 0 1000.0 1.
3 1 1539.42 1.0422
3 2 1720.12 1.31534
3 3 1562.16 1.00415

View File

@ -0,0 +1,24 @@
9 0 1000 1.0
9 1 1000 1.0
9 2 1000 1.0
9 3 1000 1.0
7 0 1000 1.0
7 1 1000 1.0
7 2 1000 1.0
7 3 1000 1.0
2 0 1000 1.0
2 1 1000 1.0
2 2 1000 1.0
2 3 1000 1.0
0 0 1000 1.0
0 1 1000 1.0
0 2 1000 1.0
0 3 1000 1.0
1 0 1000 1.0
1 1 1000 1.0
1 2 1000 1.0
1 3 1000 1.0
3 0 1000 1.0
3 1 1000 1.0
3 2 1000 1.0
3 3 1000 1.0

View File

@ -1,6 +1,6 @@
{
int index = 3;
TFile *f = new TFile("../results_SX3_run12.root");
int index = 1;
TFile *f = new TFile("../results_run19.root");
TH2F *h2=NULL;
TH1F *h1x=NULL, *h1y=NULL;
//f->cd("evsx");
@ -17,8 +17,8 @@
h2 = (TH2F*)(f->Get(Form("evsx/be_vs_x_sx3_id_%d_f%d_b%d",index,i,backnum)));
auto macro = [&]() {
h1x = (TH1F*)(h2->ProjectionX("_px"));
double xleft = h1x->GetBinCenter(h1x->FindFirstBinAbove(h1x->GetMaximum()*0.25));
double xright = h1x->GetBinCenter(h1x->FindLastBinAbove(h1x->GetMaximum()*0.25));
double xleft = h1x->GetBinCenter(h1x->FindFirstBinAbove(h1x->GetMaximum()*0.4));
double xright = h1x->GetBinCenter(h1x->FindLastBinAbove(h1x->GetMaximum()*0.4));
//h1x->GetXaxis()->SetRangeUser(4*xleft, xright*4);
h1x->Draw();
TLine L1(xleft,0,xleft,h1x->GetMaximum()); L1.SetLineColor(kRed); L1.Draw("SAME");

View File

@ -1,8 +1,8 @@
{
TFile *f = new TFile("../results_SX3_run12.root");
TFile *f = new TFile("../results_run19.root");
f->cd("l_vs_r");
f->ls();
int clkpos = 3;
gDirectory->ls();
int clkpos = 13;
std::ofstream ofile(Form("rightgains%d.dat",clkpos));
for(int i=1; i<4; i++) {
TH2F h2(*(TH2F*)(f->Get(Form("l_vs_r/l_vs_r_sx3_id_%d_f%d",clkpos,i))));
@ -14,7 +14,7 @@
gPad->Update();
while(gPad->WaitPrimitive());*/
int leftbin = hproj.FindFirstBinAbove(hproj.GetMaximum()*0.1);
int leftbin = hproj.FindFirstBinAbove(hproj.GetMaximum()*0.4);
int rightbin = hproj.FindLastBinAbove(hproj.GetMaximum()*0.1);
TH1F h1(*(TH1F*)(h2.ProfileX("_pfx",leftbin,rightbin)));

3
sx3cal/backgains1.dat Executable file
View File

@ -0,0 +1,3 @@
1 front 1 back 2 4.4094
1 front 2 back 2 4.4832
1 front 3 back 2 4.52103

6
sx3cal/backgains9.dat Executable file
View File

@ -0,0 +1,6 @@
9 front 1 back 2 3.58356
9 front 1 back 1 3.44529
9 front 2 back 2 3.58356
9 front 2 back 1 3.46759
9 front 3 back 2 3.63215
9 front 3 back 1 3.46759

3
sx3cal/frontgains1.dat Executable file
View File

@ -0,0 +1,3 @@
1 lengthcal front 1 1.5121 60.4839
1 lengthcal front 2 -1.5625 62.5
1 lengthcal front 3 2.72177 60.4839

3
sx3cal/frontgains9.dat Executable file
View File

@ -0,0 +1,3 @@
9 lengthcal front 1 0.115732 46.2928
9 lengthcal front 2 0.799176 45.6672
9 lengthcal front 3 1.68159 48.0453

3
sx3cal/rightgains1.dat Executable file
View File

@ -0,0 +1,3 @@
1 1 1678.38 1.07163
1 2 1693.99 1.1035
1 3 1667.9 0.975015

3
sx3cal/rightgains13.dat Executable file
View File

@ -0,0 +1,3 @@
13 1 1 1
13 2 1 1
13 3 1 1

3
sx3cal/rightgains9.dat Executable file
View File

@ -0,0 +1,3 @@
9 1 1555.08 0.998252
9 2 1559.36 1.00299
9 3 1585.79 1.01582