]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG3/hfe/AliHFEcutStep.cxx
Coveriry
[u/mrichter/AliRoot.git] / PWG3 / hfe / AliHFEcutStep.cxx
CommitLineData
70da6c5a 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// Cut step class
17// Select all tracks surviving cuts in one special cut step
18// Used in AliHFEtrackFilter
19//
20// Author:
21// Markus Fasel <M.Fasel@gsi.de>
22//
23#include <TObjArray.h>
24
25#include "AliAnalysisCuts.h"
26#include "AliCFCutBase.h"
27#include "AliHFEcutStep.h"
28#include "AliLog.h"
29#include "AliMCEvent.h"
30
31ClassImp(AliHFEcutStep)
32
33//__________________________________________________________________
34AliHFEcutStep::AliHFEcutStep(const Char_t *name):
35 TNamed(name, ""),
36 fCuts(NULL)
37{
38 //
39 // Default Constructor
40 //
41 fCuts = new TObjArray;
42}
43
44//__________________________________________________________________
45AliHFEcutStep::AliHFEcutStep(const AliHFEcutStep &o):
46 TNamed(o),
47 fCuts(NULL)
48{
49 //
50 // Copy constructor
51 //
52 o.Copy(*this);
53}
54
55//__________________________________________________________________
56AliHFEcutStep &AliHFEcutStep::operator=(const AliHFEcutStep &o){
57 //
58 // Assignment operator
59 //
60 if(this != &o)
61 o.Copy(*this);
62 return *this;
63}
64
65//__________________________________________________________________
66AliHFEcutStep::~AliHFEcutStep(){
67 //
68 // destructor
69 //
70 delete fCuts;
71}
72
73//__________________________________________________________________
74void AliHFEcutStep::Copy(TObject &o) const{
75 //
76 // Copy into content into object o
77 //
78 TNamed::Copy(o);
79 AliHFEcutStep &target = dynamic_cast<AliHFEcutStep &>(o);
80
81 // Make copy
82 target.fCuts = dynamic_cast<TObjArray *>(fCuts->Clone());
83}
84
85//__________________________________________________________________
86Bool_t AliHFEcutStep::IsSelected(TObject *o){
87 //
88 // Filter tracks in the given cut step
89 // Apply all cut objects
90 //
91c7e1ec 91 AliDebug(1, Form("Cut Step %s: Number of cut objects: %d", GetName(), fCuts->GetEntriesFast()));
70da6c5a 92 if(!fCuts->GetEntriesFast()) return kTRUE;
93 Bool_t isSelected = kTRUE;
e3ae862b 94 AliAnalysisCuts *cuts = NULL;
70da6c5a 95 for(Int_t iCut = 0; iCut < fCuts->GetEntriesFast(); iCut++){
e3ae862b 96 cuts = dynamic_cast<AliAnalysisCuts *>(fCuts->UncheckedAt(iCut));
97 if(cuts && (!cuts->IsSelected(o))) isSelected = kFALSE;
70da6c5a 98 }
91c7e1ec 99 AliDebug(1, Form("Accepted: %s", isSelected ? "yes" : "no"));
70da6c5a 100 return isSelected;
101}
102
103//__________________________________________________________________
104AliAnalysisCuts *AliHFEcutStep::GetCut(const Char_t *cutName){
105 //
106 // return cut object
107 //
108 return dynamic_cast<AliAnalysisCuts *>(fCuts->FindObject(cutName));
109}
110
111//__________________________________________________________________
112void AliHFEcutStep::AddCut(AliAnalysisCuts *cut){
113 //
114 // Add cut object to the cut step
115 //
116 fCuts->Add(cut);
117}
118
119//__________________________________________________________________
c2690925 120void AliHFEcutStep::SetMC(const AliMCEvent *mc){
70da6c5a 121 //
122 // Set MC information to the cuts in the cut step
123 //
bf892a6a 124 AliCFCutBase *cfc = NULL;
70da6c5a 125 for(Int_t icut = 0; icut < fCuts->GetEntriesFast(); icut++){
bf892a6a 126 if((cfc = dynamic_cast<AliCFCutBase *>(fCuts->UncheckedAt(icut)))) cfc->SetMCEventInfo(mc);
70da6c5a 127 }
128}
129
130//__________________________________________________________________
c2690925 131void AliHFEcutStep::SetRecEvent(const AliVEvent *rec){
70da6c5a 132 //
133 // Publish rec event to the cut step
134 //
bf892a6a 135 AliCFCutBase *cfc = NULL;
70da6c5a 136 for(Int_t icut = 0; icut < fCuts->GetEntriesFast(); icut++){
bf892a6a 137 if((cfc = dynamic_cast<AliCFCutBase *>(fCuts->UncheckedAt(icut)))) cfc->SetRecEventInfo(rec);
70da6c5a 138 }
139}
140