]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliTriggerCondition.cxx
Check the overlaps above 1cm after the (mis)alignment (Raffaele)
[u/mrichter/AliRoot.git] / STEER / AliTriggerCondition.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
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 **************************************************************************/
16
17/* $Id$ */
18
19///////////////////////////////////////////////////////////////////////////////
20//
21// Class to define a Trigger Condition //
22//
23// Ej Condition name Description class mask
24// inputs names ___ _________ _________
25// | | |
26// AliTriggerCondition("(T0_L0 & VZERO_MB_L0 & TRD_PRE_L0)", "MB", "Minimum Bias", 0x0100 );
27//
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
31//
32// Allow operators:
33// & => and
34// | => or
35// ! => not
36//
37// The name must be globally unique. Spaces are not allowed.
38//
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.
42//
43//
44///////////////////////////////////////////////////////////////////////////////
45
46#include <Riostream.h>
47#include <TString.h>
48#include <TObjString.h>
49#include <TObjArray.h>
50
51#include "AliLog.h"
52#include "AliExpression.h"
53#include "AliTriggerInput.h"
54#include "AliTriggerCondition.h"
55
56ClassImp( AliTriggerCondition )
57
58//_____________________________________________________________________________
59AliTriggerCondition::AliTriggerCondition() :
60 TNamed(),
61 fClassMask( 0 ),
62 fCondition( "" ),
63 fStatus( kFALSE )
64{
65 // Default ctor
66}
67
68//______________________________________________________________________________
69AliTriggerCondition::AliTriggerCondition(const AliTriggerCondition &cond) :
70 TNamed( cond ),
71 fClassMask( cond.fClassMask ),
72 fCondition( cond.fCondition ),
73 fStatus( cond.fStatus )
74{
75 // AliTriggerCondition copy ctor.
76}
77
78//______________________________________________________________________________
79AliTriggerCondition& AliTriggerCondition::operator=(const AliTriggerCondition& rhs)
80{
81 // AliTriggerCondition assignment operator.
82
83 if (this != &rhs) {
bacbe0fd 84 TNamed::operator=(rhs);
a5a091ce 85 fClassMask = rhs.fClassMask;
86 fCondition = rhs.fCondition;
87 }
88 return *this;
89}
90
91//_____________________________________________________________________________
92AliTriggerCondition::AliTriggerCondition( TString & condition, TString & name,
92c1978f 93 TString & description, ULong64_t mask ) :
a5a091ce 94 TNamed( name, description ),
95 fClassMask( mask ),
96 fCondition( condition ),
97 fStatus( kFALSE )
98{
99 // Default Constructor
100
101 // check the expression
102 AliExpression* exp = new AliExpression( fCondition );
103 delete exp;
104}
105
106
107//_____________________________________________________________________________
108Bool_t AliTriggerCondition::CheckInputs( TObjArray& inputs )
109{
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
113
114 TString condition( fCondition );
92c1978f 115 TObjArray* tokens = condition.Tokenize(" !&|()");
a5a091ce 116
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();
121 Int_t j;
122 for( j=0; j<nInputs; j++ ) {
123 AliTriggerInput* in = (AliTriggerInput*)inputs.At( j );
124 if( (iname->String()).CompareTo( in->GetName() ) == 0 ) break;
125 }
126
127 if( j >= nInputs ) {
128 AliWarning( Form( "The trigger input (%s) is not available for Condition (%s)",
129 iname->String().Data(), GetName() ) );
130 delete tokens;
131 return kFALSE;
132 }
133 }
134
135 delete tokens;
136 return kTRUE;
137}
138
139//_____________________________________________________________________________
140void AliTriggerCondition::Trigger( TObjArray& inputs )
141{
142 // Check if the inputs satify the expression condition
a5a091ce 143 AliExpression* exp = new AliExpression( fCondition );
a5a091ce 144 fStatus = exp->Value( inputs );
145 delete exp;
146}
147
148//_____________________________________________________________________________
149void AliTriggerCondition::Print( const Option_t* ) const
150{
151 // Print
152 cout << "Trigger Condition:" << endl;
153 cout << " Name: " << GetName() << endl;
154 cout << " Description: " << GetTitle() << endl;
155 cout << " Condition: " << fCondition << endl;
92c1978f 156 cout << " Class Mask: " << "0x" << hex << fClassMask << endl;
157 cout << " Value: " << "0x" << hex << GetValue() << dec << endl;
a5a091ce 158}