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 = static_cast <TObjString *>(fNameList->At(id));
120 refName = dummyString->GetString();
121 if(refName == stringName) {
129 //___________________________________________________________________________
130 Double_t AliITSQASSDRefData::GetReferenceValue(const char* name) {
131 //Returns the ref. value based on the given name
132 TString refName = "";
133 TObjString *dummyString = 0;
134 for (Int_t id=0; id<fNameList->GetEntriesFast(); id++){
135 dummyString = static_cast <TObjString *>(fNameList->At(id));
136 refName = dummyString->GetString();
138 if(refName.Data()==name) return fRefList->At(id);
140 AliError(Form("Reference name %s unknown",name));
144 //___________________________________________________________________________
145 Double_t AliITSQASSDRefData::GetReferenceValue(Int_t id) {
146 //Returns the ref. value based on the given id
147 if (id<0||id>fRefList->GetSize()-1){
148 AliError("Reference ID out of range");
151 return fRefList->At(id);
155 //___________________________________________________________________________
156 void AliITSQASSDRefData::PrintTable() {
157 //Prints the list of reference values
158 Printf("___ SSD REFERENCE DATA ___ ");
159 Printf("ID ----- Value ------- Name");
161 TString refName = "";
162 TObjString *dummyString = 0;
163 for(id=0; id<fRefList->GetSize()-1; id++) {
164 dummyString = static_cast <TObjString *>(fNameList->At(id));
165 refName = dummyString->GetString();
166 Printf("%i ------ %4.3g -------- %s",id,fRefList->At(id),refName.Data());
172 //___________________________________________________________________________
173 void AliITSQASSDRefData::SetDefault(Int_t specie) {
174 //Sets the default values
175 if(!fNameList) fNameList = new TObjArray();
176 fNameList->Add(new TObjString("minSSDDataSize"));
177 fNameList->Add(new TObjString("maxSSDDataSize"));
178 fNameList->Add(new TObjString("minDDLDataSize"));
179 fNameList->Add(new TObjString("maxDDLDataSize"));
180 fNameList->Add(new TObjString("minLDCDataSize"));
181 fNameList->Add(new TObjString("maxLDCDataSize"));
182 fNameList->Add(new TObjString("minMeanDDLDataSize"));
183 fNameList->Add(new TObjString("maxMeanDDLDataSize"));
184 fNameList->Add(new TObjString("minMeanLDCDataSize"));
185 fNameList->Add(new TObjString("maxMeanLDCDataSize"));
186 fNameList->Add(new TObjString("maxOccupancy"));
187 fNameList->SetOwner(kTRUE);
189 //specie == 0 ==> Default
190 Double_t refValues[11] = {0,0.0,0,0,0,0,0,0,0,0};
191 //specie == 1 ==> Low multiplicity
193 refValues[0] = 0; refValues[1] = 500; refValues[2] = 0; refValues[3] = 50;
194 refValues[4] = 0; refValues[5] = 100; refValues[6] = 0; refValues[7] = 50;
195 refValues[8] = 0; refValues[9] = 100; refValues[10] = 5;
197 //specie == 2 ==> High multiplicity
199 refValues[0] = 0; refValues[1] = 500; refValues[2] = 0; refValues[3] = 50;
200 refValues[4] = 0; refValues[5] = 100; refValues[6] = 0; refValues[7] = 50;
201 refValues[8] = 0; refValues[9] = 100; refValues[10] = 5;
203 //specie == 3 ==> Cosmics
205 refValues[0] = 0; refValues[1] = 500; refValues[2] = 0; refValues[3] = 50;
206 refValues[4] = 0; refValues[5] = 100; refValues[6] = 0; refValues[7] = 50;
207 refValues[8] = 0; refValues[9] = 100; refValues[10] = 5;
209 //specie == 4 ==> Calibration
211 refValues[0] = 0; refValues[1] = 500; refValues[2] = 0; refValues[3] = 50;
212 refValues[4] = 0; refValues[5] = 100; refValues[6] = 0; refValues[7] = 50;
213 refValues[8] = 0; refValues[9] = 100; refValues[10] = 5;
216 if(!fRefList) fRefList = new TArrayD();
217 fRefList->Set(11,refValues);
220 //___________________________________________________________________________
221 void AliITSQASSDRefData::SetReferenceData(const char* path) {
222 //Parses an ascii file with the reference values
223 if(!fRefList) fRefList = new TArrayD();
224 if(!fNameList) fNameList = new TObjArray();
230 AliWarning(Form("No file found at %s",path));
235 AliWarning("Reference data could not be read: Default values are used.");
241 Int_t id = 0, newid = -1;
245 while (!file.eof()) {
247 file >> name >> id >> value;
248 //Printf("Name: %s - Id: %d - Value: %lf",name.Data(),id,value);
250 if (newid==id) continue; //skip line if id is the same as previous
251 AddReference(name.Data(), id, value);
258 //___________________________________________________________________________
259 void AliITSQASSDRefData::SetReferenceValue(Int_t id, Double_t value) {
260 //Adding a single reference value by id
261 if(id<0||id>fRefList->GetSize()-1) {
262 AliWarning(Form("Reference ID %i out of range: value not set",id));
264 else fRefList->SetAt(value,id);
268 //___________________________________________________________________________
269 void AliITSQASSDRefData::SetReferenceValue(const char* name, Double_t value) {
270 //Adding a single reference value by name
271 Int_t id = GetID(name);
272 //Printf("Name: %s - Id: %d",name,id);
274 AliError(Form("Reference name %s unknown: value not set",name));
278 fRefList->SetAt(value,id);