Changes for #82873: Module debugging broken (Christian)
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnTarget.cxx
CommitLineData
7356f978 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16////////////////////////////////////////////////////////////////////////////////
a6bda389 17//
7356f978 18// Base class used wherever it is needed to check the class type of
19// an object w.r. to the RSN framework analysis (daughter, mother, event)
20// which could be used for cut checking or value computing.
21// Since most of these operation are implemented into classes that
22// operate on any of such objects, then this class helps in making sure
23// that the object being processed corresponds to what is expected.
24// It also contains three pointers to which any passed object is casted
25// in order to have a quick reference to any allowed object type from
26// an appropriate pointer, which is propagated to all inheriting classes.
a6bda389 27//
7356f978 28// authors: A. Pulvirenti (alberto.pulvirenti@ct.infn.it)
29// M. Vala (martin.vala@cern.ch)
eaa44581 30//
7356f978 31////////////////////////////////////////////////////////////////////////////////
a6bda389 32
928bbcdb 33#include "AliLog.h"
34
a6bda389 35#include "AliRsnDaughter.h"
36#include "AliRsnMother.h"
37
38#include "AliRsnTarget.h"
39
40ClassImp(AliRsnTarget)
41
42//_____________________________________________________________________________
35e49ca5 43Bool_t AliRsnTarget::TargetOK(TObject *object)
a6bda389 44{
45//
d7712d44 46// This method doew the following things:
eaa44581 47// 1) check if the object class matches the required target type
48// 2) if (1) is successful, set the built-in pointer data member
49// in order to point to it, after being casted accordingly
d7712d44 50// 3) if the target is a daughter or a mother, adjust the pointer
51// to reference event accordingly
a6bda389 52//
53
99261e24 54 // reset local pointers and then initialize
55 // only the right one by static cast, if found
56 fDaughter = 0x0;
57 fMother = 0x0;
58 fEvent = 0x0;
d7712d44 59
60 // fails by default if a NULL pointer is passed
61 if (!object) {
62 AliError("Passed a NULL object");
63 return kFALSE;
64 }
65
66 // checks matching between argument type and expected object type
67 // the passed object is also casted into the appropriate pointer
68 // when a daughter or mother is passed and the target type expects
69 // and event, the check is yes successful and the owner event is used
70 if (object->IsA() == AliRsnDaughter::Class() && (fTargetType == kDaughter || fTargetType == kEvent)) {
99261e24 71 fDaughter = static_cast<AliRsnDaughter*>(object);
d7712d44 72 fEvent = fDaughter->GetOwnerEvent();
99261e24 73 return kTRUE;
2a1c7696 74 }
d7712d44 75 else if (object->IsA() == AliRsnMother::Class() && (fTargetType == kMother || fTargetType == kEvent)) {
99261e24 76 fMother = static_cast<AliRsnMother*>(object);
d7712d44 77 fEvent = fMother->GetRefEvent();
99261e24 78 return kTRUE;
79 }
80 else if (object->IsA() == AliRsnEvent::Class() && fTargetType == kEvent) {
81 fEvent = static_cast<AliRsnEvent*>(object);
82 return kTRUE;
83 }
84 else {
d7712d44 85 if (object) {
86 AliError(Form("[%s] Target mismatch: expected '%s', passed '%s'", GetName(), GetTargetTypeName(), object->ClassName()));
87 } else {
88 AliError(Form("[%s] Target mismatch: expected '%s', passed 'NULL'", GetName(), GetTargetTypeName()));
89 }
99261e24 90 return kFALSE;
2a1c7696 91 }
a6bda389 92}
93
94//______________________________________________________________________________
95Char_t AliRsnTarget::GetTargetTypeChar() const
96{
97//
98// Returns a single character identifying the cut target type.
99//
100
2a1c7696 101 switch (fTargetType) {
102 case kDaughter: return 'D';
103 case kMother: return 'M';
104 case kEvent: return 'E';
105 default: return 'X';
106 }
a6bda389 107}
108
109//______________________________________________________________________________
110const char* AliRsnTarget::GetTargetTypeName() const
111{
112//
113// Returns a string with the name of the cut target type-
114//
115
2a1c7696 116 switch (fTargetType) {
117 case kDaughter: return "Daughter";
118 case kMother: return "Mother";
119 case kEvent: return "Event";
120 default: return "Undefined";
121 }
a6bda389 122}