1 /////////////////////////////////////////////////////////////////////
2 // Author: Henrik Tydesjo //
4 // This class takes care of simulating the output from the pixel //
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. //
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. //
18 /////////////////////////////////////////////////////////////////////
20 #include "AliITSTriggerFOProcessor.h"
21 #include "AliITSTriggerConditions.h"
26 AliITSTriggerFOProcessor::AliITSTriggerFOProcessor() :
27 fFOInner(0), fFOOuter(0), fTriggerCond(NULL)
29 // default constructor
31 //______________________________________________________________________
32 AliITSTriggerFOProcessor::AliITSTriggerFOProcessor(AliITSTriggerConditions* ocdbCond) :
33 fFOInner(0), fFOOuter(0), fTriggerCond(ocdbCond)
37 //______________________________________________________________________
38 AliITSTriggerFOProcessor::AliITSTriggerFOProcessor(const AliITSTriggerFOProcessor& handle):
39 fFOInner(handle.fFOInner), fFOOuter(handle.fFOOuter), fTriggerCond(handle.fTriggerCond)
43 //______________________________________________________________________
44 AliITSTriggerFOProcessor::~AliITSTriggerFOProcessor() {
47 //______________________________________________________________________
48 AliITSTriggerFOProcessor& AliITSTriggerFOProcessor::operator=(const AliITSTriggerFOProcessor& handle) {
49 // assignment operator
51 fFOInner = handle.fFOInner;
52 fFOOuter = handle.fFOOuter;
53 fTriggerCond = handle.fTriggerCond;
57 //______________________________________________________________________
58 void AliITSTriggerFOProcessor::SetTriggerConditions(AliITSTriggerConditions* const ocdbCond) {
59 // Method to give pointer to the OCDB conditions entry
60 fTriggerCond = ocdbCond;
62 //______________________________________________________________________
63 UInt_t AliITSTriggerFOProcessor::GetNumOutputs() const {
64 // return number of outputs (algorithms) in use
65 if (fTriggerCond==NULL) {
66 Error("AliITSTriggerFOProcessor::GetNumOutputs","Trigger conditions entry not yet given.");
69 return fTriggerCond->GetNumAlgo();
71 //______________________________________________________________________
72 const Char_t* AliITSTriggerFOProcessor::GetOutputLabel(Short_t index) const {
73 // return the label of the index'th algorithm in use
74 if (fTriggerCond==NULL) {
75 Error("AliITSTriggerFOProcessor::GetOutputLabel","Trigger conditions entry not yet given.");
78 return fTriggerCond->GetAlgoLabelI(index);
80 //______________________________________________________________________
81 void AliITSTriggerFOProcessor::PreprocessFOSignals(AliITSFOSignalsSPD* const signals) {
82 // Pre-process the fast-or signals to retrieve some data needed by most algorithms
83 if (fTriggerCond==NULL) {
84 Error("AliITSTriggerFOProcessor::PreprocessFOSignals","Trigger conditions entry not yet given.");
93 while (signals->GetNextSignal(eq,hs,chip)) {
94 if (fTriggerCond->IsChipActive( (UInt_t)eq, (UInt_t)hs, (UInt_t)chip) ) {
95 if (hs<=1) fFOInner++;
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 return ProcessFOSignalsLabel(GetOutputLabel(index), signals);
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 if (fTriggerCond==NULL) {
111 Error("AliITSTriggerFOProcessor::ProcessFOSignalsLabel","Trigger conditions entry not yet given.");
115 Short_t index = fTriggerCond->GetAlgoIndexL(label);
117 Error("AliITSTriggerFOProcessor::ProcessFOSignalsLabel", "No conditions for label '%s'.",label);
121 if (strcmp(label, "0SMB") == 0) return ProcessFOSignalsTHRTotalAndTHRInnerAndTHROuter(index, signals);
122 else if (strcmp(label, "0SH1") == 0) return ProcessFOSignalsTHRInnerAndTHROuter(index, signals);
123 else if (strcmp(label, "0SH2") == 0) return ProcessFOSignalsTHRInnerAndTHROuter(index, signals);
124 else if (strcmp(label, "0SH3") == 0) return ProcessFOSignalsTHRInnerAndTHROuter(index, signals);
125 else if (strcmp(label, "0SH4") == 0) return ProcessFOSignalsTHRInnerAndTHROuter(index, signals);
126 else if (strcmp(label, "0SPF") == 0) return ProcessFOSignalsTHRTotalAndTHRInnerAndTHROuter(index, signals);
127 else if (strcmp(label, "0SX1") == 0) return ProcessFOSignalsInnerGTOuterPlusOffset(index, signals);
128 else if (strcmp(label, "0SX2") == 0) return ProcessFOSignalsOuterGTInnerPlusOffset(index, signals);
129 else if (strcmp(label, "0SBK") == 0) return ProcessFOSignalsTHRTotal(index, signals);
130 else if (strcmp(label, "0SCO") == 0) return ProcessFOSignalsCosmic(index, signals);
133 Error("AliITSTriggerFOProcessor::ProcessFOSignalsLabel", "Algorithm not yet implemented for label '%s'.",label);
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 if (fTriggerCond==NULL) {
142 Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRTotalAndTHRInnerAndTHROuter","Trigger conditions entry not yet given.");
146 // Get parameter values:
147 Int_t thIO = fTriggerCond->GetAlgoParamValueIN(index, "total_threshold");
149 Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRTotalAndTHRInnerAndTHROuter","Parameter 'total_threshold' not defined");
152 Int_t thI = fTriggerCond->GetAlgoParamValueIN(index, "inner_threshold");
154 Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRTotalAndTHRInnerAndTHROuter","Parameter 'inner_threshold' not defined");
157 Int_t thO = fTriggerCond->GetAlgoParamValueIN(index, "outer_threshold");
159 Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRTotalAndTHRInnerAndTHROuter","Parameter 'outer_threshold' not defined");
164 return (fFOInner+fFOOuter >= thIO && fFOInner >= thI && fFOOuter >= thO);
166 //______________________________________________________________________
167 Bool_t AliITSTriggerFOProcessor::ProcessFOSignalsTHRInnerAndTHROuter(Short_t index, AliITSFOSignalsSPD* /*signals*/) {
168 // NB: For every event - Always call PreprocessFOSignals before calling this method
169 // Process algorithm ' I > thr && O > thr ' (index is needed to get the correct parameters from the ocdb object)
170 if (fTriggerCond==NULL) {
171 Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRInnerAndTHROuter","Trigger conditions entry not yet given.");
175 // Get parameter values:
176 Int_t thI = fTriggerCond->GetAlgoParamValueIN(index, "inner_threshold");
178 Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRInnerAndTHROuter","Parameter 'inner_threshold' not defined");
181 Int_t thO = fTriggerCond->GetAlgoParamValueIN(index, "outer_threshold");
183 Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRInnerAndTHROuter","Parameter 'outer_threshold' not defined");
188 return (fFOInner >= thI && fFOOuter >= thO);
190 //______________________________________________________________________
191 Bool_t AliITSTriggerFOProcessor::ProcessFOSignalsTHRTotal(Short_t index, AliITSFOSignalsSPD* /*signals*/) {
192 // NB: For every event - Always call PreprocessFOSignals before calling this method
193 // Process algorithm ' I+O > thr' (index is needed to get the correct parameters from the ocdb object)
194 if (fTriggerCond==NULL) {
195 Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRTotal","Trigger conditions entry not yet given.");
199 // Get parameter values:
200 Int_t thIO = fTriggerCond->GetAlgoParamValueIN(index, "background_threshold_both");
202 Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRTotal","Parameter 'total_threshold' not defined");
207 return (fFOInner + fFOOuter >= thIO);
209 //______________________________________________________________________
210 Bool_t AliITSTriggerFOProcessor::ProcessFOSignalsInnerGTOuterPlusOffset(Short_t index, AliITSFOSignalsSPD* /*signals*/) {
211 // NB: For every event - Always call PreprocessFOSignals before calling this method
212 // Process algorithm ' I > O+offset ' (index is needed to get the correct parameters from the ocdb object)
213 if (fTriggerCond==NULL) {
214 Error("AliITSTriggerFOProcessor::ProcessFOSignalsGTOuterPlusOffset","Trigger conditions entry not yet given.");
218 // Get parameter values:
219 Int_t offset = fTriggerCond->GetAlgoParamValueIN(index, "background_offset_inner");
221 Error("AliITSTriggerFOProcessor::ProcessFOSignalsInnerGTOuterPlusOffset","Parameter 'offset' not defined");
226 return (fFOInner >= fFOOuter + offset);
228 //______________________________________________________________________
229 Bool_t AliITSTriggerFOProcessor::ProcessFOSignalsOuterGTInnerPlusOffset(Short_t index, AliITSFOSignalsSPD* /*signals*/) {
230 // NB: For every event - Always call PreprocessFOSignals before calling this method
231 // Process algorithm ' O > I+offset ' (index is needed to get the correct parameters from the ocdb object)
232 if (fTriggerCond==NULL) {
233 Error("AliITSTriggerFOProcessor::ProcessFOSignalsGTOuterPlusOffset","Trigger conditions entry not yet given.");
237 // Get parameter values:
238 Int_t offset = fTriggerCond->GetAlgoParamValueIN(index, "background_offset_outer");
240 Error("AliITSTriggerFOProcessor::ProcessFOSignalsOuterGTInnerPlusOffset","Parameter 'offset' not defined");
245 return (fFOOuter >= fFOInner + offset);
247 //______________________________________________________________________
248 Bool_t AliITSTriggerFOProcessor::ProcessFOSignalsCosmic(Short_t index, AliITSFOSignalsSPD* const signals) {
249 // NB: For every event - Always call PreprocessFOSignals before calling this method
250 // Process algorithm 'cosmic' (index is needed to get the correct parameters from the ocdb object)
251 if (fTriggerCond==NULL) {
252 Error("AliITSTriggerFOProcessor::ProcessFOSignalsCosmic","Trigger conditions entry not yet given.");
256 // Get parameter values:
257 Int_t cosmicParam = fTriggerCond->GetAlgoParamValueIN(index, "cosmic_mode");
259 Error("AliITSTriggerFOProcessor::ProcessFOSignalsCosmic","Parameter 'cosmic_mode' not defined");
265 UShort_t topOuter = 0;
266 UShort_t topInner = 0;
267 UShort_t bottomOuter = 0;
268 UShort_t bottomInner = 0;
273 while (signals->GetNextSignal(eq,hs,chip)) {
274 if (fTriggerCond->IsChipActive( (UInt_t)eq, (UInt_t)hs, (UInt_t)chip) ) {
276 if (eq%10 < 5) topInner++;
280 if (eq%10 < 5) topOuter++;
286 // top outer & bottom outer
287 if (cosmicParam == 0) return (topOuter>0 && bottomOuter>0);
289 if (cosmicParam == 1) return (fFOInner>0 && fFOOuter>0);
290 // double layer ( >=2 of top inner, top outer, bottom inner, bottom outer )
291 if (cosmicParam == 2) {
292 UShort_t nHalfLayers = 0;
293 if (topOuter>0) nHalfLayers++;
294 if (topInner>0) nHalfLayers++;
295 if (bottomOuter>0) nHalfLayers++;
296 if (bottomInner>0) nHalfLayers++;
297 return (nHalfLayers>=2);
299 // top outer & top inner & bottom outer & bottom inner
300 if (cosmicParam == 3) return (topOuter>0 && topInner>0 && bottomOuter>0 && bottomInner>0);
301 // top outer & bottom outer & inner
302 if (cosmicParam == 4) return (topOuter>0 && bottomOuter>0 && fFOInner>0);
304 if (cosmicParam == 5) return (fFOOuter>0 || fFOInner>0);
306 Error("AliITSTriggerFOProcessor::ProcessFOSignalsCosmic","'cosmic_algorithm_parameter' = %d not defined",cosmicParam);