]>
Commit | Line | Data |
---|---|---|
563113d0 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, 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 | // The class AliCFManager is designed to handle inside the | |
17 | // task the basic components for a particle-level correction of single | |
18 | // particle analysis | |
19 | // The class provides methods to set lists of cuts and to loop over them | |
20 | // for several different selection steps to be then used for | |
21 | // efficiency calculation. | |
22 | // prototype version by S.Arcelli silvia.arcelli@cern.ch | |
23 | /////////////////////////////////////////////////////////////////////////// | |
563113d0 | 24 | #include "AliLog.h" |
25 | #include "AliCFCutBase.h" | |
26 | #include "AliCFManager.h" | |
84df86a7 | 27 | #include "AliCFContainer.h" |
563113d0 | 28 | |
29 | ClassImp(AliCFManager) | |
30 | ||
31 | //_____________________________________________________________________________ | |
32 | AliCFManager::AliCFManager() : | |
33 | TNamed(), | |
34 | fEvtContainer(0x0), | |
84df86a7 | 35 | fPartContainer(0x0), |
36 | fEvtCutList(0x0), | |
37 | fPartCutList(0x0) | |
563113d0 | 38 | { |
39 | // | |
40 | // ctor | |
41 | // | |
563113d0 | 42 | } |
43 | //_____________________________________________________________________________ | |
44 | AliCFManager::AliCFManager(Char_t* name, Char_t* title) : | |
45 | TNamed(name,title), | |
46 | fEvtContainer(0x0), | |
84df86a7 | 47 | fPartContainer(0x0), |
48 | fEvtCutList(0x0), | |
49 | fPartCutList(0x0) | |
50 | { | |
563113d0 | 51 | // |
52 | // ctor | |
53 | // | |
563113d0 | 54 | } |
55 | //_____________________________________________________________________________ | |
56 | AliCFManager::AliCFManager(const AliCFManager& c) : | |
57 | TNamed(c), | |
58 | fEvtContainer(c.fEvtContainer), | |
84df86a7 | 59 | fPartContainer(c.fPartContainer), |
60 | fEvtCutList(c.fEvtCutList), | |
61 | fPartCutList(c.fPartCutList) | |
62 | { | |
563113d0 | 63 | // |
64 | //copy ctor | |
65 | // | |
84df86a7 | 66 | } |
563113d0 | 67 | //_____________________________________________________________________________ |
68 | AliCFManager& AliCFManager::operator=(const AliCFManager& c) | |
69 | { | |
70 | // | |
71 | // Assignment operator | |
72 | // | |
73 | if (this != &c) { | |
74 | TNamed::operator=(c) ; | |
75 | } | |
84df86a7 | 76 | |
563113d0 | 77 | this->fEvtContainer=c.fEvtContainer; |
78 | this->fPartContainer=c.fPartContainer; | |
84df86a7 | 79 | this->fEvtCutList=c.fEvtCutList; |
80 | this->fPartCutList=c.fPartCutList; | |
563113d0 | 81 | return *this ; |
82 | } | |
83 | ||
84 | //_____________________________________________________________________________ | |
85 | AliCFManager::~AliCFManager() { | |
86 | // | |
87 | //dtor | |
88 | // | |
563113d0 | 89 | } |
90 | ||
91 | //_____________________________________________________________________________ | |
92 | Bool_t AliCFManager::CheckParticleCuts(Int_t isel, TObject *obj, const TString &selcuts) const { | |
93 | // | |
94 | // check whether object obj passes particle-level selection isel | |
95 | // | |
96 | ||
84df86a7 | 97 | if(isel>=fPartContainer->GetNStep()){ |
98 | AliWarning(Form("Selection index out of Range! isel=%i, max. number of selections= %i", isel,fPartContainer->GetNStep())); | |
99 | return kTRUE; | |
563113d0 | 100 | } |
101 | if(!fPartCutList[isel])return kTRUE; | |
102 | TObjArrayIter iter(fPartCutList[isel]); | |
103 | AliCFCutBase *cut = 0; | |
104 | while ( (cut = (AliCFCutBase*)iter.Next()) ) { | |
105 | TString cutName=cut->GetName(); | |
106 | Bool_t checkCut=CompareStrings(cutName,selcuts); | |
107 | if(checkCut && !cut->IsSelected(obj)) return kFALSE; | |
108 | } | |
109 | return kTRUE; | |
110 | } | |
111 | ||
112 | //_____________________________________________________________________________ | |
113 | Bool_t AliCFManager::CheckEventCuts(Int_t isel, TObject *obj, const TString &selcuts) const{ | |
114 | // | |
115 | // check whether object obj passes event-level selection isel | |
116 | // | |
117 | ||
84df86a7 | 118 | if(isel>=fEvtContainer->GetNStep()){ |
119 | AliWarning(Form("Selection index out of Range! isel=%i, max. number of selections= %i", isel,fEvtContainer->GetNStep())); | |
563113d0 | 120 | return kTRUE; |
121 | } | |
122 | if(!fEvtCutList[isel])return kTRUE; | |
123 | TObjArrayIter iter(fEvtCutList[isel]); | |
124 | AliCFCutBase *cut = 0; | |
125 | while ( (cut = (AliCFCutBase*)iter.Next()) ) { | |
126 | TString cutName=cut->GetName(); | |
127 | Bool_t checkCut=CompareStrings(cutName,selcuts); | |
128 | if(checkCut && !cut->IsSelected(obj)) return kFALSE; | |
129 | } | |
130 | return kTRUE; | |
131 | } | |
132 | ||
563113d0 | 133 | //_____________________________________________________________________________ |
134 | void AliCFManager::SetEventInfo(TObject *obj) const { | |
135 | ||
136 | //Particle level cuts | |
137 | ||
84df86a7 | 138 | if (!fPartContainer) { |
139 | AliWarning("No particle container"); | |
140 | } | |
141 | else { | |
142 | for(Int_t isel=0;isel<fPartContainer->GetNStep(); isel++){ | |
143 | if(!fPartCutList[isel])continue; | |
144 | TObjArrayIter iter(fPartCutList[isel]); | |
145 | AliCFCutBase *cut = 0; | |
146 | while ( (cut = (AliCFCutBase*)iter.Next()) ) { | |
147 | cut->SetEvtInfo(obj); | |
148 | } | |
149 | } | |
563113d0 | 150 | } |
151 | ||
152 | //Event level cuts | |
84df86a7 | 153 | |
154 | if (!fEvtContainer) { | |
155 | AliWarning("No event container found"); | |
156 | } | |
157 | else { | |
158 | for(Int_t isel=0;isel<fEvtContainer->GetNStep(); isel++){ | |
159 | if(!fEvtCutList[isel])continue; | |
160 | TObjArrayIter iter(fEvtCutList[isel]); | |
161 | AliCFCutBase *cut = 0; | |
162 | while ( (cut = (AliCFCutBase*)iter.Next()) ) { | |
163 | cut->SetEvtInfo(obj); | |
164 | } | |
165 | } | |
563113d0 | 166 | } |
167 | } | |
563113d0 | 168 | |
169 | //_____________________________________________________________________________ | |
170 | Bool_t AliCFManager::CompareStrings(const TString &cutname,const TString &selcuts) const{ | |
171 | // | |
172 | // compare two strings | |
173 | // | |
174 | ||
175 | if(selcuts.Contains("all"))return kTRUE; | |
176 | if ( selcuts.CompareTo(cutname) == 0 || | |
177 | selcuts.BeginsWith(cutname+" ") || | |
178 | selcuts.EndsWith(" "+cutname) || | |
179 | selcuts.Contains(" "+cutname+" ")) return kTRUE; | |
180 | return kFALSE; | |
181 | } | |
182 | ||
183 | ||
84df86a7 | 184 | //_____________________________________________________________________________ |
185 | void AliCFManager::SetEventCutsList(Int_t isel, TObjArray* array) { | |
186 | // | |
187 | //Setter for event-level selection cut list at selection step isel | |
188 | // | |
189 | ||
190 | if (!fEvtContainer) { | |
191 | AliError("No event container defined, please set it first!"); | |
192 | return; | |
193 | } | |
194 | ||
195 | Int_t nstep = fEvtContainer->GetNStep() ; | |
196 | ||
197 | if (!fEvtCutList) fEvtCutList = new TObjArray*[nstep] ; | |
198 | if (isel >= nstep) { | |
199 | AliWarning(Form("Selection index out of Range! isel=%i, max. number of selections= %i", isel,nstep)); | |
200 | return; | |
201 | } | |
202 | fEvtCutList[isel] = array; | |
203 | } | |
204 | ||
205 | //_____________________________________________________________________________ | |
206 | void AliCFManager::SetParticleCutsList(Int_t isel, TObjArray* array) { | |
207 | // | |
208 | //Setter for particle-level selection cut list at selection step isel | |
209 | // | |
210 | ||
211 | if (!fPartContainer) { | |
212 | AliError("No event container defined, please set it first!"); | |
213 | return; | |
214 | } | |
215 | ||
216 | Int_t nstep = fPartContainer->GetNStep() ; | |
217 | ||
218 | if (!fPartCutList) fPartCutList = new TObjArray*[nstep] ; | |
219 | if (isel >= nstep) { | |
220 | AliWarning(Form("Selection index out of Range! isel=%i, max. number of selections= %i", isel,nstep)); | |
221 | return; | |
222 | } | |
223 | fPartCutList[isel] = array; | |
224 | } |