]>
Commit | Line | Data |
---|---|---|
06351446 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, 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 | **************************************************************************/ | |
aec0ec32 | 15 | |
06351446 | 16 | //------------------------------------------------------------------------- |
17 | // Class AliRsnPIDWeightsMgr | |
18 | // ------------------- | |
19 | // Simple collection of reconstructed tracks | |
20 | // selected from an ESD event | |
21 | // to be used for analysis. | |
22 | // ......................................... | |
aec0ec32 | 23 | // |
06351446 | 24 | // author: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it) |
25 | //------------------------------------------------------------------------- | |
26 | ||
27 | #include <TMath.h> | |
28 | #include <TString.h> | |
29 | #include <TClonesArray.h> | |
30 | #include <TDatabasePDG.h> | |
31 | ||
32 | #include "AliLog.h" | |
33 | #include "AliRsnPIDWeightsMgr.h" | |
34 | ||
35 | ClassImp(AliRsnPIDWeightsMgr) | |
36 | ||
37 | //_____________________________________________________________________________ | |
aec0ec32 | 38 | AliRsnPIDWeightsMgr::AliRsnPIDWeightsMgr() |
06351446 | 39 | { |
40 | // | |
41 | // Default and unique constructor which initializes arrays | |
42 | // | |
aec0ec32 | 43 | Int_t i, j; |
44 | for (i = 0; i < kDetectors; i++) | |
45 | { | |
46 | for (j = 0; j < AliRsnPID::kSpecies; j++) fWeights[i][j] = 0.0; | |
47 | fDetPtMin[i] = 0.0; | |
48 | fDetPtMax[i] = 1E25; | |
49 | fUseDet[i] = kTRUE; | |
50 | } | |
06351446 | 51 | } |
52 | ||
53 | //_____________________________________________________________________________ | |
54 | void AliRsnPIDWeightsMgr::SetDetectorWeights(EDetector det, Double_t *weights) | |
55 | { | |
56 | // | |
57 | // Copy into the array the PID weights of a detector | |
58 | // | |
59 | ||
aec0ec32 | 60 | Int_t i; |
61 | if (!CheckBounds(det)) return; | |
62 | for (i = 0; i < AliRsnPID::kSpecies; i++) fWeights[det][i] = weights[i]; | |
06351446 | 63 | } |
64 | ||
65 | //_____________________________________________________________________________ | |
66 | void AliRsnPIDWeightsMgr::SetAcceptanceRange(EDetector det, Double_t ptmin, Double_t ptmax) | |
67 | { | |
68 | // | |
69 | // Sets a range in pt for which the PID weights of this detector | |
70 | // are accepted in the global computation, in the case that one | |
71 | // did not accept to use the global ESD pid. | |
72 | // | |
73 | ||
aec0ec32 | 74 | if (!CheckBounds(det)) return; |
75 | ||
76 | // swap values if necessary | |
77 | if (ptmin > ptmax) | |
78 | { | |
79 | AliWarning("Values passed in wrong order. Swapping"); | |
80 | Double_t temp = ptmin; | |
81 | ptmin = ptmax; | |
82 | ptmax = temp; | |
83 | } | |
84 | fDetPtMin[det] = ptmin; | |
85 | fDetPtMax[det] = ptmax; | |
06351446 | 86 | } |
87 | ||
88 | //_____________________________________________________________________________ | |
89 | Double_t AliRsnPIDWeightsMgr::GetWeight(AliRsnPID::EType type, Double_t pt) | |
90 | { | |
91 | // | |
92 | // Computes the global PID weights using the given ranges | |
93 | // | |
94 | ||
aec0ec32 | 95 | if (type < 0 or type >= AliRsnPID::kSpecies) |
96 | { | |
97 | AliError("Index out of range"); | |
98 | return kFALSE; | |
99 | } | |
100 | ||
101 | Int_t i; | |
102 | Double_t prob = 1.0; | |
103 | for (i = 0; i < kDetectors; i++) | |
104 | { | |
105 | //AliInfo(Form("weights[%d] = %f %f %f %f %f", i, fWeights[i][0], fWeights[i][1], fWeights[i][2], fWeights[i][3], fWeights[i][4], fWeights[i][5])); | |
106 | if (!fUseDet[i]) continue; | |
107 | if (pt < fDetPtMin[i] || pt > fDetPtMax[i]) continue; | |
108 | prob *= fWeights[i][type]; | |
109 | } | |
110 | ||
111 | return prob; | |
06351446 | 112 | } |
113 | ||
114 | //_____________________________________________________________________________ | |
115 | Bool_t AliRsnPIDWeightsMgr::CheckBounds(EDetector det) | |
116 | { | |
117 | // | |
118 | // Bounds checker | |
119 | // | |
aec0ec32 | 120 | |
121 | if (det < 0 or det >= kDetectors) | |
122 | { | |
123 | AliError("Index out of range"); | |
124 | return kFALSE; | |
125 | } | |
126 | ||
127 | return kTRUE; | |
06351446 | 128 | } |