@@ -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