]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGJE/EMCALJetTasks/AliEmcalJet.cxx
fix compiler warning
[u/mrichter/AliRoot.git] / PWGJE / EMCALJetTasks / AliEmcalJet.cxx
index 29aa5bc133973ad7ec9ac07a088059751f822668..75d97c2dc18cc601148361f3bc880a24dea4ee72 100644 (file)
@@ -1,4 +1,3 @@
-// $Id$
 //
 // Emcal jet class.
 //
@@ -6,6 +5,9 @@
 
 #include "AliEmcalJet.h"
 
+#include "AliLog.h"
+#include "Riostream.h"
+
 ClassImp(AliEmcalJet)
 
 //__________________________________________________________________________________________________
@@ -21,6 +23,7 @@ AliEmcalJet::AliEmcalJet() :
   fAreaPhi(0),       
   fAreaEmc(-1), 
   fAxisInEmcal(0), 
+  fFlavourTagging(0),
   fMaxCPt(0), 
   fMaxNPt(0), 
   fMCPt(0),
@@ -32,8 +35,16 @@ AliEmcalJet::AliEmcalJet() :
   fTrackIDs(),
   fMatched(2),
   fMatchingType(0),
+  fTaggedJet(0x0),
+  fTagStatus(-1),
   fPtSub(0),
-  fPtVectSub(0)
+  fPtVectSub(0),
+  fTriggers(0),
+  fJetShapeMassFirstDer(0),
+  fJetShapeMassSecondDer(0),
+  fJetShapeMassFirstSub(0),
+  fJetShapeMassSecondSub(0),
+  fLabel(-1)
 {
   // Constructor.
 
@@ -56,6 +67,7 @@ AliEmcalJet::AliEmcalJet(Double_t px, Double_t py, Double_t pz) :
   fAreaPhi(0),       
   fAreaEmc(-1), 
   fAxisInEmcal(0),
+  fFlavourTagging(0),
   fMaxCPt(0), 
   fMaxNPt(0), 
   fMCPt(0),
@@ -67,8 +79,16 @@ AliEmcalJet::AliEmcalJet(Double_t px, Double_t py, Double_t pz) :
   fTrackIDs(),
   fMatched(2),
   fMatchingType(0),
+  fTaggedJet(0x0),
+  fTagStatus(-1),
   fPtSub(0),
-  fPtVectSub(0)
+  fPtVectSub(0),
+  fTriggers(0),
+  fJetShapeMassFirstDer(0),
+  fJetShapeMassSecondDer(0),
+  fJetShapeMassFirstSub(0),
+  fJetShapeMassSecondSub(0),
+  fLabel(-1)
 {    
   // Constructor.
 
@@ -97,6 +117,7 @@ AliEmcalJet::AliEmcalJet(Double_t pt, Double_t eta, Double_t phi, Double_t m) :
   fAreaPhi(0),       
   fAreaEmc(-1), 
   fAxisInEmcal(0),
+  fFlavourTagging(0),
   fMaxCPt(0), 
   fMaxNPt(0),
   fMCPt(0),
@@ -108,8 +129,16 @@ AliEmcalJet::AliEmcalJet(Double_t pt, Double_t eta, Double_t phi, Double_t m) :
   fTrackIDs(),
   fMatched(2),
   fMatchingType(0),
+  fTaggedJet(0x0),
+  fTagStatus(-1),
   fPtSub(0),
-  fPtVectSub(0)
+  fPtVectSub(0),
+  fTriggers(0),
+  fJetShapeMassFirstDer(0),
+  fJetShapeMassSecondDer(0),
+  fJetShapeMassFirstSub(0),
+  fJetShapeMassSecondSub(0),
+  fLabel(-1)
 {
   // Constructor.
 
@@ -135,6 +164,7 @@ AliEmcalJet::AliEmcalJet(const AliEmcalJet &jet) :
   fAreaPhi(jet.fAreaPhi),       
   fAreaEmc(jet.fAreaEmc), 
   fAxisInEmcal(jet.fAxisInEmcal),
+  fFlavourTagging(jet.fFlavourTagging),
   fMaxCPt(jet.fMaxCPt), 
   fMaxNPt(jet.fMaxNPt), 
   fMCPt(jet.fMCPt),
@@ -146,8 +176,16 @@ AliEmcalJet::AliEmcalJet(const AliEmcalJet &jet) :
   fTrackIDs(jet.fTrackIDs),
   fMatched(jet.fMatched),
   fMatchingType(jet.fMatchingType),
+  fTaggedJet(jet.fTaggedJet),
+  fTagStatus(jet.fTagStatus),
   fPtSub(jet.fPtSub),
-  fPtVectSub(jet.fPtVectSub)
+  fPtVectSub(jet.fPtVectSub),
+  fTriggers(jet.fTriggers),
+  fJetShapeMassFirstDer(jet.fJetShapeMassFirstDer),
+  fJetShapeMassSecondDer(jet.fJetShapeMassSecondDer),
+  fJetShapeMassFirstSub(jet.fJetShapeMassFirstSub),
+  fJetShapeMassSecondSub(jet.fJetShapeMassSecondSub),
+  fLabel(jet.fLabel)
 {
   // Copy constructor.
 
@@ -174,6 +212,7 @@ AliEmcalJet &AliEmcalJet::operator=(const AliEmcalJet &jet)
     fAreaPhi            = jet.fAreaPhi; 
     fAreaEmc            = jet.fAreaEmc; 
     fAxisInEmcal        = jet.fAxisInEmcal; 
+    fFlavourTagging     = jet.fFlavourTagging;
     fMaxCPt             = jet.fMaxCPt; 
     fMaxNPt             = jet.fMaxNPt;
     fMCPt               = jet.fMCPt;
@@ -188,13 +227,22 @@ AliEmcalJet &AliEmcalJet::operator=(const AliEmcalJet &jet)
     fClosestJetsDist[0] = jet.fClosestJetsDist[0];  
     fClosestJetsDist[1] = jet.fClosestJetsDist[1]; 
     fMatched            = jet.fMatched;
+    fTaggedJet          = jet.fTaggedJet;
+    fTagStatus          = jet.fTagStatus;
     fPtSub              = jet.fPtSub;
     fPtVectSub          = jet.fPtVectSub;
+    fTriggers           = jet.fTriggers;
+    fJetShapeMassFirstDer  = jet.fJetShapeMassFirstDer;
+    fJetShapeMassSecondDer = jet.fJetShapeMassSecondDer;
+    fJetShapeMassFirstSub  = jet.fJetShapeMassFirstSub;
+    fJetShapeMassSecondSub = jet.fJetShapeMassSecondSub;
+    fLabel              = jet.fLabel;
   }
 
   return *this;
 }
 
+//_________________________________________________________________________________________________
 Int_t AliEmcalJet::Compare(const TObject* obj) const
 {
   //Return -1 if this is smaller than obj, 0 if objects are equal and 1 if this is larger than obj.
@@ -221,7 +269,7 @@ void AliEmcalJet::Print(Option_t* /*option*/) const
 {
   // Print jet information.
 
-  printf("Jet pt=%.2f, eta=%.2f, phi=%.2f, area=%.2f, NEF=%.2f\n", fPt, fEta, fPhi, fArea, fNEF);
+  Printf("Jet pt=%.2f, eta=%.2f, phi=%.2f, area=%.2f, NEF=%.2f", fPt, fEta, fPhi, fArea, fNEF);
 }
 
 //__________________________________________________________________________________________________
@@ -244,12 +292,61 @@ void AliEmcalJet::SortConstituents()
   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
 {
   AliVParticle* maxTrack = 0;
   for (Int_t i = 0; i < GetNumberOfTracks(); i++) {
     AliVParticle *track = TrackAt(i, tracks);
+    if (!track) {
+      AliError(Form("Unable to find jet track %d in collection %s (pos in collection %d, max %d)",
+                   i,tracks->GetName(),TrackAt(i),tracks->GetEntriesFast()));
+      continue;
+    }
     if (!maxTrack || track->Pt() > maxTrack->Pt()) 
       maxTrack = track;
   }
@@ -263,9 +360,24 @@ AliVCluster* AliEmcalJet::GetLeadingCluster(TClonesArray *clusters) const
   AliVCluster* maxCluster = 0;
   for (Int_t i = 0; i < GetNumberOfClusters(); i++) {
     AliVCluster *cluster = ClusterAt(i, clusters);
+    if (!cluster) {
+      AliError(Form("Unable to find jet cluster %d in collection %s (pos in collection %d, max %d)",
+                   i,clusters->GetName(),ClusterAt(i),clusters->GetEntriesFast()));
+      continue;
+    }
     if (!maxCluster || cluster->E() > maxCluster->E()) 
       maxCluster = cluster;
   }
 
   return maxCluster;
 }
+
+//__________________________________________________________________________________________________
+void AliEmcalJet::ResetMatching()
+{
+  fClosestJets[0] = 0;
+  fClosestJets[1] = 0; 
+  fClosestJetsDist[0] = 999; 
+  fClosestJetsDist[1] = 999; 
+  fMatched = 2;
+}