Skip to content

Commit 9db3415

Browse files
committed
Improve handling of event times
1 parent 35e4a8a commit 9db3415

File tree

3 files changed

+73
-18
lines changed

3 files changed

+73
-18
lines changed

PWGLF/DataModel/LFStrangenessTables.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ DECLARE_SOA_DYNAMIC_COLUMN(EnergyCommonZNA, energyCommonZNA, //! get the total s
6363
[](float value) -> float { return value; });
6464
DECLARE_SOA_DYNAMIC_COLUMN(EnergyCommonZNC, energyCommonZNC, //! get the total sum of the ZN A amplitudes
6565
[](float value) -> float { return value; });
66+
67+
// event time
68+
DECLARE_SOA_COLUMN(EventTime, eventTime, float); //! event time (FT0, TOF) for TOF PID (stored once per event)
6669
} // namespace stracollision
6770

6871
//______________________________________________________
@@ -308,6 +311,8 @@ DECLARE_SOA_TABLE(StraStamps_000, "AOD", "STRASTAMPS", //! information for ID-in
308311
bc::RunNumber, timestamp::Timestamp);
309312
DECLARE_SOA_TABLE_VERSIONED(StraStamps_001, "AOD", "STRASTAMPS", 1, //! information for ID-ing mag field if needed
310313
bc::RunNumber, timestamp::Timestamp, bc::GlobalBC);
314+
DECLARE_SOA_TABLE(StraEvTimes, "AOD", "STRAEVTIMES", //! event time (FT0, TOF)
315+
stracollision::EventTime);
311316

312317
using StraRawCents = StraRawCents_004;
313318
using StraCents = StraCents_001;

PWGLF/TableProducer/Strangeness/strangederivedbuilder.cxx

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ struct strangederivedbuilder {
8484
Produces<aod::StraEvSels> strangeEvSels; // characterises collisions / centrality / sel8 selection in Run 3
8585
Produces<aod::StraEvSelsRun2> strangeEvSelsRun2; // characterises collisions / centrality / sel8 selection in Run 2
8686
Produces<aod::StraStamps> strangeStamps; // provides timestamps, run numbers
87+
Produces<aod::StraEvTimes> straEvTimes; // provides event times (FT0, TOF)
8788
Produces<aod::V0CollRefs> v0collref; // references collisions from V0s
8889
Produces<aod::CascCollRefs> casccollref; // references collisions from cascades
8990
Produces<aod::KFCascCollRefs> kfcasccollref; // references collisions from KF cascades
@@ -583,6 +584,28 @@ struct strangederivedbuilder {
583584
}
584585
}
585586

587+
// helper function to estimate collision time
588+
template <typename coll, typename TTracks>
589+
void populateEventTimes(coll const& collisions, TTracks const& tracks)
590+
{
591+
std::vector<double> collisionEventTime(collisions.size(), 0.0);
592+
std::vector<int> collisionNtracks(collisions.size(), 0);
593+
for (const auto& track : tracks) {
594+
if(track.hasTOF() && track.collisionId()>=0){
595+
collisionEventTime[track.collisionId()] += track.tofEvTime();
596+
collisionNtracks[track.collisionId()] ++;
597+
}
598+
}
599+
for (const auto& collision : collisions){
600+
if(collisionNtracks[collision.globalIndex()] > 0){
601+
collisionEventTime[collision.globalIndex()] /= static_cast<double>(collisionNtracks[collision.globalIndex()]);
602+
}else{
603+
collisionEventTime[collision.globalIndex()] = -1e+6; // undefined
604+
}
605+
products.straEvTimes(collisionEventTime[collision.globalIndex()]);
606+
}
607+
}
608+
586609
// master function to process a collision
587610
template <typename mccoll, typename mcparts>
588611
void populateMCCollisionTable(mccoll const& mcCollisions, mcparts const& mcParticlesEntireTable)
@@ -820,6 +843,11 @@ struct strangederivedbuilder {
820843
// done!
821844
}
822845

846+
void processPopulateEventTimes(aod::Collisions const& collisions, soa::Join<aod::Tracks, aod::TracksExtra, aod::TOFEvTime, aod::TOFSignal> const& tracks)
847+
{
848+
populateEventTimes(collisions, tracks);
849+
}
850+
823851
void processTrackExtras(aod::V0Datas const& V0s, aod::CascDatas const& Cascades, aod::KFCascDatas const& KFCascades, aod::TraCascDatas const& TraCascades, soa::Join<aod::Tracks, aod::TracksExtra, aod::pidTPCFullEl, aod::pidTPCFullPi, aod::pidTPCFullKa, aod::pidTPCFullPr, aod::pidTPCFullHe, aod::TOFEvTime, aod::TOFSignal> const& tracksExtra, aod::V0s const&)
824852
{
825853
fillTrackExtras(V0s, Cascades, KFCascades, TraCascades, tracksExtra);
@@ -1107,7 +1135,9 @@ struct strangederivedbuilder {
11071135
// Run 2: collision processing
11081136
PROCESS_SWITCH(strangederivedbuilder, processCollisionsRun2, "Produce collisions (Run2)", false);
11091137
PROCESS_SWITCH(strangederivedbuilder, processCollisionsRun2WithMC, "Produce collisions (Run 2) with MC info", false);
1110-
1138+
// Event times
1139+
PROCESS_SWITCH(strangederivedbuilder, processPopulateEventTimes, "Populate event times", true);
1140+
11111141
// detailed information processing
11121142
PROCESS_SWITCH(strangederivedbuilder, processTrackExtrasV0sOnly, "Produce track extra information (V0s only)", true);
11131143
PROCESS_SWITCH(strangederivedbuilder, processTrackExtras, "Produce track extra information (V0s + casc)", true);

PWGLF/TableProducer/Strangeness/strangenesstofpid.cxx

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ struct strangenesstofpid {
10411041
return casctof;
10421042
}
10431043

1044-
void processStandardData(aod::Collisions const& collisions, V0OriginalDatas const& V0s, CascOriginalDatas const& cascades, TracksWithAllExtras const&, aod::BCsWithTimestamps const& /*bcs*/)
1044+
void processStandardData(aod::Collisions const& collisions, V0OriginalDatas const& V0s, CascOriginalDatas const& cascades, TracksWithAllExtras const& tracks, aod::BCsWithTimestamps const& /*bcs*/)
10451045
{
10461046
// Fire up CCDB with first collision in record. If no collisions, bypass
10471047
if (useCustomRunNumber || collisions.size() < 1) {
@@ -1052,6 +1052,24 @@ struct strangenesstofpid {
10521052
initCCDB(bc.runNumber());
10531053
}
10541054

1055+
//________________________________________________________________________
1056+
// estimate event times (only necessary for original data)
1057+
std::vector<double> collisionEventTime(collisions.size(), 0.0);
1058+
std::vector<int> collisionNtracks(collisions.size(), 0);
1059+
for (const auto& track : tracks) {
1060+
if(track.hasTOF()){
1061+
collisionEventTime[track.collisionId()] += track.tofEvTime();
1062+
collisionNtracks[track.collisionId()] ++;
1063+
}
1064+
}
1065+
for (const auto& collision: collisions){
1066+
if(collisionNtracks[collision.globalIndex()] > 0){
1067+
collisionEventTime[collision.globalIndex()] /= static_cast<double>(collisionNtracks[collision.globalIndex()]);
1068+
}else{
1069+
collisionEventTime[collision.globalIndex()] = -1e+6; // undefined
1070+
}
1071+
}
1072+
10551073
if (calculateV0s.value) {
10561074
for (const auto& V0 : V0s) {
10571075
trackTofInfo pTof, nTof; // information storage
@@ -1064,7 +1082,7 @@ struct strangenesstofpid {
10641082
pTof.hasTPC = pTra.hasTPC();
10651083
pTof.hasTOF = pTra.hasTOF();
10661084
pTof.tofExpMom = pTra.tofExpMom();
1067-
pTof.tofEvTime = pTra.tofEvTime();
1085+
pTof.tofEvTime = collisionEventTime[V0.collisionId()];
10681086
pTof.tofSignal = pTra.tofSignal();
10691087
pTof.length = pTra.length();
10701088
pTof.tpcNSigmaPi = pTra.tpcNSigmaPi();
@@ -1075,7 +1093,7 @@ struct strangenesstofpid {
10751093
nTof.hasTPC = nTra.hasTPC();
10761094
nTof.hasTOF = nTra.hasTOF();
10771095
nTof.tofExpMom = nTra.tofExpMom();
1078-
nTof.tofEvTime = nTra.tofEvTime();
1096+
nTof.tofEvTime = collisionEventTime[V0.collisionId()];
10791097
nTof.tofSignal = nTra.tofSignal();
10801098
nTof.length = nTra.length();
10811099
nTof.tpcNSigmaPi = nTra.tpcNSigmaPi();
@@ -1105,7 +1123,7 @@ struct strangenesstofpid {
11051123
pTof.hasTPC = pTra.hasTPC();
11061124
pTof.hasTOF = pTra.hasTOF();
11071125
pTof.tofExpMom = pTra.tofExpMom();
1108-
pTof.tofEvTime = pTra.tofEvTime();
1126+
pTof.tofEvTime = collisionEventTime[cascade.collisionId()];
11091127
pTof.tofSignal = pTra.tofSignal();
11101128
pTof.length = pTra.length();
11111129
pTof.tpcNSigmaPi = pTra.tpcNSigmaPi();
@@ -1116,7 +1134,7 @@ struct strangenesstofpid {
11161134
nTof.hasTPC = nTra.hasTPC();
11171135
nTof.hasTOF = nTra.hasTOF();
11181136
nTof.tofExpMom = nTra.tofExpMom();
1119-
nTof.tofEvTime = nTra.tofEvTime();
1137+
nTof.tofEvTime = collisionEventTime[cascade.collisionId()];
11201138
nTof.tofSignal = nTra.tofSignal();
11211139
nTof.length = nTra.length();
11221140
nTof.tpcNSigmaPi = nTra.tpcNSigmaPi();
@@ -1127,7 +1145,7 @@ struct strangenesstofpid {
11271145
bTof.hasTPC = bTra.hasTPC();
11281146
bTof.hasTOF = bTra.hasTOF();
11291147
bTof.tofExpMom = bTra.tofExpMom();
1130-
bTof.tofEvTime = bTra.tofEvTime();
1148+
bTof.tofEvTime = collisionEventTime[cascade.collisionId()];
11311149
bTof.tofSignal = bTra.tofSignal();
11321150
bTof.length = bTra.length();
11331151
bTof.tpcNSigmaPi = bTra.tpcNSigmaPi();
@@ -1144,7 +1162,7 @@ struct strangenesstofpid {
11441162
}
11451163
}
11461164

1147-
void processDerivedData(soa::Join<aod::StraCollisions, aod::StraStamps> const& collisions, V0DerivedDatas const& V0s, CascDerivedDatas const& cascades, dauTracks const& dauTrackTable, aod::DauTrackTOFPIDs const& dauTrackTOFPIDs)
1165+
void processDerivedData(soa::Join<aod::StraCollisions, aod::StraStamps, aod::StraEvTimes> const& collisions, V0DerivedDatas const& V0s, CascDerivedDatas const& cascades, dauTracks const& dauTrackTable, aod::DauTrackTOFPIDs const& dauTrackTOFPIDs)
11481166
{
11491167
// auto-determine if current or old generation of dauTrackTOFPIDs
11501168
if (dauTrackTOFPIDs.size() == 0) {
@@ -1178,6 +1196,7 @@ struct strangenesstofpid {
11781196
for (const auto& V0 : V0s) {
11791197
trackTofInfo pTof, nTof; // information storage
11801198

1199+
auto collision = collisions.rawIteratorAt(V0.straCollisionId());
11811200
auto pTra = V0.posTrackExtra_as<dauTracks>();
11821201
auto nTra = V0.negTrackExtra_as<dauTracks>();
11831202

@@ -1186,11 +1205,11 @@ struct strangenesstofpid {
11861205
pTof.hasTOF = pTra.hasTOF();
11871206
pTof.tpcNSigmaPi = pTra.tpcNSigmaPi();
11881207
pTof.tpcNSigmaPr = pTra.tpcNSigmaPr();
1189-
if (tofIndices[V0.posTrackExtraId()] >= 0) {
1208+
if (tofIndices[V0.posTrackExtraId()] >= 0 && collision.eventTime() > -1e+5) {
11901209
auto pTofExt = dauTrackTOFPIDs.rawIteratorAt(tofIndices[V0.posTrackExtraId()]);
11911210
pTof.collisionId = pTofExt.straCollisionId();
11921211
pTof.tofExpMom = pTofExt.tofExpMom();
1193-
pTof.tofEvTime = pTofExt.tofEvTime();
1212+
pTof.tofEvTime = collision.eventTime();
11941213
pTof.tofSignal = pTofExt.tofSignal();
11951214
pTof.length = pTofExt.length();
11961215
}
@@ -1200,11 +1219,11 @@ struct strangenesstofpid {
12001219
nTof.hasTOF = nTra.hasTOF();
12011220
nTof.tpcNSigmaPi = nTra.tpcNSigmaPi();
12021221
nTof.tpcNSigmaPr = nTra.tpcNSigmaPr();
1203-
if (tofIndices[V0.negTrackExtraId()] >= 0) {
1222+
if (tofIndices[V0.negTrackExtraId()] >= 0 && collision.eventTime() > -1e+5) {
12041223
auto nTofExt = dauTrackTOFPIDs.rawIteratorAt(tofIndices[V0.negTrackExtraId()]);
12051224
nTof.collisionId = nTofExt.straCollisionId();
12061225
nTof.tofExpMom = nTofExt.tofExpMom();
1207-
nTof.tofEvTime = nTofExt.tofEvTime();
1226+
nTof.tofEvTime = collision.eventTime();
12081227
nTof.tofSignal = nTofExt.tofSignal();
12091228
nTof.length = nTofExt.length();
12101229
}
@@ -1224,6 +1243,7 @@ struct strangenesstofpid {
12241243
for (const auto& cascade : cascades) {
12251244
trackTofInfo pTof, nTof, bTof; // information storage
12261245

1246+
auto collision = collisions.rawIteratorAt(cascade.straCollisionId());
12271247
auto pTra = cascade.posTrackExtra_as<dauTracks>();
12281248
auto nTra = cascade.negTrackExtra_as<dauTracks>();
12291249
auto bTra = cascade.bachTrackExtra_as<dauTracks>();
@@ -1233,11 +1253,11 @@ struct strangenesstofpid {
12331253
pTof.hasTOF = pTra.hasTOF();
12341254
pTof.tpcNSigmaPi = pTra.tpcNSigmaPi();
12351255
pTof.tpcNSigmaPr = pTra.tpcNSigmaPr();
1236-
if (tofIndices[cascade.posTrackExtraId()] >= 0) {
1256+
if (tofIndices[cascade.posTrackExtraId()] >= 0 && collision.eventTime() > -1e+5) {
12371257
auto pTofExt = dauTrackTOFPIDs.rawIteratorAt(tofIndices[cascade.posTrackExtraId()]);
12381258
pTof.collisionId = pTofExt.straCollisionId();
12391259
pTof.tofExpMom = pTofExt.tofExpMom();
1240-
pTof.tofEvTime = pTofExt.tofEvTime();
1260+
pTof.tofEvTime = collision.eventTime();
12411261
pTof.tofSignal = pTofExt.tofSignal();
12421262
pTof.length = pTofExt.length();
12431263
}
@@ -1247,11 +1267,11 @@ struct strangenesstofpid {
12471267
nTof.hasTOF = nTra.hasTOF();
12481268
nTof.tpcNSigmaPi = nTra.tpcNSigmaPi();
12491269
nTof.tpcNSigmaPr = nTra.tpcNSigmaPr();
1250-
if (tofIndices[cascade.negTrackExtraId()] >= 0) {
1270+
if (tofIndices[cascade.negTrackExtraId()] >= 0 && collision.eventTime() > -1e+5) {
12511271
auto nTofExt = dauTrackTOFPIDs.rawIteratorAt(tofIndices[cascade.negTrackExtraId()]);
12521272
nTof.collisionId = nTofExt.straCollisionId();
12531273
nTof.tofExpMom = nTofExt.tofExpMom();
1254-
nTof.tofEvTime = nTofExt.tofEvTime();
1274+
nTof.tofEvTime = collision.eventTime();
12551275
nTof.tofSignal = nTofExt.tofSignal();
12561276
nTof.length = nTofExt.length();
12571277
}
@@ -1261,11 +1281,11 @@ struct strangenesstofpid {
12611281
bTof.hasTOF = bTra.hasTOF();
12621282
bTof.tpcNSigmaPi = bTra.tpcNSigmaPi();
12631283
bTof.tpcNSigmaKa = bTra.tpcNSigmaKa();
1264-
if (tofIndices[cascade.bachTrackExtraId()] >= 0) {
1284+
if (tofIndices[cascade.bachTrackExtraId()] >= 0 && collision.eventTime() > -1e+5) {
12651285
auto bTofExt = dauTrackTOFPIDs.rawIteratorAt(tofIndices[cascade.bachTrackExtraId()]);
12661286
bTof.collisionId = bTofExt.straCollisionId();
12671287
bTof.tofExpMom = bTofExt.tofExpMom();
1268-
bTof.tofEvTime = bTofExt.tofEvTime();
1288+
bTof.tofEvTime = collision.eventTime();
12691289
bTof.tofSignal = bTofExt.tofSignal();
12701290
bTof.length = bTofExt.length();
12711291
}

0 commit comments

Comments
 (0)