]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSQASSDRefData.cxx
For Pythia with tune don't switch off MI in ConfigHeavyFlavor
[u/mrichter/AliRoot.git] / ITS / AliITSQASSDRefData.cxx
CommitLineData
905cc85c 1/**************************************************************************
2 * Copyright(c) 2009-2011, 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 $Id$
17*/
18
19//-------------------------------------------------------------------------
20// Class AliITSQASSDRefData
21// ITS SSD reference values for the QA
22//
23// Origin: Panos.Christakoglou@cern.ch, NIKHEF-Utrecht University
24//-------------------------------------------------------------------------
25
26#include <Riostream.h>
27#include <fstream>
28#include <TArray.h>
29#include <TString.h>
30#include <TObjString.h>
31#include <TObjArray.h>
32
33#include "AliLog.h"
34#include "AliITSQASSDRefData.h"
35
36ClassImp(AliITSQASSDRefData)
37
38//___________________________________________________________________________
39AliITSQASSDRefData::AliITSQASSDRefData() :
40 TObject(),
41 fRefList(0),
42 fNameList(0) {
43 //Default constructor
44}
45
46//___________________________________________________________________________
47AliITSQASSDRefData::AliITSQASSDRefData(Int_t specie) :
48 TObject(),
49 fRefList(0),
50 fNameList(0) {
51 //Default constructor
52 SetDefault(specie);
53}
54
55//___________________________________________________________________________
56AliITSQASSDRefData::AliITSQASSDRefData(const char* path) :
57 TObject(),
58 fRefList(0),
59 fNameList(0) {
60 //Constructor with the path of the ascii file as an argument
61 SetReferenceData(path);
62}
63
64//___________________________________________________________________________
65AliITSQASSDRefData::AliITSQASSDRefData(const AliITSQASSDRefData& refData):
66TObject(),
67fRefList(refData.fRefList),
68fNameList(refData.fNameList) {
69 //Copy constructor
70}
71
72//___________________________________________________________________________
73AliITSQASSDRefData& AliITSQASSDRefData::operator = (const AliITSQASSDRefData& refData) {
74 //assignment operator
75 if(&refData != this) {
76 fRefList = refData.fRefList;
77 fNameList = refData.fNameList;
78 }
79 return *this ;
80}
81
82//___________________________________________________________________________
83AliITSQASSDRefData::~AliITSQASSDRefData() {
84 //Destructor
85 if(fRefList) delete fRefList;
86 if(fNameList) delete fNameList;
87}
88
89//___________________________________________________________________________
90void AliITSQASSDRefData::AddReference(const char* name="",
91 Int_t id=-1,
92 Double_t value=0) {
93 //Adding a ref. value to the list
94 //Printf("(AliITSQASSDRefData::AddReference) Name: %s - Id: %d - Value: %lf",name,id,value);
95 if(id>-1&&id<fRefList->GetSize()) {
96 AliError(Form("Reference with id %i already exists. Choose other id or use SetReferenceValue(Int_t, Double_t) to overwrite",id));
97 return;
98 }
99
324c25b5 100 if( (strcmp(name,"")!=0) && GetID(name)!=-1) {
905cc85c 101 AliError(Form("Reference with name %s already exists. Choose other name or use SetReferenceValue(const char*, Double_t) to overwrite",name));
102 return;
103 }
104
105 if(id==-1) id=fRefList->GetSize();
106 fRefList->Set(id+1);
107 fRefList->AddAt(value,id);
108 fNameList->AddAt(new TObjString(name),id);
109}
110
111//___________________________________________________________________________
112Int_t AliITSQASSDRefData::GetID(const char* name) {
113 //Get the id of the reference value
114 Int_t status = -1;
115 TString refName = "";
116 TString stringName = name;
117 TObjString *dummyString = 0;
118 for (Int_t id=0; id<fNameList->GetEntriesFast(); id++){
119 dummyString = dynamic_cast <TObjString *>(fNameList->At(id));
120 refName = dummyString->GetString();
121 //Printf("(AliITSQASSDRefData::GetID) String name from the list: %s",refName.Data());
122 if(refName == stringName) {
123 status = id;
124 //Printf("(AliITSQASSDRefData::GetID) String name found from the list: %s - Id: %d",refName.Data(),status);
125 }
126 }
127
128 return status;
129}
130
131//___________________________________________________________________________
132Double_t AliITSQASSDRefData::GetReferenceValue(const char* name) {
133 //Returns the ref. value based on the given name
134 TString refName = "";
135 TObjString *dummyString = 0;
136 for (Int_t id=0; id<fNameList->GetEntriesFast(); id++){
137 dummyString = dynamic_cast <TObjString *>(fNameList->At(id));
138 refName = dummyString->GetString();
139
140 if(refName.Data()==name)
141 return fRefList->At(id);
142 }
143 AliError(Form("Reference name %s unknown",name));
144 return -1;
145}
146
147//___________________________________________________________________________
148Double_t AliITSQASSDRefData::GetReferenceValue(Int_t id) {
149 //Returns the ref. value based on the given id
150 if (id<0||id>fRefList->GetSize()-1){
151 AliError("Reference ID out of range");
152 return 0;
153 }
154 return fRefList->At(id);
155
156}
157
158//___________________________________________________________________________
159void AliITSQASSDRefData::PrintTable() {
160 //Prints the list of reference values
161 Printf("___ SSD REFERENCE DATA ___ ");
162 Printf("ID ----- Value ------- Name");
163 Int_t id=0;
164 TString refName = "";
165 TObjString *dummyString = 0;
166 for(id=0; id<fRefList->GetSize()-1; id++) {
167 dummyString = dynamic_cast <TObjString *>(fNameList->At(id));
168 refName = dummyString->GetString();
169 Printf("%i ------ %4.3g -------- %s",id,fRefList->At(id),refName.Data());
170
171 }
172
173}
174
175//___________________________________________________________________________
176void AliITSQASSDRefData::SetDefault(Int_t specie) {
177 //Sets the default values
178 if(!fNameList) fNameList = new TObjArray();
179 fNameList->Add(new TObjString("minSSDDataSize"));
180 fNameList->Add(new TObjString("maxSSDDataSize"));
181 fNameList->Add(new TObjString("minDDLDataSize"));
182 fNameList->Add(new TObjString("maxDDLDataSize"));
183 fNameList->Add(new TObjString("minLDCDataSize"));
184 fNameList->Add(new TObjString("maxLDCDataSize"));
185 fNameList->Add(new TObjString("minMeanDDLDataSize"));
186 fNameList->Add(new TObjString("maxMeanDDLDataSize"));
187 fNameList->Add(new TObjString("minMeanLDCDataSize"));
188 fNameList->Add(new TObjString("maxMeanLDCDataSize"));
189 fNameList->Add(new TObjString("maxOccupancy"));
190 fNameList->SetOwner(kTRUE);
191
192 //specie == 0 ==> Default
193 Double_t refValues[11] = {0,0.0,0,0,0,0,0,0,0,0};
194 //specie == 1 ==> Low multiplicity
195 if(specie == 1) {
196 refValues[0] = 0; refValues[1] = 500; refValues[2] = 0; refValues[3] = 50;
197 refValues[4] = 0; refValues[5] = 100; refValues[6] = 0; refValues[7] = 50;
198 refValues[8] = 0; refValues[9] = 100; refValues[10] = 5;
199 }
200 //specie == 2 ==> High multiplicity
201 if(specie == 2) {
202 refValues[0] = 0; refValues[1] = 500; refValues[2] = 0; refValues[3] = 50;
203 refValues[4] = 0; refValues[5] = 100; refValues[6] = 0; refValues[7] = 50;
204 refValues[8] = 0; refValues[9] = 100; refValues[10] = 5;
205 }
206 //specie == 3 ==> Cosmics
207 if(specie == 3) {
208 refValues[0] = 0; refValues[1] = 500; refValues[2] = 0; refValues[3] = 50;
209 refValues[4] = 0; refValues[5] = 100; refValues[6] = 0; refValues[7] = 50;
210 refValues[8] = 0; refValues[9] = 100; refValues[10] = 5;
211 }
212 //specie == 4 ==> Calibration
213 if(specie == 4) {
214 refValues[0] = 0; refValues[1] = 500; refValues[2] = 0; refValues[3] = 50;
215 refValues[4] = 0; refValues[5] = 100; refValues[6] = 0; refValues[7] = 50;
216 refValues[8] = 0; refValues[9] = 100; refValues[10] = 5;
217 }
218
219 if(!fRefList) fRefList = new TArrayD();
220 fRefList->Set(11,refValues);
221}
222
223//___________________________________________________________________________
224void AliITSQASSDRefData::SetReferenceData(const char* path) {
225 //Parses an ascii file with the reference values
226 if(!fRefList) fRefList = new TArrayD();
227 if(!fNameList) fNameList = new TObjArray();
228
229 ifstream file;
230 file.open(path);
231
232 if (!file) {
233 AliWarning(Form("No file found at %s",path));
234 SetDefault(0);
235 return;
236 }
237 if(file.bad()){
238 AliWarning("Reference data could not be read: Default values are used.");
239 SetDefault(0);
240 return;
241 }
242
243 fRefList->Set(0);
244 Int_t id = 0, newid = -1;
245 Double_t value = 0;
246 TString name = "";
247
248 while (!file.eof()) {
249 //file >> newid;
250 file >> name >> id >> value;
251 //Printf("Name: %s - Id: %d - Value: %lf",name.Data(),id,value);
252
253 if (newid==id) continue; //skip line if id is the same as previous
254 AddReference(name.Data(), id, value);
255 newid = id;
256 }
257
258 file.close();
259}
260
261//___________________________________________________________________________
262void AliITSQASSDRefData::SetReferenceValue(Int_t id, Double_t value) {
263 //Adding a single reference value by id
264 if(id<0||id>fRefList->GetSize()-1) {
265 AliWarning(Form("Reference ID %i out of range: value not set",id));
266 }
267 else fRefList->SetAt(value,id);
268
269}
270
271//___________________________________________________________________________
272void AliITSQASSDRefData::SetReferenceValue(const char* name, Double_t value) {
273 //Adding a single reference value by name
274 Int_t id = GetID(name);
275 //Printf("Name: %s - Id: %d",name,id);
276 if(id == -1) {
277 AliError(Form("Reference name %s unknown: value not set",name));
278 return;
279 }
280
281 fRefList->SetAt(value,id);
282}