1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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
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 ///////////////////////////////////////////////////////////////////////////
24 #include "AliCFCutBase.h"
25 #include "AliCFManager.h"
27 ClassImp(AliCFManager)
29 //_____________________________________________________________________________
30 AliCFManager::AliCFManager() :
43 //_____________________________________________________________________________
44 AliCFManager::AliCFManager(Char_t* name, Char_t* title) :
57 //_____________________________________________________________________________
58 AliCFManager::AliCFManager(const AliCFManager& c) :
60 fNStepEvt(c.fNStepEvt),
61 fNStepPart(c.fNStepPart),
62 fEvtContainer(c.fEvtContainer),
63 fPartContainer(c.fPartContainer),
64 fEvtCutList(c.fEvtCutList),
65 fPartCutList(c.fPartCutList)
71 //_____________________________________________________________________________
72 AliCFManager& AliCFManager::operator=(const AliCFManager& c)
75 // Assignment operator
78 TNamed::operator=(c) ;
81 this->fNStepEvt=c.fNStepEvt;
82 this->fNStepPart=c.fNStepPart;
83 this->fEvtContainer=c.fEvtContainer;
84 this->fPartContainer=c.fPartContainer;
85 this->fEvtCutList=c.fEvtCutList;
86 this->fPartCutList=c.fPartCutList;
90 //_____________________________________________________________________________
91 AliCFManager::~AliCFManager() {
97 //_____________________________________________________________________________
98 Bool_t AliCFManager::CheckParticleCuts(Int_t isel, TObject *obj, const TString &selcuts) const {
100 // check whether object obj passes particle-level selection isel
103 if(isel>=fNStepPart){
104 AliWarning(Form("Selection index out of Range! isel=%i, max. number of selections= %i", isel,fNStepPart));
107 if(!fPartCutList[isel])return kTRUE;
108 TObjArrayIter iter(fPartCutList[isel]);
109 AliCFCutBase *cut = 0;
110 while ( (cut = (AliCFCutBase*)iter.Next()) ) {
111 TString cutName=cut->GetName();
112 Bool_t checkCut=CompareStrings(cutName,selcuts);
113 if(checkCut && !cut->IsSelected(obj)) return kFALSE;
118 //_____________________________________________________________________________
119 Bool_t AliCFManager::CheckEventCuts(Int_t isel, TObject *obj, const TString &selcuts) const{
121 // check whether object obj passes event-level selection isel
125 AliWarning(Form("Selection index out of Range! isel=%i, max. number of selections= %i", isel,fNStepEvt));
128 if(!fEvtCutList[isel])return kTRUE;
129 TObjArrayIter iter(fEvtCutList[isel]);
130 AliCFCutBase *cut = 0;
131 while ( (cut = (AliCFCutBase*)iter.Next()) ) {
132 TString cutName=cut->GetName();
133 Bool_t checkCut=CompareStrings(cutName,selcuts);
134 if(checkCut && !cut->IsSelected(obj)) return kFALSE;
139 //_____________________________________________________________________________
140 void AliCFManager::SetMCEventInfo(const TObject *obj) const {
142 //Particle level cuts
145 AliWarning("No particle cut list found");
148 for(Int_t isel=0;isel<fNStepPart; isel++){
149 if(!fPartCutList[isel])continue;
150 TObjArrayIter iter(fPartCutList[isel]);
151 AliCFCutBase *cut = 0;
152 while ( (cut = (AliCFCutBase*)iter.Next()) ) {
153 cut->SetMCEventInfo(obj);
161 AliWarning("No event cut list found");
164 for(Int_t isel=0;isel<fNStepEvt; isel++){
165 if(!fEvtCutList[isel])continue;
166 TObjArrayIter iter(fEvtCutList[isel]);
167 AliCFCutBase *cut = 0;
168 while ( (cut = (AliCFCutBase*)iter.Next()) ) {
169 cut->SetMCEventInfo(obj);
174 //_____________________________________________________________________________
175 void AliCFManager::SetRecEventInfo(const TObject *obj) const {
177 //Particle level cuts
180 AliWarning("No particle cut list found");
183 for(Int_t isel=0;isel<fNStepPart; isel++){
184 if(!fPartCutList[isel])continue;
185 TObjArrayIter iter(fPartCutList[isel]);
186 AliCFCutBase *cut = 0;
187 while ( (cut = (AliCFCutBase*)iter.Next()) ) {
188 cut->SetRecEventInfo(obj);
196 AliWarning("No event cut list found");
199 for(Int_t isel=0;isel<fNStepEvt; isel++){
200 if(!fEvtCutList[isel])continue;
201 TObjArrayIter iter(fEvtCutList[isel]);
202 AliCFCutBase *cut = 0;
203 while ( (cut = (AliCFCutBase*)iter.Next()) ) {
204 cut->SetRecEventInfo(obj);
210 //_____________________________________________________________________________
211 Bool_t AliCFManager::CompareStrings(const TString &cutname,const TString &selcuts) const{
213 // compare two strings
216 if(selcuts.Contains("all"))return kTRUE;
217 if ( selcuts.CompareTo(cutname) == 0 ||
218 selcuts.BeginsWith(cutname+" ") ||
219 selcuts.EndsWith(" "+cutname) ||
220 selcuts.Contains(" "+cutname+" ")) return kTRUE;
225 //_____________________________________________________________________________
226 void AliCFManager::SetEventCutsList(Int_t isel, TObjArray* array) {
228 //Setter for event-level selection cut list at selection step isel
231 if (!fEvtContainer) {
232 AliWarning("No event container defined, you may need to set it first!");
235 Int_t nstep = fNStepEvt;
238 fEvtCutList = new TObjArray*[nstep] ;
239 for (Int_t i=0; i<nstep; ++i) fEvtCutList[i] = 0;
242 AliWarning(Form("Selection index out of Range! isel=%i, max. number of selections= %i", isel,nstep));
245 fEvtCutList[isel] = array;
248 //_____________________________________________________________________________
249 void AliCFManager::SetParticleCutsList(Int_t isel, TObjArray* array) {
251 //Setter for particle-level selection cut list at selection step isel
254 if (!fPartContainer) {
255 AliWarning("No particle container defined, you may need to set it first!");
258 Int_t nstep = fNStepPart ;
261 fPartCutList = new TObjArray*[nstep] ;
262 for (Int_t istep = 0; istep < nstep; istep++) fPartCutList[istep] = 0;
266 AliWarning(Form("Selection index out of Range! isel=%i, max. number of selections= %i", isel,nstep));
269 fPartCutList[isel] = array;