]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGDQ/dielectron/AliDielectronVarCuts.cxx
Fixed EINCLUDE
[u/mrichter/AliRoot.git] / PWGDQ / dielectron / AliDielectronVarCuts.cxx
CommitLineData
b2a297fa 1/*************************************************************************
2* Copyright(c) 1998-2009, 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///////////////////////////////////////////////////////////////////////////
17// Cut class providing cuts to all infomation //
18// available for the AliVParticle interface // //
19// //
20// Authors: //
21// Jens Wiechula <Jens.Wiechula@cern.ch> //
22/*
23
24
25
26*/
27// //
28///////////////////////////////////////////////////////////////////////////
29
30
31#include "AliDielectronVarCuts.h"
e123f993 32#include "AliDielectronMC.h"
b2a297fa 33
34ClassImp(AliDielectronVarCuts)
35
36
37AliDielectronVarCuts::AliDielectronVarCuts() :
38 AliAnalysisCuts(),
39 fNActiveCuts(0),
40 fActiveCutsMask(0),
e123f993 41 fSelectedCutsMask(0),
42 fCutOnMCtruth(kFALSE),
43 fCutType(kAll)
b2a297fa 44{
45 //
46 // Default costructor
47 //
48 for (Int_t i=0; i<AliDielectronVarManager::kNMaxValues; ++i){
49 fActiveCuts[i]=0;
50 fCutMin[i]=0;
51 fCutMax[i]=0;
572b0139 52 fCutExclude[i]=kFALSE;
b2a297fa 53 }
54}
55
56//________________________________________________________________________
57AliDielectronVarCuts::AliDielectronVarCuts(const char* name, const char* title) :
58 AliAnalysisCuts(name,title),
59 fNActiveCuts(0),
60 fActiveCutsMask(0),
e123f993 61 fSelectedCutsMask(0),
62 fCutOnMCtruth(kFALSE),
63 fCutType(kAll)
b2a297fa 64{
65 //
66 // Named contructor
67 //
68 for (Int_t i=0; i<AliDielectronVarManager::kNMaxValues; ++i){
69 fActiveCuts[i]=0;
70 fCutMin[i]=0;
71 fCutMax[i]=0;
b9d223bb 72 fCutExclude[i]=kFALSE;
b2a297fa 73 }
74}
75
76//________________________________________________________________________
77AliDielectronVarCuts::~AliDielectronVarCuts()
78{
79 //
80 // Destructor
81 //
82}
83
84//________________________________________________________________________
85Bool_t AliDielectronVarCuts::IsSelected(TObject* track)
86{
87 //
88 // Make cut decision
89 //
90
e123f993 91 //reset
b2a297fa 92 fSelectedCutsMask=0;
93 SetSelected(kFALSE);
e123f993 94
95 if (!track) return kFALSE;
96
97 //If MC cut, get MC truth
98 if (fCutOnMCtruth){
99 AliVParticle *part=static_cast<AliVParticle*>(track);
100 track=AliDielectronMC::Instance()->GetMCTrackFromMCEvent(part->GetLabel());
101 if (!track) return kFALSE;
102 }
103
104 //Fill values
105 Double_t values[AliDielectronVarManager::kNMaxValues];
106 AliDielectronVarManager::Fill(track,values);
b2a297fa 107
108 for (Int_t iCut=0; iCut<fNActiveCuts; ++iCut){
109 Int_t cut=fActiveCuts[iCut];
78091935 110 SETBIT(fSelectedCutsMask,iCut);
572b0139 111 if ( ((values[cut]<fCutMin[iCut]) || (values[cut]>fCutMax[iCut]))^fCutExclude[iCut] ) CLRBIT(fSelectedCutsMask,iCut);
b2a297fa 112 }
e123f993 113
b2a297fa 114 Bool_t isSelected=(fSelectedCutsMask==fActiveCutsMask);
e123f993 115 if ( fCutType==kAny ) isSelected=(fSelectedCutsMask>0);
b2a297fa 116 SetSelected(isSelected);
117 return isSelected;
118}
78091935 119
120//________________________________________________________________________
572b0139 121void AliDielectronVarCuts::AddCut(AliDielectronVarManager::ValueTypes type, Double_t min, Double_t max, Bool_t excludeRange)
78091935 122{
123 //
124 // Set cut range and activate it
125 //
126 if (min>max){
127 Double_t tmp=min;
128 min=max;
129 max=tmp;
130 }
e123f993 131 fCutMin[fNActiveCuts]=min;
132 fCutMax[fNActiveCuts]=max;
572b0139 133 fCutExclude[fNActiveCuts]=excludeRange;
78091935 134 SETBIT(fActiveCutsMask,fNActiveCuts);
e123f993 135 fActiveCuts[fNActiveCuts]=(UShort_t)type;
136 ++fNActiveCuts;
78091935 137}
b2a297fa 138
78091935 139//________________________________________________________________________
140void AliDielectronVarCuts::Print(const Option_t* /*option*/) const
141{
142 //
143 // Print cuts and the range
144 //
145 printf("cut ranges for '%s'\n",GetTitle());
e123f993 146 if (fCutType==kAll){
147 printf("All Cuts have to be fulfilled\n");
148 } else {
149 printf("Any Cut has to be fulfilled\n");
150 }
78091935 151 for (Int_t iCut=0; iCut<fNActiveCuts; ++iCut){
e123f993 152 Int_t cut=(Int_t)fActiveCuts[iCut];
572b0139 153 Bool_t inverse=fCutExclude[iCut];
154
155 if (!inverse){
156 printf("Cut %02d: %f < %s < %f\n", iCut,
157 fCutMin[iCut], AliDielectronVarManager::GetValueName((Int_t)cut), fCutMax[iCut]);
158 } else {
159 printf("Cut %02d: !(%f < %s < %f)\n", iCut,
160 fCutMin[iCut], AliDielectronVarManager::GetValueName((Int_t)cut), fCutMax[iCut]);
161 }
78091935 162 }
163}