Changes if SPD FO trigger simulation to cope with naming conventions (A. Mastroserio)
[u/mrichter/AliRoot.git] / ITS / AliITSTriggerFOProcessor.cxx
CommitLineData
ad7f2bfa 1/////////////////////////////////////////////////////////////////////
2// Author: Henrik Tydesjo //
3// //
4// This class takes care of simulating the output from the pixel //
5// trigger system. //
6// The fast-or signals are given as input and they are processed //
7// to see which algorithm will give a signal to the central //
8// trigger system. To avoid doing the same operations many times, //
9// there is a method called PreprocessFOSignals, which should //
10// always be called for each event before the processing of //
11// each individual algorithm is done. //
12// //
13// As soon as a new algorithm has been implemented online, a //
14// corresponding method should be implemented here. Which method //
15// should be used for a given trigger label is taken care of in //
16// ProcessFOSignalsLabel method. //
17// //
18/////////////////////////////////////////////////////////////////////
19
20#include "AliITSTriggerFOProcessor.h"
21#include "AliITSTriggerConditions.h"
22#include <TError.h>
23
24AliITSTriggerFOProcessor::AliITSTriggerFOProcessor() :
25 fFOInner(0), fFOOuter(0), fTriggerCond(NULL)
26{
27 // default constructor
28}
29//______________________________________________________________________
30AliITSTriggerFOProcessor::AliITSTriggerFOProcessor(AliITSTriggerConditions* ocdbCond) :
31 fFOInner(0), fFOOuter(0), fTriggerCond(ocdbCond)
32{
33 // constructor
34}
35//______________________________________________________________________
36AliITSTriggerFOProcessor::AliITSTriggerFOProcessor(const AliITSTriggerFOProcessor& handle):
37 fFOInner(handle.fFOInner), fFOOuter(handle.fFOOuter), fTriggerCond(handle.fTriggerCond)
38{
39 // copy constructor
40}
41//______________________________________________________________________
42AliITSTriggerFOProcessor::~AliITSTriggerFOProcessor() {
43 // destructor
44}
45//______________________________________________________________________
46AliITSTriggerFOProcessor& AliITSTriggerFOProcessor::operator=(const AliITSTriggerFOProcessor& handle) {
47 // assignment operator
48 if (this!=&handle) {
49 fFOInner = handle.fFOInner;
50 fFOOuter = handle.fFOOuter;
51 fTriggerCond = handle.fTriggerCond;
52 }
53 return *this;
54}
55//______________________________________________________________________
56void AliITSTriggerFOProcessor::SetTriggerConditions(AliITSTriggerConditions* ocdbCond) {
57 // Method to give pointer to the OCDB conditions entry
58 fTriggerCond = ocdbCond;
59}
60//______________________________________________________________________
61UInt_t AliITSTriggerFOProcessor::GetNumOutputs() const {
62 // return number of outputs (algorithms) in use
63 if (fTriggerCond==NULL) {
64 Error("AliITSTriggerFOProcessor::GetNumOutputs","Trigger conditions entry not yet given.");
65 return 0;
66 }
67 return fTriggerCond->GetNumAlgo();
68}
69//______________________________________________________________________
70const Char_t* AliITSTriggerFOProcessor::GetOutputLabel(Short_t index) const {
71 // return the label of the index'th algorithm in use
72 if (fTriggerCond==NULL) {
73 Error("AliITSTriggerFOProcessor::GetOutputLabel","Trigger conditions entry not yet given.");
74 return "";
75 }
76 return fTriggerCond->GetAlgoLabelI(index);
77}
78//______________________________________________________________________
79void AliITSTriggerFOProcessor::PreprocessFOSignals(AliITSFOSignalsSPD* signals) {
80 // Pre-process the fast-or signals to retrieve some data needed by most algorithms
81 if (fTriggerCond==NULL) {
82 Error("AliITSTriggerFOProcessor::PreprocessFOSignals","Trigger conditions entry not yet given.");
83 return;
84 }
85 fFOInner = 0;
86 fFOOuter = 0;
87
88 Int_t eq = -1;
89 Int_t hs = -1;
90 Int_t chip = -1;
91 while (signals->GetNextSignal(eq,hs,chip)) {
92 if (fTriggerCond->IsChipActive( (UInt_t)eq, (UInt_t)hs, (UInt_t)chip) ) {
93 if (hs<=1) fFOInner++;
94 else fFOOuter++;
95 }
96 }
97}
98//______________________________________________________________________
99Bool_t AliITSTriggerFOProcessor::ProcessFOSignalsIndex(Short_t index, AliITSFOSignalsSPD* signals) {
100 // NB: For every event - Always call PreprocessFOSignals before calling this method
101 // Process index'th algorithm - returns true if output active
102 return ProcessFOSignalsLabel(GetOutputLabel(index), signals);
103}
104//______________________________________________________________________
105Bool_t AliITSTriggerFOProcessor::ProcessFOSignalsLabel(const Char_t* label, AliITSFOSignalsSPD* signals) {
106 // NB: For every event - Always call PreprocessFOSignals before calling this method
107 // Process algorithm with label ... - returns true if output active
108 if (fTriggerCond==NULL) {
109 Error("AliITSTriggerFOProcessor::ProcessFOSignalsLabel","Trigger conditions entry not yet given.");
110 return kFALSE;
111 }
112
113 Short_t index = fTriggerCond->GetAlgoIndexL(label);
114 if (index<0) {
115 Error("AliITSTriggerFOProcessor::ProcessFOSignalsLabel", "No conditions for label '%s'.",label);
116 return kFALSE;
117 }
118
119 if (strcmp(label, "0SMB") == 0) return ProcessFOSignalsTHRTotalAndTHRInnerAndTHROuter(index, signals);
120 else if (strcmp(label, "0SH1") == 0) return ProcessFOSignalsTHRInnerAndTHROuter(index, signals);
121 else if (strcmp(label, "0SH2") == 0) return ProcessFOSignalsTHRInnerAndTHROuter(index, signals);
122 else if (strcmp(label, "0SH3") == 0) return ProcessFOSignalsTHRInnerAndTHROuter(index, signals);
123 else if (strcmp(label, "0SH4") == 0) return ProcessFOSignalsTHRInnerAndTHROuter(index, signals);
124 else if (strcmp(label, "0SPF") == 0) return ProcessFOSignalsTHRTotalAndTHRInnerAndTHROuter(index, signals);
125 else if (strcmp(label, "0SBK") == 0) return ProcessFOSignalsInnerGTOuterPlusOffset(index, signals);
126 else if (strcmp(label, "0SBK") == 0) return ProcessFOSignalsOuterGTInnerPlusOffset(index, signals);
127 else if (strcmp(label, "0SBK") == 0) return ProcessFOSignalsTHRTotal(index, signals);
128 else if (strcmp(label, "SPD_GFO_L0") == 0) return ProcessFOSignalsTHRTotal(index, signals);
129 else if (strcmp(label, "SPD_HMULT_L0") == 0) return ProcessFOSignalsTHRTotal(index, signals);
130
131 else {
132 Error("AliITSTriggerFOProcessor::ProcessFOSignalsLabel", "Algorithm not yet implemented for label '%s'.",label);
133 return kFALSE;
134 }
135}
136//______________________________________________________________________
137Bool_t AliITSTriggerFOProcessor::ProcessFOSignalsTHRTotalAndTHRInnerAndTHROuter(Short_t index, AliITSFOSignalsSPD* /*signals*/) {
138 // NB: For every event - Always call PreprocessFOSignals before calling this method
139 // Process algorithm ' I+O > thr && I > thr && O > thr ' (index is needed to get the correct parameters from the ocdb object)
140 if (fTriggerCond==NULL) {
141 Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRTotalAndTHRInnerAndTHROuter","Trigger conditions entry not yet given.");
142 return kFALSE;
143 }
144
145 // Get parameter values:
146 Int_t thIO = fTriggerCond->GetAlgoParamValueIN(index, "total_threshold");
147 if (thIO<0) {
148 Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRTotalAndTHRInnerAndTHROuter","Parameter 'total_threshold' not defined");
149 return kFALSE;
150 }
151 Int_t thI = fTriggerCond->GetAlgoParamValueIN(index, "inner_threshold");
152 if (thI<0) {
153 Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRTotalAndTHRInnerAndTHROuter","Parameter 'inner_threshold' not defined");
154 return kFALSE;
155 }
156 Int_t thO = fTriggerCond->GetAlgoParamValueIN(index, "outer_threshold");
157 if (thO<0) {
158 Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRTotalAndTHRInnerAndTHROuter","Parameter 'outer_threshold' not defined");
159 return kFALSE;
160 }
161
162 // Evaluate:
163 return (fFOInner+fFOOuter >= thIO && fFOInner >= thI && fFOOuter >= thO);
164}
165//______________________________________________________________________
166Bool_t AliITSTriggerFOProcessor::ProcessFOSignalsTHRInnerAndTHROuter(Short_t index, AliITSFOSignalsSPD* /*signals*/) {
167 // NB: For every event - Always call PreprocessFOSignals before calling this method
168 // Process algorithm ' I > thr && O > thr ' (index is needed to get the correct parameters from the ocdb object)
169 if (fTriggerCond==NULL) {
170 Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRInnerAndTHROuter","Trigger conditions entry not yet given.");
171 return kFALSE;
172 }
173
174 // Get parameter values:
175 Int_t thI = fTriggerCond->GetAlgoParamValueIN(index, "inner_threshold");
176 if (thI<0) {
177 Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRInnerAndTHROuter","Parameter 'inner_threshold' not defined");
178 return kFALSE;
179 }
180 Int_t thO = fTriggerCond->GetAlgoParamValueIN(index, "outer_threshold");
181 if (thO<0) {
182 Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRInnerAndTHROuter","Parameter 'outer_threshold' not defined");
183 return kFALSE;
184 }
185
186 // Evaluate:
187 return (fFOInner >= thI && fFOOuter >= thO);
188}
189//______________________________________________________________________
190Bool_t AliITSTriggerFOProcessor::ProcessFOSignalsTHRTotal(Short_t index, AliITSFOSignalsSPD* /*signals*/) {
191 // NB: For every event - Always call PreprocessFOSignals before calling this method
192 // Process algorithm ' I+O > thr' (index is needed to get the correct parameters from the ocdb object)
193 if (fTriggerCond==NULL) {
194 Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRTotal","Trigger conditions entry not yet given.");
195 return kFALSE;
196 }
197
198 // Get parameter values:
199 Int_t thIO = fTriggerCond->GetAlgoParamValueIN(index, "total_threshold");
200 if (thIO<0) {
201 Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRTotal","Parameter 'total_threshold' not defined");
202 return kFALSE;
203 }
204
205 // Evaluate:
206 return (fFOInner + fFOOuter >= thIO);
207}
208//______________________________________________________________________
209Bool_t AliITSTriggerFOProcessor::ProcessFOSignalsInnerGTOuterPlusOffset(Short_t index, AliITSFOSignalsSPD* /*signals*/) {
210 // NB: For every event - Always call PreprocessFOSignals before calling this method
211 // Process algorithm ' I > O+offset ' (index is needed to get the correct parameters from the ocdb object)
212 if (fTriggerCond==NULL) {
213 Error("AliITSTriggerFOProcessor::ProcessFOSignalsGTOuterPlusOffset","Trigger conditions entry not yet given.");
214 return kFALSE;
215 }
216
217 // Get parameter values:
218 Int_t offset = fTriggerCond->GetAlgoParamValueIN(index, "offset");
219 if (offset<0) {
220 Error("AliITSTriggerFOProcessor::ProcessFOSignalsInnerGTOuterPlusOffset","Parameter 'offset' not defined");
221 return kFALSE;
222 }
223
224 // Evaluate:
225 return (fFOInner >= fFOOuter + offset);
226}
227//______________________________________________________________________
228Bool_t AliITSTriggerFOProcessor::ProcessFOSignalsOuterGTInnerPlusOffset(Short_t index, AliITSFOSignalsSPD* /*signals*/) {
229 // NB: For every event - Always call PreprocessFOSignals before calling this method
230 // Process algorithm ' O > I+offset ' (index is needed to get the correct parameters from the ocdb object)
231 if (fTriggerCond==NULL) {
232 Error("AliITSTriggerFOProcessor::ProcessFOSignalsGTOuterPlusOffset","Trigger conditions entry not yet given.");
233 return kFALSE;
234 }
235
236 // Get parameter values:
237 Int_t offset = fTriggerCond->GetAlgoParamValueIN(index, "offset");
238 if (offset<0) {
239 Error("AliITSTriggerFOProcessor::ProcessFOSignalsOuterGTInnerPlusOffset","Parameter 'offset' not defined");
240 return kFALSE;
241 }
242
243 // Evaluate:
244 return (fFOOuter >= fFOInner + offset);
245}
246