Skip to content

Commit 0bfd605

Browse files
authored
Update femtoDreamCollisionSelection.h
Added code for shpericity calculation. Sphericity matrix is taken from: EPJC72:2124
1 parent f88c0a3 commit 0bfd605

File tree

1 file changed

+69
-3
lines changed

1 file changed

+69
-3
lines changed

PWGCF/FemtoDream/Core/femtoDreamCollisionSelection.h

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class FemtoDreamCollisionSelection
4141
/// \param checkTrigger whether or not to check for the trigger alias
4242
/// \param trig Requested trigger alias
4343
/// \param checkOffline whether or not to check for offline selection criteria
44-
void setCuts(float zvtxMax, bool checkTrigger, int trig, bool checkOffline, bool addCheckOffline, bool checkRun3)
44+
void setCuts(float zvtxMax, bool checkTrigger, int trig, bool checkOffline, bool addCheckOffline, bool checkRun3, float minSphericity, float sphericityPtmin)
4545
{
4646
mCutsSet = true;
4747
mZvtxMax = zvtxMax;
@@ -50,6 +50,8 @@ class FemtoDreamCollisionSelection
5050
mCheckOffline = checkOffline;
5151
mAddCheckOffline = addCheckOffline;
5252
mCheckIsRun3 = checkRun3;
53+
mMinSphericity = minSphericity;
54+
mSphericityPtmin = sphericityPtmin;
5355
}
5456

5557
/// Initializes histograms for the task
@@ -66,6 +68,7 @@ class FemtoDreamCollisionSelection
6668
mHistogramRegistry->add("Event/MultNTracksPV", "; MultNTracksPV; Entries", kTH1F, {{200, 0, 200}});
6769
mHistogramRegistry->add("Event/MultNTracklets", "; MultNTrackslets; Entries", kTH1F, {{300, 0, 300}});
6870
mHistogramRegistry->add("Event/MultTPC", "; MultTPC; Entries", kTH1F, {{600, 0, 600}});
71+
mHistogramRegistry->add("Event/Sphericity", "; Sphericity; Entries", kTH1F, {{100, 0, 1}});
6972
}
7073

7174
/// Print some debug information
@@ -76,6 +79,8 @@ class FemtoDreamCollisionSelection
7679
LOG(info) << "Check trigger: " << mCheckTrigger;
7780
LOG(info) << "Trigger: " << mTrigger;
7881
LOG(info) << " Check offline: " << mCheckOffline;
82+
LOG(info) << "Min sphericity: " << mMinSphericity;
83+
LOG(info) << "Min Pt (sphericity): " << mSphericityPtmin;
7984
}
8085

8186
/// Check whether the collisions fulfills the specified selections
@@ -180,9 +185,68 @@ class FemtoDreamCollisionSelection
180185
/// \param tracks All tracks
181186
/// \return value of the sphericity of the event
182187
template <typename T1, typename T2>
183-
float computeSphericity(T1 const& /*col*/, T2 const& /*tracks*/)
188+
float computeSphericity(T1 const& col, T2 const& tracks)
184189
{
185-
return 2.f;
190+
double ptTot = 0.;
191+
double s00 = 0.; //elements of the sphericity matrix taken form EPJC72:2124
192+
double s01 = 0.;
193+
double s10 = 0.;
194+
double s11 = 0.;
195+
196+
int numOfTracks = col.numContrib();
197+
if (numOfTracks < 3)
198+
return -9999.;
199+
200+
201+
for (auto& track : tracks) {
202+
double pt = track.pt();
203+
double eta = track.eta();
204+
double px = track.px();
205+
double py = track.py();
206+
if (TMath::Abs(pt) < /*lowerPtbound*/ 0.5 || TMath::Abs(eta) > 0.8) {
207+
continue;
208+
}
209+
210+
ptTot += pt;
211+
212+
s00 += px * px / pt;
213+
s01 += px * py / pt;
214+
s10 = s01;
215+
s11 += py * py / pt;
216+
217+
}
218+
219+
//normalize to total Pt to obtain a linear form:
220+
if (ptTot == 0.)
221+
return -9999.;
222+
s00 /= ptTot;
223+
s11 /= ptTot;
224+
s10 /= ptTot;
225+
226+
//Calculate the trace of the sphericity matrix:
227+
double T = s00 + s11;
228+
//Calculate the determinant of the sphericity matrix:
229+
double D = s00 * s11 - s10 * s10; //S10 = S01
230+
231+
//Calculate the eigenvalues of the sphericity matrix:
232+
double lambda1 = 0.5 * (T + std::sqrt(T * T - 4. * D));
233+
double lambda2 = 0.5 * (T - std::sqrt(T * T - 4. * D));
234+
235+
if ((lambda1 + lambda2) == 0.)
236+
return -9999.;
237+
238+
double spt = -1.;
239+
240+
if (lambda2 > lambda1) {
241+
spt = 2. * lambda1 / (lambda1 + lambda2);
242+
} else {
243+
spt = 2. * lambda2 / (lambda1 + lambda2);
244+
}
245+
246+
247+
mHistogramRegistry->fill(HIST("Event/Sphericity"), spt);
248+
249+
return spt;
186250
}
187251

188252
private:
@@ -194,6 +258,8 @@ class FemtoDreamCollisionSelection
194258
bool mCheckIsRun3 = false; ///< Check if running on Pilot Beam
195259
triggerAliases mTrigger = kINT7; ///< Trigger to check for
196260
float mZvtxMax = 999.f; ///< Maximal deviation from nominal z-vertex (cm)
261+
float mMinSphericity = 0.f;
262+
float mSphericityPtmin = 0.f;
197263
};
198264
} // namespace o2::analysis::femtoDream
199265

0 commit comments

Comments
 (0)