Line data Source code
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 :
24 : /* $Id$ */
25 :
26 : AliITSTriggerFOProcessor::AliITSTriggerFOProcessor() :
27 0 : fFOInner(0), fFOOuter(0), fTriggerCond(NULL)
28 0 : {
29 : // default constructor
30 0 : }
31 : //______________________________________________________________________
32 : AliITSTriggerFOProcessor::AliITSTriggerFOProcessor(AliITSTriggerConditions* ocdbCond) :
33 4 : fFOInner(0), fFOOuter(0), fTriggerCond(ocdbCond)
34 16 : {
35 : // constructor
36 8 : }
37 : //______________________________________________________________________
38 : AliITSTriggerFOProcessor::AliITSTriggerFOProcessor(const AliITSTriggerFOProcessor& handle):
39 0 : fFOInner(handle.fFOInner), fFOOuter(handle.fFOOuter), fTriggerCond(handle.fTriggerCond)
40 0 : {
41 : // copy constructor
42 0 : }
43 : //______________________________________________________________________
44 8 : AliITSTriggerFOProcessor::~AliITSTriggerFOProcessor() {
45 : // destructor
46 12 : }
47 : //______________________________________________________________________
48 : AliITSTriggerFOProcessor& AliITSTriggerFOProcessor::operator=(const AliITSTriggerFOProcessor& handle) {
49 : // assignment operator
50 0 : if (this!=&handle) {
51 0 : fFOInner = handle.fFOInner;
52 0 : fFOOuter = handle.fFOOuter;
53 0 : fTriggerCond = handle.fTriggerCond;
54 0 : }
55 0 : return *this;
56 : }
57 : //______________________________________________________________________
58 : void AliITSTriggerFOProcessor::SetTriggerConditions(AliITSTriggerConditions* const ocdbCond) {
59 : // Method to give pointer to the OCDB conditions entry
60 0 : fTriggerCond = ocdbCond;
61 0 : }
62 : //______________________________________________________________________
63 : UInt_t AliITSTriggerFOProcessor::GetNumOutputs() const {
64 : // return number of outputs (algorithms) in use
65 16 : if (fTriggerCond==NULL) {
66 0 : Error("AliITSTriggerFOProcessor::GetNumOutputs","Trigger conditions entry not yet given.");
67 0 : return 0;
68 : }
69 8 : return fTriggerCond->GetNumAlgo();
70 8 : }
71 : //______________________________________________________________________
72 : const Char_t* AliITSTriggerFOProcessor::GetOutputLabel(Short_t index) const {
73 : // return the label of the index'th algorithm in use
74 200 : if (fTriggerCond==NULL) {
75 0 : Error("AliITSTriggerFOProcessor::GetOutputLabel","Trigger conditions entry not yet given.");
76 0 : return "";
77 : }
78 100 : return fTriggerCond->GetAlgoLabelI(index);
79 100 : }
80 : //______________________________________________________________________
81 : void AliITSTriggerFOProcessor::PreprocessFOSignals(AliITSFOSignalsSPD* const signals) {
82 : // Pre-process the fast-or signals to retrieve some data needed by most algorithms
83 8 : if (fTriggerCond==NULL) {
84 0 : Error("AliITSTriggerFOProcessor::PreprocessFOSignals","Trigger conditions entry not yet given.");
85 0 : return;
86 : }
87 4 : fFOInner = 0;
88 4 : fFOOuter = 0;
89 :
90 4 : Int_t eq = -1;
91 4 : Int_t hs = -1;
92 4 : Int_t chip = -1;
93 82 : while (signals->GetNextSignal(eq,hs,chip)) {
94 74 : if (fTriggerCond->IsChipActive( (UInt_t)eq, (UInt_t)hs, (UInt_t)chip) ) {
95 109 : if (hs<=1) fFOInner++;
96 29 : else fFOOuter++;
97 : }
98 : }
99 8 : }
100 : //______________________________________________________________________
101 : Bool_t AliITSTriggerFOProcessor::ProcessFOSignalsIndex(Short_t index, AliITSFOSignalsSPD* signals) {
102 : // NB: For every event - Always call PreprocessFOSignals before calling this method
103 : // Process index'th algorithm - returns true if output active
104 80 : return ProcessFOSignalsLabel(GetOutputLabel(index), signals);
105 : }
106 : //______________________________________________________________________
107 : Bool_t AliITSTriggerFOProcessor::ProcessFOSignalsLabel(const Char_t* label, AliITSFOSignalsSPD* signals) {
108 : // NB: For every event - Always call PreprocessFOSignals before calling this method
109 : // Process algorithm with label ... - returns true if output active
110 80 : if (fTriggerCond==NULL) {
111 0 : Error("AliITSTriggerFOProcessor::ProcessFOSignalsLabel","Trigger conditions entry not yet given.");
112 0 : return kFALSE;
113 : }
114 :
115 40 : Short_t index = fTriggerCond->GetAlgoIndexL(label);
116 40 : if (index<0) {
117 0 : Error("AliITSTriggerFOProcessor::ProcessFOSignalsLabel", "No conditions for label '%s'.",label);
118 0 : return kFALSE;
119 : }
120 :
121 44 : if (strcmp(label, "0SMB") == 0) return ProcessFOSignalsTHRTotalAndTHRInnerAndTHROuter(index, signals);
122 40 : else if (strcmp(label, "0SH1") == 0) return ProcessFOSignalsTHRInnerAndTHROuter(index, signals);
123 36 : else if (strcmp(label, "0SH2") == 0) return ProcessFOSignalsTHRInnerAndTHROuter(index, signals);
124 32 : else if (strcmp(label, "0SH3") == 0) return ProcessFOSignalsTHRInnerAndTHROuter(index, signals);
125 28 : else if (strcmp(label, "0SH4") == 0) return ProcessFOSignalsTHRInnerAndTHROuter(index, signals);
126 24 : else if (strcmp(label, "0SPF") == 0) return ProcessFOSignalsTHRTotalAndTHRInnerAndTHROuter(index, signals);
127 20 : else if (strcmp(label, "0SX1") == 0) return ProcessFOSignalsInnerGTOuterPlusOffset(index, signals);
128 16 : else if (strcmp(label, "0SX2") == 0) return ProcessFOSignalsOuterGTInnerPlusOffset(index, signals);
129 12 : else if (strcmp(label, "0SBK") == 0) return ProcessFOSignalsTHRTotal(index, signals);
130 8 : else if (strcmp(label, "0SCO") == 0) return ProcessFOSignalsCosmic(index, signals);
131 :
132 : else {
133 0 : Error("AliITSTriggerFOProcessor::ProcessFOSignalsLabel", "Algorithm not yet implemented for label '%s'.",label);
134 0 : return kFALSE;
135 : }
136 40 : }
137 : //______________________________________________________________________
138 : Bool_t AliITSTriggerFOProcessor::ProcessFOSignalsTHRTotalAndTHRInnerAndTHROuter(Short_t index, AliITSFOSignalsSPD* /*signals*/) {
139 : // NB: For every event - Always call PreprocessFOSignals before calling this method
140 : // Process algorithm ' I+O > thr && I > thr && O > thr ' (index is needed to get the correct parameters from the ocdb object)
141 16 : if (fTriggerCond==NULL) {
142 0 : Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRTotalAndTHRInnerAndTHROuter","Trigger conditions entry not yet given.");
143 0 : return kFALSE;
144 : }
145 :
146 : // Get parameter values:
147 8 : Int_t thIO = fTriggerCond->GetAlgoParamValueIN(index, "total_threshold");
148 8 : if (thIO<0) {
149 0 : Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRTotalAndTHRInnerAndTHROuter","Parameter 'total_threshold' not defined");
150 0 : return kFALSE;
151 : }
152 8 : Int_t thI = fTriggerCond->GetAlgoParamValueIN(index, "inner_threshold");
153 8 : if (thI<0) thI = fTriggerCond->GetAlgoParamValueIN(index, "inner_treshold"); // hack to comply with a typo in ocdb file
154 8 : if (thI<0) {
155 0 : Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRTotalAndTHRInnerAndTHROuter","Parameter 'inner_threshold' not defined");
156 0 : return kFALSE;
157 : }
158 8 : Int_t thO = fTriggerCond->GetAlgoParamValueIN(index, "outer_threshold");
159 8 : if (thO<0) {
160 0 : Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRTotalAndTHRInnerAndTHROuter","Parameter 'outer_threshold' not defined");
161 0 : return kFALSE;
162 : }
163 :
164 : // Evaluate:
165 32 : return (fFOInner+fFOOuter >= thIO && fFOInner >= thI && fFOOuter >= thO);
166 8 : }
167 : //______________________________________________________________________
168 : Bool_t AliITSTriggerFOProcessor::ProcessFOSignalsTHRInnerAndTHROuter(Short_t index, AliITSFOSignalsSPD* /*signals*/) {
169 : // NB: For every event - Always call PreprocessFOSignals before calling this method
170 : // Process algorithm ' I > thr && O > thr ' (index is needed to get the correct parameters from the ocdb object)
171 32 : if (fTriggerCond==NULL) {
172 0 : Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRInnerAndTHROuter","Trigger conditions entry not yet given.");
173 0 : return kFALSE;
174 : }
175 :
176 : // Get parameter values:
177 16 : Int_t thI = fTriggerCond->GetAlgoParamValueIN(index, "inner_threshold");
178 16 : if (thI<0) thI = fTriggerCond->GetAlgoParamValueIN(index, "inner_treshold"); // hack to comply with a typo in ocdb file
179 16 : if (thI<0) {
180 0 : Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRInnerAndTHROuter","Parameter 'inner_threshold' not defined");
181 0 : return kFALSE;
182 : }
183 16 : Int_t thO = fTriggerCond->GetAlgoParamValueIN(index, "outer_threshold");
184 16 : if (thO<0) {
185 0 : Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRInnerAndTHROuter","Parameter 'outer_threshold' not defined");
186 0 : return kFALSE;
187 : }
188 :
189 : // Evaluate:
190 40 : return (fFOInner >= thI && fFOOuter >= thO);
191 16 : }
192 : //______________________________________________________________________
193 : Bool_t AliITSTriggerFOProcessor::ProcessFOSignalsTHRTotal(Short_t index, AliITSFOSignalsSPD* /*signals*/) {
194 : // NB: For every event - Always call PreprocessFOSignals before calling this method
195 : // Process algorithm ' I+O > thr' (index is needed to get the correct parameters from the ocdb object)
196 8 : if (fTriggerCond==NULL) {
197 0 : Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRTotal","Trigger conditions entry not yet given.");
198 0 : return kFALSE;
199 : }
200 :
201 : // Get parameter values:
202 4 : Int_t thIO = fTriggerCond->GetAlgoParamValueIN(index, "background_threshold_both");
203 4 : if (thIO<0) {
204 0 : Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRTotal","Parameter 'total_threshold' not defined");
205 0 : return kFALSE;
206 : }
207 :
208 : // Evaluate:
209 4 : return (fFOInner + fFOOuter >= thIO);
210 4 : }
211 : //______________________________________________________________________
212 : Bool_t AliITSTriggerFOProcessor::ProcessFOSignalsInnerGTOuterPlusOffset(Short_t index, AliITSFOSignalsSPD* /*signals*/) {
213 : // NB: For every event - Always call PreprocessFOSignals before calling this method
214 : // Process algorithm ' I > O+offset ' (index is needed to get the correct parameters from the ocdb object)
215 8 : if (fTriggerCond==NULL) {
216 0 : Error("AliITSTriggerFOProcessor::ProcessFOSignalsGTOuterPlusOffset","Trigger conditions entry not yet given.");
217 0 : return kFALSE;
218 : }
219 :
220 : // Get parameter values:
221 4 : Int_t offset = fTriggerCond->GetAlgoParamValueIN(index, "background_offset_inner");
222 4 : if (offset<0) {
223 0 : Error("AliITSTriggerFOProcessor::ProcessFOSignalsInnerGTOuterPlusOffset","Parameter 'offset' not defined");
224 0 : return kFALSE;
225 : }
226 :
227 : // Evaluate:
228 4 : return (fFOInner >= fFOOuter + offset);
229 4 : }
230 : //______________________________________________________________________
231 : Bool_t AliITSTriggerFOProcessor::ProcessFOSignalsOuterGTInnerPlusOffset(Short_t index, AliITSFOSignalsSPD* /*signals*/) {
232 : // NB: For every event - Always call PreprocessFOSignals before calling this method
233 : // Process algorithm ' O > I+offset ' (index is needed to get the correct parameters from the ocdb object)
234 8 : if (fTriggerCond==NULL) {
235 0 : Error("AliITSTriggerFOProcessor::ProcessFOSignalsGTOuterPlusOffset","Trigger conditions entry not yet given.");
236 0 : return kFALSE;
237 : }
238 :
239 : // Get parameter values:
240 4 : Int_t offset = fTriggerCond->GetAlgoParamValueIN(index, "background_offset_outer");
241 4 : if (offset<0) {
242 0 : Error("AliITSTriggerFOProcessor::ProcessFOSignalsOuterGTInnerPlusOffset","Parameter 'offset' not defined");
243 0 : return kFALSE;
244 : }
245 :
246 : // Evaluate:
247 4 : return (fFOOuter >= fFOInner + offset);
248 4 : }
249 : //______________________________________________________________________
250 : Bool_t AliITSTriggerFOProcessor::ProcessFOSignalsCosmic(Short_t index, AliITSFOSignalsSPD* const signals) {
251 : // NB: For every event - Always call PreprocessFOSignals before calling this method
252 : // Process algorithm 'cosmic' (index is needed to get the correct parameters from the ocdb object)
253 8 : if (fTriggerCond==NULL) {
254 0 : Error("AliITSTriggerFOProcessor::ProcessFOSignalsCosmic","Trigger conditions entry not yet given.");
255 0 : return kFALSE;
256 : }
257 :
258 : // Get parameter values:
259 4 : Int_t cosmicParam = fTriggerCond->GetAlgoParamValueIN(index, "cosmic_mode");
260 4 : if (cosmicParam<0) {
261 0 : Error("AliITSTriggerFOProcessor::ProcessFOSignalsCosmic","Parameter 'cosmic_mode' not defined");
262 0 : return kFALSE;
263 : }
264 :
265 : // Evaluate:
266 :
267 : UShort_t topOuter = 0;
268 : UShort_t topInner = 0;
269 : UShort_t bottomOuter = 0;
270 : UShort_t bottomInner = 0;
271 :
272 4 : Int_t eq = -1;
273 4 : Int_t hs = -1;
274 4 : Int_t chip = -1;
275 82 : while (signals->GetNextSignal(eq,hs,chip)) {
276 74 : if (fTriggerCond->IsChipActive( (UInt_t)eq, (UInt_t)hs, (UInt_t)chip) ) {
277 138 : if (hs<=1) {
278 141 : if (eq%10 < 5) topInner++;
279 8 : else bottomInner++;
280 : }
281 : else {
282 49 : if (eq%10 < 5) topOuter++;
283 9 : else bottomOuter++;
284 : }
285 : }
286 : }
287 :
288 : // top outer & bottom outer
289 16 : if (cosmicParam == 0) return (topOuter>0 && bottomOuter>0);
290 : // inner & outer
291 0 : if (cosmicParam == 1) return (fFOInner>0 && fFOOuter>0);
292 : // double layer ( >=2 of top inner, top outer, bottom inner, bottom outer )
293 0 : if (cosmicParam == 2) {
294 : UShort_t nHalfLayers = 0;
295 0 : if (topOuter>0) nHalfLayers++;
296 0 : if (topInner>0) nHalfLayers++;
297 0 : if (bottomOuter>0) nHalfLayers++;
298 0 : if (bottomInner>0) nHalfLayers++;
299 0 : return (nHalfLayers>=2);
300 : }
301 : // top outer & top inner & bottom outer & bottom inner
302 0 : if (cosmicParam == 3) return (topOuter>0 && topInner>0 && bottomOuter>0 && bottomInner>0);
303 : // top outer & bottom outer & inner
304 0 : if (cosmicParam == 4) return (topOuter>0 && bottomOuter>0 && fFOInner>0);
305 : // global or
306 0 : if (cosmicParam == 5) return (fFOOuter>0 || fFOInner>0);
307 :
308 0 : Error("AliITSTriggerFOProcessor::ProcessFOSignalsCosmic","'cosmic_algorithm_parameter' = %d not defined",cosmicParam);
309 0 : return kFALSE;
310 8 : }
311 :
|