Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please consider the following formatting changes to #5013 #14

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 40 additions & 32 deletions PWGUD/Core/SGSelector.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,41 +19,49 @@
#include "PWGUD/Core/UDHelpers.h"
#include "PWGUD/Core/SGCutParHolder.h"

class SGSelector {
public:
SGSelector() : fPDG(TDatabasePDG::Instance()) {}

template <typename CC, typename BCs, typename TCs, typename FWs>
int Print(SGCutParHolder diffCuts, CC& collision, BCs& bcRange, TCs& tracks, FWs& fwdtracks) {
LOGF(info, "Size of array %i", collision.size());
return 1;
}
class SGSelector
{
public:
SGSelector() : fPDG(TDatabasePDG::Instance()) {}

template <typename CC, typename BCs>
int IsSelected(SGCutParHolder diffCuts, CC& collision, BCs& bcRange) {
LOGF(debug, "Collision %f", collision.collisionTime());
LOGF(debug, "Number of close BCs: %i", bcRange.size());

bool gA = true, gC = true;
for (auto const& bc : bcRange) {
if (!udhelpers::cleanFITA(bc, diffCuts.maxFITtime(), diffCuts.FITAmpLimits())) gA = false;
if (!udhelpers::cleanFITC(bc, diffCuts.maxFITtime(), diffCuts.FITAmpLimits())) gC = false;
}
if (!gA && !gC) return 3;
if (collision.numContrib() < diffCuts.minNTracks() || collision.numContrib() > diffCuts.maxNTracks()) {
return 4;
}
return gA && gC ? 2 : (gA ? 0 : 1);
}
template <typename TFwdTrack>
int FwdTrkSelector(TFwdTrack const& fwdtrack) {
if (fwdtrack.trackType() == 0 || fwdtrack.trackType() == 3) return 1;
else return 0;
template <typename CC, typename BCs, typename TCs, typename FWs>
int Print(SGCutParHolder diffCuts, CC& collision, BCs& bcRange, TCs& tracks, FWs& fwdtracks)
{
LOGF(info, "Size of array %i", collision.size());
return 1;
}

template <typename CC, typename BCs>
int IsSelected(SGCutParHolder diffCuts, CC& collision, BCs& bcRange)
{
LOGF(debug, "Collision %f", collision.collisionTime());
LOGF(debug, "Number of close BCs: %i", bcRange.size());

bool gA = true, gC = true;
for (auto const& bc : bcRange) {
if (!udhelpers::cleanFITA(bc, diffCuts.maxFITtime(), diffCuts.FITAmpLimits()))
gA = false;
if (!udhelpers::cleanFITC(bc, diffCuts.maxFITtime(), diffCuts.FITAmpLimits()))
gC = false;
}
if (!gA && !gC)
return 3;
if (collision.numContrib() < diffCuts.minNTracks() || collision.numContrib() > diffCuts.maxNTracks()) {
return 4;
}
return gA && gC ? 2 : (gA ? 0 : 1);
}
template <typename TFwdTrack>
int FwdTrkSelector(TFwdTrack const& fwdtrack)
{
if (fwdtrack.trackType() == 0 || fwdtrack.trackType() == 3)
return 1;
else
return 0;
}

private:
TDatabasePDG* fPDG;
private:
TDatabasePDG* fPDG;
};

#endif // PWGUD_CORE_SGSELECTOR_H_

40 changes: 21 additions & 19 deletions PWGUD/TableProducer/SGCandProducer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -151,23 +151,24 @@ struct SGCandProducer {
auto bc = collision.foundBC_as<BCs>();

// obtain slice of compatible BCs
auto bcRange = udhelpers::compatibleBCs(collision, sameCuts.NDtcoll(), bcs, sameCuts.minNBCs());
auto isSGEvent = sgSelector.IsSelected(sameCuts, collision, bcRange);
//auto isSGEvent = sgSelector.IsSelected(sameCuts, collision, bcRange, tracks);
auto bcRange = udhelpers::compatibleBCs(collision, sameCuts.NDtcoll(), bcs, sameCuts.minNBCs());
auto isSGEvent = sgSelector.IsSelected(sameCuts, collision, bcRange);
// auto isSGEvent = sgSelector.IsSelected(sameCuts, collision, bcRange, tracks);
registry.get<TH1>(HIST("reco/Stat"))->Fill(0., 1.);
registry.get<TH1>(HIST("reco/Stat"))->Fill(isSGEvent + 1, 1.);
if (isSGEvent <= 2) {
// if (isSGEvent < 2) LOGF(info, "Current BC: %i, %i", bc.globalBC(), isSGEvent);
if (sameCuts.minRgtrwTOF()){
if (udhelpers::rPVtrwTOF<true>(tracks, collision.numContrib()) < sameCuts.minRgtrwTOF()) return;
// if (isSGEvent < 2) LOGF(info, "Current BC: %i, %i", bc.globalBC(), isSGEvent);
if (sameCuts.minRgtrwTOF()) {
if (udhelpers::rPVtrwTOF<true>(tracks, collision.numContrib()) < sameCuts.minRgtrwTOF())
return;
}
upchelpers::FITInfo fitInfo{};
udhelpers::getFITinfo(fitInfo, bc.globalBC(), bcs, ft0s, fv0as, fdds);
// update SG candidates tables
outputCollisions(bc.globalBC(), bc.runNumber(),
collision.posX(), collision.posY(), collision.posZ(),
collision.numContrib(), udhelpers::netCharge<true>(tracks),
1.);//rtrwTOF); //omit the calculation to speed up the things while skimming
1.); // rtrwTOF); //omit the calculation to speed up the things while skimming
outputSGCollisions(isSGEvent);
outputCollisionsSels(fitInfo.ampFT0A, fitInfo.ampFT0C, fitInfo.timeFT0A, fitInfo.timeFT0C,
fitInfo.triggerMaskFT0,
Expand All @@ -179,23 +180,24 @@ struct SGCandProducer {
fitInfo.BBFDDApf, fitInfo.BBFDDCpf, fitInfo.BGFDDApf, fitInfo.BGFDDCpf);
outputCollsLabels(collision.globalIndex());
if (bc.has_zdc()) {
auto zdc = bc.zdc();
udZdcsReduced(outputCollisions.lastIndex(), zdc.timeZNA(), zdc.timeZNC(), zdc.energyCommonZNA(), zdc.energyCommonZNC());
}
else{
udZdcsReduced(outputCollisions.lastIndex(), -999, -999, -999, -999);
auto zdc = bc.zdc();
udZdcsReduced(outputCollisions.lastIndex(), zdc.timeZNA(), zdc.timeZNC(), zdc.energyCommonZNA(), zdc.energyCommonZNC());
} else {
udZdcsReduced(outputCollisions.lastIndex(), -999, -999, -999, -999);
}
// update SGTracks tables
for (auto& track : tracks) {
if (track.isPVContributor() && track.eta() > sameCuts.minEta() && track.eta() < sameCuts.maxEta()) updateUDTrackTables(outputCollisions.lastIndex(), track, bc.globalBC());
//if (track.isPVContributor()) updateUDTrackTables(outputCollisions.lastIndex(), track, bc.globalBC());
if (track.isPVContributor() && track.eta() > sameCuts.minEta() && track.eta() < sameCuts.maxEta())
updateUDTrackTables(outputCollisions.lastIndex(), track, bc.globalBC());
// if (track.isPVContributor()) updateUDTrackTables(outputCollisions.lastIndex(), track, bc.globalBC());
}

// update SGFwdTracks tables
if (sameCuts.withFwdTracks()){
for (auto& fwdtrack : fwdtracks) {
if (!sgSelector.FwdTrkSelector(fwdtrack)) updateUDFwdTrackTables(fwdtrack, bc.globalBC());
}
if (sameCuts.withFwdTracks()) {
for (auto& fwdtrack : fwdtracks) {
if (!sgSelector.FwdTrkSelector(fwdtrack))
updateUDFwdTrackTables(fwdtrack, bc.globalBC());
}
}
}
}
Expand Down
Loading