]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG3/dielectron/AliDielectronVarCuts.cxx
Major dielectron framework update; includes "alignment" to updates in
[u/mrichter/AliRoot.git] / PWG3 / 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;
72 }
73}
74
75//________________________________________________________________________
76AliDielectronVarCuts::~AliDielectronVarCuts()
77{
78 //
79 // Destructor
80 //
81}
82
83//________________________________________________________________________
84Bool_t AliDielectronVarCuts::IsSelected(TObject* track)
85{
86 //
87 // Make cut decision
88 //
89
e123f993 90 //reset
b2a297fa 91 fSelectedCutsMask=0;
92 SetSelected(kFALSE);
e123f993 93
94 if (!track) return kFALSE;
95
96 //If MC cut, get MC truth
97 if (fCutOnMCtruth){
98 AliVParticle *part=static_cast<AliVParticle*>(track);
99 track=AliDielectronMC::Instance()->GetMCTrackFromMCEvent(part->GetLabel());
100 if (!track) return kFALSE;
101 }
102
103 //Fill values
104 Double_t values[AliDielectronVarManager::kNMaxValues];
105 AliDielectronVarManager::Fill(track,values);
b2a297fa 106
107 for (Int_t iCut=0; iCut<fNActiveCuts; ++iCut){
108 Int_t cut=fActiveCuts[iCut];
78091935 109 SETBIT(fSelectedCutsMask,iCut);
572b0139 110 if ( ((values[cut]<fCutMin[iCut]) || (values[cut]>fCutMax[iCut]))^fCutExclude[iCut] ) CLRBIT(fSelectedCutsMask,iCut);
b2a297fa 111 }
e123f993 112
b2a297fa 113 Bool_t isSelected=(fSelectedCutsMask==fActiveCutsMask);
e123f993 114 if ( fCutType==kAny ) isSelected=(fSelectedCutsMask>0);
b2a297fa 115 SetSelected(isSelected);
116 return isSelected;
117}
78091935 118
119//________________________________________________________________________
572b0139 120void AliDielectronVarCuts::AddCut(AliDielectronVarManager::ValueTypes type, Double_t min, Double_t max, Bool_t excludeRange)
78091935 121{
122 //
123 // Set cut range and activate it
124 //
125 if (min>max){
126 Double_t tmp=min;
127 min=max;
128 max=tmp;
129 }
e123f993 130 fCutMin[fNActiveCuts]=min;
131 fCutMax[fNActiveCuts]=max;
572b0139 132 fCutExclude[fNActiveCuts]=excludeRange;
78091935 133 SETBIT(fActiveCutsMask,fNActiveCuts);
e123f993 134 fActiveCuts[fNActiveCuts]=(UShort_t)type;
135 ++fNActiveCuts;
78091935 136}
b2a297fa 137
78091935 138//________________________________________________________________________
139void AliDielectronVarCuts::Print(const Option_t* /*option*/) const
140{
141 //
142 // Print cuts and the range
143 //
144 printf("cut ranges for '%s'\n",GetTitle());
e123f993 145 if (fCutType==kAll){
146 printf("All Cuts have to be fulfilled\n");
147 } else {
148 printf("Any Cut has to be fulfilled\n");
149 }
78091935 150 for (Int_t iCut=0; iCut<fNActiveCuts; ++iCut){
e123f993 151 Int_t cut=(Int_t)fActiveCuts[iCut];
572b0139 152 Bool_t inverse=fCutExclude[iCut];
153
154 if (!inverse){
155 printf("Cut %02d: %f < %s < %f\n", iCut,
156 fCutMin[iCut], AliDielectronVarManager::GetValueName((Int_t)cut), fCutMax[iCut]);
157 } else {
158 printf("Cut %02d: !(%f < %s < %f)\n", iCut,
159 fCutMin[iCut], AliDielectronVarManager::GetValueName((Int_t)cut), fCutMax[iCut]);
160 }
78091935 161 }
162}