]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGHF/hfe/AliHFEOADBThresholdsTRD.cxx
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / PWGHF / hfe / AliHFEOADBThresholdsTRD.cxx
CommitLineData
8c1c76e9 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// Container for TRD Threshold parameters stored in the OADB
17//
18// Author: Markus Fasel <M.Fasel@gsi.de>
19//
20#include <TMath.h>
21#include <TSortedList.h>
22
23#include "AliLog.h"
24
25#include "AliHFEOADBThresholdsTRD.h"
26
27ClassImp(AliHFEOADBThresholdsTRD)
28
29const Double_t AliHFEOADBThresholdsTRD::fgkVerySmall = 1e-5;
30
31//____________________________________________________________
32AliHFEOADBThresholdsTRD::AliHFEOADBThresholdsTRD():
33 TNamed(),
34 fEntries(NULL)
35{
36 //
37 // Dummy constructor
38 //
39}
40
41//____________________________________________________________
42AliHFEOADBThresholdsTRD::AliHFEOADBThresholdsTRD(const char *name) :
43 TNamed(name, ""),
44 fEntries(NULL)
45{
46 //
47 // Default constructor
48 //
49 fEntries = new TSortedList;
50}
51
52//____________________________________________________________
53AliHFEOADBThresholdsTRD::~AliHFEOADBThresholdsTRD(){
54 //
55 // Destructor
56 //
57 delete fEntries;
58}
59
60//____________________________________________________________
61Bool_t AliHFEOADBThresholdsTRD::GetThresholdParameters(Int_t ntracklets, Double_t efficiency, Double_t *params){
62 //
63 // Retrieve params
64 // Use IsEqual definition
65 //
66 AliHFEthresholdParamsTRD test(ntracklets, efficiency);
67 TObject *result = fEntries->FindObject(&test);
68 if(!result){
69 AliDebug(1, Form("No threshold params found for %d tracklets and an electron efficiency of %f", ntracklets, efficiency));
70 return kFALSE;
71 }
72 AliHFEthresholdParamsTRD *parResult = static_cast<AliHFEthresholdParamsTRD *>(result);
73 AliDebug(1, Form("Threshold params found: NTracklets %d, Electron Efficiency %f", parResult->GetNTracklets(), parResult->GetElectronEfficiency()));
74 memcpy(params, parResult->GetThresholdParams(), sizeof(Double_t) * 4);
75 return kTRUE;
76}
77
78//____________________________________________________________
79void AliHFEOADBThresholdsTRD::SetThresholdParameters(Int_t ntracklets, Double_t efficiency, Double_t *params){
80 //
81 // Store new Params in the Object
82 //
83 AliDebug(1, Form("Save Parameters for %d tracklets at and electron efficiency of %f", ntracklets, efficiency));
84 fEntries->Add(new AliHFEthresholdParamsTRD(ntracklets, efficiency, params));
85}
86
87//____________________________________________________________
88void AliHFEOADBThresholdsTRD::Print(Option_t *) const {
89 //
90 // Print thresholds
91 //
92 printf("Available thresholds:\n");
93 printf("_________________________________________\n");
94 TIter objects(fEntries);
95 AliHFEthresholdParamsTRD *par;
96 while((par = dynamic_cast<AliHFEthresholdParamsTRD *>(objects()))){
97 printf("Number of tracklets %d, Electron efficiency %f\n", par->GetNTracklets(), par->GetElectronEfficiency());
98 }
99}
100
101//____________________________________________________________
102AliHFEOADBThresholdsTRD::AliHFEthresholdParamsTRD::AliHFEthresholdParamsTRD():
103 TObject(),
104 fNTracklets(0),
105 fEfficiency(0.)
106{
107 //
108 // Default constructor
109 //
110 memset(fParams, 0, sizeof(Double_t) * 4);
111}
112
113//____________________________________________________________
114AliHFEOADBThresholdsTRD::AliHFEthresholdParamsTRD::AliHFEthresholdParamsTRD(Int_t nTracklets, Double_t eff, Double_t *params) :
115 TObject(),
116 fNTracklets(nTracklets),
117 fEfficiency(eff)
118{
119 //
120 // Default Constructor
121 //
122 if(params) memcpy(fParams, params, sizeof(Double_t) * 4);
123 else memset(fParams, 0, sizeof(Double_t) * 4);
124}
125
126//____________________________________________________________
127AliHFEOADBThresholdsTRD::AliHFEthresholdParamsTRD::AliHFEthresholdParamsTRD(const AliHFEthresholdParamsTRD &ref) :
128 TObject(ref),
129 fNTracklets(ref.fNTracklets),
130 fEfficiency(ref.fEfficiency)
131{
132 //
133 // Copy constructor
134 //
135 memcpy(fParams, ref.fParams, sizeof(Double_t) * 4);
136}
137
138//____________________________________________________________
139AliHFEOADBThresholdsTRD::AliHFEthresholdParamsTRD &AliHFEOADBThresholdsTRD::AliHFEthresholdParamsTRD::operator=(const AliHFEthresholdParamsTRD &ref){
140 //
141 // Assignment operator
142 //
aa1417ee 143 if(this != &ref){
144 TObject::operator=(ref);
8c1c76e9 145
aa1417ee 146 fNTracklets = ref.fNTracklets;
147 fEfficiency = ref.fEfficiency;
148 memcpy(fParams, ref.fParams, sizeof(Double_t) * 4);
149 }
8c1c76e9 150 return *this;
151}
152
153//____________________________________________________________
154Int_t AliHFEOADBThresholdsTRD::AliHFEthresholdParamsTRD::Compare(const TObject *ref) const{
155 //
156 // Compares two objects
157 // Order:
158 // First compare number of tracklets, if they are equal compare electron efficiency
159 //
160 const AliHFEthresholdParamsTRD *refObj = static_cast<const AliHFEthresholdParamsTRD *>(ref);
161 if(fNTracklets < refObj->GetNTracklets()) return -1;
162 else if(fNTracklets > refObj->GetNTracklets()) return 1;
163 else{
164 if(fEfficiency < refObj->GetElectronEfficiency()) return -1;
165 else if(fEfficiency > refObj->GetElectronEfficiency()) return 1;
166 else return 0;
167 }
168}
169
170//____________________________________________________________
171Bool_t AliHFEOADBThresholdsTRD::AliHFEthresholdParamsTRD::IsEqual(const TObject *ref) const {
172 //
173 // Check for equality
174 // Tracklets and Efficiency are used
175 //
176 const AliHFEthresholdParamsTRD *refObj = dynamic_cast<const AliHFEthresholdParamsTRD *>(ref);
177 if(!refObj) return kFALSE;
178 return fNTracklets == refObj->GetNTracklets() && TMath::Abs(fEfficiency - refObj->GetElectronEfficiency()) < fgkVerySmall;
179}