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