1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 ///////////////////////////////////////////////////////////////////////////////
18 // This class which defines the trigger descriptor objects
21 ///////////////////////////////////////////////////////////////////////////////
23 #include <Riostream.h>
24 #include <TObjArray.h>
25 #include <TObjString.h>
28 #include "AliTriggerDescriptor.h"
29 #include "AliTriggerInput.h"
30 #include "AliTriggerInteraction.h"
32 ClassImp(AliTriggerDescriptor)
34 //_____________________________________________________________________________
35 AliTriggerDescriptor::AliTriggerDescriptor():
38 // Default constructor
41 //_____________________________________________________________________________
42 AliTriggerDescriptor::AliTriggerDescriptor( TString & name, TString &cond ):
47 //_____________________________________________________________________________
48 AliTriggerDescriptor::~AliTriggerDescriptor()
52 //_____________________________________________________________________________
53 AliTriggerDescriptor::AliTriggerDescriptor( const AliTriggerDescriptor& desc ):
59 //______________________________________________________________________________
60 AliTriggerDescriptor& AliTriggerDescriptor::operator=(const AliTriggerDescriptor& desc)
62 // AliTriggerDescriptor assignment operator.
65 TNamed::operator=(desc);
70 //_____________________________________________________________________________
71 Bool_t AliTriggerDescriptor::CheckInputsAndFunctions(const TObjArray &inputs, const TObjArray &functions) const
73 // Check the existance of trigger inputs and functions
74 // and the logic used.
75 // Return false in case of wrong interaction
78 TString condition( GetTitle() );
79 TObjArray* tokens = condition.Tokenize(" !&|()\t");
81 Bool_t IsInput = kFALSE;
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
89 AliError("Logical functions can not follow inputs, they are always declared first !");
96 if (inputs.FindObject(iname->String())) {
97 // already a trigger input
101 AliError(Form("Invalid trigger input or function (%s)",iname->String().Data()));
110 //_____________________________________________________________________________
111 Bool_t AliTriggerDescriptor::IsActive(const TObjArray &inputs, const TObjArray &functions) const
113 // Check if the trigger inputs and functions
115 // Return false in case one or more inputs
117 TString condition( GetTitle() );
118 TObjArray* tokens = condition.Tokenize(" !&|()\t");
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());
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()));
133 AliTriggerInput *inp = (AliTriggerInput *)inputs.FindObject(iname->String());
135 if (!inp->IsActive()) {
136 AliWarning(Form("The descriptor (%s) will be disabled, because the input (%s) is disabled",
137 GetName(),iname->String().Data()));
143 AliError(Form("Desciptor (%s) contains invalid trigger input or function (%s)",
144 GetName(),iname->String().Data()));
154 //_____________________________________________________________________________
155 Bool_t AliTriggerDescriptor::Trigger( const TObjArray &inputs, const TObjArray &functions) const
157 // Check if the inputs and functions
158 // satify the descriptor conditions
160 TString condition( GetTitle() );
161 TObjArray* tokens = condition.Tokenize(" !&|()\t");
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());
168 if (!interact->Trigger(inputs)) {
174 AliTriggerInput *inp = (AliTriggerInput *)inputs.FindObject(iname->String());
176 if (!inp->Status()) {
182 AliError(Form("Desciptor (%s) contains invalid trigger input or function (%s)",
183 GetName(),iname->String().Data()));
193 //_____________________________________________________________________________
194 void AliTriggerDescriptor::Print( const Option_t* ) const
197 cout << "Trigger Descriptor:" << endl;
198 cout << " Name: " << GetName() << endl;
199 cout << " Logic: " << GetTitle() << endl;