]>
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 | ||
775970eb | 31 | #include <TH1.h> |
32 | ||
b2a297fa | 33 | #include "AliDielectronVarCuts.h" |
e123f993 | 34 | #include "AliDielectronMC.h" |
b2a297fa | 35 | |
36 | ClassImp(AliDielectronVarCuts) | |
37 | ||
38 | ||
39 | AliDielectronVarCuts::AliDielectronVarCuts() : | |
40 | AliAnalysisCuts(), | |
a94c2e7e | 41 | fUsedVars(new TBits(AliDielectronVarManager::kNMaxValues)), |
b2a297fa | 42 | fNActiveCuts(0), |
43 | fActiveCutsMask(0), | |
e123f993 | 44 | fSelectedCutsMask(0), |
45 | fCutOnMCtruth(kFALSE), | |
46 | fCutType(kAll) | |
b2a297fa | 47 | { |
48 | // | |
49 | // Default costructor | |
50 | // | |
51 | for (Int_t i=0; i<AliDielectronVarManager::kNMaxValues; ++i){ | |
52 | fActiveCuts[i]=0; | |
53 | fCutMin[i]=0; | |
54 | fCutMax[i]=0; | |
572b0139 | 55 | fCutExclude[i]=kFALSE; |
775970eb | 56 | fUpperCut[i]=0x0; |
b2a297fa | 57 | } |
58 | } | |
59 | ||
60 | //________________________________________________________________________ | |
61 | AliDielectronVarCuts::AliDielectronVarCuts(const char* name, const char* title) : | |
62 | AliAnalysisCuts(name,title), | |
a94c2e7e | 63 | fUsedVars(new TBits(AliDielectronVarManager::kNMaxValues)), |
b2a297fa | 64 | fNActiveCuts(0), |
65 | fActiveCutsMask(0), | |
e123f993 | 66 | fSelectedCutsMask(0), |
67 | fCutOnMCtruth(kFALSE), | |
68 | fCutType(kAll) | |
b2a297fa | 69 | { |
70 | // | |
71 | // Named contructor | |
72 | // | |
73 | for (Int_t i=0; i<AliDielectronVarManager::kNMaxValues; ++i){ | |
74 | fActiveCuts[i]=0; | |
75 | fCutMin[i]=0; | |
76 | fCutMax[i]=0; | |
b9d223bb | 77 | fCutExclude[i]=kFALSE; |
775970eb | 78 | fUpperCut[i]=0x0; |
b2a297fa | 79 | } |
80 | } | |
81 | ||
82 | //________________________________________________________________________ | |
83 | AliDielectronVarCuts::~AliDielectronVarCuts() | |
84 | { | |
85 | // | |
86 | // Destructor | |
87 | // | |
a94c2e7e | 88 | if (fUsedVars) delete fUsedVars; |
b2a297fa | 89 | } |
90 | ||
91 | //________________________________________________________________________ | |
92 | Bool_t AliDielectronVarCuts::IsSelected(TObject* track) | |
93 | { | |
94 | // | |
95 | // Make cut decision | |
96 | // | |
97 | ||
e123f993 | 98 | //reset |
b2a297fa | 99 | fSelectedCutsMask=0; |
100 | SetSelected(kFALSE); | |
e123f993 | 101 | |
102 | if (!track) return kFALSE; | |
775970eb | 103 | |
e123f993 | 104 | //If MC cut, get MC truth |
105 | if (fCutOnMCtruth){ | |
106 | AliVParticle *part=static_cast<AliVParticle*>(track); | |
107 | track=AliDielectronMC::Instance()->GetMCTrackFromMCEvent(part->GetLabel()); | |
108 | if (!track) return kFALSE; | |
109 | } | |
110 | ||
111 | //Fill values | |
112 | Double_t values[AliDielectronVarManager::kNMaxValues]; | |
a94c2e7e | 113 | AliDielectronVarManager::SetFillMap(fUsedVars); |
e123f993 | 114 | AliDielectronVarManager::Fill(track,values); |
775970eb | 115 | |
b2a297fa | 116 | for (Int_t iCut=0; iCut<fNActiveCuts; ++iCut){ |
117 | Int_t cut=fActiveCuts[iCut]; | |
78091935 | 118 | SETBIT(fSelectedCutsMask,iCut); |
775970eb | 119 | if ( !fUpperCut[iCut] && ((values[cut]<fCutMin[iCut]) || (values[cut]>fCutMax[iCut]))^fCutExclude[iCut] ) CLRBIT(fSelectedCutsMask,iCut); |
120 | else if ( fUpperCut[iCut]) { | |
121 | // use a TH1 inherited cut object | |
122 | Float_t x=0.,y=0.,z=0.; | |
123 | switch (fUpperCut[iCut]->GetDimension()) { | |
124 | case 3: z=values[fUpperCut[iCut]->GetZaxis()->GetUniqueID()]; | |
125 | case 2: y=values[fUpperCut[iCut]->GetYaxis()->GetUniqueID()]; | |
126 | case 1: x=values[fUpperCut[iCut]->GetXaxis()->GetUniqueID()]; | |
127 | } | |
128 | Int_t bin = fUpperCut[iCut]->FindBin(x,y,z); | |
129 | if ( ((values[cut]<fCutMin[iCut]) || (values[cut]>fUpperCut[iCut]->GetBinContent(bin)))^fCutExclude[iCut] ) CLRBIT(fSelectedCutsMask,iCut); | |
130 | } | |
de620662 | 131 | if ( fCutType==kAll && !TESTBIT(fSelectedCutsMask,iCut) ) return kFALSE; // option to (minor) speed improvement |
b2a297fa | 132 | } |
775970eb | 133 | |
b2a297fa | 134 | Bool_t isSelected=(fSelectedCutsMask==fActiveCutsMask); |
e123f993 | 135 | if ( fCutType==kAny ) isSelected=(fSelectedCutsMask>0); |
b2a297fa | 136 | SetSelected(isSelected); |
137 | return isSelected; | |
138 | } | |
78091935 | 139 | |
140 | //________________________________________________________________________ | |
572b0139 | 141 | void AliDielectronVarCuts::AddCut(AliDielectronVarManager::ValueTypes type, Double_t min, Double_t max, Bool_t excludeRange) |
78091935 | 142 | { |
143 | // | |
144 | // Set cut range and activate it | |
145 | // | |
146 | if (min>max){ | |
147 | Double_t tmp=min; | |
148 | min=max; | |
149 | max=tmp; | |
150 | } | |
e123f993 | 151 | fCutMin[fNActiveCuts]=min; |
152 | fCutMax[fNActiveCuts]=max; | |
572b0139 | 153 | fCutExclude[fNActiveCuts]=excludeRange; |
78091935 | 154 | SETBIT(fActiveCutsMask,fNActiveCuts); |
e123f993 | 155 | fActiveCuts[fNActiveCuts]=(UShort_t)type; |
a94c2e7e | 156 | fUsedVars->SetBitNumber(type,kTRUE); |
e123f993 | 157 | ++fNActiveCuts; |
78091935 | 158 | } |
b2a297fa | 159 | |
775970eb | 160 | //________________________________________________________________________ |
161 | void AliDielectronVarCuts::AddCut(AliDielectronVarManager::ValueTypes type, Double_t min, TH1 * const max, Bool_t excludeRange) | |
162 | { | |
163 | // | |
164 | // Set cut range and activate it | |
165 | // | |
166 | fCutMin[fNActiveCuts]=min; | |
167 | fCutMax[fNActiveCuts]=0.0; | |
168 | fCutExclude[fNActiveCuts]=excludeRange; | |
169 | SETBIT(fActiveCutsMask,fNActiveCuts); | |
170 | fActiveCuts[fNActiveCuts]=(UShort_t)type; | |
171 | fUsedVars->SetBitNumber(type,kTRUE); | |
172 | // cut dependencies | |
173 | UInt_t var =0; | |
174 | switch(max->GetDimension()) { | |
175 | case 3: | |
176 | case 2: | |
177 | var=AliDielectronVarManager::GetValueType(max->GetZaxis()->GetName()); | |
178 | fUsedVars->SetBitNumber(var,kTRUE); | |
179 | max->GetZaxis()->SetUniqueID(var); | |
180 | case 1: | |
181 | var=AliDielectronVarManager::GetValueType(max->GetYaxis()->GetName()); | |
182 | fUsedVars->SetBitNumber(var,kTRUE); | |
183 | max->GetYaxis()->SetUniqueID(var); | |
184 | /*case 1:*/ | |
185 | var=AliDielectronVarManager::GetValueType(max->GetXaxis()->GetName()); | |
186 | fUsedVars->SetBitNumber(var,kTRUE); | |
187 | max->GetXaxis()->SetUniqueID(var); | |
188 | } | |
189 | fUpperCut[fNActiveCuts]=(TH1*)max->Clone("histCut"); | |
190 | fUpperCut[fNActiveCuts]->SetDirectory(0x0); | |
191 | ++fNActiveCuts; | |
192 | } | |
193 | ||
78091935 | 194 | //________________________________________________________________________ |
195 | void AliDielectronVarCuts::Print(const Option_t* /*option*/) const | |
196 | { | |
197 | // | |
198 | // Print cuts and the range | |
199 | // | |
200 | printf("cut ranges for '%s'\n",GetTitle()); | |
e123f993 | 201 | if (fCutType==kAll){ |
202 | printf("All Cuts have to be fulfilled\n"); | |
203 | } else { | |
204 | printf("Any Cut has to be fulfilled\n"); | |
205 | } | |
78091935 | 206 | for (Int_t iCut=0; iCut<fNActiveCuts; ++iCut){ |
e123f993 | 207 | Int_t cut=(Int_t)fActiveCuts[iCut]; |
572b0139 | 208 | Bool_t inverse=fCutExclude[iCut]; |
209 | ||
210 | if (!inverse){ | |
211 | printf("Cut %02d: %f < %s < %f\n", iCut, | |
212 | fCutMin[iCut], AliDielectronVarManager::GetValueName((Int_t)cut), fCutMax[iCut]); | |
213 | } else { | |
214 | printf("Cut %02d: !(%f < %s < %f)\n", iCut, | |
215 | fCutMin[iCut], AliDielectronVarManager::GetValueName((Int_t)cut), fCutMax[iCut]); | |
216 | } | |
78091935 | 217 | } |
218 | } |