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