]>
Commit | Line | Data |
---|---|---|
b2a297fa | 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 | // Cut class providing cuts to all infomation // | |
18 | // available for the AliVParticle interface // // | |
19 | // // | |
20 | // Authors: // | |
21 | // Jens Wiechula <Jens.Wiechula@cern.ch> // | |
22 | /* | |
23 | ||
24 | ||
25 | ||
26 | */ | |
27 | // // | |
28 | /////////////////////////////////////////////////////////////////////////// | |
29 | ||
30 | ||
31 | #include "AliDielectronVarCuts.h" | |
e123f993 | 32 | #include "AliDielectronMC.h" |
b2a297fa | 33 | |
34 | ClassImp(AliDielectronVarCuts) | |
35 | ||
36 | ||
37 | AliDielectronVarCuts::AliDielectronVarCuts() : | |
38 | AliAnalysisCuts(), | |
39 | fNActiveCuts(0), | |
40 | fActiveCutsMask(0), | |
e123f993 | 41 | fSelectedCutsMask(0), |
42 | fCutOnMCtruth(kFALSE), | |
43 | fCutType(kAll) | |
b2a297fa | 44 | { |
45 | // | |
46 | // Default costructor | |
47 | // | |
48 | for (Int_t i=0; i<AliDielectronVarManager::kNMaxValues; ++i){ | |
49 | fActiveCuts[i]=0; | |
50 | fCutMin[i]=0; | |
51 | fCutMax[i]=0; | |
572b0139 | 52 | fCutExclude[i]=kFALSE; |
b2a297fa | 53 | } |
54 | } | |
55 | ||
56 | //________________________________________________________________________ | |
57 | AliDielectronVarCuts::AliDielectronVarCuts(const char* name, const char* title) : | |
58 | AliAnalysisCuts(name,title), | |
59 | fNActiveCuts(0), | |
60 | fActiveCutsMask(0), | |
e123f993 | 61 | fSelectedCutsMask(0), |
62 | fCutOnMCtruth(kFALSE), | |
63 | fCutType(kAll) | |
b2a297fa | 64 | { |
65 | // | |
66 | // Named contructor | |
67 | // | |
68 | for (Int_t i=0; i<AliDielectronVarManager::kNMaxValues; ++i){ | |
69 | fActiveCuts[i]=0; | |
70 | fCutMin[i]=0; | |
71 | fCutMax[i]=0; | |
b9d223bb | 72 | fCutExclude[i]=kFALSE; |
b2a297fa | 73 | } |
74 | } | |
75 | ||
76 | //________________________________________________________________________ | |
77 | AliDielectronVarCuts::~AliDielectronVarCuts() | |
78 | { | |
79 | // | |
80 | // Destructor | |
81 | // | |
82 | } | |
83 | ||
84 | //________________________________________________________________________ | |
85 | Bool_t AliDielectronVarCuts::IsSelected(TObject* track) | |
86 | { | |
87 | // | |
88 | // Make cut decision | |
89 | // | |
90 | ||
e123f993 | 91 | //reset |
b2a297fa | 92 | fSelectedCutsMask=0; |
93 | SetSelected(kFALSE); | |
e123f993 | 94 | |
95 | if (!track) return kFALSE; | |
96 | ||
97 | //If MC cut, get MC truth | |
98 | if (fCutOnMCtruth){ | |
99 | AliVParticle *part=static_cast<AliVParticle*>(track); | |
100 | track=AliDielectronMC::Instance()->GetMCTrackFromMCEvent(part->GetLabel()); | |
101 | if (!track) return kFALSE; | |
102 | } | |
103 | ||
104 | //Fill values | |
105 | Double_t values[AliDielectronVarManager::kNMaxValues]; | |
106 | AliDielectronVarManager::Fill(track,values); | |
b2a297fa | 107 | |
108 | for (Int_t iCut=0; iCut<fNActiveCuts; ++iCut){ | |
109 | Int_t cut=fActiveCuts[iCut]; | |
78091935 | 110 | SETBIT(fSelectedCutsMask,iCut); |
572b0139 | 111 | if ( ((values[cut]<fCutMin[iCut]) || (values[cut]>fCutMax[iCut]))^fCutExclude[iCut] ) CLRBIT(fSelectedCutsMask,iCut); |
de620662 | 112 | if ( fCutType==kAll && !TESTBIT(fSelectedCutsMask,iCut) ) return kFALSE; // option to (minor) speed improvement |
b2a297fa | 113 | } |
e123f993 | 114 | |
b2a297fa | 115 | Bool_t isSelected=(fSelectedCutsMask==fActiveCutsMask); |
e123f993 | 116 | if ( fCutType==kAny ) isSelected=(fSelectedCutsMask>0); |
b2a297fa | 117 | SetSelected(isSelected); |
118 | return isSelected; | |
119 | } | |
78091935 | 120 | |
121 | //________________________________________________________________________ | |
572b0139 | 122 | void AliDielectronVarCuts::AddCut(AliDielectronVarManager::ValueTypes type, Double_t min, Double_t max, Bool_t excludeRange) |
78091935 | 123 | { |
124 | // | |
125 | // Set cut range and activate it | |
126 | // | |
127 | if (min>max){ | |
128 | Double_t tmp=min; | |
129 | min=max; | |
130 | max=tmp; | |
131 | } | |
e123f993 | 132 | fCutMin[fNActiveCuts]=min; |
133 | fCutMax[fNActiveCuts]=max; | |
572b0139 | 134 | fCutExclude[fNActiveCuts]=excludeRange; |
78091935 | 135 | SETBIT(fActiveCutsMask,fNActiveCuts); |
e123f993 | 136 | fActiveCuts[fNActiveCuts]=(UShort_t)type; |
137 | ++fNActiveCuts; | |
78091935 | 138 | } |
b2a297fa | 139 | |
78091935 | 140 | //________________________________________________________________________ |
141 | void AliDielectronVarCuts::Print(const Option_t* /*option*/) const | |
142 | { | |
143 | // | |
144 | // Print cuts and the range | |
145 | // | |
146 | printf("cut ranges for '%s'\n",GetTitle()); | |
e123f993 | 147 | if (fCutType==kAll){ |
148 | printf("All Cuts have to be fulfilled\n"); | |
149 | } else { | |
150 | printf("Any Cut has to be fulfilled\n"); | |
151 | } | |
78091935 | 152 | for (Int_t iCut=0; iCut<fNActiveCuts; ++iCut){ |
e123f993 | 153 | Int_t cut=(Int_t)fActiveCuts[iCut]; |
572b0139 | 154 | Bool_t inverse=fCutExclude[iCut]; |
155 | ||
156 | if (!inverse){ | |
157 | printf("Cut %02d: %f < %s < %f\n", iCut, | |
158 | fCutMin[iCut], AliDielectronVarManager::GetValueName((Int_t)cut), fCutMax[iCut]); | |
159 | } else { | |
160 | printf("Cut %02d: !(%f < %s < %f)\n", iCut, | |
161 | fCutMin[iCut], AliDielectronVarManager::GetValueName((Int_t)cut), fCutMax[iCut]); | |
162 | } | |
78091935 | 163 | } |
164 | } |