Skip to content

Commit

Permalink
Fix hit creation for TF3 et al + minor fixes (AliceO2Group#12925)
Browse files Browse the repository at this point in the history
  • Loading branch information
mconcas authored Mar 25, 2024
1 parent f12310e commit b8fa51e
Show file tree
Hide file tree
Showing 8 changed files with 187 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ class SimTraits
/*IT3*/ VS{ "IT3Hit" },
/*TRK*/ VS{ "TRKHit" },
/*FT3*/ VS{ "FT3Hit" },
/*FCT*/ VS{ "FCTHit" }
/*FCT*/ VS{ "FCTHit" },
/*TF3*/ VS{ "TF3Hit" },
/*RCH*/ VS{ "RCHHit" },
/*MI3*/ VS{ "MI3Hit" },
/*ECL*/ VS{ "ECLHit" }
#endif
};
// clang-format on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ bool Detector::ProcessHits(FairVolume* vol)
int lay = vol->getVolumeId();
int volID = vol->getMCid();

// Is it needed to keep a track reference when the outer ITS volume is encountered?
// Is it needed to keep a track reference when the outer volume is encountered?
auto stack = (o2::data::Stack*)fMC->GetStack();
if (fMC->IsTrackExiting() /*&& (lay == 0 || lay == mLayers.size() - 1)*/) {
// Keep the track refs for the innermost and outermost layers only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ class FWDRich
// Silicon:
float mZSiliconMin;
float mDZSilicon;

ClassDef(FWDRich, 0);
};

class BWDRich
Expand Down Expand Up @@ -131,6 +133,8 @@ class BWDRich
// Silicon:
float mZSiliconMin;
float mDZSilicon;

ClassDef(BWDRich, 0);
};

} // namespace rich
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#pragma link off all functions;

#pragma link C++ class o2::rich::Ring + ;
#pragma link C++ class o2::rich::BWDRich + ;
#pragma link C++ class o2::rich::FWDRich + ;
#pragma link C++ class o2::rich::Detector + ;
#pragma link C++ class o2::base::DetImpl < o2::rich::Detector> + ;

Expand Down
3 changes: 3 additions & 0 deletions Detectors/Upgrades/ALICE3/macros/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@
# or submit itself to any jurisdiction.

o2_add_test_root_macro(scanXX0.C
LABELS alice3)

o2_add_test_root_macro(plotHits.C
LABELS alice3)
112 changes: 112 additions & 0 deletions Detectors/Upgrades/ALICE3/macros/plotHits.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
//
// Author: M. Concas

#if !defined(__CLING__) || defined(__ROOTCLING__)
#include "ITSMFTSimulation/Hit.h"

#include <TCanvas.h>
#include <TFile.h>
#include <TTree.h>
#include <TVector3.h>
#include <TVector2.h>
#include <TH2F.h>
#include <TH3F.h>
#include <TNtuple.h>

#include <vector>
#endif

void plotHits(const size_t nevents = 100)
{
TNtuple* tuple = new TNtuple("xyz", "xyz", "x:y:z:color");
TH2* ep = new TH2F("etaph", "hist_etaph;#varphi;#eta", 150, 0., TMath::TwoPi(), 150, -5, 5);
TH2* zp = new TH2F("zph", "hist_zph;;#varphi;z(cm) ", 150, 0., TMath::TwoPi(), 300, -200, 200);
TH2* zr = new TH2F("zr", "hist_zr;z(cm);r(cm) ", 500, -400, 400, 500, 0, 110);
TH3F* xyz_trk = new TH3F("xyz_trk", "hist_xyz;x(cm);y(cm);z(cm)", 300, -100, 100, 300, -100, 100, 300, -400, 400);
TH3F* xyz_ft3 = new TH3F("xyz_ft3", "hist_xyz;x(cm);y(cm);z(cm)", 300, -100, 100, 300, -100, 100, 300, -400, 400);
TH3F* xyz_tof = new TH3F("xyz_tf3", "hist_xyz;x(cm);y(cm);z(cm)", 300, -100, 100, 300, -100, 100, 300, -400, 400);

std::vector<TFile*> hitFiles;
hitFiles.push_back(TFile::Open("o2sim_HitsTF3.root"));
hitFiles.push_back(TFile::Open("o2sim_HitsFT3.root"));
hitFiles.push_back(TFile::Open("o2sim_HitsTRK.root"));

TTree* trkTree = hitFiles[2] ? (TTree*)hitFiles[2]->Get("o2sim") : nullptr;
TTree* ft3Tree = hitFiles[1] ? (TTree*)hitFiles[1]->Get("o2sim") : nullptr;
TTree* tf3Tree = hitFiles[0] ? (TTree*)hitFiles[0]->Get("o2sim") : nullptr;

// TRK
std::vector<o2::itsmft::Hit>* trkHit = nullptr;
trkTree->SetBranchAddress("TRKHit", &trkHit);

// FT3
std::vector<o2::itsmft::Hit>* ft3Hit = nullptr;
ft3Tree->SetBranchAddress("FT3Hit", &ft3Hit);

// TF3
std::vector<o2::itsmft::Hit>* tf3Hit = nullptr;
tf3Tree->SetBranchAddress("TF3Hit", &tf3Hit);

for (size_t iev = 0; iev < std::min(nevents, (size_t)trkTree->GetEntries()); iev++) {
trkTree->GetEntry(iev);
for (const auto& h : *trkHit) {
TVector3 posvec(h.GetX(), h.GetY(), h.GetZ());
ep->Fill(TVector2::Phi_0_2pi(posvec.Phi()), posvec.Eta());
zp->Fill(TVector2::Phi_0_2pi(posvec.Phi()), posvec.Z());
zr->Fill(posvec.Z(), TMath::Hypot(posvec.X(), posvec.Y()));
xyz_trk->Fill(posvec.X(), posvec.Y(), posvec.Z());
tuple->Fill(posvec.X(), posvec.Y(), posvec.Z(), 40);
}
ft3Tree->GetEntry(iev);
for (const auto& h : *ft3Hit) {
TVector3 posvec(h.GetX(), h.GetY(), h.GetZ());
ep->Fill(TVector2::Phi_0_2pi(posvec.Phi()), posvec.Eta());
zp->Fill(TVector2::Phi_0_2pi(posvec.Phi()), posvec.Z());
zr->Fill(posvec.Z(), TMath::Hypot(posvec.X(), posvec.Y()));
xyz_ft3->Fill(posvec.X(), posvec.Y(), posvec.Z());
tuple->Fill(posvec.X(), posvec.Y(), posvec.Z(), 30);
}
tf3Tree->GetEntry(iev);
for (const auto& h : *tf3Hit) {
TVector3 posvec(h.GetX(), h.GetY(), h.GetZ());
ep->Fill(TVector2::Phi_0_2pi(posvec.Phi()), posvec.Eta());
zp->Fill(TVector2::Phi_0_2pi(posvec.Phi()), posvec.Z());
zr->Fill(posvec.Z(), TMath::Hypot(posvec.X(), posvec.Y()));
xyz_tof->Fill(posvec.X(), posvec.Y(), posvec.Z());
tuple->Fill(posvec.X(), posvec.Y(), posvec.Z(), 20);
}
}

auto* EPcanvas = new TCanvas("EtaPhi", "EP", 1000, 800);
EPcanvas->cd();
ep->Draw();
EPcanvas->SaveAs("EtaPhi.png");
auto* ZPcanvas = new TCanvas("ZPhi", "ZP", 1000, 800);
ZPcanvas->cd();
zp->Draw();
ZPcanvas->SaveAs("ZPhi.png");
auto* RZcanvas = new TCanvas("RZ", "RZ", 1000, 800);
RZcanvas->cd();
zr->Draw();
RZcanvas->SaveAs("RZ.png");
auto* XYZcanvas = new TCanvas("XYZ", "XYZ", 1000, 800);
XYZcanvas->cd();
xyz_trk->Draw("p");
xyz_ft3->Draw("same");
xyz_tof->Draw("same");
XYZcanvas->SaveAs("XYZ.png");
auto* XYZ3Dcanvas = new TCanvas("XYZ3D", "XYZ3D", 1000, 800);
XYZ3Dcanvas->cd();
tuple->Draw("x:y:z:color");
XYZ3Dcanvas->SaveAs("XYZ3D.png");
}
81 changes: 50 additions & 31 deletions Detectors/Upgrades/ALICE3/macros/scanXX0.C
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
constexpr int nBinsPhiScan = 90;
constexpr int nBinsEtaScan = 200;
constexpr int nBinsZvtxScan = 300;
constexpr float maxEtaScan = 8.;
constexpr int n = 1e4; // testtracks
constexpr float maxEtaScan = 5.;
constexpr int n = 1e6; // testtracks
constexpr float len = 1000; // cm

void vacuumFormMaterial(TGeoMaterial* mat)
Expand Down Expand Up @@ -202,7 +202,7 @@ std::vector<std::string> printMaterialDefinitions(TGeoManager* gman)
return materialNames;
}

void scanXX0(const float rmax = 200, const float rmin = 0.2, const std::string OnlyMat = "all", const string fileName = "o2sim_geometry.root", const string path = "./")
void scanXX0(const float rmax = 350, const float rmin = 0.1, const std::string OnlyMat = "all", const std::string fileName = "o2sim_geometry.root", const string path = "./")
{
gStyle->SetPadTopMargin(0.035);
gStyle->SetPadRightMargin(0.035);
Expand All @@ -217,30 +217,30 @@ void scanXX0(const float rmax = 200, const float rmin = 0.2, const std::string O

double etaPos = 1.;

TCanvas* canvStack = new TCanvas("canvStack", "canvStack", 2400, 800);
TCanvas* canvStack = new TCanvas("canvStack", "canvStack", 2400, 1400);
canvStack->Divide(3, 1);

TCanvas* canv = new TCanvas("canv", "canv", 2400, 800);
TCanvas* canv = new TCanvas("canv", "canv", 2400, 1400);
canv->Divide(3, 1);

TLegend* legVsPhi = new TLegend(0.25, 0.6, 0.85, 0.9);
legVsPhi->SetFillColor(kWhite);
legVsPhi->SetTextSize(0.045);
legVsPhi->SetTextSize(0.025);
legVsPhi->SetHeader(Form("ALICE 3, |#it{#eta}| < %0.f, #it{Z}_{vtx} = 0", etaPos));

TLegend* legVsEta = new TLegend(0.25, 0.6, 0.85, 0.9);
legVsEta->SetFillColor(kWhite);
legVsEta->SetTextSize(0.045);
legVsEta->SetTextSize(0.025);
legVsEta->SetHeader("ALICE 3, 0 < #it{#varphi} < #pi, #it{Z}_{vtx} = 0");

TLegend* legVsZvtx = new TLegend(0.25, 0.6, 0.85, 0.9);
legVsZvtx->SetFillColor(kWhite);
legVsZvtx->SetTextSize(0.045);
legVsZvtx->SetTextSize(0.025);
legVsZvtx->SetHeader("ALICE 3, #it{#varphi} = #pi/2, #it{#eta} = 0");

auto* xOverX0VsPhiStack = new THStack("xOverX0VsPhi", "");
auto* xOverX0VsEtaStack = new THStack("xOverX0VsEta", "");
auto* xOverX0VsZvtxStack = new THStack("xOverX0VsZvtx", "");
auto* xOverX0VsPhiStack = new THStack("xOverX0VsPhi", ";#varphi (rad);#it{X/X0}");
auto* xOverX0VsEtaStack = new THStack("xOverX0VsEta", ";#eta;#it{X/X0}");
auto* xOverX0VsZvtxStack = new THStack("xOverX0VsZvtx", ";Z_{vtz} (cm);#it{X/X0}");

std::vector<TH1F*> xOverX0VsPhi;
std::vector<TH1F*> xOverX0VsEta;
Expand All @@ -251,14 +251,17 @@ void scanXX0(const float rmax = 200, const float rmin = 0.2, const std::string O

const double phiMin = 0;
const double phiMax = 2 * TMath::Pi();
const double len = 1000.;
const double len = 1200.;
std::vector<int> colors = {kAzure + 4, kRed + 1};

// delete gGeoManager; // We re-import the geometry at each iteration
int count = 2;
auto cols = TColor::GetPalette();

float maxPhiHist = 0.f, maxEtaHist = 0.f, maxZHist = 0.f;
for (size_t iMaterial{0}; iMaterial < materials.size(); ++iMaterial) {
if (materials[iMaterial] == "VACUUM") {
continue;
}
if (OnlyMat != "all" && materials[iMaterial] != OnlyMat) {
continue;
}
Expand All @@ -282,8 +285,11 @@ void scanXX0(const float rmax = 200, const float rmin = 0.2, const std::string O
xOverX0VsZvtx.emplace_back(new TH1F(Form("xOverX0VsZvtx_step%zu", iMaterial), "", nBinsZvtxScan, -len / 2, len / 2));

ComputeMaterialBudget(rmin, rmax, etaPos, phiMin, phiMax, xOverX0VsPhi.back(), xOverX0VsEta.back(), xOverX0VsZvtx.back());

// maxPhiHist = xOverX0VsPhi.back()->GetMaximum() > maxPhiHist ? 1.1 * xOverX0VsPhi.back()->GetMaximum() : maxPhiHist;
// maxEtaHist = xOverX0VsEta.back()->GetMaximum() > maxEtaHist ? 1.1 * xOverX0VsEta.back()->GetMaximum() : maxEtaHist;
// maxZHist = xOverX0VsZvtx.back()->GetMaximum() > maxZHist ? 1.1 * xOverX0VsZvtx.back()->GetMaximum() : maxZHist;
double meanX0vsPhi = 0, meanX0vsEta = 0, meanX0vsZvtx = 0;

for (int ix = 1; ix <= xOverX0VsPhi.back()->GetNbinsX(); ix++) {
meanX0vsPhi += xOverX0VsPhi.back()->GetBinContent(ix);
}
Expand All @@ -299,6 +305,11 @@ void scanXX0(const float rmax = 200, const float rmin = 0.2, const std::string O
}
meanX0vsZvtx /= xOverX0VsZvtx.back()->GetNbinsX();

if (!meanX0vsPhi && !meanX0vsEta && !meanX0vsZvtx) {
LOGP(info, "Material {} allegedly not present, skipping.", materials[iMaterial]);
continue;
}

LOGP(info, "Mean X/X0 vs. phi: {}", meanX0vsPhi);
LOGP(info, "Mean X/X0 vs. eta: {}", meanX0vsEta);
LOGP(info, "Mean X/X0 vs. Zvtx: {}", meanX0vsZvtx);
Expand Down Expand Up @@ -336,60 +347,68 @@ void scanXX0(const float rmax = 200, const float rmin = 0.2, const std::string O
xOverX0VsZvtx.back()->SetLineColor(iMaterial + 2);
xOverX0VsZvtx.back()->SetLineWidth(2);

if (xOverX0VsPhi.size() == 1) {
legVsPhi->AddEntry("", Form("#LT #it{X}/#it{X}_{0} #GT = %0.3f %%", meanX0vsPhi), "");
legVsEta->AddEntry("", Form("#LT #it{X}/#it{X}_{0} #GT = %0.3f %%", meanX0vsEta), "");
legVsZvtx->AddEntry("", Form("#LT #it{X}/#it{X}_{0} #GT = %0.3f %%", meanX0vsZvtx), "");
}
// if (xOverX0VsPhi.size() == materials.size() - 1 /*Vacuum is skipped*/) {
// legVsPhi->AddEntry("", Form("#LT #it{X}/#it{X}_{0} #GT = %0.3f %%", meanX0vsPhi), "");
// legVsEta->AddEntry("", Form("#LT #it{X}/#it{X}_{0} #GT = %0.3f %%", meanX0vsEta), "");
// legVsZvtx->AddEntry("", Form("#LT #it{X}/#it{X}_{0} #GT = %0.3f %%", meanX0vsZvtx), "");
// }

legVsPhi->AddEntry(xOverX0VsPhi.back(), materials[iMaterial].c_str(), "f");
legVsEta->AddEntry(xOverX0VsPhi.back(), materials[iMaterial].c_str(), "f");
legVsZvtx->AddEntry(xOverX0VsZvtx.back(), materials[iMaterial].c_str(), "f");

canv->cd(1)->SetGrid();
if (xOverX0VsPhi.size() == 1) {
xOverX0VsPhi.back()->SetMinimum(1.e-4);
// xOverX0VsPhi.back()->SetMaximum(20.f);
// xOverX0VsPhi.back()->SetMinimum(1.e-4);
xOverX0VsPhi.back()->SetMaximum(1e4);
xOverX0VsPhi.back()->DrawCopy("HISTO");
legVsPhi->Draw();
xOverX0VsPhiStack->Add(xOverX0VsPhi.back());
} else {
xOverX0VsPhi.back()->SetMaximum(1e4);
xOverX0VsPhi.back()->DrawCopy("HISTO SAME");
xOverX0VsPhiStack->Add(xOverX0VsPhi.back());
}

canv->cd(2)->SetGrid();
if (xOverX0VsEta.size() == 1) {
xOverX0VsEta.back()->SetMinimum(1.e-4);
// xOverX0VsEta.back()->SetMaximum(60.f);
// xOverX0VsEta.back()->SetMinimum(1.e-4);
xOverX0VsEta.back()->SetMaximum(1e4);
xOverX0VsEta.back()->DrawCopy("HISTO");
legVsEta->Draw();
xOverX0VsEtaStack->Add(xOverX0VsEta.back());
} else {
xOverX0VsEta.back()->SetMaximum(1e4);
xOverX0VsEta.back()->DrawCopy("HISTO SAME");
xOverX0VsEtaStack->Add(xOverX0VsEta.back());
}

canv->cd(3)->SetGrid();
if (xOverX0VsZvtx.size() == 1) {
xOverX0VsZvtx.back()->SetMinimum(1.e-4);
// xOverX0VsZvtx.back()->SetMaximum(120.f);
// xOverX0VsZvtx.back()->SetMinimum(1.e-4);
xOverX0VsZvtx.back()->SetMaximum(1e4);
xOverX0VsZvtx.back()->DrawCopy("HISTO");
legVsZvtx->Draw();
xOverX0VsZvtxStack->Add(xOverX0VsZvtx.back());
} else {
xOverX0VsZvtx.back()->SetMaximum(1e4);
xOverX0VsZvtx.back()->DrawCopy("HISTO SAME");
xOverX0VsZvtxStack->Add(xOverX0VsZvtx.back());
}
delete gGeoManager;
}
canv->cd(1)->SetLogy();
legVsPhi->Draw();
canv->cd(2)->SetLogy();
canv->cd(3)->SetLogy();
canvStack->cd(1)->SetGrid();
legVsEta->Draw();
canvStack->cd(1)->SetLogy();
xOverX0VsPhiStack->Draw("HISTO");
canvStack->cd(2)->SetGrid();
canvStack->cd(2)->SetLogy();
xOverX0VsEtaStack->Draw("HISTO");
canvStack->cd(3)->SetGrid();
canvStack->cd(3)->SetLogy();
xOverX0VsZvtxStack->Draw("HISTO");
canvStack->BuildLegend(0.25, 0.6, 0.85, 0.9);

canv->SaveAs("alice3_material_vsphietaz.pdf");
canvStack->SaveAs("alice3_material_vsphietaz_stack.pdf");
canv->SaveAs("alice3_material_vsphietaz.png");
canvStack->SaveAs("alice3_material_vsphietaz_stack.png");
}
10 changes: 10 additions & 0 deletions run/O2HitMerger.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@
#include <ITS3Simulation/DescriptorInnerBarrelITS3.h>
#include <IOTOFSimulation/Detector.h>
#include <RICHSimulation/Detector.h>
#include <ECalSimulation/Detector.h>
#include <MI3Simulation/Detector.h>
#endif

#include <tbb/concurrent_unordered_map.h>
Expand Down Expand Up @@ -1005,6 +1007,14 @@ void O2HitMerger::initDetInstances()
mDetectorInstances[i] = std::move(std::make_unique<o2::rich::Detector>(true));
counter++;
}
if (i == DetID::MI3) {
mDetectorInstances[i] = std::move(std::make_unique<o2::mi3::Detector>(true));
counter++;
}
if (i == DetID::ECL) {
mDetectorInstances[i] = std::move(std::make_unique<o2::ecal::Detector>(true));
counter++;
}
#endif
}
if (counter != DetID::nDetectors) {
Expand Down

0 comments on commit b8fa51e

Please sign in to comment.