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