Introduce a limit on the gain factor (Raphaelle)
[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
eaa44581 42AliRsnEvent* AliRsnTarget::fgCurrentEvent = 0x0;
43const Double_t AliRsnTarget::fgkVeryBig = 1E+10;
44const Double_t AliRsnTarget::fgkVerySmall = 1E-10;
35e49ca5 45
a6bda389 46//_____________________________________________________________________________
35e49ca5 47Bool_t AliRsnTarget::TargetOK(TObject *object)
a6bda389 48{
49//
eaa44581 50// This method doew two things:
51// 1) check if the object class matches the required target type
52// 2) if (1) is successful, set the built-in pointer data member
53// in order to point to it, after being casted accordingly
a6bda389 54//
55
2a1c7696 56 // fails by default if a NULL pointer is passed
99261e24 57 if (!object) return kFALSE;
58
59 // reset local pointers and then initialize
60 // only the right one by static cast, if found
61 fDaughter = 0x0;
62 fMother = 0x0;
63 fEvent = 0x0;
64 if (object->IsA() == AliRsnDaughter::Class() && fTargetType == kDaughter) {
65 fDaughter = static_cast<AliRsnDaughter*>(object);
66 return kTRUE;
2a1c7696 67 }
99261e24 68 else if (object->IsA() == AliRsnMother::Class() && fTargetType == kMother) {
69 fMother = static_cast<AliRsnMother*>(object);
70 return kTRUE;
71 }
72 else if (object->IsA() == AliRsnEvent::Class() && fTargetType == kEvent) {
73 fEvent = static_cast<AliRsnEvent*>(object);
74 return kTRUE;
75 }
76 else {
77 AliError(Form("[%s] Target mismatch: expected '%s', passed '%s'", GetName(), GetTargetTypeName(), object->ClassName()));
78 return kFALSE;
2a1c7696 79 }
a6bda389 80}
81
82//______________________________________________________________________________
83Char_t AliRsnTarget::GetTargetTypeChar() const
84{
85//
86// Returns a single character identifying the cut target type.
87//
88
2a1c7696 89 switch (fTargetType) {
90 case kDaughter: return 'D';
91 case kMother: return 'M';
92 case kEvent: return 'E';
93 default: return 'X';
94 }
a6bda389 95}
96
97//______________________________________________________________________________
98const char* AliRsnTarget::GetTargetTypeName() const
99{
100//
101// Returns a string with the name of the cut target type-
102//
103
2a1c7696 104 switch (fTargetType) {
105 case kDaughter: return "Daughter";
106 case kMother: return "Mother";
107 case kEvent: return "Event";
108 default: return "Undefined";
109 }
a6bda389 110}