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 classes objects
19 : //
20 : //
21 : ///////////////////////////////////////////////////////////////////////////////
22 : #include <Riostream.h>
23 : #include <TMath.h>
24 :
25 : #include "AliLog.h"
26 : #include "AliTriggerClass.h"
27 : #include "AliTriggerConfiguration.h"
28 : #include "AliTriggerDescriptor.h"
29 : #include "AliTriggerCluster.h"
30 : #include "AliTriggerPFProtection.h"
31 : #include "AliTriggerBCMask.h"
32 :
33 : using std::endl;
34 : using std::cout;
35 : using std::hex;
36 : using std::dec;
37 172 : ClassImp(AliTriggerClass)
38 :
39 : //_____________________________________________________________________________
40 : AliTriggerClass::AliTriggerClass():
41 90 : TNamed(),
42 90 : fClassMask(0),
43 90 : fClassMaskNext50(0),
44 90 : fIndex(0),
45 90 : fDescriptor(NULL),
46 90 : fCluster(NULL),
47 90 : fPFProtection(NULL),
48 90 : fPrescaler(0),
49 90 : fAllRare(kFALSE),
50 90 : fStatus(kFALSE),
51 90 : fTimeGroup(0),
52 90 : fTimeWindow(0)
53 450 : {
54 : // Default constructor
55 2520 : for(Int_t i = 0; i < kNMaxMasks; i++)fMask[i]=0;
56 180 : }
57 :
58 : //_____________________________________________________________________________
59 : AliTriggerClass::AliTriggerClass( TString & name, UChar_t index,
60 : AliTriggerDescriptor *desc, AliTriggerCluster *clus,
61 : AliTriggerPFProtection *pfp, AliTriggerBCMask *mask,
62 : UInt_t prescaler, Bool_t allrare) :
63 0 : TNamed( name, name ),
64 0 : fClassMask((index<51) ? (1ull << ULong64_t(index-1)): 0),
65 0 : fClassMaskNext50((index<51) ? 0 :(1ull << ULong64_t(index-51))),
66 0 : fIndex(index),
67 0 : fDescriptor( desc ),
68 0 : fCluster( clus ),
69 0 : fPFProtection( pfp ),
70 0 : fPrescaler( prescaler ),
71 0 : fAllRare( allrare ),
72 0 : fStatus(kFALSE),
73 0 : fTimeGroup(0),
74 0 : fTimeWindow(0)
75 0 : {
76 : // Constructor
77 : // This should be used with old version of config
78 0 : for(Int_t i = 0; i < kNMaxMasks; i++)fMask[i]=0;
79 0 : fMask[0]=mask;
80 0 : }
81 :
82 : //_____________________________________________________________________________
83 : AliTriggerClass::AliTriggerClass( AliTriggerConfiguration *config,
84 : TString & name, UChar_t index,
85 : TString &desc, TString &clus,
86 : TString &pfp, TString &mask,
87 : UInt_t prescaler, Bool_t allrare) :
88 18 : TNamed( name, name ),
89 54 : fClassMask((index<51) ? (1ull << ULong64_t(index-1)): 0),
90 36 : fClassMaskNext50((index<51) ? 0 :(1ull << ULong64_t(index-51))),
91 18 : fIndex(index),
92 18 : fDescriptor( NULL ),
93 18 : fCluster( NULL ),
94 18 : fPFProtection( NULL ),
95 18 : fPrescaler( prescaler ),
96 18 : fAllRare( allrare ),
97 18 : fStatus(kFALSE),
98 18 : fTimeGroup(0),
99 18 : fTimeWindow(0)
100 54 : {
101 : // This should be used with old version of config
102 54 : fDescriptor = (AliTriggerDescriptor*)config->GetDescriptors().FindObject(desc);
103 54 : fCluster = (AliTriggerCluster*)config->GetClusters().FindObject(clus);
104 18 : pfp.ReplaceAll("{","");
105 18 : pfp.ReplaceAll("}","");
106 54 : fPFProtection = (AliTriggerPFProtection*)config->GetPFProtections().FindObject(pfp);
107 : // BC masks
108 504 : for(Int_t i = 0; i < kNMaxMasks; i++)fMask[i]=0;
109 18 : mask.ReplaceAll("{","");
110 18 : mask.ReplaceAll("}","");
111 54 : fMask[0] = (AliTriggerBCMask*)config->GetMasks().FindObject(mask);
112 36 : }
113 : //_____________________________________________________________________________
114 : AliTriggerClass::AliTriggerClass( AliTriggerConfiguration *config,
115 : TString & name, UChar_t index,
116 : TString &desc, TString &clus,
117 : TString &pfp,
118 : UInt_t prescaler, Bool_t allrare,
119 : UInt_t timegroup,UInt_t timewindow) :
120 0 : TNamed( name, name ),
121 0 : fClassMask((index<51) ? (1ull << ULong64_t(index-1)): 0),
122 0 : fClassMaskNext50((index<51) ? 0 :(1ull << ULong64_t(index-51))),
123 0 : fIndex(index),
124 0 : fDescriptor( NULL ),
125 0 : fCluster( NULL ),
126 0 : fPFProtection( NULL ),
127 0 : fPrescaler( prescaler ),
128 0 : fAllRare( allrare ),
129 0 : fStatus(kFALSE),
130 0 : fTimeGroup(timegroup),
131 0 : fTimeWindow(timewindow)
132 0 : {
133 0 : fDescriptor = (AliTriggerDescriptor*)config->GetDescriptors().FindObject(desc);
134 0 : fCluster = (AliTriggerCluster*)config->GetClusters().FindObject(clus);
135 0 : pfp.ReplaceAll("{","");
136 0 : pfp.ReplaceAll("}","");
137 0 : fPFProtection = (AliTriggerPFProtection*)config->GetPFProtections().FindObject(pfp);
138 : // masks are added by seter
139 0 : for(Int_t i = 0; i < kNMaxMasks; i++)fMask[i]=0;
140 0 : }
141 : //_____________________________________________________________________________
142 : AliTriggerClass::~AliTriggerClass()
143 288 : {
144 : // Destructor
145 288 : }
146 : //_____________________________________________________________________________
147 : AliTriggerClass::AliTriggerClass( const AliTriggerClass& trclass ):
148 0 : TNamed( trclass ),
149 0 : fClassMask(trclass.fClassMask),
150 0 : fClassMaskNext50(trclass.fClassMaskNext50),
151 0 : fIndex(trclass.fIndex),
152 0 : fDescriptor(trclass.fDescriptor),
153 0 : fCluster(trclass.fCluster),
154 0 : fPFProtection(trclass.fPFProtection),
155 0 : fPrescaler(trclass.fPrescaler),
156 0 : fAllRare(trclass.fAllRare),
157 0 : fStatus(trclass.fStatus),
158 0 : fTimeGroup(trclass.fTimeGroup),
159 0 : fTimeWindow(trclass.fTimeWindow)
160 0 : {
161 : // Copy constructor
162 0 : for(Int_t i = 0; i < kNMaxMasks; i++)fMask[i]=trclass.fMask[i];
163 0 : }
164 : //______________________________________________________________________________
165 : AliTriggerClass& AliTriggerClass::operator=(const AliTriggerClass& trclass)
166 : {
167 : // AliTriggerClass assignment operator.
168 :
169 0 : if (this != &trclass) {
170 0 : TNamed::operator=(trclass);
171 0 : fClassMask = trclass.fClassMask;
172 0 : fClassMaskNext50 = trclass.fClassMaskNext50;
173 0 : fIndex=trclass.fIndex;
174 0 : fDescriptor = trclass.fDescriptor;
175 0 : fCluster = trclass.fCluster;
176 0 : fPFProtection = trclass.fPFProtection;
177 0 : for(Int_t i=0; i< kNMaxMasks; i++)fMask[i]=trclass.fMask[i];
178 0 : fPrescaler = trclass.fPrescaler;
179 0 : fAllRare = trclass.fAllRare;
180 0 : fStatus = trclass.fStatus;
181 0 : fTimeGroup = trclass.fTimeGroup;
182 0 : fTimeWindow = trclass.fTimeWindow;
183 0 : }
184 0 : return *this;
185 : }
186 : //_____________________________________________________________________________
187 : Bool_t AliTriggerClass::SetMasks(AliTriggerConfiguration* config,TString& masks)
188 : {
189 0 : masks.ReplaceAll("{","");
190 0 : masks.ReplaceAll("}","");
191 0 : masks.ReplaceAll(" ","");
192 0 : masks.ReplaceAll("\t","");
193 0 : TObjArray *tokens = masks.Tokenize(",");
194 0 : Int_t ntokens = tokens->GetEntriesFast();
195 0 : if(ntokens==0){
196 0 : delete tokens;
197 0 : AliError(Form("The class (%s) has invalid mask pattern: (%s)",GetName(),masks.Data()));
198 0 : return kFALSE;
199 : }
200 : Int_t nmask=0;
201 0 : while(fMask[nmask])nmask++;
202 0 : if(nmask+ntokens>=kNMaxMasks){
203 0 : delete tokens;
204 0 : AliError(Form("The class (%s) exceeds %i masks",GetName(),kNMaxMasks));
205 0 : return kFALSE;
206 : }
207 0 : for(Int_t i=nmask; i<nmask+ntokens; i++){
208 0 : fMask[i] = (AliTriggerBCMask*)config->GetMasks().FindObject(((TObjString*)tokens->At(i-nmask))->String());
209 0 : if(!fMask[i]){
210 0 : AliError(Form("The class (%s) unknown mask %s",GetName(),(((TObjString*)tokens->At(i-nmask))->String().Data())));
211 0 : return kFALSE;
212 : }
213 : }
214 0 : delete tokens;
215 0 : return kTRUE;
216 0 : }
217 : //_____________________________________________________________________________
218 : Bool_t AliTriggerClass::CheckClass(AliTriggerConfiguration* config) const
219 : {
220 : // Check the existance of trigger inputs and functions
221 : // and the logic used.
222 : // Return false in case of wrong class
223 : // definition.
224 :
225 36 : if (!fClassMask && !fClassMaskNext50) {
226 0 : AliError(Form("The class (%s) has invalid mask pattern !",GetName()));
227 0 : return kFALSE;
228 : }
229 :
230 : // check consistency of index and mask
231 :
232 18 : if (!config->GetDescriptors().FindObject(fDescriptor)) {
233 0 : AliError(Form("The class (%s) contains invalid descriptor !",GetName()));
234 0 : return kFALSE;
235 : }
236 : else {
237 18 : if (!(fDescriptor->CheckInputsAndFunctions(config->GetInputs(),config->GetFunctions()))) {
238 0 : AliError(Form("The class (%s) contains bad descriptor !",GetName()));
239 0 : return kFALSE;
240 : }
241 : }
242 :
243 18 : if (!config->GetClusters().FindObject(fCluster)) {
244 0 : AliError(Form("The class (%s) contains invalid cluster !",GetName()));
245 0 : return kFALSE;
246 : }
247 :
248 18 : if (!config->GetPFProtections().FindObject(fPFProtection)) {
249 0 : AliError(Form("The class (%s) contains invalid past-future protection !",GetName()));
250 0 : return kFALSE;
251 : }
252 :
253 522 : for(Int_t i=0; i< kNMaxMasks; i++){
254 234 : if(fMask[i]){
255 18 : if (!config->GetMasks().FindObject(fMask[i])) {
256 0 : AliError(Form("The class (%s) contains invalid BC mask !",GetName()));
257 0 : return kFALSE;
258 : }
259 : }
260 : }
261 18 : return kTRUE;
262 18 : }
263 :
264 : //_____________________________________________________________________________
265 : void AliTriggerClass::Trigger( const TObjArray& inputs , const TObjArray& functions)
266 : {
267 : // Check if the inputs satify the trigger class conditions
268 144 : fStatus = fDescriptor->Trigger(inputs,functions);
269 72 : }
270 :
271 : //_____________________________________________________________________________
272 : Bool_t AliTriggerClass::IsActive( const TObjArray& inputs, const TObjArray& functions) const
273 : {
274 : // Check if the inputs satify the trigger class conditions
275 0 : if (fDescriptor)
276 0 : return fDescriptor->IsActive(inputs,functions);
277 :
278 0 : return kFALSE;
279 0 : }
280 :
281 : //_____________________________________________________________________________
282 : void AliTriggerClass::Print( const Option_t* ) const
283 : {
284 : // Print
285 0 : cout << "Trigger Class:" << endl;
286 0 : cout << " Name: " << GetName() << endl;
287 0 : cout << " ClassBit: 1..50 0x" << hex << fClassMask << " 51..10 0x" << fClassMaskNext50 << dec << endl;
288 0 : cout << " Index: " << (UInt_t)fIndex << endl;
289 0 : cout << " Descriptor: " << fDescriptor->GetName() << endl;
290 0 : cout << " Cluster: " << fCluster->GetName() << endl;
291 0 : cout << " PF Protection:" << fPFProtection->GetName() << endl;
292 0 : cout << " BC Mask: " ;
293 0 : for(Int_t i=0; i< kNMaxMasks; i++)if(fMask[i])cout << fMask[i]->GetName() << " ";
294 0 : cout << endl;
295 0 : cout << " Prescaler: " << fPrescaler << endl;
296 0 : cout << " AllRare: " << fAllRare << endl;
297 0 : cout << " Time Group: " << fTimeGroup << endl;
298 0 : cout << " Time Window: " << fTimeWindow << endl;
299 0 : if (fStatus)
300 0 : cout << " Class is fired " << endl;
301 : else
302 0 : cout << " Class is not fired " << endl;
303 0 : }
304 : //______________________________________________________________________
305 : Int_t AliTriggerClass::GetDownscaleFactor(Double_t& ds) const
306 : {
307 : // There are 2 types of downscaling:
308 : // - Random time veto downscale (option=0 <=> bit 31=0)
309 : // - Class busy veto (option=1 <=> bit 31=1)
310 : //
311 : Int_t option=0;
312 0 : if(fPrescaler&(1<<31)) option=1;
313 0 : if(option){
314 0 : ds = (fPrescaler&0x1ffffff)/100.; // class busy in milisec
315 0 : }else{
316 0 : ds = 1.- fPrescaler/2097151.; // reduction factor in %
317 : }
318 0 : return option;
319 : }
320 :
|