Skip to content
Snippets Groups Projects
Commit e24c2728 authored by Alex Jentsch's avatar Alex Jentsch Committed by Alex Jentsch
Browse files

Trying to add occupancy plots for the B0.

parent 726efc4f
No related branches found
No related tags found
No related merge requests found
......@@ -46,13 +46,43 @@ void b0_tracker_hits(const char* fname = "./sim_output/sim_forward_protons.root"
return result;
};
auto d1 = d0.Define("hits_theta", hits_theta, {"B0TrackerHits"});
auto x_pos_disk_1 = [&](const std::vector<std::array<double, 2>>& xypos) {
std::vector<double> result;
for (const auto& h : xypos) {
result.push_back(h.at(0));
}
return result;
};
auto y_pos_disk_1 = [&](const std::vector<std::array<double, 2>>& xypos) {
std::vector<double> result;
for (const auto& h : xypos) {
result.push_back(h.at(1));
}
return result;
};
auto d1 = d0.Define("nhits", nhits, {"B0TrackerHits"})
.Define("xy_hit_pos", local_position, {"B0TrackerHits"})
.Define("x_pos", x_pos, {"xy_hit_pos"})
.Define("y_pos", y_pos, {"xy_hit_pos"});
auto h1 = d1.Histo1D({"h1", "hits_theta", 100, 0,20}, "hits_theta");
auto h_local_pos = d1.Histo2D({"h_local_pos", ";x [mm]; y [mm] ", 100, -100.0, -200.0, 100, -100.0, 100.0}, "x_pos", "y_pos");
auto d2 = d0.Define("hits_theta", hits_theta, {"B0TrackerHits"});
auto h1 = d2.Histo1D({"h1", "hits_theta", 100, 0,20}, "hits_theta");
TCanvas* c = new TCanvas();
h1->DrawCopy();
c->SaveAs("results/b0_tracker_hits_theta.png");
c->SaveAs("results/b0_tracker_hits_theta.pdf");
h_local_pos->DrawCopy("colz");
c->SaveAs("results/b0_tracker_hits_occupancy_disk_1.png");
c->SaveAs("results/b0_tracker_hits_occupancy_disk_1.pdf");
auto n1 = h1->GetMean();
std::cout << "Polar angle of hits: " << n1 << std::endl;
......
......@@ -17,13 +17,15 @@ using namespace HepMC3;
/** Generate electrons in the central region.
* This is for testing detectors in the "barrel" region.
*/
void gen_forward_protons(int n_events = 100,
void gen_forward_protons(int n_events = 1000,
const char* out_fname = "forward_protons.hepmc")
{
// generate protons in B0 acceptance - roughly 5 - 20 mrad
double cos_theta_min = std::cos(0.005*(M_PI/180.0));
double cos_theta_max = std::cos(0.020*(M_PI/180.0));
double cos_theta_min = 0.005; //std::cos(0.005*(M_PI/180.0));
double cos_theta_max = 0.020; //std::cos(0.020*(M_PI/180.0));
double partEnergyMin = 270.0; // xL 0.98
double partEnergyMax = 275.0; // top beam energy
......@@ -52,7 +54,7 @@ void gen_forward_protons(int n_events = 100,
Double_t p = r1->Uniform(partEnergyMin, partEnergyMax);
Double_t phi = r1->Uniform(0.0, 2.0 * M_PI);
Double_t costh = r1->Uniform(cos_theta_min, cos_theta_max);
Double_t th = std::acos(costh);
Double_t th = costh; //std::acos(costh);
Double_t px = p * std::cos(phi) * std::sin(th);
Double_t py = p * std::sin(phi) * std::sin(th);
Double_t pz = p * std::cos(th);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment