]>
Commit | Line | Data |
---|---|---|
a5a091ce | 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 | ||
a5a091ce | 16 | /////////////////////////////////////////////////////////////////////////////// |
bacbe0fd | 17 | // |
51f6d619 | 18 | // This class which defines the trigger descriptor objects |
a5a091ce | 19 | // |
bacbe0fd | 20 | // |
a5a091ce | 21 | /////////////////////////////////////////////////////////////////////////////// |
22 | ||
51f6d619 | 23 | #include <Riostream.h> |
a5a091ce | 24 | #include <TObjArray.h> |
51f6d619 | 25 | #include <TObjString.h> |
a5a091ce | 26 | |
27 | #include "AliLog.h" | |
a5a091ce | 28 | #include "AliTriggerDescriptor.h" |
51f6d619 | 29 | #include "AliTriggerInput.h" |
30 | #include "AliTriggerInteraction.h" | |
a5a091ce | 31 | |
66b0310c | 32 | using std::endl; |
33 | using std::cout; | |
a5a091ce | 34 | ClassImp(AliTriggerDescriptor) |
35 | ||
a5a091ce | 36 | //_____________________________________________________________________________ |
37 | AliTriggerDescriptor::AliTriggerDescriptor(): | |
51f6d619 | 38 | TNamed() |
a5a091ce | 39 | { |
51f6d619 | 40 | // Default constructor |
a5a091ce | 41 | } |
42 | ||
43 | //_____________________________________________________________________________ | |
51f6d619 | 44 | AliTriggerDescriptor::AliTriggerDescriptor( TString & name, TString &cond ): |
45 | TNamed( name, cond ) | |
a5a091ce | 46 | { |
51f6d619 | 47 | // Constructor |
a5a091ce | 48 | } |
a5a091ce | 49 | //_____________________________________________________________________________ |
51f6d619 | 50 | AliTriggerDescriptor::~AliTriggerDescriptor() |
51 | { | |
52 | // Destructor | |
53 | } | |
54 | //_____________________________________________________________________________ | |
55 | AliTriggerDescriptor::AliTriggerDescriptor( const AliTriggerDescriptor& desc ): | |
56 | TNamed( desc ) | |
a5a091ce | 57 | { |
58 | // Copy constructor | |
bacbe0fd | 59 | } |
60 | ||
61 | //______________________________________________________________________________ | |
51f6d619 | 62 | AliTriggerDescriptor& AliTriggerDescriptor::operator=(const AliTriggerDescriptor& desc) |
bacbe0fd | 63 | { |
64 | // AliTriggerDescriptor assignment operator. | |
65 | ||
51f6d619 | 66 | if (this != &desc) { |
67 | TNamed::operator=(desc); | |
bacbe0fd | 68 | } |
69 | return *this; | |
a5a091ce | 70 | } |
71 | ||
72 | //_____________________________________________________________________________ | |
51f6d619 | 73 | Bool_t AliTriggerDescriptor::CheckInputsAndFunctions(const TObjArray &inputs, const TObjArray &functions) const |
a5a091ce | 74 | { |
51f6d619 | 75 | // Check the existance of trigger inputs and functions |
76 | // and the logic used. | |
77 | // Return false in case of wrong interaction | |
78 | // definition. | |
79 | ||
80 | TString condition( GetTitle() ); | |
81 | TObjArray* tokens = condition.Tokenize(" !&|()\t"); | |
82 | ||
83 | Bool_t IsInput = kFALSE; | |
84 | ||
85 | Int_t ntokens = tokens->GetEntriesFast(); | |
86 | for( Int_t i=0; i<ntokens; i++ ) { | |
87 | TObjString* iname = (TObjString*)tokens->At( i ); | |
88 | if (functions.FindObject(iname->String())) { | |
89 | // Logical function of the first 4 inputs | |
90 | if (IsInput) { | |
91 | AliError("Logical functions can not follow inputs, they are always declared first !"); | |
92 | delete tokens; | |
93 | return kFALSE; | |
94 | } | |
95 | IsInput = kFALSE; | |
96 | continue; | |
a5a091ce | 97 | } |
51f6d619 | 98 | if (inputs.FindObject(iname->String())) { |
99 | // already a trigger input | |
100 | IsInput = kTRUE; | |
101 | continue; | |
102 | } | |
103 | AliError(Form("Invalid trigger input or function (%s)",iname->String().Data())); | |
104 | delete tokens; | |
a5a091ce | 105 | return kFALSE; |
106 | } | |
107 | ||
51f6d619 | 108 | delete tokens; |
a5a091ce | 109 | return kTRUE; |
110 | } | |
111 | ||
112 | //_____________________________________________________________________________ | |
51f6d619 | 113 | Bool_t AliTriggerDescriptor::IsActive(const TObjArray &inputs, const TObjArray &functions) const |
a5a091ce | 114 | { |
51f6d619 | 115 | // Check if the trigger inputs and functions |
116 | // are active | |
117 | // Return false in case one or more inputs | |
118 | // are disabled | |
119 | TString condition( GetTitle() ); | |
120 | TObjArray* tokens = condition.Tokenize(" !&|()\t"); | |
121 | ||
122 | Int_t ntokens = tokens->GetEntriesFast(); | |
123 | for( Int_t i=0; i<ntokens; i++ ) { | |
124 | TObjString* iname = (TObjString*)tokens->At( i ); | |
125 | AliTriggerInteraction *interact = (AliTriggerInteraction *)functions.FindObject(iname->String()); | |
126 | if (interact) { | |
127 | if (!interact->IsActive(inputs)) { | |
128 | AliWarning(Form("The descriptor (%s) will be disabled, because the function (%s) is disabled", | |
129 | GetName(),iname->String().Data())); | |
130 | delete tokens; | |
131 | return kFALSE; | |
132 | } | |
133 | continue; | |
a5a091ce | 134 | } |
51f6d619 | 135 | AliTriggerInput *inp = (AliTriggerInput *)inputs.FindObject(iname->String()); |
136 | if (inp) { | |
137 | if (!inp->IsActive()) { | |
138 | AliWarning(Form("The descriptor (%s) will be disabled, because the input (%s) is disabled", | |
139 | GetName(),iname->String().Data())); | |
140 | delete tokens; | |
141 | return kFALSE; | |
142 | } | |
143 | continue; | |
144 | } | |
145 | AliError(Form("Desciptor (%s) contains invalid trigger input or function (%s)", | |
146 | GetName(),iname->String().Data())); | |
147 | delete tokens; | |
148 | return kFALSE; | |
a5a091ce | 149 | } |
a5a091ce | 150 | |
51f6d619 | 151 | delete tokens; |
152 | return kTRUE; | |
bacbe0fd | 153 | |
a5a091ce | 154 | } |
155 | ||
a5a091ce | 156 | //_____________________________________________________________________________ |
51f6d619 | 157 | Bool_t AliTriggerDescriptor::Trigger( const TObjArray &inputs, const TObjArray &functions) const |
a5a091ce | 158 | { |
51f6d619 | 159 | // Check if the inputs and functions |
160 | // satify the descriptor conditions | |
161 | ||
162 | TString condition( GetTitle() ); | |
163 | TObjArray* tokens = condition.Tokenize(" !&|()\t"); | |
164 | ||
165 | Int_t ntokens = tokens->GetEntriesFast(); | |
166 | for( Int_t i=0; i<ntokens; i++ ) { | |
167 | TObjString* iname = (TObjString*)tokens->At( i ); | |
168 | AliTriggerInteraction *interact = (AliTriggerInteraction *)functions.FindObject(iname->String()); | |
169 | if (interact) { | |
170 | if (!interact->Trigger(inputs)) { | |
171 | delete tokens; | |
172 | return kFALSE; | |
a5a091ce | 173 | } |
51f6d619 | 174 | continue; |
175 | } | |
176 | AliTriggerInput *inp = (AliTriggerInput *)inputs.FindObject(iname->String()); | |
177 | if (inp) { | |
178 | if (!inp->Status()) { | |
179 | delete tokens; | |
180 | return kFALSE; | |
92c1978f | 181 | } |
51f6d619 | 182 | continue; |
183 | } | |
184 | AliError(Form("Desciptor (%s) contains invalid trigger input or function (%s)", | |
185 | GetName(),iname->String().Data())); | |
186 | delete tokens; | |
187 | return kFALSE; | |
188 | } | |
a5a091ce | 189 | |
51f6d619 | 190 | delete tokens; |
191 | return kTRUE; | |
a5a091ce | 192 | |
a5a091ce | 193 | } |
194 | ||
a5a091ce | 195 | //_____________________________________________________________________________ |
51f6d619 | 196 | void AliTriggerDescriptor::Print( const Option_t* ) const |
a5a091ce | 197 | { |
51f6d619 | 198 | |
199 | cout << "Trigger Descriptor:" << endl; | |
200 | cout << " Name: " << GetName() << endl; | |
201 | cout << " Logic: " << GetTitle() << endl; | |
a5a091ce | 202 | } |