Patch provided by Adrian (slightly reworked by Constantin).
authorloizides <loizides@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 14 Oct 2013 21:03:58 +0000 (21:03 +0000)
committerloizides <loizides@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 14 Oct 2013 21:03:58 +0000 (21:03 +0000)
Enable the use of fastjet 3 (3.0.5 was tested). Not all features are implemented
in the wrapper. In particular  fj::JetMedianBackgroundEstimator is commented, and
we still use RangeDefinition instead of Selector. Can be changed at a later stage.
Verified that raw spectra are not changing if you have fastjet 2.4.x.
(Also with 3.0.5 raw results were the same for the same settings as with 2.4.x)
More tests are being performed by Adrian.

To install fastjet 3. Follow $ALICE_ROOT/JETAN/README_FASTJET
Configure fastjet with:
--enable-debug --enable-shared --enable-cgal --disable-monolithic --disable-static

Order to load libraries:
  gSystem->Load("libCGAL");
  gSystem->Load("libfastjet");
  gSystem->Load("libsiscone");
  gSystem->Load("libsiscone_spherical");
  gSystem->Load("libSISConePlugin");

  gSystem->Load("libJETAN");
  gSystem->Load("libFASTJETAN");
  gSystem->Load("libPWGJEEMCALJetTasks");

PWGJE/CMakelibPWGJE.pkg
PWGJE/CMakelibPWGJEEMCALJetTasks.pkg
PWGJE/CMakelibPWGJEFlavourJetTasks.pkg
PWGJE/EMCALJetTasks/AliEmcalJetTask.cxx
PWGJE/EMCALJetTasks/AliEmcalJetTask.h
PWGJE/EMCALJetTasks/AliFJWrapper.h
PWGJE/EMCALJetTasks/FJ_includes.h

index 8d4acaa..1cca00c 100644 (file)
@@ -1,4 +1,4 @@
-# -*- mode: CMake -*-
+# -*- mode: Makefile -*-
 #--------------------------------------------------------------------------------#
 # Package File for PWGJE                                                  #
 # Author : Johny Jose (johny.jose@cern.ch)                                       #
@@ -59,7 +59,19 @@ set ( DHDR  PWGJELinkDef.h)
 
 string ( REPLACE ".cxx" ".h" EXPORT "${SRCS}" )
 
-set ( EINCLUDE ANALYSIS JETAN JETAN/fastjet CORRFW PWGJE PWG/Tools PWGCF/Correlations/Base STEER/AOD STEER/ESD STEER/STEERBase)
+set ( HDRS ${HDRS}  EMCALJetTasks/FJ_includes.h  )
+
+set(FASTJET_ROOT $ENV{FASTJET_ROOT})
+
+if(FASTJET_ROOT)
+  set (FASTJET_INC ${FASTJET_ROOT}/include)
+else()
+  set (FASTJET_INC ${ALICE_ROOT}/JETAN/fastjet)
+endif(FASTJET_ROOT)
+
+#set ( EDEFINE -isystem${FASTJET_INC})
+set ( EINCLUDE ${FASTJET_INC} ANALYSIS JETAN CORRFW PWGJE PWG/Tools PWGCF/Correlations/Base STEER/AOD STEER/ESD STEER/STEERBase)
+#set ( EINCLUDE ANALYSIS JETAN CORRFW PWGJE PWG/Tools PWGCF/Correlations/Base STEER/AOD STEER/ESD STEER/STEERBase)
 
 install (DIRECTORY macros
         DESTINATION PWGJE
index 57d6d7c..d81195c 100644 (file)
@@ -26,6 +26,7 @@
 #--------------------------------------------------------------------------------#
 
 set ( SRCS 
+ EMCALJetTasks/AliFJWrapper.cxx
  EMCALJetTasks/AliAnalysisTaskDeltaPt.cxx
  EMCALJetTasks/AliAnalysisTaskEmcalJet.cxx
  EMCALJetTasks/AliAnalysisTaskEmcalJetDev.cxx
@@ -89,9 +90,10 @@ set ( HDRS ${HDRS}  EMCALJetTasks/FJ_includes.h )
 set ( FASTJET_ROOT $ENV{FASTJET_ROOT} )
 
 if(FASTJET_ROOT)
-  set ( EDEFINE -isystem${FASTJET_ROOT}/include )
+  set (FASTJET_INC ${FASTJET_ROOT}/include)
 else()
-  set ( EDEFINE -isystem${ALICE_ROOT}/JETAN/fastjet )
+  set (FASTJET_INC ${ALICE_ROOT}/JETAN/fastjet)
 endif(FASTJET_ROOT)
 
-set ( EINCLUDE JETAN/fastjet PWGJE/EMCALJetTasks PWG/EMCAL EMCAL OADB STEER/ESD STEER/STEERBase )
+set ( EDEFINE -isystem${FASTJET_INC})
+set ( EINCLUDE ${FASTJET_INC} PWGJE/EMCALJetTasks PWG/EMCAL EMCAL OADB STEER/ESD STEER/STEERBase )
index cbdf279..463b90f 100644 (file)
@@ -39,9 +39,10 @@ string ( REPLACE ".cxx" ".h" HDRS "${SRCS}" )
 set ( FASTJET_ROOT $ENV{FASTJET_ROOT} )
 
 if(FASTJET_ROOT)
-  set ( EDEFINE -isystem${FASTJET_ROOT}/include )
+  set (FASTJET_INC ${FASTJET_ROOT}/include)
 else()
-  set ( EDEFINE -isystem${ALICE_ROOT}/JETAN/fastjet )
+  set (FASTJET_INC ${ALICE_ROOT}/JETAN/fastjet)
 endif(FASTJET_ROOT)
 
-set ( EINCLUDE JETAN/fastjet PWGJE/EMCALJetTasks PWGJE/FlavourJetTasks PWG/EMCAL PWGHF/vertexingHF EMCAL OADB STEER/ESD STEER/STEERBase )
+set ( EDEFINE -isystem${FASTJET_INC})
+set ( EINCLUDE ${FASTJET_INC} PWGJE/EMCALJetTasks PWGJE/FlavourJetTasks PWG/EMCAL PWGHF/vertexingHF EMCAL OADB STEER/ESD STEER/STEERBase )
index c0ef3b5..4bb6375 100644 (file)
@@ -62,6 +62,7 @@ AliEmcalJetTask::AliEmcalJetTask() :
   fIsPSelSet(0),
   fIsMcPart(0),
   fIsEmcPart(0),
+  fLegacyMode(kFALSE),
   fJets(0),
   fEvent(0),
   fTracks(0),
@@ -101,6 +102,7 @@ AliEmcalJetTask::AliEmcalJetTask(const char *name) :
   fIsPSelSet(0),
   fIsMcPart(0),
   fIsEmcPart(0),
+  fLegacyMode(false),
   fJets(0),
   fEvent(0),
   fTracks(0),
@@ -334,7 +336,12 @@ void AliEmcalJetTask::FindJets()
       fjw.AddInputVector(cPx, cPy, cPz, TMath::Sqrt(cPx*cPx+cPy*cPy+cPz*cPz), -iClus - 100);
     }
   }
-  
+
+  // setting legacy mode
+  if (fLegacyMode) { 
+    fjw.SetLegacyMode(kTRUE);
+  }
+
   // run jet finder
   fjw.Run();
 
index 88e8d74..9fc29c1 100644 (file)
@@ -76,8 +76,10 @@ class AliEmcalJetTask : public AliAnalysisTaskSE {
       fOfflineTriggerMask = fOfflineTriggerMask | offlineTriggerMask;
     }
   }
+  void                   SetLegacyMode(Bool_t mode)       { fLegacyMode ^= mode; }
 
   UInt_t                 GetJetType()                     { return fJetType; }
+  Bool_t                 GetLegacyMode()                  { return fLegacyMode; }
 
  protected:
   void                   FindJets();
@@ -112,6 +114,7 @@ class AliEmcalJetTask : public AliAnalysisTaskSE {
   Bool_t                 fIsPSelSet;              //!=true if physics selection was set
   Bool_t                 fIsMcPart;               //!=true if MC particles are given as input
   Bool_t                 fIsEmcPart;              //!=true if emcal particles are given as input (for clusters)
+  Bool_t                 fLegacyMode;             //! if true, enable FJ 2.x behavior
   TClonesArray          *fJets;                   //!jet collection
   AliVEvent             *fEvent;                  //!current event
   TClonesArray          *fTracks;                 //!tracks collection
index c9baf2e..e93fc88 100644 (file)
@@ -34,6 +34,7 @@ class AliFJWrapper
   fastjet::PseudoJet                    GetJetAreaVector   (UInt_t idx) const;
   Double_t                              GetJetSubtractedPt (UInt_t idx) const;
   virtual std::vector<double>           GetSubtractedJetsPts(Double_t median_pt = -1, Bool_t sorted = kFALSE);
+  Bool_t                                GetLegacyMode()            { return fLegacyMode; }
 
   virtual Int_t Run();
 
@@ -54,36 +55,42 @@ class AliFJWrapper
   void SetupAreaTypefromOpt(const char *option);
   void SetupSchemefromOpt(const char *option);
   void SetupStrategyfromOpt(const char *option);
+  void SetLegacyMode (Bool_t mode)      { fLegacyMode ^= mode; }
+  void SetLegacyFJ();
 
  protected:
-  TString                         fName;             //!
-  TString                         fTitle;            //!
-  std::vector<fastjet::PseudoJet> fInputVectors;     //!
-  std::vector<fastjet::PseudoJet> fInclusiveJets;    //!
-  std::vector<double>             fSubtractedJetsPt; //!
-  fastjet::AreaDefinition        *fAreaDef;          //!
-  fastjet::VoronoiAreaSpec       *fVorAreaSpec;      //!
-  fastjet::GhostedAreaSpec       *fGhostedAreaSpec;  //!
-  fastjet::JetDefinition         *fJetDef;           //!
-  fastjet::JetDefinition::Plugin *fPlugin;           //!
-  fastjet::RangeDefinition       *fRange;            //!
-  fastjet::ClusterSequenceArea   *fClustSeq;         //!
-  fastjet::Strategy               fStrategy;         //!
-  fastjet::JetAlgorithm           fAlgor;            //!
-  fastjet::RecombinationScheme    fScheme;           //!
-  fastjet::AreaType               fAreaType;         //!
-  Int_t                           fNGhostRepeats;    //!
-  Double_t                        fGhostArea;       //!
-  Double_t                        fMaxRap;          //!
-  Double_t                        fR;                //!
+  TString                                fName;             //!
+  TString                                fTitle;            //!
+  std::vector<fastjet::PseudoJet>        fInputVectors;     //!
+  std::vector<fastjet::PseudoJet>        fInclusiveJets;    //!
+  std::vector<double>                    fSubtractedJetsPt; //!
+  fastjet::AreaDefinition               *fAreaDef;          //!
+  fastjet::VoronoiAreaSpec              *fVorAreaSpec;      //!
+  fastjet::GhostedAreaSpec              *fGhostedAreaSpec;  //!
+  fastjet::JetDefinition                *fJetDef;           //!
+  fastjet::JetDefinition::Plugin        *fPlugin;           //!
+  fastjet::RangeDefinition              *fRange;            //!
+  fastjet::ClusterSequenceArea          *fClustSeq;         //!
+  fastjet::Strategy                      fStrategy;         //!
+  fastjet::JetAlgorithm                  fAlgor;            //!
+  fastjet::RecombinationScheme           fScheme;           //!
+  fastjet::AreaType                      fAreaType;         //!
+  Int_t                                  fNGhostRepeats;    //!
+  Double_t                               fGhostArea;       //!
+  Double_t                               fMaxRap;          //!
+  Double_t                               fR;                //!
   // no setters for the moment - used default values in the constructor
-  Double_t                        fGridScatter;      //!
-  Double_t                        fKtScatter;       //!
-  Double_t                        fMeanGhostKt;      //!
-  Int_t                           fPluginAlgor;      //!
+  Double_t                               fGridScatter;      //!
+  Double_t                               fKtScatter;       //!
+  Double_t                               fMeanGhostKt;      //!
+  Int_t                                  fPluginAlgor;      //!
   // extra parameters
-  Double_t                        fMedUsedForBgSub;  //!
-  Bool_t                          fUseArea4Vector;   //!
+  Double_t                               fMedUsedForBgSub;  //!
+  Bool_t                                 fUseArea4Vector;   //!
+#ifdef FASTJET_VERSION
+  fastjet::JetMedianBackgroundEstimator *fBkrdEstimator;    //!
+#endif
+  Bool_t                                 fLegacyMode;       //!
 
   virtual void   SubtractBackground(const Double_t median_pt = -1);
 
@@ -133,6 +140,10 @@ AliFJWrapper::AliFJWrapper(const char *name, const char *title)
   , fPluginAlgor       (0)
   , fMedUsedForBgSub   (0)
   , fUseArea4Vector    (kFALSE)
+#ifdef FASTJET_VERSION
+  , fBkrdEstimator     (0)
+#endif
+  , fLegacyMode        (false)
 {
   // Constructor.
 }
@@ -148,7 +159,10 @@ AliFJWrapper::~AliFJWrapper()
   delete fJetDef;
   delete fPlugin;
   delete fRange;
-  delete fClustSeq;  
+  delete fClustSeq;
+#ifdef FASTJET_VERSION
+  if (fBkrdEstimator) delete fBkrdEstimator;
+#endif
 }
 
 //_________________________________________________________________________________________________
@@ -171,6 +185,7 @@ void AliFJWrapper::CopySettingsFrom(const AliFJWrapper& wrapper)
   fMeanGhostKt    = wrapper.fMeanGhostKt;
   fPluginAlgor    = wrapper.fPluginAlgor;
   fUseArea4Vector = wrapper.fUseArea4Vector;
+  fLegacyMode     = wrapper.fLegacyMode;
 }
 
 //_________________________________________________________________________________________________
@@ -191,6 +206,9 @@ void AliFJWrapper::Clear(const Option_t */*opt*/)
   delete fPlugin;          fPlugin          = 0;
   delete fRange;           fRange           = 0;
   delete fClustSeq;        fClustSeq        = 0;
+#ifdef FASTJET_VERSION
+  if (fBkrdEstimator) delete fBkrdEstimator; fBkrdEstimator = 0;
+#endif
 }
 
 //_________________________________________________________________________________________________
@@ -328,7 +346,7 @@ void AliFJWrapper::GetMedianAndSigma(Double_t &median, Double_t &sigma, Int_t re
     }  else {
       std::vector<fastjet::PseudoJet> input_jets = sorted_by_pt(fClustSeq->inclusive_jets());
       input_jets.erase(input_jets.begin(), input_jets.begin() + remove);
-      fClustSeq->get_median_rho_and_sigma(input_jets, *fRange, kFALSE, median, sigma, mean_area);
+      fClustSeq->get_median_rho_and_sigma(input_jets, *fRange, fUseArea4Vector, median, sigma, mean_area);
       input_jets.clear();
     }
   } catch (fj::Error) {
@@ -386,6 +404,13 @@ Int_t AliFJWrapper::Run()
     return -1;
   }
 
+  // FJ3 :: Define an JetMedianBackgroundEstimator just in case it will be used 
+#ifdef FASTJET_VERSION
+  //fBkrdEstimator = new fj::JetMedianBackgroundEstimator(*fRange, *fJetDef, *fAreaDef) ;
+#endif
+
+  if (fLegacyMode) { SetLegacyFJ(); } // for FJ 2.x even if fLegacyMode is set, SetLegacyFJ is dummy
+
   // inclusive jets:
   fInclusiveJets.clear();
   fInclusiveJets = fClustSeq->inclusive_jets(0.0); 
@@ -394,6 +419,20 @@ Int_t AliFJWrapper::Run()
 }
 
 //_________________________________________________________________________________________________
+void AliFJWrapper::SetLegacyFJ()
+{
+  // This methods enable legacy behaviour (FastJet 2.x) when AliROOT is compiled with FastJet 3.x
+#ifdef FASTJET_VERSION
+    std::cout << "WARNING! Setting FastJet in legacy mode" << std::endl;
+    if (fGhostedAreaSpec) { fGhostedAreaSpec->set_fj2_placement(kTRUE); }
+    if (fBkrdEstimator) {
+      fBkrdEstimator->set_provide_fj2_sigma(kTRUE);
+      fBkrdEstimator->set_use_area_4vector(kFALSE);
+    } 
+#endif
+}
+
+//_________________________________________________________________________________________________
 void AliFJWrapper::SubtractBackground(Double_t median_pt)
 {
   // Subtract the background (specify the value - see below the meaning).
@@ -407,13 +446,13 @@ void AliFJWrapper::SubtractBackground(Double_t median_pt)
 
   // clear the subtracted jet pt's vector<double>
   fSubtractedJetsPt.clear();
-      
+
   // check what was specified (default is -1)
   if (median_pt < 0) {
     try {
-      fClustSeq->get_median_rho_and_sigma(*fRange, kFALSE, median, sigma, mean_area);
+      fClustSeq->get_median_rho_and_sigma(*fRange, fUseArea4Vector, median, sigma, mean_area);
     }
-      
+
     catch (fj::Error) {
       AliError(" [w] FJ Exception caught.");
       median = -9999.;
@@ -435,7 +474,7 @@ void AliFJWrapper::SubtractBackground(Double_t median_pt)
 
   // subtract:
   for (unsigned i = 0; i < fInclusiveJets.size(); i++) {
-    if (kTRUE == fUseArea4Vector) {
+    if ( fUseArea4Vector ) {
       // subtract the background using the area4vector
       fj::PseudoJet area4v = fClustSeq->area_4vector(fInclusiveJets[i]);
       fj::PseudoJet jet_sub = fInclusiveJets[i] - area4v * fMedUsedForBgSub;
index 517f338..d94ad9e 100644 (file)
@@ -7,11 +7,15 @@
 #if defined __GNUC__
 #pragma GCC system_header
 #endif
+#include <fastjet/config.h>
 #include <fastjet/PseudoJet.hh>
 #include <fastjet/JetDefinition.hh>
 #include <fastjet/ClusterSequence.hh>
 #include <fastjet/ClusterSequenceArea.hh>
 #include <fastjet/AreaDefinition.hh>
 #include <fastjet/SISConePlugin.hh>
+#ifdef FASTJET_VERSION
+#include <fastjet/tools/JetMedianBackgroundEstimator.hh>
+#endif
 #endif
 #endif