]>
Commit | Line | Data |
---|---|---|
51f6d619 | 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 | ||
66b0310c | 32 | using std::endl; |
33 | using std::cout; | |
51f6d619 | 34 | ClassImp(AliTriggerInteraction) |
35 | ||
36 | //_____________________________________________________________________________ | |
37 | AliTriggerInteraction::AliTriggerInteraction(): | |
38 | TNamed() | |
39 | { | |
40 | // Default constructor | |
41 | } | |
42 | ||
43 | //_____________________________________________________________________________ | |
44 | AliTriggerInteraction::AliTriggerInteraction( TString & name, TString &logic ): | |
45 | TNamed( name, logic ) | |
46 | { | |
47 | // Constructor | |
48 | } | |
49 | //_____________________________________________________________________________ | |
50 | AliTriggerInteraction::~AliTriggerInteraction() | |
51 | { | |
52 | // Destructor | |
53 | } | |
54 | //_____________________________________________________________________________ | |
55 | AliTriggerInteraction::AliTriggerInteraction( const AliTriggerInteraction& interact ): | |
56 | TNamed( interact ) | |
57 | { | |
58 | // Copy constructor | |
59 | } | |
60 | ||
61 | //______________________________________________________________________________ | |
62 | AliTriggerInteraction& AliTriggerInteraction::operator=(const AliTriggerInteraction& interact) | |
63 | { | |
64 | // AliTriggerInteraction assignment operator. | |
65 | ||
66 | if (this != &interact) { | |
67 | TNamed::operator=(interact); | |
68 | } | |
69 | 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 | TString logic( GetTitle() ); | |
81 | TObjArray* tokens = logic.Tokenize(" !&|()\t"); | |
82 | ||
83 | Int_t ntokens = tokens->GetEntriesFast(); | |
84 | for( Int_t i=0; i<ntokens; i++ ) { | |
85 | TObjString* iname = (TObjString*)tokens->At( i ); | |
86 | ||
87 | AliTriggerInput *inp = (AliTriggerInput*)inputs.FindObject(iname->String().Data()); | |
88 | if (!inp) { | |
89 | AliError( Form( "The trigger input (%s) is not available for Interaction (%s)", | |
90 | iname->String().Data(), GetName() ) ); | |
91 | delete tokens; | |
92 | return kFALSE; | |
93 | } | |
e9bf49e8 | 94 | if (inp->GetMask() == 0 || inp->GetMask() > (1<<24)) { // New l0f can use all inputs |
51f6d619 | 95 | 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 | delete tokens; | |
98 | return kFALSE; | |
99 | } | |
100 | } | |
101 | ||
102 | delete tokens; | |
103 | return kTRUE; | |
104 | } | |
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 | TString logic( GetTitle() ); | |
115 | TObjArray* tokens = logic.Tokenize(" !&|()\t"); | |
116 | ||
117 | Int_t ntokens = tokens->GetEntriesFast(); | |
118 | for( Int_t i=0; i<ntokens; i++ ) { | |
119 | TObjString* iname = (TObjString*)tokens->At( i ); | |
120 | ||
121 | AliTriggerInput *inp = (AliTriggerInput *)inputs.FindObject(iname->String()); | |
122 | if (!inp) { | |
123 | AliError( Form( "The trigger input (%s) is not available for Interaction (%s)", | |
124 | iname->String().Data(), GetName() ) ); | |
125 | delete tokens; | |
126 | return kFALSE; | |
127 | } | |
128 | else { | |
129 | if (!inp->IsActive()) { | |
130 | AliWarning(Form("The interaction/function (%s) will be disabled, because the input (%s) is disabled", | |
131 | GetName(),iname->String().Data())); | |
132 | delete tokens; | |
133 | return kFALSE; | |
134 | } | |
135 | } | |
136 | } | |
137 | ||
138 | delete tokens; | |
139 | return kTRUE; | |
140 | } | |
141 | ||
142 | //_____________________________________________________________________________ | |
143 | Bool_t AliTriggerInteraction::Trigger(const TObjArray& inputs ) const | |
144 | { | |
145 | // Check if the inputs satify the interaction expression condition | |
146 | AliExpression* exp = new AliExpression( GetTitle() ); | |
147 | Bool_t status = exp->Value( inputs ); | |
148 | delete exp; | |
149 | return status; | |
150 | } | |
151 | ||
152 | //_____________________________________________________________________________ | |
153 | void AliTriggerInteraction::Print( const Option_t* ) const | |
154 | { | |
155 | ||
156 | cout << "Trigger Interaction:" << endl; | |
157 | cout << " Name: " << GetName() << endl; | |
158 | cout << " Logic: " << GetTitle() << endl; | |
159 | } |