-// $Id$
//
// Emcal jet class.
//
std::sort(fTrackIDs.GetArray(), fTrackIDs.GetArray() + fTrackIDs.GetSize());
}
+//__________________________________________________________________________________________________
+Double_t AliEmcalJet::DeltaR (const AliVParticle* part) const
+{ // Helper function to calculate the distance between two jets or a jet and a particle
+ Double_t dPhi = this->Phi() - part->Phi();
+ Double_t dEta = this->Eta() - part->Eta();
+ dPhi = TVector2::Phi_mpi_pi ( dPhi );
+
+ return TMath::Sqrt ( dPhi * dPhi + dEta * dEta );
+}
+
+
+//__________________________________________________________________________________________________
+std::vector<int> AliEmcalJet::SortConstituentsPt( TClonesArray *tracks ) const
+{ //___________________________________________
+ // Sorting by p_T (decreasing) jet constituents
+ //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ typedef std::pair<Double_t, Int_t> ptidx_pair;
+
+ // Create vector for Pt sorting
+ std::vector<ptidx_pair> pair_list ;
+
+ for ( Int_t i_entry = 0; i_entry < GetNumberOfTracks(); i_entry++ )
+ {
+ AliVParticle *track = TrackAt(i_entry, tracks);
+ if (!track)
+ {
+ AliError(Form("Unable to find jet track %d in collection %s (pos in collection %d, max %d)", i_entry, tracks->GetName(), TrackAt(i_entry), tracks->GetEntriesFast()));
+ continue;
+ }
+
+ pair_list.push_back( std::make_pair ( track->Pt(), i_entry ) );
+ }
+
+ std::stable_sort( pair_list.begin() , pair_list.end() , sort_descend() );
+
+ // return an vector of indexes of constituents (sorted descending by pt)
+ std::vector <int> index_sorted_list;
+
+ for ( std::vector< std::pair<Double_t,Int_t> >::iterator it = pair_list.begin(); it != pair_list.end(); ++it)
+ { index_sorted_list.push_back( (*it).second ); } // populating the return object with indexes of sorted tracks
+
+ return index_sorted_list;
+}
+
//__________________________________________________________________________________________________
AliVParticle* AliEmcalJet::GetLeadingTrack(TClonesArray *tracks) const
{
#ifndef AliEmcalJet_H
#define AliEmcalJet_H
-// $Id$
-
+#include <vector>
+#include <algorithm>
+#include <utility>
#include <TArrayS.h>
#include <TLorentzVector.h>
#include <TMath.h>
#include <TClonesArray.h>
+#include <TVector2.h>
#include "AliVParticle.h"
#include "AliVCluster.h"
void AddTrackAt(Int_t track, Int_t idx) { fTrackIDs.AddAt(track, idx); }
void Clear(Option_t */*option*/="") { fClusterIDs.Set(0); fTrackIDs.Set(0); fClosestJets[0] = 0; fClosestJets[1] = 0;
fClosestJetsDist[0] = 0; fClosestJetsDist[1] = 0; fMatched = 0; fPtSub = 0; }
+ Double_t DeltaR(const AliVParticle* part) const;
void SetArea(Double_t a) { fArea = a; }
void SetAreaEta(Double_t a) { fAreaEta = a; }
void SetAreaPhi(Double_t a) { fAreaPhi = a; }
void SetNumberOfNeutrals(Int_t n) { fNn = n; }
void SetMCPt(Double_t p) { fMCPt = p; }
void SortConstituents();
+ std::vector<int> SortConstituentsPt(TClonesArray *tracks) const;
void SetNEmc(Int_t n) { fNEmc = n; }
void SetPtEmc(Double_t pt) { fPtEmc = pt; }
void SetPtSub(Double_t ps) { fPtSub = ps; }
Double_t fPtVectSub; //! background vector subtracted pt (not stored set from outside)
UInt_t fTriggers; //! triggers that the jet might have fired (AliVEvent::EOfflineTriggerTypes)
- ClassDef(AliEmcalJet,12) // Emcal jet class in cylindrical coordinates
+ private:
+ struct sort_descend
+ { // sort in decreasing order
+ // first value of the pair is Pt and the second is entry index
+ bool operator () (const std::pair<Double_t, Int_t>& p1, const std::pair<Double_t, Int_t>& p2) { return p1.first > p2.first ; }
+ };
+
+ ClassDef(AliEmcalJet,13) // Emcal jet class in cylindrical coordinates
};
#endif