Init() method added.
[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):
51 TNamed(obj)
52{
53// Copy constructor
54}
55
56
57UInt_t AliAnalysisFilter::IsSelected(TObject* obj)
58{
59 //
60 // Loop over all set of cuts
61 // and store the decision
62 UInt_t result = 0;
63 TIter next(fCuts);
64 AliAnalysisCuts *cuts;
65 Int_t iCutB = 1;
66
67 while((cuts = (AliAnalysisCuts*)next())) {
68 Bool_t acc = cuts->IsSelected(obj);
69 if (acc) {result |= iCutB & 0x00ffffff;}
70 iCutB *= 2;
71 }
72
73 return result;
74}
75
1b398ab4 76void AliAnalysisFilter::Init()
77{
78 //
79 // Loop over all set of cuts and call Init
80 TIter next(fCuts);
81 AliAnalysisCuts *cuts;
82 while((cuts = (AliAnalysisCuts*)next())) cuts->Init();
83}
84
7c38d6ee 85void AliAnalysisFilter::AddCuts(AliAnalysisCuts* cuts)
86{
87 // Add a set of cuts
88 fCuts->Add(cuts);
89}