]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGDQ/dielectron/AliDielectronVarCuts.cxx
Change Mult binning scheme
[u/mrichter/AliRoot.git] / PWGDQ / dielectron / AliDielectronVarCuts.cxx
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"
32 #include "AliDielectronMC.h"
33
34 ClassImp(AliDielectronVarCuts)
35
36
37 AliDielectronVarCuts::AliDielectronVarCuts() :
38   AliAnalysisCuts(),
39   fNActiveCuts(0),
40   fActiveCutsMask(0),
41   fSelectedCutsMask(0),
42   fCutOnMCtruth(kFALSE),
43   fCutType(kAll)
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;
52     fCutExclude[i]=kFALSE;
53   }
54 }
55
56 //________________________________________________________________________
57 AliDielectronVarCuts::AliDielectronVarCuts(const char* name, const char* title) :
58   AliAnalysisCuts(name,title),
59   fNActiveCuts(0),
60   fActiveCutsMask(0),
61   fSelectedCutsMask(0),
62   fCutOnMCtruth(kFALSE),
63   fCutType(kAll)
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     fCutExclude[i]=kFALSE;
73   }
74 }
75
76 //________________________________________________________________________
77 AliDielectronVarCuts::~AliDielectronVarCuts()
78 {
79   //
80   // Destructor
81   //
82 }
83
84 //________________________________________________________________________
85 Bool_t AliDielectronVarCuts::IsSelected(TObject* track)
86 {
87   //
88   // Make cut decision
89   //
90
91   //reset
92   fSelectedCutsMask=0;
93   SetSelected(kFALSE);
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);
107   
108   for (Int_t iCut=0; iCut<fNActiveCuts; ++iCut){
109     Int_t cut=fActiveCuts[iCut];
110     SETBIT(fSelectedCutsMask,iCut);
111     if ( ((values[cut]<fCutMin[iCut]) || (values[cut]>fCutMax[iCut]))^fCutExclude[iCut] ) CLRBIT(fSelectedCutsMask,iCut);
112     if ( fCutType==kAll && !TESTBIT(fSelectedCutsMask,iCut) ) return kFALSE; // option to (minor) speed improvement
113   }
114   
115   Bool_t isSelected=(fSelectedCutsMask==fActiveCutsMask);
116   if ( fCutType==kAny ) isSelected=(fSelectedCutsMask>0);
117   SetSelected(isSelected);
118   return isSelected;
119 }
120
121 //________________________________________________________________________
122 void AliDielectronVarCuts::AddCut(AliDielectronVarManager::ValueTypes type, Double_t min, Double_t max, Bool_t excludeRange)
123 {
124   //
125   // Set cut range and activate it
126   //
127   if (min>max){
128     Double_t tmp=min;
129     min=max;
130     max=tmp;
131   }
132   fCutMin[fNActiveCuts]=min;
133   fCutMax[fNActiveCuts]=max;
134   fCutExclude[fNActiveCuts]=excludeRange;
135   SETBIT(fActiveCutsMask,fNActiveCuts);
136   fActiveCuts[fNActiveCuts]=(UShort_t)type;
137   ++fNActiveCuts;
138 }
139
140 //________________________________________________________________________
141 void AliDielectronVarCuts::Print(const Option_t* /*option*/) const
142 {
143   //
144   // Print cuts and the range
145   //
146   printf("cut ranges for '%s'\n",GetTitle());
147   if (fCutType==kAll){
148     printf("All Cuts have to be fulfilled\n");
149   } else {
150     printf("Any Cut has to be fulfilled\n");
151   }
152   for (Int_t iCut=0; iCut<fNActiveCuts; ++iCut){
153     Int_t cut=(Int_t)fActiveCuts[iCut];
154     Bool_t inverse=fCutExclude[iCut];
155
156     if (!inverse){
157       printf("Cut %02d: %f < %s < %f\n", iCut,
158              fCutMin[iCut], AliDielectronVarManager::GetValueName((Int_t)cut), fCutMax[iCut]);
159     } else {
160       printf("Cut %02d: !(%f < %s < %f)\n", iCut,
161              fCutMin[iCut], AliDielectronVarManager::GetValueName((Int_t)cut), fCutMax[iCut]);
162     }
163   }
164 }