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