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"
33 #include "AliCDBEntry.h"
34 #include "AliCDBLocal.h"
38 ClassImp(AliITSsimulationSPD)
39 ////////////////////////////////////////////////////////////////////////
41 // Modified by D. Elia, G.E. Bruno, H. Tydesjo
42 // Fast diffusion code by Bjorn S. Nilsen
46 // Written by Boris Batyunya
50 // AliITSsimulationSPD is to do the simulation of SPDs.
52 ////////////////////////////////////////////////////////////////////////
54 //______________________________________________________________________
55 AliITSsimulationSPD::AliITSsimulationSPD():
60 // Default constructor.
66 // A default constructed AliITSsimulationSPD class.
68 AliDebug(1,Form("Calling default constructor"));
71 //______________________________________________________________________
72 AliITSsimulationSPD::AliITSsimulationSPD(AliITSDetTypeSim *dettyp):
73 AliITSsimulation(dettyp),
77 // standard constructor
79 // AliITSsegmentation *seg A pointer to the segmentation class
80 // to be used for this simulation
81 // AliITSCalibration *resp A pointer to the responce class to
82 // be used for this simulation
86 // A default constructed AliITSsimulationSPD class.
88 AliDebug(1,Form("Calling standard constructor "));
89 // AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(fDetType->GetITSgeom()->GetStartSPD());
90 // res->SetTemperature(0.0);
91 // res->SetDistanceOverVoltage(0.0);
94 //______________________________________________________________________
95 void AliITSsimulationSPD::Init(){
103 const Double_t kmictocm = 1.0e-4; // convert microns to cm.
107 SetMap(new AliITSpList(GetNPixelsZ(),GetNPixelsX()));
108 AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(fDetType->GetITSgeom()->GetStartSPD());
109 AliITSsegmentationSPD* seg = (AliITSsegmentationSPD*)GetSegmentationModel(0);
110 Double_t bias = res->GetBiasVoltage();
111 // cout << "Bias Voltage --> " << bias << endl; // dom
112 res->SetDistanceOverVoltage(kmictocm*seg->Dy(),bias);
113 // set kind of coupling ("old" or "new")
115 res->GetCouplingOption(opt);
116 char *old = strstr(opt,"old");
123 // Get the calibration objects for each module(ladder)
124 GetCalibrationObjects(0); //RunNr 0 hard coded for now
127 //______________________________________________________________________
128 AliITSsimulationSPD::~AliITSsimulationSPD(){
142 //______________________________________________________________________
143 AliITSsimulationSPD::AliITSsimulationSPD(const
145 &s) : AliITSsimulation(s),
147 fSPDname(s.fSPDname),
148 fCoupling(s.fCoupling){
151 // AliITSsimulationSPD &s The original class for which
152 // this class is a copy of
158 //______________________________________________________________________
159 AliITSsimulationSPD& AliITSsimulationSPD::operator=(const
160 AliITSsimulationSPD &s){
161 // Assignment operator
163 // AliITSsimulationSPD &s The original class for which
164 // this class is a copy of
169 if(&s == this) return *this;
171 fCoupling = s.fCoupling;
172 fSPDname = s.fSPDname;
175 //______________________________________________________________________
176 AliITSsimulation& AliITSsimulationSPD::operator=(const
177 AliITSsimulation &s){
178 // Assignment operator
180 // AliITSsimulationSPD &s The original class for which
181 // this class is a copy of
186 if(&s == this) return *this;
187 Error("AliITSsimulationSPD","Not allowed to make a = with "
188 "AliITSsimulationSPD","Using default creater instead");
193 //______________________________________________________________________
194 void AliITSsimulationSPD::GetCalibrationObjects(Int_t RunNr) {
195 // Gets the calibration objects for each module (ladder)
197 // RunNr: hard coded to RunNr=0 for now
203 AliCDBManager* man = AliCDBManager::Instance();
205 AliCDBEntry *entrySPD=0;
206 entrySPD = man->Get("ITS/Calib/CalibSPD", RunNr);
209 AliWarning("Cannot find SPD calibration entry in default storage! Using local storage $ALICE_ROOT");
210 AliCDBStorage *localStor =
211 AliCDBManager::Instance()->GetStorage("local://$ALICE_ROOT");
212 entrySPD = localStor->Get("ITS/Calib/CalibSPD", RunNr);
214 AliFatal("Cannot find SPD calibration entry!");
219 TObjArray *respSPD = (TObjArray *)entrySPD->GetObject();
221 AliFatal("Cannot get data from SPD database entry!");
224 for (Int_t mod=0; mod<240; mod++) {
225 fCalObj[mod] = (AliITSCalibrationSPD*) respSPD->At(mod);
229 //______________________________________________________________________
230 void AliITSsimulationSPD::InitSimulationModule(Int_t module, Int_t event){
231 // This function creates maps to build the list of tracks for each
232 // summable digit. Inputs defined by base class.
234 // Int_t module // Module number to be simulated
235 // Int_t event // Event number to be simulated
241 AliDebug(1,Form("(module=%d,event=%d)",module,event));
242 SetModuleNumber(module);
243 SetEventNumber(event);
246 //_____________________________________________________________________
247 void AliITSsimulationSPD::SDigitiseModule(AliITSmodule *mod,Int_t,
249 // This function begins the work of creating S-Digits. Inputs defined
252 // AliITSmodule *mod // module
254 // Int_t event // Event number
258 // test // test returns kTRUE if the module contained hits
259 // // test returns kFALSE if it did not contain hits
261 AliDebug(1,Form("(mod=%p, ,event=%d)",mod,event));
262 if(!(mod->GetNhits())){
263 AliDebug(1,Form("In event %d module %d there are %d hits returning.",
264 event, mod->GetIndex(),mod->GetNhits()));
265 return;// if module has no hits don't create Sdigits
267 SetModuleNumber(mod->GetIndex());
268 SetEventNumber(event);
270 HitToSDigitFast(mod);
271 RemoveDeadPixels(mod);
272 // cout << "After Remove in SDigitiseModule !!!!!" << endl; // dom
273 // cout << "Module " << mod->GetIndex() << " Event " << event << endl; // dom
277 //______________________________________________________________________
278 void AliITSsimulationSPD::WriteSDigits(){
279 // This function adds each S-Digit to pList
286 Int_t ix, nix, iz, niz;
287 static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
289 AliDebug(1,Form("Writing SDigits for module %d",GetModuleNumber()));
290 // cout << "WriteSDigits for module " << GetModuleNumber() << endl; // dom
291 GetMap()->GetMaxMapIndex(niz, nix);
292 for(iz=0; iz<niz; iz++)for(ix=0; ix<nix; ix++){
293 if(GetMap()->GetSignalOnly(iz,ix)>0.0){
294 // cout << " Signal gt 0 iz ix " << iz << ix << " Module " << GetModuleNumber() << endl; // dom
295 aliITS->AddSumDigit(*(GetMap()->GetpListItem(iz,ix)));
296 if(AliDebugLevel()>0) {
297 AliDebug(1,Form("%d, %d",iz,ix));
298 cout << *(GetMap()->GetpListItem(iz,ix)) << endl;
300 } // end if GetMap()->GetSignalOnly(iz,ix)>0.0
304 //______________________________________________________________________
305 void AliITSsimulationSPD::FinishSDigitiseModule(){
306 // This function calls SDigitsToDigits which creates Digits from SDigits
315 // cout << "FinishSDigitiseModule for module " << GetModuleNumber() << endl; // dom
316 FrompListToDigits(); // Charge To Signal both adds noise and
320 //______________________________________________________________________
321 void AliITSsimulationSPD::DigitiseModule(AliITSmodule *mod,Int_t,
323 // This function creates Digits straight from the hits and then adds
324 // electronic noise to the digits before adding them to pList
325 // Each of the input variables is passed along to HitToSDigit
327 // AliITSmodule *mod module
335 AliDebug(1,Form("(mod=%p,,)",mod));
337 HitToSDigitFast(mod);
338 RemoveDeadPixels(mod);
339 // cout << "After Remove in DigitiseModule in module " << mod->GetIndex() << endl; // dom
343 //______________________________________________________________________
344 void AliITSsimulationSPD::HitToSDigit(AliITSmodule *mod){
345 // Does the charge distributions using Gaussian diffusion charge charing.
347 // AliITSmodule *mod Pointer to this module
352 const Double_t kmictocm = 1.0e-4; // convert microns to cm.
353 TObjArray *hits = mod->GetHits();
354 Int_t nhits = hits->GetEntriesFast();
357 Double_t x0=0.0,x1=0.0,y0=0.0,y1=0.0,z0=0.0,z1=0.0,de=0.0;
358 Double_t x,y,z,t,tp,st,dt=0.2,el,sig,sigx,sigz,fda;
359 AliITSsegmentationSPD* seg = (AliITSsegmentationSPD*)GetSegmentationModel(0);
360 AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(fDetType->GetITSgeom()->GetStartSPD());
361 Double_t thick = 0.5*kmictocm*seg->Dy(); // Half Thickness
362 res->GetSigmaDiffusionAsymmetry(fda);
364 AliDebug(1,Form("(mod=%p) fCoupling=%d",mod,fCoupling));
366 for(h=0;h<nhits;h++){
367 if(AliDebugLevel()>0) {
368 AliDebug(1,Form("Hits, %d", h));
369 cout << *(mod->GetHit(h)) << endl;
371 if(!mod->LineSegmentL(h,x0,x1,y0,y1,z0,z1,de,idtrack)) continue;
372 st = TMath::Sqrt(x1*x1+y1*y1+z1*z1);
374 st = (Double_t)((Int_t)(st/kmictocm)); // number of microns
375 if(st<=1.0) st = 1.0;
377 for(t=0.0;t<1.0;t+=dt){ // Integrate over t
382 if(!(seg->LocalToDet(x,z,ix,iz))) continue; // outside
383 el = res->GeVToCharge((Double_t)(dt*de));
385 if(el<=0.0) cout<<"el="<<el<<" dt="<<dt
388 sig = res->SigmaDiffusion1D(TMath::Abs(thick + y));
389 // SpreadCharge(x,z,ix,iz,el,sig,idtrack,h);
392 SpreadChargeAsym(x,z,ix,iz,el,sigx,sigz,idtrack,h);
393 cout << "sigx, sigz, y "<< sigx << " " << sigz<< " " << TMath::Abs(thick + y) << endl;// ciccio
395 } else { // st == 0.0 deposit it at this point
399 if(!(seg->LocalToDet(x,z,ix,iz))) continue; // outside
400 el = res->GeVToCharge((Double_t)de);
401 sig = res->SigmaDiffusion1D(TMath::Abs(thick + y));
402 // SpreadCharge(x,z,ix,iz,el,sig,idtrack,h);
405 SpreadChargeAsym(x,z,ix,iz,el,sigx,sigz,idtrack,h);
412 for(i=0;i<GetMap()->GetEntries();i++)
413 if(GetMap()->GetpListItem(i)==0) continue;
415 GetMap()->GetMapIndex(GetMap()->GetpListItem(i)->GetIndex(),iz,ix);
416 SetCoupling(iz,ix,idtrack,h);
420 for(i=0;i<GetMap()->GetEntries();i++)
421 if(GetMap()->GetpListItem(i)==0) continue;
423 GetMap()->GetMapIndex(GetMap()->GetpListItem(i)->GetIndex(),iz,ix);
424 SetCouplingOld(iz,ix,idtrack,h);
428 } // Loop over all hits h
429 if(GetDebug(2))Info("HitToSDigit","Finished fCoupling=%d",fCoupling);
431 //______________________________________________________________________
432 void AliITSsimulationSPD::HitToSDigitFast(AliITSmodule *mod){
433 // Does the charge distributions using Gaussian diffusion charge charing. // Inputs:
434 // AliITSmodule *mod Pointer to this module
439 const Double_t kmictocm = 1.0e-4; // convert microns to cm.
441 const Double_t kti[kn10]={7.443716945e-3,2.166976971e-1,3.397047841e-1,
442 4.325316833e-1,4.869532643e-1,5.130467358e-1,
443 5.674683167e-1,6.602952159e-1,7.833023029e-1,
445 const Double_t kwi[kn10]={1.477621124e-1,1.346333597e-1,1.095431813e-1,
446 7.472567455e-2,3.333567215e-2,3.333567215e-2,
447 7.472567455e-2,1.095431813e-1,1.346333597e-1,
449 TObjArray *hits = mod->GetHits();
450 Int_t nhits = hits->GetEntriesFast();
453 Double_t x0=0.0,x1=0.0,y0=0.0,y1=0.0,z0=0.0,z1=0.0,de=0.0;
454 Double_t x,y,z,t,st,el,sig,sigx,sigz,fda;
455 AliITSsegmentationSPD* seg = (AliITSsegmentationSPD*)GetSegmentationModel(0);
456 AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(fDetType->GetITSgeom()->GetStartSPD());
457 Double_t thick = 0.5*kmictocm*seg->Dy(); // Half thickness
458 res->GetSigmaDiffusionAsymmetry(fda);
459 // cout << "Half Thickness " << thick << endl; // dom
460 // cout << "Diffusion asymm " << fda << endl; // dom
462 AliDebug(1,Form("(mod=%p) fCoupling=%d",mod,fCoupling));
464 for(h=0;h<nhits;h++){
465 if(AliDebugLevel()>0) {
466 AliDebug(1,Form("Hits, %d", h));
467 cout << *(mod->GetHit(h)) << endl;
469 if(!mod->LineSegmentL(h,x0,x1,y0,y1,z0,z1,de,idtrack)) continue;
470 st = TMath::Sqrt(x1*x1+y1*y1+z1*z1);
471 if(st>0.0) for(i=0;i<kn10;i++){ // Integrate over t
476 if(!(seg->LocalToDet(x,z,ix,iz))) continue; // outside
477 // el = res->GeVToCharge((Double_t)(dt*de));
478 // el = 1./kn10*res->GeVToCharge((Double_t)de);
479 el = kwi[i]*res->GeVToCharge((Double_t)de);
481 if(el<=0.0) cout<<"el="<<el<<" kwi["<<i<<"]="<<kwi[i]
484 sig = res->SigmaDiffusion1D(TMath::Abs(thick + y));
487 //SpreadCharge(x,z,ix,iz,el,sig,idtrack,h);
488 SpreadChargeAsym(x,z,ix,iz,el,sigx,sigz,idtrack,h);
489 // cout << "sigx sigz " << sigx << " " << sigz << endl; // dom
490 } // end for i // End Integrate over t
491 else { // st == 0.0 deposit it at this point
495 if(!(seg->LocalToDet(x,z,ix,iz))) continue; // outside
496 el = res->GeVToCharge((Double_t)de);
497 sig = res->SigmaDiffusion1D(TMath::Abs(thick + y));
498 //SpreadCharge(x,z,ix,iz,el,sig,idtrack,h);
501 SpreadChargeAsym(x,z,ix,iz,el,sigx,sigz,idtrack,h);
508 for(i=0;i<GetMap()->GetEntries();i++)
509 if(GetMap()->GetpListItem(i)==0) continue;
511 GetMap()->GetMapIndex(GetMap()->GetpListItem(i)->GetIndex(),iz,ix);
512 SetCoupling(iz,ix,idtrack,h);
516 for(i=0;i<GetMap()->GetEntries();i++)
517 if(GetMap()->GetpListItem(i)==0) continue;
519 GetMap()->GetMapIndex(GetMap()->GetpListItem(i)->GetIndex(),iz,ix);
520 SetCouplingOld(iz,ix,idtrack,h);
524 } // Loop over all hits h
525 if(GetDebug(2))Info("HitToSDigit","Finished fCoupling=%d",fCoupling);
527 //______________________________________________________________________
528 void AliITSsimulationSPD::SpreadCharge(Double_t x0,Double_t z0,
530 Double_t el,Double_t sig,Int_t t,
532 // Spreads the charge over neighboring cells. Assume charge is distributed
533 // as charge(x,z) = (el/2*pi*sig*sig)*exp(-arg)
534 // arg=((x-x0)*(x-x0)/2*sig*sig)+((z-z0*z-z0)/2*sig*sig)
535 // Defined this way, the integral over all x and z is el.
537 // Double_t x0 x position of point where charge is liberated
538 // Double_t y0 y position of point where charge is liberated
539 // Double_t z0 z position of point where charge is liberated
540 // Int_t ix0 row of cell corresponding to point x0
541 // Int_t iz0 columb of cell corresponding to point z0
542 // Double_t el number of electrons liberated in this step
543 // Double_t sig Sigma difusion for this step (y0 dependent)
544 // Int_t t track number
545 // Int_t ti hit track index number
546 // Int_t hi hit "hit" index number
551 const Int_t knx = 3,knz = 2;
552 const Double_t kRoot2 = 1.414213562; // Sqrt(2).
553 const Double_t kmictocm = 1.0e-4; // convert microns to cm.
554 Int_t ix,iz,ixs,ixe,izs,ize;
556 Double_t x1,x2,z1,z2,s,sp;
557 AliITSsegmentationSPD* seg = (AliITSsegmentationSPD*)GetSegmentationModel(0);
560 if(GetDebug(4)) Info("SpreadCharge","(x0=%e,z0=%e,ix0=%d,iz0=%d,el=%e,"
561 "sig=%e,t=%d,i=%d)",x0,z0,ix0,iz0,el,sig,t,hi);
562 if(sig<=0.0) { // if sig<=0 No diffusion to simulate.
563 GetMap()->AddSignal(iz0,ix0,t,hi,GetModuleNumber(),el);
565 cout << "sig<=0.0=" << sig << endl;
569 sp = 1.0/(sig*kRoot2);
571 cout << "sig=" << sig << " sp=" << sp << endl;
573 ixs = TMath::Max(-knx+ix0,0);
574 ixe = TMath::Min(knx+ix0,seg->Npx()-1);
575 izs = TMath::Max(-knz+iz0,0);
576 ize = TMath::Min(knz+iz0,seg->Npz()-1);
577 for(ix=ixs;ix<=ixe;ix++) for(iz=izs;iz<=ize;iz++){
578 seg->DetToLocal(ix,iz,x,z); // pixel center
581 x2 = x1 + 0.5*kmictocm*seg->Dpx(ix); // Upper
582 x1 -= 0.5*kmictocm*seg->Dpx(ix); // Lower
583 z2 = z1 + 0.5*kmictocm*seg->Dpz(iz); // Upper
584 z1 -= 0.5*kmictocm*seg->Dpz(iz); // Lower
585 x1 -= x0; // Distance from where track traveled
586 x2 -= x0; // Distance from where track traveled
587 z1 -= z0; // Distance from where track traveled
588 z2 -= z0; // Distance from where track traveled
589 s = 0.25; // Correction based on definision of Erfc
590 s *= TMath::Erfc(sp*x1) - TMath::Erfc(sp*x2);
592 cout <<"el="<<el<<" ix0="<<ix0<<" ix="<<ix<<" x0="<<x<<
593 " iz0="<<iz0<<" iz="<<iz<<" z0="<<z<<
594 " sp*x1="<<sp*x1<<" sp*x2="<<sp*x2<<" s="<<s;
596 s *= TMath::Erfc(sp*z1) - TMath::Erfc(sp*z2);
598 cout<<" sp*z1="<<sp*z1<<" sp*z2="<<sp*z2<<" s="<<s<< endl;
600 GetMap()->AddSignal(iz,ix,t,hi,GetModuleNumber(),s*el);
603 //______________________________________________________________________
604 void AliITSsimulationSPD::SpreadChargeAsym(Double_t x0,Double_t z0,
606 Double_t el,Double_t sigx,Double_t sigz,
608 // Spreads the charge over neighboring cells. Assume charge is distributed
609 // as charge(x,z) = (el/2*pi*sigx*sigz)*exp(-arg)
610 // arg=((x-x0)*(x-x0)/2*sigx*sigx)+((z-z0*z-z0)/2*sigz*sigz)
611 // Defined this way, the integral over all x and z is el.
613 // Double_t x0 x position of point where charge is liberated
614 // Double_t y0 y position of point where charge is liberated
615 // Double_t z0 z position of point where charge is liberated
616 // Int_t ix0 row of cell corresponding to point x0
617 // Int_t iz0 columb of cell corresponding to point z0
618 // Double_t el number of electrons liberated in this step
619 // Double_t sigx Sigma difusion along x for this step (y0 dependent)
620 // Double_t sigz Sigma difusion along z for this step (y0 dependent)
621 // Int_t t track number
622 // Int_t ti hit track index number
623 // Int_t hi hit "hit" index number
628 const Int_t knx = 3,knz = 2;
629 const Double_t kRoot2 = 1.414213562; // Sqrt(2).
630 const Double_t kmictocm = 1.0e-4; // convert microns to cm.
631 Int_t ix,iz,ixs,ixe,izs,ize;
633 Double_t x1,x2,z1,z2,s,spx,spz;
634 AliITSsegmentationSPD* seg = (AliITSsegmentationSPD*)GetSegmentationModel(0);
637 if(GetDebug(4)) Info("SpreadCharge","(x0=%e,z0=%e,ix0=%d,iz0=%d,el=%e,"
638 "sig=%e,t=%d,i=%d)",x0,z0,ix0,iz0,el,sigx,sigz,t,hi);
639 if(sigx<=0.0 || sigz<=0.0) { // if sig<=0 No diffusion to simulate.
640 GetMap()->AddSignal(iz0,ix0,t,hi,GetModuleNumber(),el);
642 cout << "sigx<=0.0=" << sigx << endl;
643 cout << "sigz<=0.0=" << sigz << endl;
647 spx = 1.0/(sigx*kRoot2); spz = 1.0/(sigz*kRoot2);
649 cout << "sigx=" << sigx << " spx=" << spx << endl;
650 cout << "sigz=" << sigz << " spz=" << spz << endl;
652 ixs = TMath::Max(-knx+ix0,0);
653 ixe = TMath::Min(knx+ix0,seg->Npx()-1);
654 izs = TMath::Max(-knz+iz0,0);
655 ize = TMath::Min(knz+iz0,seg->Npz()-1);
656 for(ix=ixs;ix<=ixe;ix++) for(iz=izs;iz<=ize;iz++){
657 seg->DetToLocal(ix,iz,x,z); // pixel center
660 x2 = x1 + 0.5*kmictocm*seg->Dpx(ix); // Upper
661 x1 -= 0.5*kmictocm*seg->Dpx(ix); // Lower
662 z2 = z1 + 0.5*kmictocm*seg->Dpz(iz); // Upper
663 z1 -= 0.5*kmictocm*seg->Dpz(iz); // Lower
664 x1 -= x0; // Distance from where track traveled
665 x2 -= x0; // Distance from where track traveled
666 z1 -= z0; // Distance from where track traveled
667 z2 -= z0; // Distance from where track traveled
668 s = 0.25; // Correction based on definision of Erfc
669 s *= TMath::Erfc(spx*x1) - TMath::Erfc(spx*x2);
671 cout <<"el="<<el<<" ix0="<<ix0<<" ix="<<ix<<" x0="<<x<<
672 " iz0="<<iz0<<" iz="<<iz<<" z0="<<z<<
673 " spx*x1="<<spx*x1<<" spx*x2="<<spx*x2<<" s="<<s;
675 s *= TMath::Erfc(spz*z1) - TMath::Erfc(spz*z2);
677 cout<<" spz*z1="<<spz*z1<<" spz*z2="<<spz*z2<<" s="<<s<< endl;
679 GetMap()->AddSignal(iz,ix,t,hi,GetModuleNumber(),s*el);
682 //______________________________________________________________________
683 void AliITSsimulationSPD::RemoveDeadPixels(AliITSmodule *mod){
684 // Removes dead pixels on each module (ladder)
686 // Module Index (0,239)
692 Int_t moduleNr = mod->GetIndex();
693 Int_t nrDead = fCalObj[moduleNr]->GetNrDead();
694 for (Int_t i=0; i<nrDead; i++) {
695 GetMap()->DeleteHit(fCalObj[moduleNr]->GetDeadColAt(i),fCalObj[moduleNr]->GetDeadRowAt(i));
698 //______________________________________________________________________
699 void AliITSsimulationSPD::FrompListToDigits(){
700 // add noise and electronics, perform the zero suppression and add the
708 static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
710 Double_t electronics;
712 const Int_t knmaxtrk=AliITSdigit::GetNTracks();
713 static AliITSdigitSPD dig;
714 AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(fDetType->GetITSgeom()->GetStartSPD());
715 if(GetDebug(1)) Info("FrompListToDigits","()");
716 for(iz=0; iz<GetNPixelsZ(); iz++) for(ix=0; ix<GetNPixelsX(); ix++){
717 // NEW (for the moment plugged by hand, in the future possibly read from Data Base)
718 // here parametrize the efficiency of the pixel along the row for the test columns (1,9,17,25)
719 // if(iz==1 || iz == 9 || iz == 17 || iz == 25) {
720 // Double_t eff,p1=0.,p2=0.;
723 // case 1: p1=0.63460;p2=0.42438E-01;break;
724 // case 9: p1=0.41090;p2=0.75914E-01;break;
725 // case 17: p1=0.31883;p2=0.91502E-01;break;
726 // case 25: p1=0.48828;p2=0.57975E-01;break;
728 // eff=1.-p1*exp(-p2*x);
729 // if (gRandom->Rndm() >= eff) continue;
731 // END parametrize the efficiency
733 electronics = res->ApplyBaselineAndNoise();
734 UpdateMapNoise(ix,iz,electronics);
736 // Apply Threshold and write Digits.
737 sig = GetMap()->GetSignalOnly(iz,ix);
738 FillHistograms(ix,iz,sig+electronics);
740 cout<<sig<<"+"<<electronics<<">threshold("<<ix<<","<<iz
741 <<")="<<GetThreshold() <<endl;
743 if (sig+electronics <= GetThreshold()) continue;
748 // dig.SetSignalSPD((Int_t) GetMap()->GetSignal(iz,ix));
749 Double_t aSignal = GetMap()->GetSignal(iz,ix);
750 if (TMath::Abs(aSignal)>2147483647.0) {
751 //PH 2147483647 is the max. integer
752 //PH This apparently is a problem which needs investigation
753 AliWarning(Form("Too big or too small signal value %f",aSignal));
754 aSignal = TMath::Sign((Double_t)2147483647,aSignal);
756 dig.SetSignalSPD((Int_t)aSignal);
758 for(j=0;j<knmaxtrk;j++){
759 if (j<GetMap()->GetNEntries()) {
760 dig.SetTrack(j,GetMap()->GetTrack(iz,ix,j));
761 dig.SetHit(j,GetMap()->GetHit(iz,ix,j));
762 }else { // Default values
768 cout<<iz<<","<<ix<<","<<*(GetMap()->GetpListItem(iz,ix))<<endl;
770 aliITS->AddSimDigit(0,&dig);
773 //______________________________________________________________________
774 void AliITSsimulationSPD::CreateHistograms(){
775 // create 1D histograms for tests
783 if(GetDebug(1)) Info("CreateHistograms","create histograms");
785 fHis = new TObjArray(GetNPixelsZ());
786 TString fSPDname("spd_");
787 for(Int_t i=0;i<GetNPixelsZ();i++) {
789 sprintf(pixelz,"%d",i);
790 fSPDname.Append(pixelz);
791 fHis->AddAt(new TH1F(fSPDname.Data(),"SPD maps",
792 GetNPixelsX(),0.,(Double_t)GetNPixelsX()),i);
795 //______________________________________________________________________
796 void AliITSsimulationSPD::FillHistograms(Int_t ix,Int_t iz,Double_t v){
797 // Fill the histogram
805 if(!GetHistArray()) return; // Only fill if setup.
806 if(GetDebug(2)) Info("FillHistograms","fill histograms");
807 GetHistogram(iz)->Fill(ix,v);
809 //______________________________________________________________________
810 void AliITSsimulationSPD::ResetHistograms(){
811 // Reset histograms for this detector
819 if(!GetHistArray()) return; // Only fill if setup.
820 if(GetDebug(2)) Info("FillHistograms","fill histograms");
821 for ( int i=0;i<GetNPixelsZ();i++ ) {
822 if (fHis->At(i)) ((TH1F*)fHis->At(i))->Reset();
826 //______________________________________________________________________
827 void AliITSsimulationSPD::SetCoupling(Int_t col, Int_t row, Int_t ntrack,
829 // Take into account the coupling between adiacent pixels.
830 // The parameters probcol and probrow are the probability of the
831 // signal in one pixel shared in the two adjacent pixels along
832 // the column and row direction, respectively.
833 // Note pList is goten via GetMap() and module is not need any more.
834 // Otherwise it is identical to that coded by Tiziano Virgili (BSN).
837 <img src="picts/ITS/barimodel_3.gif">
840 <font size=+2 color=red>
841 <a href="mailto:tiziano.virgili@cern.ch"></a>.
847 // Int_t col z cell index
848 // Int_t row x cell index
849 // Int_t ntrack track incex number
850 // Int_t idhit hit index number
856 Double_t pulse1,pulse2;
857 Double_t couplR=0.0,couplC=0.0;
860 GetCouplings(couplC,couplR);
861 if(GetDebug(3)) Info("SetCoupling","(col=%d,row=%d,ntrack=%d,idhit=%d) "
862 "Calling SetCoupling couplC=%e couplR=%e",
863 col,row,ntrack,idhit,couplC,couplR);
866 pulse1 = GetMap()->GetSignalOnly(col,row);
868 for (Int_t isign=-1;isign<=1;isign+=2){// loop in col direction
871 xr = gRandom->Rndm();
872 if ((j1<0) || (j1>GetNPixelsZ()-1) || (xr>couplC)){
876 UpdateMapSignal(row,j1,ntrack,idhit,pulse1);
878 flag = 1; // only first next!!
881 // loop in row direction
884 xr = gRandom->Rndm();
885 if ((j2<0) || (j2>GetNPixelsX()-1) || (xr>couplR)){
889 UpdateMapSignal(j2,col,ntrack,idhit,pulse2);
891 flag = 1; // only first next!!
896 //______________________________________________________________________
897 void AliITSsimulationSPD::SetCouplingOld(Int_t col, Int_t row,
898 Int_t ntrack,Int_t idhit) {
899 // Take into account the coupling between adiacent pixels.
900 // The parameters probcol and probrow are the fractions of the
901 // signal in one pixel shared in the two adjacent pixels along
902 // the column and row direction, respectively.
905 <img src="picts/ITS/barimodel_3.gif">
908 <font size=+2 color=red>
909 <a href="mailto:Rocco.Caliandro@ba.infn.it"></a>.
915 // Int_t col z cell index
916 // Int_t row x cell index
917 // Int_t ntrack track incex number
918 // Int_t idhit hit index number
919 // Int_t module module number
925 Double_t pulse1,pulse2;
926 Double_t couplR=0.0,couplC=0.0;
928 GetCouplings(couplC,couplR);
931 // cout << "Threshold --> " << GetThreshold() << endl; // dom
932 // cout << "Couplings --> " << couplC << " " << couplR << endl; //dom
935 if(GetDebug(3)) Info("SetCouplingOld","(col=%d,row=%d,ntrack=%d,idhit=%d) "
936 "Calling SetCoupling couplC=%e couplR=%e",
937 col,row,ntrack,idhit,couplC,couplR);
938 for (Int_t isign=-1;isign<=1;isign+=2){// loop in col direction
939 pulse1 = GetMap()->GetSignalOnly(col,row);
946 if ((j1<0)||(j1>GetNPixelsZ()-1)||(pulse1<GetThreshold())){
947 pulse1 = GetMap()->GetSignalOnly(col,row);
951 UpdateMapSignal(row,j1,ntrack,idhit,pulse1);
953 flag = 1; // only first next !!
956 // loop in row direction
960 if((j2<0)||(j2>(GetNPixelsX()-1))||(pulse2<GetThreshold())){
961 pulse2 = GetMap()->GetSignalOnly(col,row);
965 UpdateMapSignal(j2,col,ntrack,idhit,pulse2);
967 flag = 1; // only first next!!