]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG3/hfe/AliHFEcutStep.cxx
Some more clang warnings corrected
[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 // 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
31 ClassImp(AliHFEcutStep)
32
33 //__________________________________________________________________
34 AliHFEcutStep::AliHFEcutStep(const Char_t *name):
35   TNamed(name, ""),
36   fCuts(NULL)
37 {
38   //
39   // Default Constructor
40   //
41   fCuts = new TObjArray;
42 }
43
44 //__________________________________________________________________
45 AliHFEcutStep::AliHFEcutStep(const AliHFEcutStep &o):
46   TNamed(o),
47   fCuts(NULL)
48 {
49   //
50   // Copy constructor
51   //
52   o.Copy(*this);
53 }
54
55 //__________________________________________________________________
56 AliHFEcutStep &AliHFEcutStep::operator=(const AliHFEcutStep &o){
57   //
58   // Assignment operator
59   //
60   if(this != &o)
61     o.Copy(*this);
62   return *this;
63 }
64  
65 //__________________________________________________________________
66 AliHFEcutStep::~AliHFEcutStep(){
67   //
68   // destructor
69   //
70   delete fCuts;
71 }
72
73 //__________________________________________________________________
74 void 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 //__________________________________________________________________
86 Bool_t AliHFEcutStep::IsSelected(TObject *o){
87   //
88   // Filter tracks in the given cut step
89   // Apply all cut objects
90   //
91   AliDebug(1, Form("Cut Step %s: Number of cut objects: %d", GetName(), fCuts->GetEntriesFast()));
92   if(!fCuts->GetEntriesFast()) return kTRUE;
93   Bool_t isSelected = kTRUE;
94   AliAnalysisCuts *cuts = NULL;
95   for(Int_t iCut = 0; iCut < fCuts->GetEntriesFast(); iCut++){
96     cuts = dynamic_cast<AliAnalysisCuts *>(fCuts->UncheckedAt(iCut));
97     if(cuts && (!cuts->IsSelected(o))) isSelected = kFALSE;
98   }
99   AliDebug(1, Form("Accepted: %s", isSelected ? "yes" : "no"));
100   return isSelected;
101
102
103 //__________________________________________________________________
104 AliAnalysisCuts *AliHFEcutStep::GetCut(const Char_t *cutName){
105   //
106   // return cut object
107   //
108   return dynamic_cast<AliAnalysisCuts *>(fCuts->FindObject(cutName));
109 }
110
111 //__________________________________________________________________
112 void AliHFEcutStep::AddCut(AliAnalysisCuts *cut){
113   //
114   // Add cut object to the cut step
115   //
116   fCuts->Add(cut);
117 }
118
119 //__________________________________________________________________
120 void AliHFEcutStep::SetMC(const AliMCEvent *mc){
121   //
122   // Set MC information to the cuts in the cut step
123   //
124   AliCFCutBase *cfc = NULL;
125   for(Int_t icut = 0; icut < fCuts->GetEntriesFast(); icut++){
126     if((cfc = dynamic_cast<AliCFCutBase *>(fCuts->UncheckedAt(icut)))) cfc->SetMCEventInfo(mc);
127   }
128 }
129
130 //__________________________________________________________________
131 void AliHFEcutStep::SetRecEvent(const AliVEvent *rec){
132   //
133   // Publish rec event to the cut step
134   //
135   AliCFCutBase *cfc = NULL;
136   for(Int_t icut = 0; icut < fCuts->GetEntriesFast(); icut++){
137     if((cfc = dynamic_cast<AliCFCutBase *>(fCuts->UncheckedAt(icut)))) cfc->SetRecEventInfo(rec);
138   }
139 }
140