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