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