1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 // Container for TRD Threshold parameters stored in the OADB
18 // Author: Markus Fasel <M.Fasel@gsi.de>
21 #include <TSortedList.h>
25 #include "AliHFEOADBThresholdsTRD.h"
27 ClassImp(AliHFEOADBThresholdsTRD)
29 const Double_t AliHFEOADBThresholdsTRD::fgkVerySmall = 1e-5;
31 //____________________________________________________________
32 AliHFEOADBThresholdsTRD::AliHFEOADBThresholdsTRD():
41 //____________________________________________________________
42 AliHFEOADBThresholdsTRD::AliHFEOADBThresholdsTRD(const char *name) :
47 // Default constructor
49 fEntries = new TSortedList;
52 //____________________________________________________________
53 AliHFEOADBThresholdsTRD::~AliHFEOADBThresholdsTRD(){
60 //____________________________________________________________
61 Bool_t AliHFEOADBThresholdsTRD::GetThresholdParameters(Int_t ntracklets, Double_t efficiency, Double_t *params){
64 // Use IsEqual definition
66 AliHFEthresholdParamsTRD test(ntracklets, efficiency);
67 TObject *result = fEntries->FindObject(&test);
69 AliDebug(1, Form("No threshold params found for %d tracklets and an electron efficiency of %f", ntracklets, efficiency));
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);
78 //____________________________________________________________
79 void AliHFEOADBThresholdsTRD::SetThresholdParameters(Int_t ntracklets, Double_t efficiency, Double_t *params){
81 // Store new Params in the Object
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));
87 //____________________________________________________________
88 void AliHFEOADBThresholdsTRD::Print(Option_t *) const {
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());
101 //____________________________________________________________
102 AliHFEOADBThresholdsTRD::AliHFEthresholdParamsTRD::AliHFEthresholdParamsTRD():
108 // Default constructor
110 memset(fParams, 0, sizeof(Double_t) * 4);
113 //____________________________________________________________
114 AliHFEOADBThresholdsTRD::AliHFEthresholdParamsTRD::AliHFEthresholdParamsTRD(Int_t nTracklets, Double_t eff, Double_t *params) :
116 fNTracklets(nTracklets),
120 // Default Constructor
122 if(params) memcpy(fParams, params, sizeof(Double_t) * 4);
123 else memset(fParams, 0, sizeof(Double_t) * 4);
126 //____________________________________________________________
127 AliHFEOADBThresholdsTRD::AliHFEthresholdParamsTRD::AliHFEthresholdParamsTRD(const AliHFEthresholdParamsTRD &ref) :
129 fNTracklets(ref.fNTracklets),
130 fEfficiency(ref.fEfficiency)
135 memcpy(fParams, ref.fParams, sizeof(Double_t) * 4);
138 //____________________________________________________________
139 AliHFEOADBThresholdsTRD::AliHFEthresholdParamsTRD &AliHFEOADBThresholdsTRD::AliHFEthresholdParamsTRD::operator=(const AliHFEthresholdParamsTRD &ref){
141 // Assignment operator
144 TObject::operator=(ref);
146 fNTracklets = ref.fNTracklets;
147 fEfficiency = ref.fEfficiency;
148 memcpy(fParams, ref.fParams, sizeof(Double_t) * 4);
153 //____________________________________________________________
154 Int_t AliHFEOADBThresholdsTRD::AliHFEthresholdParamsTRD::Compare(const TObject *ref) const{
156 // Compares two objects
158 // First compare number of tracklets, if they are equal compare electron efficiency
160 const AliHFEthresholdParamsTRD *refObj = static_cast<const AliHFEthresholdParamsTRD *>(ref);
161 if(fNTracklets < refObj->GetNTracklets()) return -1;
162 else if(fNTracklets > refObj->GetNTracklets()) return 1;
164 if(fEfficiency < refObj->GetElectronEfficiency()) return -1;
165 else if(fEfficiency > refObj->GetElectronEfficiency()) return 1;
170 //____________________________________________________________
171 Bool_t AliHFEOADBThresholdsTRD::AliHFEthresholdParamsTRD::IsEqual(const TObject *ref) const {
173 // Check for equality
174 // Tracklets and Efficiency are used
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;