1 /**************************************************************************
2 * Copyright(c) 2009-2011, 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 **************************************************************************/
19 //-------------------------------------------------------------------------
20 // Class AliITSQASSDRefData
21 // ITS SSD reference values for the QA
23 // Origin: Panos.Christakoglou@cern.ch, NIKHEF-Utrecht University
24 //-------------------------------------------------------------------------
26 #include <Riostream.h>
30 #include <TObjString.h>
31 #include <TObjArray.h>
34 #include "AliITSQASSDRefData.h"
36 ClassImp(AliITSQASSDRefData)
38 //___________________________________________________________________________
39 AliITSQASSDRefData::AliITSQASSDRefData() :
46 //___________________________________________________________________________
47 AliITSQASSDRefData::AliITSQASSDRefData(Int_t specie) :
55 //___________________________________________________________________________
56 AliITSQASSDRefData::AliITSQASSDRefData(const char* path) :
60 //Constructor with the path of the ascii file as an argument
61 SetReferenceData(path);
64 //___________________________________________________________________________
65 AliITSQASSDRefData::AliITSQASSDRefData(const AliITSQASSDRefData& refData):
67 fRefList(refData.fRefList),
68 fNameList(refData.fNameList) {
72 //___________________________________________________________________________
73 AliITSQASSDRefData& AliITSQASSDRefData::operator = (const AliITSQASSDRefData& refData) {
75 if(&refData != this) {
76 fRefList = refData.fRefList;
77 fNameList = refData.fNameList;
82 //___________________________________________________________________________
83 AliITSQASSDRefData::~AliITSQASSDRefData() {
85 if(fRefList) delete fRefList;
86 if(fNameList) delete fNameList;
89 //___________________________________________________________________________
90 void AliITSQASSDRefData::AddReference(const char* name="",
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));
100 if( (strcmp(name,"")!=0) && GetID(name)!=-1) {
101 AliError(Form("Reference with name %s already exists. Choose other name or use SetReferenceValue(const char*, Double_t) to overwrite",name));
105 if(id==-1) id=fRefList->GetSize();
107 fRefList->AddAt(value,id);
108 fNameList->AddAt(new TObjString(name),id);
111 //___________________________________________________________________________
112 Int_t AliITSQASSDRefData::GetID(const char* name) {
113 //Get the id of the reference value
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) {
124 //Printf("(AliITSQASSDRefData::GetID) String name found from the list: %s - Id: %d",refName.Data(),status);
131 //___________________________________________________________________________
132 Double_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();
140 if(refName.Data()==name)
141 return fRefList->At(id);
143 AliError(Form("Reference name %s unknown",name));
147 //___________________________________________________________________________
148 Double_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");
154 return fRefList->At(id);
158 //___________________________________________________________________________
159 void AliITSQASSDRefData::PrintTable() {
160 //Prints the list of reference values
161 Printf("___ SSD REFERENCE DATA ___ ");
162 Printf("ID ----- Value ------- Name");
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());
175 //___________________________________________________________________________
176 void 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);
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
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;
200 //specie == 2 ==> High multiplicity
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;
206 //specie == 3 ==> Cosmics
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;
212 //specie == 4 ==> Calibration
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;
219 if(!fRefList) fRefList = new TArrayD();
220 fRefList->Set(11,refValues);
223 //___________________________________________________________________________
224 void 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();
233 AliWarning(Form("No file found at %s",path));
238 AliWarning("Reference data could not be read: Default values are used.");
244 Int_t id = 0, newid = -1;
248 while (!file.eof()) {
250 file >> name >> id >> value;
251 //Printf("Name: %s - Id: %d - Value: %lf",name.Data(),id,value);
253 if (newid==id) continue; //skip line if id is the same as previous
254 AddReference(name.Data(), id, value);
261 //___________________________________________________________________________
262 void 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));
267 else fRefList->SetAt(value,id);
271 //___________________________________________________________________________
272 void 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);
277 AliError(Form("Reference name %s unknown: value not set",name));
281 fRefList->SetAt(value,id);