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