]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG/EMCAL/AliEmcalTriggerSelectionCuts.cxx
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWG / EMCAL / AliEmcalTriggerSelectionCuts.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-2007, 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  * Class for the selection of trigger patches in the EMCAL triggered event selection
17  *
18  * Author: Markus Fasel
19  */
20 #include "AliEmcalTriggerPatchInfo.h"
21 #include "AliEmcalTriggerSelectionCuts.h"
22
23 ClassImp(AliEmcalTriggerSelectionCuts)
24
25 //______________________________________________________________________________
26 AliEmcalTriggerSelectionCuts::AliEmcalTriggerSelectionCuts() :
27   TObject(),
28   fSelectionMethod(kADC),
29   fPatchType(kAnyPatch),
30   fThreshold(0),
31   fUseSimpleOffline(kFALSE)
32 {
33   /*
34    * Dummy constructor
35    */
36 }
37
38 //______________________________________________________________________________
39 Bool_t AliEmcalTriggerSelectionCuts::IsSelected(const AliEmcalTriggerPatchInfo * const patch) const {
40   /*
41    * Apply selection of the given trigger patch according to the selections described in the object
42    *
43    * @param patch: the trigger patch to check
44    * @return" the decision (true if selected, false otherwise)
45    */
46   if(fUseSimpleOffline && !patch->IsOfflineSimple()) return kFALSE;
47   else if(!fUseSimpleOffline && patch->IsOfflineSimple()) return kFALSE;
48   if(!SelectPatchType(patch)) return kFALSE;
49   if(GetCutPrimitive(patch) <= fThreshold) return kFALSE;
50   return kTRUE;
51 }
52
53 //______________________________________________________________________________
54 Int_t AliEmcalTriggerSelectionCuts::CompareTriggerPatches(const AliEmcalTriggerPatchInfo *first, const AliEmcalTriggerPatchInfo *second) const {
55   /*
56    * Compare two patches according to the energy measure specified in the cut object
57    *
58    * @param first: the first patch
59    * @param second: the second patch
60    * @return: the result of the comparison (0 if equal, 1 if the first patch has a larger primitive,
61    *          -1 if the second patch has a larger primitive)
62    */
63   Double_t valfirst = GetCutPrimitive(first), valsecond = GetCutPrimitive(second);
64   if(valfirst == valsecond) return 0;
65   if(valfirst > valsecond) return 1;
66   return -1;
67 }
68
69 //______________________________________________________________________________
70 Double_t AliEmcalTriggerSelectionCuts::GetCutPrimitive(const AliEmcalTriggerPatchInfo * const patch) const{
71   /*
72    * Return (energy) measure we cut on, depending on the selection method specified
73    *
74    * @param patch: The patch from which to obtain the value
75    * @return: The energy measure of the patch
76    */
77   if(fSelectionMethod == kADC) return static_cast<Double_t>(patch->GetADCAmp());
78   else if(fSelectionMethod == kEnergyRough) return patch->GetADCAmpGeVRough();
79   return patch->GetPatchE();
80 }
81
82 //______________________________________________________________________________
83 Bool_t AliEmcalTriggerSelectionCuts::SelectPatchType(const AliEmcalTriggerPatchInfo * const patch) const{
84   /*
85    * Select type of the patch according the definitions in the header file
86    *
87    * @param patch: the patch to be checked
88    * @return: selection result (true ig the patch is selected)
89    */
90   if(fPatchType == kAnyPatch) return kTRUE;
91   if(fUseSimpleOffline){
92     if(patch->IsJetLowSimple() && ((fPatchType == kL1JetPatch) || (fPatchType == kL1JetLowPatch))) return kTRUE;
93     if(patch->IsJetHighSimple() && ((fPatchType == kL1JetPatch) || (fPatchType == kL1JetHighPatch))) return kTRUE;
94     if(patch->IsGammaLowSimple() && ((fPatchType == kL1GammaPatch) || (fPatchType == kL1GammaLowPatch))) return kTRUE;
95     if(patch->IsGammaHighSimple() && ((fPatchType == kL1GammaPatch) || (fPatchType == kL1GammaHighPatch))) return kTRUE;
96   } else {
97     if(patch->IsJetLow() && ((fPatchType == kL1JetPatch) || (fPatchType == kL1JetLowPatch))) return kTRUE;
98     if(patch->IsJetHigh() && ((fPatchType == kL1JetPatch) || (fPatchType == kL1JetHighPatch))) return kTRUE;
99     if(patch->IsGammaLow() && ((fPatchType == kL1GammaPatch) || (fPatchType == kL1GammaLowPatch))) return kTRUE;
100     if(patch->IsGammaHigh() && ((fPatchType == kL1GammaPatch) || (fPatchType == kL1GammaHighPatch))) return kTRUE;
101     if(patch->IsLevel0() && fPatchType == kL0Patch) return kTRUE;
102   }
103   return kFALSE;
104 }