Skip to content
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
1 change: 0 additions & 1 deletion PWGUD/Core/SGCutParHolder.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,3 @@ class SGCutParHolder
};

#endif // PWGUD_CORE_SGCUTPARHOLDER_H_

1 change: 0 additions & 1 deletion PWGUD/Core/SGCutParHolderLinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@
#pragma link C++ class SGCutParHolder + ;

#endif // PWGUD_CORE_SGCUTPARHOLDERLINKDEF_H_

166 changes: 69 additions & 97 deletions PWGUD/Core/SGSelector.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,52 +11,50 @@
// Selector for Single Gap events
class SGSelector
{
public:
public:
// constructor/destructor
SGSelector() { fPDG = TDatabasePDG::Instance(); }
~SGSelector() { delete fPDG; }

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

// Function to check if collisions pass SG filter
template <typename CC, typename BCs, typename TCs, typename FWs>
int IsSelected(SGCutParHolder diffCuts, CC &collision, BCs &bcRange, TCs &tracks, FWs &fwdtracks, bool useSideA)
int IsSelected(SGCutParHolder diffCuts, CC& collision, BCs& bcRange, TCs& tracks, FWs& fwdtracks, bool useSideA)
{
LOGF(debug, "Collision %f", collision.collisionTime());
LOGF(debug, "Number of close BCs: %i", bcRange.size());
// check that there are no FIT signals in any of the compatible BCs
// Single Gap (SG) condition
int sg = 1;
int dg = 1;
for (auto const &bc : bcRange)
{
// LOGF(info, "%i \t %i \t %i", udhelpers::cleanFITA(bc, diffCuts.maxFITtime(), diffCuts.FITAmpLimits()), udhelpers::cleanFITC(bc, diffCuts.maxFITtime(), diffCuts.FITAmpLimits()), udhelpers::cleanFIT(bc, diffCuts.maxFITtime(), diffCuts.FITAmpLimits()));
if (!udhelpers::cleanFITA(bc, diffCuts.maxFITtime(), diffCuts.FITAmpLimits()) && !udhelpers::cleanFITC(bc, diffCuts.maxFITtime(), diffCuts.FITAmpLimits())) {
// return 1; //activity on both sides
sg = 0;
}
if (!udhelpers::cleanFIT(bc, diffCuts.maxFITtime(), diffCuts.FITAmpLimits())) {
// return 1; //activity on both sides
dg = 0;
}
for (auto const& bc : bcRange) {
// LOGF(info, "%i \t %i \t %i", udhelpers::cleanFITA(bc, diffCuts.maxFITtime(), diffCuts.FITAmpLimits()), udhelpers::cleanFITC(bc, diffCuts.maxFITtime(), diffCuts.FITAmpLimits()), udhelpers::cleanFIT(bc, diffCuts.maxFITtime(), diffCuts.FITAmpLimits()));
if (!udhelpers::cleanFITA(bc, diffCuts.maxFITtime(), diffCuts.FITAmpLimits()) && !udhelpers::cleanFITC(bc, diffCuts.maxFITtime(), diffCuts.FITAmpLimits())) {
// return 1; //activity on both sides
sg = 0;
}
if (!udhelpers::cleanFIT(bc, diffCuts.maxFITtime(), diffCuts.FITAmpLimits())) {
// return 1; //activity on both sides
dg = 0;
}
}
if (sg||dg) LOGF(info, "%i\t%i",sg,dg);
if (!sg) return 1;
if (sg || dg)
LOGF(info, "%i\t%i", sg, dg);
if (!sg)
return 1;
// forward tracks
LOGF(debug, "FwdTracks %i", fwdtracks.size());
if (!diffCuts.withFwdTracks())
{
for (auto &fwdtrack : fwdtracks)
{
if (!diffCuts.withFwdTracks()) {
for (auto& fwdtrack : fwdtracks) {
LOGF(info, " %i / %f / %f / %f / %f", fwdtrack.trackType(), fwdtrack.eta(), fwdtrack.pt(), fwdtrack.p(), fwdtrack.trackTimeRes());
// only consider tracks with MID (good timing)
if (fwdtrack.trackType() == 0 || fwdtrack.trackType() == 3)
{
if (fwdtrack.trackType() == 0 || fwdtrack.trackType() == 3) {
return 2;
}
}
Expand All @@ -66,39 +64,31 @@ class SGSelector
// no vtx tracks which are not global tracks
// no PV tracks with ITS only
auto rgtrwTOF = 0.; // fraction of PV tracks with TOF hit
for (auto &track : tracks)
{
if (track.isGlobalTrack() && !track.isPVContributor())
{
for (auto& track : tracks) {
if (track.isGlobalTrack() && !track.isPVContributor()) {
return 3;
}
if (diffCuts.globalTracksOnly() && track.isPVContributor() && !track.isGlobalTrack())
{
if (diffCuts.globalTracksOnly() && track.isPVContributor() && !track.isGlobalTrack()) {
return 4;
}
if (!diffCuts.ITSOnlyTracks() && track.isPVContributor() && !track.hasTPC())
{
if (!diffCuts.ITSOnlyTracks() && track.isPVContributor() && !track.hasTPC()) {
return 5;
}

// update fraction of PV tracks with TOF hit
if (track.isPVContributor() && track.hasTOF())
{
if (track.isPVContributor() && track.hasTOF()) {
rgtrwTOF += 1.;
}
}
if (collision.numContrib() > 0)
{
if (collision.numContrib() > 0) {
rgtrwTOF /= collision.numContrib();
}
if (rgtrwTOF < diffCuts.minRgtrwTOF())
{
if (rgtrwTOF < diffCuts.minRgtrwTOF()) {
return 6;
}

// number of vertex tracks
if (collision.numContrib() < diffCuts.minNTracks() || collision.numContrib() > diffCuts.maxNTracks())
{
if (collision.numContrib() < diffCuts.minNTracks() || collision.numContrib() > diffCuts.maxNTracks()) {
return 7;
}

Expand All @@ -107,19 +97,16 @@ class SGSelector

// which particle hypothesis?
auto mass2Use = 0.;
TParticlePDG *pdgparticle = fPDG->GetParticle(diffCuts.pidHypothesis());
if (pdgparticle != nullptr)
{
TParticlePDG* pdgparticle = fPDG->GetParticle(diffCuts.pidHypothesis());
if (pdgparticle != nullptr) {
mass2Use = pdgparticle->Mass();
}

auto netCharge = 0;
auto lvtmp = TLorentzVector();
auto ivm = TLorentzVector();
for (auto &track : tracks)
{
if (track.isPVContributor())
{
for (auto& track : tracks) {
if (track.isPVContributor()) {

// PID
// if (!udhelpers::hasGoodPID(diffCuts, track)) {
Expand All @@ -128,14 +115,12 @@ class SGSelector

// pt
lvtmp.SetXYZM(track.px(), track.py(), track.pz(), mass2Use);
if (lvtmp.Perp() < diffCuts.minPt() || lvtmp.Perp() > diffCuts.maxPt())
{
if (lvtmp.Perp() < diffCuts.minPt() || lvtmp.Perp() > diffCuts.maxPt()) {
return 9;
}

// eta
if (lvtmp.Eta() < diffCuts.minEta() || lvtmp.Eta() > diffCuts.maxEta())
{
if (lvtmp.Eta() < diffCuts.minEta() || lvtmp.Eta() > diffCuts.maxEta()) {
return 10;
}
netCharge += track.sign();
Expand All @@ -145,31 +130,30 @@ class SGSelector

// net charge
auto netChargeValues = diffCuts.netCharges();
if (std::find(netChargeValues.begin(), netChargeValues.end(), netCharge) == netChargeValues.end())
{
if (std::find(netChargeValues.begin(), netChargeValues.end(), netCharge) == netChargeValues.end()) {
return 11;
}
// invariant mass
if (ivm.M() < diffCuts.minIVM() || ivm.M() > diffCuts.maxIVM())
{
if (ivm.M() < diffCuts.minIVM() || ivm.M() > diffCuts.maxIVM()) {
return 12;
}
// check that there are no FIT signals in any of the compatible BCs
// Single Gap (SG) condition
for (auto const &bc : bcRange)
{
for (auto const& bc : bcRange) {
if (useSideA) {
if (!udhelpers::cleanFITA(bc, diffCuts.maxFITtime(), diffCuts.FITAmpLimits())) {
return 1;
}
// if we arrive here then the event is good!
else return 0;
// if we arrive here then the event is good!
else
return 0;
} else {
if (!udhelpers::cleanFITC(bc, diffCuts.maxFITtime(), diffCuts.FITAmpLimits())) {
return 1;
}
// if we arrive here then the event is good!
else return 0;
// if we arrive here then the event is good!
else
return 0;
}
}

Expand All @@ -179,35 +163,30 @@ class SGSelector

// Function to check if BC passes SG filter (without associated collision)
template <typename BCs, typename TCs, typename FWs>
int IsSelected(SGCutParHolder diffCuts, BCs &bcRange, TCs &tracks, FWs &fwdtracks, bool useSideA)
int IsSelected(SGCutParHolder diffCuts, BCs& bcRange, TCs& tracks, FWs& fwdtracks, bool useSideA)
{
// check that there are no FIT signals in bcRange
// Single Gap (SG) condition
for (auto const &bc : bcRange)
{
LOGF(info, "%i \t %i", udhelpers::cleanFITA(bc, diffCuts.maxFITtime(), diffCuts.FITAmpLimits()), udhelpers::cleanFITC(bc, diffCuts.maxFITtime(), diffCuts.FITAmpLimits()));
if (!udhelpers::cleanFITA(bc, diffCuts.maxFITtime(), diffCuts.FITAmpLimits()) && !udhelpers::cleanFITC(bc, diffCuts.maxFITtime(), diffCuts.FITAmpLimits())) {
return 1; //activity on both sides
}
for (auto const& bc : bcRange) {
LOGF(info, "%i \t %i", udhelpers::cleanFITA(bc, diffCuts.maxFITtime(), diffCuts.FITAmpLimits()), udhelpers::cleanFITC(bc, diffCuts.maxFITtime(), diffCuts.FITAmpLimits()));
if (!udhelpers::cleanFITA(bc, diffCuts.maxFITtime(), diffCuts.FITAmpLimits()) && !udhelpers::cleanFITC(bc, diffCuts.maxFITtime(), diffCuts.FITAmpLimits())) {
return 1; // activity on both sides
}
}

// no activity in muon arm
if (!diffCuts.withFwdTracks())
{
for (auto &fwdtrack : fwdtracks)
{
if (!diffCuts.withFwdTracks()) {
for (auto& fwdtrack : fwdtracks) {
LOGF(info, " %i / %f / %f / %f / %f", fwdtrack.trackType(), fwdtrack.eta(), fwdtrack.pt(), fwdtrack.p(), fwdtrack.trackTimeRes());
// only consider tracks with MID (good timing)
if (fwdtrack.trackType() == 0 || fwdtrack.trackType() == 3)
{
if (fwdtrack.trackType() == 0 || fwdtrack.trackType() == 3) {
return 2;
}
}
}

// number of tracks
if (static_cast<int>(tracks.size()) < diffCuts.minNTracks() || static_cast<int>(tracks.size()) > diffCuts.maxNTracks())
{
if (static_cast<int>(tracks.size()) < diffCuts.minNTracks() || static_cast<int>(tracks.size()) > diffCuts.maxNTracks()) {
return 3;
}

Expand All @@ -216,17 +195,15 @@ class SGSelector

// which particle hypothesis?
auto mass2Use = 0.;
TParticlePDG *pdgparticle = fPDG->GetParticle(diffCuts.pidHypothesis());
if (pdgparticle != nullptr)
{
TParticlePDG* pdgparticle = fPDG->GetParticle(diffCuts.pidHypothesis());
if (pdgparticle != nullptr) {
mass2Use = pdgparticle->Mass();
}

auto netCharge = 0;
auto lvtmp = TLorentzVector();
auto ivm = TLorentzVector();
for (auto &track : tracks)
{
for (auto& track : tracks) {

// PID
// if (!udhelpers::hasGoodPID(diffCuts, track)) {
Expand All @@ -235,14 +212,12 @@ class SGSelector

// pt
lvtmp.SetXYZM(track.px(), track.py(), track.pz(), mass2Use);
if (lvtmp.Perp() < diffCuts.minPt() || lvtmp.Perp() > diffCuts.maxPt())
{
if (lvtmp.Perp() < diffCuts.minPt() || lvtmp.Perp() > diffCuts.maxPt()) {
return 5;
}

// eta
if (lvtmp.Eta() < diffCuts.minEta() || lvtmp.Eta() > diffCuts.maxEta())
{
if (lvtmp.Eta() < diffCuts.minEta() || lvtmp.Eta() > diffCuts.maxEta()) {
return 6;
}
netCharge += track.sign();
Expand All @@ -251,40 +226,37 @@ class SGSelector

// net charge
auto netChargeValues = diffCuts.netCharges();
if (std::find(netChargeValues.begin(), netChargeValues.end(), netCharge) == netChargeValues.end())
{
if (std::find(netChargeValues.begin(), netChargeValues.end(), netCharge) == netChargeValues.end()) {
return 7;
}
// invariant mass
if (ivm.M() < diffCuts.minIVM() || ivm.M() > diffCuts.maxIVM())
{
if (ivm.M() < diffCuts.minIVM() || ivm.M() > diffCuts.maxIVM()) {
return 8;
}

// check that there are no FIT signals in any of the compatible BCs
// Single Gap (SG) condition
for (auto const &bc : bcRange)
{
for (auto const& bc : bcRange) {
if (useSideA) {
if (!udhelpers::cleanFITA(bc, diffCuts.maxFITtime(), diffCuts.FITAmpLimits())) {
return 1;
}
// if we arrive here then the event is good!
else return 0;
// if we arrive here then the event is good!
else
return 0;
} else {
if (!udhelpers::cleanFITC(bc, diffCuts.maxFITtime(), diffCuts.FITAmpLimits())) {
return 1;
}
// if we arrive here then the event is good!
else return 0;
// if we arrive here then the event is good!
else
return 0;
}
}

};

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

#endif // PWGUD_CORE_SGSELECTOR_H_

5 changes: 2 additions & 3 deletions PWGUD/DataModel/UDTables.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ DECLARE_SOA_COLUMN(TriggerMaskFDD, triggerMaskFDD, uint8_t); //! FDD trigg
DECLARE_SOA_COLUMN(TotalFV0AmplitudeA, totalFV0AmplitudeA, float); //! sum of amplitudes on A side of FDD
DECLARE_SOA_COLUMN(TimeFV0A, timeFV0A, float); //! FV0A average time
DECLARE_SOA_COLUMN(TriggerMaskFV0A, triggerMaskFV0A, uint8_t); //! FV0 trigger mask
//Gap Side Information
// Gap Side Information
DECLARE_SOA_COLUMN(GapSide, gapSide, uint8_t); // 0 for side A, 1 for side C, 2 for both sides (or use an enum for better readability)
// FIT selection flags
// bits in range [0, 15] -> past BCs
Expand Down Expand Up @@ -150,7 +150,6 @@ DECLARE_SOA_TABLE(UDCollisions, "AOD", "UDCOLLISION",
collision::NumContrib,
udcollision::NetCharge,
udcollision::RgtrwTOF);


DECLARE_SOA_TABLE(SGCollisions, "AOD", "SGCOLLISION",
o2::soa::Index<>,
Expand All @@ -162,7 +161,7 @@ DECLARE_SOA_TABLE(SGCollisions, "AOD", "SGCOLLISION",
collision::NumContrib,
udcollision::NetCharge,
udcollision::RgtrwTOF,
udcollision::GapSide);
udcollision::GapSide);

DECLARE_SOA_TABLE(UDCollisionsSels, "AOD", "UDCOLLISIONSEL",
udcollision::TotalFT0AmplitudeA,
Expand Down
Loading