This version includes the suppression of the 0.5 channel shift used previously to...
[u/mrichter/AliRoot.git] / CORRFW / AliCFManager.cxx
CommitLineData
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"
27
28ClassImp(AliCFManager)
29
30//_____________________________________________________________________________
31AliCFManager::AliCFManager() :
32 TNamed(),
33 fEvtContainer(0x0),
9f6be3a2 34 fPartContainer(0x0)
563113d0 35{
36 //
37 // ctor
38 //
39 for(Int_t i=0;i<kNEvtSel;i++)fEvtCutList[i]=0x0;
40 for(Int_t i=0;i<kNPartSel;i++)fPartCutList[i]=0x0;
563113d0 41}
42//_____________________________________________________________________________
43AliCFManager::AliCFManager(Char_t* name, Char_t* title) :
44 TNamed(name,title),
45 fEvtContainer(0x0),
9f6be3a2 46 fPartContainer(0x0)
563113d0 47 {
48 //
49 // ctor
50 //
51 for(Int_t i=0;i<kNEvtSel;i++)fEvtCutList[i]=0x0;
52 for(Int_t i=0;i<kNPartSel;i++)fPartCutList[i]=0x0;
563113d0 53}
54//_____________________________________________________________________________
55AliCFManager::AliCFManager(const AliCFManager& c) :
56 TNamed(c),
57 fEvtContainer(c.fEvtContainer),
9f6be3a2 58 fPartContainer(c.fPartContainer)
563113d0 59 {
60 //
61 //copy ctor
62 //
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];
65 }
66//_____________________________________________________________________________
67AliCFManager& AliCFManager::operator=(const AliCFManager& c)
68{
69 //
70 // Assignment operator
71 //
72 if (this != &c) {
73 TNamed::operator=(c) ;
74 }
75
76 this->fEvtContainer=c.fEvtContainer;
77 this->fPartContainer=c.fPartContainer;
563113d0 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];
80 return *this ;
81}
82
83//_____________________________________________________________________________
84AliCFManager::~AliCFManager() {
85 //
86 //dtor
87 //
563113d0 88}
89
90//_____________________________________________________________________________
91Bool_t AliCFManager::CheckParticleCuts(Int_t isel, TObject *obj, const TString &selcuts) const {
92 //
93 // check whether object obj passes particle-level selection isel
94 //
95
96 if(isel>=kNPartSel){
97 AliWarning(Form("Selection index out of Range! isel=%i, max. number of selections= %i", isel,kNPartSel));
98 return kTRUE;
99 }
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;
107 }
108 return kTRUE;
109}
110
111//_____________________________________________________________________________
112Bool_t AliCFManager::CheckEventCuts(Int_t isel, TObject *obj, const TString &selcuts) const{
113 //
114 // check whether object obj passes event-level selection isel
115 //
116
117 if(isel>=kNEvtSel){
118 AliWarning(Form("Selection index out of Range! isel=%i, max. number of selections= %i", isel,kNEvtSel));
119 return kTRUE;
120 }
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;
128 }
129 return kTRUE;
130}
131
132//_____________________________________________________________________________
563113d0 133void AliCFManager::SetEventInfo(TObject *obj) const {
134
135 //Particle level cuts
136
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);
143 }
144 }
145
146 //Event level cuts
147
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);
154 }
155 }
156}
563113d0 157
158//_____________________________________________________________________________
159Bool_t AliCFManager::CompareStrings(const TString &cutname,const TString &selcuts) const{
160 //
161 // compare two strings
162 //
163
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;
169 return kFALSE;
170}
171
172