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"
28 ClassImp(AliCFManager)
30 //_____________________________________________________________________________
31 AliCFManager::AliCFManager() :
39 for(Int_t i=0;i<kNEvtSel;i++)fEvtCutList[i]=0x0;
40 for(Int_t i=0;i<kNPartSel;i++)fPartCutList[i]=0x0;
42 //_____________________________________________________________________________
43 AliCFManager::AliCFManager(Char_t* name, Char_t* title) :
51 for(Int_t i=0;i<kNEvtSel;i++)fEvtCutList[i]=0x0;
52 for(Int_t i=0;i<kNPartSel;i++)fPartCutList[i]=0x0;
54 //_____________________________________________________________________________
55 AliCFManager::AliCFManager(const AliCFManager& c) :
57 fEvtContainer(c.fEvtContainer),
58 fPartContainer(c.fPartContainer)
63 for(Int_t i=0;i<kNEvtSel;i++)fEvtCutList[i]=c.fEvtCutList[i];
64 for(Int_t i=0;i<kNPartSel;i++)fPartCutList[i]=c.fPartCutList[i];
66 //_____________________________________________________________________________
67 AliCFManager& AliCFManager::operator=(const AliCFManager& c)
70 // Assignment operator
73 TNamed::operator=(c) ;
76 this->fEvtContainer=c.fEvtContainer;
77 this->fPartContainer=c.fPartContainer;
78 for(Int_t i=0;i<kNEvtSel;i++)this->fEvtCutList[i]=c.fEvtCutList[i];
79 for(Int_t i=0;i<kNPartSel;i++)this->fPartCutList[i]=c.fPartCutList[i];
83 //_____________________________________________________________________________
84 AliCFManager::~AliCFManager() {
90 //_____________________________________________________________________________
91 Bool_t AliCFManager::CheckParticleCuts(Int_t isel, TObject *obj, const TString &selcuts) const {
93 // check whether object obj passes particle-level selection isel
97 AliWarning(Form("Selection index out of Range! isel=%i, max. number of selections= %i", isel,kNPartSel));
100 if(!fPartCutList[isel])return kTRUE;
101 TObjArrayIter iter(fPartCutList[isel]);
102 AliCFCutBase *cut = 0;
103 while ( (cut = (AliCFCutBase*)iter.Next()) ) {
104 TString cutName=cut->GetName();
105 Bool_t checkCut=CompareStrings(cutName,selcuts);
106 if(checkCut && !cut->IsSelected(obj)) return kFALSE;
111 //_____________________________________________________________________________
112 Bool_t AliCFManager::CheckEventCuts(Int_t isel, TObject *obj, const TString &selcuts) const{
114 // check whether object obj passes event-level selection isel
118 AliWarning(Form("Selection index out of Range! isel=%i, max. number of selections= %i", isel,kNEvtSel));
121 if(!fEvtCutList[isel])return kTRUE;
122 TObjArrayIter iter(fEvtCutList[isel]);
123 AliCFCutBase *cut = 0;
124 while ( (cut = (AliCFCutBase*)iter.Next()) ) {
125 TString cutName=cut->GetName();
126 Bool_t checkCut=CompareStrings(cutName,selcuts);
127 if(checkCut && !cut->IsSelected(obj)) return kFALSE;
132 //_____________________________________________________________________________
133 void AliCFManager::SetEventInfo(TObject *obj) const {
135 //Particle level cuts
137 for(Int_t isel=0;isel<kNPartSel; isel++){
138 if(!fPartCutList[isel])continue;
139 TObjArrayIter iter(fPartCutList[isel]);
140 AliCFCutBase *cut = 0;
141 while ( (cut = (AliCFCutBase*)iter.Next()) ) {
142 cut->SetEvtInfo(obj);
148 for(Int_t isel=0;isel<kNEvtSel; isel++){
149 if(!fEvtCutList[isel])continue;
150 TObjArrayIter iter(fEvtCutList[isel]);
151 AliCFCutBase *cut = 0;
152 while ( (cut = (AliCFCutBase*)iter.Next()) ) {
153 cut->SetEvtInfo(obj);
158 //_____________________________________________________________________________
159 Bool_t AliCFManager::CompareStrings(const TString &cutname,const TString &selcuts) const{
161 // compare two strings
164 if(selcuts.Contains("all"))return kTRUE;
165 if ( selcuts.CompareTo(cutname) == 0 ||
166 selcuts.BeginsWith(cutname+" ") ||
167 selcuts.EndsWith(" "+cutname) ||
168 selcuts.Contains(" "+cutname+" ")) return kTRUE;