@@ -222,6 +222,7 @@ struct TableMaker {
222222 // Q-vector related tables, to be filled only if the user selects the corresponding option
223223 Produces<ReducedEventsQvectorCentr> eventQvectorCentr;
224224 Produces<ReducedEventsQvectorCentrExtra> eventQvectorCentrExtra;
225+ Produces<ReducedEventsSpherocity> eventSpherocity; // Achu-Changes
225226 } outTables;
226227
227228 OutputObj<THashList> fOutputList {" output" }; // ! the histogram manager output list
@@ -333,6 +334,16 @@ struct TableMaker {
333334 Configurable<bool > fExcludeShort {" cfgTPCExcludeShort" , true , " Exclude short term from long term occupancy (micro-seconds)" };
334335 } fConfigVariousOptions ;
335336
337+ // Spherocity configurables
338+ struct : ConfigurableGroup {
339+ Configurable<float > fConfigSpherocityPtMin {" cfgSpherocityPtMin" , 0 .15f , " Min pT for spherocity calculation" };
340+ Configurable<float > fConfigSpherocityPtMax {" cfgSpherocityPtMax" , 10 .0f , " Max pT for spherocity calculation" };
341+ Configurable<float > fConfigSpherocityEtaMin {" cfgSpherocityEtaMin" , -0 .8f , " Min eta for spherocity calculation" };
342+ Configurable<float > fConfigSpherocityEtaMax {" cfgSpherocityEtaMax" , 0 .8f , " Max eta for spherocity calculation" };
343+ Configurable<int > fConfigSpherocityMinMult {" cfgSpherocityMinMult" , 5 , " Min multiplicity for spherocity calculation" };
344+ Configurable<bool > fConfigSpherocityUsePtWeight {" cfgSpherocityUsePtWeight" , false , " Use pT weighting for spherocity" };
345+ } fConfigSpherocity ;
346+
336347 Service<o2::ccdb::BasicCCDBManager> fCCDB {};
337348 o2::ccdb::CcdbApi fCCDBApi ;
338349
@@ -1033,15 +1044,22 @@ struct TableMaker {
10331044 }
10341045 }
10351046
1036- template <uint32_t TEventFillMap, typename TEvents, typename TBCs,
1037- typename TZdcs, typename TFt0s, typename TFv0as, typename TFdds>
1047+ template <uint32_t TEventFillMap, uint32_t TTrackFillMap, typename TEvents, typename TBCs,
1048+ typename TZdcs, typename TFt0s, typename TFv0as, typename TFdds, typename TTrackAssoc, typename TTracks >
10381049 void skimCollisions (TEvents const & collisions, TBCs const & bcs, TZdcs const & /* zdcs*/ ,
1039- TFt0s const & ft0s, TFv0as const & fv0as, TFdds const & fdds)
1050+ TFt0s const & ft0s, TFv0as const & fv0as, TFdds const & fdds,
1051+ TTrackAssoc const & trackAssocs, TTracks const & tracksBarrel)
10401052 {
10411053 // Skim collisions
10421054 // NOTE: So far, collisions are filtered based on the user specified analysis cuts AND the filterPP or Zorro event filter.
10431055 // The collision-track associations which point to an event that is not selected for writing are discarded!
10441056
1057+ LOGF (info, " === skimCollisions CALLED ===" );
1058+ LOGF (info, " TEventFillMap = %u" , TEventFillMap);
1059+ LOGF (info, " TTrackFillMap = %u" , TTrackFillMap);
1060+ LOGF (info, " TTrackFillMap is zero: %s" , TTrackFillMap == 0 ? " TRUE" : " FALSE" );
1061+ LOGF (info, " Number of collisions = %d" , static_cast <int >(collisions.size ()));
1062+
10451063 VarManager::FillTimeFrame (collisions);
10461064 fCollIndexMap .clear ();
10471065 int multTPC = -1.0 ;
@@ -1222,6 +1240,78 @@ struct TableMaker {
12221240 }
12231241 (dynamic_cast <TH2D *>(fStatsList ->At (kStatsEvent )))->Fill (3.0 , static_cast <float >(o2::aod::evsel::kNsel ));
12241242
1243+ // Calculate spherocity for this collision
1244+ float spherocityValue = -1 .0f ;
1245+ float spherocityPtWeighted = -1 .0f ;
1246+
1247+ if constexpr (static_cast <bool >(TTrackFillMap)) {
1248+ // DIAGNOSTIC: Check table sizes
1249+ LOGF (info, " === skimCollisions DIAGNOSTIC ===" );
1250+ LOGF (info, " Total collisions: %d" , static_cast <int >(collisions.size ()));
1251+ LOGF (info, " Total tracksBarrel: %d" , static_cast <int >(tracksBarrel.size ()));
1252+ LOGF (info, " Total trackAssocs: %d" , static_cast <int >(trackAssocs.size ()));
1253+ LOGF (info, " ================================" );
1254+
1255+ LOGF (info, " >>> Collision %d: TTrackFillMap check PASSED" , collision.globalIndex ());
1256+
1257+ auto groupedTrackIndices = trackAssocs.sliceBy (trackIndicesPerCollision, collision.globalIndex ());
1258+ LOGF (info, " >>> Collision %d: groupedTrackIndices.size() = %d" ,
1259+ collision.globalIndex (), static_cast <int >(groupedTrackIndices.size ()));
1260+
1261+ if (static_cast <int >(groupedTrackIndices.size ()) >= fConfigSpherocity .fConfigSpherocityMinMult ) {
1262+ LOGF (info, " >>> Collision %d: PASSED multiplicity check, collecting tracks..." ,
1263+ collision.globalIndex ());
1264+
1265+ std::vector<typename std::decay_t <decltype (tracksBarrel.begin ())>> trackVec;
1266+ trackVec.reserve (groupedTrackIndices.size ());
1267+
1268+ int validTracks = 0 ;
1269+ for (auto const & assoc : groupedTrackIndices) {
1270+ if (assoc.trackId () < tracksBarrel.size ()) {
1271+ auto track = tracksBarrel.rawIteratorAt (assoc.trackId ());
1272+ trackVec.push_back (track);
1273+ validTracks++;
1274+ }
1275+ }
1276+
1277+ LOGF (info, " >>> Collision %d: Collected %d valid tracks" ,
1278+ collision.globalIndex (), validTracks);
1279+
1280+ if (validTracks >= fConfigSpherocity .fConfigSpherocityMinMult ) {
1281+ // Calculate unweighted spherocity
1282+ spherocityValue = VarManager::CalculateSpherocity (
1283+ trackVec,
1284+ fConfigSpherocity .fConfigSpherocityPtMin ,
1285+ fConfigSpherocity .fConfigSpherocityPtMax ,
1286+ fConfigSpherocity .fConfigSpherocityEtaMin ,
1287+ fConfigSpherocity .fConfigSpherocityEtaMax ,
1288+ fConfigSpherocity .fConfigSpherocityMinMult ,
1289+ false );
1290+
1291+ // Calculate pT-weighted spherocity
1292+ spherocityPtWeighted = VarManager::CalculateSpherocity (
1293+ trackVec,
1294+ fConfigSpherocity .fConfigSpherocityPtMin ,
1295+ fConfigSpherocity .fConfigSpherocityPtMax ,
1296+ fConfigSpherocity .fConfigSpherocityEtaMin ,
1297+ fConfigSpherocity .fConfigSpherocityEtaMax ,
1298+ fConfigSpherocity .fConfigSpherocityMinMult ,
1299+ true );
1300+
1301+ LOGF (info, " Event %d: Spherocity = %.3f, pT-weighted = %.3f, nTracks = %d" ,
1302+ collision.globalIndex (), spherocityValue, spherocityPtWeighted, validTracks);
1303+ }
1304+ }
1305+ }
1306+
1307+ // CRITICAL: Fill VarManager::fgValues so histograms can be filled!
1308+ VarManager::fgValues[VarManager::kSpherocity ] = spherocityValue;
1309+ VarManager::fgValues[VarManager::kSpherocityPtWeighted ] = spherocityPtWeighted;
1310+ LOGF (info, " Filled VarManager: Spherocity = %.3f, pT-weighted = %.3f" ,
1311+ VarManager::fgValues[VarManager::kSpherocity ],
1312+ VarManager::fgValues[VarManager::kSpherocityPtWeighted ]);
1313+
1314+ // fHistMan->FillHistClass("Event_AfterCuts", VarManager::fgValues);
12251315 fHistMan ->FillHistClass (" Event_AfterCuts" , dqtablemaker_helpers::varValues ());
12261316
12271317 // create the event tables
@@ -1245,9 +1335,10 @@ struct TableMaker {
12451335 centFT0M = collision.centFT0M ();
12461336 }
12471337 outTables.eventExtended (bc.globalBC (), collision.alias_raw (), collision.selection_raw (), bc.timestamp (), VarManager::fgValues[VarManager::kCentVZERO ],
1248- multTPC, multFV0A, multFV0C, multFT0A, multFT0C, multFDDA, multFDDC, multZNA, multZNC, multTracklets, multTracksPV, centFT0C, centFT0A, centFT0M);
1338+ multTPC, multFV0A, multFV0C, multFT0A, multFT0C, multFDDA, multFDDC, multZNA, multZNC, multTracklets, multTracksPV, centFT0C, centFT0A, centFT0M, spherocityValue, spherocityPtWeighted );
12491339 outTables.eventVtxCov (collision.covXX (), collision.covXY (), collision.covXZ (), collision.covYY (), collision.covYZ (), collision.covZZ (), collision.chi2 ());
12501340 outTables.eventInfo (collision.globalIndex ());
1341+ outTables.eventSpherocity (spherocityValue, spherocityPtWeighted);
12511342
12521343 if constexpr ((TEventFillMap & VarManager::ObjTypes::CollisionQvectCentr) > 0 ) {
12531344 if (fConfigQvector .fConfigQvectCalibAvailable ) {
@@ -1914,8 +2005,9 @@ struct TableMaker {
19142005 outTables.event .reserve (collisions.size ());
19152006 outTables.eventExtended .reserve (collisions.size ());
19162007 outTables.eventVtxCov .reserve (collisions.size ());
2008+ outTables.eventSpherocity .reserve (collisions.size ()); // ADD THIS LINE//Achu-Changes
19172009
1918- skimCollisions<TEventFillMap>(collisions, bcs, zdcs, ft0s, fv0as, fdds);
2010+ skimCollisions<TEventFillMap, TTrackFillMap >(collisions, bcs, zdcs, ft0s, fv0as, fdds, trackAssocs, tracksBarrel );
19192011 if (fCollIndexMap .empty ()) {
19202012 return ;
19212013 }
0 commit comments