]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG2/RESONANCES/AliRsnCutPrimaryVertex.cxx
Renames and new scripts
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnCutPrimaryVertex.cxx
index 562dc4d9739dabfecb188d0e07622f61954a9a82..afc75ebe7b76abc7dac2634d7216fb8bacf2991d 100644 (file)
 //
 // Class AliRsnCutPrimaryVertex
 //
-// 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.
+// This cut implementation checks the quality of event primary vertex.
+// It currently works only with ESD events (not AOD).
 //
 // authors: Martin Vala (martin.vala@cern.ch)
 //          Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
 //
 
-// #include "AliLog.h"
-// #include "AliESDEvent.h"
-// #include "AliESDVertex.h"
-// 
-// #include "AliRsnEvent.h"
-// #include "AliRsnCutPrimaryVertex.h"
-
-// #include "Riostream.h"
-// #include "TMath.h"
-// 
-// #include "AliLog.h"
-// #include "AliESDEvent.h"
-// #include "AliESDVertex.h"
-// 
-// #include "AliRsnEvent.h"
 #include "AliRsnCutPrimaryVertex.h"
 
 ClassImp(AliRsnCutPrimaryVertex)
 
-//_________________________________________________________________________________________________
-AliRsnCutPrimaryVertex::AliRsnCutPrimaryVertex() :
-    AliRsnCut()
-{
-//
-// Default constructor.
-//
-}
-
 //_________________________________________________________________________________________________
 AliRsnCutPrimaryVertex::AliRsnCutPrimaryVertex
-(const char *name, Int_t nContributors) :
-    AliRsnCut(name, 0, nContributors)
+(const char *name, Double_t maxVz, Int_t nContributors, Bool_t acceptTPC) :
+  AliRsnCut(name, AliRsnCut::kEvent, 0, nContributors - 1, 0.0, maxVz),
+  fAcceptTPC(acceptTPC),
+  fCheckPileUp(kFALSE)
 {
 //
 // Main constructor.
-// the cut range is outside the interval 0 - min number of contributors.
+// Defines the cut range between 0 and
+// the minimum required number of contributors.
+// The cut will be passed when if the event has a
+// primary vertex with number of contributors outside this interval.
+// ---
+// If the 'acceptTPC' argument is true, events with TPC
+// primary vertex will be checked, otherwise they will be
+// rejected by default.
+// ---
+// Since the range check uses the '>=' and '<=', the high edge
+// must be decreased by 1 to get the right behaviour, since this is integer.
 //
-}
 
-//_________________________________________________________________________________________________
-Bool_t AliRsnCutPrimaryVertex::IsSelected(AliRsnCut::ETarget /*tgt*/, AliRsnDaughter*/*const track*/)
-{
-//
-// Cut checker.
-//
-  AliWarning("Cannot apply this cut to particles");
-  return kTRUE;
+  fMinD = 0.0;
+  fMaxD = maxVz + 1E-6;
 }
 
 //_________________________________________________________________________________________________
-Bool_t AliRsnCutPrimaryVertex::IsSelected(AliRsnCut::ETarget, AliRsnPairParticle*/*const pair*/)
+Bool_t AliRsnCutPrimaryVertex::IsSelected(TObject *object)
 {
 //
 // Cut checker
 //
-
-  AliWarning("Cannot apply this cut to pairs");
-  return kTRUE;
-}
-
-//_________________________________________________________________________________________________
-Bool_t AliRsnCutPrimaryVertex::IsSelected(AliRsnCut::ETarget, AliRsnEvent*event)
-{
-//
-// Cut checker
-//
-
+  
   // retrieve ESD event
-  AliESDEvent *esd = dynamic_cast<AliESDEvent*>(event->GetRef());
-  if (!esd) {
-    AliDebug(AliLog::kDebug+2, "NO ESD");
-    return kTRUE;
+  AliRsnEvent *rsn = dynamic_cast<AliRsnEvent*>(object);
+  if (!rsn) return kFALSE;
+  AliESDEvent *esd = rsn->GetRefESD();
+  AliAODEvent *aod = rsn->GetRefAOD();
+  
+  if (esd)
+  {
+    // pile-up check
+    if (fCheckPileUp)
+    {
+      if (esd->IsPileupFromSPD()) return kFALSE;
+    }
+    
+    // get the best primary vertex:
+    // first try the one with tracks
+    const AliESDVertex *vTrk  = esd->GetPrimaryVertexTracks();
+    const AliESDVertex *vSPD  = esd->GetPrimaryVertexSPD();
+    const AliESDVertex *vTPC  = esd->GetPrimaryVertexTPC();
+    Int_t               ncTrk = -1;
+    Int_t               ncSPD = -1;
+    Int_t               ncTPC = -1;
+    Double_t            vzTrk = 1000000.0;
+    Double_t            vzSPD = 1000000.0;
+    Double_t            vzTPC = 1000000.0;
+    if (vTrk) vzTrk = TMath::Abs(vTrk->GetZv());
+    if (vSPD) vzSPD = TMath::Abs(vSPD->GetZv());
+    if (vTPC) vzTPC = TMath::Abs(vTPC->GetZv());
+    if (vTrk) ncTrk = (Int_t)vTrk->GetNContributors();
+    if (vSPD) ncSPD = (Int_t)vSPD->GetNContributors();
+    if (vTPC) ncTPC = (Int_t)vTPC->GetNContributors();
+    if(vTrk && ncTrk > 0)
+    {
+      fCutValueI = ncTrk;
+      fCutValueD = vzTrk;
+    }
+    else if (vSPD && ncSPD > 0)
+    {
+      fCutValueI = ncSPD;
+      fCutValueD = vzSPD;
+    }
+    else if (vTPC && ncTPC > 0)
+    {
+      if (!fAcceptTPC) 
+        return kFALSE;
+      else
+      {
+        fCutValueI = ncTPC;
+        fCutValueD = vzTPC;
+      }
+    }
+    else
+      return kFALSE;
   }
+  else if (aod)
+  {
+    // pile-up check is not yet available for AODs
+    
+    // lines suggested by Andrea to reject TPC-only events
+    if(!fAcceptTPC)
+    {
+      if (!aod->GetPrimaryVertexSPD()) return kFALSE;
+      else if(aod->GetPrimaryVertexSPD()->GetNContributors() < 1) return kFALSE;
+    }
+    
+    AliAODVertex *prim = (AliAODVertex*)aod->GetPrimaryVertex();
+    if (!prim) return kFALSE;
 
-  // check primary vertex and eventually fill step 1
-  // if a vertex with tracks was successfully reconstructed,
-  // it is used for computing DCA;
-  // otherwise, the one computed with SPD is used.
-  // This is known from the "Status" parameter of the vertex itself.
-  const AliESDVertex *v = esd->GetPrimaryVertex();
-  if (!v->GetStatus()) v = esd->GetPrimaryVertexSPD();
-  if (!v->GetStatus()) {
-    AliDebug(AliLog::kDebug+2, "Bad vertex status");
-    return kFALSE;
+    fCutValueI = prim->GetNContributors();
+    fCutValueD = prim->GetZ();
   }
-
-  fCutValueI = v->GetNContributors();
-
-  return !OkRange();
+  else
+    return kFALSE;
+    
+  // output
+  Bool_t result = ((!OkRangeI()) && OkRangeD());
+  return result;
 }
 
 //_________________________________________________________________________________________________
-Bool_t AliRsnCutPrimaryVertex::IsSelected(AliRsnCut::ETarget, AliRsnEvent*/*ev1*/, AliRsnEvent*/*ev2*/)
+void AliRsnCutPrimaryVertex::Print(const Option_t *) const
 {
 //
-// Cut checker
+// Print information on this cut
 //
 
-  AliWarning("Cannot apply this cut to event mixing");
-  return kTRUE;
+  AliInfo(Form("Cut name                     : %s", GetName()));
+  AliInfo(Form("Accepting TPC primary vertex : %s", (fAcceptTPC ? "YES" : "NO")));
+  AliInfo(Form("Contributors range (outside) : %d - %d", fMinI, fMaxI));
+  AliInfo(Form("Z-vertex     range (inside)  : %f - %f", fMinD, fMaxD));
 }