]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONSt1Response.cxx
Replacing rindex by strrchr
[u/mrichter/AliRoot.git] / MUON / AliMUONSt1Response.cxx
CommitLineData
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
25
ba030c0e 26#include <TMath.h>
27#include <TRandom.h>
28#include <TSystem.h>
74d70ece 29#include <Riostream.h>
3c25381f 30
5f91c9e8 31#include "AliMpIntPair.h"
32#include "AliMpPlaneSegmentation.h"
33#include "AliMpPad.h"
34#include "AliMpMotifMap.h"
35#include "AliMpSector.h"
36#include "AliMpPlane.h"
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"
47
48ClassImp(AliMUONSt1Response);
49
74d70ece 50const TString AliMUONSt1Response::fgkTopDir = getenv("ALICE_ROOT");
51const TString AliMUONSt1Response::fgkDataDir = "/MUON/data/";
ba030c0e 52const TString AliMUONSt1Response::fgkConfigBaseName = "configChamber";
53const TString AliMUONSt1Response::fgkStandardIniFileName = "st1StdParameter.ini";
54
55const TString AliMUONSt1Response::fgkBaseName ="base";
56const TString AliMUONSt1Response::fgkIncludeName ="include";
57const TString AliMUONSt1Response::fgkParameterName ="parameter";
58const TString AliMUONSt1Response::fgkRegionName ="region";
59const TString AliMUONSt1Response::fgkRuleName ="rule";
60const TString AliMUONSt1Response::fgkNameName ="name";
61const TString AliMUONSt1Response::fgkPedestalName ="pedestal";
62const TString AliMUONSt1Response::fgkNoiseName ="noise";
63const TString AliMUONSt1Response::fgkStateName ="state";
64const TString AliMUONSt1Response::fgkMName ="padM";
65const TString AliMUONSt1Response::fgkMGName ="padMG";
66const TString AliMUONSt1Response::fgkMGCName ="padMGC";
67const TString AliMUONSt1Response::fgkIJName ="padIJ";
68const TString AliMUONSt1Response::fgkXYName ="padXY";
69const TString AliMUONSt1Response::fgkZoneName ="zone";
70const TString AliMUONSt1Response::fgkStickyOnName ="stickyOn";
71const TString AliMUONSt1Response::fgkStickyOffName ="stickyOff";
72const TString AliMUONSt1Response::fgkFileName ="file";
73const TString AliMUONSt1Response::fgkValueName ="value";
74const TString AliMUONSt1Response::fgkGausName ="gaus";
75const TString AliMUONSt1Response::fgkNotName ="no";
76const TString AliMUONSt1Response::fgkNofSigmaName ="nofSigma";
77
78
79
80//__________________________________________________________________________
81AliMUONSt1Response::AliMUONSt1Response(Int_t chamber)
3c25381f 82 : AliMUONResponseV0(),
83 fCountNofCalls(0),
84 fCountUnknownZone(0),
85 fCountUnknownIndices(0),
86 fChamber(chamber),
87 fParams(),
88 fRegions(),
89 fTrashList()
ba030c0e 90
91{
3c25381f 92// Standard constructor
93
ba030c0e 94 // default pedestal value
95 fCountNofCalls=0;
96 fCountUnknownZone=0;
97 fCountUnknownIndices=0;
98
99 Int_t i;
100 for (i=0;i<2;i++){
101 fIniFileName[i]="";
102 fPlane[0]=0;
103 fPlaneSegmentation[i]=0;
104 for (Int_t j=0;j<fgkNofZones;j++)
105 {
106 fDefaultParameters[i][j]=0;
107 }
108 }
109 fTrashList.SetOwner(kTRUE);
110}
111
112
3c25381f 113//__________________________________________________________________________
114AliMUONSt1Response::AliMUONSt1Response(const AliMUONSt1Response& rhs)
115 : AliMUONResponseV0(rhs)
116{
117// Copy constructor
118
119 Fatal("Copy constructor",
120 "Copy constructor is not implemented.");
121}
122
ba030c0e 123//__________________________________________________________________________
124AliMUONSt1Response::~AliMUONSt1Response()
125{
126//destructor
127 Int_t i;
128 for (i=0;i<2;i++){
129 if (fPlaneSegmentation[i]) delete fPlaneSegmentation[i];
130 if (fPlane[i]) delete fPlane[i];
131 fTrashList.Delete();
132 }
133}
134
3c25381f 135//
136// operators
137//
138
139//______________________________________________________________________________
140AliMUONSt1Response&
141AliMUONSt1Response::operator=(const AliMUONSt1Response& rhs)
142{
143// Copy operator
144
145 // check assignement to self
146 if (this == &rhs) return *this;
147
148 Fatal("operator=",
149 "Assignment operator is not implemented.");
150
151 return *this;
152}
153
ba030c0e 154//__________________________________________________________________________
155void 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 163void 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) {
176 Warning("ReadIniFile","Bad pad definition");
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 196void 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) {
208 Warning("ReadIniFile","Bad pad definition");
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 228void 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 278void 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//__________________________________________________________________________
306void 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)){
313 Fatal("ReadIniFile",
314 Form("Unable to Read the file %s",fIniFileName[plane].Data()));
315 return;
316 }
317 fRegions.clear();
318 fParams.clear();
319 ReadIniFile(plane,path+fIniFileName[plane],kTRUE,kTRUE,kTRUE);
320}
321
322
323//__________________________________________________________________________
324void AliMUONSt1Response::ReadIniFile(Int_t plane,const TString& fileName,
79637e23 325 Bool_t rdParam,Bool_t rdRegion,Bool_t rdRule)
ba030c0e 326{
327 //Read the given ini file and fill the <plane>th structures
79637e23 328
ba030c0e 329 cout<<"Reading parameter file "<<fileName<<endl;
330 AliMUONSt1IniReader iniFile(fileName.Data());
79637e23 331 AliMUONSt1IniReader::Chapter chap;
332 AliMUONSt1IniReader::ValueList vals;
333 AliMUONSt1IniReader::ValueList::iterator itValue;
ba030c0e 334 while (!iniFile.Eof()){
335 chap = iniFile.MakeCurrentChapter();
336 TString chapName = chap.first.c_str();
337 vals = chap.second;
338 if (fgkBaseName.CompareTo(chapName,TString::kIgnoreCase)==0){
339 for (itValue = vals.begin() ; itValue != vals.end(); ++itValue){
340 string name = (*itValue).first;
341 string value = (*itValue).second;
342 if (fgkIncludeName.CompareTo(name.c_str(),TString::kIgnoreCase)==0){
79637e23 343 StringVector lst = decoder::SplitList(value,":");
ba030c0e 344 if (lst.size()>0){
345 TString inFileName = TString(gSystem->DirName(fileName))+"/" + lst[0].c_str();
346 Bool_t inParam=kFALSE,inRegion=kFALSE,inRule=kFALSE;
347 if (lst.size()>1) {
79637e23 348 StringVector lst2 = decoder::SplitList(lst[1],",");
349 for (UInt_t k=0;k<lst2.size();k++){
ba030c0e 350 if (fgkParameterName.CompareTo(lst2[k].c_str(),TString::kIgnoreCase)==0){
351 inParam=kTRUE;
352 } else if (fgkRegionName.CompareTo(lst2[k].c_str(),TString::kIgnoreCase)==0){
353 inRegion=kTRUE;
354 } else if (fgkRuleName.CompareTo(lst2[k].c_str(),TString::kIgnoreCase)==0){
355 inRule=kTRUE;
356 }
357 }
358 } else {
359 inParam=inRegion=inRule=kTRUE;
360 }
361 ReadIniFile(plane,inFileName,inParam,inRegion,inRule);
362 }
363 }
364 }
365 } else if (rdParam && fgkParameterName.CompareTo(chapName,TString::kIgnoreCase)==0){
366 AliMUONSt1ResponseParameter* param = new AliMUONSt1ResponseParameter();
367 fTrashList.Add(param);
368 string paramName=Form("Parameter %d",fParams.size()+1);
369 for (itValue = vals.begin() ; itValue != vals.end(); ++itValue){
370 string name = (*itValue).first;
371 string value = (*itValue).second;
372 if (fgkNameName.CompareTo(name.c_str(),TString::kIgnoreCase)==0){
373 paramName=value;
374 } else SetPairToParam(name,value,param);
375 }
376 fParams[paramName]=param;
377 } else if (rdRegion && fgkRegionName.CompareTo(chapName,TString::kIgnoreCase)==0){
378 TList* lstElem = new TList;
379 string listName=Form("Region %d",fRegions.size()+1);
380 for (itValue = vals.begin() ; itValue != vals.end(); ++itValue){
381 string name = (*itValue).first;
382 string value = (*itValue).second;
383 if (fgkNameName.CompareTo(name.c_str(),TString::kIgnoreCase)==0){
384 listName=value;
385 } else SetPairToListElem(name,value,lstElem);
386 }
387 fRegions[listName]=lstElem;
388 }
389 }
390 iniFile.Reset();
391 while (!iniFile.Eof()){
392 chap = iniFile.MakeCurrentChapter();
393 TString chapName = chap.first.c_str();
394 vals = chap.second;
395 if (rdRule && fgkRuleName.CompareTo(chapName,TString::kIgnoreCase)==0){
396 Int_t i;
397 Bool_t zones[fgkNofZones];
398 for (i=0;i<fgkNofZones;i++) zones[i]=kFALSE;
399 AliMUONSt1ResponseRule* rule=0;
400 for (itValue = vals.begin() ; itValue != vals.end(); ++itValue){
401 string name = (*itValue).first;
402 string value = (*itValue).second;
403 if (fgkZoneName.CompareTo(name.c_str(),TString::kIgnoreCase)==0){
79637e23 404 IntPairVector lst = decoder::DecodeListOfIntRanges(value);
405 for (UInt_t i=0;i<lst.size();i++){
406 for (Int_t j=lst[i].first;(j<=fgkNofZones) && (j<=lst[i].second);j++) {
ba030c0e 407 if (j>0) zones[j-1] = kTRUE;
408 }
409 }
410 } else if (fgkRegionName.CompareTo(name.c_str(),TString::kIgnoreCase)==0){
79637e23 411 ListMap::iterator it = fRegions.find(value);
ba030c0e 412 if (it != fRegions.end()){
413 if (!rule) {
414 rule = new AliMUONSt1ResponseRule();
415 fTrashList.Add(rule);
416 }
417 TIter next((*it).second);
418 AliMUONSt1ElectronicElement* el;
419 while ((el = static_cast<AliMUONSt1ElectronicElement*>(next()))){
420 rule->AddElement(el);
421 }
422 } else Warning("ReadIniFile",Form("Can't find region named %s",value.c_str()));
423 }
424 }
425 for (itValue = vals.begin() ; itValue != vals.end(); ++itValue){
426 string name = (*itValue).first;
427 string value = (*itValue).second;
428 if (fgkParameterName.CompareTo(name.c_str(),TString::kIgnoreCase)==0){
79637e23 429 ParamsMap::iterator it = fParams.find(value);
ba030c0e 430 if (it != fParams.end()){
431 AliMUONSt1ResponseParameter* param = (*it).second;
432 for (i=0;i<fgkNofZones;i++) if (zones[i]) {
433 fDefaultParameters[plane][i]=param;
434 }
435 if (rule) rule->AddParameter(param);
436 } else Warning("ReadIniFile",Form("Can't find parameter named %s",value.c_str()));
437 }
438 }
439 if (rule) fRulesList[plane].AddFirst(rule);
440 }
441 }
79637e23 442 for (ListMap::iterator it = fRegions.begin() ; it != fRegions.end(); ++it) delete (*it).second;
ba030c0e 443}
444
445
446//__________________________________________________________________________
447void AliMUONSt1Response::ReadFiles()
448{
449// Define the current response rules with respect to the description
450// given in the "configChamber1.ini" and "configChamber2.ini" files.
79637e23 451
ba030c0e 452 Int_t i;
74d70ece 453 TString path = fgkTopDir + fgkDataDir ;
ba030c0e 454
455 TString configFileName = path + fgkConfigBaseName + Form("%d.ini",fChamber);
456 if (gSystem->AccessPathName(configFileName,kReadPermission)){
457 // no configChamberI.ini file exists
458 SetIniFileName(0,fgkStandardIniFileName);
459 SetIniFileName(1,fgkStandardIniFileName);
460 } else {
461 cout<<"Reading configuration file "<<configFileName<<endl;
462 AliMUONSt1IniReader iniFile(configFileName.Data());
463 while (!iniFile.Eof()) {
464 iniFile.ReadNextLine();
465 if (iniFile.GetCurrentType() != AliMUONSt1IniReader::kValue) continue;
466 Int_t plane;
467 if ((sscanf(iniFile.GetCurrentName().c_str()
468 ,"file%d",&plane)==1) && (plane>=0) && (plane<=1)){
469 SetIniFileName(plane,iniFile.GetCurrentValue().c_str());
470 }
471 }
472 }
473 //book memory and fill them with .ini files
4a147321 474 fPlane[0]=AliMpPlane::Create(kStation1, kBendingPlane);
475 fPlane[1]=AliMpPlane::Create(kStation1, kNonBendingPlane);
ba030c0e 476 for (i=0;i<2;i++){
5f91c9e8 477 fPlaneSegmentation[i]= new AliMpPlaneSegmentation(fPlane[i]);
ba030c0e 478 ReadIniFile(i);
479 }
480}
481
482//__________________________________________________________________________
483Float_t AliMUONSt1Response::IntPH(Float_t eloss)
484{
485 // Calculate charge from given ionization energy lost.
79637e23 486
ba030c0e 487 Int_t nel;
488 nel= Int_t(eloss*1.e9/20);
489 Float_t charge=0;
490 if (nel == 0) nel=1;
491 for (Int_t i=1;i<=nel;i++) {
492 Float_t arg=0.;
493 while(!arg) arg = gRandom->Rndm();
494 charge -= fChargeSlope*TMath::Log(arg);
495 }
496 return charge;
497}
498
499
500//__________________________________________________________________________
79637e23 501AliMpZone* AliMUONSt1Response::FindZone(AliMpSector* sector, Int_t posId) const
ba030c0e 502{
5f91c9e8 503// to be moved to AliMpSector::
79637e23 504
ba030c0e 505 for (Int_t izone=1;izone<=sector->GetNofZones();izone++){
5f91c9e8 506 AliMpZone* zone = sector->GetZone(izone);
ba030c0e 507 for (Int_t isub=0;isub<zone->GetNofSubZones();isub++){
5f91c9e8 508 AliMpSubZone* sub=zone->GetSubZone(isub);
ba030c0e 509 for (Int_t iseg=0;iseg<sub->GetNofRowSegments();iseg++){
510 if (sub->GetRowSegment(iseg)->HasMotifPosition(posId)) return zone;
511 }
512 }
513 }
514 return 0;
515}
516
517
518//__________________________________________________________________________
79637e23 519Int_t AliMUONSt1Response::DigitResponse(Int_t digit, AliMUONTransientDigit* where)
ba030c0e 520{
521 // returns the electronic response of pad located at <where>, when
522 // a charge <digit> is present
523
524 //cout<<"electronic of pad "<<where->PadX()<<' '<<where->PadY()
525 // <<" on plane "<<where->Cathode()<<endl;
526
527 //read the files the first time this function is called
528 if (!fPlane[0]) ReadFiles();
529
530 fCountNofCalls++;
531
5f91c9e8 532 AliMpIntPair indices(where->PadX(),where->PadY());
533 AliMpPad pad = fPlaneSegmentation[where->Cathode()]->PadByIndices(indices,kFALSE);
3c25381f 534 Int_t gc=0;
ba030c0e 535 Int_t numZone=0;
5f91c9e8 536 AliMpZone* zone=0;
ba030c0e 537
538 if (pad.IsValid()) {
5f91c9e8 539 AliMpIntPair location = pad.GetLocation();
ba030c0e 540 //cout<<location.GetFirst()<<endl;
541 Int_t posId=abs(location.GetFirst());
5f91c9e8 542 AliMpSector* sector=0;
ba030c0e 543 if (fPlane[0]->GetFrontSector()->GetMotifMap()->FindMotifPosition(posId))
5f91c9e8 544 sector=(AliMpSector*)fPlane[0]->GetFrontSector();
ba030c0e 545 else if (fPlane[0]->GetBackSector()->GetMotifMap()->FindMotifPosition(posId))
5f91c9e8 546 sector=(AliMpSector*)fPlane[0]->GetBackSector();
ba030c0e 547
548 if (sector) zone=FindZone(sector,posId);
549 if (zone){
550 numZone=zone->GetID()-1;
3c25381f 551 gc=location.GetSecond();
ba030c0e 552 } else {
553 fCountUnknownZone++;
554 }
555 } else {
556 fCountUnknownIndices++;
557 }
558
559 if (!zone) {
560 cout<<"Probleme electronic of pad "<<where->PadX()<<' '<<where->PadY()
561 <<" on plane "<<where->Cathode()<<endl;
562 return 6666;
563 }
564 TList listParams;
565 TIter next(&fRulesList[where->Cathode()]);
566 AliMUONSt1ResponseRule* rule;
567 while ( (rule = static_cast<AliMUONSt1ResponseRule*>(next())))
568 if (rule->Contains(pad)) listParams.AddAll(rule->GetParameters());
569 if (fDefaultParameters[where->Cathode()][numZone])
570 listParams.Add(fDefaultParameters[where->Cathode()][numZone]);
571
572 AliMUONSt1ResponseParameter* param;
573 TIter nextParam(&listParams);
574 while ( (param = static_cast<AliMUONSt1ResponseParameter*>(nextParam()))){
575 if (param->GetState()==kFALSE) {
576 return 0;
577 }
578 }
579 nextParam.Reset();
580 while ( (param = static_cast<AliMUONSt1ResponseParameter*>(nextParam()))){
581 if (param->HasPedestal()) {
3c25381f 582 digit = param->ApplyPedestal(digit,gc);
ba030c0e 583 break; // Apply pedestals just once --> break the loop once a pedestal
584// rule is applied
585 }
586 }
587 if ( digit < 0) digit=0;
588 if (digit > MaxAdc()) digit=MaxAdc();
589 nextParam.Reset();
590 while ( (param = static_cast<AliMUONSt1ResponseParameter*>(nextParam()))){
591 digit = param->ApplyStickyBits(digit);
592 }
593
594 //cout<<digit<<endl;
595 return digit;
596}
597
598
599//__________________________________________________________________________
600void AliMUONSt1Response::PrintStatistics() const
601{
602// Show the results of the statistics
79637e23 603
ba030c0e 604 cout<<"The DigitResponse() method was called "<<fCountNofCalls<<" times"<<endl;
605 cout<<" it was unable to find the pad corresponding to the given indices "
606 <<fCountUnknownIndices<<" times ("
607 <<(Double_t)100.*fCountUnknownIndices/fCountNofCalls
608 <<"%)"<<endl;
609 cout<<" it was unable to find the zone corresponding to the found pad "
610 <<fCountUnknownZone<<" times ("
611 <<(Double_t)100.*fCountUnknownZone/fCountNofCalls
612 <<"%)"<<endl;
613}
614
615
616
617
618
619
620