+//______________________________________________________________________
+Bool_t AliITSTriggerFOProcessor::ProcessFOSignalsCosmic(Short_t index, AliITSFOSignalsSPD* const signals) {
+ // NB: For every event - Always call PreprocessFOSignals before calling this method
+ // Process algorithm 'cosmic' (index is needed to get the correct parameters from the ocdb object)
+ if (fTriggerCond==NULL) {
+ Error("AliITSTriggerFOProcessor::ProcessFOSignalsCosmic","Trigger conditions entry not yet given.");
+ return kFALSE;
+ }
+
+ // Get parameter values:
+ Int_t cosmicParam = fTriggerCond->GetAlgoParamValueIN(index, "cosmic_mode");
+ if (cosmicParam<0) {
+ Error("AliITSTriggerFOProcessor::ProcessFOSignalsCosmic","Parameter 'cosmic_mode' not defined");
+ return kFALSE;
+ }
+
+ // Evaluate:
+
+ UShort_t topOuter = 0;
+ UShort_t topInner = 0;
+ UShort_t bottomOuter = 0;
+ UShort_t bottomInner = 0;
+
+ Int_t eq = -1;
+ Int_t hs = -1;
+ Int_t chip = -1;
+ while (signals->GetNextSignal(eq,hs,chip)) {
+ if (fTriggerCond->IsChipActive( (UInt_t)eq, (UInt_t)hs, (UInt_t)chip) ) {
+ if (hs<=1) {
+ if (eq%10 < 5) topInner++;
+ else bottomInner++;
+ }
+ else {
+ if (eq%10 < 5) topOuter++;
+ else bottomOuter++;
+ }
+ }
+ }
+
+ // top outer & bottom outer
+ if (cosmicParam == 0) return (topOuter>0 && bottomOuter>0);
+ // inner & outer
+ if (cosmicParam == 1) return (fFOInner>0 && fFOOuter>0);
+ // double layer ( >=2 of top inner, top outer, bottom inner, bottom outer )
+ if (cosmicParam == 2) {
+ UShort_t nHalfLayers = 0;
+ if (topOuter>0) nHalfLayers++;
+ if (topInner>0) nHalfLayers++;
+ if (bottomOuter>0) nHalfLayers++;
+ if (bottomInner>0) nHalfLayers++;
+ return (nHalfLayers>=2);
+ }
+ // top outer & top inner & bottom outer & bottom inner
+ if (cosmicParam == 3) return (topOuter>0 && topInner>0 && bottomOuter>0 && bottomInner>0);
+ // top outer & bottom outer & inner
+ if (cosmicParam == 4) return (topOuter>0 && bottomOuter>0 && fFOInner>0);
+ // global or
+ if (cosmicParam == 5) return (fFOOuter>0 || fFOInner>0);
+
+ Error("AliITSTriggerFOProcessor::ProcessFOSignalsCosmic","'cosmic_algorithm_parameter' = %d not defined",cosmicParam);
+ return kFALSE;
+}