]>
Commit | Line | Data |
---|---|---|
51f6d619 | 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 | /////////////////////////////////////////////////////////////////////////////// | |
17 | // | |
18 | // This class which defines the trigger interaction objects | |
19 | // | |
20 | // | |
21 | /////////////////////////////////////////////////////////////////////////////// | |
22 | ||
23 | #include <Riostream.h> | |
24 | #include <TObjArray.h> | |
25 | #include <TObjString.h> | |
26 | ||
27 | #include "AliTriggerInteraction.h" | |
28 | #include "AliTriggerInput.h" | |
29 | #include "AliExpression.h" | |
30 | #include "AliLog.h" | |
31 | ||
32 | ClassImp(AliTriggerInteraction) | |
33 | ||
34 | //_____________________________________________________________________________ | |
35 | AliTriggerInteraction::AliTriggerInteraction(): | |
36 | TNamed() | |
37 | { | |
38 | // Default constructor | |
39 | } | |
40 | ||
41 | //_____________________________________________________________________________ | |
42 | AliTriggerInteraction::AliTriggerInteraction( TString & name, TString &logic ): | |
43 | TNamed( name, logic ) | |
44 | { | |
45 | // Constructor | |
46 | } | |
47 | //_____________________________________________________________________________ | |
48 | AliTriggerInteraction::~AliTriggerInteraction() | |
49 | { | |
50 | // Destructor | |
51 | } | |
52 | //_____________________________________________________________________________ | |
53 | AliTriggerInteraction::AliTriggerInteraction( const AliTriggerInteraction& interact ): | |
54 | TNamed( interact ) | |
55 | { | |
56 | // Copy constructor | |
57 | } | |
58 | ||
59 | //______________________________________________________________________________ | |
60 | AliTriggerInteraction& AliTriggerInteraction::operator=(const AliTriggerInteraction& interact) | |
61 | { | |
62 | // AliTriggerInteraction assignment operator. | |
63 | ||
64 | if (this != &interact) { | |
65 | TNamed::operator=(interact); | |
66 | } | |
67 | return *this; | |
68 | } | |
69 | ||
70 | //_____________________________________________________________________________ | |
71 | Bool_t AliTriggerInteraction::CheckInputs(const TObjArray &inputs) const | |
72 | { | |
73 | // Check the existance of trigger inputs | |
74 | // and the logic used. | |
75 | // Return false in case of wrong interaction | |
76 | // definition. | |
77 | ||
78 | TString logic( GetTitle() ); | |
79 | TObjArray* tokens = logic.Tokenize(" !&|()\t"); | |
80 | ||
81 | Int_t ntokens = tokens->GetEntriesFast(); | |
82 | for( Int_t i=0; i<ntokens; i++ ) { | |
83 | TObjString* iname = (TObjString*)tokens->At( i ); | |
84 | ||
85 | AliTriggerInput *inp = (AliTriggerInput*)inputs.FindObject(iname->String().Data()); | |
86 | if (!inp) { | |
87 | AliError( Form( "The trigger input (%s) is not available for Interaction (%s)", | |
88 | iname->String().Data(), GetName() ) ); | |
89 | delete tokens; | |
90 | return kFALSE; | |
91 | } | |
92 | if (inp->GetMask() == 0 || inp->GetMask() > 16) { | |
93 | AliError( Form( "The trigger input (%s) is not among the first 4 trigger inputs used to create interactions. Interaction (%s) is invalid", | |
94 | iname->String().Data(), GetName() ) ); | |
95 | delete tokens; | |
96 | return kFALSE; | |
97 | } | |
98 | } | |
99 | ||
100 | delete tokens; | |
101 | return kTRUE; | |
102 | } | |
103 | ||
104 | //_____________________________________________________________________________ | |
105 | Bool_t AliTriggerInteraction::IsActive(const TObjArray &inputs) const | |
106 | { | |
107 | // Check if the trigger inputs | |
108 | // are active | |
109 | // Return false in one or more inputs | |
110 | // are disabled | |
111 | ||
112 | TString logic( GetTitle() ); | |
113 | TObjArray* tokens = logic.Tokenize(" !&|()\t"); | |
114 | ||
115 | Int_t ntokens = tokens->GetEntriesFast(); | |
116 | for( Int_t i=0; i<ntokens; i++ ) { | |
117 | TObjString* iname = (TObjString*)tokens->At( i ); | |
118 | ||
119 | AliTriggerInput *inp = (AliTriggerInput *)inputs.FindObject(iname->String()); | |
120 | if (!inp) { | |
121 | AliError( Form( "The trigger input (%s) is not available for Interaction (%s)", | |
122 | iname->String().Data(), GetName() ) ); | |
123 | delete tokens; | |
124 | return kFALSE; | |
125 | } | |
126 | else { | |
127 | if (!inp->IsActive()) { | |
128 | AliWarning(Form("The interaction/function (%s) will be disabled, because the input (%s) is disabled", | |
129 | GetName(),iname->String().Data())); | |
130 | delete tokens; | |
131 | return kFALSE; | |
132 | } | |
133 | } | |
134 | } | |
135 | ||
136 | delete tokens; | |
137 | return kTRUE; | |
138 | } | |
139 | ||
140 | //_____________________________________________________________________________ | |
141 | Bool_t AliTriggerInteraction::Trigger(const TObjArray& inputs ) const | |
142 | { | |
143 | // Check if the inputs satify the interaction expression condition | |
144 | AliExpression* exp = new AliExpression( GetTitle() ); | |
145 | Bool_t status = exp->Value( inputs ); | |
146 | delete exp; | |
147 | return status; | |
148 | } | |
149 | ||
150 | //_____________________________________________________________________________ | |
151 | void AliTriggerInteraction::Print( const Option_t* ) const | |
152 | { | |
153 | ||
154 | cout << "Trigger Interaction:" << endl; | |
155 | cout << " Name: " << GetName() << endl; | |
156 | cout << " Logic: " << GetTitle() << endl; | |
157 | } |