Skip to content

Commit 880e450

Browse files
committed
Extend TOF Event Time maker for analysis
- Add authors - Add track multiplicity used for the TOF event time estimation Align AOD maker behaviour for trackTime - Update trackTime - Fix call to exp times Expand log axis in HistogramRegistry
1 parent b8c109d commit 880e450

6 files changed

Lines changed: 139 additions & 52 deletions

File tree

Detectors/AOD/src/AODProducerWorkflowSpec.cxx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,11 @@ void AODProducerWorkflowDPL::fillTrackTablesPerCollision(int collisionID,
327327
}
328328
const auto& tofCl = tofClus[contributorsGID[GIndex::Source::TOF]];
329329
// correct the time of the track
330-
extraInfoHolder.trackTime = (tofCl.getTime() - tofInt.getTOF(trackPar.getPID())) * 1e-3; // tof time in \mus, FIXME: account for time of flight to R TOF
331-
extraInfoHolder.trackTimeRes = 200e-3; // FIXME: calculate actual resolution (if possible?)
330+
const float massZ = o2::track::PID::getMass2Z(trackPar.getPID());
331+
const float energy = sqrt((massZ * massZ) + (extraInfoHolder.tofExpMom * extraInfoHolder.tofExpMom));
332+
const float exp = extraInfoHolder.length * energy / (cSpeed * extraInfoHolder.tofExpMom);
333+
extraInfoHolder.trackTime = (tofCl.getTime() - exp) * 1e-3; // tof time in \mus, FIXME: account for time of flight to R TOF
334+
extraInfoHolder.trackTimeRes = 200e-3; // FIXME: calculate actual resolution (if possible?)
332335
}
333336
if (src == GIndex::Source::TPCTRD || src == GIndex::Source::ITSTPCTRD) {
334337
const auto& trdOrig = data.getTrack<o2::trd::TrackTRD>(src, contributorsGID[src].getIndex());

Detectors/GlobalTrackingWorkflow/src/TOFEventTimeChecker.cxx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ using GID = o2::dataformats::GlobalTrackID;
6464

6565
struct MyTrack : o2::tof::eventTimeTrackTest {
6666
double tofSignalDouble() const { return mSignalDouble; }
67-
float tofExpTimeDe() const { return mExpDe; }
67+
float tofExpSignalDe() const { return mExpDe; }
6868
double mSignalDouble = 0.0;
6969
float mEta = 0.0;
7070
float mPhi = 0.0;
@@ -216,10 +216,10 @@ void TOFEventTimeChecker::processEvent(std::vector<MyTrack>& tracks)
216216
mChi2 = track.mChi2;
217217
mL = track.mLength;
218218
mTof = track.tofSignal();
219-
mExpDe = track.tofExpTimeDe();
220-
mExpPi = track.tofExpTimePi();
221-
mExpKa = track.tofExpTimeKa();
222-
mExpPr = track.tofExpTimePr();
219+
mExpDe = track.tofExpSignalDe();
220+
mExpPi = track.tofExpSignalPi();
221+
mExpKa = track.tofExpSignalKa();
222+
mExpPr = track.tofExpSignalPr();
223223
mIsProb = track.mIsProb;
224224
mTrktime = track.mTrktime;
225225
mTrktimeRes = track.mTrktimeRes;

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

Lines changed: 82 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,20 @@
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
1111

12-
/// \file EventTimeMaker.h
13-
/// \brief Definition of the TOF event time maker
12+
/// \file EventTimeMaker.h
13+
/// \author Francesca Ercolessi francesca.ercolessi@cern.ch
14+
/// \author Francesco Noferini francesco.noferini@cern.ch
15+
/// \author Nicolò Jacazio nicolo.jacazio@cern.ch
16+
/// \brief Definition of the TOF event time maker
1417

1518
#ifndef ALICEO2_TOF_EVENTTIMEMAKER_H
1619
#define ALICEO2_TOF_EVENTTIMEMAKER_H
1720

1821
#include "TRandom.h"
1922
#include "TMath.h"
2023
#include "TOFBase/Utils.h"
24+
#include "ReconstructionDataFormats/PID.h"
25+
#include "Framework/Logger.h"
2126

2227
namespace o2
2328
{
@@ -27,12 +32,17 @@ namespace tof
2732

2833
struct eventTimeContainer {
2934
eventTimeContainer(const float& e, const float& err) : eventTime{e}, eventTimeError{err} {};
30-
float eventTime = 0.f;
31-
float eventTimeError = 0.f;
32-
33-
float sumweights = 0.f; // sum of weights of all track contributors
34-
std::vector<float> weights; // weights (1/sigma^2) associated to a track in event time computation, 0 if track not used
35-
std::vector<float> tracktime; // eventtime provided by a single track
35+
float eventTime = 0.f; /// Value of the event time
36+
float eventTimeError = 0.f; /// Uncertainty on the computed event time
37+
unsigned short eventTimeMultiplicity = 0.f; /// Track multiplicity used to compute the event time
38+
39+
float sumweights = 0.f; /// sum of weights of all track contributors
40+
std::vector<float> weights; /// weights (1/sigma^2) associated to a track in event time computation, 0 if track not used
41+
std::vector<float> tracktime; /// eventtime provided by a single track
42+
void print()
43+
{
44+
LOG(info) << "eventTimeContainer " << eventTime << " +- " << eventTimeError << " sum of weights " << sumweights << " tracks used " << eventTimeMultiplicity;
45+
}
3646
};
3747

3848
struct eventTimeTrack {
@@ -45,9 +55,9 @@ struct eventTimeTrack {
4555
}
4656
}
4757
float tofSignal() const { return mSignal; }
48-
float tofExpTimePi() const { return expTimes[0]; }
49-
float tofExpTimeKa() const { return expTimes[1]; }
50-
float tofExpTimePr() const { return expTimes[2]; }
58+
float tofExpSignalPi() const { return expTimes[0]; }
59+
float tofExpSignalKa() const { return expTimes[1]; }
60+
float tofExpSignalPr() const { return expTimes[2]; }
5161
float tofExpSigmaPi() const { return expSigma[0]; }
5262
float tofExpSigmaKa() const { return expSigma[1]; }
5363
float tofExpSigmaPr() const { return expSigma[2]; }
@@ -74,14 +84,17 @@ void generateEvTimeTracks(std::vector<eventTimeTrackTest>& tracks, int ntracks,
7484
template <typename trackType>
7585
bool filterDummy(const trackType& tr)
7686
{
77-
return (tr.tofChi2() >= 0 && tr.mP < 2.0);
87+
return (tr.tofChi2() >= 0 && tr.p() < 2.0);
7888
} // accept all
7989

8090
void computeEvTime(const std::vector<eventTimeTrack>& tracks, const std::vector<int>& trkIndex, eventTimeContainer& evtime);
8191
int getStartTimeInSet(const std::vector<eventTimeTrack>& tracks, std::vector<int>& trackInSet, unsigned long& bestComb);
8292

83-
template <typename trackTypeContainer, typename trackType, bool (*trackFilter)(const trackType&)>
84-
eventTimeContainer evTimeMaker(const trackTypeContainer& tracks, float diamond = Utils::mEventTimeSpread * 0.029979246 /* spread of primary verdex in cm */)
93+
template <typename trackTypeContainer,
94+
typename trackType,
95+
bool (*trackFilter)(const trackType&)>
96+
eventTimeContainer evTimeMaker(const trackTypeContainer& tracks,
97+
float diamond = Utils::mEventTimeSpread * 0.029979246 /* spread of primary verdex in cm */)
8598
{
8699
static std::vector<eventTimeTrack> trkWork;
87100
trkWork.clear();
@@ -100,11 +113,14 @@ eventTimeContainer evTimeMaker(const trackTypeContainer& tracks, float diamond =
100113
result.eventTimeError = sigmaFill;
101114
result.sumweights = 0.;
102115

103-
// Qui facciamo un pool di tracce buone per calcolare il T0
104-
for (auto track : tracks) {
105-
if (trackFilter(track)) {
106-
expt[0] = track.tofExpTimePi(), expt[1] = track.tofExpTimeKa(), expt[2] = track.tofExpTimePr();
107-
expsigma[0] = track.tofExpSigmaPi(), expsigma[1] = track.tofExpSigmaKa(), expsigma[2] = track.tofExpSigmaPr();
116+
for (auto track : tracks) { // Loop on tracks
117+
if (trackFilter(track)) { // Select tracks good for T0 computation
118+
expt[0] = track.tofExpSignalPi();
119+
expt[1] = track.tofExpSignalKa();
120+
expt[2] = track.tofExpSignalPr();
121+
expsigma[0] = track.tofExpSigmaPi();
122+
expsigma[1] = track.tofExpSigmaKa();
123+
expsigma[2] = track.tofExpSigmaPr();
108124
trkWork.emplace_back(track.tofSignal(), expt, expsigma);
109125
trkIndex.push_back(result.weights.size());
110126
}
@@ -115,6 +131,53 @@ eventTimeContainer evTimeMaker(const trackTypeContainer& tracks, float diamond =
115131
return result;
116132
}
117133

134+
template <typename trackTypeContainer,
135+
typename trackType,
136+
bool (*trackFilter)(const trackType&),
137+
template <typename T, o2::track::PID::ID> typename response,
138+
typename responseParametersType>
139+
eventTimeContainer evTimeMakerFromParam(const trackTypeContainer& tracks,
140+
const responseParametersType& responseParameters,
141+
float diamond = Utils::mEventTimeSpread * 0.029979246 /* spread of primary verdex in cm */)
142+
{
143+
static std::vector<eventTimeTrack> trkWork;
144+
trkWork.clear();
145+
static std::vector<int> trkIndex; // indexes of working tracks in the track original array
146+
trkIndex.clear();
147+
148+
constexpr auto responsePi = response<trackType, o2::track::PID::Pion>();
149+
constexpr auto responseKa = response<trackType, o2::track::PID::Kaon>();
150+
constexpr auto responsePr = response<trackType, o2::track::PID::Proton>();
151+
152+
static float expt[3], expsigma[3];
153+
154+
static eventTimeContainer result = {0, 0};
155+
156+
// reset info
157+
float sigmaFill = diamond * 33.356409; // move from diamond (cm) to spread on event time (ps)
158+
result.weights.clear();
159+
result.tracktime.clear();
160+
result.eventTime = 0.;
161+
result.eventTimeError = sigmaFill;
162+
result.sumweights = 0.;
163+
164+
for (auto track : tracks) { // Loop on tracks
165+
if (trackFilter(track)) { // Select tracks good for T0 computation
166+
expt[0] = responsePi.GetExpectedSignal(track);
167+
expt[1] = responseKa.GetExpectedSignal(track);
168+
expt[2] = responsePr.GetExpectedSignal(track);
169+
expsigma[0] = responsePi.GetExpectedSigmaTracking(responseParameters, track);
170+
expsigma[1] = responseKa.GetExpectedSigmaTracking(responseParameters, track);
171+
expsigma[2] = responsePr.GetExpectedSigmaTracking(responseParameters, track);
172+
trkWork.emplace_back(track.tofSignal(), expt, expsigma);
173+
trkIndex.push_back(result.weights.size());
174+
}
175+
result.weights.push_back(0.);
176+
result.tracktime.push_back(0.);
177+
}
178+
computeEvTime(trkWork, trkIndex, result);
179+
return result;
180+
}
118181
} // namespace tof
119182
} // namespace o2
120183

Detectors/TOF/reconstruction/src/EventTimeMaker.cxx

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,16 @@
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
1111

12-
/// \file EventTimeMaker.cxx
13-
/// \brief Implementation of the TOF event time maker
14-
12+
///
13+
/// \file EventTimeMaker.cxx
14+
/// \author Francesca Ercolessi francesca.ercolessi@cern.ch
15+
/// \author Francesco Noferini francesco.noferini@cern.ch
16+
/// \author Nicolò Jacazio nicolo.jacazio@cern.ch
17+
/// \brief Implementation of the TOF event time maker
18+
///
19+
20+
#include "TRandom.h"
21+
#include "TMath.h"
1522
#include "TOFReconstruction/EventTimeMaker.h"
1623

1724
namespace o2
@@ -27,11 +34,14 @@ constexpr unsigned long combinatorial[MAXNTRACKINSET + 1] = {1, 3, 9, 27, 81, 24
2734

2835
void computeEvTime(const std::vector<eventTimeTrack>& tracks, const std::vector<int>& trkIndex, eventTimeContainer& evtime)
2936
{
30-
const int maxNumberOfSets = 200;
37+
static constexpr int maxNumberOfSets = 200;
38+
static constexpr float weightLimit = 1E-6; // Limit in the weights
3139

32-
int ntracks = tracks.size();
40+
const int ntracks = tracks.size();
41+
LOG(debug) << "For the collision time using " << ntracks;
3342

3443
if (ntracks < 2) { // at least 2 tracks required
44+
LOG(debug) << "Skipping event because at least 2 tracks are required";
3545
return;
3646
}
3747

@@ -40,7 +50,7 @@ void computeEvTime(const std::vector<eventTimeTrack>& tracks, const std::vector<
4050
int nmaxtracksinset = ntracks > 22 ? 6 : MAXNTRACKINSET; // max number of tracks in a set for event time computation
4151
int ntracksinset = std::min(ntracks, nmaxtracksinset);
4252

43-
Int_t nset = ((ntracks - 1) / ntracksinset) + 1;
53+
int nset = ((ntracks - 1) / ntracksinset) + 1;
4454
int ntrackUsed = ntracks;
4555

4656
if (nset > maxNumberOfSets) {
@@ -73,6 +83,9 @@ void computeEvTime(const std::vector<eventTimeTrack>& tracks, const std::vector<
7383

7484
int index = trkIndex[trackInSet[iset][itrk]];
7585
const eventTimeTrack& ctrack = tracks[trackInSet[iset][itrk]];
86+
LOG(debug) << "Using hypothesis: " << hypo[itrk] << " tofSignal: " << ctrack.mSignal << " exp. time: " << ctrack.expTimes[hypo[itrk]] << " exp. sigma: " << ctrack.expSigma[hypo[itrk]];
87+
LOG(debug) << "0= " << ctrack.expTimes[0] << " +- " << ctrack.expSigma[0] << " 1= " << ctrack.expTimes[1] << " +- " << ctrack.expSigma[1] << " 2= " << ctrack.expTimes[2] << " +- " << ctrack.expSigma[2];
88+
7689
evtime.weights[index] = 1. / (ctrack.expSigma[hypo[itrk]] * ctrack.expSigma[hypo[itrk]]);
7790
evtime.tracktime[index] = ctrack.mSignal - ctrack.expTimes[hypo[itrk]];
7891
}
@@ -82,19 +95,21 @@ void computeEvTime(const std::vector<eventTimeTrack>& tracks, const std::vector<
8295
// do average among all tracks
8396
float finalTime = 0, allweights = 0;
8497
for (int i = 0; i < evtime.weights.size(); i++) {
85-
if (evtime.weights[i] < 1E-6) {
98+
if (evtime.weights[i] < weightLimit) {
8699
continue;
87100
}
88101
allweights += evtime.weights[i];
89102
finalTime += evtime.tracktime[i] * evtime.weights[i];
90103
}
91104

92-
if (allweights < 1E-6) {
105+
if (allweights < weightLimit) {
106+
LOG(info) << "Skipping because allweights " << allweights << " are lower than " << weightLimit;
93107
return;
94108
}
95109

96110
evtime.eventTime = finalTime / allweights;
97111
evtime.eventTimeError = sqrt(1. / allweights);
112+
evtime.eventTimeMultiplicity = ntracks;
98113
}
99114

100115
int getStartTimeInSet(const std::vector<eventTimeTrack>& tracks, std::vector<int>& trackInSet, unsigned long& bestComb)

Framework/Core/include/Framework/HistogramSpec.h

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -117,24 +117,7 @@ struct AxisSpec {
117117
}
118118

119119
/// Function to make the axis logartitmic
120-
void makeLogaritmic()
121-
{
122-
if (binEdges.size() > 2) {
123-
LOG(FATAL) << "Cannot make a variabled bin width axis logaritmic";
124-
}
125-
126-
const double min = binEdges[0];
127-
const double max = binEdges[1];
128-
const double logmin = std::log10(min);
129-
const double logmax = std::log10(max);
130-
const int nbins = nBins.value();
131-
const double logdelta = (logmax - logmin) / (static_cast<double>(nbins));
132-
const double log10 = std::log10(10.);
133-
for (int i = 0; i < nbins + 1; i++) {
134-
binEdges.push_back(std::exp(log10 * (logmin + i * logdelta)));
135-
}
136-
nBins = std::nullopt;
137-
}
120+
void makeLogaritmic();
138121

139122
/// Data members
140123
std::optional<int> nBins{}; /// Number of bins (only used for fixed bin width axis)

Framework/Core/src/HistogramSpec.cxx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,29 @@
1515
namespace o2::framework
1616
{
1717

18+
void AxisSpec::makeLogaritmic()
19+
{
20+
if (binEdges.size() > 2) {
21+
LOG(FATAL) << "Cannot make a variabled bin width axis logaritmic";
22+
}
23+
24+
const double min = binEdges[0];
25+
const double max = binEdges[1];
26+
binEdges.clear();
27+
const double logmin = std::log10(min);
28+
const double logmax = std::log10(max);
29+
const int nbins = nBins.value();
30+
const double logdelta = (logmax - logmin) / (static_cast<double>(nbins));
31+
const double log10 = std::log10(10.);
32+
LOG(debug) << "Making a logaritmic binning from " << min << " to " << max << " with " << nbins << " bins";
33+
for (int i = 0; i < nbins + 1; i++) {
34+
const auto nextEdge = std::pow(10, logmin + i * logdelta);
35+
LOG(debug) << i << "/" << nbins - 1 << ": " << nextEdge;
36+
binEdges.push_back(nextEdge);
37+
}
38+
nBins = std::nullopt;
39+
}
40+
1841
// main function for creating arbirtary histograms
1942
template <typename T>
2043
std::unique_ptr<T> HistFactory::createHist(const HistogramSpec& histSpec)

0 commit comments

Comments
 (0)