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 interaction objects
21 ///////////////////////////////////////////////////////////////////////////////
23 #include <Riostream.h>
24 #include <TObjArray.h>
25 #include <TObjString.h>
27 #include "AliTriggerInteraction.h"
28 #include "AliTriggerInput.h"
29 #include "AliExpression.h"
32 ClassImp(AliTriggerInteraction)
34 //_____________________________________________________________________________
35 AliTriggerInteraction::AliTriggerInteraction():
38 // Default constructor
41 //_____________________________________________________________________________
42 AliTriggerInteraction::AliTriggerInteraction( TString & name, TString &logic ):
47 //_____________________________________________________________________________
48 AliTriggerInteraction::~AliTriggerInteraction()
52 //_____________________________________________________________________________
53 AliTriggerInteraction::AliTriggerInteraction( const AliTriggerInteraction& interact ):
59 //______________________________________________________________________________
60 AliTriggerInteraction& AliTriggerInteraction::operator=(const AliTriggerInteraction& interact)
62 // AliTriggerInteraction assignment operator.
64 if (this != &interact) {
65 TNamed::operator=(interact);
70 //_____________________________________________________________________________
71 Bool_t AliTriggerInteraction::CheckInputs(const TObjArray &inputs) const
73 // Check the existance of trigger inputs
74 // and the logic used.
75 // Return false in case of wrong interaction
78 TString logic( GetTitle() );
79 TObjArray* tokens = logic.Tokenize(" !&|()\t");
81 Int_t ntokens = tokens->GetEntriesFast();
82 for( Int_t i=0; i<ntokens; i++ ) {
83 TObjString* iname = (TObjString*)tokens->At( i );
85 AliTriggerInput *inp = (AliTriggerInput*)inputs.FindObject(iname->String().Data());
87 AliError( Form( "The trigger input (%s) is not available for Interaction (%s)",
88 iname->String().Data(), GetName() ) );
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() ) );
104 //_____________________________________________________________________________
105 Bool_t AliTriggerInteraction::IsActive(const TObjArray &inputs) const
107 // Check if the trigger inputs
109 // Return false in one or more inputs
112 TString logic( GetTitle() );
113 TObjArray* tokens = logic.Tokenize(" !&|()\t");
115 Int_t ntokens = tokens->GetEntriesFast();
116 for( Int_t i=0; i<ntokens; i++ ) {
117 TObjString* iname = (TObjString*)tokens->At( i );
119 AliTriggerInput *inp = (AliTriggerInput *)inputs.FindObject(iname->String());
121 AliError( Form( "The trigger input (%s) is not available for Interaction (%s)",
122 iname->String().Data(), GetName() ) );
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()));
140 //_____________________________________________________________________________
141 Bool_t AliTriggerInteraction::Trigger(const TObjArray& inputs ) const
143 // Check if the inputs satify the interaction expression condition
144 AliExpression* exp = new AliExpression( GetTitle() );
145 Bool_t status = exp->Value( inputs );
150 //_____________________________________________________________________________
151 void AliTriggerInteraction::Print( const Option_t* ) const
154 cout << "Trigger Interaction:" << endl;
155 cout << " Name: " << GetName() << endl;
156 cout << " Logic: " << GetTitle() << endl;