]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnCutPIDNSigma.cxx
Implementation of all needed changes in the package in order to speed-up the executio...
[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 (const char *name, AliPID::EParticleType species, EDetector det, Double_t nsigma) :
31    AliRsnCut(name, AliRsnCut::kDaughter, -nsigma, nsigma),
32    fSpecies(species),
33    fDetector(det),
34    fMomMin(0.0),
35    fMomMax(0.0),
36    fRejectOutside(kFALSE),
37    fRejectUnmatched(kFALSE)
38 {
39 //
40 // Main constructor.
41 //
42 }
43
44 //_________________________________________________________________________________________________
45 AliRsnCutPIDNSigma::AliRsnCutPIDNSigma
46 (const AliRsnCutPIDNSigma& copy) :
47    AliRsnCut(copy),
48    fSpecies(copy.fSpecies),
49    fDetector(copy.fDetector),
50    fMomMin(copy.fMomMin),
51    fMomMax(copy.fMomMax),
52    fRejectOutside(copy.fRejectOutside),
53    fRejectUnmatched(copy.fRejectUnmatched)
54 {
55 //
56 // Copy constructor.
57 //
58 }
59
60 //_________________________________________________________________________________________________
61 AliRsnCutPIDNSigma& AliRsnCutPIDNSigma::operator=(const AliRsnCutPIDNSigma& copy)
62 {
63 //
64 // Assignment operator
65 //
66
67    AliRsnCut::operator=(copy);
68
69    fSpecies = copy.fSpecies;
70    fDetector = copy.fDetector;
71    fMomMin = copy.fMomMin;
72    fMomMax = copy.fMomMax;
73    fRejectOutside = copy.fRejectOutside;
74    fRejectUnmatched = copy.fRejectUnmatched;
75
76    return (*this);
77 }
78
79 //_________________________________________________________________________________________________
80 Bool_t AliRsnCutPIDNSigma::IsSelected(TObject *object)
81 {
82 //
83 // Cut checker.
84 //
85
86    // coherence check
87    if (!TargetOK(object)) return kFALSE;
88    
89    // check initialization of PID object
90    AliPIDResponse *pid = fEvent->GetPIDResponse();
91    if (!pid) {
92       AliFatal("NULL PID response");
93       return kFALSE;
94    }
95
96    // get reference momentum, for range cut
97    Double_t momentum = -1.0;
98    if (!fDaughter->GetRefVtrack()) {
99       AliDebugClass(2, "Referenced daughter is not a track");
100       return kFALSE;
101    }
102    if (fDetector == kTPC)
103       momentum = fDaughter->GetRefVtrack()->GetTPCmomentum();
104    else
105       momentum = fDaughter->GetRef()->P();
106       
107    // check momentum range, if required
108    if (fRejectOutside) {
109       if (momentum < fMomMin || momentum > fMomMax) {
110          AliDebugClass(2, Form("Track momentum = %.5f, outside allowed range [%.2f - %.2f]", momentum, fMomMin, fMomMax));
111          return kFALSE;
112       }
113    }
114    
115    // matching check, if required
116    if (fRejectUnmatched) {
117       switch (fDetector) {
118          case kITS:
119             if (!IsITS()) {
120                AliDebug(3, "Rejecting track not matched in ITS");
121                return kFALSE;
122             }
123             break;
124          case kTPC:
125             if (!IsTPC()) {
126                AliDebug(3, "Rejecting track not matched in TPC");
127                return kFALSE;
128             }
129             break;
130          case kTOF:
131             if (!IsTOF()) {
132                AliDebug(3, "Rejecting track not matched in TOF");
133                return kFALSE;
134             }
135             break;
136          default:
137             AliWarning("Required to reject unmatched tracks, but no detector defined. Track rejected");
138             return kFALSE;
139       }
140    }
141    
142    // check PID
143    // the number of sigmas is set as cut value, which is then checked
144    // using the basic functions available in AliRsnCut
145    switch (fDetector) {
146       case kITS:
147          fCutValueD = pid->NumberOfSigmasITS(fDaughter->GetRef(), fSpecies);
148          break;
149       case kTPC:
150          fCutValueD = pid->NumberOfSigmasTPC(fDaughter->GetRef(), fSpecies);
151          break;
152       case kTOF:
153          fCutValueD = pid->NumberOfSigmasTOF(fDaughter->GetRef(), fSpecies);
154          break;
155       default:
156          fCutValueD = 1E20;
157          return kFALSE;
158    }
159    
160    return OkRangeD();
161 }
162
163 //_________________________________________________________________________________________________
164 void AliRsnCutPIDNSigma::Print(const Option_t *) const
165 {
166 //
167 // Print information on this cut
168 //
169
170    Char_t mom[100], det[10], match[100];
171    
172    if (fRejectOutside)
173       sprintf(mom, "Tracks are accepted only in the momentum range %.2f --> %.2f", fMomMin, fMomMax);
174    else
175       sprintf(mom, "No check in momentum range");
176       
177    if (fRejectUnmatched)
178       sprintf(match, "Unmatched tracks are rejected");
179    else
180       sprintf(match, "No check on track matching");
181       
182    switch (fDetector) {
183       case kITS: sprintf(det, "ITS"); break;
184       case kTPC: sprintf(det, "TPC"); break;
185       case kTOF: sprintf(det, "TOF"); break;
186       default  : sprintf(det, "undefined");
187    }
188
189    AliInfo(Form("Cut name          : %s", GetName()));
190    AliInfo(Form("--> PID detector  : %s", det));
191    AliInfo(Form("--> match criteria: %s", match));
192    AliInfo(Form("--> momentum range: %s", mom));   
193 }