]>
Commit | Line | Data |
---|---|---|
ba030c0e | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, 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 | // Authors: David Guez, Ivana Hrivnacova, Marion MacCormick; IPN Orsay | |
19 | // | |
20 | // Class AliMUONSt1Response | |
21 | // ---------------------------- | |
22 | // Response class for station 1 including electronics and detector response. | |
23 | // Individual pedestals or noise levels can be controlled separately. | |
24 | // The current pulse height responses do not contain any physics | |
5f1df83a | 25 | // Included in AliRoot 2003/01/28 |
ba030c0e | 26 | |
ba030c0e | 27 | #include <TMath.h> |
28 | #include <TRandom.h> | |
29 | #include <TSystem.h> | |
74d70ece | 30 | #include <Riostream.h> |
3c25381f | 31 | |
5f91c9e8 | 32 | #include "AliMpIntPair.h" |
33 | #include "AliMpPlaneSegmentation.h" | |
34 | #include "AliMpPad.h" | |
35 | #include "AliMpMotifMap.h" | |
36 | #include "AliMpSector.h" | |
37 | #include "AliMpPlane.h" | |
38 | #include "AliMpZone.h" | |
39 | #include "AliMpSubZone.h" | |
40 | #include "AliMpVRowSegment.h" | |
3c25381f | 41 | |
ba030c0e | 42 | #include "AliMUONSt1Response.h" |
43 | #include "AliMUONSt1ResponseParameter.h" | |
44 | #include "AliMUONSt1ResponseRule.h" | |
45 | #include "AliMUONSt1IniReader.h" | |
46 | #include "AliMUONSt1Decoder.h" | |
47 | #include "AliMUONTransientDigit.h" | |
8c343c7c | 48 | #include "AliLog.h" |
ba030c0e | 49 | |
925e6570 | 50 | ClassImp(AliMUONSt1Response) |
ba030c0e | 51 | |
74d70ece | 52 | const TString AliMUONSt1Response::fgkTopDir = getenv("ALICE_ROOT"); |
53 | const TString AliMUONSt1Response::fgkDataDir = "/MUON/data/"; | |
ba030c0e | 54 | const TString AliMUONSt1Response::fgkConfigBaseName = "configChamber"; |
55 | const TString AliMUONSt1Response::fgkStandardIniFileName = "st1StdParameter.ini"; | |
56 | ||
57 | const TString AliMUONSt1Response::fgkBaseName ="base"; | |
58 | const TString AliMUONSt1Response::fgkIncludeName ="include"; | |
59 | const TString AliMUONSt1Response::fgkParameterName ="parameter"; | |
60 | const TString AliMUONSt1Response::fgkRegionName ="region"; | |
61 | const TString AliMUONSt1Response::fgkRuleName ="rule"; | |
62 | const TString AliMUONSt1Response::fgkNameName ="name"; | |
63 | const TString AliMUONSt1Response::fgkPedestalName ="pedestal"; | |
64 | const TString AliMUONSt1Response::fgkNoiseName ="noise"; | |
65 | const TString AliMUONSt1Response::fgkStateName ="state"; | |
66 | const TString AliMUONSt1Response::fgkMName ="padM"; | |
67 | const TString AliMUONSt1Response::fgkMGName ="padMG"; | |
68 | const TString AliMUONSt1Response::fgkMGCName ="padMGC"; | |
69 | const TString AliMUONSt1Response::fgkIJName ="padIJ"; | |
70 | const TString AliMUONSt1Response::fgkXYName ="padXY"; | |
71 | const TString AliMUONSt1Response::fgkZoneName ="zone"; | |
72 | const TString AliMUONSt1Response::fgkStickyOnName ="stickyOn"; | |
73 | const TString AliMUONSt1Response::fgkStickyOffName ="stickyOff"; | |
74 | const TString AliMUONSt1Response::fgkFileName ="file"; | |
75 | const TString AliMUONSt1Response::fgkValueName ="value"; | |
76 | const TString AliMUONSt1Response::fgkGausName ="gaus"; | |
77 | const TString AliMUONSt1Response::fgkNotName ="no"; | |
78 | const TString AliMUONSt1Response::fgkNofSigmaName ="nofSigma"; | |
79 | ||
80 | ||
81 | ||
82 | //__________________________________________________________________________ | |
83 | AliMUONSt1Response::AliMUONSt1Response(Int_t chamber) | |
3c25381f | 84 | : AliMUONResponseV0(), |
85 | fCountNofCalls(0), | |
86 | fCountUnknownZone(0), | |
87 | fCountUnknownIndices(0), | |
88 | fChamber(chamber), | |
89 | fParams(), | |
90 | fRegions(), | |
91 | fTrashList() | |
ba030c0e | 92 | |
93 | { | |
3c25381f | 94 | // Standard constructor |
95 | ||
ba030c0e | 96 | // default pedestal value |
97 | fCountNofCalls=0; | |
98 | fCountUnknownZone=0; | |
99 | fCountUnknownIndices=0; | |
100 | ||
101 | Int_t i; | |
102 | for (i=0;i<2;i++){ | |
103 | fIniFileName[i]=""; | |
104 | fPlane[0]=0; | |
105 | fPlaneSegmentation[i]=0; | |
106 | for (Int_t j=0;j<fgkNofZones;j++) | |
107 | { | |
108 | fDefaultParameters[i][j]=0; | |
109 | } | |
110 | } | |
111 | fTrashList.SetOwner(kTRUE); | |
112 | } | |
113 | ||
114 | ||
3c25381f | 115 | //__________________________________________________________________________ |
116 | AliMUONSt1Response::AliMUONSt1Response(const AliMUONSt1Response& rhs) | |
117 | : AliMUONResponseV0(rhs) | |
118 | { | |
119 | // Copy constructor | |
120 | ||
8c343c7c | 121 | AliFatal("Copy constructor is not implemented."); |
3c25381f | 122 | } |
123 | ||
ba030c0e | 124 | //__________________________________________________________________________ |
125 | AliMUONSt1Response::~AliMUONSt1Response() | |
126 | { | |
127 | //destructor | |
128 | Int_t i; | |
129 | for (i=0;i<2;i++){ | |
130 | if (fPlaneSegmentation[i]) delete fPlaneSegmentation[i]; | |
131 | if (fPlane[i]) delete fPlane[i]; | |
132 | fTrashList.Delete(); | |
133 | } | |
134 | } | |
135 | ||
3c25381f | 136 | // |
137 | // operators | |
138 | // | |
139 | ||
140 | //______________________________________________________________________________ | |
141 | AliMUONSt1Response& | |
142 | AliMUONSt1Response::operator=(const AliMUONSt1Response& rhs) | |
143 | { | |
144 | // Copy operator | |
145 | ||
146 | // check assignement to self | |
147 | if (this == &rhs) return *this; | |
148 | ||
8c343c7c | 149 | AliFatal("Assignment operator is not implemented."); |
3c25381f | 150 | |
151 | return *this; | |
152 | } | |
153 | ||
ba030c0e | 154 | //__________________________________________________________________________ |
155 | void AliMUONSt1Response::SetIniFileName(Int_t plane,const TString& fileName) | |
156 | { | |
157 | // Set the file to be read for the response parameters | |
158 | if ((plane>=0) && (plane<=1)) fIniFileName[plane] = fileName; | |
159 | } | |
160 | ||
161 | ||
162 | //__________________________________________________________________________ | |
79637e23 | 163 | void AliMUONSt1Response::ReadCouplesOfIntRanges(const string& value, |
164 | TList* list, | |
165 | AliMUONSt1ElectronicElement::TDescription descr) | |
ba030c0e | 166 | { |
167 | // Decode couplets of integer ranges (enclosed within parenthesis and | |
168 | // separated by a comma, eg. (12/20,33/60) for ranges 12 to 20 and 33 to 60) | |
169 | // and save these ranges in <list> | |
79637e23 | 170 | |
171 | StringVector lstCpl = decoder::SplitNtuples(value); | |
172 | for (UInt_t n=0;n<lstCpl.size();n++){ // for each (..,..) couplet | |
173 | StringVector lst = decoder::SplitList(lstCpl[n],","); | |
ba030c0e | 174 | // should have 2 elements |
175 | if (lst.size() != 2) { | |
8c343c7c | 176 | AliWarning("Bad pad definition"); |
ba030c0e | 177 | continue; |
178 | } | |
79637e23 | 179 | IntPairVector lst1 = decoder::DecodeListOfIntRanges(lst[0],";"); |
180 | IntPairVector lst2 = decoder::DecodeListOfIntRanges(lst[1],";"); | |
181 | for (UInt_t u1=0;u1<lst1.size();u1++){ | |
182 | for (UInt_t u2=0;u2<lst2.size();u2++){ | |
ba030c0e | 183 | AliMUONSt1ElectronicElement* elem |
184 | = new AliMUONSt1ElectronicElement(descr); | |
185 | fTrashList.Add(elem); | |
186 | elem->SetRange(0,lst1[u1].first,lst1[u1].second); | |
187 | elem->SetRange(1,lst2[u2].first,lst2[u2].second); | |
188 | list->Add(elem); | |
189 | } | |
190 | } | |
191 | } | |
192 | } | |
193 | ||
194 | ||
195 | //__________________________________________________________________________ | |
79637e23 | 196 | void AliMUONSt1Response::ReadCouplesOfFloatRanges(const string& value, |
197 | TList* list) | |
ba030c0e | 198 | { |
199 | // Decode couplets of floating point ranges (enclosed within parenthesis and | |
200 | // separated by a comma, eg. (12./20.,33./60.) for ranges 12. to 20. and 33. to 60.) | |
201 | // and save these ranges in <list> | |
79637e23 | 202 | |
203 | StringVector lstCpl = decoder::SplitNtuples(value); | |
204 | for (UInt_t n=0;n<lstCpl.size();n++){ // for each (..,..) couplets | |
205 | StringVector lst = decoder::SplitList(lstCpl[n],","); | |
ba030c0e | 206 | // should have 2 elements |
207 | if (lst.size() != 2) { | |
8c343c7c | 208 | AliWarning("Bad pad definition"); |
ba030c0e | 209 | continue; |
210 | } | |
79637e23 | 211 | DoublePairVector lst1 = decoder::DecodeListOfFloatRanges(lst[0],";"); |
212 | DoublePairVector lst2 = decoder::DecodeListOfFloatRanges(lst[1],";"); | |
213 | for (UInt_t u1=0;u1<lst1.size();u1++){ | |
214 | for (UInt_t u2=0;u2<lst2.size();u2++){ | |
ba030c0e | 215 | AliMUONSt1ElectronicElement* elem |
216 | = new AliMUONSt1ElectronicElement(AliMUONSt1ElectronicElement::kXY); | |
217 | fTrashList.Add(elem); | |
218 | elem->SetRange(0,lst1[u1].first,lst1[u1].second); | |
219 | elem->SetRange(1,lst2[u2].first,lst2[u2].second); | |
220 | list->Add(elem); | |
221 | } | |
222 | } | |
223 | } | |
224 | } | |
225 | ||
226 | ||
227 | //__________________________________________________________________________ | |
79637e23 | 228 | void AliMUONSt1Response::SetPairToParam(const string& name, const string& value, |
229 | AliMUONSt1ResponseParameter* param) const | |
ba030c0e | 230 | { |
231 | // set a (name,value) pair to <param> | |
79637e23 | 232 | |
74d70ece | 233 | TString path = fgkTopDir + fgkDataDir ; |
ba030c0e | 234 | const char* nm = name.c_str(); |
235 | if (fgkStateName.CompareTo(nm,TString::kIgnoreCase)==0){ | |
236 | param->SetState(atoi(value.c_str())); | |
237 | } else if (fgkPedestalName.CompareTo(nm,TString::kIgnoreCase)==0){ | |
79637e23 | 238 | StringVector lst = decoder::SplitList(value," "); |
ba030c0e | 239 | if ((lst.size()>0) && (fgkNotName.CompareTo(lst[0].c_str(),TString::kIgnoreCase)==0)){ |
240 | param->UnSetPedestal(); | |
241 | } else if ((lst.size()>1) && (fgkValueName.CompareTo(lst[0].c_str(),TString::kIgnoreCase)==0)){ | |
242 | param->SetPedestal(atof(lst[1].c_str())); | |
243 | } else if ((lst.size()>1) && (fgkFileName.CompareTo(lst[0].c_str(),TString::kIgnoreCase)==0)){ | |
244 | param->SetPedestal(path+lst[1].c_str()); | |
245 | } else if ((lst.size()>2) && (fgkGausName.CompareTo(lst[0].c_str(),TString::kIgnoreCase)==0)){ | |
246 | param->SetPedestal(atof(lst[1].c_str()),atof(lst[2].c_str())); | |
247 | } | |
248 | } else if (fgkNoiseName.CompareTo(nm,TString::kIgnoreCase)==0){ | |
79637e23 | 249 | StringVector lst = decoder::SplitList(value," "); |
ba030c0e | 250 | if ((lst.size()>1) && (fgkValueName.CompareTo(lst[0].c_str(),TString::kIgnoreCase)==0)){ |
251 | param->SetNoise(atof(lst[1].c_str())); | |
252 | } else if ((lst.size()>1) && (fgkFileName.CompareTo(lst[0].c_str(),TString::kIgnoreCase)==0)){ | |
253 | param->SetNoise(path+lst[1].c_str()); | |
254 | } else if ((lst.size()>2) && (fgkGausName.CompareTo(lst[0].c_str(),TString::kIgnoreCase)==0)){ | |
255 | param->SetNoise(atof(lst[1].c_str()),atof(lst[2].c_str())); | |
256 | } | |
257 | } else if (fgkNofSigmaName.CompareTo(nm,TString::kIgnoreCase)==0){ | |
258 | param->SetNofSigma(atoi(value.c_str())); | |
259 | } else if (fgkStickyOnName.CompareTo(nm,TString::kIgnoreCase)==0){ | |
79637e23 | 260 | IntPairVector lst = decoder::DecodeListOfIntRanges(value); |
261 | for (UInt_t i=0;i<lst.size();i++){ | |
262 | for (Int_t j=lst[i].first;(j<12) && (j<=lst[i].second);j++){ | |
ba030c0e | 263 | param->SetStickyBitOn(j); |
264 | } | |
265 | } | |
266 | } else if (fgkStickyOffName.CompareTo(nm,TString::kIgnoreCase)==0){ | |
79637e23 | 267 | IntPairVector lst = decoder::DecodeListOfIntRanges(value); |
268 | for (UInt_t i=0;i<lst.size();i++){ | |
269 | for (Int_t j=lst[i].first;(j<12) && (j<=lst[i].second);j++){ | |
ba030c0e | 270 | param->SetStickyBitOff(j); |
271 | } | |
272 | } | |
273 | } | |
274 | } | |
275 | ||
276 | ||
277 | //__________________________________________________________________________ | |
79637e23 | 278 | void AliMUONSt1Response::SetPairToListElem(const string& name, |
279 | const string& value, TList* list) | |
ba030c0e | 280 | { |
281 | // set a (name,value) pair to <list> | |
79637e23 | 282 | |
ba030c0e | 283 | const char* nm = name.c_str(); |
284 | if (fgkIJName.CompareTo(nm,TString::kIgnoreCase)==0){ | |
285 | ReadCouplesOfIntRanges(value,list,AliMUONSt1ElectronicElement::kIJ); | |
286 | } else if (fgkMGCName.CompareTo(nm,TString::kIgnoreCase)==0){ | |
287 | ReadCouplesOfIntRanges(value,list,AliMUONSt1ElectronicElement::kMGC); | |
288 | } else if (fgkMGName.CompareTo(nm,TString::kIgnoreCase)==0){ | |
289 | ReadCouplesOfIntRanges(value,list,AliMUONSt1ElectronicElement::kMG); | |
290 | } else if (fgkMName.CompareTo(nm,TString::kIgnoreCase)==0){ | |
79637e23 | 291 | IntPairVector lst = decoder::DecodeListOfIntRanges(value); |
292 | for (UInt_t i=0;i<lst.size();i++){ | |
ba030c0e | 293 | AliMUONSt1ElectronicElement* elem |
294 | = new AliMUONSt1ElectronicElement(AliMUONSt1ElectronicElement::kM); | |
295 | fTrashList.Add(elem); | |
296 | elem->SetRange(0,lst[i].first,lst[i].second); | |
297 | list->Add(elem); | |
298 | } | |
299 | } else if (fgkXYName.CompareTo(nm,TString::kIgnoreCase)==0){ | |
300 | ReadCouplesOfFloatRanges(value,list); | |
301 | } | |
302 | } | |
303 | ||
304 | ||
305 | //__________________________________________________________________________ | |
306 | void AliMUONSt1Response::ReadIniFile(Int_t plane) | |
307 | { | |
308 | //Read the ini file and fill the <plane>th structures | |
79637e23 | 309 | |
74d70ece | 310 | TString path = fgkTopDir + fgkDataDir ; |
ba030c0e | 311 | //read .ini file |
312 | if (gSystem->AccessPathName(path+fIniFileName[plane],kReadPermission)){ | |
8c343c7c | 313 | AliFatal(Form("Unable to Read the file %s",fIniFileName[plane].Data())); |
ba030c0e | 314 | return; |
315 | } | |
316 | fRegions.clear(); | |
317 | fParams.clear(); | |
318 | ReadIniFile(plane,path+fIniFileName[plane],kTRUE,kTRUE,kTRUE); | |
319 | } | |
320 | ||
321 | ||
322 | //__________________________________________________________________________ | |
323 | void AliMUONSt1Response::ReadIniFile(Int_t plane,const TString& fileName, | |
79637e23 | 324 | Bool_t rdParam,Bool_t rdRegion,Bool_t rdRule) |
ba030c0e | 325 | { |
326 | //Read the given ini file and fill the <plane>th structures | |
79637e23 | 327 | |
ba030c0e | 328 | cout<<"Reading parameter file "<<fileName<<endl; |
329 | AliMUONSt1IniReader iniFile(fileName.Data()); | |
79637e23 | 330 | AliMUONSt1IniReader::Chapter chap; |
331 | AliMUONSt1IniReader::ValueList vals; | |
332 | AliMUONSt1IniReader::ValueList::iterator itValue; | |
ba030c0e | 333 | while (!iniFile.Eof()){ |
334 | chap = iniFile.MakeCurrentChapter(); | |
335 | TString chapName = chap.first.c_str(); | |
336 | vals = chap.second; | |
337 | if (fgkBaseName.CompareTo(chapName,TString::kIgnoreCase)==0){ | |
338 | for (itValue = vals.begin() ; itValue != vals.end(); ++itValue){ | |
339 | string name = (*itValue).first; | |
340 | string value = (*itValue).second; | |
341 | if (fgkIncludeName.CompareTo(name.c_str(),TString::kIgnoreCase)==0){ | |
79637e23 | 342 | StringVector lst = decoder::SplitList(value,":"); |
ba030c0e | 343 | if (lst.size()>0){ |
344 | TString inFileName = TString(gSystem->DirName(fileName))+"/" + lst[0].c_str(); | |
345 | Bool_t inParam=kFALSE,inRegion=kFALSE,inRule=kFALSE; | |
346 | if (lst.size()>1) { | |
79637e23 | 347 | StringVector lst2 = decoder::SplitList(lst[1],","); |
348 | for (UInt_t k=0;k<lst2.size();k++){ | |
ba030c0e | 349 | if (fgkParameterName.CompareTo(lst2[k].c_str(),TString::kIgnoreCase)==0){ |
350 | inParam=kTRUE; | |
351 | } else if (fgkRegionName.CompareTo(lst2[k].c_str(),TString::kIgnoreCase)==0){ | |
352 | inRegion=kTRUE; | |
353 | } else if (fgkRuleName.CompareTo(lst2[k].c_str(),TString::kIgnoreCase)==0){ | |
354 | inRule=kTRUE; | |
355 | } | |
356 | } | |
357 | } else { | |
358 | inParam=inRegion=inRule=kTRUE; | |
359 | } | |
360 | ReadIniFile(plane,inFileName,inParam,inRegion,inRule); | |
361 | } | |
362 | } | |
363 | } | |
364 | } else if (rdParam && fgkParameterName.CompareTo(chapName,TString::kIgnoreCase)==0){ | |
365 | AliMUONSt1ResponseParameter* param = new AliMUONSt1ResponseParameter(); | |
366 | fTrashList.Add(param); | |
367 | string paramName=Form("Parameter %d",fParams.size()+1); | |
368 | for (itValue = vals.begin() ; itValue != vals.end(); ++itValue){ | |
369 | string name = (*itValue).first; | |
370 | string value = (*itValue).second; | |
371 | if (fgkNameName.CompareTo(name.c_str(),TString::kIgnoreCase)==0){ | |
372 | paramName=value; | |
373 | } else SetPairToParam(name,value,param); | |
374 | } | |
375 | fParams[paramName]=param; | |
376 | } else if (rdRegion && fgkRegionName.CompareTo(chapName,TString::kIgnoreCase)==0){ | |
377 | TList* lstElem = new TList; | |
378 | string listName=Form("Region %d",fRegions.size()+1); | |
379 | for (itValue = vals.begin() ; itValue != vals.end(); ++itValue){ | |
380 | string name = (*itValue).first; | |
381 | string value = (*itValue).second; | |
382 | if (fgkNameName.CompareTo(name.c_str(),TString::kIgnoreCase)==0){ | |
383 | listName=value; | |
384 | } else SetPairToListElem(name,value,lstElem); | |
385 | } | |
386 | fRegions[listName]=lstElem; | |
387 | } | |
388 | } | |
389 | iniFile.Reset(); | |
390 | while (!iniFile.Eof()){ | |
391 | chap = iniFile.MakeCurrentChapter(); | |
392 | TString chapName = chap.first.c_str(); | |
393 | vals = chap.second; | |
394 | if (rdRule && fgkRuleName.CompareTo(chapName,TString::kIgnoreCase)==0){ | |
395 | Int_t i; | |
396 | Bool_t zones[fgkNofZones]; | |
397 | for (i=0;i<fgkNofZones;i++) zones[i]=kFALSE; | |
398 | AliMUONSt1ResponseRule* rule=0; | |
399 | for (itValue = vals.begin() ; itValue != vals.end(); ++itValue){ | |
400 | string name = (*itValue).first; | |
401 | string value = (*itValue).second; | |
402 | if (fgkZoneName.CompareTo(name.c_str(),TString::kIgnoreCase)==0){ | |
79637e23 | 403 | IntPairVector lst = decoder::DecodeListOfIntRanges(value); |
404 | for (UInt_t i=0;i<lst.size();i++){ | |
405 | for (Int_t j=lst[i].first;(j<=fgkNofZones) && (j<=lst[i].second);j++) { | |
ba030c0e | 406 | if (j>0) zones[j-1] = kTRUE; |
407 | } | |
408 | } | |
409 | } else if (fgkRegionName.CompareTo(name.c_str(),TString::kIgnoreCase)==0){ | |
79637e23 | 410 | ListMap::iterator it = fRegions.find(value); |
ba030c0e | 411 | if (it != fRegions.end()){ |
412 | if (!rule) { | |
413 | rule = new AliMUONSt1ResponseRule(); | |
414 | fTrashList.Add(rule); | |
415 | } | |
416 | TIter next((*it).second); | |
417 | AliMUONSt1ElectronicElement* el; | |
418 | while ((el = static_cast<AliMUONSt1ElectronicElement*>(next()))){ | |
419 | rule->AddElement(el); | |
420 | } | |
8c343c7c | 421 | } else AliWarning(Form("Can't find region named %s",value.c_str())); |
ba030c0e | 422 | } |
423 | } | |
424 | for (itValue = vals.begin() ; itValue != vals.end(); ++itValue){ | |
425 | string name = (*itValue).first; | |
426 | string value = (*itValue).second; | |
427 | if (fgkParameterName.CompareTo(name.c_str(),TString::kIgnoreCase)==0){ | |
79637e23 | 428 | ParamsMap::iterator it = fParams.find(value); |
ba030c0e | 429 | if (it != fParams.end()){ |
430 | AliMUONSt1ResponseParameter* param = (*it).second; | |
431 | for (i=0;i<fgkNofZones;i++) if (zones[i]) { | |
432 | fDefaultParameters[plane][i]=param; | |
433 | } | |
434 | if (rule) rule->AddParameter(param); | |
8c343c7c | 435 | } else AliWarning(Form("Can't find parameter named %s",value.c_str())); |
ba030c0e | 436 | } |
437 | } | |
438 | if (rule) fRulesList[plane].AddFirst(rule); | |
439 | } | |
440 | } | |
79637e23 | 441 | for (ListMap::iterator it = fRegions.begin() ; it != fRegions.end(); ++it) delete (*it).second; |
ba030c0e | 442 | } |
443 | ||
444 | ||
445 | //__________________________________________________________________________ | |
446 | void AliMUONSt1Response::ReadFiles() | |
447 | { | |
448 | // Define the current response rules with respect to the description | |
449 | // given in the "configChamber1.ini" and "configChamber2.ini" files. | |
79637e23 | 450 | |
ba030c0e | 451 | Int_t i; |
74d70ece | 452 | TString path = fgkTopDir + fgkDataDir ; |
ba030c0e | 453 | |
454 | TString configFileName = path + fgkConfigBaseName + Form("%d.ini",fChamber); | |
455 | if (gSystem->AccessPathName(configFileName,kReadPermission)){ | |
456 | // no configChamberI.ini file exists | |
457 | SetIniFileName(0,fgkStandardIniFileName); | |
458 | SetIniFileName(1,fgkStandardIniFileName); | |
459 | } else { | |
460 | cout<<"Reading configuration file "<<configFileName<<endl; | |
461 | AliMUONSt1IniReader iniFile(configFileName.Data()); | |
462 | while (!iniFile.Eof()) { | |
463 | iniFile.ReadNextLine(); | |
464 | if (iniFile.GetCurrentType() != AliMUONSt1IniReader::kValue) continue; | |
465 | Int_t plane; | |
466 | if ((sscanf(iniFile.GetCurrentName().c_str() | |
467 | ,"file%d",&plane)==1) && (plane>=0) && (plane<=1)){ | |
468 | SetIniFileName(plane,iniFile.GetCurrentValue().c_str()); | |
469 | } | |
470 | } | |
471 | } | |
472 | //book memory and fill them with .ini files | |
4a147321 | 473 | fPlane[0]=AliMpPlane::Create(kStation1, kBendingPlane); |
474 | fPlane[1]=AliMpPlane::Create(kStation1, kNonBendingPlane); | |
ba030c0e | 475 | for (i=0;i<2;i++){ |
5f91c9e8 | 476 | fPlaneSegmentation[i]= new AliMpPlaneSegmentation(fPlane[i]); |
ba030c0e | 477 | ReadIniFile(i); |
478 | } | |
479 | } | |
480 | ||
481 | //__________________________________________________________________________ | |
482 | Float_t AliMUONSt1Response::IntPH(Float_t eloss) | |
483 | { | |
484 | // Calculate charge from given ionization energy lost. | |
79637e23 | 485 | |
ba030c0e | 486 | Int_t nel; |
487 | nel= Int_t(eloss*1.e9/20); | |
488 | Float_t charge=0; | |
489 | if (nel == 0) nel=1; | |
490 | for (Int_t i=1;i<=nel;i++) { | |
491 | Float_t arg=0.; | |
492 | while(!arg) arg = gRandom->Rndm(); | |
493 | charge -= fChargeSlope*TMath::Log(arg); | |
494 | } | |
495 | return charge; | |
496 | } | |
497 | ||
498 | ||
499 | //__________________________________________________________________________ | |
79637e23 | 500 | AliMpZone* AliMUONSt1Response::FindZone(AliMpSector* sector, Int_t posId) const |
ba030c0e | 501 | { |
5f91c9e8 | 502 | // to be moved to AliMpSector:: |
79637e23 | 503 | |
ba030c0e | 504 | for (Int_t izone=1;izone<=sector->GetNofZones();izone++){ |
5f91c9e8 | 505 | AliMpZone* zone = sector->GetZone(izone); |
ba030c0e | 506 | for (Int_t isub=0;isub<zone->GetNofSubZones();isub++){ |
5f91c9e8 | 507 | AliMpSubZone* sub=zone->GetSubZone(isub); |
ba030c0e | 508 | for (Int_t iseg=0;iseg<sub->GetNofRowSegments();iseg++){ |
509 | if (sub->GetRowSegment(iseg)->HasMotifPosition(posId)) return zone; | |
510 | } | |
511 | } | |
512 | } | |
513 | return 0; | |
514 | } | |
515 | ||
516 | ||
517 | //__________________________________________________________________________ | |
79637e23 | 518 | Int_t AliMUONSt1Response::DigitResponse(Int_t digit, AliMUONTransientDigit* where) |
ba030c0e | 519 | { |
520 | // returns the electronic response of pad located at <where>, when | |
521 | // a charge <digit> is present | |
522 | ||
523 | //cout<<"electronic of pad "<<where->PadX()<<' '<<where->PadY() | |
524 | // <<" on plane "<<where->Cathode()<<endl; | |
525 | ||
526 | //read the files the first time this function is called | |
527 | if (!fPlane[0]) ReadFiles(); | |
528 | ||
529 | fCountNofCalls++; | |
530 | ||
5f91c9e8 | 531 | AliMpIntPair indices(where->PadX(),where->PadY()); |
532 | AliMpPad pad = fPlaneSegmentation[where->Cathode()]->PadByIndices(indices,kFALSE); | |
3c25381f | 533 | Int_t gc=0; |
ba030c0e | 534 | Int_t numZone=0; |
5f91c9e8 | 535 | AliMpZone* zone=0; |
ba030c0e | 536 | |
537 | if (pad.IsValid()) { | |
5f91c9e8 | 538 | AliMpIntPair location = pad.GetLocation(); |
ba030c0e | 539 | //cout<<location.GetFirst()<<endl; |
540 | Int_t posId=abs(location.GetFirst()); | |
5f91c9e8 | 541 | AliMpSector* sector=0; |
ba030c0e | 542 | if (fPlane[0]->GetFrontSector()->GetMotifMap()->FindMotifPosition(posId)) |
5f91c9e8 | 543 | sector=(AliMpSector*)fPlane[0]->GetFrontSector(); |
ba030c0e | 544 | else if (fPlane[0]->GetBackSector()->GetMotifMap()->FindMotifPosition(posId)) |
5f91c9e8 | 545 | sector=(AliMpSector*)fPlane[0]->GetBackSector(); |
ba030c0e | 546 | |
547 | if (sector) zone=FindZone(sector,posId); | |
548 | if (zone){ | |
549 | numZone=zone->GetID()-1; | |
3c25381f | 550 | gc=location.GetSecond(); |
ba030c0e | 551 | } else { |
552 | fCountUnknownZone++; | |
553 | } | |
554 | } else { | |
555 | fCountUnknownIndices++; | |
556 | } | |
557 | ||
558 | if (!zone) { | |
559 | cout<<"Probleme electronic of pad "<<where->PadX()<<' '<<where->PadY() | |
560 | <<" on plane "<<where->Cathode()<<endl; | |
561 | return 6666; | |
562 | } | |
563 | TList listParams; | |
564 | TIter next(&fRulesList[where->Cathode()]); | |
565 | AliMUONSt1ResponseRule* rule; | |
566 | while ( (rule = static_cast<AliMUONSt1ResponseRule*>(next()))) | |
567 | if (rule->Contains(pad)) listParams.AddAll(rule->GetParameters()); | |
568 | if (fDefaultParameters[where->Cathode()][numZone]) | |
569 | listParams.Add(fDefaultParameters[where->Cathode()][numZone]); | |
570 | ||
571 | AliMUONSt1ResponseParameter* param; | |
572 | TIter nextParam(&listParams); | |
573 | while ( (param = static_cast<AliMUONSt1ResponseParameter*>(nextParam()))){ | |
574 | if (param->GetState()==kFALSE) { | |
575 | return 0; | |
576 | } | |
577 | } | |
578 | nextParam.Reset(); | |
579 | while ( (param = static_cast<AliMUONSt1ResponseParameter*>(nextParam()))){ | |
580 | if (param->HasPedestal()) { | |
3c25381f | 581 | digit = param->ApplyPedestal(digit,gc); |
ba030c0e | 582 | break; // Apply pedestals just once --> break the loop once a pedestal |
583 | // rule is applied | |
584 | } | |
585 | } | |
586 | if ( digit < 0) digit=0; | |
587 | if (digit > MaxAdc()) digit=MaxAdc(); | |
588 | nextParam.Reset(); | |
589 | while ( (param = static_cast<AliMUONSt1ResponseParameter*>(nextParam()))){ | |
590 | digit = param->ApplyStickyBits(digit); | |
591 | } | |
592 | ||
593 | //cout<<digit<<endl; | |
594 | return digit; | |
595 | } | |
596 | ||
597 | ||
598 | //__________________________________________________________________________ | |
599 | void AliMUONSt1Response::PrintStatistics() const | |
600 | { | |
601 | // Show the results of the statistics | |
79637e23 | 602 | |
ba030c0e | 603 | cout<<"The DigitResponse() method was called "<<fCountNofCalls<<" times"<<endl; |
604 | cout<<" it was unable to find the pad corresponding to the given indices " | |
605 | <<fCountUnknownIndices<<" times (" | |
606 | <<(Double_t)100.*fCountUnknownIndices/fCountNofCalls | |
607 | <<"%)"<<endl; | |
608 | cout<<" it was unable to find the zone corresponding to the found pad " | |
609 | <<fCountUnknownZone<<" times (" | |
610 | <<(Double_t)100.*fCountUnknownZone/fCountNofCalls | |
611 | <<"%)"<<endl; | |
612 | } | |
613 | ||
614 | ||
615 | ||
616 | ||
617 | ||
618 | ||
619 |