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 *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
19 ///////////////////////////////////////////////////////////////////////////////
21 // Class to define a Trigger Condition //
23 // Ej Condition name Description class mask
24 // inputs names ___ _________ _________
26 // AliTriggerCondition("(T0_L0 & VZERO_MB_L0 & TRD_PRE_L0)", "MB", "Minimum Bias", 0x0100 );
28 // A Trigger condition is defined from logical combination of trigger
29 // inputs names (boolean expression), trigger inputs names must match
30 // with the inputs defined in AliTriggerDetector classes
37 // The name must be globally unique. Spaces are not allowed.
39 // A maximun of 50 diffentes trigger signatures ("trigger classes" or conditions)
40 // are allow to run simultaneously.
41 // So, the "class mask" should set only 1 bit from the position 1 to 50.
44 ///////////////////////////////////////////////////////////////////////////////
46 #include <Riostream.h>
48 #include <TObjString.h>
49 #include <TObjArray.h>
52 #include "AliExpression.h"
53 #include "AliTriggerInput.h"
54 #include "AliTriggerCondition.h"
56 ClassImp( AliTriggerCondition )
58 //_____________________________________________________________________________
59 AliTriggerCondition::AliTriggerCondition() :
68 //______________________________________________________________________________
69 AliTriggerCondition::AliTriggerCondition(const AliTriggerCondition &cond) :
71 fClassMask( cond.fClassMask ),
72 fCondition( cond.fCondition ),
73 fStatus( cond.fStatus )
75 // AliTriggerCondition copy ctor.
78 //______________________________________________________________________________
79 AliTriggerCondition& AliTriggerCondition::operator=(const AliTriggerCondition& rhs)
81 // AliTriggerCondition assignment operator.
84 TNamed::operator=(rhs);
85 fClassMask = rhs.fClassMask;
86 fCondition = rhs.fCondition;
91 //_____________________________________________________________________________
92 AliTriggerCondition::AliTriggerCondition( TString & condition, TString & name,
93 TString & description, ULong64_t mask ) :
94 TNamed( name, description ),
96 fCondition( condition ),
99 // Default Constructor
101 // check the expression
102 AliExpression* exp = new AliExpression( fCondition );
107 //_____________________________________________________________________________
108 Bool_t AliTriggerCondition::CheckInputs( TObjArray& inputs )
110 // The "inputs" array should be the list of all possible inputs
111 // so each input in the condition is checked to be present in the array
112 // return false if one input is missing
114 TString condition( fCondition );
115 TObjArray* tokens = condition.Tokenize(" !&|()");
117 Int_t ntokens = tokens->GetEntriesFast();
118 for( Int_t i=0; i<ntokens; i++ ) {
119 TObjString* iname = (TObjString*)tokens->At( i );
120 Int_t nInputs = inputs.GetEntriesFast();
122 for( j=0; j<nInputs; j++ ) {
123 AliTriggerInput* in = (AliTriggerInput*)inputs.At( j );
124 if( (iname->String()).CompareTo( in->GetName() ) == 0 ) break;
128 AliWarning( Form( "The trigger input (%s) is not available for Condition (%s)",
129 iname->String().Data(), GetName() ) );
139 //_____________________________________________________________________________
140 void AliTriggerCondition::Trigger( TObjArray& inputs )
142 // Check if the inputs satify the expression condition
143 AliExpression* exp = new AliExpression( fCondition );
144 fStatus = exp->Value( inputs );
148 //_____________________________________________________________________________
149 void AliTriggerCondition::Print( const Option_t* ) const
152 cout << "Trigger Condition:" << endl;
153 cout << " Name: " << GetName() << endl;
154 cout << " Description: " << GetTitle() << endl;
155 cout << " Condition: " << fCondition << endl;
156 cout << " Class Mask: " << "0x" << hex << fClassMask << endl;
157 cout << " Value: " << "0x" << hex << GetValue() << dec << endl;