Skip to content

Commit 255abdf

Browse files
njacazioshahor02
authored andcommitted
add first tof start time prototype
1 parent 63b1cf2 commit 255abdf

File tree

5 files changed

+358
-10
lines changed

5 files changed

+358
-10
lines changed

Detectors/TOF/prototyping/CMakeLists.txt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ o2_add_test_root_macro(checkRotation.C
1515

1616
o2_add_test_root_macro(convertTreeTo02object.C
1717
PUBLIC_LINK_LIBRARIES O2::ReconstructionDataFormats
18-
O2::DataFormatsTOF
18+
O2::DataFormatsTOF
1919
LABELS tof)
2020

2121
o2_add_test_root_macro(drawTOFgeometry.C
@@ -43,14 +43,19 @@ o2_add_test_root_macro(findTOFclusterFromLabel.C
4343

4444
o2_add_test_root_macro(checkTS.C
4545
PUBLIC_LINK_LIBRARIES O2::DataFormatsTOF
46-
LABELS tof)
46+
LABELS tof)
4747

4848
o2_add_test_root_macro(testCCDB.C
4949
PUBLIC_LINK_LIBRARIES O2::DataFormatsTOF
50-
O2::TOFCalibration
51-
LABELS tof)
50+
O2::TOFCalibration
51+
LABELS tof)
5252

5353
o2_add_test_root_macro(checkChannelMapping.C
5454
PUBLIC_LINK_LIBRARIES O2::TOFBase
5555
LABELS tof)
5656

57+
58+
o2_add_test_root_macro(macroEvTime.C
59+
PUBLIC_LINK_LIBRARIES O2::TOFBase
60+
O2::TOFReconstruction
61+
LABELS tof)
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#if !defined(__CLING__) || defined(__ROOTCLING__)
2+
#include "TOFReconstruction/EventTimeMaker.h"
3+
#endif
4+
5+
using namespace o2::tof;
6+
void macroEvTime(bool removebias = true)
7+
{
8+
9+
TH1F* htest = new TH1F("htest", ";N#sigma (t0_{reco} - t0_{true})", 100, -10, 10);
10+
TH1F* htest2 = new TH1F("htest2", ";t0_{reco} - t0_{true} ps", 100, -100, 100);
11+
12+
TH1F* hkaon = new TH1F("hkaon", ";N#sigma^{K}", 100, -10, 10);
13+
TH1F* hkaonT = new TH1F("hkaonT", ";N#sigma^{K}", 100, -10, 10);
14+
hkaonT->SetLineColor(2);
15+
16+
std::vector<eventTimeTrackTest> tracks;
17+
for (int i = 0; i < 1000; i++) {
18+
tracks.clear();
19+
generateEvTimeTracks(tracks, 5);
20+
auto evtime = evTimeMaker<std::vector<eventTimeTrackTest>, eventTimeTrackTest, filterDummy>(tracks);
21+
// Printf("Ev time %f +-%f", evtime.eventTime, evtime.eventTimeError);
22+
htest->Fill(evtime.eventTime / evtime.eventTimeError);
23+
htest2->Fill(evtime.eventTime);
24+
25+
int nt = 0;
26+
for (auto track : tracks) {
27+
28+
if (track.p() > 2) {
29+
nt++;
30+
continue;
31+
}
32+
33+
float et = evtime.eventTime;
34+
float erret = evtime.eventTimeError;
35+
36+
if (removebias) {
37+
float sumw = 1. / erret / erret;
38+
et *= sumw;
39+
et -= evtime.weights[nt] * evtime.tracktime[nt];
40+
sumw -= evtime.weights[nt];
41+
et /= sumw;
42+
erret = sqrt(1. / sumw);
43+
}
44+
45+
nt++;
46+
47+
float res = sqrt(100 * 100 + erret * erret);
48+
hkaon->Fill((track.tofSignal() - track.tofExpTimeKa() - et) / res);
49+
50+
if (track.masshypo() == 1) {
51+
hkaonT->Fill((track.tofSignal() - track.tofExpTimeKa() - et) / res);
52+
}
53+
}
54+
}
55+
htest->Draw();
56+
new TCanvas;
57+
htest2->Draw();
58+
new TCanvas;
59+
hkaon->Draw();
60+
hkaonT->Draw("SAME");
61+
}

Detectors/TOF/reconstruction/include/TOFReconstruction/EventTimeMaker.h

Lines changed: 83 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
#ifndef ALICEO2_TOF_EVENTTIMEMAKER_H
1616
#define ALICEO2_TOF_EVENTTIMEMAKER_H
1717

18+
#include "TRandom.h"
19+
#include "TMath.h"
20+
1821
namespace o2
1922
{
2023

@@ -25,18 +28,93 @@ struct eventTimeContainer {
2528
eventTimeContainer(const float& e, const float& err) : eventTime{e}, eventTimeError{err} {};
2629
float eventTime = 0.f;
2730
float eventTimeError = 0.f;
31+
32+
float sumweights = 0.f; // sum of weights of all track contributors
33+
std::vector<float> weights; // weights (1/sigma^2) associated to a track in event time computation, 0 if track not used
34+
std::vector<float> tracktime; // eventtime provided by a single track
35+
};
36+
37+
struct eventTimeTrack {
38+
eventTimeTrack() = default;
39+
eventTimeTrack(float tof, float expt[3], float expsigma[3]) : mSignal(tof)
40+
{
41+
for (int i = 0; i < 3; i++) {
42+
expTimes[i] = expt[i];
43+
expSigma[i] = expsigma[i];
44+
}
45+
}
46+
float tofSignal() const { return mSignal; }
47+
float tofExpTimePi() const { return expTimes[0]; }
48+
float tofExpTimeKa() const { return expTimes[1]; }
49+
float tofExpTimePr() const { return expTimes[2]; }
50+
float tofExpSigmaPi() const { return expSigma[0]; }
51+
float tofExpSigmaKa() const { return expSigma[1]; }
52+
float tofExpSigmaPr() const { return expSigma[2]; }
53+
float mSignal = 0.f;
54+
float expTimes[3] = {0.f, 0.f, 0.f};
55+
float expSigma[3] = {999.f, 999.f, 999.f};
56+
};
57+
58+
struct eventTimeTrackTest : eventTimeTrack {
59+
float tofChi2() const { return mTOFChi2; }
60+
float pt() const { return mPt; }
61+
float p() const { return mP; }
62+
float length() const { return mLength; }
63+
int masshypo() const { return mHypo; }
64+
float mTOFChi2 = -1.f;
65+
float mPt = 0.f;
66+
float mP = 0.f;
67+
float mLength = 0.f;
68+
int mHypo = 0;
2869
};
2970

30-
template <typename trackContainer>
31-
eventTimeContainer evTimeMaker(const trackContainer& tracks)
71+
void generateEvTimeTracks(std::vector<eventTimeTrackTest>& tracks, int ntracks, float evTime = 0.f);
72+
73+
template <typename trackType>
74+
bool filterDummy(const trackType& tr)
3275
{
76+
return (tr.tofChi2() >= 0 && tr.mP < 2.0);
77+
} // accept all
78+
79+
void computeEvTime(const std::vector<eventTimeTrack>& tracks, const std::vector<int>& trkIndex, eventTimeContainer& evtime);
80+
int getStartTimeInSet(const std::vector<eventTimeTrack>& tracks, std::vector<int>& trackInSet, unsigned long& bestComb);
81+
82+
template <typename trackTypeContainer, typename trackType, bool (*trackFilter)(const trackType&)>
83+
eventTimeContainer evTimeMaker(const trackTypeContainer& tracks, float diamond = 6. /* spread of primary verdex in cm */)
84+
{
85+
static std::vector<eventTimeTrack> trkWork;
86+
trkWork.clear();
87+
static std::vector<int> trkIndex; // indexes of working tracks in the track original array
88+
trkIndex.clear();
89+
90+
static float expt[3], expsigma[3];
91+
92+
static eventTimeContainer result = {0, 0};
93+
94+
// reset info
95+
float sigmaFill = diamond * 33.356409; // move from diamond (cm) to spread on event time (ps)
96+
result.weights.clear();
97+
result.tracktime.clear();
98+
result.eventTime = 0.;
99+
result.eventTimeError = sigmaFill;
100+
result.sumweights = 0.;
101+
102+
// Qui facciamo un pool di tracce buone per calcolare il T0
33103
for (auto track : tracks) {
34-
track.tofSignal();
104+
if (trackFilter(track)) {
105+
expt[0] = track.tofExpTimePi(), expt[1] = track.tofExpTimeKa(), expt[2] = track.tofExpTimePr();
106+
expsigma[0] = track.tofExpSigmaPi(), expsigma[1] = track.tofExpSigmaKa(), expsigma[2] = track.tofExpSigmaPr();
107+
trkWork.emplace_back(track.tofSignal(), expt, expsigma);
108+
trkIndex.push_back(result.weights.size());
109+
}
110+
result.weights.push_back(0.);
111+
result.tracktime.push_back(0.);
35112
}
36-
return eventTimeContainer{0.f, 0.f};
113+
computeEvTime(trkWork, trkIndex, result);
114+
return result;
37115
}
38116

39117
} // namespace tof
40118
} // namespace o2
41119

42-
#endif /* ALICEO2_TOF_EVENTTIMEMAKER_H */
120+
#endif /* ALICEO2_TOF_EVENTTIMEMAKER_H */

0 commit comments

Comments
 (0)