AliRsnCutManager:
authorpulvir <pulvir@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 26 Jan 2011 07:04:29 +0000 (07:04 +0000)
committerpulvir <pulvir@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 26 Jan 2011 07:04:29 +0000 (07:04 +0000)
-- bugfix on distinct daughter cuts (thanks Leonidas)

AliRsnCutBetheBloch, AliRsnCutDaugtherType, AliRsnCutESDPrimary, AliRsnCutPID:
-- more appropriate implementation of coverity fixes

AliRsnTarget:
-- reimplementation of TargetOK() function
-- addition of pointer to allowed target types (daughter, pair, event)

AliRsnAnalysisManager:
-- add the manager name in front of the histograms

Added two new cuts which try to split the comples ESD2010 cuts and try to generalize them also for AODs:
-- AliRsnCutTrackQuality --> quality cuts (nTPClusters, DCA, chi2, ...)
-- AliRsnCutPIDTOF       --> TOF PID with compatibility range

Added a new directory 'extra' containing code related to resonances but not integrated in the RSN package:
currently it contains the classes used for current Sigma1385 analysis.

18 files changed:
PWG2/CMakelibPWG2resonances.pkg
PWG2/PWG2resonancesLinkDef.h
PWG2/RESONANCES/AliRsnAnalysisManager.cxx
PWG2/RESONANCES/AliRsnAnalysisManager.h
PWG2/RESONANCES/AliRsnCutBetheBloch.cxx
PWG2/RESONANCES/AliRsnCutDaughterType.cxx
PWG2/RESONANCES/AliRsnCutESDPrimary.cxx
PWG2/RESONANCES/AliRsnCutManager.h
PWG2/RESONANCES/AliRsnCutPID.cxx
PWG2/RESONANCES/AliRsnCutPIDTOF.cxx [new file with mode: 0644]
PWG2/RESONANCES/AliRsnCutPIDTOF.h [new file with mode: 0644]
PWG2/RESONANCES/AliRsnCutTrackQuality.cxx [new file with mode: 0644]
PWG2/RESONANCES/AliRsnCutTrackQuality.h [new file with mode: 0644]
PWG2/RESONANCES/AliRsnTarget.cxx
PWG2/RESONANCES/AliRsnTarget.h
PWG2/RESONANCES/extra/AliAnalysisTaskSigma1385.C [new file with mode: 0644]
PWG2/RESONANCES/extra/AliAnalysisTaskSigma1385.cxx [new file with mode: 0644]
PWG2/RESONANCES/extra/AliAnalysisTaskSigma1385.h [new file with mode: 0644]

index 849b97eb499d91895251a672131bdab24c10ebe1..64b843b804ab0e286fe2ff934531f8b10e681924 100644 (file)
@@ -25,7 +25,7 @@
 # SHLIBS - Shared Libraries and objects for linking (Executables only)           #
 #--------------------------------------------------------------------------------#
 
-set ( SRCS  RESONANCES/AliRsnDaughter.cxx RESONANCES/AliRsnMother.cxx RESONANCES/AliRsnPairDef.cxx RESONANCES/AliRsnEvent.cxx RESONANCES/AliRsnTarget.cxx RESONANCES/AliRsnValue.cxx RESONANCES/AliRsnCut.cxx RESONANCES/AliRsnCutValue.cxx RESONANCES/AliRsnCutPID.cxx RESONANCES/AliRsnCutBetheBloch.cxx RESONANCES/AliRsnCutPrimaryVertex.cxx RESONANCES/AliRsnCutESDPrimary.cxx RESONANCES/AliRsnCutDaughterType.cxx RESONANCES/AliRsnCutESD2010.cxx RESONANCES/AliRsnCutAOD2010.cxx RESONANCES/AliRsnCutSet.cxx RESONANCES/AliRsnExpression.cxx RESONANCES/AliRsnVariableExpression.cxx RESONANCES/AliRsnCutManager.cxx RESONANCES/AliRsnFunction.cxx RESONANCES/AliRsnPair.cxx RESONANCES/AliRsnPairFunctions.cxx RESONANCES/AliRsnPairNtuple.cxx RESONANCES/AliRsnAnalysisManager.cxx RESONANCES/AliRsnVATProcessInfo.cxx RESONANCES/AliRsnVAnalysisTaskSE.cxx RESONANCES/AliRsnVAnalysisTaskME.cxx RESONANCES/AliRsnAnalysisSE.cxx RESONANCES/AliRsnAnalysisME.cxx RESONANCES/AliRsnAnalysisEffSE.cxx RESONANCES/AliRsnTOFT0maker.cxx RESONANCES/AliRsnAnalysisPhi900GeV.cxx RESONANCES/AliRsnAnalysisPhi7TeV.cxx RESONANCES/AliRsnAnalysisPhi7TeVNoPID.cxx RESONANCES/AliRsnMonitorTrack.cxx RESONANCES/AliRsnAnalysisMonitorTask.cxx RESONANCES/AliRsnAnalysisMonitorTask.cxx RESONANCES/AliRsnAnalysisPhiKK.cxx RESONANCES/AliRsnAnalysisKStarKpi.cxx RESONANCES/AliRsnVAnalysisTask.cxx RESONANCES/AliRsnAnalysisTask.cxx )
+set ( SRCS  RESONANCES/AliRsnDaughter.cxx RESONANCES/AliRsnMother.cxx RESONANCES/AliRsnPairDef.cxx RESONANCES/AliRsnEvent.cxx RESONANCES/AliRsnTarget.cxx RESONANCES/AliRsnValue.cxx RESONANCES/AliRsnCut.cxx RESONANCES/AliRsnCutValue.cxx RESONANCES/AliRsnCutPID.cxx RESONANCES/AliRsnCutBetheBloch.cxx RESONANCES/AliRsnCutPrimaryVertex.cxx RESONANCES/AliRsnCutESDPrimary.cxx RESONANCES/AliRsnCutDaughterType.cxx RESONANCES/AliRsnCutESD2010.cxx RESONANCES/AliRsnCutAOD2010.cxx RESONANCES/AliRsnCutTrackQuality.cxx RESONANCES/AliRsnCutPIDTOF.cxx RESONANCES/AliRsnCutSet.cxx RESONANCES/AliRsnExpression.cxx RESONANCES/AliRsnVariableExpression.cxx RESONANCES/AliRsnCutManager.cxx RESONANCES/AliRsnFunction.cxx RESONANCES/AliRsnPair.cxx RESONANCES/AliRsnPairFunctions.cxx RESONANCES/AliRsnPairNtuple.cxx RESONANCES/AliRsnAnalysisManager.cxx RESONANCES/AliRsnVATProcessInfo.cxx RESONANCES/AliRsnVAnalysisTaskSE.cxx RESONANCES/AliRsnVAnalysisTaskME.cxx RESONANCES/AliRsnAnalysisSE.cxx RESONANCES/AliRsnAnalysisME.cxx RESONANCES/AliRsnAnalysisEffSE.cxx RESONANCES/AliRsnTOFT0maker.cxx RESONANCES/AliRsnAnalysisPhi900GeV.cxx RESONANCES/AliRsnAnalysisPhi7TeV.cxx RESONANCES/AliRsnAnalysisPhi7TeVNoPID.cxx RESONANCES/AliRsnMonitorTrack.cxx RESONANCES/AliRsnAnalysisMonitorTask.cxx RESONANCES/AliRsnAnalysisMonitorTask.cxx RESONANCES/AliRsnAnalysisPhiKK.cxx RESONANCES/AliRsnAnalysisKStarKpi.cxx RESONANCES/AliRsnVAnalysisTask.cxx RESONANCES/AliRsnAnalysisTask.cxx  RESONANCES/extra/AliAnalysisTaskSigma1385.cxx )
 
 string ( REPLACE ".cxx" ".h" HDRS "${SRCS}" )
 
index 96989be9f569a341b9fffabd0ca7d0dbce2878f3..4ff7235caa61f0504cf2861937153de147773735 100644 (file)
@@ -17,6 +17,8 @@
 #pragma link C++ class AliRsnCutDaughterType+;
 #pragma link C++ class AliRsnCutESD2010+;
 #pragma link C++ class AliRsnCutAOD2010+;
+#pragma link C++ class AliRsnCutTrackQuality+;
+#pragma link C++ class AliRsnCutPIDTOF+;
 
 #pragma link C++ class AliRsnCutSet+;
 #pragma link C++ class AliRsnExpression+;
@@ -52,4 +54,6 @@
 #pragma link C++ class AliRsnVAnalysisTask+;
 #pragma link C++ class AliRsnAnalysisTask+;
 
+#pragma link C++ class AliAnalysisTaskSigma1385+;
+
 #endif
index 737c42c280532d0977eb22401da5707cb5b7b887..8f923e67201cb68e17695b85d6d81a36fe9cf2fd 100644 (file)
@@ -135,10 +135,11 @@ void AliRsnAnalysisManager::InitAllPairs(TList *list)
   while ((pair = (AliRsnPair*)next())) 
   {
     AliDebug(AliLog::kDebug+1, Form("InitAllPairs of the PairManager(%s) [%d] ...", pair->GetName(), i++));
-    pair->Init("", list);
+//     pair->Init("", list);
+    pair->Init(GetName(), list);
     
     // add a counter for used/unused events for each pair
-    TH1I *hPairUsed = new TH1I(Form("_%s_USED", pair->GetName()), "Used events for pair", 2, 0, 2);
+    TH1I *hPairUsed = new TH1I(Form("%s_%s_USED", GetName(),pair->GetName()), "Used events for pair", 2, 0, 2);
     list->Add(hPairUsed);
   }
   
index 978675591812b41a9fae4efc4ebcf451c5acc78a..98f08d9cd76aae0e7ec3264fe9067a37b3b50b03 100644 (file)
@@ -30,7 +30,7 @@ class AliRsnAnalysisManager : public TNamed
 {
   public:
 
-    AliRsnAnalysisManager(const char*name = "defaultAnalysisMgr");
+    AliRsnAnalysisManager(const char*name = "RSN");
     AliRsnAnalysisManager(const AliRsnAnalysisManager& copy);
     AliRsnAnalysisManager& operator=(const AliRsnAnalysisManager& copy);
     virtual ~AliRsnAnalysisManager() { }
index 26467a640193b724c96821c0e4a536873c8c9b63..329426f2dab142c7c4a8429cc273e4aa85889418 100644 (file)
@@ -117,7 +117,7 @@ Bool_t AliRsnCutBetheBloch::IsSelected(TObject *object)
 //
 
   // dynamic cast the object into AliRsnDaughter
-  if (!TargetOK(object, AliRsnTarget::kDaughter)) return kFALSE;
+  if (!TargetOK(object)) return kFALSE;
 
   // retrieve the TPC signal
   AliRsnDaughter *track = fDaughter;
index 7032b3a7006819a3a67e864916a5b24f7ac1fdc9..0c03e74c91866186b1b81c1f538f139f037ddca6 100644 (file)
@@ -52,7 +52,7 @@ Bool_t AliRsnCutDaughterType::IsSelected(TObject *object)
 //
 
   // coherence check
-  if (!TargetOK(object, AliRsnTarget::kDaughter)) return kFALSE;
+  if (!TargetOK(object)) return kFALSE;
   
   // check the daughter according to the selected type
   // in some cases this means to retrieve the track status
index 7aeed5a1a6c8405521d6eb4da32d034d1b2bd4b7..838d4d883c9050adcbe22043cb4a117aadcdace4 100644 (file)
@@ -52,7 +52,7 @@ Bool_t AliRsnCutESDPrimary::IsSelected(TObject *object)
 //
 
   // coherence check
-  if (!TargetOK(object, AliRsnTarget::kDaughter)) return kFALSE;
+  if (!TargetOK(object)) return kFALSE;
   
   // retrieve the TPC signal
   AliRsnDaughter *daughter = fDaughter;
index 2a9b48d24e2ed336c1eb34a9482dbd0185fb57ee..7de65dd12fe68c347db20f559643a7ae83c76195 100644 (file)
@@ -44,7 +44,7 @@ class AliRsnCutManager : public TNamed
     AliRsnCutSet*  GetMotherCuts()         {return &fMotherCuts;}
     
     Bool_t         PassCommonDaughterCuts(AliRsnDaughter *daughter) {return fDaughterCutsCommon.IsSelected(daughter);}
-    Bool_t         PassDaughter1Cuts(AliRsnDaughter *daughter)      {return fDaughterCuts2.IsSelected(daughter);}
+    Bool_t         PassDaughter1Cuts(AliRsnDaughter *daughter)      {return fDaughterCuts1.IsSelected(daughter);}
     Bool_t         PassDaughter2Cuts(AliRsnDaughter *daughter)      {return fDaughterCuts2.IsSelected(daughter);}
     Bool_t         PassMotherCuts(AliRsnMother *mother)             {return fMotherCuts.IsSelected(mother);}
     Bool_t         PassSpecificDaughterCuts(Bool_t first, AliRsnDaughter *daughter)
index b34973bb3fb6391f640f5feb3fbb8468d9bf1cf7..16ca58577a9b0022a382a582cce6495787500783 100644 (file)
@@ -263,7 +263,7 @@ Bool_t AliRsnCutPID::IsSelected(TObject *object)
   
   // convert the object into the unique correct type
   
-  if (!TargetOK(object, AliRsnTarget::kDaughter))
+  if (!TargetOK(object))
   {
     AliError(Form("[%s]: this cut works only with AliRsnDaughter objects", GetName()));
     return kTRUE;
diff --git a/PWG2/RESONANCES/AliRsnCutPIDTOF.cxx b/PWG2/RESONANCES/AliRsnCutPIDTOF.cxx
new file mode 100644 (file)
index 0000000..dcfa886
--- /dev/null
@@ -0,0 +1,232 @@
+//
+// Class AliRsnCutPIDTOF
+//
+// General implementation of a single cut strategy, which can be:
+// - a value contained in a given interval  [--> IsBetween()   ]
+// - a value equal to a given reference     [--> MatchesValue()]
+//
+// In all cases, the reference value(s) is (are) given as data members
+// and each kind of cut requires a given value type (Int, UInt, Double),
+// but the cut check procedure is then automatized and chosen thanks to
+// an enumeration of the implemented cut types.
+// At the end, the user (or any other point which uses this object) has
+// to use the method IsSelected() to check if this cut has been passed.
+//
+// authors: Martin Vala (martin.vala@cern.ch)
+//          Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
+//
+
+#include <Riostream.h>
+
+#include "AliESDtrack.h"
+#include "AliAODTrack.h"
+#include "AliESDpid.h"
+#include "AliTOFT0maker.h"
+#include "AliTOFcalib.h"
+#include "AliCDBManager.h"
+#include "AliVTrack.h"
+
+#include "AliRsnEvent.h"
+#include "AliRsnDaughter.h"
+#include "AliRsnCutPIDTOF.h"
+
+ClassImp(AliRsnCutPIDTOF)
+
+//Bool_t         AliRsnCutPIDTOF::fgTOFcalibrateESD = kTRUE;
+Bool_t         AliRsnCutPIDTOF::fgTOFcorrectTExp  = kTRUE;
+Bool_t         AliRsnCutPIDTOF::fgTOFuseT0        = kTRUE;
+Bool_t         AliRsnCutPIDTOF::fgTOFtuneMC       = kFALSE;
+Double_t       AliRsnCutPIDTOF::fgTOFresolution   = 100.0;
+AliTOFT0maker* AliRsnCutPIDTOF::fgTOFmaker        = 0x0;
+AliTOFcalib*   AliRsnCutPIDTOF::fgTOFcalib        = 0x0;
+Int_t          AliRsnCutPIDTOF::fgLastRun         = -1;
+Int_t          AliRsnCutPIDTOF::fgLastEventID     = -1;
+AliESDEvent*   AliRsnCutPIDTOF::fgLastEvent       = 0x0;
+
+
+//_________________________________________________________________________________________________
+AliRsnCutPIDTOF::AliRsnCutPIDTOF(const char *name, Bool_t isMC, Double_t min, Double_t max) :
+  AliRsnCut(name, AliRsnCut::kDaughter, min, max),
+  fIsMC(isMC),
+  fPIDtype(AliPID::kPion),
+  fESDpid(),
+  fAODpid()
+{
+//
+// Default constructor.
+//
+}
+
+//_________________________________________________________________________________________________
+AliRsnCutPIDTOF::AliRsnCutPIDTOF(const AliRsnCutPIDTOF& copy) :
+  AliRsnCut(copy),
+  fIsMC(copy.fIsMC),
+  fPIDtype(copy.fPIDtype),
+  fESDpid(copy.fESDpid),
+  fAODpid(copy.fAODpid)
+{
+//
+// Copy constructor
+//
+}
+
+//_________________________________________________________________________________________________
+AliRsnCutPIDTOF& AliRsnCutPIDTOF::operator=(const AliRsnCutPIDTOF& copy)
+{
+//
+// Assignment operator
+//
+
+  fIsMC = copy.fIsMC;
+  fPIDtype = copy.fPIDtype;
+  fESDpid = copy.fESDpid;
+  fAODpid = copy.fAODpid;
+  
+  return (*this);
+}
+
+//_________________________________________________________________________________________________
+Bool_t AliRsnCutPIDTOF::IsSelected(TObject *object)
+{
+//
+// Cut checker.
+//
+
+  // coherence check
+  if (!TargetOK(object)) return kFALSE;
+  
+  // reject not TOF-matched tracks
+  // status is checked in the same way for all tracks
+  AliVTrack *vtrack = dynamic_cast<AliVTrack*>(fDaughter->GetRef());
+  if (!vtrack)
+  {
+    AliDebug(AliLog::kDebug + 2, Form("This object is not either an ESD nor AOD track, it is an %s", fDaughter->GetRef()->ClassName()));
+    return kFALSE;
+  }
+  ULong_t status = (ULong_t)vtrack->GetStatus();
+  if ((status & AliESDtrack::kTOFout) == 0 || (status & AliESDtrack::kTIME) == 0)
+  {
+    AliDebug(AliLog::kDebug + 2, "Track is not matched with TOF");
+    return kFALSE;
+  }
+  
+  // retrieve real object type
+  AliESDtrack *esdTrack = fDaughter->GetRefESDtrack();
+  AliAODTrack *aodTrack = fDaughter->GetRefAODtrack();
+  if (esdTrack) 
+  {
+    AliDebug(AliLog::kDebug + 2, "Checking an ESD track");
+    ProcessCurrentEvent();
+    return CheckESD(esdTrack);
+  }
+  else if (aodTrack)
+  {
+    AliDebug(AliLog::kDebug + 2, "Checking an AOD track");
+    return CheckAOD(aodTrack);
+  }
+  else
+  {
+    AliDebug(AliLog::kDebug + 2, Form("This object is not either an ESD nor AOD track, it is an %s", fDaughter->GetRef()->ClassName()));
+    return kFALSE;
+  }
+}
+
+//_________________________________________________________________________________________________
+void AliRsnCutPIDTOF::ProcessCurrentEvent()
+{
+//
+// Repeats the PID for current event.
+// In order to avoid to repeat the operation for each track
+// this function uses the data-member pointers to check
+// if current event was already processed or not.
+//
+
+  // get current event and skip if it is the same as before
+  AliESDEvent *esd = fgCurrentEvent->GetRefESD();
+  if (esd == fgLastEvent) return;
+  
+  // if event has changed, get run number and 
+  // reinitialize the calib and time maker
+  // if this has changed
+  Int_t run = esd->GetRunNumber();
+  if (run != fgLastRun)
+  {
+    AliInfo("============================================================================================");
+    AliInfo(Form("*** CHANGING RUN NUMBER: PREVIOUS = %d --> CURRENT = %d ***", fgLastRun, run));
+    AliInfo("============================================================================================");
+    fgLastRun = run;
+  
+    AliCDBManager::Instance()->SetDefaultStorage("raw://");
+    AliCDBManager::Instance()->SetRun(fgLastRun);
+    
+    if (fgTOFmaker) delete fgTOFmaker;
+    if (fgTOFcalib) delete fgTOFcalib;
+    
+    fgTOFcalib = new AliTOFcalib();
+    if (fIsMC)
+    {
+      fgTOFcalib->SetRemoveMeanT0(kFALSE);
+      fgTOFcalib->SetCalibrateTOFsignal(kFALSE);
+    }
+    else
+    {
+      fgTOFcalib->SetRemoveMeanT0(kTRUE);
+      fgTOFcalib->SetCalibrateTOFsignal(kTRUE);
+    }
+    if (fgTOFcorrectTExp) fgTOFcalib->SetCorrectTExp(kTRUE);
+    fgTOFcalib->Init();
+    
+    fgTOFmaker = new AliTOFT0maker(&fESDpid, fgTOFcalib);
+    fgTOFmaker->SetTimeResolution(fgTOFresolution);
+  }
+
+  // repeat the calibration and PID computations
+  /*if (fgTOFcalibrateESD)*/ fgTOFcalib->CalibrateESD(esd);
+  if (fgTOFtuneMC) fgTOFmaker->TuneForMC(esd);
+  if (fgTOFuseT0)
+  {
+    fgTOFmaker->ComputeT0TOF(esd);
+    fgTOFmaker->ApplyT0TOF(esd);
+    fESDpid.MakePID(esd, kFALSE, 0.);
+  }
+}
+
+//_________________________________________________________________________________________________
+Bool_t AliRsnCutPIDTOF::CheckESD(AliESDtrack *track)
+{
+//
+// Check TOF particle identification for ESD tracks.
+// Uses the AlifESDpid odata member.
+//
+
+  // require a minimum length to have meaningful match
+  if (track->GetIntegratedLength() < 350.) return kFALSE;
+  
+  // setup TOF PID response
+  AliTOFPIDResponse &tofrsp = fESDpid.GetTOFResponse();
+  
+  // get info for computation
+  Double_t momentum = track->P();
+  Double_t time     = track->GetTOFsignal();
+  Double_t timeint[AliPID::kSPECIES];
+  tofrsp.GetStartTime(momentum);
+  track->GetIntegratedTimes(timeint);
+  Double_t timeDiff = time - timeint[(Int_t)fPIDtype];
+  Double_t sigmaRef = tofrsp.GetExpectedSigma(momentum, timeint[(Int_t)fPIDtype], AliPID::ParticleMass(fPIDtype));
+  
+  // port values to standard AliRsnCut checker
+  fCutValueD = timeDiff / sigmaRef;
+  return OkRangeD();
+}
+
+//_________________________________________________________________________________________________
+Bool_t AliRsnCutPIDTOF::CheckAOD(AliAODTrack *track) 
+{
+//
+// check TOF particle identification for AOD tracks.
+// Uses the AliAODpidUtil data member.
+//
+
+  fCutValueD = (Double_t)fAODpid.NumberOfSigmasTOF(track, fPIDtype);
+  return OkRangeD();
+}
diff --git a/PWG2/RESONANCES/AliRsnCutPIDTOF.h b/PWG2/RESONANCES/AliRsnCutPIDTOF.h
new file mode 100644 (file)
index 0000000..ef4bfed
--- /dev/null
@@ -0,0 +1,63 @@
+//
+// Class AliRsnCutRange
+//
+// General implementation of cuts which check a value inside a range.
+// This range can be defined by two integers or two doubles.
+// A user-friendly enumeration allows to define what is checked.
+//
+// authors: Martin Vala (martin.vala@cern.ch)
+//          Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
+//
+
+#ifndef ALIRSNCUTPIDTOF_H
+#define ALIRSNCUTPIDTOF_H
+
+#include "AliPID.h"
+#include "AliESDpid.h"
+#include "AliAODpidUtil.h"
+
+class AliTOFT0maker;
+class AliTOFcalib;
+class AliESDtrack;
+class AliAODTrack;
+
+#include "AliRsnCut.h"
+
+class AliRsnCutPIDTOF : public AliRsnCut
+{
+  public:
+
+    AliRsnCutPIDTOF(const char *name = "cutPIDTOF", Bool_t isMC = kFALSE, Double_t min = -10.0, Double_t max = 10.0);
+    AliRsnCutPIDTOF(const AliRsnCutPIDTOF& copy);
+    AliRsnCutPIDTOF& operator=(const AliRsnCutPIDTOF& copy);
+    virtual ~AliRsnCutPIDTOF() { }
+    
+    void             SetMC(Bool_t yn = kTRUE) {fIsMC = yn;}
+    virtual Bool_t   IsSelected(TObject *object);
+
+  protected:
+  
+    void    ProcessCurrentEvent();
+    Bool_t  CheckESD(AliESDtrack *track);
+    Bool_t  CheckAOD(AliAODTrack *track);
+  
+    Bool_t                 fIsMC;             //  switch for MC analysis    
+    AliPID::EParticleType  fPIDtype;          //  particle type for which PID is checked   
+    AliESDpid              fESDpid;           //  PID utility for ESD
+    AliAODpidUtil          fAODpid;           //  PID utility for AOD
+    
+  //static Bool_t          fgTOFcalibrateESD; //! TOF settings
+    static Bool_t          fgTOFcorrectTExp;  //! TOF settings
+    static Bool_t          fgTOFuseT0;        //! TOF settings
+    static Bool_t          fgTOFtuneMC;       //! TOF settings
+    static Double_t        fgTOFresolution;   //! TOF settings
+    static AliTOFT0maker  *fgTOFmaker;        //! TOF time0 computator
+    static AliTOFcalib    *fgTOFcalib;        //! TOF calibration
+    static Int_t           fgLastRun;         //! last run number
+    static Int_t           fgLastEventID;     //! ID of last event processed
+    static AliESDEvent    *fgLastEvent;       //! pointer to last processed event
+
+    ClassDef(AliRsnCutPIDTOF, 1)
+};
+
+#endif
diff --git a/PWG2/RESONANCES/AliRsnCutTrackQuality.cxx b/PWG2/RESONANCES/AliRsnCutTrackQuality.cxx
new file mode 100644 (file)
index 0000000..b1f2061
--- /dev/null
@@ -0,0 +1,340 @@
+//
+// Class AliRsnCutTrackQuality
+//
+// General implementation of a single cut strategy, which can be:
+// - a value contained in a given interval  [--> IsBetween()   ]
+// - a value equal to a given reference     [--> MatchesValue()]
+//
+// In all cases, the reference value(s) is (are) given as data members
+// and each kind of cut requires a given value type (Int, UInt, Double),
+// but the cut check procedure is then automatized and chosen thanks to
+// an enumeration of the implemented cut types.
+// At the end, the user (or any other point which uses this object) has
+// to use the method IsSelected() to check if this cut has been passed.
+//
+// authors: Martin Vala (martin.vala@cern.ch)
+//          Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
+//
+
+#include <Riostream.h>
+#include <TFormula.h>
+#include <TBits.h>
+
+#include "AliLog.h"
+#include "AliESDtrack.h"
+#include "AliAODTrack.h"
+#include "AliESDtrackCuts.h"
+
+#include "AliRsnEvent.h"
+#include "AliRsnDaughter.h"
+#include "AliRsnCutTrackQuality.h"
+
+ClassImp(AliRsnCutTrackQuality)
+
+//_________________________________________________________________________________________________
+AliRsnCutTrackQuality::AliRsnCutTrackQuality(const char *name) :
+  AliRsnCut(name, AliRsnCut::kDaughter, 0.0, 0.0),
+  fFlags(0xFFFFFFFF),
+  fRejectKinkDaughter(kFALSE),
+  fDCARfixed(kTRUE),
+  fDCARptFormula(""),
+  fDCARmax(fgkVeryBig),
+  fDCAZfixed(kTRUE),
+  fDCAZptFormula(""),
+  fDCAZmax(fgkVeryBig),
+  fSPDminNClusters(0),
+  fITSminNClusters(0),
+  fITSmaxChi2(fgkVeryBig),
+  fTPCminNClusters(0),
+  fTPCmaxChi2(fgkVeryBig)
+{
+//
+// Default constructor.
+// Initializes all cuts in such a way that all of them are disabled.
+//
+
+  SetPtRange(0.0, fgkVeryBig);
+  SetEtaRange(-fgkVeryBig, fgkVeryBig);
+}
+
+//_________________________________________________________________________________________________
+AliRsnCutTrackQuality::AliRsnCutTrackQuality(const AliRsnCutTrackQuality &copy) :
+  AliRsnCut(copy),
+  fFlags(copy.fFlags),
+  fRejectKinkDaughter(copy.fRejectKinkDaughter),
+  fDCARfixed(copy.fDCARfixed),
+  fDCARptFormula(copy.fDCARptFormula),
+  fDCARmax(copy.fDCARmax),
+  fDCAZfixed(copy.fDCAZfixed),
+  fDCAZptFormula(copy.fDCAZptFormula),
+  fDCAZmax(copy.fDCAZmax),
+  fSPDminNClusters(copy.fSPDminNClusters),
+  fITSminNClusters(copy.fITSminNClusters),
+  fITSmaxChi2(copy.fITSmaxChi2),
+  fTPCminNClusters(copy.fTPCminNClusters),
+  fTPCmaxChi2(copy.fTPCmaxChi2)
+{
+//
+// Copy constructor.
+// Just copy all data member values.
+//
+
+  SetPtRange(copy.fPt[0], copy.fPt[1]);
+  SetEtaRange(copy.fEta[0], copy.fEta[1]);
+}
+
+//_________________________________________________________________________________________________
+AliRsnCutTrackQuality& AliRsnCutTrackQuality::operator=(const AliRsnCutTrackQuality &copy)
+{
+//
+// Assignment operator.
+// Just copy all data member values.
+//
+
+  
+  fFlags = copy.fFlags;
+  fRejectKinkDaughter = copy.fRejectKinkDaughter;
+  fDCARfixed = copy.fDCARfixed;
+  fDCARptFormula = copy.fDCARptFormula;
+  fDCARmax = copy.fDCARmax;
+  fDCAZfixed = copy.fDCAZfixed;
+  fDCAZptFormula = copy.fDCAZptFormula;
+  fDCAZmax = copy.fDCAZmax;
+  fSPDminNClusters = copy.fSPDminNClusters;
+  fITSminNClusters = copy.fITSminNClusters;
+  fITSmaxChi2 = copy.fITSmaxChi2;
+  fTPCminNClusters = copy.fTPCminNClusters;
+  fTPCmaxChi2 = copy.fTPCmaxChi2;
+
+  SetPtRange(copy.fPt[0], copy.fPt[1]);
+  SetEtaRange(copy.fEta[0], copy.fEta[1]);
+  
+  return (*this);
+}
+
+//_________________________________________________________________________________________________
+void AliRsnCutTrackQuality::DisableAll()
+{
+//
+// Disable all cuts
+//
+  
+  fFlags = 0xFFFFFFFF;
+  fRejectKinkDaughter = kFALSE;
+  fDCARfixed = kTRUE;
+  fDCARptFormula = "";
+  fDCARmax = fgkVeryBig;
+  fDCAZfixed = kTRUE;
+  fDCAZptFormula = "";
+  fDCAZmax = fgkVeryBig;
+  fSPDminNClusters = 0;
+  fITSminNClusters = 0;
+  fITSmaxChi2 = fgkVeryBig;
+  fTPCminNClusters = 0;
+  fTPCmaxChi2 = fgkVeryBig;
+
+  SetPtRange(0.0, fgkVeryBig);
+  SetEtaRange(-fgkVeryBig, fgkVeryBig);
+}
+
+//_________________________________________________________________________________________________
+Bool_t AliRsnCutTrackQuality::IsSelected(TObject *object)
+{
+//
+// Cut checker.
+// Checks the type of object being evaluated
+// and then calls the appropriate sub-function (for ESD or AOD)
+//
+
+  // coherence check
+  if (!TargetOK(object)) return kFALSE;
+  
+  // status is checked in the same way for all tracks
+  AliVTrack *vtrack = dynamic_cast<AliVTrack*>(fDaughter->GetRef());
+  if (!vtrack)
+  {
+    AliDebug(AliLog::kDebug + 2, Form("This object is not either an ESD nor AOD track, it is an %s", fDaughter->GetRef()->ClassName()));
+    return kFALSE;
+  }
+  ULong_t status = (ULong_t)vtrack->GetStatus();
+  ULong_t check  = status & fFlags;
+  if (check == 0)
+  {
+    AliDebug(AliLog::kDebug + 2, Form("Status cut non passed: required %lx, track has %lx", fFlags, status));
+    return kFALSE;
+  }
+  
+  // retrieve real object type
+  AliESDtrack *esdTrack = fDaughter->GetRefESDtrack();
+  AliAODTrack *aodTrack = fDaughter->GetRefAODtrack();
+  if (esdTrack) 
+  {
+    AliDebug(AliLog::kDebug + 2, "Checking an ESD track");
+    return CheckESD(esdTrack);
+  }
+  else if (aodTrack)
+  {
+    AliDebug(AliLog::kDebug + 2, "Checking an AOD track");
+    return CheckAOD(aodTrack);
+  }
+  else
+  {
+    AliDebug(AliLog::kDebug + 2, Form("This object is not either an ESD nor AOD track, it is an %s", fDaughter->GetRef()->ClassName()));
+    return kFALSE;
+  }
+}
+
+//_________________________________________________________________________________________________
+Bool_t AliRsnCutTrackQuality::CheckESD(AliESDtrack *track)
+{
+//
+// Check an ESD track.
+// This is done using the default track checker for ESD.
+// It is declared static, not to recreate it every time.
+//
+
+  static AliESDtrackCuts cuts;
+  
+  // general acceptance/pt cuts
+  cuts.SetPtRange (fPt[0], fPt[1]);
+  cuts.SetEtaRange(fEta[0], fEta[1]);
+  
+  // transverse DCA cuts
+  if (fDCARfixed)
+    cuts.SetMaxDCAToVertexXY(fDCARmax);
+  else
+    cuts.SetMaxDCAToVertexXYPtDep(fDCARptFormula.Data());
+    
+  // longitudinal DCA cuts
+  if (fDCAZfixed)
+    cuts.SetMaxDCAToVertexZ(fDCARmax);
+  else
+    cuts.SetMaxDCAToVertexZPtDep(fDCAZptFormula.Data());
+    
+  // these options are always disabled in currend version
+  cuts.SetDCAToVertex2D(kFALSE);
+  cuts.SetRequireSigmaToVertex(kFALSE);
+  
+  // TPC related cuts for TPC+ITS tracks
+  cuts.SetMinNClustersTPC(fTPCminNClusters);
+  cuts.SetMaxChi2PerClusterTPC(fTPCmaxChi2);
+  cuts.SetAcceptKinkDaughters(!fRejectKinkDaughter);
+  
+  // ITS related cuts for TPC+ITS tracks
+  if (fSPDminNClusters > 0)
+    cuts.SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
+  
+  // now that all is initialized, do the check
+  return cuts.IsSelected(track);
+}
+
+//_________________________________________________________________________________________________
+Bool_t AliRsnCutTrackQuality::CheckAOD(AliAODTrack *track)
+{
+//
+// Check an AOD track.
+// This is done doing directly all checks, since there is not
+// an equivalend checker for AOD tracks
+//
+  
+  // step #0: check SPD and ITS clusters
+  Int_t nSPD = 0;
+  nSPD  = TESTBIT(track->GetITSClusterMap(), 0);
+  nSPD += TESTBIT(track->GetITSClusterMap(), 1);
+  if (nSPD < fSPDminNClusters)
+  {
+    AliDebug(AliLog::kDebug + 2, "Not enough SPD clusters in this track. Rejected");
+    return kFALSE;
+  }
+
+  // step #1: check number of clusters in TPC
+  if (track->GetTPCNcls() < fTPCminNClusters)
+  {
+    AliDebug(AliLog::kDebug + 2, "Too few TPC clusters. Rejected");
+    return kFALSE;
+  }
+  if (track->GetITSNcls() < fITSminNClusters)
+  {
+    AliDebug(AliLog::kDebug + 2, "Too few ITS clusters. Rejected");
+    return kFALSE;
+  }
+  
+  // step #2: check chi square
+  if (track->Chi2perNDF() > fTPCmaxChi2)
+  {
+    AliDebug(AliLog::kDebug + 2, "Bad chi2. Rejected");
+    return kFALSE;
+  }
+  if (track->Chi2perNDF() > fITSmaxChi2)
+  {
+    AliDebug(AliLog::kDebug + 2, "Bad chi2. Rejected");
+    return kFALSE;
+  }
+  
+  // step #3: reject kink daughters
+  AliAODVertex *vertex = track->GetProdVertex();
+  if (vertex && fRejectKinkDaughter)
+  {
+    if (vertex->GetType() == AliAODVertex::kKink)
+    {
+      AliDebug(AliLog::kDebug + 2, "Kink daughter. Rejected");
+      return kFALSE;
+    }
+  }
+  
+  // step #4: DCA cut (transverse)
+  Double_t b[2], cov[3];
+  vertex = AliRsnTarget::GetCurrentEvent()->GetRefAOD()->GetPrimaryVertex();
+  if (!vertex)
+  {
+    AliDebug(AliLog::kDebug + 2, "NULL vertex");
+    return kFALSE;
+  }
+  if (!track->PropagateToDCA(vertex, AliRsnTarget::GetCurrentEvent()->GetRefAOD()->GetMagneticField(), kVeryBig, b, cov))
+  {
+    AliDebug(AliLog::kDebug + 2, "Failed propagation to vertex");
+    return kFALSE;
+  }
+  // if the DCA cut is not fixed, compute current value
+  if (!fDCARfixed)
+  {
+    static const TFormula dcaXY(Form("%s_dcaXY", GetName()), fDCARptFormula.Data());
+    fDCARmax = dcaXY.Eval(track->Pt());
+  }
+  // check the cut
+  if (TMath::Abs(b[0]) > fDCARmax)
+  {
+    AliDebug(AliLog::kDebug + 2, "Too large transverse DCA");
+    return kFALSE;
+  }
+  
+  // step #5: DCA cut (longitudinal)
+  // the DCA has already been computed above
+  // if the DCA cut is not fixed, compute current value
+  if (!fDCAZfixed)
+  {
+    static const TFormula dcaZ(Form("%s_dcaXY", GetName()), fDCAZptFormula.Data());
+    fDCAZmax = dcaZ.Eval(track->Pt());
+  }
+  // check the cut
+  if (TMath::Abs(b[1]) > fDCAZmax)
+  {
+    AliDebug(AliLog::kDebug + 2, "Too large longitudinal DCA");
+    return kFALSE;
+  }
+  
+  // step #6: check eta/pt range
+  if (track->Eta() < fEta[0] || track->Eta() > fEta[1])
+  {
+    AliDebug(AliLog::kDebug + 2, "Outside ETA acceptance");
+    return kFALSE;
+  }
+  if (track->Pt() < fPt[0] || track->Pt() > fPt[1])
+  {
+    AliDebug(AliLog::kDebug + 2, "Outside PT acceptance");
+    return kFALSE;
+  }
+  
+  // if we are here, all cuts were passed and no exit point was got
+  return kTRUE;
+}
diff --git a/PWG2/RESONANCES/AliRsnCutTrackQuality.h b/PWG2/RESONANCES/AliRsnCutTrackQuality.h
new file mode 100644 (file)
index 0000000..cdefa7d
--- /dev/null
@@ -0,0 +1,81 @@
+//
+// Class AliRsnCutRange
+//
+// General implementation of cuts which check a value inside a range.
+// This range can be defined by two integers or two doubles.
+// A user-friendly enumeration allows to define what is checked.
+//
+// authors: Martin Vala (martin.vala@cern.ch)
+//          Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
+//
+
+#ifndef ALIRSNCUTTRACKQUALITY_H
+#define ALIRSNCUTTRACKQUALITY_H
+
+#include <TMath.h>
+#include <TString.h>
+
+#include "AliRsnCut.h"
+
+class AliESDtrack;
+class AliAODTrack;
+
+class AliRsnCutTrackQuality : public AliRsnCut
+{
+  public:
+
+    AliRsnCutTrackQuality(const char *name = "AliRsncutTrackQuality");
+    AliRsnCutTrackQuality(const AliRsnCutTrackQuality& copy);
+    AliRsnCutTrackQuality& operator=(const AliRsnCutTrackQuality& copy);
+    virtual ~AliRsnCutTrackQuality() { }
+
+    void      DisableAll();
+    
+    void      AddStatusFlag(ULong_t flag)         {fFlags = fFlags | flag;}
+    void      SetStatusFlags(ULong_t flags)       {fFlags = flags;}
+    void      SetPtRange(Double_t a, Double_t b)  {fPt[0] = TMath::Min(a, b); fPt[1] = TMath::Max(a, b);}
+    void      SetEtaRange(Double_t a, Double_t b) {fEta[0] = TMath::Min(a, b); fEta[1] = TMath::Max(a, b);}
+    
+    void      SetDCARPtFormula(const char *formula) {fDCARptFormula = formula; fDCARptFormula.ReplaceAll("pt", "x"); fDCARfixed = kFALSE;}
+    void      SetDCARmax(Double_t value)            {fDCARmax = value; fDCARptFormula = ""; fDCARfixed = kTRUE;}
+    void      SetDCAZPtFormula(const char *formula) {fDCAZptFormula = formula; fDCAZptFormula.ReplaceAll("pt", "x"); fDCAZfixed = kFALSE;}
+    void      SetDCAZmax(Double_t value)            {fDCAZmax = value; fDCAZptFormula = ""; fDCAZfixed = kTRUE;}
+    
+    void      SetSPDminNClusters(Int_t value)       {fSPDminNClusters = value;}
+    void      SetITSminNClusters(Int_t value)       {fITSminNClusters = value;}
+    void      SetITSmaxChi2(Double_t value)         {fITSmaxChi2 = value;}
+    
+    void      SetTPCminNClusters(Int_t value)       {fTPCminNClusters = value;}
+    void      SetTPCmaxChi2(Double_t value)         {fTPCmaxChi2 = value;}
+    
+    virtual Bool_t IsSelected(TObject *obj);
+
+  protected:
+  
+    Bool_t     CheckESD(AliESDtrack *track);
+    Bool_t     CheckAOD(AliAODTrack *track);
+  
+    ULong_t    fFlags;              // required status flag (used AliESDtrack ones, connected with '|')
+    Double_t   fPt[2];              // pt range
+    Double_t   fEta[2];             // eta range
+    Bool_t     fRejectKinkDaughter; // switch to kTRUE if daughters of kinks must be rejected
+    
+    Bool_t     fDCARfixed;          // flag to switch between fixed and pt-dependent DCA cut
+    TString    fDCARptFormula;      // expression to compute transverse DCA sigma w.r. to pt
+    Double_t   fDCARmax;            // maximum value for transverse DCA
+    
+    Bool_t     fDCAZfixed;          // flag to switch between fixed and pt-dependent DCA cut
+    TString    fDCAZptFormula;      // expression to compute longitudinal DCA sigma w.r. to pt
+    Double_t   fDCAZmax;            // maximum value for longitudinal DCA
+    
+    Int_t      fSPDminNClusters;    // minimum number of required clusters in SPD
+    Int_t      fITSminNClusters;    // minimum number of required clusters in ITS
+    Double_t   fITSmaxChi2;         // maximum chi2 / number of clusters in ITS
+    
+    Int_t      fTPCminNClusters;    // minimum number of required clusters in TPC
+    Double_t   fTPCmaxChi2;         // maximum chi2 / number of clusters in TPC
+    
+    ClassDef(AliRsnCutTrackQuality, 1)
+};
+
+#endif
index 80b8bfe305371e13987a51913999188e42ce9027..0168708e7de4c3127ccd0eb1b24dfdeeaa8088f2 100644 (file)
@@ -20,8 +20,11 @@ ClassImp(AliRsnTarget)
 
 AliRsnEvent* AliRsnTarget::fgCurrentEvent = 0x0;
 
+const Double_t fgkVeryBig   = 1E+10;
+const Double_t fgkVerySmall = 1E-10;
+
 //_____________________________________________________________________________
-Bool_t AliRsnTarget::TargetOK(TObject *object, ETargetType ref)
+Bool_t AliRsnTarget::TargetOK(TObject *object)
 {
 //
 // This method compares the target type stored as data member
index a1235e871200ad8424bb1928134307eae53cc1ce..13d123e2c991578e237cde8c6ae21999dc417d2d 100644 (file)
@@ -42,7 +42,7 @@ class AliRsnTarget : public TNamed
     Char_t           GetTargetTypeChar() const;
     const char*      GetTargetTypeName() const;
     void             SetTargetType(ETargetType type)   {fTargetType = type;}
-    Bool_t           TargetOK(TObject *object, ETargetType ref);
+    Bool_t           TargetOK(TObject *object);
     AliRsnDaughter*  GetTargetDaughter()               {return fDaughter;}
     AliRsnMother*    GetTargetMother()                 {return fMother;}
     AliRsnEvent*     GetTargetEvent()                  {return fEvent;}
@@ -61,6 +61,9 @@ class AliRsnTarget : public TNamed
     AliRsnMother       *fMother;         //  utility pointer to target object (mother)
     AliRsnEvent        *fEvent;          //  utility pointer to target object (event)
     
+    static const Double_t fgkVeryBig;    //  utility value for very large value
+    static const Double_t fgkVerySmall;  //  utility value for very small value
+    
     // ROOT dictionary
     ClassDef(AliRsnTarget, 1)
 };
diff --git a/PWG2/RESONANCES/extra/AliAnalysisTaskSigma1385.C b/PWG2/RESONANCES/extra/AliAnalysisTaskSigma1385.C
new file mode 100644 (file)
index 0000000..12e6e83
--- /dev/null
@@ -0,0 +1,96 @@
+void AliAnalysisTaskSigma1385() {
+  TStopwatch timer;
+  timer.Start();
+
+  printf("*** Connect to AliEn ***\n");
+  TGrid::Connect("alien://");
+
+  gSystem->Load("libTree.so");
+  gSystem->Load("libGeom.so");
+  gSystem->Load("libVMC.so");
+  gSystem->Load("libPhysics.so");
+  //____________________________________________________//
+  //_____________Setting up required packages___________//
+  //____________________________________________________//
+  gSystem->Load("libSTEERBase.so");
+  gSystem->Load("libSTEER.so");
+  gSystem->Load("libESD.so");
+  gSystem->Load("libAOD.so");
+  gSystem->Load("libANALYSIS.so");
+  gSystem->Load("libANALYSISalice.so");
+  gROOT->ProcessLine(".include $ALICE_ROOT/include");
+  gROOT->ProcessLine(".include $ALICE_ROOT/TOF");
+  //ANALYSIS PART
+  gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
+  gROOT->LoadMacro("AliAnalysisTaskSigma1385.cxx+g");
+
+ const char *collectionfile = "sigmaLHC10d1.xml";
+
+  TAlienCollection * myCollection  = TAlienCollection::Open(collectionfile);
+
+  if (!myCollection) {
+        Error("AliAnalysisTaskSigma1385", Form("Cannot create an AliEn collection from %s", collectionfile)) ;
+    return kFALSE ;
+  }
+
+  Info("AliAnalysisTaskSigma1385", Form("Creating the analysis chain %s","esdTree")) ;
+  TChain* chain = new TChain("esdTree");
+
+  Info("AliAnalysisTaskSigma1385", "Preparing the file list") ;
+  myCollection->Reset() ;
+  while ( myCollection->Next() ) {
+    char esdFile[255] ;
+    sprintf(esdFile, "%s", myCollection->GetTURL("") ) ;
+    Info("AliAnalysisTaskSigma1385", Form("Adding %s", esdFile ) ) ;
+    chain->Add(esdFile) ;
+  }
+   
+  //____________________________________________//
+  // Make the analysis manager
+  AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");
+  AliVEventHandler* esdH = new AliESDInputHandler;
+  mgr->SetInputEventHandler(esdH);  
+
+  //____________________________________________//
+  // 1st Pt task
+  //AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection();
+  AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(kTRUE);
+  AliAnalysisTaskSigma1385 *task1 = new AliAnalysisTaskSigma1385("TaskSigma1385");
+
+
+  mgr->AddTask(task1);
+
+   task1->SetDataType("SIM");
+   task1->SelectCollisionCandidates();
+   
+   if ( !(strcmp(task1->GetDataType(),"SIM")) ){
+
+   AliMCEventHandler *mc = new AliMCEventHandler();
+   mc->SetReadTR(kFALSE);
+   mgr->SetMCtruthEventHandler(mc);
+   }
+   mgr->SetDebugLevel(10);
+  
+  
+  
+  //------ input data ------
+  AliAnalysisDataContainer *cinput0 = mgr->GetCommonInputContainer();
+
+  // ----- output data -----
+  
+  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("chist1", TList::Class(),AliAnalysisManager::kOutputContainer,"Sigma.ESD.root");
+  
+  //____________________________________________//
+
+  mgr->ConnectInput(task1,0,cinput0);
+  mgr->ConnectOutput(task1,1,coutput1);
+  if (!mgr->InitAnalysis()) return;
+  mgr->PrintStatus();
+  mgr->StartAnalysis("local",chain);
+
+  timer.Stop();
+  timer.Print();
+}
diff --git a/PWG2/RESONANCES/extra/AliAnalysisTaskSigma1385.cxx b/PWG2/RESONANCES/extra/AliAnalysisTaskSigma1385.cxx
new file mode 100644 (file)
index 0000000..0763aca
--- /dev/null
@@ -0,0 +1,773 @@
+/**************************************************************************
+ * Authors : Massimo Venaruzzo (massimo.venaruzzo@ts.infn.it)             *
+ *          Enrico Fragiacomo (enrico.fragiacomo@ts.infn.it)             *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+//-----------------------------------------------------------------
+//                 AliAnalysisTaskSigma1385 class
+//-----------------------------------------------------------------
+
+class TTree;
+class TParticle;
+class TVector3;
+
+#include "AliAnalysisManager.h"
+#include <AliMCEventHandler.h>
+#include <AliMCEvent.h>
+#include <AliStack.h>
+
+class AliESDVertex;
+class AliESDv0;
+class AliAODv0;
+
+#include <iostream>
+
+#include "TList.h"
+#include "TH1.h"
+#include "TNtuple.h"
+#include "TGraph.h"
+#include "TCanvas.h"
+#include "TMath.h"
+#include "TChain.h"
+#include "AliLog.h"
+#include "AliESDEvent.h"
+#include "AliAODEvent.h"
+#include "AliCascadeVertexer.h"
+#include "AliESDcascade.h"
+#include "AliAODcascade.h"
+#include "AliAnalysisTaskSigma1385.h"
+#include "AliESDtrackCuts.h"
+
+ClassImp(AliAnalysisTaskSigma1385)
+    
+//________________________________________________________________________
+  AliAnalysisTaskSigma1385::AliAnalysisTaskSigma1385() 
+    : AliAnalysisTaskSE(), fAnalysisType("ESD"), fCollidingSystems(0), fDataType("REAL"),
+      fListHistCascade(0), fHistEventMultiplicity(0), fHistEventMultiplicityRAVS(0), fNtuple1(0), fNtuple2(0),fNtuple3(0), fNtuple4(0),
+      
+      //-------------------------------- For PID
+      
+  fIsMC(isMC),
+  fCheckITS(kTRUE),
+  fCheckTPC(kTRUE),
+  fCheckTOF(kTRUE),
+  fUseGlobal(kTRUE),
+  fUseITSSA(kTRUE),
+  fMaxITSband(3.0),
+  fTPCpLimit(0.35),
+  fMinTPCband(3.0),
+  fMaxTPCband(5.0),
+  fESDpid(0x0),
+  fTOFmaker(0x0),
+  fTOFcalib(0x0),
+  fTOFcalibrateESD(!isMC),
+  fTOFcorrectTExp(kTRUE),
+  fTOFuseT0(kTRUE),
+  fTOFtuneMC(isMC),
+  fTOFresolution(100.0),
+  fMinTOF(-2.5),
+  fMaxTOF( 3.5),
+  fLastRun(-1)
+      
+      //-------------------------------- 
+      
+{
+  // Dummy Constructor 
+}
+
+//________________________________________________________________________
+AliAnalysisTaskSigma1385::AliAnalysisTaskSigma1385(const char *name) 
+  : AliAnalysisTaskSE(name), fAnalysisType("ESD"), fCollidingSystems(0),fDataType("REAL"),     
+    fListHistCascade(0), fHistEventMultiplicity(0), fHistEventMultiplicityRAVS(0), fNtuple1(0), fNtuple2(0), fNtuple3(0), fNtuple4(0),
+    
+        //-------------------------------- For PID
+      
+  fIsMC(isMC),
+  fCheckITS(kTRUE),
+  fCheckTPC(kTRUE),
+  fCheckTOF(kTRUE),
+  fUseGlobal(kTRUE),
+  fUseITSSA(kTRUE),
+  fMaxITSband(3.0),
+  fTPCpLimit(0.35),
+  fMinTPCband(3.0),
+  fMaxTPCband(5.0),
+  fESDpid(0x0),
+  fTOFmaker(0x0),
+  fTOFcalib(0x0),
+  fTOFcalibrateESD(!isMC),
+  fTOFcorrectTExp(kTRUE),
+  fTOFuseT0(kTRUE),
+  fTOFtuneMC(isMC),
+  fTOFresolution(100.0),
+  fMinTOF(-2.5),
+  fMaxTOF( 3.5),
+  fLastRun(-1)
+      
+      //-------------------------------- 
+{
+
+  // Output slot #0 writes into a TList container (Cascade)
+  DefineOutput(1, TList::Class());
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskSigma1385::UserCreateOutputObjects()
+{
+  fListHistCascade = new TList();
+  
+  if(! fHistEventMultiplicity ){
+    fHistEventMultiplicity   = new TH1F( "fHistEventMultiplicity" , "Nb of Events" , 4, -1.0, 3.0 );
+    fListHistCascade->Add(fHistEventMultiplicity);
+  }
+  
+   if(! fHistEventMultiplicityRAVS ){
+    fHistEventMultiplicityRAVS   = new TH1F( "fHistEventMultiplicityRAVS" , "Nb of Events Rejected After Vertex selection" , 4, -1.0, 3.0 );
+    fListHistCascade->Add(fHistEventMultiplicityRAVS);
+  }
+  
+  if(! fNtuple1 ) {
+    fNtuple1 = new TNtuple("fNtuple1","Ntuple1","TrkNmb");
+    fNtuple1->SetDirectory(0);
+    fListHistCascade->Add(fNtuple1);
+  }
+  
+  if(! fNtuple2 ) {
+    fNtuple2 = new TNtuple("fNtuple2","Ntuple2","s:dcal:lCosPoinAn:lDaugDCA:lambdap:lambdapt:lambdamass");
+    fNtuple2->SetDirectory(0);
+    fListHistCascade->Add(fNtuple2);
+  }
+  
+  if(! fNtuple3 ) {
+    fNtuple3 = new TNtuple("fNtuple3","Ntuple3","c:dcapi:ppi:ptpi:bachphi:bachtheta:okPiTPC:okPiTOF");
+    fNtuple3->SetDirectory(0);
+    fListHistCascade->Add(fNtuple3);
+  }
+  
+  if(! fNtuple4 ) {
+    fNtuple4 = new TNtuple("fNtuple4","Ntuple4","dca:mc:phi:theta:eta:y:pt:p:opang:invmass");
+    fListHistCascade->Add(fNtuple4);
+  }
+  
+    
+}// end UserCreateOutputObjects
+
+
+//________________________________________________________________________
+void AliAnalysisTaskSigma1385::UserExec(Option_t *) 
+{
+
+  // Main loop
+  // Called for each event
+  
+  
+  Info("AliAnalysisTaskSigma1385","Starting UserExec");  
+  
+  AliMCEventHandler* eventHandler;
+  AliMCEvent* mcEvent;
+  
+  if(fDataType == "SIM") {
+  
+  eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
+  if (!eventHandler) {
+  Printf("ERROR: Could not retrieve MC event handler");
+    return;
+  }
+  
+  mcEvent = eventHandler->MCEvent();
+  if (!mcEvent) {
+    Printf("ERROR: Could not retrieve MC event");
+    return;
+  }
+  
+  }
+  
+  AliStack* stack;
+  if(fDataType == "SIM") {stack = mcEvent->Stack(); fIsMC=1; isMC=1;}
+
+  AliESDEvent *lESDevent = 0x0;
+  AliAODEvent *lAODevent = 0x0;
+  
+  
+  // Connect to the InputEvent  
+  Int_t ncascades = -1;
+  if(fAnalysisType == "ESD"){
+    lESDevent = dynamic_cast<AliESDEvent*>( InputEvent() );
+    if (!lESDevent) {
+      Printf("ERROR: lESDevent not available \n");
+      return;
+    }
+    ncascades = lESDevent->GetNumberOfCascades();
+  }
+  
+  if(fAnalysisType == "AOD"){  
+    lAODevent = dynamic_cast<AliAODEvent*>( InputEvent() ); 
+    if (!lAODevent) {
+      Printf("ERROR: lAODevent not available \n");
+      return;
+    }
+    ncascades = lAODevent->GetNumberOfCascades();
+  }
+  
+  
+  //------------------------------for PID
+  
+    SetCheckITS(kTRUE);
+    SetCheckTPC(kTRUE);
+    SetCheckTOF(kTRUE);
+
+ // ----> set TPC range for PID and calibration
+  SetTPCrange(5.0, 3.0);
+  SetTPCpLimit(0.35);
+  
+  // ----> set ITS range for PID
+  SetITSband(4.0);
+  
+  // ----> set TPC calibration
+  if (fDataType=="SIM") SetTPCpar(2.15898 / 50.0, 1.75295E1, 3.40030E-9, 1.96178, 3.91720);
+  else       SetTPCpar(1.41543 / 50.0, 2.63394E1, 5.0411E-11, 2.12543, 4.88663);
+  
+  // ----> set the TOF calibration depending on type of input (sim/data)
+  SetTOFcorrectTExp(kTRUE);
+  SetTOFuseT0(kTRUE);
+  SetTOFresolution(100.0);
+  if (fDataType=="SIM")
+  {
+    SetTOFcalibrateESD(kFALSE);
+    SetTOFtuneMC(kTRUE);
+  }
+  else
+  {
+    
+    SetTOFcalibrateESD(kTRUE);
+    SetTOFtuneMC(kFALSE);
+  }
+
+  
+   if (!fESDpid)
+  {
+    fESDpid = new AliESDpid;
+    fESDpid->GetTPCResponse().SetBetheBlochParameters(fTPCpar[0],fTPCpar[1],fTPCpar[2],fTPCpar[3],fTPCpar[4]);
+  }
+  
+  // initialize DB to current run
+  Int_t run = lESDevent->GetRunNumber();
+  if (run != fLastRun)
+  {
+    cout << "Run = " << run << " -- LAST = " << fLastRun << endl;
+    fLastRun = run;
+    
+    // setup TOF maker & calibration
+    if (!fTOFcalib) fTOFcalib = new AliTOFcalib;
+    fTOFcalib->SetCorrectTExp(fTOFcorrectTExp);
+    if (!fTOFmaker) fTOFmaker = new AliTOFT0maker(fESDpid, fTOFcalib);
+    fTOFmaker->SetTimeResolution(fTOFresolution);
+      
+    AliCDBManager *cdb = AliCDBManager::Instance();
+    cdb->ClearCache(); // suggestion by Annalisa
+    cdb->Clear();      // suggestion by Annalisa
+    cdb->SetDefaultStorage("raw://");
+    cdb->SetRun(run);
+    fTOFcalib->SetCorrectTExp(fTOFcorrectTExp);
+    fTOFcalib->Init();
+  }
+  
+  // if required, calibrate the TOF t0 maker with current event
+  if (fTOFcalibrateESD) fTOFcalib->CalibrateESD(lESDevent);
+  if (fTOFtuneMC) fTOFmaker->TuneForMC(lESDevent);
+  if (fTOFuseT0) 
+  {
+    fTOFmaker->ComputeT0TOF(lESDevent);
+    fTOFmaker->ApplyT0TOF(lESDevent);
+    fESDpid->MakePID(lESDevent, kFALSE, 0.);
+  }
+  
+  
+  //--------------------------------------------------------
+  
+
+  fHistEventMultiplicity->Fill(1);
+
+  //Some Quantities to characterize the event
+  
+  Double_t b = lESDevent->GetMagneticField();
+  Int_t TrackNumber = lESDevent->GetNumberOfTracks();
+
+  
+  //---------------------------
+  // new part from AliCascadeVertexer (use vertexer for reconstructing Sigma(1385)
+  //
+  //const AliESDVertex *vtxT3D=lESDevent->GetPrimaryVertex();  
+  const AliESDVertex *vtxT3D=lESDevent->GetPrimaryVertexTracks();
+       if(vtxT3D->GetNContributors()<1) {
+       // SPD vertex
+       vtxT3D= lESDevent->GetPrimaryVertexSPD();
+               if(vtxT3D->GetNContributors()<1){ 
+               
+               
+               fHistEventMultiplicityRAVS->Fill(1);
+               return;
+               }
+               
+                                       
+       }
+
+  Double_t xPrimaryVertex=vtxT3D->GetXv();
+  Double_t yPrimaryVertex=vtxT3D->GetYv();
+  Double_t zPrimaryVertex=vtxT3D->GetZv();  
+
+ if ( zPrimaryVertex>10 || zPrimaryVertex<-10)  return;
+  
+  //-------------------------------------------------------
+  // New Part about tracks global selection criteria
+  //-------------------------------------------------------
+  
+  AliESDtrackCuts* esdTrackCuts = new AliESDtrackCuts("AliESDtrackCuts");
+
+  esdTrackCuts->SetAcceptKinkDaughters(0); // 0 = kFalse
+  esdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
+  esdTrackCuts->SetMaxChi2PerClusterTPC(4);
+  esdTrackCuts->SetMinNClustersTPC(70);
+
+  
+  //-------------------------------------------------------
+  // loops over V0s
+  //stores relevant V0s in an array
+  Int_t nV0=(Int_t)lESDevent->GetNumberOfV0s();
+  
+  TObjArray vtcs(nV0);
+  for (Int_t i=0; i<nV0; i++) {
+    AliESDv0 *v=lESDevent->GetV0(i);
+    if (v->GetOnFlyStatus()) continue; // if kTRUE, then this V0 is recontructed
+    
+    vtcs.AddLast(v);
+  }
+  nV0=vtcs.GetEntriesFast();
+
+  //-------------------------------------------------------
+  // loops over bachelor tracks
+  // stores relevant tracks in another array
+  
+  Int_t nentr=(Int_t)lESDevent->GetNumberOfTracks();
+  TArrayI trk(nentr); Int_t ntr=0;
+
+  for (Int_t i=0; i<nentr; i++) {
+    AliESDtrack *esdtr=lESDevent->GetTrack(i);
+      
+    if ( !(esdtr->GetStatus() & AliESDtrack::kITSrefit) ) continue;
+    if ( !(esdtr->GetStatus() & AliESDtrack::kTPCrefit) ) continue;
+    
+    
+    if (! (esdTrackCuts->AcceptTrack(esdtr)) ) continue;
+    
+    trk[ntr++]=i;
+  }   
+  
+
+  
+  //-----------------------------------------------------
+  // nested loops over V0s and bachelors
+  Float_t massLambda = 1.11568;
+  Int_t ncasc=0;
+  AliCascadeVertexer *cascvert = new AliCascadeVertexer();  
+  for (Int_t i=0; i<nV0; i++) { //loop on V0s
+    
+    // Lambda 
+    AliESDv0 *v=(AliESDv0*)vtcs.UncheckedAt(i);    
+    Int_t strness=0;
+    Double_t lambdaMass = 0;
+    Float_t lambdaP = 0;
+    Float_t lambdaPt = 0;
+    Float_t LambdaDCA = 0; // DCA between Lambda and Primary Vertex
+    Double_t v0cospointangle = 0;
+    Float_t v0daughtersDCA = 0;
+
+      
+    // Lambda quality cuts
+    UInt_t lIdxPosXi   = (UInt_t) TMath::Abs( v->GetPindex() );
+    UInt_t lIdxNegXi   = (UInt_t) TMath::Abs( v->GetNindex() );
+    
+    AliESDtrack *pTrackXi              = lESDevent->GetTrack( lIdxPosXi );
+    AliESDtrack *nTrackXi              = lESDevent->GetTrack( lIdxNegXi );
+    
+    // Filter like-sign V0
+    if ( pTrackXi->GetSign() == nTrackXi->GetSign()) continue; 
+    
+    // WARNING: the following selections cannot be done for AOD yet...
+
+    
+    v->ChangeMassHypothesis(kLambda0); // the v0 must be Lambda 
+
+    
+    if ( (TMath::Abs(v->GetEffMass()-massLambda))<0.1) {
+    
+        if( !(pTrackXi->GetStatus() & AliESDtrack::kTPCrefit))  continue;     
+       if( !(nTrackXi->GetStatus() & AliESDtrack::kTPCrefit))  continue;
+    
+    
+       if( (pTrackXi->GetTPCNcls() ) < 70) continue;   
+       if( (nTrackXi->GetTPCNcls() ) < 70) continue;
+    
+       strness=1; lambdaMass = v->GetEffMass(); lambdaP = v->P(); lambdaPt = v->Pt(); LambdaDCA = v->GetD(xPrimaryVertex,yPrimaryVertex,zPrimaryVertex); v0cospointangle = v->GetV0CosineOfPointingAngle(); v0daughtersDCA = v->GetDcaV0Daughters();
+    
+
+    
+    }
+    
+    
+    v->ChangeMassHypothesis(kLambda0Bar); // the v0 must be Anti Lambda 
+    
+
+    
+    if ( (TMath::Abs(v->GetEffMass()-massLambda))<0.1) {
+    
+       if( !(pTrackXi->GetStatus() & AliESDtrack::kTPCrefit))  continue;     
+       if( !(nTrackXi->GetStatus() & AliESDtrack::kTPCrefit))  continue;
+    
+    
+       if( (pTrackXi->GetTPCNcls() ) < 70) continue;   
+       if( (nTrackXi->GetTPCNcls() ) < 70) continue;
+    
+       Int_t temp=strness+1; strness=-1*temp; lambdaMass = v->GetEffMass(); lambdaP = v->P(); lambdaPt = v->Pt(); LambdaDCA = v->GetD(xPrimaryVertex,yPrimaryVertex,zPrimaryVertex); v0cospointangle = v->GetV0CosineOfPointingAngle(); v0daughtersDCA = v->GetDcaV0Daughters();
+    
+    
+    }
+    
+    if(strness==0) continue;
+
+    for (Int_t j=0; j<ntr; j++) {//loop on tracks
+      
+      // Pion bachelor
+      Int_t bidx=trk[j]; 
+      Int_t bachTPCcls=0;
+      
+      
+      if ((bidx==v->GetIndex(0))||(bidx==v->GetIndex(1))) continue; // bach and V0's daughter's must be different!
+      
+      AliESDtrack *btrk=lESDevent->GetTrack(bidx);
+      if ( !(btrk->GetStatus() & AliESDtrack::kTPCrefit) ) continue;
+      
+      if ( (bachTPCcls=btrk->GetTPCNcls()) <70) continue; 
+      
+      Bool_t *IsOkTrack = IsSelected(btrk); //for Alberto's PID
+      
+      Bool_t *okTrack = new Bool_t[5];
+      
+      for(Int_t k=0; k<5; k++) okTrack[k]=IsOkTrack[k];
+         
+      
+      Int_t BachCharge = btrk->Charge();
+      Float_t PionDCA = TMath::Abs(btrk->GetD(xPrimaryVertex,yPrimaryVertex,b)); // DCA between Bachelor and Primary Vertex 
+          
+      Double_t bachphi = btrk->Phi();
+      Double_t bachtheta = btrk->Theta();
+      Double_t bachmass = 0.13957;
+      Double_t bachp = btrk->GetP();
+      Double_t bachpt = btrk->Pt();
+      
+      
+      // Distance between Lambda and Pion bachelor
+      AliESDv0 v0(*v), *pv0=&v0;
+      AliExternalTrackParam bt(*btrk), *pbt=&bt;      
+      Double_t dca=cascvert->PropagateToDCA(pv0,pbt,b); // distance bwn V0 and bach (in cm)
+      if (dca > 10.0) continue;  // Note: was 0.1! Enlarged->further filter in second pass analysis
+      
+      
+      AliESDcascade cascade(*pv0,*pbt,bidx);//constucts a sigma1385 candidate
+      AliESDcascade *xi = &cascade;
+      
+     
+      UInt_t lBachIdx  = (UInt_t) TMath::Abs( xi->GetBindex() );
+      AliESDtrack *bachTrackXi = lESDevent->GetTrack( lBachIdx );
+            
+           
+      
+      Bool_t MCtrue=0;
+      if(fDataType == "SIM") {
+       
+       Int_t pLabel    = TMath::Abs(pTrackXi->GetLabel());
+       Int_t nLabel    = TMath::Abs(nTrackXi->GetLabel());
+       Int_t bachLabel = TMath::Abs(bachTrackXi->GetLabel());
+       
+       Int_t motherpLabel = stack->Particle(pLabel)->GetFirstMother();
+       Int_t mothernLabel = stack->Particle(nLabel)->GetFirstMother();
+       Int_t motherbachLabel = stack->Particle(bachLabel)->GetFirstMother();
+       
+       
+       //cout<< "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"<<endl;
+       //cout<< "plabel " << pLabel << " nlabel " << nLabel << " mother p " << motherpLabel << " mother n " << mothernLabel << " bachlabel " << bachLabel << " mother bach " << motherbachLabel << endl;
+       //cout<< "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"<<endl; 
+       
+       if (motherpLabel>-1 && mothernLabel>-1) {
+         TParticle *plambda = stack->Particle(motherpLabel);
+         Int_t grandmother = plambda->GetFirstMother();
+         
+         motherpLabel = TMath::Abs(motherpLabel);
+         mothernLabel = TMath::Abs(mothernLabel);
+         //motherbachLabel = TMath::Abs(motherbachLabel);
+                 
+       //cout<< "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"<<endl;
+       //cout<< "plabel " << pLabel << " nlabel " << nLabel << " mother p " << motherpLabel << " mother n " << mothernLabel << " mother lambda " << grandmother << " bachlabel " << bachLabel << " mother bach " << motherbachLabel << endl;
+       //cout<< "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"<<endl;           
+                 
+         if (motherbachLabel >-1){
+         
+         
+       //cout<< "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"<<endl;
+       //cout<< "mother lambda " << grandmother << " mother bach " << motherbachLabel << " PDG Code "<< stack->Particle(grandmother)->GetPdgCode() << endl;
+       //cout<< "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"<<endl; 
+           
+           if( (motherpLabel==mothernLabel) && (grandmother==motherbachLabel) &&
+                       ( (TMath::Abs(stack->Particle(grandmother)->GetPdgCode())==3114) ||
+                 (TMath::Abs(stack->Particle(grandmother)->GetPdgCode())==3224) ) ) MCtrue=1;
+           
+           }
+         
+       }
+
+      }
+      
+      Double_t lBachMomX       = 0., lBachMomY  = 0., lBachMomZ   = 0.;
+      Double_t lPMom[3]= {0.,0.,0.,};
+      Double_t lNMom[3]= {0.,0.,0.,};
+      Float_t lLambdaMomX       = 0., lLambdaMomY  = 0., lLambdaMomZ   = 0.;
+      xi->GetBPxPyPz(  lBachMomX,  lBachMomY,  lBachMomZ );
+      xi->GetPPxPyPz(  lPMom[0],  lPMom[1],  lPMom[2] );
+      xi->GetNPxPyPz(  lNMom[0],  lNMom[1],  lNMom[2] );
+      lLambdaMomX=lPMom[0]+lNMom[0];
+      lLambdaMomY=lPMom[1]+lNMom[1];
+      lLambdaMomZ=lPMom[2]+lNMom[2];
+      
+      Float_t  lRapXi    = xi->RapXi();
+      Float_t  lEta      = xi->Eta();
+      Float_t  lTheta    = xi->Theta();
+      Float_t  lPhi      = xi->Phi();  
+      Float_t  lPt       = xi->Pt();
+      Float_t   lP       = xi->P();
+      
+      // Support variables for invariant mass calculation
+      TLorentzVector Lambda, Pion, Sigma;
+      Double_t Elambda = TMath::Sqrt( lLambdaMomX*lLambdaMomX + lLambdaMomY*lLambdaMomY + lLambdaMomZ*lLambdaMomZ + lambdaMass*lambdaMass );
+      Double_t Epion = TMath::Sqrt( lBachMomX*lBachMomX + lBachMomY*lBachMomY + lBachMomZ*lBachMomZ + bachmass*bachmass) ;
+   
+      Lambda.SetPxPyPzE(lLambdaMomX, lLambdaMomY, lLambdaMomZ, Elambda);
+      Pion.SetPxPyPzE(lBachMomX, lBachMomY, lBachMomZ, Epion);
+   
+      Sigma = Lambda + Pion;
+   
+      Double_t openingangle, invmass=0;
+      
+      openingangle = TMath::ACos( ( lBachMomX*lLambdaMomX + lBachMomY*lLambdaMomY + lBachMomZ*lLambdaMomZ ) / (  (TMath::Sqrt( lBachMomX*lBachMomX + lBachMomY*lBachMomY + lBachMomZ*lBachMomZ )) *(TMath::Sqrt( lLambdaMomX*lLambdaMomX + lLambdaMomY*lLambdaMomY +
+      lLambdaMomZ*lLambdaMomZ ) ) ) );
+      
+      invmass = Sigma.M();
+      
+
+      fNtuple1->Fill( TrackNumber ); 
+      fNtuple2->Fill( (1.*strness), LambdaDCA, v0cospointangle, v0daughtersDCA , lambdaP, lambdaPt, lambdaMass  );
+      fNtuple3->Fill( (1.*BachCharge), PionDCA, bachp, bachpt, bachphi, bachtheta, okTrack[1], okTrack[2]);
+      fNtuple4->Fill( dca, (1.*MCtrue), lPhi, lTheta, lEta, lRapXi, lPt, lP, openingangle, invmass);
+      
+      ncasc++;
+      
+  delete IsOkTrack;
+  delete okTrack;
+  
+      
+    } // end loop tracks
+  } // end loop V0s
+  
+  Info("AliAnalysisTaskSigma1385","Number of reconstructed Sigma(1385): %d",ncasc);
+  
+
+  // Post output data.
+  PostData(1, fListHistCascade);
+  
+}
+
+//________________________________________________________________________
+
+Bool_t *AliAnalysisTaskSigma1385::IsSelected(AliESDtrack *track)
+{
+//
+//
+  Bool_t *okTrack = new Bool_t[5];
+    
+  for (Int_t i=0; i<5; i++) okTrack[i]=kFALSE;
+  
+  
+  AliITSPIDResponse itsrsp(fIsMC);
+  
+  
+  ULong_t  status;
+  Int_t    k, nITS;
+  Double_t times[10], tpcNSigma, tpcMaxNSigma, itsSignal, itsNSigma, mom, tofTime, tofSigma, tofRef, tofRel;
+  Bool_t   okTOF= kFALSE;
+  Bool_t   okTPC= kFALSE;
+  Bool_t   okITS= kFALSE;
+  Bool_t   isTPC= kFALSE; 
+  Bool_t   isITSSA= kFALSE; 
+  Bool_t   isTOF= kFALSE;
+  UChar_t  itsCluMap;
+  
+  // get commonly used variables
+  status  = (ULong_t)track->GetStatus();
+  mom     = track->P();
+  isTPC   = ((status & AliESDtrack::kTPCin)  != 0);
+  isITSSA = ((status & AliESDtrack::kTPCin)  == 0 && (status & AliESDtrack::kITSrefit) != 0 && (status & AliESDtrack::kITSpureSA) == 0 && (status & AliESDtrack::kITSpid) != 0);
+  isTOF   = (((status & AliESDtrack::kTOFout) != 0) && ((status & AliESDtrack::kTIME) != 0) /* && mom > TMath::Max(b1, b2)*/);
+  
+  
+  // check if the track type matches what is required
+  if (!isTPC && !isITSSA) 
+  {
+    AliDebug(AliLog::kDebug + 2, "Track is not either a TPC track or a ITS standalone. Rejected");
+    return okTrack;
+    
+  }
+  else if (isTPC && !fUseGlobal)
+  {
+    AliDebug(AliLog::kDebug + 2, "Global tracks not used. Rejected");
+    return okTrack;
+    
+  }
+  else if (isITSSA && !fUseITSSA)
+  {
+    AliDebug(AliLog::kDebug + 2, "ITS standalone not used. Rejected");
+    return okTrack;
+    
+  }
+  
+  // does a preliminary check on TOF values, if necessary
+  // then, if the reference time or TOF signal are meaningless
+  // even if the 'isTOF' flag is true, switch it to false
+  if (isTOF)
+  {
+    track->GetIntegratedTimes(times);
+    tofTime  = (Double_t)track->GetTOFsignal();
+    tofSigma = fTOFmaker->GetExpectedSigma(mom, times[AliPID::kPion], AliPID::ParticleMass(AliPID::kPion));
+    tofRef   = times[AliPID::kPion];
+    if (tofRef <= 0.0 && tofSigma <= 0.0) isTOF = kFALSE;
+  }
+  
+
+  
+    // check TPC dE/dx
+      if (isTPC) // this branch is entered by all global tracks
+  {
+    // check TPC dE/dx:
+    if (fCheckTPC)
+    {
+      tpcNSigma = TMath::Abs(fESDpid->NumberOfSigmasTPC(track, AliPID::kPion));
+      if (track->GetInnerParam()->P() > fTPCpLimit) tpcMaxNSigma = fMinTPCband; else tpcMaxNSigma = fMaxTPCband;
+      okTPC = (tpcNSigma <= tpcMaxNSigma);
+      AliDebug(AliLog::kDebug + 2, Form("TPC nsigma = %f -- max = %f -- cut %s", tpcNSigma, tpcMaxNSigma, (okTPC ? "passed" : "failed")));
+    }
+    else
+    {
+      // if TPC is not checked, it is as if all tracks do pass the cut
+      okTPC = kTRUE;
+      AliDebug(AliLog::kDebug + 2, "TPC not checked, track accepted");
+    }
+      
+    // check TOF (only if flags are OK)
+    if (fCheckTOF)
+    {
+      if (isTOF)
+      {
+        // TOF can be checked only when track is matched there
+        track->GetIntegratedTimes(times);
+        tofTime  = (Double_t)track->GetTOFsignal();
+        tofSigma = fTOFmaker->GetExpectedSigma(mom, times[AliPID::kPion], AliPID::ParticleMass(AliPID::kPion));
+        tofRef   = times[AliPID::kPion];
+        
+        tofRel   = (tofTime - tofRef) / tofSigma;
+        okTOF    = ((tofRel >= fMinTOF) && (tofRel <= fMaxTOF));
+        AliDebug(AliLog::kDebug + 2, Form("TOF nsigma = %f -- range = %f %f -- cut %s", tofRel, fMinTOF, fMaxTOF, (okTOF ? "passed" : "failed")));
+      }
+      else
+      {
+        // if TOF is not matched, the answer depends on TPC:
+        // - if TPC is required, track is checked only there and TOF simply ignored
+        // - if TPC is not required, track is rejected when TOF does not match it, if TOF check is required
+        if (fCheckTPC) okTOF = kTRUE; else okTOF = kFALSE;
+      }
+    }
+    else
+    {
+      okTOF = kTRUE;
+    }
+   
+   }
+  else if (isITSSA) // this branch is entered by all ITS standalone tracks
+  {
+    // check dE/dx only if this is required, otherwise ITS standalone are just added but not checked for PID
+    if (fCheckITS)
+    {
+      itsSignal = track->GetITSsignal();
+      itsCluMap = track->GetITSClusterMap();
+      nITS      = 0;
+      for(k = 2; k < 6; k++) if(itsCluMap & (1 << k)) ++nITS;
+      if (nITS < 3) return kFALSE;
+      itsNSigma = itsrsp.GetNumberOfSigmas(mom, itsSignal, AliPID::kPion, nITS, kTRUE);
+      okITS = ((TMath::Abs(itsNSigma)) <= fMaxITSband);
+      AliDebug(AliLog::kDebug + 2, Form("ITS nsigma = %f -- max = %f -- cut %s", itsNSigma, fMaxITSband, (okITS ? "passed" : "failed")));
+    }
+    else
+    {
+      okITS = kTRUE;
+    }
+  }
+  else
+    {
+    // if we are here, the track is surely bad
+    okITS=kFALSE;
+    okTPC=kFALSE;
+    okTOF=kFALSE;
+    }
+    
+  
+  okTrack[0]=okITS;
+  okTrack[1]=okTPC;
+  okTrack[2]=okTOF;
+  okTrack[3]=isTPC;
+  okTrack[4]=isITSSA;
+  
+  //cout<<"##########################################"<<endl;
+  //cout<<"isITSSA "<<isITSSA<< " isTPC "<<isTPC<<endl;
+  //cout<<"##########################################"<<endl;
+  
+  
+  return okTrack;
+}
+
+
+
+
+
+
+
+
+
+
+
+//________________________________________________________________________
+void AliAnalysisTaskSigma1385::Terminate(Option_t *) 
+{
+  // Draw result to the screen
+  // Called once at the end of the query
+}
+
+
+
diff --git a/PWG2/RESONANCES/extra/AliAnalysisTaskSigma1385.h b/PWG2/RESONANCES/extra/AliAnalysisTaskSigma1385.h
new file mode 100644 (file)
index 0000000..694975c
--- /dev/null
@@ -0,0 +1,133 @@
+#ifndef ALIANALYSISTASKSIGMA1385_H
+#define ALIANALYSISTASKSIGMA1385_H
+
+/*  See cxx source for full Copyright notice */
+
+//-----------------------------------------------------------------
+//                 AliAnalysisTaskSigma1385 class
+//-----------------------------------------------------------------
+
+class TList;
+class TH1F;
+class TNtuple;
+class AliESDcascade; 
+
+//-------------------------------- For PID
+
+
+#include  "AliESDpid.h"
+#include  "AliTOFT0maker.h"
+#include  "AliTOFcalib.h"
+#include  "AliCDBManager.h"
+#include  "AliESDtrackCuts.h"
+
+//-------------------------------  
+
+#include "TString.h"
+#include "AliAnalysisTaskSE.h"
+
+class AliAnalysisTaskSigma1385 : public AliAnalysisTaskSE {
+ public:
+  AliAnalysisTaskSigma1385();
+  AliAnalysisTaskSigma1385(const char *name);
+  virtual ~AliAnalysisTaskSigma1385() {}
+  
+  virtual void   UserCreateOutputObjects();
+  virtual void   UserExec(Option_t *option);
+  virtual void   Terminate(Option_t *);
+  
+  void SetCollidingSystems(Short_t collidingSystems = 0)     {fCollidingSystems = collidingSystems;}
+  void SetAnalysisType    (const char* analysisType = "ESD") {fAnalysisType = analysisType;}
+  void SetDataType    (const char* dataType = "REAL") {fDataType = dataType;}
+  
+  virtual const char *GetDataType() {return fDataType;}
+  
+  Bool_t *IsSelected(AliESDtrack* track);
+  
+  
+  
+
+//-------------------------------- For Alberto's PID
+
+
+    void             SetCheckITS (Bool_t yn = kTRUE) {fCheckITS = yn;}
+    void             SetCheckTPC (Bool_t yn = kTRUE) {fCheckTPC = yn;}
+    void             SetCheckTOF (Bool_t yn = kTRUE) {fCheckTOF = yn;}
+    void             SetUseGlobal(Bool_t yn = kTRUE) {fUseGlobal = yn;}
+    void             SetUseITSSA (Bool_t yn = kTRUE) {fUseITSSA = yn;}
+    
+    void             SetITSband(Double_t v) {fMaxITSband = v;}
+    
+    void             SetTPCpLimit(Double_t v) {fTPCpLimit = v;}
+    void             SetTPCrange(Double_t min, Double_t max) {fMinTPCband = min; fMaxTPCband = max;}
+    void             SetTPCpar(Double_t p0, Double_t p1, Double_t p2, Double_t p3, Double_t p4)
+                       {fTPCpar[0]=p0;fTPCpar[1]=p1;fTPCpar[2]=p2;fTPCpar[3]=p3;fTPCpar[4]=p4;}
+
+    void             SetTOFcalibrateESD(Bool_t yn = kTRUE)  {fTOFcalibrateESD = yn;}
+    void             SetTOFcorrectTExp (Bool_t yn = kTRUE)  {fTOFcorrectTExp = yn;}
+    void             SetTOFuseT0       (Bool_t yn = kTRUE)  {fTOFuseT0 = yn;}
+    void             SetTOFtuneMC      (Bool_t yn = kTRUE)  {fTOFtuneMC = yn;}
+    void             SetTOFresolution  (Double_t v = 100.0) {fTOFresolution = v;}
+    void             SetTOFrange       (Double_t v1, Double_t v2) {fMinTOF = v1; fMaxTOF = v2;}
+
+
+//------------------------------- 
+
+ private:
+
+  TString fAnalysisType;                               // "ESD" or "AOD" analysis type 
+  Short_t fCollidingSystems;                   // 0 = pp collisions or 1 = AA collisions
+  TString fDataType;                           // "REAL" or "SIM" data type    
+  
+  TList        *fListHistCascade;              //! List of Cascade histograms
+  TH1F    *fHistEventMultiplicity;
+  TH1F    *fHistEventMultiplicityRAVS;  //event rejected after vertex selection
+  TNtuple *fNtuple1;
+  TNtuple *fNtuple2;
+  TNtuple *fNtuple3;
+  TNtuple *fNtuple4;
+  
+
+  
+//-------------------------------- For PID
+ protected:
+  
+    Bool_t           isMC;
+    Bool_t           fIsMC;             //  switch for MC analysis
+    Bool_t           fCheckITS;         //  switch for ITS dE/dx check
+    Bool_t           fCheckTPC;         //  switch for TPC dE/dx check
+    Bool_t           fCheckTOF;         //  switch for TOF time check
+    Bool_t           fUseGlobal;        //  switch to use TPC global tracks
+    Bool_t           fUseITSSA;         //  switch to use ITS standalone tracks
+    
+    Double_t         fMaxITSband;       //  range for ITS de/dx band
+
+    Double_t         fTPCpLimit;        //  limit to choose what band to apply
+    Double_t         fTPCpar[5];        //  parameters for TPC bethe-Bloch
+    Double_t         fMinTPCband;       //  range for TPC de/dx band - min
+    Double_t         fMaxTPCband;       //  range for TPC de/dx band - max
+    
+    
+    AliESDpid       *fESDpid;           //! PID manager
+    AliTOFT0maker   *fTOFmaker;         //! TOF time0 computator
+    AliTOFcalib     *fTOFcalib;         //! TOF calibration
+    Bool_t           fTOFcalibrateESD;  //  TOF settings
+    Bool_t           fTOFcorrectTExp;   //  TOF settings
+    Bool_t           fTOFuseT0;         //  TOF settings
+    Bool_t           fTOFtuneMC;        //  TOF settings
+    Double_t         fTOFresolution;    //  TOF settings
+    Double_t         fMinTOF;           //  range for TOF PID (min)
+    Double_t         fMaxTOF;           //  range for TOF PID (max)
+    Int_t            fLastRun;          //  last run number
+  
+//-------------------------------   
+  
+  
+  AliAnalysisTaskSigma1385(const AliAnalysisTaskSigma1385&);            // not implemented
+  AliAnalysisTaskSigma1385& operator=(const AliAnalysisTaskSigma1385&); // not implemented
+  
+  ClassDef(AliAnalysisTaskSigma1385, 3);
+};
+
+#endif