]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnPIDWeightsMgr.cxx
Package upgrade.
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnPIDWeightsMgr.cxx
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  **************************************************************************/
15  
16 //-------------------------------------------------------------------------
17 //                      Class AliRsnPIDWeightsMgr
18 //                     -------------------
19 //           Simple collection of reconstructed tracks
20 //           selected from an ESD event
21 //           to be used for analysis.
22 //           .........................................
23 // 
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 //_____________________________________________________________________________
38 AliRsnPIDWeightsMgr::AliRsnPIDWeightsMgr() 
39 {
40 //
41 // Default and unique constructor which initializes arrays
42 //
43     Int_t i, j;
44     for (i = 0; i < kDetectors; i++) {
45         for (j = 0; j < AliRsnPID::kSpecies; j++) fWeights[i][j] = 0.0;
46         fDetPtMin[i] = 0.0;
47         fDetPtMax[i] = 1E25;
48         fUseDet[i] = kTRUE;
49     }
50 }
51
52 //_____________________________________________________________________________
53 void AliRsnPIDWeightsMgr::SetDetectorWeights(EDetector det, Double_t *weights)
54 {
55 //
56 // Copy into the array the PID weights of a detector
57 //
58
59     Int_t i;
60     if (!CheckBounds(det)) return;
61     for (i = 0; i < AliRsnPID::kSpecies; i++) fWeights[det][i] = weights[i];
62 }
63
64 //_____________________________________________________________________________
65 void AliRsnPIDWeightsMgr::SetAcceptanceRange(EDetector det, Double_t ptmin, Double_t ptmax)
66 {
67 //
68 // Sets a range in pt for which the PID weights of this detector
69 // are accepted in the global computation, in the case that one
70 // did not accept to use the global ESD pid.
71 //
72
73     if (!CheckBounds(det)) return;
74
75     // swap values if necessary
76     if (ptmin > ptmax) {
77         AliWarning("Values passed in wrong order. Swapping");
78         Double_t temp = ptmin;
79         ptmin = ptmax;
80         ptmax = temp;
81     }
82     fDetPtMin[det] = ptmin;
83     fDetPtMax[det] = ptmax;
84 }
85
86 //_____________________________________________________________________________
87 Double_t AliRsnPIDWeightsMgr::GetWeight(AliRsnPID::EType type, Double_t pt)
88 {
89 //
90 // Computes the global PID weights using the given ranges
91 //
92
93     if (type < 0 or type >= AliRsnPID::kSpecies) {
94         AliError("Index out of range");
95         return kFALSE;
96     }
97     
98     Int_t i;
99     Double_t prob = 1.0;
100     for (i = 0; i < kDetectors; i++) {
101         //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]));
102         if (!fUseDet[i]) continue;
103         if (pt < fDetPtMin[i] || pt > fDetPtMax[i]) continue;
104         prob *= fWeights[i][type];
105     }
106
107     return prob;
108 }
109
110 //_____________________________________________________________________________
111 Bool_t AliRsnPIDWeightsMgr::CheckBounds(EDetector det)
112 {
113 //
114 // Bounds checker
115 //
116     
117     if (det < 0 or det >= kDetectors) {
118         AliError("Index out of range");
119         return kFALSE;
120     }
121     
122     return kTRUE;
123 }