]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGDQ/dielectron/AliDielectronVarCuts.cxx
including add task macro and link/builder changes for libPWGGAEMCALTask
[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   }
113   
114   Bool_t isSelected=(fSelectedCutsMask==fActiveCutsMask);
115   if ( fCutType==kAny ) isSelected=(fSelectedCutsMask>0);
116   SetSelected(isSelected);
117   return isSelected;
118 }
119
120 //________________________________________________________________________
121 void AliDielectronVarCuts::AddCut(AliDielectronVarManager::ValueTypes type, Double_t min, Double_t max, Bool_t excludeRange)
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   }
131   fCutMin[fNActiveCuts]=min;
132   fCutMax[fNActiveCuts]=max;
133   fCutExclude[fNActiveCuts]=excludeRange;
134   SETBIT(fActiveCutsMask,fNActiveCuts);
135   fActiveCuts[fNActiveCuts]=(UShort_t)type;
136   ++fNActiveCuts;
137 }
138
139 //________________________________________________________________________
140 void AliDielectronVarCuts::Print(const Option_t* /*option*/) const
141 {
142   //
143   // Print cuts and the range
144   //
145   printf("cut ranges for '%s'\n",GetTitle());
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   }
151   for (Int_t iCut=0; iCut<fNActiveCuts; ++iCut){
152     Int_t cut=(Int_t)fActiveCuts[iCut];
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     }
162   }
163 }