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