]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ANALYSIS/AliAnalysisFilter.cxx
Merge branch 'master', remote branch 'origin' into TPCdev
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisFilter.cxx
CommitLineData
7c38d6ee 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
1b398ab4 16/* $Id$ */
17
7c38d6ee 18//
19// Manager class for filter decisions based on cuts
20// The filter contains a list of sets of cuts.
21// A bit field is filled in order to store the decision of each cut-set.
22// Author: Andreas Morsch
23// andreas.morsch@cern.ch
24
25#include <TObject.h>
26#include <TList.h>
27#include "AliAnalysisFilter.h"
28#include "AliAnalysisCuts.h"
29
30
31ClassImp(AliAnalysisFilter)
32
33
34////////////////////////////////////////////////////////////////////////
35
36AliAnalysisFilter::AliAnalysisFilter():
37 TNamed(),
38 fCuts(0)
39{
40 // Default constructor
41}
42
43AliAnalysisFilter::AliAnalysisFilter(const char* name, const char* title):
44 TNamed(name, title),
45 fCuts(new TList())
46{
47 // Constructor
48}
49
50AliAnalysisFilter::AliAnalysisFilter(const AliAnalysisFilter& obj):
26f071d8 51 TNamed(obj),
52 fCuts(0)
7c38d6ee 53{
54// Copy constructor
26f071d8 55 fCuts = obj.fCuts;
7c38d6ee 56}
57
483ad248 58AliAnalysisFilter::~AliAnalysisFilter()
59{
60// Destructor
61 if (fCuts) fCuts->Delete("slow");
62 delete fCuts;
63}
7c38d6ee 64
26f071d8 65AliAnalysisFilter& AliAnalysisFilter::operator=(const AliAnalysisFilter& other)
66{
67// Assignment
9702ce91 68 if (&other != this) {
69 TNamed::operator=(other);
70 fCuts = other.fCuts;
71 }
72 return *this;
26f071d8 73 }
74
9eeae5d5 75UInt_t AliAnalysisFilter::IsSelected(TObject* obj)
7c38d6ee 76{
77 //
78 // Loop over all set of cuts
79 // and store the decision
80 UInt_t result = 0;
c54360e6 81 UInt_t filterMask;
82
7c38d6ee 83 TIter next(fCuts);
84 AliAnalysisCuts *cuts;
85 Int_t iCutB = 1;
86
87 while((cuts = (AliAnalysisCuts*)next())) {
9eeae5d5 88 Bool_t acc = cuts->IsSelected(obj);
c54360e6 89 if ((filterMask = cuts->GetFilterMask()) > 0) {
30a5c689 90 acc = (acc && (filterMask == result));
c54360e6 91 }
a710e44a 92 cuts->SetSelected(acc);
7c38d6ee 93 if (acc) {result |= iCutB & 0x00ffffff;}
94 iCutB *= 2;
95 }
96
97 return result;
98}
99
ac212a3c 100UInt_t AliAnalysisFilter::IsSelected(TList* list)
101{
102 //
103 // Loop over all set of cuts
104 // and store the decision
105 UInt_t result = 0;
a710e44a 106 UInt_t filterMask;
107
ac212a3c 108 TIter next(fCuts);
109 AliAnalysisCuts *cuts;
110 Int_t iCutB = 1;
111
112 while((cuts = (AliAnalysisCuts*)next())) {
113 Bool_t acc = cuts->IsSelected(list);
a710e44a 114 if ((filterMask = cuts->GetFilterMask()) > 0) {
115 acc = (acc && (filterMask & result));
116 }
117 cuts->SetSelected(acc);
ac212a3c 118 if (acc) {result |= iCutB & 0x00ffffff;}
119 iCutB *= 2;
120 }
121
122 return result;
123}
9eeae5d5 124
1b398ab4 125void AliAnalysisFilter::Init()
126{
127 //
128 // Loop over all set of cuts and call Init
129 TIter next(fCuts);
130 AliAnalysisCuts *cuts;
131 while((cuts = (AliAnalysisCuts*)next())) cuts->Init();
132}
133
7c38d6ee 134void AliAnalysisFilter::AddCuts(AliAnalysisCuts* cuts)
135{
136 // Add a set of cuts
137 fCuts->Add(cuts);
138}
a710e44a 139
140Bool_t AliAnalysisFilter::IsSelected(char* name)
141{
142 //
143 // Returns current result for cut with name
144 AliAnalysisCuts* cut = (AliAnalysisCuts*) (fCuts->FindObject(name));
81557f01 145 if (cut) {
146 return (cut->Selected());
147 } else {
148 return 0;
149 }
a710e44a 150}