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