]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG2/RESONANCES/AliRsnPair.cxx
Attempt to make the HV filtering more robust
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnPair.cxx
index b67d2f98ff3da4a2ea808b3fdfb2281b909bf1eb..cbaf2b00b03ab7df66bf4ad5c056f5c0dccb63e7 100644 (file)
 //          M. Vala (email: martin.vala@cern.ch)
 //
 
-#include <Riostream.h>
 #include <TList.h>
 
 #include "AliLog.h"
 
 #include "AliRsnMother.h"
-#include "AliRsnEvent.h"
-#include "AliRsnFunction.h"
 #include "AliRsnCutSet.h"
-#include "AliRsnCutStd.h"
-#include "AliRsnValue.h"
-#include "AliRsnCutManager.h"
 
 #include "AliRsnPair.h"
 
@@ -31,51 +25,48 @@ ClassImp(AliRsnPair)
 
 //_____________________________________________________________________________
 AliRsnPair::AliRsnPair(const char *name, AliRsnPairDef *def) :
-  TNamed(name, ""),
-  fOnlyTrue(kFALSE),
-  fIsMixed(kFALSE),
-  fPairDef(def),
-  fCutManager(),
-  fMother(),
-  fEvent(0x0)
+   TNamed(name, ""),
+   fOnlyTrue(kFALSE),
+   fCheckDecay(kFALSE),
+   fIsMixed(kFALSE),
+   fCount(0),
+   fPairDef(def),
+   fCutManager(Form("cutMgr_%s", name)),
+   fMother()
 {
 //
 // Default constructor
 //
-
-  AliDebug(AliLog::kDebug+2,"<-");
-  AliDebug(AliLog::kDebug+2,"->");
 }
 
 //_____________________________________________________________________________
 AliRsnPair::AliRsnPair(const AliRsnPair& copy) :
-  TNamed(copy),
-  fOnlyTrue(copy.fOnlyTrue),
-  fIsMixed(copy.fIsMixed),
-  fPairDef(copy.fPairDef),
-  fCutManager(copy.fCutManager),
-  fMother(copy.fMother),
-  fEvent(0x0)
+   TNamed(copy),
+   fOnlyTrue(copy.fOnlyTrue),
+   fCheckDecay(copy.fCheckDecay),
+   fIsMixed(copy.fIsMixed),
+   fCount(copy.fCount),
+   fPairDef(copy.fPairDef),
+   fCutManager(copy.fCutManager),
+   fMother(copy.fMother)
 {
 //
 // Default constructor
 //
-
-  AliDebug(AliLog::kDebug+2,"<-");
-  AliDebug(AliLog::kDebug+2,"->");
 }
 
 //_____________________________________________________________________________
 AliRsnPair& AliRsnPair::operator=(const AliRsnPair& copy)
 {
-  fOnlyTrue = copy.fOnlyTrue;
-  fIsMixed = copy.fIsMixed;
-  fPairDef = copy.fPairDef;
-  fMother = copy.fMother;
-  fCutManager = copy.fCutManager;
-  fEvent = 0x0;
-
-  return (*this);
+   fOnlyTrue = copy.fOnlyTrue;
+   fCheckDecay = copy.fCheckDecay;
+   fIsMixed = copy.fIsMixed;
+   fCount = copy.fCount;
+   fPairDef = copy.fPairDef;
+   fMother = copy.fMother;
+   fCutManager = copy.fCutManager;
+
+   return (*this);
 }
 
 //_____________________________________________________________________________
@@ -84,9 +75,6 @@ AliRsnPair::~AliRsnPair()
 //
 // Destructor
 //
-
-  AliDebug(AliLog::kDebug+2,"<-");
-  AliDebug(AliLog::kDebug+2,"->");
 }
 
 //_____________________________________________________________________________
@@ -95,86 +83,81 @@ void AliRsnPair::Print(Option_t* /*option*/) const
 //
 // Prints info about pair
 //
-
-  AliDebug(AliLog::kDebug+2,"<-");
-  AliInfo(Form("PDG %d %d", AliPID::ParticleCode(fPairDef->GetPID(0)), AliPID::ParticleCode(fPairDef->GetPID(1))));
-  AliInfo(Form("Masses %f %f", fPairDef->GetMass(0), fPairDef->GetMass(1)));
-
-  AliDebug(AliLog::kDebug+2,"->");
 }
 
 //_____________________________________________________________________________
 Bool_t AliRsnPair::Fill
-(AliRsnDaughter *daughter0, AliRsnDaughter *daughter1, AliRsnEvent *ev0, AliRsnEvent *ev1)
+(AliRsnDaughter *daughter1, AliRsnDaughter *daughter2, Bool_t refFirst)
 {
 //
-// Sets the two passed daughters to the AliRsnMother data member of this object
-// which is used to perform all computations to fill the value list.
-// This operation is done successfully only when the first passed object matches
-// the required object type (track/V0) and the required charge for first element in pair def,
-// and the second passed object does the same w.r. to the second element in pair def.
-// Moreover, all cuts are checked and the operation fails if a cut check is unsuccessful.
-// Finally, if a true pair is required, this is checked at the end.
-//
-
-  AliDebug(AliLog::kDebug+2,"<-");
-  
-  // check for correct type-charge match for first element
-  if (daughter0->RefType() != fPairDef->GetDaughterType(0)) return kFALSE;
-  if (daughter0->ChargeChar() != fPairDef->GetCharge(0)) return kFALSE;
-  
-  // check for correct type-charge match for second element
-  if (daughter1->RefType() != fPairDef->GetDaughterType(1)) return kFALSE;
-  if (daughter1->ChargeChar() != fPairDef->GetCharge(1)) return kFALSE;
-    
-  // cuts on track #1 & common
-  fCutManager.SetEvent(ev0);
-  if (!fCutManager.PassDaughter1Cuts(daughter0)) return kFALSE;
-  if (!fCutManager.PassCommonDaughterCuts(daughter0)) return kFALSE;
-  
-  // cuts on track #2 & common
-  fCutManager.SetEvent(ev1);
-  if (!fCutManager.PassDaughter2Cuts(daughter1)) return kFALSE;
-  if (!fCutManager.PassCommonDaughterCuts(daughter1)) return kFALSE;
-  
-  // point to first event as reference
-  fEvent = ev0;
-  
-  // define pair & check
-  fMother.SetDaughters(daughter0, fPairDef->GetMass(0), daughter1, fPairDef->GetMass(1));
-  fCutManager.SetEvent(fEvent);
-  if (!fCutManager.PassMotherCuts(&fMother)) return kFALSE;
-  
-  // if required a true pair, check this here and eventually return a fail message
-  if (fOnlyTrue)
-  {
-    // are we in a MonteCarlo?
-    if (!daughter0->GetParticle() || !daughter1->GetParticle()) return kFALSE;
-    
-    // are the daughters really secondaries (in MC)?
-    Int_t m0 = daughter0->GetParticle()->GetFirstMother();
-    Int_t m1 = daughter1->GetParticle()->GetFirstMother();
-    if (m0 < 0 || m1 < 0) return kFALSE;
-    
-    // if they are, do they come from the same mother?
-    if (m0 != m1) return kFALSE;
-    
-    // if they do, is this mother the correct type?
-    if (daughter0->GetMotherPDG() != fPairDef->GetMotherPDG()) return kFALSE;
-    if (daughter1->GetMotherPDG() != fPairDef->GetMotherPDG()) return kFALSE;
-    
-    // do they match the expected decay channel (that is, are they the expected types)?
-    Int_t pdg0 = TMath::Abs(daughter0->GetParticle()->GetPdgCode());
-    Int_t pdg1 = TMath::Abs(daughter1->GetParticle()->GetPdgCode());
-    if (AliPID::ParticleCode(fPairDef->GetPID(0)) != pdg0) return kFALSE;
-    if (AliPID::ParticleCode(fPairDef->GetPID(1)) != pdg1) return kFALSE;
-    
-    // ok... if we arrive here that must really be a true pair! :-)
-  }
-
-  AliDebug(AliLog::kDebug+2,"->");
-  
-  return kTRUE;
+// Checks that first argument matches definitions for first daughter
+// and the same for second argument, where the order is defined by
+// the AliRsnPairDef data member.
+// If the matching is successful, the AliRsnMother data member is 
+// initialized using the mass hypotheses defined here and the momenta
+// in the passed daughters.
+// The third argument is necessary to choose which one of the possible two
+// events owning the two daughter will be used as reference.
+//
+   
+   // check matching and exit if one of them fails
+   // if true pair is required, this is taken into account:
+   // if both true pairs and correct decay tree is required,
+   // then we must be sure that also the true PID of daughters matches,
+   // instead if correct decay tree is not required this additional check is not done
+   if (!fPairDef->GetDef1()->MatchesDaughter(daughter1, fOnlyTrue && fCheckDecay)) return kFALSE;
+   if (!fPairDef->GetDef2()->MatchesDaughter(daughter2, fOnlyTrue && fCheckDecay)) return kFALSE;
+   
+   // if matching is successful
+   // compute 4-momenta of daughters and mother
+   fMother.SetDaughter(0, daughter1);
+   fMother.SetDaughter(1, daughter2);
+   fMother.ComputeSum(fPairDef->GetMass1(), fPairDef->GetMass2());
+   
+   // assign reference event
+   if (refFirst) fMother.SetRefEvent(daughter1->GetOwnerEvent()); else fMother.SetRefEvent(daughter2->GetOwnerEvent());
+   
+   // if required a true pair, check this here and eventually return a fail message
+   // this is done using the method AliRsnMother::CommonMother with 2 arguments
+   // passed by reference, where the real GEANT label of the particle is stored
+   // and one can check if these tracks are both really secondaries (ID >= 0)
+   if (fOnlyTrue) {
+      Int_t m0, m1, common;
+      common = fMother.CommonMother(m0, m1);
+      if (m0 < 0 || m1 < 0) return kFALSE;
+      if (common != fPairDef->GetMotherPDG()) return kFALSE;
+   }
+   
+   // point to first event as reference
+   // and checks the pair cuts,
+   // (done first because it is more likely 
+   // that it is not passed and execution is faster)
+   if (!fCutManager.PassMotherCuts(&fMother)) return kFALSE;
+
+   // cuts on track #1 & common
+   if (!fCutManager.PassDaughter1Cuts(daughter1)) {
+      AliDebug(AliLog::kDebug + 2, "Specific cuts for track #1 not passed");
+      return kFALSE;
+   }
+   if (!fCutManager.PassCommonDaughterCuts(daughter1)) {
+      AliDebug(AliLog::kDebug + 2, "Common cuts for track #1 not passed");
+      return kFALSE;
+   }
+
+   // cuts on track #2 & common
+   if (!fCutManager.PassDaughter2Cuts(daughter2)) {
+      AliDebug(AliLog::kDebug + 2, "Specific cuts for track #2 not passed");
+      return kFALSE;
+   }
+   if (!fCutManager.PassCommonDaughterCuts(daughter2)) {
+      AliDebug(AliLog::kDebug + 2, "Common cuts for track #2 not passed");
+      return kFALSE;
+   }
+
+   // if pair is accepted, increment counter
+   ++fCount;
+
+   return kTRUE;
 }
 
 //_____________________________________________________________________________
@@ -184,7 +167,7 @@ void AliRsnPair::Compute()
 // Virtual method to compute pair quantities of interest
 //
 
-  AliWarning("Implement this method in derived classes");
+   AliWarning("Implement this method in derived classes");
 }
 
 //_____________________________________________________________________________
@@ -194,5 +177,5 @@ void AliRsnPair::Init(const char* /*prefix*/, TList* /*list*/)
 // Virtual method to compute pair quantities of interest
 //
 
-  AliWarning("Implement this method in derived classes");
+   AliWarning("Implement this method in derived classes");
 }