Project
Loading...
Searching...
No Matches
Histos.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11//_________________________________________________________________________________________________
12
13#include "Histos.h"
16#include <TCanvas.h>
17#include <TH1.h>
18#include <TH2.h>
19#include <TMath.h>
20
21namespace o2::mch::eval
22{
23void createHistosForClusterResiduals(std::vector<TH1*>& histos, const char* extension, double range)
24{
25 if (histos.size() == 0) {
26 for (int iSt = 1; iSt <= 5; ++iSt) {
27 histos.emplace_back(new TH1F(Form("resX%sSt%d", extension, iSt),
28 Form("#DeltaX Station %d;#DeltaX (cm)", iSt), 2000, -range, range));
29 histos.emplace_back(new TH1F(Form("resY%sSt%d", extension, iSt),
30 Form("#DeltaY Station %d;#DeltaY (cm)", iSt), 2000, -range, range));
31 }
32 histos.emplace_back(new TH1F(Form("resX%s", extension), "#DeltaX;#DeltaX (cm)", 2000, -range, range));
33 histos.emplace_back(new TH1F(Form("resY%s", extension), "#DeltaY;#DeltaY (cm)", 2000, -range, range));
34 }
35}
36
37void createHistosForTrackResiduals(std::vector<TH1*>& histos)
38{
39 if (histos.size() == 0) {
40 histos.emplace_back(new TH1F("dx", "dx;dx (cm)", 20001, -1.00005, 1.00005));
41 histos.emplace_back(new TH1F("dy", "dy;dy (cm)", 20001, -1.00005, 1.00005));
42 histos.emplace_back(new TH1F("dz", "dz;dz (cm)", 20001, -1.00005, 1.00005));
43 histos.emplace_back(new TH1F("dpx", "dpx;dpx (GeV/c)", 20001, -1.00005, 1.00005));
44 histos.emplace_back(new TH1F("dpy", "dpy;dpy (GeV/c)", 20001, -1.00005, 1.00005));
45 histos.emplace_back(new TH1F("dpz", "dpz;dpz (GeV/c)", 20001, -1.00005, 1.00005));
46 histos.emplace_back(new TH2F("dpxvspx", "dpxvspx;px (GeV/c);dpx/px (\%)", 2000, 0., 20., 2001, -10.005, 10.005));
47 histos.emplace_back(new TH2F("dpyvspy", "dpyvspy;py (GeV/c);dpy/py (\%)", 2000, 0., 20., 2001, -10.005, 10.005));
48 histos.emplace_back(new TH2F("dpzvspz", "dpzvspz;pz (GeV/c);dpz/pz (\%)", 2000, 0., 200., 2001, -10.005, 10.005));
49 histos.emplace_back(new TH2F("dslopexvsp", "dslopexvsp;p (GeV/c);dslopex", 2000, 0., 200., 2001, -0.0010005, 0.0010005));
50 histos.emplace_back(new TH2F("dslopeyvsp", "dslopeyvsp;p (GeV/c);dslopey", 2000, 0., 200., 2001, -0.0010005, 0.0010005));
51 histos.emplace_back(new TH2F("dpvsp", "dpvsp;p (GeV/c);dp/p (\%)", 2000, 0., 200., 2001, -10.005, 10.005));
52 }
53}
54
55void createHistosAtVertex(std::vector<TH1*>& histos, const char* extension)
56{
57 if (histos.size() == 0) {
58 histos.emplace_back(new TH1F(Form("pT%s", extension), "pT;p_{T} (GeV/c)", 300, 0., 30.));
59 histos.emplace_back(new TH1F(Form("eta%s", extension), "eta;eta", 200, -4.5, -2.));
60 histos.emplace_back(new TH1F(Form("phi%s", extension), "phi;phi", 360, 0., 360.));
61 histos.emplace_back(new TH1F(Form("rAbs%s", extension), "rAbs;R_{abs} (cm)", 1000, 0., 100.));
62 histos.emplace_back(new TH1F(Form("p%s", extension), "p;p (GeV/c)", 300, 0., 300.));
63 histos.emplace_back(new TH1F(Form("dca%s", extension), "DCA;DCA (cm)", 500, 0., 500.));
64 histos.emplace_back(new TH1F(Form("pDCA23%s", extension), "pDCA for #theta_{abs} < 3#circ;pDCA (GeV.cm/c)", 2500, 0., 5000.));
65 histos.emplace_back(new TH1F(Form("pDCA310%s", extension), "pDCA for #theta_{abs} > 3#circ;pDCA (GeV.cm/c)", 2500, 0., 5000.));
66 histos.emplace_back(new TH1F(Form("nClusters%s", extension), "number of clusters per track;n_{clusters}", 20, 0., 20.));
67 histos.emplace_back(new TH1F(Form("chi2%s", extension), "normalized #chi^{2};#chi^{2} / ndf", 500, 0., 50.));
68 histos.emplace_back(new TH1F(Form("matchChi2%s", extension), "normalized matched #chi^{2};#chi^{2} / ndf", 160, 0., 16.));
69 histos.emplace_back(new TH1F(Form("mass%s", extension), "#mu^{+}#mu^{-} invariant mass;mass (GeV/c^{2})", 1600, 0., 20.));
70 }
71}
72
73void fillHistosAtVertex(const std::list<ExtendedTrack>& tracks, const std::vector<TH1*>& histos)
74{
75 for (auto itTrack1 = tracks.begin(); itTrack1 != tracks.end(); ++itTrack1) {
76 fillHistosMuAtVertex(*itTrack1, histos);
77 for (auto itTrack2 = std::next(itTrack1); itTrack2 != tracks.end(); ++itTrack2) {
78 fillHistosDimuAtVertex(*itTrack1, *itTrack2, histos);
79 }
80 }
81}
82
83void fillHistosMuAtVertex(const ExtendedTrack& track, const std::vector<TH1*>& histos)
84{
85 double thetaAbs = TMath::ATan(track.getRabs() / 505.) * TMath::RadToDeg();
86 double pUncorr = std::sqrt(track.param().px() * track.param().px() + track.param().py() * track.param().py() + track.param().pz() * track.param().pz());
87 double pDCA = pUncorr * track.getDCA();
88
89 histos[0]->Fill(track.P().Pt());
90 histos[1]->Fill(track.P().Eta());
91 histos[2]->Fill(180. + std::atan2(-track.P().Px(), -track.P().Py()) / TMath::Pi() * 180.);
92 histos[3]->Fill(track.getRabs());
93 histos[4]->Fill(track.P().P());
94 histos[5]->Fill(track.getDCA());
95 if (thetaAbs < 3) {
96 histos[6]->Fill(pDCA);
97 } else {
98 histos[7]->Fill(pDCA);
99 }
100 histos[8]->Fill(track.getClusters().size());
101 histos[9]->Fill(track.getNormalizedChi2());
102}
103
104void fillHistosDimuAtVertex(const ExtendedTrack& track1, const ExtendedTrack& track2, const std::vector<TH1*>& histos)
105{
106 if (track1.getCharge() * track2.getCharge() < 0.) {
107 ROOT::Math::PxPyPzMVector dimu = track1.P() + track2.P();
108 histos[11]->Fill(dimu.M());
109 }
110}
111
112void fillComparisonsAtVertex(std::list<ExtendedTrack>& tracks1,
113 std::list<ExtendedTrack>& tracks2,
114 const std::array<std::vector<TH1*>, 5>& histos)
115{
116 for (auto itTrack21 = tracks2.begin(); itTrack21 != tracks2.end(); ++itTrack21) {
117
118 // fill histograms for identical, similar (from file 2) and additional muons
119 if (itTrack21->hasMatchIdentical()) {
120 fillHistosMuAtVertex(*itTrack21, histos[0]);
121 } else if (itTrack21->hasMatchFound()) {
122 fillHistosMuAtVertex(*itTrack21, histos[2]);
123 } else {
124 fillHistosMuAtVertex(*itTrack21, histos[3]);
125 }
126
127 for (auto itTrack22 = std::next(itTrack21); itTrack22 != tracks2.end(); ++itTrack22) {
128
129 // fill histograms for identical, similar (from file 2) and additional dimuons
130 if (itTrack21->hasMatchIdentical() && itTrack22->hasMatchIdentical()) {
131 fillHistosDimuAtVertex(*itTrack21, *itTrack22, histos[0]);
132 } else if (itTrack21->hasMatchFound() && itTrack22->hasMatchFound()) {
133 fillHistosDimuAtVertex(*itTrack21, *itTrack22, histos[2]);
134 } else {
135 fillHistosDimuAtVertex(*itTrack21, *itTrack22, histos[3]);
136 }
137 }
138 }
139
140 for (auto itTrack11 = tracks1.begin(); itTrack11 != tracks1.end(); ++itTrack11) {
141
142 // fill histograms for missing and similar (from file 1) muons
143 if (!itTrack11->hasMatchFound()) {
144 fillHistosMuAtVertex(*itTrack11, histos[4]);
145 } else if (!itTrack11->hasMatchIdentical()) {
146 fillHistosMuAtVertex(*itTrack11, histos[1]);
147 }
148
149 for (auto itTrack12 = std::next(itTrack11); itTrack12 != tracks1.end(); ++itTrack12) {
150
151 // fill histograms for missing and similar (from file 1) dimuons
152 if (!itTrack11->hasMatchFound() || !itTrack12->hasMatchFound()) {
153 fillHistosDimuAtVertex(*itTrack11, *itTrack12, histos[4]);
154 } else if (!itTrack11->hasMatchIdentical() || !itTrack12->hasMatchIdentical()) {
155 fillHistosDimuAtVertex(*itTrack11, *itTrack12, histos[1]);
156 }
157 }
158 }
159}
160
161void fillTrackResiduals(const TrackParam& param1, const TrackParam& param2, std::vector<TH1*>& histos)
162{
163 double p1 = TMath::Sqrt(param1.px() * param1.px() + param1.py() * param1.py() + param1.pz() * param1.pz());
164 double p2 = TMath::Sqrt(param2.px() * param2.px() + param2.py() * param2.py() + param2.pz() * param2.pz());
165 histos[0]->Fill(param2.getNonBendingCoor() - param1.getNonBendingCoor());
166 histos[1]->Fill(param2.getBendingCoor() - param1.getBendingCoor());
167 histos[2]->Fill(param2.getZ() - param1.getZ());
168 histos[3]->Fill(param2.px() - param1.px());
169 histos[4]->Fill(param2.py() - param1.py());
170 histos[5]->Fill(param2.pz() - param1.pz());
171 histos[6]->Fill(TMath::Abs(param1.px()), 100. * (param2.px() - param1.px()) / param1.px());
172 histos[7]->Fill(TMath::Abs(param1.py()), 100. * (param2.py() - param1.py()) / param1.py());
173 histos[8]->Fill(TMath::Abs(param1.pz()), 100. * (param2.pz() - param1.pz()) / param1.pz());
174 histos[9]->Fill(p1, param2.px() / param2.pz() - param1.px() / param1.pz());
175 histos[10]->Fill(p1, param2.py() / param2.pz() - param1.py() / param1.pz());
176 histos[11]->Fill(p1, 100. * (p2 - p1) / p1);
177}
178
179void fillClusterClusterResiduals(const ExtendedTrack& track1, const ExtendedTrack& track2, std::vector<TH1*>& histos)
180{
181 for (const auto& cl1 : track1.getClusters()) {
182 for (const auto& cl2 : track2.getClusters()) {
183 if (cl1.getDEId() == cl2.getDEId()) {
184 double dx = cl2.getX() - cl1.getX();
185 double dy = cl2.getY() - cl1.getY();
186 histos[cl1.getChamberId() / 2 * 2]->Fill(dx);
187 histos[cl1.getChamberId() / 2 * 2 + 1]->Fill(dy);
188 histos[10]->Fill(dx);
189 histos[11]->Fill(dy);
190 }
191 }
192 }
193}
194
195//_________________________________________________________________________________________________
196void fillClusterTrackResiduals(const std::list<ExtendedTrack>& tracks, std::vector<TH1*>& histos, bool matched)
197{
198 for (const auto& track : tracks) {
199 if (!matched || track.hasMatchFound()) {
200 for (const auto& param : track.track()) {
201 double dx = param.getClusterPtr()->getX() - param.getNonBendingCoor();
202 double dy = param.getClusterPtr()->getY() - param.getBendingCoor();
203 histos[param.getClusterPtr()->getChamberId() / 2 * 2]->Fill(dx);
204 histos[param.getClusterPtr()->getChamberId() / 2 * 2 + 1]->Fill(dy);
205 histos[10]->Fill(dx);
206 histos[11]->Fill(dy);
207 }
208 }
209 }
210}
211
212} // namespace o2::mch::eval
constexpr int p2()
constexpr int p1()
constexpr to accelerate the coordinates changing
Definition of the MCH track parameters for internal use.
track parameters for internal use
Definition TrackParam.h:34
Double_t pz() const
Double_t getNonBendingCoor() const
return non bending coordinate (cm)
Definition TrackParam.h:51
Double_t py() const
Double_t getZ() const
return Z coordinate (cm)
Definition TrackParam.h:47
Double_t getBendingCoor() const
return bending coordinate (cm)
Definition TrackParam.h:59
Double_t px() const
const TrackParam & param() const
const ROOT::Math::PxPyPzMVector & P() const
const std::vector< Cluster > & getClusters() const
GLenum GLint * range
Definition glcorearb.h:1899
GLenum GLfloat param
Definition glcorearb.h:271
void createHistosForTrackResiduals(std::vector< TH1 * > &histos)
Definition Histos.cxx:37
void fillHistosAtVertex(const std::list< ExtendedTrack > &tracks, const std::vector< TH1 * > &histos)
Definition Histos.cxx:73
void fillHistosDimuAtVertex(const ExtendedTrack &track1, const ExtendedTrack &track2, const std::vector< TH1 * > &histos)
Definition Histos.cxx:104
void fillClusterTrackResiduals(const std::list< ExtendedTrack > &tracks, std::vector< TH1 * > &histos, bool matched)
Definition Histos.cxx:196
void createHistosAtVertex(std::vector< TH1 * > &histos, const char *extension)
Definition Histos.cxx:55
void fillComparisonsAtVertex(std::list< ExtendedTrack > &tracks1, std::list< ExtendedTrack > &tracks2, const std::array< std::vector< TH1 * >, 5 > &histos)
Definition Histos.cxx:112
void createHistosForClusterResiduals(std::vector< TH1 * > &histos, const char *extension, double range)
Definition Histos.cxx:23
void fillTrackResiduals(const TrackParam &param1, const TrackParam &param2, std::vector< TH1 * > &histos)
Definition Histos.cxx:161
void fillHistosMuAtVertex(const ExtendedTrack &track, const std::vector< TH1 * > &histos)
Definition Histos.cxx:83
void fillClusterClusterResiduals(const ExtendedTrack &track1, const ExtendedTrack &track2, std::vector< TH1 * > &histos)
Definition Histos.cxx:179