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 ///////////////////////////////////////////////////////////////////////////
25 #include "AliCFCutBase.h"
26 #include "AliCFManager.h"
27 #include "AliCFContainer.h"
29 ClassImp(AliCFManager)
31 //_____________________________________________________________________________
32 AliCFManager::AliCFManager() :
43 //_____________________________________________________________________________
44 AliCFManager::AliCFManager(Char_t* name, Char_t* title) :
55 //_____________________________________________________________________________
56 AliCFManager::AliCFManager(const AliCFManager& c) :
58 fEvtContainer(c.fEvtContainer),
59 fPartContainer(c.fPartContainer),
60 fEvtCutList(c.fEvtCutList),
61 fPartCutList(c.fPartCutList)
67 //_____________________________________________________________________________
68 AliCFManager& AliCFManager::operator=(const AliCFManager& c)
71 // Assignment operator
74 TNamed::operator=(c) ;
77 this->fEvtContainer=c.fEvtContainer;
78 this->fPartContainer=c.fPartContainer;
79 this->fEvtCutList=c.fEvtCutList;
80 this->fPartCutList=c.fPartCutList;
84 //_____________________________________________________________________________
85 AliCFManager::~AliCFManager() {
91 //_____________________________________________________________________________
92 Bool_t AliCFManager::CheckParticleCuts(Int_t isel, TObject *obj, const TString &selcuts) const {
94 // check whether object obj passes particle-level selection isel
97 if(isel>=fPartContainer->GetNStep()){
98 AliWarning(Form("Selection index out of Range! isel=%i, max. number of selections= %i", isel,fPartContainer->GetNStep()));
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;
112 //_____________________________________________________________________________
113 Bool_t AliCFManager::CheckEventCuts(Int_t isel, TObject *obj, const TString &selcuts) const{
115 // check whether object obj passes event-level selection isel
118 if(isel>=fEvtContainer->GetNStep()){
119 AliWarning(Form("Selection index out of Range! isel=%i, max. number of selections= %i", isel,fEvtContainer->GetNStep()));
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;
133 //_____________________________________________________________________________
134 void AliCFManager::SetEventInfo(TObject *obj) const {
136 //Particle level cuts
138 if (!fPartContainer) {
139 AliWarning("No particle container");
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);
154 if (!fEvtContainer) {
155 AliWarning("No event container found");
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);
169 //_____________________________________________________________________________
170 Bool_t AliCFManager::CompareStrings(const TString &cutname,const TString &selcuts) const{
172 // compare two strings
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;
184 //_____________________________________________________________________________
185 void AliCFManager::SetEventCutsList(Int_t isel, TObjArray* array) {
187 //Setter for event-level selection cut list at selection step isel
190 if (!fEvtContainer) {
191 AliError("No event container defined, please set it first!");
195 Int_t nstep = fEvtContainer->GetNStep() ;
197 if (!fEvtCutList) fEvtCutList = new TObjArray*[nstep] ;
199 AliWarning(Form("Selection index out of Range! isel=%i, max. number of selections= %i", isel,nstep));
202 fEvtCutList[isel] = array;
205 //_____________________________________________________________________________
206 void AliCFManager::SetParticleCutsList(Int_t isel, TObjArray* array) {
208 //Setter for particle-level selection cut list at selection step isel
211 if (!fPartContainer) {
212 AliError("No event container defined, please set it first!");
216 Int_t nstep = fPartContainer->GetNStep() ;
218 if (!fPartCutList) fPartCutList = new TObjArray*[nstep] ;
220 AliWarning(Form("Selection index out of Range! isel=%i, max. number of selections= %i", isel,nstep));
223 fPartCutList[isel] = array;