]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG3/dielectron/AliDielectronCutGroup.cxx
Updating the functionality of AliAnalysisHadEtCorrections to accomodate centrality...
[u/mrichter/AliRoot.git] / PWG3 / dielectron / AliDielectronCutGroup.cxx
1 /*************************************************************************
2  * Copyright(c) 1998-2009, 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 /* $Id$ */
17
18 //////////////////////////////////////////////////////////////////////////
19 //                           CutGroup                                   //
20 //                                                                      //
21 //                                                                      //
22 //   Allow to define groups of cut conditions which are tested with     //
23 //      an OR condition between groups and an AND within groups         //
24 //                                                                      //
25 //////////////////////////////////////////////////////////////////////////
26
27 #include "AliDielectronCutGroup.h"
28
29 ClassImp(AliDielectronCutGroup)
30
31 AliDielectronCutGroup::AliDielectronCutGroup(Bool_t compOperator /*=kCompOR*/) :
32   AliAnalysisCuts(),
33   fCutGroupList(0x0),
34   fCompOperator(compOperator)
35 {
36   //
37   // Default constructor
38   //
39 }
40
41 //_____________________________________________________________________
42 AliDielectronCutGroup::AliDielectronCutGroup(const char* name, const char* title, Bool_t compOperator /*=kCompOR*/) :
43   AliAnalysisCuts(name, title),
44   fCutGroupList(0x0),
45   fCompOperator(compOperator)
46 {
47   //
48   // Named Constructor
49   //
50 }
51
52 //_____________________________________________________________________
53 AliDielectronCutGroup::~AliDielectronCutGroup() 
54 {
55   //
56   //Default Destructor
57   //
58 }
59
60 //_____________________________________________________________________
61 Bool_t AliDielectronCutGroup::IsSelected(TObject* track) 
62 {
63   //
64   // Selection-finder handling different comparison operations
65   //
66   
67   
68   //Different init for and/or makes code shorter
69   Bool_t selectionResult=fCompOperator;
70   
71   TIter listIterator(&fCutGroupList);
72   while (AliAnalysisCuts *thisCut = (AliAnalysisCuts*) listIterator()) {
73     if (fCompOperator == kCompOR) {
74       selectionResult = (selectionResult || thisCut->IsSelected(track));
75     }
76     else { //kCompAND
77       selectionResult = (selectionResult && thisCut->IsSelected(track));
78       if (selectionResult==kFALSE) break; //Save loops vs. additional check?
79     }
80     
81   }
82   return selectionResult;
83 }
84
85 //_____________________________________________________________________
86
87 void AliDielectronCutGroup::AddCut(AliAnalysisCuts* fCut) 
88 {
89   //
90   // Add a defined cut to the list
91   //
92   
93   fCutGroupList.Add(fCut);
94 }
95
96 //_____________________________________________________________________
97 void AliDielectronCutGroup::SetCompOperator(Bool_t compOperator) 
98 {
99   //
100   // Switch between AND/OR
101   //
102   
103   fCompOperator = compOperator;
104 }