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