]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnCutPIDNSigma.cxx
Added the possibility to use a manually set up TPC BB definition
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnCutPIDNSigma.cxx
1 //
2 // Class AliRsnCutPIDNSigma
3 //
4 // General implementation of a single cut strategy, which can be:
5 // - a value contained in a given interval  [--> IsBetween()   ]
6 // - a value equal to a given reference     [--> MatchesValue()]
7 //
8 // In all cases, the reference value(s) is (are) given as data members
9 // and each kind of cut requires a given value type (Int, UInt, Double),
10 // but the cut check procedure is then automatized and chosen thanks to
11 // an enumeration of the implemented cut types.
12 // At the end, the user (or any other point which uses this object) has
13 // to use the method IsSelected() to check if this cut has been passed.
14 //
15 // authors: Martin Vala (martin.vala@cern.ch)
16 //          Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
17 //
18
19 #include "AliPIDResponse.h"
20 #include "AliAnalysisManager.h"
21 #include "AliInputEventHandler.h"
22 #include "AliMultiInputEventHandler.h"
23
24 #include "AliRsnCutPIDNSigma.h"
25
26 ClassImp(AliRsnCutPIDNSigma)
27
28 //_________________________________________________________________________________________________
29 AliRsnCutPIDNSigma::AliRsnCutPIDNSigma() : 
30    AliRsnCut("cut", AliRsnTarget::kDaughter),
31    fSpecies(AliPID::kUnknown),
32    fDetector(kDetectors),
33    fRejectUnmatched(kFALSE),
34    fMomMin(0.0),
35    fMomMax(1E20),
36    fNSigma(1E20)
37 {
38 //
39 // Main constructor.
40 //
41 }
42
43 //_________________________________________________________________________________________________
44 AliRsnCutPIDNSigma::AliRsnCutPIDNSigma
45 (const char *name, AliPID::EParticleType species, EDetector det, Double_t nsigma) :
46    AliRsnCut(name, AliRsnTarget::kDaughter),
47    fSpecies(species),
48    fDetector(det),
49    fRejectUnmatched(kFALSE),
50    fMomMin(0.0),
51    fMomMax(1E20),
52    fNSigma(nsigma)
53 {
54 //
55 // Main constructor.
56 //
57 }
58
59 //_________________________________________________________________________________________________
60 AliRsnCutPIDNSigma::AliRsnCutPIDNSigma
61 (const AliRsnCutPIDNSigma& copy) :
62    AliRsnCut(copy),
63    fSpecies(copy.fSpecies),
64    fDetector(copy.fDetector),
65    fRejectUnmatched(copy.fRejectUnmatched),
66    fMomMin(copy.fMomMin),
67    fMomMax(copy.fMomMax),
68    fNSigma(copy.fNSigma)
69 {
70 //
71 // Copy constructor.
72 //
73 }
74
75 //_________________________________________________________________________________________________
76 AliRsnCutPIDNSigma& AliRsnCutPIDNSigma::operator=(const AliRsnCutPIDNSigma& copy)
77 {
78 //
79 // Assignment operator
80 //
81
82    AliRsnCut::operator=(copy);
83
84    fSpecies = copy.fSpecies;
85    fDetector = copy.fDetector;
86    fRejectUnmatched = copy.fRejectUnmatched;
87    fMomMin = copy.fMomMin;
88    fMomMax = copy.fMomMax;
89    fNSigma = copy.fNSigma;
90
91    return (*this);
92 }
93
94 //_________________________________________________________________________________________________
95 Bool_t AliRsnCutPIDNSigma::IsSelected(TObject *object)
96 {
97 //
98 // Cut checker.
99 //
100
101    // coherence check
102    if (!TargetOK(object)) return kFALSE;
103    
104    // check initialization of PID object
105    AliPIDResponse *pid = fEvent->GetPIDResponse();
106    if (!pid) {
107       AliFatal("NULL PID response");
108       return kFALSE;
109    }
110
111    // get reference momentum, for range cut
112    Double_t momentum = -1.0;
113    AliVTrack *vtrack = fDaughter->Ref2Vtrack();
114    if (!vtrack) {
115       AliDebugClass(2, "Referenced daughter is not a track");
116       return kFALSE;
117    }
118    if (fDetector == kTPC)
119       momentum = vtrack->GetTPCmomentum();
120    else
121       momentum = vtrack->P();
122       
123    // check momentum range
124    if (momentum < fMomMin || momentum > fMomMax) {
125       AliDebugClass(2, Form("Track momentum = %.5f, outside allowed range [%.2f - %.2f]", momentum, fMomMin, fMomMax));
126       return kFALSE;
127    }
128    
129    // check PID
130    Bool_t matched;
131    Double_t nsigma;
132    switch (fDetector) {
133       case kITS:
134          matched = IsITS(vtrack);
135          nsigma  = pid->NumberOfSigmasITS(vtrack, fSpecies);
136          break;
137       case kTPC:
138          matched = IsTPC(vtrack);
139          nsigma  = pid->NumberOfSigmasTPC(vtrack, fSpecies);
140          break;
141       case kTOF:
142          matched = IsTOF(vtrack);
143          nsigma  = pid->NumberOfSigmasTOF(vtrack, fSpecies);
144          break;
145       default:
146          AliError("Bad detector chosen. Rejecting track");
147          return kFALSE;
148    }
149    
150    // determine cut result
151    if (fRejectUnmatched && (matched == kFALSE)) {
152       AliDebugClass(2, "Required to reject unmatched traks, and this track is not matched in the detector");
153       return kFALSE;
154    } else {
155       AliDebugClass(2, Form("Nsigma = %.5f, maximum allowed = %.2f", nsigma, fNSigma));
156       if (TMath::Abs(nsigma) <= fNSigma) {
157          AliDebugClass(2, "Track accepted");
158          return kTRUE;
159       } else {
160          AliDebugClass(2, "Track rejected");
161          return kFALSE;
162       }
163    }
164 }
165
166 //_________________________________________________________________________________________________
167 void AliRsnCutPIDNSigma::Print(const Option_t *) const
168 {
169 //
170 // Print information on this cut
171 //
172
173    Char_t mom[200], det[100], match[200];
174       
175    if (fRejectUnmatched)
176       snprintf(match, 200, "Unmatched tracks are rejected");
177    else
178       snprintf(match, 200, "No check on track matching");
179       
180    switch (fDetector) {
181       case kITS: snprintf(det, 3, "ITS"); break;
182       case kTPC: snprintf(det, 3, "TPC"); break;
183       case kTOF: snprintf(det, 3, "TOF"); break;
184       default  : snprintf(det, 3, "undefined");
185    }
186
187    AliInfo(Form("Cut name          : %s", GetName()));
188    AliInfo(Form("--> PID detector  : %s", det));
189    AliInfo(Form("--> match criteria: %s", match));
190    AliInfo(Form("--> momentum range: %s", mom));   
191 }