Skip to content

Commit

Permalink
add grid and marker of mean
Browse files Browse the repository at this point in the history
  • Loading branch information
Roberta-Ferioli committed Mar 21, 2024
1 parent ec63939 commit 9ea6f5c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 13 deletions.
50 changes: 37 additions & 13 deletions Event_Display/ClusterShapeDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,66 @@
#include "TStyle.h"
#include <bitset>
#include <iostream>
#include <TMarker.h>
#include <TGraphErrors.h>

void fillBinaryMatrix(TH2D *hist, const uint8_t *ExampleArray, int size,
void fillBinaryMatrix(TH2D *histCluster, const uint8_t *ExampleArray, int size,
int max_length, int xClusterPosition,
int yClusterPosition) {
for (int i = 0; i < size; ++i) {
std::bitset<8> bits(ExampleArray[i]);
for (int j = 0; j < max_length; j++) {
hist->Fill(xClusterPosition + j, yClusterPosition - i - 1,
histCluster->Fill(xClusterPosition + j, yClusterPosition - i - 1,
bits[max_length - 1 - j]); // Adjusting the y-position
}
}
}

void ClusterShapeDisplay() {
// need to link t cluster class
// uint8_t ExampleArray[] = {16, 48, 48, 224, 32, 0, 0, 0};// Example array
uint8_t ExampleArray[] = {192, 192, 80, 248, 16, 16, 16, 16};
uint8_t ExampleArray[] = {16, 48, 48, 224, 32, 0, 0, 0};// Example array
//uint8_t ExampleArray[] = {192, 192, 80, 248, 16, 16, 16, 16};
int size = sizeof(ExampleArray) / sizeof(ExampleArray[0]);
int max_length = 8;
// int xClusterPosition = 123;
// int yClusterPosition = 456;
int xClusterPosition = 379;
int yClusterPosition = 28;
int xClusterPosition = 123;
int yClusterPosition = 456;
//int xClusterPosition = 379;
//int yClusterPosition = 28;
double xMean=125;
double yMean=453.5;
double xErrorBar=2;
double yErrorBar=2.5;
//double xMean=381.5; //to be linked to the cluster class, made with mean of random numbers used before
//double yMean=24.0;
//double xErrorBar=2.5;
//double yErrorBar=4.0;

TH2D *hist = new TH2D("Cluster", "Cluster", max_length, xClusterPosition,
TH2D *histCluster = new TH2D("Cluster", "Cluster", max_length, xClusterPosition,
xClusterPosition + max_length, size,
yClusterPosition - size, yClusterPosition);

fillBinaryMatrix(hist, ExampleArray, size, max_length, xClusterPosition,
fillBinaryMatrix(histCluster, ExampleArray, size, max_length, xClusterPosition,
yClusterPosition);

TCanvas *canvas = new TCanvas("canvas", "Canvas", 800, 600);
TCanvas *canvas = new TCanvas("canvas", "Canvas", 1000, 1000);
gStyle->SetOptStat(0);
hist->Draw("col");
gPad->SetGrid();
histCluster->Draw("col");
histCluster->GetXaxis()->SetTitle("X (pixel)");
histCluster->GetYaxis()->SetTitle("Y (pixel)");
TGraphErrors *PointGraph = new TGraphErrors();
PointGraph->SetPoint(0, xMean, yMean);
PointGraph->SetPointError(0, xErrorBar, yErrorBar);
PointGraph->SetLineColor(kRed);
PointGraph->SetLineWidth(3);
PointGraph->SetMarkerStyle(20);
PointGraph->SetMarkerColor(kRed);
PointGraph->SetMarkerSize(2);
PointGraph->Draw("P,same");

canvas->Update();
canvas->SaveAs("clusterShape1.png");

delete hist;
delete histCluster;
delete canvas;
}
Binary file removed Event_Display/clusterShape.png
Binary file not shown.
Binary file modified Event_Display/clusterShape1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Event_Display/clusterShape2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9ea6f5c

Please sign in to comment.