E vs dE plotter
This commit is contained in:
parent
fe112a6004
commit
049365a549
|
|
@ -46,10 +46,10 @@ void aarootscript(int argument = 0) {
|
||||||
|
|
||||||
std::cout << "Zero Count: " << zeroCount << std::endl;
|
std::cout << "Zero Count: " << zeroCount << std::endl;
|
||||||
|
|
||||||
std::cout << "Making histograms..." << std::endl;
|
//std::cout << "Making histograms..." << std::endl;
|
||||||
|
|
||||||
gErrorIgnoreLevel = 2001;
|
gErrorIgnoreLevel = 2001;
|
||||||
gROOT->ProcessLine(".x histcomp.C");
|
//gROOT->ProcessLine(".x histcomp.C");
|
||||||
|
|
||||||
std::cout << "=========================================\n";
|
std::cout << "=========================================\n";
|
||||||
|
|
||||||
|
|
@ -68,7 +68,59 @@ void aarootscript(int argument = 0) {
|
||||||
std::cout << "Tree2 not found!" << std::endl;
|
std::cout << "Tree2 not found!" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::cout << "Creating Tb vs dEb plot..." << std::endl;
|
||||||
|
|
||||||
|
// Readers for both trees
|
||||||
|
TTreeReader r1(tree1);
|
||||||
|
TTreeReader r2(tree2);
|
||||||
|
|
||||||
|
TTreeReaderValue<double> Tb_val(r1, "Tb");
|
||||||
|
TTreeReaderValue<double> dEb_val(r2, "dEb");
|
||||||
|
|
||||||
|
std::vector<double> x; // Tb (tree1)
|
||||||
|
std::vector<double> y; // dEb (tree2)
|
||||||
|
|
||||||
|
|
||||||
|
// Loop over both trees simultaneously
|
||||||
|
while (r1.Next() && r2.Next()) {
|
||||||
|
x.push_back(*Tb_val);
|
||||||
|
y.push_back(*dEb_val);
|
||||||
|
}
|
||||||
|
std::cout << "x length: " << x.size() << ", y length: " << y.size() << std::endl;
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
std::ofstream outfile("Tb_dEb_data.txt");
|
||||||
|
|
||||||
|
if (!outfile.is_open()) {
|
||||||
|
std::cerr << "Error: Could not open output file!" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < x.size(); i++) {
|
||||||
|
outfile << x[i] << " " << y[i] << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
outfile.close();
|
||||||
|
|
||||||
|
std::cout << "Data written to Tb_dEb_data.txt" << std::endl;
|
||||||
|
/*
|
||||||
|
// Create graph
|
||||||
|
TGraph *gr = new TGraph(x.size(), &x[0], &y[0]);
|
||||||
|
gr->SetTitle("Tb (tree1) vs dEb (tree2);Tb;dEb");
|
||||||
|
gr->SetMarkerStyle(20);
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
TCanvas *c1 = new TCanvas("c1", "Tb vs dEb", 800, 600);
|
||||||
|
gr->Draw("AP");
|
||||||
|
c1->Update();
|
||||||
|
c1->SaveAs("Tb_vs_dEb.png");
|
||||||
|
std::cout << "Plot saved as Tb_vs_dEb.pdf" << std::endl;
|
||||||
std::cout << "\n\n\n";
|
std::cout << "\n\n\n";
|
||||||
|
|
||||||
|
delete c1;
|
||||||
|
delete gr;*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -129,9 +129,11 @@ int main(int argc, char **argv){
|
||||||
// outgoing particles in lab frame (light/heavy)
|
// outgoing particles in lab frame (light/heavy)
|
||||||
double thetab, phib, Tb;
|
double thetab, phib, Tb;
|
||||||
double thetaB, phiB, TB;
|
double thetaB, phiB, TB;
|
||||||
|
double dEb; // energy loss variable for light particle, will be updated after loss calculation
|
||||||
tree->Branch("thetab", &thetab, "thetab/D");
|
tree->Branch("thetab", &thetab, "thetab/D");
|
||||||
tree->Branch("phib", &phib, "phib/D");
|
tree->Branch("phib", &phib, "phib/D");
|
||||||
tree->Branch("Tb", &Tb, "Tb/D");
|
tree->Branch("Tb", &Tb, "Tb/D");
|
||||||
|
tree->Branch("dEb", &dEb, "dEb/D"); // for energy loss calculation, will be updated with loss
|
||||||
tree->Branch("thetaB", &thetaB, "thetaB/D");
|
tree->Branch("thetaB", &thetaB, "thetaB/D");
|
||||||
tree->Branch("phiB", &phiB, "phiB/D");
|
tree->Branch("phiB", &phiB, "phiB/D");
|
||||||
tree->Branch("TB", &TB, "TB/D");
|
tree->Branch("TB", &TB, "TB/D");
|
||||||
|
|
@ -297,6 +299,7 @@ int main(int argc, char **argv){
|
||||||
rePhi1 = pw->GetTrackPhi() * TMath::RadToDeg();
|
rePhi1 = pw->GetTrackPhi() * TMath::RadToDeg();
|
||||||
|
|
||||||
z0 = pw->GetZ0();
|
z0 = pw->GetZ0();
|
||||||
|
dEb = 0; // initialize energy loss variable for tree storage, will be updated after loss calculation
|
||||||
tree->Fill();
|
tree->Fill();
|
||||||
//Energy loss
|
//Energy loss
|
||||||
double dl = (hitPos - vertex).Mag() / 10; // path length in cm (positions in mm)
|
double dl = (hitPos - vertex).Mag() / 10; // path length in cm (positions in mm)
|
||||||
|
|
@ -325,6 +328,7 @@ int main(int argc, char **argv){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dEb = tb_temp - Tb; // total energy loss for this event
|
||||||
// fill tree2 with energy loss adjusted data
|
// fill tree2 with energy loss adjusted data
|
||||||
if (Tb != 0) {
|
if (Tb != 0) {
|
||||||
tree2->Fill();
|
tree2->Fill();
|
||||||
|
|
@ -350,6 +354,7 @@ int main(int argc, char **argv){
|
||||||
reTheta1 = TMath::QuietNaN();
|
reTheta1 = TMath::QuietNaN();
|
||||||
rePhi1 = TMath::QuietNaN();
|
rePhi1 = TMath::QuietNaN();
|
||||||
z0 = TMath::QuietNaN();
|
z0 = TMath::QuietNaN();
|
||||||
|
dEb = TMath::QuietNaN(); // initialize energy loss variable for no hit case
|
||||||
//Tb = -12354567; // mark kinetic energy as invalid for no hit case
|
//Tb = -12354567; // mark kinetic energy as invalid for no hit case
|
||||||
// fill tree with original data (no energy loss for these events)
|
// fill tree with original data (no energy loss for these events)
|
||||||
//tree->Fill();
|
//tree->Fill();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user