Line data Source code
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 :
16 : ///////////////////////////////////////////////////////////////////////////////
17 : //
18 : // This class which defines the trigger interaction objects
19 : //
20 : //
21 : ///////////////////////////////////////////////////////////////////////////////
22 :
23 : #include <Riostream.h>
24 : #include <TObjArray.h>
25 : #include <TObjString.h>
26 :
27 : #include "AliTriggerInteraction.h"
28 : #include "AliTriggerInput.h"
29 : #include "AliExpression.h"
30 : #include "AliLog.h"
31 :
32 : using std::endl;
33 : using std::cout;
34 172 : ClassImp(AliTriggerInteraction)
35 :
36 : //_____________________________________________________________________________
37 : AliTriggerInteraction::AliTriggerInteraction():
38 20 : TNamed()
39 100 : {
40 : // Default constructor
41 40 : }
42 :
43 : //_____________________________________________________________________________
44 : AliTriggerInteraction::AliTriggerInteraction( TString & name, TString &logic ):
45 4 : TNamed( name, logic )
46 20 : {
47 : // Constructor
48 8 : }
49 : //_____________________________________________________________________________
50 : AliTriggerInteraction::~AliTriggerInteraction()
51 64 : {
52 : // Destructor
53 64 : }
54 : //_____________________________________________________________________________
55 : AliTriggerInteraction::AliTriggerInteraction( const AliTriggerInteraction& interact ):
56 0 : TNamed( interact )
57 0 : {
58 : // Copy constructor
59 0 : }
60 :
61 : //______________________________________________________________________________
62 : AliTriggerInteraction& AliTriggerInteraction::operator=(const AliTriggerInteraction& interact)
63 : {
64 : // AliTriggerInteraction assignment operator.
65 :
66 0 : if (this != &interact) {
67 0 : TNamed::operator=(interact);
68 0 : }
69 0 : return *this;
70 : }
71 :
72 : //_____________________________________________________________________________
73 : Bool_t AliTriggerInteraction::CheckInputs(const TObjArray &inputs) const
74 : {
75 : // Check the existance of trigger inputs
76 : // and the logic used.
77 : // Return false in case of wrong interaction
78 : // definition.
79 :
80 8 : TString logic( GetTitle() );
81 12 : TObjArray* tokens = logic.Tokenize(" !&|()\t");
82 :
83 4 : Int_t ntokens = tokens->GetEntriesFast();
84 30 : for( Int_t i=0; i<ntokens; i++ ) {
85 18 : TObjString* iname = (TObjString*)tokens->At( i );
86 :
87 27 : AliTriggerInput *inp = (AliTriggerInput*)inputs.FindObject(iname->String().Data());
88 9 : if (!inp) {
89 0 : AliError( Form( "The trigger input (%s) is not available for Interaction (%s)",
90 : iname->String().Data(), GetName() ) );
91 0 : delete tokens;
92 0 : return kFALSE;
93 : }
94 18 : if (inp->GetMask() == 0 || inp->GetMask() > (1<<24)) { // New l0f can use all inputs
95 0 : AliError( Form( "The trigger input (%s) is not among the first 4 trigger inputs used to create interactions. Interaction (%s) is invalid",
96 : iname->String().Data(), GetName() ) );
97 0 : delete tokens;
98 0 : return kFALSE;
99 : }
100 9 : }
101 :
102 8 : delete tokens;
103 4 : return kTRUE;
104 4 : }
105 :
106 : //_____________________________________________________________________________
107 : Bool_t AliTriggerInteraction::IsActive(const TObjArray &inputs) const
108 : {
109 : // Check if the trigger inputs
110 : // are active
111 : // Return false in one or more inputs
112 : // are disabled
113 :
114 0 : TString logic( GetTitle() );
115 0 : TObjArray* tokens = logic.Tokenize(" !&|()\t");
116 :
117 0 : Int_t ntokens = tokens->GetEntriesFast();
118 0 : for( Int_t i=0; i<ntokens; i++ ) {
119 0 : TObjString* iname = (TObjString*)tokens->At( i );
120 :
121 0 : AliTriggerInput *inp = (AliTriggerInput *)inputs.FindObject(iname->String());
122 0 : if (!inp) {
123 0 : AliError( Form( "The trigger input (%s) is not available for Interaction (%s)",
124 : iname->String().Data(), GetName() ) );
125 0 : delete tokens;
126 0 : return kFALSE;
127 : }
128 : else {
129 0 : if (!inp->IsActive()) {
130 0 : AliWarning(Form("The interaction/function (%s) will be disabled, because the input (%s) is disabled",
131 : GetName(),iname->String().Data()));
132 0 : delete tokens;
133 0 : return kFALSE;
134 : }
135 : }
136 0 : }
137 :
138 0 : delete tokens;
139 0 : return kTRUE;
140 0 : }
141 :
142 : //_____________________________________________________________________________
143 : Bool_t AliTriggerInteraction::Trigger(const TObjArray& inputs ) const
144 : {
145 : // Check if the inputs satify the interaction expression condition
146 100 : AliExpression* exp = new AliExpression( GetTitle() );
147 20 : Bool_t status = exp->Value( inputs );
148 40 : delete exp;
149 20 : return status;
150 0 : }
151 :
152 : //_____________________________________________________________________________
153 : void AliTriggerInteraction::Print( const Option_t* ) const
154 : {
155 : // Print
156 0 : cout << "Trigger Interaction:" << endl;
157 0 : cout << " Name: " << GetName() << endl;
158 0 : cout << " Logic: " << GetTitle() << endl;
159 0 : }
|