Commit 6fb21ba4 authored by Paul Schütze's avatar Paul Schütze
Browse files

Merge branch 'p-histos' into 'master'

DetectorHistogrammer: add hitmap of MC positions in global coords

See merge request allpix-squared/allpix-squared!1192
parents c0d25a6e 1507f095
Loading
Loading
Loading
Loading
+20 −3
Original line number Diff line number Diff line
@@ -90,10 +90,21 @@ void DetectorHistogrammerModule::initialize() {
        (model->getSensorCenter() + ROOT::Math::XYZVector(-model->getSensorSize().x(), model->getSensorSize().y(), 0) / 2));
    hit_map_global = CreateHistogram<TH2D>("hit_map_global",
                                           hit_map_global_title.c_str(),
                                           static_cast<int>(model->getSensorSize().x()) * 10,
                                           200,
                                           std::min({global_ll.x(), global_ur.x(), global_lr.x(), global_ul.x()}),
                                           std::max({global_ll.x(), global_ur.x(), global_lr.x(), global_ul.x()}),
                                           static_cast<int>(model->getSensorSize().y()) * 10,
                                           200,
                                           std::min({global_ll.y(), global_ur.y(), global_lr.y(), global_ul.y()}),
                                           std::max({global_ll.y(), global_ur.y(), global_lr.y(), global_ul.y()}));

    std::string hit_map_global_mc_title =
        "MCParticle position hitmap (" + detector_->getName() + ") in global coord.;x [mm[];y [mm];hits";
    hit_map_global_mc = CreateHistogram<TH2D>("hit_map_global_mc",
                                              hit_map_global_mc_title.c_str(),
                                              200,
                                              std::min({global_ll.x(), global_ur.x(), global_lr.x(), global_ul.x()}),
                                              std::max({global_ll.x(), global_ur.x(), global_lr.x(), global_ul.x()}),
                                              200,
                                              std::min({global_ll.y(), global_ur.y(), global_lr.y(), global_ul.y()}),
                                              std::max({global_ll.y(), global_ur.y(), global_lr.y(), global_ul.y()}));

@@ -493,8 +504,10 @@ void DetectorHistogrammerModule::run(Event* event) {
        LOG(TRACE) << "Matching primaries: " << intersection.size();
        for(const auto& particle : intersection) {
            auto particlePos = particle->getLocalReferencePoint();
            auto particlePosGlobal = detector_->getGlobalPosition(particlePos);
            // Plot hist in global coordinates of the associated MCParticles:
            hit_map_local_mc->Fill(particlePos.x(), particlePos.y());
            hit_map_global_mc->Fill(particlePosGlobal.x(), particlePosGlobal.y());
            // Add track smearing to the particle position:
            particlePos += track_smearing(track_resolution_);
            LOG(DEBUG) << "MCParticle at " << Units::display(particlePos, {"mm", "um"});
@@ -503,7 +516,8 @@ void DetectorHistogrammerModule::run(Event* event) {
            auto [xpixel, ypixel] = model->getPixelIndex(particlePos);

            auto inPixelPos = particlePos - model->getPixelCenter(xpixel, ypixel);
            LOG(TRACE) << "MCParticle in pixel at " << Units::display(inPixelPos, {"mm", "um"});
            LOG(TRACE) << "MCParticle in pixel (" << xpixel << "," << ypixel << ") at "
                       << Units::display(inPixelPos, {"mm", "um"});

            // Calculate residual with cluster position:
            auto residual_um_x = static_cast<double>(Units::convert(particlePos.x() - clusterPos.x(), "um"));
@@ -630,6 +644,7 @@ void DetectorHistogrammerModule::finalize() {
    // Merge histograms that were possibly filled in parallel in order to change drawing options on the final object
    auto hit_map_histogram = hit_map->Merge();
    auto hit_map_global_histogram = hit_map_global->Merge();
    auto hit_map_global_mc_histogram = hit_map_global_mc->Merge();
    auto hit_map_local_histogram = hit_map_local->Merge();
    auto hit_map_local_mc_histogram = hit_map_local_mc->Merge();
    auto charge_map_histogram = charge_map->Merge();
@@ -717,6 +732,7 @@ void DetectorHistogrammerModule::finalize() {
    // Set default drawing option histogram for hitmap
    hit_map_histogram->SetOption("colz");
    hit_map_global_histogram->SetOption("colz");
    hit_map_global_mc_histogram->SetOption("colz");
    hit_map_local_histogram->SetOption("colz");
    hit_map_local_mc_histogram->SetOption("colz");
    // Set hit_map axis spacing
@@ -761,6 +777,7 @@ void DetectorHistogrammerModule::finalize() {
    n_cluster_histogram->Write();
    hit_map_histogram->Write();
    hit_map_global_histogram->Write();
    hit_map_global_mc_histogram->Write();
    hit_map_local_histogram->Write();
    hit_map_local_mc_histogram->Write();

+2 −1
Original line number Diff line number Diff line
@@ -90,7 +90,8 @@ namespace allpix {
        ROOT::Math::XYVector track_resolution_{};

        // Histograms to output
        Histogram<TH2D> hit_map, hit_map_global, hit_map_local, hit_map_local_mc, charge_map, cluster_map, polar_hit_map;
        Histogram<TH2D> hit_map, hit_map_global, hit_map_global_mc, hit_map_local, hit_map_local_mc, charge_map, cluster_map,
            polar_hit_map;
        Histogram<TProfile2D> cluster_size_map_local, cluster_size_map, cluster_size_x_map, cluster_size_y_map;
        Histogram<TProfile2D> cluster_charge_map, seed_charge_map;
        Histogram<TProfile2D> residual_map, residual_x_map, residual_y_map, residual_detector, residual_x_detector,