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