21 double dEdx(
float dqdx,
float Efield) {
25 TFile *
ef=
new TFile(
"/dune/data/users/higuera/data/SCE_DataDriven_180kV_v3.root");
26 TH3F *
xneg=(TH3F*)
ef->Get(
"Reco_ElecField_X_Neg");
27 TH3F *
yneg=(TH3F*)
ef->Get(
"Reco_ElecField_Y_Neg");
28 TH3F *
zneg=(TH3F*)
ef->Get(
"Reco_ElecField_Z_Neg");
29 TH3F *
xpos=(TH3F*)
ef->Get(
"Reco_ElecField_X_Pos");
30 TH3F *
ypos=(TH3F*)
ef->Get(
"Reco_ElecField_Y_Pos");
31 TH3F *
zpos=(TH3F*)
ef->Get(
"Reco_ElecField_Z_Pos");
33 double tot_Ef(
double xval,
double yval,
double zval){
35 double ex=0.5+0.5*
xpos->GetBinContent(
xpos->FindBin(xval,yval,zval));
36 double ey=0.5*
ypos->GetBinContent(
ypos->FindBin(xval,yval,zval));
37 double ez=0.5*
zpos->GetBinContent(
zpos->FindBin(xval,yval,zval));
38 return sqrt(ex*ex+ey*ey+ez*ez);
41 double ex=0.5+0.5*
xneg->GetBinContent(
xneg->FindBin(xval,yval,zval));
42 double ey=0.5*
yneg->GetBinContent(
yneg->FindBin(xval,yval,zval));
43 double ez=0.5*
zneg->GetBinContent(
zneg->FindBin(xval,yval,zval));
44 return sqrt(ex*ex+ey*ey+ez*ez);
51 TFile *fyz_corr=
new TFile(
"/dune/data/users/higuera/data/YZcalo_ProtoDUNE.root");
52 TH2F *YZ_neg=(TH2F*)fyz_corr->Get(
"run_YZ_negativeX_2");
53 TH2F *YZ_pos=(TH2F*)fyz_corr->Get(
"run_YZ_positiveX_2");
56 TFile *fx_corr=
new TFile(
"/dune/data/users/higuera/data/Xcalo_ProtoDUNE.root");
57 TH2F *X_correction= (TH2F*)fx_corr->Get(
"X_correction_2");
59 TFile *f_data =
new TFile(filename,
"READ");
60 TFile *
f =
new TFile(outfile,
"recreate");
62 TH1D *h_costheta =
new TH1D(
"h_costheta",
";cos#theta",100,-1,1);
63 TH1D *h_nhits =
new TH1D(
"h_nhits",
";",500,0,2000);
64 TH1D *h_dEdx =
new TH1D(
"h_dEdx",
";",50,0,10);
65 TH1D *h_sh_length =
new TH1D(
"h_sh_length",
";",100,0,400);
66 TH1D *h_sh_length_afcut =
new TH1D(
"h_sh_length_afcut",
";",100,0,400);
67 TH1D *h_P =
new TH1D(
"h_P",
"; Beamline Momentum [GeV/c]",300,0,3);
68 TH1D *h_ratio =
new TH1D(
"h_ratio",
";(Shower Energy - Beamline Momentum)/Beamline Momentum",100,-1,1);
69 TH1D *h_Ecal =
new TH1D(
"h_Ecal",
";Shower Energy [Gev]",300,0,3);
72 TTree *
tree =(TTree*)f_data->Get(
"PandoraBeam");
74 int n_entries = tree->GetEntries();
77 for(
long int jentry=0; jentry<n_entries;jentry++) {
93 double costheta = (shdir.Dot(zaxis))/(shdir.Mag()*zaxis.Mag());
94 h_costheta->Fill(costheta);
96 if( costheta < 0.9 )
continue;
116 double YZcorrection_factor =1.0;
117 double Xcorrection_factor=1.0;
121 Xcorrection_factor=X_correction->GetBinContent(X_correction->FindBin(5834,signal->
primaryShower_hit_X[
h]));
127 if(signal->
primaryShower_hit_X[
h]<0) { YZcorrection_factor=YZ_neg->GetBinContent(5834,YZ_neg->FindBin(ave_Z,ave_Y)); }
128 if(signal->
primaryShower_hit_X[
h]>=0) { YZcorrection_factor=YZ_pos->GetBinContent(5834,YZ_pos->FindBin(ave_Z,ave_Y)); }
139 vector<double> tmp_x;
140 vector<double> tmp_y;
141 vector<double> tmp_z;
159 double YZcorrection_factor =1.0;
160 double Xcorrection_factor=1.0;
165 Xcorrection_factor=X_correction->GetBinContent(X_correction->FindBin(5834,signal->
primary_calX[
k]));
170 double cali_dEdx=
dEdx(scaled_dQdx, Efield);
172 double newvtx_x = tmp_x.at(0);
173 double newvtx_y = tmp_y.at(0);
174 double newvtx_z = tmp_z.at(0);
177 double x = 4.0*sin(theta)*cos(phi)+newvtx_x;
178 double y = 4.0*sin(theta)*sin(phi)+newvtx_y;
179 double z = 4.0*cos(theta)+newvtx_z;
181 TVector3
x1(newvtx_x,newvtx_y,newvtx_z);
184 TVector3 diff1 = x2-
x1;
185 TVector3 diff2 = x1-x0;
186 TVector3
cross = diff1.Cross(diff2);
187 double r= cross.Mag()/diff1.Mag();
190 if( r < 1.0 && d < 4.0){
191 dEdx_tmp[idx]=cali_dEdx;
199 dEdx_m = TMath::Median(idx,dEdx_tmp);
201 if( dEdx_m == 0 )
continue;
202 h_dEdx->Fill(dEdx_m);
205 h_Ecal->Fill(Ecal/1000.0);
218 cout<<
"**************************** "<<
endl;
219 cout<<
"* WELCOME TO JAMAICA * "<<
endl;
220 cout<<
"* HAVE A NICE DAY * "<<
endl;
221 cout<<
"**************************** "<<
endl;
225 cout<<
"please provide an input and output file "<<
endl;
Double_t primaryShower_hit_Z[4847]
Double_t primaryShower_hit_X[4847]
int EventSelection(const char *filename, const char *outfile)
Int_t primaryShower_nHits
Double_t primary_calZ[4847]
Double_t primarydQdx[4847]
Double_t primary_cal_pitch[4847]
double dEdx(float dqdx, float Efield)
Double_t primary_calY[4847]
Double_t primaryShower_hit_Y[4847]
Double_t primaryStartDirection[3]
Double_t beamtrackMomentum
int main(int argc, char *argv[])
double normalisation_factor
virtual Int_t GetEntry(Long64_t entry)
double tot_Ef(double xval, double yval, double zval)
Vector cross(Vector const &a, Vector const &b)
Return cross product of two vectors.
Double_t primaryShower_hit_q[4847]
QTextStream & endl(QTextStream &s)
Double_t primary_calX[4847]