ROOT logo
/**************************************************************************
 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 *                                                                        *
 * Author: The ALICE Off-line Project.                                    *
 * 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.                  *
 **************************************************************************/

////////////////////////////////////////////////////////////////////////////////
//
//  Base class used wherever it is needed to check the class type of
//  an object w.r. to the RSN framework analysis (daughter, mother, event)
//  which could be used for cut checking or value computing.
//  Since most of these operation are implemented into classes that
//  operate on any of such objects, then this class helps in making sure
//  that the object being processed corresponds to what is expected.
//  It also contains three pointers to which any passed object is casted
//  in order to have a quick reference to any allowed object type from
//  an appropriate pointer, which is propagated to all inheriting classes.
//
//  authors: A. Pulvirenti (alberto.pulvirenti@ct.infn.it)
//           M. Vala (martin.vala@cern.ch)
//
////////////////////////////////////////////////////////////////////////////////

#include "AliLog.h"

#include "AliRsnDaughter.h"
#include "AliRsnMother.h"

#include "AliRsnTarget.h"

ClassImp(AliRsnTarget)

//_____________________________________________________________________________
Bool_t AliRsnTarget::TargetOK(TObject *object)
{
//
// This method doew the following things:
// 1) check if the object class matches the required target type
// 2) if (1) is successful, set the built-in pointer data member
//    in order to point to it, after being casted accordingly
// 3) if the target is a daughter or a mother, adjust the pointer
//    to reference event accordingly
//

   // reset local pointers and then initialize
   // only the right one by static cast, if found
   fDaughter = 0x0;
   fMother   = 0x0;
   fEvent    = 0x0;

   // fails by default if a NULL pointer is passed
   if (!object) {
      AliError("Passed a NULL object");
      return kFALSE;
   }

   // checks matching between argument type and expected object type
   // the passed object is also casted into the appropriate pointer
   // when a daughter or mother is passed and the target type expects
   // and event, the check is yes successful and the owner event is used
   if (object->IsA() == AliRsnDaughter::Class() && (fTargetType == kDaughter || fTargetType == kEvent)) {
      fDaughter = static_cast<AliRsnDaughter *>(object);
      fEvent = fDaughter->GetOwnerEvent();
      return kTRUE;
   }
   else if (object->IsA() == AliRsnMother::Class() && (fTargetType == kMother || fTargetType == kEvent)) {
      fMother = static_cast<AliRsnMother *>(object);
      fEvent = fMother->GetRefEvent();
      return kTRUE;
   }
   else if (object->IsA() == AliRsnEvent::Class() && fTargetType == kEvent) {
      fEvent = static_cast<AliRsnEvent *>(object);
      return kTRUE;
   }
   else {
      if (object) {
         AliError(Form("[%s] Target mismatch: expected '%s', passed '%s'", GetName(), GetTargetTypeName(), object->ClassName()));
      } else {
         AliError(Form("[%s] Target mismatch: expected '%s', passed 'NULL'", GetName(), GetTargetTypeName()));
      }
      return kFALSE;
   }
}

//______________________________________________________________________________
Char_t AliRsnTarget::GetTargetTypeChar() const
{
//
// Returns a single character identifying the cut target type.
//

   switch (fTargetType) {
      case kDaughter: return 'D';
      case kMother: return 'M';
      case kEvent: return 'E';
      default: return 'X';
   }
}

//______________________________________________________________________________
const char *AliRsnTarget::GetTargetTypeName() const
{
//
// Returns a string with the name of the cut target type-
//

   switch (fTargetType) {
      case kDaughter: return "Daughter";
      case kMother: return "Mother";
      case kEvent: return "Event";
      default: return "Undefined";
   }
}
 AliRsnTarget.cxx:1
 AliRsnTarget.cxx:2
 AliRsnTarget.cxx:3
 AliRsnTarget.cxx:4
 AliRsnTarget.cxx:5
 AliRsnTarget.cxx:6
 AliRsnTarget.cxx:7
 AliRsnTarget.cxx:8
 AliRsnTarget.cxx:9
 AliRsnTarget.cxx:10
 AliRsnTarget.cxx:11
 AliRsnTarget.cxx:12
 AliRsnTarget.cxx:13
 AliRsnTarget.cxx:14
 AliRsnTarget.cxx:15
 AliRsnTarget.cxx:16
 AliRsnTarget.cxx:17
 AliRsnTarget.cxx:18
 AliRsnTarget.cxx:19
 AliRsnTarget.cxx:20
 AliRsnTarget.cxx:21
 AliRsnTarget.cxx:22
 AliRsnTarget.cxx:23
 AliRsnTarget.cxx:24
 AliRsnTarget.cxx:25
 AliRsnTarget.cxx:26
 AliRsnTarget.cxx:27
 AliRsnTarget.cxx:28
 AliRsnTarget.cxx:29
 AliRsnTarget.cxx:30
 AliRsnTarget.cxx:31
 AliRsnTarget.cxx:32
 AliRsnTarget.cxx:33
 AliRsnTarget.cxx:34
 AliRsnTarget.cxx:35
 AliRsnTarget.cxx:36
 AliRsnTarget.cxx:37
 AliRsnTarget.cxx:38
 AliRsnTarget.cxx:39
 AliRsnTarget.cxx:40
 AliRsnTarget.cxx:41
 AliRsnTarget.cxx:42
 AliRsnTarget.cxx:43
 AliRsnTarget.cxx:44
 AliRsnTarget.cxx:45
 AliRsnTarget.cxx:46
 AliRsnTarget.cxx:47
 AliRsnTarget.cxx:48
 AliRsnTarget.cxx:49
 AliRsnTarget.cxx:50
 AliRsnTarget.cxx:51
 AliRsnTarget.cxx:52
 AliRsnTarget.cxx:53
 AliRsnTarget.cxx:54
 AliRsnTarget.cxx:55
 AliRsnTarget.cxx:56
 AliRsnTarget.cxx:57
 AliRsnTarget.cxx:58
 AliRsnTarget.cxx:59
 AliRsnTarget.cxx:60
 AliRsnTarget.cxx:61
 AliRsnTarget.cxx:62
 AliRsnTarget.cxx:63
 AliRsnTarget.cxx:64
 AliRsnTarget.cxx:65
 AliRsnTarget.cxx:66
 AliRsnTarget.cxx:67
 AliRsnTarget.cxx:68
 AliRsnTarget.cxx:69
 AliRsnTarget.cxx:70
 AliRsnTarget.cxx:71
 AliRsnTarget.cxx:72
 AliRsnTarget.cxx:73
 AliRsnTarget.cxx:74
 AliRsnTarget.cxx:75
 AliRsnTarget.cxx:76
 AliRsnTarget.cxx:77
 AliRsnTarget.cxx:78
 AliRsnTarget.cxx:79
 AliRsnTarget.cxx:80
 AliRsnTarget.cxx:81
 AliRsnTarget.cxx:82
 AliRsnTarget.cxx:83
 AliRsnTarget.cxx:84
 AliRsnTarget.cxx:85
 AliRsnTarget.cxx:86
 AliRsnTarget.cxx:87
 AliRsnTarget.cxx:88
 AliRsnTarget.cxx:89
 AliRsnTarget.cxx:90
 AliRsnTarget.cxx:91
 AliRsnTarget.cxx:92
 AliRsnTarget.cxx:93
 AliRsnTarget.cxx:94
 AliRsnTarget.cxx:95
 AliRsnTarget.cxx:96
 AliRsnTarget.cxx:97
 AliRsnTarget.cxx:98
 AliRsnTarget.cxx:99
 AliRsnTarget.cxx:100
 AliRsnTarget.cxx:101
 AliRsnTarget.cxx:102
 AliRsnTarget.cxx:103
 AliRsnTarget.cxx:104
 AliRsnTarget.cxx:105
 AliRsnTarget.cxx:106
 AliRsnTarget.cxx:107
 AliRsnTarget.cxx:108
 AliRsnTarget.cxx:109
 AliRsnTarget.cxx:110
 AliRsnTarget.cxx:111
 AliRsnTarget.cxx:112
 AliRsnTarget.cxx:113
 AliRsnTarget.cxx:114
 AliRsnTarget.cxx:115
 AliRsnTarget.cxx:116
 AliRsnTarget.cxx:117
 AliRsnTarget.cxx:118
 AliRsnTarget.cxx:119
 AliRsnTarget.cxx:120
 AliRsnTarget.cxx:121
 AliRsnTarget.cxx:122