Bug fix
[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
58
26f071d8 59AliAnalysisFilter& AliAnalysisFilter::operator=(const AliAnalysisFilter& other)
60{
61// Assignment
62 TNamed::operator=(other);
63 fCuts = other.fCuts;
64 return *this;
65 }
66
10d100d4 67UInt_t AliAnalysisFilter::IsSelected(TObject* track, TObject* event)
7c38d6ee 68{
69 //
70 // Loop over all set of cuts
71 // and store the decision
72 UInt_t result = 0;
c54360e6 73 UInt_t filterMask;
74
7c38d6ee 75 TIter next(fCuts);
76 AliAnalysisCuts *cuts;
77 Int_t iCutB = 1;
78
79 while((cuts = (AliAnalysisCuts*)next())) {
10d100d4 80 Bool_t acc = cuts->IsSelected(track, event);
c54360e6 81 if ((filterMask = cuts->GetFilterMask()) > 0) {
30a5c689 82 acc = (acc && (filterMask == result));
c54360e6 83 }
a710e44a 84 cuts->SetSelected(acc);
7c38d6ee 85 if (acc) {result |= iCutB & 0x00ffffff;}
86 iCutB *= 2;
87 }
88
89 return result;
90}
91
10d100d4 92/*
ac212a3c 93UInt_t AliAnalysisFilter::IsSelected(TList* list)
94{
95 //
96 // Loop over all set of cuts
97 // and store the decision
98 UInt_t result = 0;
a710e44a 99 UInt_t filterMask;
100
ac212a3c 101 TIter next(fCuts);
102 AliAnalysisCuts *cuts;
103 Int_t iCutB = 1;
104
105 while((cuts = (AliAnalysisCuts*)next())) {
106 Bool_t acc = cuts->IsSelected(list);
a710e44a 107 if ((filterMask = cuts->GetFilterMask()) > 0) {
108 acc = (acc && (filterMask & result));
109 }
110 cuts->SetSelected(acc);
ac212a3c 111 if (acc) {result |= iCutB & 0x00ffffff;}
112 iCutB *= 2;
113 }
114
115 return result;
116}
10d100d4 117*/
1b398ab4 118void AliAnalysisFilter::Init()
119{
120 //
121 // Loop over all set of cuts and call Init
122 TIter next(fCuts);
123 AliAnalysisCuts *cuts;
124 while((cuts = (AliAnalysisCuts*)next())) cuts->Init();
125}
126
7c38d6ee 127void AliAnalysisFilter::AddCuts(AliAnalysisCuts* cuts)
128{
129 // Add a set of cuts
130 fCuts->Add(cuts);
131}
a710e44a 132
133Bool_t AliAnalysisFilter::IsSelected(char* name)
134{
135 //
136 // Returns current result for cut with name
137 AliAnalysisCuts* cut = (AliAnalysisCuts*) (fCuts->FindObject(name));
81557f01 138 if (cut) {
139 return (cut->Selected());
140 } else {
141 return 0;
142 }
a710e44a 143}