]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG2/RESONANCES/AliRsnCut.cxx
- added the DCA for the HLT tracks, as calculated by the HLT reconstruction, however...
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnCut.cxx
index f6b085ae5d71fd41a5116612104dbb39d40717b3..4d618dca1ce25d727947a462ba8e08b3ba3cca21 100644 (file)
@@ -18,7 +18,7 @@
 #include "AliLog.h"
 
 #include "AliRsnDaughter.h"
-#include "AliRsnPairParticle.h"
+#include "AliRsnMother.h"
 #include "AliRsnEvent.h"
 
 #include "AliRsnCut.h"
 ClassImp(AliRsnCut)
 
 //_________________________________________________________________________________________________
-AliRsnCut::AliRsnCut() :
+AliRsnCut::AliRsnCut(ETarget target) :
   TNamed(),
   fVarType(kInt),
+  fTarget(target),
   fMinI(0),
   fMaxI(0),
-  fMinU(0),
-  fMaxU(0),
   fMinD(0.0),
   fMaxD(0.0),
   fCutValueI(0),
-  fCutValueU(0),
   fCutValueD(0.0),
-  fCutResult(kTRUE)
+  fCutResult(kTRUE),
+  fEvent(0x0)
 {
 //
 // Default constructor.
@@ -46,48 +45,41 @@ AliRsnCut::AliRsnCut() :
 }
 
 //_________________________________________________________________________________________________
-AliRsnCut::AliRsnCut
-(const char *name, Int_t min, Int_t max) :
-  TNamed(name, ""),
-  fVarType(kInt),
-  fMinI(min),
-  fMaxI(max),
-  fMinU(0),
-  fMaxU(0),
-  fMinD(0.0),
-  fMaxD(0.0),
-  fCutValueI(0),
-  fCutValueU(0),
-  fCutValueD(0.0),
-  fCutResult(kTRUE)
+AliRsnCut::AliRsnCut(const AliRsnCut& copy) :
+  TNamed(copy),
+  fVarType(copy.fVarType),
+  fTarget(copy.fTarget),
+  fMinI(copy.fMinI),
+  fMaxI(copy.fMaxI),
+  fMinD(copy.fMinD),
+  fMaxD(copy.fMaxD),
+  fCutValueI(copy.fCutValueI),
+  fCutValueD(copy.fCutValueD),
+  fCutResult(copy.fCutResult),
+  fEvent(copy.fEvent)
 {
 //
-// Constructor.
-// If the cut must check values inside a range,
-// both 'value' arguments must be used, and they are, in the order,
-// the minimum and maximum of the allowed range.
-// If the cut must check a value, the second 'value' argument will never be used.
+// Copy constructor.
 //
 }
 
 //_________________________________________________________________________________________________
 AliRsnCut::AliRsnCut
-(const char *name, ULong_t min, ULong_t max) :
+(const char *name, ETarget target, Int_t min, Int_t max) :
   TNamed(name, ""),
-  fVarType(kULong),
-  fMinI(0),
-  fMaxI(0),
-  fMinU(min),
-  fMaxU(max),
+  fVarType(kInt),
+  fTarget(target),
+  fMinI(min),
+  fMaxI(max),
   fMinD(0.0),
   fMaxD(0.0),
   fCutValueI(0),
-  fCutValueU(0),
   fCutValueD(0.0),
-  fCutResult(kTRUE)
+  fCutResult(kTRUE),
+  fEvent(0x0)
 {
 //
-// Constructor.
+// Constructor with integer values.
 // If the cut must check values inside a range,
 // both 'value' arguments must be used, and they are, in the order,
 // the minimum and maximum of the allowed range.
@@ -97,22 +89,21 @@ AliRsnCut::AliRsnCut
 
 //_________________________________________________________________________________________________
 AliRsnCut::AliRsnCut
-(const char *name, Double_t min, Double_t max) :
+(const char *name, ETarget target, Double_t min, Double_t max) :
   TNamed(name, ""),
   fVarType(kDouble),
+  fTarget(target),
   fMinI(0),
   fMaxI(0),
-  fMinU(0),
-  fMaxU(0),
   fMinD(min),
   fMaxD(max),
   fCutValueI(0),
-  fCutValueU(0),
   fCutValueD(0.0),
-  fCutResult(kTRUE)
+  fCutResult(kTRUE),
+  fEvent(0x0)
 {
 //
-// Constructor.
+// Constructor with double values.
 // If the cut must check values inside a range,
 // both 'value' arguments must be used, and they are, in the order,
 // the minimum and maximum of the allowed range.
@@ -121,50 +112,105 @@ AliRsnCut::AliRsnCut
 }
 
 //_________________________________________________________________________________________________
-Bool_t AliRsnCut::IsSelected(ETarget /*tgt*/, AliRsnDaughter* /*track*/)
+AliRsnCut& AliRsnCut::operator=(const AliRsnCut& copy)
 {
 //
-// Virtual cut-checking method.
-// In base class, these methods compare the argument type
-// with the defined target, in order to detect a mismatch
+// Assignment operator
+// don't duplicate memory occupancy for pointer
 //
 
-  return kTRUE;
-}
-
-//_________________________________________________________________________________________________
-Bool_t AliRsnCut::IsSelected(ETarget /*tgt*/, AliRsnPairParticle* /*pair*/)
-{
-//
-// Virtual cut-checking method.
-// In base class, these methods compare the argument type
-// with the defined target, in order to detect a mismatch
-//
+  fVarType   = copy.fVarType;
+  fTarget    = copy.fTarget;
+  fMinI      = copy.fMinI;
+  fMaxI      = copy.fMaxI;
+  fMinD      = copy.fMinD;
+  fMaxD      = copy.fMaxD;
+  fCutValueI = copy.fCutValueI;
+  fCutValueD = copy.fCutValueD;
+  fCutResult = copy.fCutResult;
+  fEvent     = copy.fEvent;
 
-  return kTRUE;
+  return (*this);
 }
 
 //_________________________________________________________________________________________________
-Bool_t AliRsnCut::IsSelected(ETarget /*tgt*/, AliRsnEvent* /*event*/)
+Bool_t AliRsnCut::TargetOK(TObject *obj1, TObject *obj2)
 {
 //
-// Virtual cut-checking method.
-// In base class, these methods compare the argument type
-// with the defined target, in order to detect a mismatch
+// This method checks if the expected target and the passed object match.
 //
 
+  if (!obj1)
+  {
+    AliError("Cannot cut on a NULL object!");
+    return kFALSE;
+  }
+
+  switch (fTarget)
+  {
+    case kDaughter:
+      if (dynamic_cast<AliRsnDaughter*>(obj1) == 0x0)
+      {
+        AliError(Form("[%s] Target mismatch (obj #1): expected  'AliRsnDaughter', passed '%s'", GetName(), obj1->ClassName()));
+        Print();
+        return kFALSE;
+      }
+      break;
+    case kMother:
+      if (dynamic_cast<AliRsnMother*>(obj1) == 0x0)
+      {
+        AliError(Form("[%s] Target mismatch (obj #1): expected  'AliRsnMother', passed '%s'", GetName(), obj1->ClassName()));
+        Print();
+        return kFALSE;
+      }
+      break;
+    case kEvent:
+      if (dynamic_cast<AliRsnEvent*>(obj1) == 0x0)
+      {
+        AliError(Form("[%s] Target mismatch (obj #1): expected  'AliRsnEvent', passed '%s'", GetName(), obj1->ClassName()));
+        Print();
+        return kFALSE;
+      }
+      break;
+    case kMixEvent:
+      if (dynamic_cast<AliRsnEvent*>(obj1) == 0x0)
+      {
+        AliError(Form("[%s] Target mismatch (obj #1): expected  'AliRsnEvent', passed '%s' an", GetName(), obj1->ClassName()));
+        Print();
+        return kFALSE;
+      }
+      if (obj2)
+      {
+        if (dynamic_cast<AliRsnEvent*>(obj2) == 0x0)
+        {
+          AliError(Form("[%s] Target mismatch (obj #2): expected  'AliRsnEvent', passed '%s' an", GetName(), obj2->ClassName()));
+          Print();
+          return kFALSE;
+        }
+      }
+      else
+      {
+        AliError("Mix-event cuts require 2 not NULL objects");
+        Print();
+        return kFALSE;
+      }
+      break;
+    default:
+      return kTRUE;
+  }
+  
   return kTRUE;
 }
 
 //_________________________________________________________________________________________________
-Bool_t AliRsnCut::IsSelected(ETarget /*tgt*/, AliRsnEvent* /*ev1*/, AliRsnEvent* /*ev2*/)
+Bool_t AliRsnCut::IsSelected(TObject* /*obj1*/, TObject* /*obj2*/)
 {
 //
-// Virtual cut-checking method.
-// In base class, these methods compare the argument type
-// with the defined target, in order to detect a mismatch
+// Virtual cut-checking method for event mixing.
+// This method checks only that the target is the oner for mixing.
 //
 
+  AliWarning("Single-object cuts are not implemented here.");
   return kTRUE;
 }
 
@@ -177,47 +223,16 @@ Bool_t AliRsnCut::OkValue()
 // Then, the cut result is kTRUE if the cut value is equal to this reference value.
 //
 
-  switch (fVarType)
+  switch (fVarType) 
   {
     case kInt:
-      // eval result
-      fCutResult = (fCutValueI == fMinI);
-      // print debug message
-      AliDebug(AliLog::kDebug + 3, "=== CUT DEBUG ====================================");
-      AliDebug(AliLog::kDebug + 3, Form("Cut name     : %s", GetName()));
-      AliDebug(AliLog::kDebug + 3, Form("Checked value: %d", fCutValueI));
-      AliDebug(AliLog::kDebug + 3, Form("Cut value    : %d", fMinI));
-      AliDebug(AliLog::kDebug + 3, Form("Cut result   : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
-      AliDebug(AliLog::kDebug + 3, "=== END CUT DEBUG ================================");
-      break;
-    case kULong:
-      // eval result
-      fCutResult = (fCutValueU == fMinU);
-      // print debug message
-      AliDebug(AliLog::kDebug + 3, "=== CUT DEBUG ====================================");
-      AliDebug(AliLog::kDebug + 3, Form("Cut name     : %s", GetName()));
-      AliDebug(AliLog::kDebug + 3, Form("Checked value: %d", fCutValueU));
-      AliDebug(AliLog::kDebug + 3, Form("Cut value    : %d", fMinU));
-      AliDebug(AliLog::kDebug + 3, Form("Cut result   : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
-      AliDebug(AliLog::kDebug + 3, "=== END CUT DEBUG ================================");
-      break;
+      return OkValueI();
     case kDouble:
-      // eval result
-      fCutResult = (TMath::Abs(fCutValueD - fMinD) < 1E-6);
-      // print debug message
-      AliDebug(AliLog::kDebug + 3, "=== CUT DEBUG ====================================");
-      AliDebug(AliLog::kDebug + 3, Form("Cut name     : %s", GetName()));
-      AliDebug(AliLog::kDebug + 3, Form("Checked value: %f", fCutValueD));
-      AliDebug(AliLog::kDebug + 3, Form("Cut value    : %f", fMinD));
-      AliDebug(AliLog::kDebug + 3, Form("Cut result   : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
-      AliDebug(AliLog::kDebug + 3, "=== END CUT DEBUG ================================");
-      break;
+      return OkValueD();
     default:
       AliError(Form("fVarType = %d --> not allowed", fVarType));
       return kFALSE;
   }
-
-  return fCutResult;
 }
 
 //_________________________________________________________________________________________________
@@ -229,46 +244,139 @@ Bool_t AliRsnCut::OkRange()
 // Then, the cut result is kTRUE if the cut value is inside this range.
 //
 
-  switch (fVarType)
+  switch (fVarType) 
   {
     case kInt:
-      // eval result
-      fCutResult = ((fCutValueI >= fMinI) && (fCutValueI <= fMaxI));
-      // print debug message
-      AliDebug(AliLog::kDebug + 3, "=== CUT DEBUG ====================================");
-      AliDebug(AliLog::kDebug + 2, Form("Cut name     : %s", GetName()));
-      AliDebug(AliLog::kDebug + 2, Form("Checked value: %d", fCutValueI));
-      AliDebug(AliLog::kDebug + 2, Form("Cut range    : %d , %d", fMinI, fMaxI));
-      AliDebug(AliLog::kDebug + 2, Form("Cut result   : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
-      AliDebug(AliLog::kDebug + 3, "=== END CUT DEBUG ================================");
-      break;
-    case kULong:
-      // eval result
-      fCutResult = ((fCutValueU >= fMinU) && (fCutValueU <= fMaxU));
-      // print debug message
-      AliDebug(AliLog::kDebug + 3, "=== CUT DEBUG ====================================");
-      AliDebug(AliLog::kDebug + 2, Form("Cut name     : %s", GetName()));
-      AliDebug(AliLog::kDebug + 2, Form("Checked value: %d", fCutValueU));
-      AliDebug(AliLog::kDebug + 2, Form("Cut range    : %d , %d", fMinU, fMaxU));
-      AliDebug(AliLog::kDebug + 2, Form("Cut result   : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
-      AliDebug(AliLog::kDebug + 3, "=== END CUT DEBUG ================================");
-      break;
+      return OkRangeI();
     case kDouble:
-      // eval result
-      fCutResult = ((fCutValueD >= fMinD) && (fCutValueD <= fMaxD));
-      // print debug message
-      AliDebug(AliLog::kDebug + 3, "=== CUT DEBUG ====================================");
-      AliDebug(AliLog::kDebug + 2, Form("Cut name     : %s", GetName()));
-      AliDebug(AliLog::kDebug + 2, Form("Checked value: %f", fCutValueD));
-      AliDebug(AliLog::kDebug + 2, Form("Cut range    : %f , %f", fMinD, fMaxD));
-      AliDebug(AliLog::kDebug + 2, Form("Cut result   : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
-      AliDebug(AliLog::kDebug + 3, "=== END CUT DEBUG ================================");
-      break;
+      return OkRangeD();
     default:
       AliError(Form("fVarType = %d --> not allowed", fVarType));
       return kFALSE;
   }
+}
 
+//_________________________________________________________________________________________________
+Bool_t AliRsnCut::OkValueI()
+{
+//
+// This method is used when the cut consists in comparing the cut value
+// with a reference integer value to which it must be equal.
+//
+
+  // eval result
+  fCutResult = (fCutValueI == fMinI);
+  
+  // print debug message
+  AliDebug(AliLog::kDebug + 2, "=== CUT DEBUG ====================================");
+  AliDebug(AliLog::kDebug + 2, Form("Cut name     : %s", GetName()));
+  AliDebug(AliLog::kDebug + 2, Form("Checked value: %d", fCutValueI));
+  AliDebug(AliLog::kDebug + 2, Form("Cut value    : %d", fMinI));
+  AliDebug(AliLog::kDebug + 2, Form("Cut result   : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
+  AliDebug(AliLog::kDebug + 2, "=== END CUT DEBUG ================================");
+  
   return fCutResult;
 }
 
+//_________________________________________________________________________________________________
+Bool_t AliRsnCut::OkValueD()
+{
+//
+// This method is used when the cut consists in comparing the cut value
+// with a reference double value to which it must be equal (or at least, almost).
+//
+
+  // eval result
+  fCutResult = (TMath::Abs(fCutValueD - fMinD) < 1E-6);
+  
+  // print debug message
+  AliDebug(AliLog::kDebug + 2, "=== CUT DEBUG ====================================");
+  AliDebug(AliLog::kDebug + 2, Form("Cut name     : %s", GetName()));
+  AliDebug(AliLog::kDebug + 2, Form("Checked value: %f", fCutValueD));
+  AliDebug(AliLog::kDebug + 2, Form("Cut value    : %f", fMinD));
+  AliDebug(AliLog::kDebug + 2, Form("Cut result   : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
+  AliDebug(AliLog::kDebug + 2, "=== END CUT DEBUG ================================");
+  
+  return fCutResult;
+}
+
+//_________________________________________________________________________________________________
+Bool_t AliRsnCut::OkRangeI()
+{
+//
+// This method is used when the cut consists in an allowed range
+// where the cut value must be included to pass the cut.
+// Then, the cut result is kTRUE if the cut value is inside this range.
+//
+
+  // eval result
+  fCutResult = ((fCutValueI >= fMinI) && (fCutValueI <= fMaxI));
+  
+  // print debug message
+  AliDebug(AliLog::kDebug + 2, "=== CUT DEBUG ====================================");
+  AliDebug(AliLog::kDebug + 2, Form("Cut name     : %s", GetName()));
+  AliDebug(AliLog::kDebug + 2, Form("Checked value: %d", fCutValueI));
+  AliDebug(AliLog::kDebug + 2, Form("Cut range    : %d , %d", fMinI, fMaxI));
+  AliDebug(AliLog::kDebug + 2, Form("Cut result   : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
+  AliDebug(AliLog::kDebug + 2, "=== END CUT DEBUG ================================");
+  
+  return fCutResult;
+}
+
+//_________________________________________________________________________________________________
+Bool_t AliRsnCut::OkRangeD()
+{
+//
+// This method is used when the cut consists in an allowed range
+// where the cut value must be included to pass the cut.
+// Then, the cut result is kTRUE if the cut value is inside this range.
+//
+
+  // eval result
+  fCutResult = ((fCutValueD >= fMinD) && (fCutValueD <= fMaxD));
+   
+  // print debug message
+  AliDebug(AliLog::kDebug + 2, "=== CUT DEBUG ====================================");
+  AliDebug(AliLog::kDebug + 2, Form("Cut name     : %s", GetName()));
+  AliDebug(AliLog::kDebug + 2, Form("Checked value: %f", fCutValueD));
+  AliDebug(AliLog::kDebug + 2, Form("Cut range    : %f , %f", fMinD, fMaxD));
+  AliDebug(AliLog::kDebug + 2, Form("Cut result   : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
+  AliDebug(AliLog::kDebug + 2, "=== END CUT DEBUG ================================");
+
+  return fCutResult;
+}
+
+//_________________________________________________________________________________________________
+void AliRsnCut::Print(Option_t*) const
+{
+//
+// Override TObject::Print() method
+//
+
+  Char_t target[100];
+  switch (fTarget)
+  {
+    case kDaughter: snprintf(target, strlen("DAUGHTER") , "DAUGHTER") ; break;
+    case kMother  : snprintf(target, strlen("MOTHER")   , "MOTHER")   ; break;
+    case kEvent   : snprintf(target, strlen("EVENT")    , "EVENT")    ; break;
+    case kMixEvent: snprintf(target, strlen("MIX EVENT"), "MIX EVENT"); break;
+    default       : snprintf(target, strlen("UNDEFINED"), "UNDEFINED"); break;
+  }
+
+  AliInfo("=== CUT DETAILS ====================================");
+  AliInfo(Form("Cut name     : [%s]", GetName()));
+  AliInfo(Form("Cut target   : [%s]", target));
+  AliInfo(Form("Cut edges [D]: [%f - %f]", fMinD, fMaxD));
+  AliInfo(Form("Cut edges [I]: [%d - %d]", fMinI, fMaxI));
+  AliInfo("====================================================");
+}
+
+//_________________________________________________________________________________________________
+void AliRsnCut::SetEvent(AliRsnEvent *event)
+{
+//
+// Sets the reference event
+//
+
+  fEvent = event;
+}