1 /**************************************************************************
2 * Copyright(c) 1998-1999, 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 **************************************************************************/
20 #include <Riostream.h>
24 #include "AliITSdigitSPD.h"
25 #include "AliITShit.h"
26 #include "AliITSmodule.h"
27 #include "AliITSpList.h"
28 #include "AliITSCalibrationSPD.h"
29 #include "AliITSsegmentationSPD.h"
30 #include "AliITSsimulationSPD.h"
36 ClassImp(AliITSsimulationSPD)
37 ////////////////////////////////////////////////////////////////////////
39 // Modified by D. Elia, G.E. Bruno, H. Tydesjo
40 // Fast diffusion code by Bjorn S. Nilsen
42 // October 2007: GetCalibrationObjects() removed
45 // Written by Boris Batyunya
49 // AliITSsimulationSPD is to do the simulation of SPDs.
51 ////////////////////////////////////////////////////////////////////////
53 //______________________________________________________________________
54 AliITSsimulationSPD::AliITSsimulationSPD():
59 // Default constructor.
65 // A default constructed AliITSsimulationSPD class.
67 AliDebug(1,Form("Calling default constructor"));
70 //______________________________________________________________________
71 AliITSsimulationSPD::AliITSsimulationSPD(AliITSDetTypeSim *dettyp):
72 AliITSsimulation(dettyp),
76 // standard constructor
78 // AliITSsegmentation *seg A pointer to the segmentation class
79 // to be used for this simulation
80 // AliITSCalibration *resp A pointer to the responce class to
81 // be used for this simulation
85 // A default constructed AliITSsimulationSPD class.
87 AliDebug(1,Form("Calling standard constructor "));
88 // AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(fDetType->GetITSgeom()->GetStartSPD());
89 // res->SetTemperature(0.0);
90 // res->SetDistanceOverVoltage(0.0);
93 //______________________________________________________________________
94 void AliITSsimulationSPD::Init(){
102 const Double_t kmictocm = 1.0e-4; // convert microns to cm.
106 SetMap(new AliITSpList(GetNPixelsZ(),GetNPixelsX()));
107 AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(fDetType->GetITSgeom()->GetStartSPD());
108 AliITSsegmentationSPD* seg = (AliITSsegmentationSPD*)GetSegmentationModel(0);
109 Double_t bias = res->GetBiasVoltage();
110 // cout << "Bias Voltage --> " << bias << endl; // dom
111 res->SetDistanceOverVoltage(kmictocm*seg->Dy(),bias);
112 // set kind of coupling ("old" or "new")
114 res->GetCouplingOption(opt);
115 char *old = strstr(opt,"old");
123 //______________________________________________________________________
124 AliITSsimulationSPD::~AliITSsimulationSPD(){
138 //______________________________________________________________________
139 AliITSsimulationSPD::AliITSsimulationSPD(const
141 &s) : AliITSsimulation(s),
143 fSPDname(s.fSPDname),
144 fCoupling(s.fCoupling){
147 // AliITSsimulationSPD &s The original class for which
148 // this class is a copy of
154 //______________________________________________________________________
155 AliITSsimulationSPD& AliITSsimulationSPD::operator=(const
156 AliITSsimulationSPD &s){
157 // Assignment operator
159 // AliITSsimulationSPD &s The original class for which
160 // this class is a copy of
165 if(&s == this) return *this;
167 fCoupling = s.fCoupling;
168 fSPDname = s.fSPDname;
171 //______________________________________________________________________
172 AliITSsimulation& AliITSsimulationSPD::operator=(const
173 AliITSsimulation &s){
174 // Assignment operator
176 // AliITSsimulationSPD &s The original class for which
177 // this class is a copy of
182 if(&s == this) return *this;
183 Error("AliITSsimulationSPD","Not allowed to make a = with "
184 "AliITSsimulationSPD","Using default creater instead");
188 //______________________________________________________________________
189 void AliITSsimulationSPD::InitSimulationModule(Int_t module, Int_t event){
190 // This function creates maps to build the list of tracks for each
191 // summable digit. Inputs defined by base class.
193 // Int_t module // Module number to be simulated
194 // Int_t event // Event number to be simulated
200 AliDebug(1,Form("(module=%d,event=%d)",module,event));
201 SetModuleNumber(module);
202 SetEventNumber(event);
205 //_____________________________________________________________________
206 void AliITSsimulationSPD::SDigitiseModule(AliITSmodule *mod,Int_t,
208 // This function begins the work of creating S-Digits. Inputs defined
211 // AliITSmodule *mod // module
213 // Int_t event // Event number
217 // test // test returns kTRUE if the module contained hits
218 // // test returns kFALSE if it did not contain hits
220 AliDebug(1,Form("(mod=%p, ,event=%d)",mod,event));
221 if(!(mod->GetNhits())){
222 AliDebug(1,Form("In event %d module %d there are %d hits returning.",
223 event, mod->GetIndex(),mod->GetNhits()));
224 return;// if module has no hits don't create Sdigits
226 SetModuleNumber(mod->GetIndex());
227 SetEventNumber(event);
229 HitToSDigitFast(mod);
230 RemoveDeadPixels(mod);
231 // cout << "After Remove in SDigitiseModule !!!!!" << endl; // dom
232 // cout << "Module " << mod->GetIndex() << " Event " << event << endl; // dom
236 //______________________________________________________________________
237 void AliITSsimulationSPD::WriteSDigits(){
238 // This function adds each S-Digit to pList
245 Int_t ix, nix, iz, niz;
246 static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
248 AliDebug(1,Form("Writing SDigits for module %d",GetModuleNumber()));
249 // cout << "WriteSDigits for module " << GetModuleNumber() << endl; // dom
250 GetMap()->GetMaxMapIndex(niz, nix);
251 for(iz=0; iz<niz; iz++)for(ix=0; ix<nix; ix++){
252 if(GetMap()->GetSignalOnly(iz,ix)>0.0){
253 // cout << " Signal gt 0 iz ix " << iz << ix << " Module " << GetModuleNumber() << endl; // dom
254 aliITS->AddSumDigit(*(GetMap()->GetpListItem(iz,ix)));
255 if(AliDebugLevel()>0) {
256 AliDebug(1,Form("%d, %d",iz,ix));
257 cout << *(GetMap()->GetpListItem(iz,ix)) << endl;
259 } // end if GetMap()->GetSignalOnly(iz,ix)>0.0
263 //______________________________________________________________________
264 void AliITSsimulationSPD::FinishSDigitiseModule(){
265 // This function calls SDigitsToDigits which creates Digits from SDigits
274 // cout << "FinishSDigitiseModule for module " << GetModuleNumber() << endl; // dom
275 FrompListToDigits(); // Charge To Signal both adds noise and
279 //______________________________________________________________________
280 void AliITSsimulationSPD::DigitiseModule(AliITSmodule *mod,Int_t,
282 // This function creates Digits straight from the hits and then adds
283 // electronic noise to the digits before adding them to pList
284 // Each of the input variables is passed along to HitToSDigit
286 // AliITSmodule *mod module
294 AliDebug(1,Form("(mod=%p,,)",mod));
296 HitToSDigitFast(mod);
297 RemoveDeadPixels(mod);
298 // cout << "After Remove in DigitiseModule in module " << mod->GetIndex() << endl; // dom
302 //______________________________________________________________________
303 void AliITSsimulationSPD::HitToSDigit(AliITSmodule *mod){
304 // Does the charge distributions using Gaussian diffusion charge charing.
306 // AliITSmodule *mod Pointer to this module
311 const Double_t kmictocm = 1.0e-4; // convert microns to cm.
312 TObjArray *hits = mod->GetHits();
313 Int_t nhits = hits->GetEntriesFast();
316 Double_t x0=0.0,x1=0.0,y0=0.0,y1=0.0,z0=0.0,z1=0.0,de=0.0;
317 Double_t x,y,z,t,tp,st,dt=0.2,el,sig,sigx,sigz,fda;
318 AliITSsegmentationSPD* seg = (AliITSsegmentationSPD*)GetSegmentationModel(0);
319 AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(fDetType->GetITSgeom()->GetStartSPD());
320 Double_t thick = 0.5*kmictocm*seg->Dy(); // Half Thickness
321 res->GetSigmaDiffusionAsymmetry(fda);
323 AliDebug(1,Form("(mod=%p) fCoupling=%d",mod,fCoupling));
325 for(h=0;h<nhits;h++){
326 if(AliDebugLevel()>0) {
327 AliDebug(1,Form("Hits, %d", h));
328 cout << *(mod->GetHit(h)) << endl;
330 if(!mod->LineSegmentL(h,x0,x1,y0,y1,z0,z1,de,idtrack)) continue;
331 st = TMath::Sqrt(x1*x1+y1*y1+z1*z1);
333 st = (Double_t)((Int_t)(st/kmictocm)); // number of microns
334 if(st<=1.0) st = 1.0;
336 for(t=0.0;t<1.0;t+=dt){ // Integrate over t
341 if(!(seg->LocalToDet(x,z,ix,iz))) continue; // outside
342 el = res->GeVToCharge((Double_t)(dt*de));
344 if(el<=0.0) cout<<"el="<<el<<" dt="<<dt
347 sig = res->SigmaDiffusion1D(TMath::Abs(thick + y));
348 // SpreadCharge(x,z,ix,iz,el,sig,idtrack,h);
351 SpreadChargeAsym(x,z,ix,iz,el,sigx,sigz,idtrack,h);
352 cout << "sigx, sigz, y "<< sigx << " " << sigz<< " " << TMath::Abs(thick + y) << endl;// ciccio
354 } else { // st == 0.0 deposit it at this point
358 if(!(seg->LocalToDet(x,z,ix,iz))) continue; // outside
359 el = res->GeVToCharge((Double_t)de);
360 sig = res->SigmaDiffusion1D(TMath::Abs(thick + y));
361 // SpreadCharge(x,z,ix,iz,el,sig,idtrack,h);
364 SpreadChargeAsym(x,z,ix,iz,el,sigx,sigz,idtrack,h);
367 } // Loop over all hits h
374 for(i=0;i<GetMap()->GetEntries();i++)
375 if(GetMap()->GetpListItem(i)==0) continue;
377 GetMap()->GetMapIndex(GetMap()->GetpListItem(i)->GetIndex(),iz,ix);
378 SetCoupling(iz,ix,idtrack,h);
382 for(i=0;i<GetMap()->GetEntries();i++)
383 if(GetMap()->GetpListItem(i)==0) continue;
385 GetMap()->GetMapIndex(GetMap()->GetpListItem(i)->GetIndex(),iz,ix);
386 SetCouplingOld(iz,ix,idtrack,h);
390 if(GetDebug(2))Info("HitToSDigit","Finished fCoupling=%d",fCoupling);
392 //______________________________________________________________________
393 void AliITSsimulationSPD::HitToSDigitFast(AliITSmodule *mod){
394 // Does the charge distributions using Gaussian diffusion charge charing. // Inputs:
395 // AliITSmodule *mod Pointer to this module
400 const Double_t kmictocm = 1.0e-4; // convert microns to cm.
402 const Double_t kti[kn10]={7.443716945e-3,2.166976971e-1,3.397047841e-1,
403 4.325316833e-1,4.869532643e-1,5.130467358e-1,
404 5.674683167e-1,6.602952159e-1,7.833023029e-1,
406 const Double_t kwi[kn10]={1.477621124e-1,1.346333597e-1,1.095431813e-1,
407 7.472567455e-2,3.333567215e-2,3.333567215e-2,
408 7.472567455e-2,1.095431813e-1,1.346333597e-1,
410 TObjArray *hits = mod->GetHits();
411 Int_t nhits = hits->GetEntriesFast();
414 Double_t x0=0.0,x1=0.0,y0=0.0,y1=0.0,z0=0.0,z1=0.0,de=0.0;
415 Double_t x,y,z,t,st,el,sig,sigx,sigz,fda;
416 AliITSsegmentationSPD* seg = (AliITSsegmentationSPD*)GetSegmentationModel(0);
417 AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(fDetType->GetITSgeom()->GetStartSPD());
418 Double_t thick = 0.5*kmictocm*seg->Dy(); // Half thickness
419 res->GetSigmaDiffusionAsymmetry(fda);
420 // cout << "Half Thickness " << thick << endl; // dom
421 // cout << "Diffusion asymm " << fda << endl; // dom
423 AliDebug(1,Form("(mod=%p) fCoupling=%d",mod,fCoupling));
425 for(h=0;h<nhits;h++){
426 if(AliDebugLevel()>0) {
427 AliDebug(1,Form("Hits, %d", h));
428 cout << *(mod->GetHit(h)) << endl;
430 if(!mod->LineSegmentL(h,x0,x1,y0,y1,z0,z1,de,idtrack)) continue;
431 st = TMath::Sqrt(x1*x1+y1*y1+z1*z1);
432 if(st>0.0) for(i=0;i<kn10;i++){ // Integrate over t
437 if(!(seg->LocalToDet(x,z,ix,iz))) continue; // outside
438 // el = res->GeVToCharge((Double_t)(dt*de));
439 // el = 1./kn10*res->GeVToCharge((Double_t)de);
440 el = kwi[i]*res->GeVToCharge((Double_t)de);
442 if(el<=0.0) cout<<"el="<<el<<" kwi["<<i<<"]="<<kwi[i]
445 sig = res->SigmaDiffusion1D(TMath::Abs(thick + y));
448 //SpreadCharge(x,z,ix,iz,el,sig,idtrack,h);
449 SpreadChargeAsym(x,z,ix,iz,el,sigx,sigz,idtrack,h);
450 // cout << "sigx sigz " << sigx << " " << sigz << endl; // dom
451 } // end for i // End Integrate over t
452 else { // st == 0.0 deposit it at this point
456 if(!(seg->LocalToDet(x,z,ix,iz))) continue; // outside
457 el = res->GeVToCharge((Double_t)de);
458 sig = res->SigmaDiffusion1D(TMath::Abs(thick + y));
459 //SpreadCharge(x,z,ix,iz,el,sig,idtrack,h);
462 SpreadChargeAsym(x,z,ix,iz,el,sigx,sigz,idtrack,h);
465 } // Loop over all hits h
472 for(i=0;i<GetMap()->GetEntries();i++)
473 if(GetMap()->GetpListItem(i)==0) continue;
475 GetMap()->GetMapIndex(GetMap()->GetpListItem(i)->GetIndex(),iz,ix);
476 SetCoupling(iz,ix,idtrack,h);
480 for(i=0;i<GetMap()->GetEntries();i++)
481 if(GetMap()->GetpListItem(i)==0) continue;
483 GetMap()->GetMapIndex(GetMap()->GetpListItem(i)->GetIndex(),iz,ix);
484 SetCouplingOld(iz,ix,idtrack,h);
488 if(GetDebug(2))Info("HitToSDigit","Finished fCoupling=%d",fCoupling);
490 //______________________________________________________________________
491 void AliITSsimulationSPD::SpreadCharge(Double_t x0,Double_t z0,
493 Double_t el,Double_t sig,Int_t t,
495 // Spreads the charge over neighboring cells. Assume charge is distributed
496 // as charge(x,z) = (el/2*pi*sig*sig)*exp(-arg)
497 // arg=((x-x0)*(x-x0)/2*sig*sig)+((z-z0*z-z0)/2*sig*sig)
498 // Defined this way, the integral over all x and z is el.
500 // Double_t x0 x position of point where charge is liberated
501 // Double_t y0 y position of point where charge is liberated
502 // Double_t z0 z position of point where charge is liberated
503 // Int_t ix0 row of cell corresponding to point x0
504 // Int_t iz0 columb of cell corresponding to point z0
505 // Double_t el number of electrons liberated in this step
506 // Double_t sig Sigma difusion for this step (y0 dependent)
507 // Int_t t track number
508 // Int_t ti hit track index number
509 // Int_t hi hit "hit" index number
514 const Int_t knx = 3,knz = 2;
515 const Double_t kRoot2 = 1.414213562; // Sqrt(2).
516 const Double_t kmictocm = 1.0e-4; // convert microns to cm.
517 Int_t ix,iz,ixs,ixe,izs,ize;
519 Double_t x1,x2,z1,z2,s,sp;
520 AliITSsegmentationSPD* seg = (AliITSsegmentationSPD*)GetSegmentationModel(0);
523 if(GetDebug(4)) Info("SpreadCharge","(x0=%e,z0=%e,ix0=%d,iz0=%d,el=%e,"
524 "sig=%e,t=%d,i=%d)",x0,z0,ix0,iz0,el,sig,t,hi);
525 if(sig<=0.0) { // if sig<=0 No diffusion to simulate.
526 GetMap()->AddSignal(iz0,ix0,t,hi,GetModuleNumber(),el);
528 cout << "sig<=0.0=" << sig << endl;
532 sp = 1.0/(sig*kRoot2);
534 cout << "sig=" << sig << " sp=" << sp << endl;
536 ixs = TMath::Max(-knx+ix0,0);
537 ixe = TMath::Min(knx+ix0,seg->Npx()-1);
538 izs = TMath::Max(-knz+iz0,0);
539 ize = TMath::Min(knz+iz0,seg->Npz()-1);
540 for(ix=ixs;ix<=ixe;ix++) for(iz=izs;iz<=ize;iz++){
541 seg->DetToLocal(ix,iz,x,z); // pixel center
544 x2 = x1 + 0.5*kmictocm*seg->Dpx(ix); // Upper
545 x1 -= 0.5*kmictocm*seg->Dpx(ix); // Lower
546 z2 = z1 + 0.5*kmictocm*seg->Dpz(iz); // Upper
547 z1 -= 0.5*kmictocm*seg->Dpz(iz); // Lower
548 x1 -= x0; // Distance from where track traveled
549 x2 -= x0; // Distance from where track traveled
550 z1 -= z0; // Distance from where track traveled
551 z2 -= z0; // Distance from where track traveled
552 s = 0.25; // Correction based on definision of Erfc
553 s *= TMath::Erfc(sp*x1) - TMath::Erfc(sp*x2);
555 cout <<"el="<<el<<" ix0="<<ix0<<" ix="<<ix<<" x0="<<x<<
556 " iz0="<<iz0<<" iz="<<iz<<" z0="<<z<<
557 " sp*x1="<<sp*x1<<" sp*x2="<<sp*x2<<" s="<<s;
559 s *= TMath::Erfc(sp*z1) - TMath::Erfc(sp*z2);
561 cout<<" sp*z1="<<sp*z1<<" sp*z2="<<sp*z2<<" s="<<s<< endl;
563 GetMap()->AddSignal(iz,ix,t,hi,GetModuleNumber(),s*el);
566 //______________________________________________________________________
567 void AliITSsimulationSPD::SpreadChargeAsym(Double_t x0,Double_t z0,
569 Double_t el,Double_t sigx,Double_t sigz,
571 // Spreads the charge over neighboring cells. Assume charge is distributed
572 // as charge(x,z) = (el/2*pi*sigx*sigz)*exp(-arg)
573 // arg=((x-x0)*(x-x0)/2*sigx*sigx)+((z-z0*z-z0)/2*sigz*sigz)
574 // Defined this way, the integral over all x and z is el.
576 // Double_t x0 x position of point where charge is liberated
577 // Double_t y0 y position of point where charge is liberated
578 // Double_t z0 z position of point where charge is liberated
579 // Int_t ix0 row of cell corresponding to point x0
580 // Int_t iz0 columb of cell corresponding to point z0
581 // Double_t el number of electrons liberated in this step
582 // Double_t sigx Sigma difusion along x for this step (y0 dependent)
583 // Double_t sigz Sigma difusion along z for this step (y0 dependent)
584 // Int_t t track number
585 // Int_t ti hit track index number
586 // Int_t hi hit "hit" index number
591 const Int_t knx = 3,knz = 2;
592 const Double_t kRoot2 = 1.414213562; // Sqrt(2).
593 const Double_t kmictocm = 1.0e-4; // convert microns to cm.
594 Int_t ix,iz,ixs,ixe,izs,ize;
596 Double_t x1,x2,z1,z2,s,spx,spz;
597 AliITSsegmentationSPD* seg = (AliITSsegmentationSPD*)GetSegmentationModel(0);
600 if(GetDebug(4)) Info("SpreadCharge","(x0=%e,z0=%e,ix0=%d,iz0=%d,el=%e,"
601 "sig=%e,t=%d,i=%d)",x0,z0,ix0,iz0,el,sigx,sigz,t,hi);
602 if(sigx<=0.0 || sigz<=0.0) { // if sig<=0 No diffusion to simulate.
603 GetMap()->AddSignal(iz0,ix0,t,hi,GetModuleNumber(),el);
605 cout << "sigx<=0.0=" << sigx << endl;
606 cout << "sigz<=0.0=" << sigz << endl;
610 spx = 1.0/(sigx*kRoot2); spz = 1.0/(sigz*kRoot2);
612 cout << "sigx=" << sigx << " spx=" << spx << endl;
613 cout << "sigz=" << sigz << " spz=" << spz << endl;
615 ixs = TMath::Max(-knx+ix0,0);
616 ixe = TMath::Min(knx+ix0,seg->Npx()-1);
617 izs = TMath::Max(-knz+iz0,0);
618 ize = TMath::Min(knz+iz0,seg->Npz()-1);
619 for(ix=ixs;ix<=ixe;ix++) for(iz=izs;iz<=ize;iz++){
620 seg->DetToLocal(ix,iz,x,z); // pixel center
623 x2 = x1 + 0.5*kmictocm*seg->Dpx(ix); // Upper
624 x1 -= 0.5*kmictocm*seg->Dpx(ix); // Lower
625 z2 = z1 + 0.5*kmictocm*seg->Dpz(iz); // Upper
626 z1 -= 0.5*kmictocm*seg->Dpz(iz); // Lower
627 x1 -= x0; // Distance from where track traveled
628 x2 -= x0; // Distance from where track traveled
629 z1 -= z0; // Distance from where track traveled
630 z2 -= z0; // Distance from where track traveled
631 s = 0.25; // Correction based on definision of Erfc
632 s *= TMath::Erfc(spx*x1) - TMath::Erfc(spx*x2);
634 cout <<"el="<<el<<" ix0="<<ix0<<" ix="<<ix<<" x0="<<x<<
635 " iz0="<<iz0<<" iz="<<iz<<" z0="<<z<<
636 " spx*x1="<<spx*x1<<" spx*x2="<<spx*x2<<" s="<<s;
638 s *= TMath::Erfc(spz*z1) - TMath::Erfc(spz*z2);
640 cout<<" spz*z1="<<spz*z1<<" spz*z2="<<spz*z2<<" s="<<s<< endl;
642 GetMap()->AddSignal(iz,ix,t,hi,GetModuleNumber(),s*el);
645 //______________________________________________________________________
646 void AliITSsimulationSPD::RemoveDeadPixels(AliITSmodule *mod){
647 // Removes dead pixels on each module (ladder)
649 // Module Index (0,239)
655 Int_t moduleNr = mod->GetIndex();
656 AliITSCalibrationSPD* calObj = (AliITSCalibrationSPD*) GetCalibrationModel(moduleNr);
658 Int_t nrDead = calObj->GetNrBad();
659 // cout << "Module --> " << moduleNr << endl; // dom
660 // cout << "nr of dead " << nrDead << endl; // dom
661 for (Int_t i=0; i<nrDead; i++) {
662 GetMap()->DeleteHit(calObj->GetBadColAt(i),calObj->GetBadRowAt(i));
663 // cout << "dead index " << i << endl; // dom
664 // cout << "col row --> " << calObj->GetDeadColAt(i) << " " << calObj->GetDeadRowAt(i) << endl; // dom
667 //______________________________________________________________________
668 void AliITSsimulationSPD::FrompListToDigits(){
669 // add noise and electronics, perform the zero suppression and add the
677 static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
679 Double_t electronics;
681 const Int_t knmaxtrk=AliITSdigit::GetNTracks();
682 static AliITSdigitSPD dig;
683 AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(fDetType->GetITSgeom()->GetStartSPD());
684 if(GetDebug(1)) Info("FrompListToDigits","()");
685 for(iz=0; iz<GetNPixelsZ(); iz++) for(ix=0; ix<GetNPixelsX(); ix++){
686 // NEW (for the moment plugged by hand, in the future possibly read from Data Base)
687 // here parametrize the efficiency of the pixel along the row for the test columns (1,9,17,25)
688 // if(iz==1 || iz == 9 || iz == 17 || iz == 25) {
689 // Double_t eff,p1=0.,p2=0.;
692 // case 1: p1=0.63460;p2=0.42438E-01;break;
693 // case 9: p1=0.41090;p2=0.75914E-01;break;
694 // case 17: p1=0.31883;p2=0.91502E-01;break;
695 // case 25: p1=0.48828;p2=0.57975E-01;break;
697 // eff=1.-p1*exp(-p2*x);
698 // if (gRandom->Rndm() >= eff) continue;
700 // END parametrize the efficiency
702 electronics = res->ApplyBaselineAndNoise();
703 UpdateMapNoise(ix,iz,electronics);
705 // Apply Threshold and write Digits.
706 sig = GetMap()->GetSignalOnly(iz,ix);
707 FillHistograms(ix,iz,sig+electronics);
709 cout<<sig<<"+"<<electronics<<">threshold("<<ix<<","<<iz
710 <<")="<<GetThreshold() <<endl;
712 if (sig+electronics <= GetThreshold()) continue;
717 // dig.SetSignalSPD((Int_t) GetMap()->GetSignal(iz,ix));
718 Double_t aSignal = GetMap()->GetSignal(iz,ix);
719 if (TMath::Abs(aSignal)>2147483647.0) {
720 //PH 2147483647 is the max. integer
721 //PH This apparently is a problem which needs investigation
722 AliWarning(Form("Too big or too small signal value %f",aSignal));
723 aSignal = TMath::Sign((Double_t)2147483647,aSignal);
725 dig.SetSignalSPD((Int_t)aSignal);
727 for(j=0;j<knmaxtrk;j++){
728 if (j<GetMap()->GetNEntries()) {
729 dig.SetTrack(j,GetMap()->GetTrack(iz,ix,j));
730 dig.SetHit(j,GetMap()->GetHit(iz,ix,j));
731 }else { // Default values
737 cout<<iz<<","<<ix<<","<<*(GetMap()->GetpListItem(iz,ix))<<endl;
739 aliITS->AddSimDigit(0,&dig);
742 //______________________________________________________________________
743 void AliITSsimulationSPD::CreateHistograms(){
744 // create 1D histograms for tests
752 if(GetDebug(1)) Info("CreateHistograms","create histograms");
754 fHis = new TObjArray(GetNPixelsZ());
755 TString fSPDname("spd_");
756 for(Int_t i=0;i<GetNPixelsZ();i++) {
758 sprintf(pixelz,"%d",i);
759 fSPDname.Append(pixelz);
760 fHis->AddAt(new TH1F(fSPDname.Data(),"SPD maps",
761 GetNPixelsX(),0.,(Double_t)GetNPixelsX()),i);
764 //______________________________________________________________________
765 void AliITSsimulationSPD::FillHistograms(Int_t ix,Int_t iz,Double_t v){
766 // Fill the histogram
774 if(!GetHistArray()) return; // Only fill if setup.
775 if(GetDebug(2)) Info("FillHistograms","fill histograms");
776 GetHistogram(iz)->Fill(ix,v);
778 //______________________________________________________________________
779 void AliITSsimulationSPD::ResetHistograms(){
780 // Reset histograms for this detector
788 if(!GetHistArray()) return; // Only fill if setup.
789 if(GetDebug(2)) Info("FillHistograms","fill histograms");
790 for ( int i=0;i<GetNPixelsZ();i++ ) {
791 if (fHis->At(i)) ((TH1F*)fHis->At(i))->Reset();
795 //______________________________________________________________________
796 void AliITSsimulationSPD::SetCoupling(Int_t col, Int_t row, Int_t ntrack,
798 // Take into account the coupling between adiacent pixels.
799 // The parameters probcol and probrow are the probability of the
800 // signal in one pixel shared in the two adjacent pixels along
801 // the column and row direction, respectively.
802 // Note pList is goten via GetMap() and module is not need any more.
803 // Otherwise it is identical to that coded by Tiziano Virgili (BSN).
806 <img src="picts/ITS/barimodel_3.gif">
809 <font size=+2 color=red>
810 <a href="mailto:tiziano.virgili@cern.ch"></a>.
816 // Int_t col z cell index
817 // Int_t row x cell index
818 // Int_t ntrack track incex number
819 // Int_t idhit hit index number
825 Double_t pulse1,pulse2;
826 Double_t couplR=0.0,couplC=0.0;
829 GetCouplings(couplC,couplR);
830 if(GetDebug(3)) Info("SetCoupling","(col=%d,row=%d,ntrack=%d,idhit=%d) "
831 "Calling SetCoupling couplC=%e couplR=%e",
832 col,row,ntrack,idhit,couplC,couplR);
835 pulse1 = GetMap()->GetSignalOnly(col,row);
837 for (Int_t isign=-1;isign<=1;isign+=2){// loop in col direction
840 xr = gRandom->Rndm();
841 if ((j1<0) || (j1>GetNPixelsZ()-1) || (xr>couplC)){
845 UpdateMapSignal(row,j1,ntrack,idhit,pulse1);
847 flag = 1; // only first next!!
850 // loop in row direction
853 xr = gRandom->Rndm();
854 if ((j2<0) || (j2>GetNPixelsX()-1) || (xr>couplR)){
858 UpdateMapSignal(j2,col,ntrack,idhit,pulse2);
860 flag = 1; // only first next!!
865 //______________________________________________________________________
866 void AliITSsimulationSPD::SetCouplingOld(Int_t col, Int_t row,
867 Int_t ntrack,Int_t idhit) {
868 // Take into account the coupling between adiacent pixels.
869 // The parameters probcol and probrow are the fractions of the
870 // signal in one pixel shared in the two adjacent pixels along
871 // the column and row direction, respectively.
874 <img src="picts/ITS/barimodel_3.gif">
877 <font size=+2 color=red>
878 <a href="mailto:Rocco.Caliandro@ba.infn.it"></a>.
884 // Int_t col z cell index
885 // Int_t row x cell index
886 // Int_t ntrack track incex number
887 // Int_t idhit hit index number
888 // Int_t module module number
894 Double_t pulse1,pulse2;
895 Double_t couplR=0.0,couplC=0.0;
897 GetCouplings(couplC,couplR);
900 // cout << "Threshold --> " << GetThreshold() << endl; // dom
901 // cout << "Couplings --> " << couplC << " " << couplR << endl; // dom
903 if(GetDebug(3)) Info("SetCouplingOld","(col=%d,row=%d,ntrack=%d,idhit=%d) "
904 "Calling SetCoupling couplC=%e couplR=%e",
905 col,row,ntrack,idhit,couplC,couplR);
906 for (Int_t isign=-1;isign<=1;isign+=2){// loop in col direction
907 pulse1 = GetMap()->GetSignalOnly(col,row);
914 if ((j1<0)||(j1>GetNPixelsZ()-1)||(pulse1<GetThreshold())){
915 pulse1 = GetMap()->GetSignalOnly(col,row);
919 UpdateMapSignal(row,j1,ntrack,idhit,pulse1);
921 flag = 1; // only first next !!
924 // loop in row direction
928 if((j2<0)||(j2>(GetNPixelsX()-1))||(pulse2<GetThreshold())){
929 pulse2 = GetMap()->GetSignalOnly(col,row);
933 UpdateMapSignal(j2,col,ntrack,idhit,pulse2);
935 flag = 1; // only first next!!