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"
37 ClassImp(AliITSQASSDRefData)
39 //___________________________________________________________________________
40 AliITSQASSDRefData::AliITSQASSDRefData() :
47 //___________________________________________________________________________
48 AliITSQASSDRefData::AliITSQASSDRefData(Int_t specie) :
56 //___________________________________________________________________________
57 AliITSQASSDRefData::AliITSQASSDRefData(const char* path) :
61 //Constructor with the path of the ascii file as an argument
62 SetReferenceData(path);
65 //___________________________________________________________________________
66 AliITSQASSDRefData::AliITSQASSDRefData(const AliITSQASSDRefData& refData):
68 fRefList(refData.fRefList),
69 fNameList(refData.fNameList) {
73 //___________________________________________________________________________
74 AliITSQASSDRefData& AliITSQASSDRefData::operator = (const AliITSQASSDRefData& refData) {
76 if(&refData != this) {
77 fRefList = refData.fRefList;
78 fNameList = refData.fNameList;
83 //___________________________________________________________________________
84 AliITSQASSDRefData::~AliITSQASSDRefData() {
86 if(fRefList) delete fRefList;
87 if(fNameList) delete fNameList;
90 //___________________________________________________________________________
91 void AliITSQASSDRefData::AddReference(const char* name="",
94 //Adding a ref. value to the list
95 //Printf("(AliITSQASSDRefData::AddReference) Name: %s - Id: %d - Value: %lf",name,id,value);
96 if(id>-1&&id<fRefList->GetSize()) {
97 AliError(Form("Reference with id %i already exists. Choose other id or use SetReferenceValue(Int_t, Double_t) to overwrite",id));
101 if( (strcmp(name,"")!=0) && GetID(name)!=-1) {
102 AliError(Form("Reference with name %s already exists. Choose other name or use SetReferenceValue(const char*, Double_t) to overwrite",name));
106 if(id==-1) id=fRefList->GetSize();
108 fRefList->AddAt(value,id);
109 fNameList->AddAt(new TObjString(name),id);
112 //___________________________________________________________________________
113 Int_t AliITSQASSDRefData::GetID(const char* name) {
114 //Get the id of the reference value
116 TString refName = "";
117 TString stringName = name;
118 TObjString *dummyString = 0;
119 for (Int_t id=0; id<fNameList->GetEntriesFast(); id++){
120 dummyString = static_cast <TObjString *>(fNameList->At(id));
121 refName = dummyString->GetString();
122 if(refName == stringName) {
130 //___________________________________________________________________________
131 Double_t AliITSQASSDRefData::GetReferenceValue(const char* name) {
132 //Returns the ref. value based on the given name
133 TString refName = "";
134 TObjString *dummyString = 0;
135 for (Int_t id=0; id<fNameList->GetEntriesFast(); id++){
136 dummyString = static_cast <TObjString *>(fNameList->At(id));
137 refName = dummyString->GetString();
139 if(refName.Data()==name) return fRefList->At(id);
141 AliError(Form("Reference name %s unknown",name));
145 //___________________________________________________________________________
146 Double_t AliITSQASSDRefData::GetReferenceValue(Int_t id) {
147 //Returns the ref. value based on the given id
148 if (id<0||id>fRefList->GetSize()-1){
149 AliError("Reference ID out of range");
152 return fRefList->At(id);
156 //___________________________________________________________________________
157 void AliITSQASSDRefData::PrintTable() {
158 //Prints the list of reference values
159 Printf("___ SSD REFERENCE DATA ___ ");
160 Printf("ID ----- Value ------- Name");
162 TString refName = "";
163 TObjString *dummyString = 0;
164 for(id=0; id<fRefList->GetSize()-1; id++) {
165 dummyString = static_cast <TObjString *>(fNameList->At(id));
166 refName = dummyString->GetString();
167 Printf("%i ------ %4.3g -------- %s",id,fRefList->At(id),refName.Data());
173 //___________________________________________________________________________
174 void AliITSQASSDRefData::SetDefault(Int_t specie) {
175 //Sets the default values
176 if(!fNameList) fNameList = new TObjArray();
177 fNameList->Add(new TObjString("minSSDDataSize"));
178 fNameList->Add(new TObjString("maxSSDDataSize"));
179 fNameList->Add(new TObjString("minDDLDataSize"));
180 fNameList->Add(new TObjString("maxDDLDataSize"));
181 fNameList->Add(new TObjString("minLDCDataSize"));
182 fNameList->Add(new TObjString("maxLDCDataSize"));
183 fNameList->Add(new TObjString("minMeanDDLDataSize"));
184 fNameList->Add(new TObjString("maxMeanDDLDataSize"));
185 fNameList->Add(new TObjString("minMeanLDCDataSize"));
186 fNameList->Add(new TObjString("maxMeanLDCDataSize"));
187 fNameList->Add(new TObjString("maxOccupancy"));
188 fNameList->SetOwner(kTRUE);
190 //specie == 0 ==> Default
191 Double_t refValues[11] = {0,0.0,0,0,0,0,0,0,0,0};
192 //specie == 1 ==> Low multiplicity
194 refValues[0] = 0; refValues[1] = 500; refValues[2] = 0; refValues[3] = 50;
195 refValues[4] = 0; refValues[5] = 100; refValues[6] = 0; refValues[7] = 50;
196 refValues[8] = 0; refValues[9] = 100; refValues[10] = 5;
198 //specie == 2 ==> High multiplicity
200 refValues[0] = 0; refValues[1] = 500; refValues[2] = 0; refValues[3] = 50;
201 refValues[4] = 0; refValues[5] = 100; refValues[6] = 0; refValues[7] = 50;
202 refValues[8] = 0; refValues[9] = 100; refValues[10] = 5;
204 //specie == 3 ==> Cosmics
206 refValues[0] = 0; refValues[1] = 500; refValues[2] = 0; refValues[3] = 50;
207 refValues[4] = 0; refValues[5] = 100; refValues[6] = 0; refValues[7] = 50;
208 refValues[8] = 0; refValues[9] = 100; refValues[10] = 5;
210 //specie == 4 ==> Calibration
212 refValues[0] = 0; refValues[1] = 500; refValues[2] = 0; refValues[3] = 50;
213 refValues[4] = 0; refValues[5] = 100; refValues[6] = 0; refValues[7] = 50;
214 refValues[8] = 0; refValues[9] = 100; refValues[10] = 5;
217 if(!fRefList) fRefList = new TArrayD();
218 fRefList->Set(11,refValues);
221 //___________________________________________________________________________
222 void AliITSQASSDRefData::SetReferenceData(const char* path) {
223 //Parses an ascii file with the reference values
224 if(!fRefList) fRefList = new TArrayD();
225 if(!fNameList) fNameList = new TObjArray();
231 AliWarning(Form("No file found at %s",path));
236 AliWarning("Reference data could not be read: Default values are used.");
242 Int_t id = 0, newid = -1;
246 while (!file.eof()) {
248 file >> name >> id >> value;
249 //Printf("Name: %s - Id: %d - Value: %lf",name.Data(),id,value);
251 if (newid==id) continue; //skip line if id is the same as previous
252 AddReference(name.Data(), id, value);
259 //___________________________________________________________________________
260 void AliITSQASSDRefData::SetReferenceValue(Int_t id, Double_t value) {
261 //Adding a single reference value by id
262 if(id<0||id>fRefList->GetSize()-1) {
263 AliWarning(Form("Reference ID %i out of range: value not set",id));
265 else fRefList->SetAt(value,id);
269 //___________________________________________________________________________
270 void AliITSQASSDRefData::SetReferenceValue(const char* name, Double_t value) {
271 //Adding a single reference value by name
272 Int_t id = GetID(name);
273 //Printf("Name: %s - Id: %d",name,id);
275 AliError(Form("Reference name %s unknown: value not set",name));
279 fRefList->SetAt(value,id);