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>
23 #include <TParticle.h>
27 #include "AliITSMapA2.h"
28 #include "AliITSdigitSPD.h"
29 #include "AliITSgeom.h"
30 #include "AliITShit.h"
31 #include "AliITSmodule.h"
32 #include "AliITSpList.h"
33 #include "AliITSCalibrationSPD.h"
34 #include "AliITSsegmentationSPD.h"
35 #include "AliITSsimulationSPD.h"
41 ClassImp(AliITSsimulationSPD)
42 ////////////////////////////////////////////////////////////////////////
44 // Modified by Bjorn S. Nilsen, G.E. Bruno, H. Tydesjo
48 // Written by Boris Batyunya
52 // AliITSsimulationSPD is to do the simulation of SPDs.
54 ////////////////////////////////////////////////////////////////////////
56 //______________________________________________________________________
57 AliITSsimulationSPD::AliITSsimulationSPD():
62 // Default constructor.
68 // A default constructed AliITSsimulationSPD class.
70 AliDebug(1,Form("Calling default constructor"));
73 //______________________________________________________________________
74 AliITSsimulationSPD::AliITSsimulationSPD(AliITSDetTypeSim *dettyp):
75 AliITSsimulation(dettyp),
79 // standard constructor
81 // AliITSsegmentation *seg A pointer to the segmentation class
82 // to be used for this simulation
83 // AliITSCalibration *resp A pointer to the responce class to
84 // be used for this simulation
88 // A default constructed AliITSsimulationSPD class.
90 AliDebug(1,Form("Calling standard constructor "));
91 // AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(fDetType->GetITSgeom()->GetStartSPD());
92 // res->SetTemperature(0.0);
93 // res->SetDistanceOverVoltage(0.0);
96 //______________________________________________________________________
97 void AliITSsimulationSPD::Init(){
105 const Double_t kmictocm = 1.0e-4; // convert microns to cm.
109 SetMap(new AliITSpList(GetNPixelsZ(),GetNPixelsX()));
110 AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(fDetType->GetITSgeom()->GetStartSPD());
111 AliITSsegmentationSPD* seg = (AliITSsegmentationSPD*)GetSegmentationModel(0);
112 Double_t bias = res->GetBiasVoltage();
113 // cout << "Bias Voltage --> " << bias << endl; // dom
114 res->SetDistanceOverVoltage(kmictocm*seg->Dy(),bias);
115 // set kind of coupling ("old" or "new")
117 res->GetCouplingOption(opt);
118 char *old = strstr(opt,"old");
125 // Get the calibration objects for each module(ladder)
126 GetCalibrationObjects(0); //RunNr 0 hard coded for now
129 //______________________________________________________________________
130 AliITSsimulationSPD::~AliITSsimulationSPD(){
144 //______________________________________________________________________
145 AliITSsimulationSPD::AliITSsimulationSPD(const
147 &s) : AliITSsimulation(s){
150 // AliITSsimulationSPD &s The original class for which
151 // this class is a copy of
159 //______________________________________________________________________
160 AliITSsimulationSPD& AliITSsimulationSPD::operator=(const
161 AliITSsimulationSPD &s){
162 // Assignment operator
164 // AliITSsimulationSPD &s The original class for which
165 // this class is a copy of
170 if(&s == this) return *this;
172 fCoupling = s.fCoupling;
173 fSPDname = s.fSPDname;
176 //______________________________________________________________________
177 AliITSsimulation& AliITSsimulationSPD::operator=(const
178 AliITSsimulation &s){
179 // Assignment operator
181 // AliITSsimulationSPD &s The original class for which
182 // this class is a copy of
187 if(&s == this) return *this;
188 Error("AliITSsimulationSPD","Not allowed to make a = with "
189 "AliITSsimulationSPD","Using default creater instead");
194 //______________________________________________________________________
195 void AliITSsimulationSPD::GetCalibrationObjects(Int_t RunNr) {
196 AliCDBManager* man = AliCDBManager::Instance();
197 if(!man->IsDefaultStorageSet()) {
198 man->SetDefaultStorage("local://$ALICE_ROOT");
200 AliCDBEntry *entrySPD = man->Get("ITS/Calib/CalibSPD", RunNr);
202 AliWarning("Cannot find SPD calibration entry!");
205 TObjArray *respSPD = (TObjArray *)entrySPD->GetObject();
207 AliWarning("Cannot get data from SPD database entry!");
210 for (Int_t mod=0; mod<240; mod++) {
211 calObj[mod] = (AliITSCalibrationSPD*) respSPD->At(mod);
215 //______________________________________________________________________
216 void AliITSsimulationSPD::InitSimulationModule(Int_t module, Int_t event){
217 // This function creates maps to build the list of tracks for each
218 // summable digit. Inputs defined by base class.
220 // Int_t module // Module number to be simulated
221 // Int_t event // Event number to be simulated
227 AliDebug(1,Form("(module=%d,event=%d)",module,event));
228 SetModuleNumber(module);
229 SetEventNumber(event);
232 //_____________________________________________________________________
233 void AliITSsimulationSPD::SDigitiseModule(AliITSmodule *mod,Int_t,
235 // This function begins the work of creating S-Digits. Inputs defined
238 // AliITSmodule *mod // module
240 // Int_t event // Event number
244 // test // test returns kTRUE if the module contained hits
245 // // test returns kFALSE if it did not contain hits
247 AliDebug(1,Form("(mod=%p, ,event=%d)",mod,event));
248 if(!(mod->GetNhits())){
249 AliDebug(1,Form("In event %d module %d there are %d hits returning.",
250 event, mod->GetIndex(),mod->GetNhits()));
251 return;// if module has no hits don't create Sdigits
253 SetModuleNumber(mod->GetIndex());
254 SetEventNumber(event);
256 HitToSDigitFast(mod);
260 //______________________________________________________________________
261 void AliITSsimulationSPD::WriteSDigits(){
262 // This function adds each S-Digit to pList
269 Int_t ix, nix, iz, niz;
270 static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
272 AliDebug(1,Form("Writing SDigits for module %d",GetModuleNumber()));
273 GetMap()->GetMaxMapIndex(niz, nix);
274 for(iz=0; iz<niz; iz++)for(ix=0; ix<nix; ix++){
275 if(GetMap()->GetSignalOnly(iz,ix)>0.0){
276 aliITS->AddSumDigit(*(GetMap()->GetpListItem(iz,ix)));
277 if(AliDebugLevel()>0) {
278 AliDebug(1,Form("%d, %d",iz,ix));
279 cout << *(GetMap()->GetpListItem(iz,ix)) << endl;
281 } // end if GetMap()->GetSignalOnly(iz,ix)>0.0
285 //______________________________________________________________________
286 void AliITSsimulationSPD::FinishSDigitiseModule(){
287 // This function calls SDigitsToDigits which creates Digits from SDigits
296 pListToDigits(); // Charge To Signal both adds noise and
300 //______________________________________________________________________
301 void AliITSsimulationSPD::DigitiseModule(AliITSmodule *mod,Int_t,
303 // This function creates Digits straight from the hits and then adds
304 // electronic noise to the digits before adding them to pList
305 // Each of the input variables is passed along to HitToSDigit
307 // AliITSmodule *mod module
315 AliDebug(1,Form("(mod=%p,,)",mod));
317 HitToSDigitFast(mod);
318 RemoveDeadPixels(mod);
322 //______________________________________________________________________
323 void AliITSsimulationSPD::HitToSDigit(AliITSmodule *mod){
324 // Does the charge distributions using Gaussian diffusion charge charing.
326 // AliITSmodule *mod Pointer to this module
331 const Double_t kmictocm = 1.0e-4; // convert microns to cm.
332 TObjArray *hits = mod->GetHits();
333 Int_t nhits = hits->GetEntriesFast();
336 Double_t x0=0.0,x1=0.0,y0=0.0,y1=0.0,z0=0.0,z1=0.0,de=0.0;
337 Double_t x,y,z,t,tp,st,dt=0.2,el,sig,sigx,sigz,fda;
338 AliITSsegmentationSPD* seg = (AliITSsegmentationSPD*)GetSegmentationModel(0);
339 AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(fDetType->GetITSgeom()->GetStartSPD());
340 Double_t thick = 0.5*kmictocm*seg->Dy(); // Half Thickness
341 res->GetSigmaDiffusionAsymmetry(fda);
343 AliDebug(1,Form("(mod=%p) fCoupling=%d",mod,fCoupling));
345 for(h=0;h<nhits;h++){
346 if(AliDebugLevel()>0) {
347 AliDebug(1,Form("Hits, %d", h));
348 cout << *(mod->GetHit(h)) << endl;
350 if(!mod->LineSegmentL(h,x0,x1,y0,y1,z0,z1,de,idtrack)) continue;
351 st = TMath::Sqrt(x1*x1+y1*y1+z1*z1);
353 st = (Double_t)((Int_t)(st/kmictocm)); // number of microns
354 if(st<=1.0) st = 1.0;
356 for(t=0.0;t<1.0;t+=dt){ // Integrate over t
361 if(!(seg->LocalToDet(x,z,ix,iz))) continue; // outside
362 el = res->GeVToCharge((Double_t)(dt*de));
364 if(el<=0.0) cout<<"el="<<el<<" dt="<<dt
367 sig = res->SigmaDiffusion1D(TMath::Abs(thick + y));
368 // SpreadCharge(x,z,ix,iz,el,sig,idtrack,h);
371 SpreadChargeAsym(x,z,ix,iz,el,sigx,sigz,idtrack,h);
372 cout << "sigx, sigz, y "<< sigx << " " << sigz<< " " << TMath::Abs(thick + y) << endl;// ciccio
374 } else { // st == 0.0 deposit it at this point
378 if(!(seg->LocalToDet(x,z,ix,iz))) continue; // outside
379 el = res->GeVToCharge((Double_t)de);
380 sig = res->SigmaDiffusion1D(TMath::Abs(thick + y));
381 // SpreadCharge(x,z,ix,iz,el,sig,idtrack,h);
384 SpreadChargeAsym(x,z,ix,iz,el,sigx,sigz,idtrack,h);
391 // x is column and z is row (see AliITSsegmentationSPD::GetPadIxz)
392 for(i=0;i<GetMap()->GetEntries();i++)
393 if(GetMap()->GetpListItem(i)==0) continue;
395 GetMap()->GetMapIndex(
396 GetMap()->GetpListItem(i)->GetIndex(),iz,ix);
397 SetCoupling(iz,ix,idtrack,h);
401 // x is column and z is row (see AliITSsegmentationSPD::GetPadIxz)
402 for(i=0;i<GetMap()->GetEntries();i++)
403 if(GetMap()->GetpListItem(i)==0) continue;
405 GetMap()->GetMapIndex(
406 GetMap()->GetpListItem(i)->GetIndex(),iz,ix);
407 SetCouplingOld(iz,ix,idtrack,h);
411 } // Loop over all hits h
412 if(GetDebug(2))Info("HitToSDigit","Finished fCoupling=%d",fCoupling);
414 //______________________________________________________________________
415 void AliITSsimulationSPD::HitToSDigitFast(AliITSmodule *mod){
416 // Does the charge distributions using Gaussian diffusion charge charing. // Inputs:
417 // AliITSmodule *mod Pointer to this module
422 const Double_t kmictocm = 1.0e-4; // convert microns to cm.
424 const Double_t ti[n10]={7.443716945e-3,2.166976971e-1,3.397047841e-1,
425 4.325316833e-1,4.869532643e-1,5.130467358e-1,
426 5.674683167e-1,6.602952159e-1,7.833023029e-1,
428 const Double_t wi[n10]={1.477621124e-1,1.346333597e-1,1.095431813e-1,
429 7.472567455e-2,3.333567215e-2,3.333567215e-2,
430 7.472567455e-2,1.095431813e-1,1.346333597e-1,
432 TObjArray *hits = mod->GetHits();
433 Int_t nhits = hits->GetEntriesFast();
436 Double_t x0=0.0,x1=0.0,y0=0.0,y1=0.0,z0=0.0,z1=0.0,de=0.0;
437 Double_t x,y,z,t,st,el,sig,sigx,sigz,fda;
438 AliITSsegmentationSPD* seg = (AliITSsegmentationSPD*)GetSegmentationModel(0);
439 AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(fDetType->GetITSgeom()->GetStartSPD());
440 Double_t thick = 0.5*kmictocm*seg->Dy(); // Half thickness
441 res->GetSigmaDiffusionAsymmetry(fda);
442 // cout << "Half Thickness " << thick << endl; // dom
443 // cout << "Diffusion asymm " << fda << endl; // dom
445 AliDebug(1,Form("(mod=%p) fCoupling=%d",mod,fCoupling));
447 for(h=0;h<nhits;h++){
448 if(AliDebugLevel()>0) {
449 AliDebug(1,Form("Hits, %d", h));
450 cout << *(mod->GetHit(h)) << endl;
452 if(!mod->LineSegmentL(h,x0,x1,y0,y1,z0,z1,de,idtrack)) continue;
453 st = TMath::Sqrt(x1*x1+y1*y1+z1*z1);
454 if(st>0.0) for(i=0;i<n10;i++){ // Integrate over t
459 if(!(seg->LocalToDet(x,z,ix,iz))) continue; // outside
460 // el = res->GeVToCharge((Double_t)(dt*de));
461 // el = 1./n10*res->GeVToCharge((Double_t)de);
462 el = wi[i]*res->GeVToCharge((Double_t)de);
464 if(el<=0.0) cout<<"el="<<el<<" wi["<<i<<"]="<<wi[i]
467 sig = res->SigmaDiffusion1D(TMath::Abs(thick + y));
470 //SpreadCharge(x,z,ix,iz,el,sig,idtrack,h);
471 SpreadChargeAsym(x,z,ix,iz,el,sigx,sigz,idtrack,h);
472 // cout << "sigx sigz " << sigx << " " << sigz << endl; // dom
473 } // end for i // End Integrate over t
474 else { // st == 0.0 deposit it at this point
478 if(!(seg->LocalToDet(x,z,ix,iz))) continue; // outside
479 el = res->GeVToCharge((Double_t)de);
480 sig = res->SigmaDiffusion1D(TMath::Abs(thick + y));
481 //SpreadCharge(x,z,ix,iz,el,sig,idtrack,h);
484 SpreadChargeAsym(x,z,ix,iz,el,sigx,sigz,idtrack,h);
491 // x is column and z is row (see AliITSsegmentationSPD::GetPadIxz)
492 for(i=0;i<GetMap()->GetEntries();i++)
493 if(GetMap()->GetpListItem(i)==0) continue;
495 GetMap()->GetMapIndex(
496 GetMap()->GetpListItem(i)->GetIndex(),iz,ix);
497 SetCoupling(iz,ix,idtrack,h);
501 // x is column and z is row (see AliITSsegmentationSPD::GetPadIxz)
502 for(i=0;i<GetMap()->GetEntries();i++)
503 if(GetMap()->GetpListItem(i)==0) continue;
505 GetMap()->GetMapIndex(
506 GetMap()->GetpListItem(i)->GetIndex(),iz,ix); SetCouplingOld(iz,ix,idtrack,h);
510 } // Loop over all hits h
511 if(GetDebug(2))Info("HitToSDigit","Finished fCoupling=%d",fCoupling);
513 //______________________________________________________________________
514 void AliITSsimulationSPD::SpreadCharge(Double_t x0,Double_t z0,
516 Double_t el,Double_t sig,Int_t t,
518 // Spreads the charge over neighboring cells. Assume charge is distributed
519 // as charge(x,z) = (el/2*pi*sig*sig)*exp(-arg)
520 // arg=((x-x0)*(x-x0)/2*sig*sig)+((z-z0*z-z0)/2*sig*sig)
521 // Defined this way, the integral over all x and z is el.
523 // Double_t x0 x position of point where charge is liberated
524 // Double_t y0 y position of point where charge is liberated
525 // Double_t z0 z position of point where charge is liberated
526 // Int_t ix0 row of cell corresponding to point x0
527 // Int_t iz0 columb of cell corresponding to point z0
528 // Double_t el number of electrons liberated in this step
529 // Double_t sig Sigma difusion for this step (y0 dependent)
530 // Int_t t track number
531 // Int_t ti hit track index number
532 // Int_t hi hit "hit" index number
537 const Int_t knx = 3,knz = 2;
538 const Double_t kRoot2 = 1.414213562; // Sqrt(2).
539 const Double_t kmictocm = 1.0e-4; // convert microns to cm.
540 Int_t ix,iz,ixs,ixe,izs,ize;
542 Double_t x1,x2,z1,z2,s,sp;
543 AliITSsegmentationSPD* seg = (AliITSsegmentationSPD*)GetSegmentationModel(0);
546 if(GetDebug(4)) Info("SpreadCharge","(x0=%e,z0=%e,ix0=%d,iz0=%d,el=%e,"
547 "sig=%e,t=%d,i=%d)",x0,z0,ix0,iz0,el,sig,t,hi);
548 if(sig<=0.0) { // if sig<=0 No diffusion to simulate.
549 GetMap()->AddSignal(iz0,ix0,t,hi,GetModuleNumber(),el);
551 cout << "sig<=0.0=" << sig << endl;
555 sp = 1.0/(sig*kRoot2);
557 cout << "sig=" << sig << " sp=" << sp << endl;
559 ixs = TMath::Max(-knx+ix0,0);
560 ixe = TMath::Min(knx+ix0,seg->Npx()-1);
561 izs = TMath::Max(-knz+iz0,0);
562 ize = TMath::Min(knz+iz0,seg->Npz()-1);
563 for(ix=ixs;ix<=ixe;ix++) for(iz=izs;iz<=ize;iz++){
564 seg->DetToLocal(ix,iz,x,z); // pixel center
567 x2 = x1 + 0.5*kmictocm*seg->Dpx(ix); // Upper
568 x1 -= 0.5*kmictocm*seg->Dpx(ix); // Lower
569 z2 = z1 + 0.5*kmictocm*seg->Dpz(iz); // Upper
570 z1 -= 0.5*kmictocm*seg->Dpz(iz); // Lower
571 x1 -= x0; // Distance from where track traveled
572 x2 -= x0; // Distance from where track traveled
573 z1 -= z0; // Distance from where track traveled
574 z2 -= z0; // Distance from where track traveled
575 s = 0.25; // Correction based on definision of Erfc
576 s *= TMath::Erfc(sp*x1) - TMath::Erfc(sp*x2);
578 cout <<"el="<<el<<" ix0="<<ix0<<" ix="<<ix<<" x0="<<x<<
579 " iz0="<<iz0<<" iz="<<iz<<" z0="<<z<<
580 " sp*x1="<<sp*x1<<" sp*x2="<<sp*x2<<" s="<<s;
582 s *= TMath::Erfc(sp*z1) - TMath::Erfc(sp*z2);
584 cout<<" sp*z1="<<sp*z1<<" sp*z2="<<sp*z2<<" s="<<s<< endl;
586 GetMap()->AddSignal(iz,ix,t,hi,GetModuleNumber(),s*el);
589 //______________________________________________________________________
590 void AliITSsimulationSPD::SpreadChargeAsym(Double_t x0,Double_t z0,
592 Double_t el,Double_t sigx,Double_t sigz,
594 // Spreads the charge over neighboring cells. Assume charge is distributed
595 // as charge(x,z) = (el/2*pi*sigx*sigz)*exp(-arg)
596 // arg=((x-x0)*(x-x0)/2*sigx*sigx)+((z-z0*z-z0)/2*sigz*sigz)
597 // Defined this way, the integral over all x and z is el.
599 // Double_t x0 x position of point where charge is liberated
600 // Double_t y0 y position of point where charge is liberated
601 // Double_t z0 z position of point where charge is liberated
602 // Int_t ix0 row of cell corresponding to point x0
603 // Int_t iz0 columb of cell corresponding to point z0
604 // Double_t el number of electrons liberated in this step
605 // Double_t sigx Sigma difusion along x for this step (y0 dependent)
606 // Double_t sigz Sigma difusion along z for this step (y0 dependent)
607 // Int_t t track number
608 // Int_t ti hit track index number
609 // Int_t hi hit "hit" index number
614 const Int_t knx = 3,knz = 2;
615 const Double_t kRoot2 = 1.414213562; // Sqrt(2).
616 const Double_t kmictocm = 1.0e-4; // convert microns to cm.
617 Int_t ix,iz,ixs,ixe,izs,ize;
619 Double_t x1,x2,z1,z2,s,spx,spz;
620 AliITSsegmentationSPD* seg = (AliITSsegmentationSPD*)GetSegmentationModel(0);
623 if(GetDebug(4)) Info("SpreadCharge","(x0=%e,z0=%e,ix0=%d,iz0=%d,el=%e,"
624 "sig=%e,t=%d,i=%d)",x0,z0,ix0,iz0,el,sigx,sigz,t,hi);
625 if(sigx<=0.0 || sigz<=0.0) { // if sig<=0 No diffusion to simulate.
626 GetMap()->AddSignal(iz0,ix0,t,hi,GetModuleNumber(),el);
628 cout << "sigx<=0.0=" << sigx << endl;
629 cout << "sigz<=0.0=" << sigz << endl;
633 spx = 1.0/(sigx*kRoot2); spz = 1.0/(sigz*kRoot2);
635 cout << "sigx=" << sigx << " spx=" << spx << endl;
636 cout << "sigz=" << sigz << " spz=" << spz << endl;
638 ixs = TMath::Max(-knx+ix0,0);
639 ixe = TMath::Min(knx+ix0,seg->Npx()-1);
640 izs = TMath::Max(-knz+iz0,0);
641 ize = TMath::Min(knz+iz0,seg->Npz()-1);
642 for(ix=ixs;ix<=ixe;ix++) for(iz=izs;iz<=ize;iz++){
643 seg->DetToLocal(ix,iz,x,z); // pixel center
646 x2 = x1 + 0.5*kmictocm*seg->Dpx(ix); // Upper
647 x1 -= 0.5*kmictocm*seg->Dpx(ix); // Lower
648 z2 = z1 + 0.5*kmictocm*seg->Dpz(iz); // Upper
649 z1 -= 0.5*kmictocm*seg->Dpz(iz); // Lower
650 x1 -= x0; // Distance from where track traveled
651 x2 -= x0; // Distance from where track traveled
652 z1 -= z0; // Distance from where track traveled
653 z2 -= z0; // Distance from where track traveled
654 s = 0.25; // Correction based on definision of Erfc
655 s *= TMath::Erfc(spx*x1) - TMath::Erfc(spx*x2);
657 cout <<"el="<<el<<" ix0="<<ix0<<" ix="<<ix<<" x0="<<x<<
658 " iz0="<<iz0<<" iz="<<iz<<" z0="<<z<<
659 " spx*x1="<<spx*x1<<" spx*x2="<<spx*x2<<" s="<<s;
661 s *= TMath::Erfc(spz*z1) - TMath::Erfc(spz*z2);
663 cout<<" spz*z1="<<spz*z1<<" spz*z2="<<spz*z2<<" s="<<s<< endl;
665 GetMap()->AddSignal(iz,ix,t,hi,GetModuleNumber(),s*el);
668 //______________________________________________________________________
669 void AliITSsimulationSPD::RemoveDeadPixels(AliITSmodule *mod){
670 Int_t module_nr = mod->GetIndex();
671 Int_t nr_dead = calObj[module_nr]->GetNrDead();
672 for (Int_t i=0; i<nr_dead; i++) {
673 GetMap()->DeleteHit(calObj[module_nr]->GetDeadColAt(i),calObj[module_nr]->GetDeadRowAt(i));
676 //______________________________________________________________________
677 void AliITSsimulationSPD::pListToDigits(){
678 // add noise and electronics, perform the zero suppression and add the
686 static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
688 Double_t electronics;
690 const Int_t nmaxtrk=AliITSdigitSPD::GetNTracks();
691 static AliITSdigitSPD dig;
692 AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(fDetType->GetITSgeom()->GetStartSPD());
693 if(GetDebug(1)) Info("pListToDigits","()");
694 for(iz=0; iz<GetNPixelsZ(); iz++) for(ix=0; ix<GetNPixelsX(); ix++){
695 // NEW (for the moment plugged by hand, in the future possibly read from Data Base)
696 // here parametrize the efficiency of the pixel along the row for the test columns (1,9,17,25)
697 // if(iz==1 || iz == 9 || iz == 17 || iz == 25) {
698 // Double_t eff,p1=0.,p2=0.;
701 // case 1: p1=0.63460;p2=0.42438E-01;break;
702 // case 9: p1=0.41090;p2=0.75914E-01;break;
703 // case 17: p1=0.31883;p2=0.91502E-01;break;
704 // case 25: p1=0.48828;p2=0.57975E-01;break;
706 // eff=1.-p1*exp(-p2*x);
707 // if (gRandom->Rndm() >= eff) continue;
709 // END parametrize the efficiency
711 electronics = res->ApplyBaselineAndNoise();
712 UpdateMapNoise(ix,iz,electronics);
714 // Apply Threshold and write Digits.
715 sig = GetMap()->GetSignalOnly(iz,ix);
716 FillHistograms(ix,iz,sig+electronics);
718 cout<<sig<<"+"<<electronics<<">threshold("<<ix<<","<<iz
719 <<")="<<GetThreshold() <<endl;
721 if (sig+electronics <= GetThreshold()) continue;
725 dig.SetSignalSPD((Int_t) GetMap()->GetSignal(iz,ix));
726 for(j=0;j<nmaxtrk;j++){
727 if (j<GetMap()->GetNEntries()) {
728 dig.SetTrack(j,GetMap()->GetTrack(iz,ix,j));
729 dig.SetHit(j,GetMap()->GetHit(iz,ix,j));
730 }else { // Default values
736 cout<<iz<<","<<ix<<","<<*(GetMap()->GetpListItem(iz,ix))<<endl;
738 aliITS->AddSimDigit(0,&dig);
741 //______________________________________________________________________
742 void AliITSsimulationSPD::CreateHistograms(){
743 // create 1D histograms for tests
751 if(GetDebug(1)) Info("CreateHistograms","create histograms");
753 fHis = new TObjArray(GetNPixelsZ());
754 TString fSPDname("spd_");
755 for(Int_t i=0;i<GetNPixelsZ();i++) {
757 sprintf(pixelz,"%d",i);
758 fSPDname.Append(pixelz);
759 fHis->AddAt(new TH1F(fSPDname.Data(),"SPD maps",
760 GetNPixelsX(),0.,(Double_t)GetNPixelsX()),i);
763 //______________________________________________________________________
764 void AliITSsimulationSPD::FillHistograms(Int_t ix,Int_t iz,Double_t v){
765 // Fill the histogram
773 if(!GetHistArray()) return; // Only fill if setup.
774 if(GetDebug(2)) Info("FillHistograms","fill histograms");
775 GetHistogram(iz)->Fill(ix,v);
777 //______________________________________________________________________
778 void AliITSsimulationSPD::ResetHistograms(){
779 // Reset histograms for this detector
787 if(!GetHistArray()) return; // Only fill if setup.
788 if(GetDebug(2)) Info("FillHistograms","fill histograms");
789 for ( int i=0;i<GetNPixelsZ();i++ ) {
790 if (fHis->At(i)) ((TH1F*)fHis->At(i))->Reset();
794 //______________________________________________________________________
795 void AliITSsimulationSPD::SetCoupling(Int_t row, Int_t col, Int_t ntrack,
797 // Take into account the coupling between adiacent pixels.
798 // The parameters probcol and probrow are the probability of the
799 // signal in one pixel shared in the two adjacent pixels along
800 // the column and row direction, respectively.
801 // Note pList is goten via GetMap() and module is not need any more.
802 // Otherwise it is identical to that coded by Tiziano Virgili (BSN).
805 <img src="picts/ITS/barimodel_3.gif">
808 <font size=+2 color=red>
809 <a href="mailto:tiziano.virgili@cern.ch"></a>.
815 // Int_t row z cell index
816 // Int_t col x cell index
817 // Int_t ntrack track incex number
818 // Int_t idhit hit index number
824 Double_t pulse1,pulse2;
825 Double_t couplR=0.0,couplC=0.0;
828 GetCouplings(couplC,couplR);
829 if(GetDebug(3)) Info("SetCoupling","(row=%d,col=%d,ntrack=%d,idhit=%d) "
830 "Calling SetCoupling couplR=%e couplC=%e",
831 row,col,ntrack,idhit,couplR,couplC);
834 pulse1 = GetMap()->GetSignalOnly(row,col);
836 for (Int_t isign=-1;isign<=1;isign+=2){// loop in row direction
840 xr = gRandom->Rndm();
841 //if ((j1<0)||(j1>GetNPixelsZ()-1)||(pulse1<GetThreshold())){
842 if ((j1<0) || (j1>GetNPixelsZ()-1) || (xr>couplR)){
846 UpdateMapSignal(col,j1,ntrack,idhit,pulse1);
848 flag = 1; // only first next!!
851 // loop in column direction
855 xr = gRandom->Rndm();
856 //if((j2<0)||j2>(GetNPixelsX()-1)||pulse2<GetThreshold()){
857 if ((j2<0) || (j2>GetNPixelsX()-1) || (xr>couplC)){
861 UpdateMapSignal(j2,row,ntrack,idhit,pulse2);
863 flag = 1; // only first next!!
868 //______________________________________________________________________
869 void AliITSsimulationSPD::SetCouplingOld(Int_t row, Int_t col,
870 Int_t ntrack,Int_t idhit) {
871 // Take into account the coupling between adiacent pixels.
872 // The parameters probcol and probrow are the fractions of the
873 // signal in one pixel shared in the two adjacent pixels along
874 // the column and row direction, respectively.
877 <img src="picts/ITS/barimodel_3.gif">
880 <font size=+2 color=red>
881 <a href="mailto:Rocco.Caliandro@ba.infn.it"></a>.
887 // Int_t row z cell index
888 // Int_t col x cell index
889 // Int_t ntrack track incex number
890 // Int_t idhit hit index number
891 // Int_t module module number
897 Double_t pulse1,pulse2;
898 Double_t couplR=0.0,couplC=0.0;
900 GetCouplings(couplC,couplR);
903 // cout << "Threshold --> " << GetThreshold() << endl; // dom
904 // cout << "Couplings --> " << couplC << " " << couplR << endl; //dom
907 if(GetDebug(3)) Info("SetCouplingOld","(row=%d,col=%d,ntrack=%d,idhit=%d) "
908 "Calling SetCoupling couplR=%e couplC=%e",
909 row,col,ntrack,idhit,couplR,couplC);
910 for (Int_t isign=-1;isign<=1;isign+=2){// loop in row direction
911 pulse1 = GetMap()->GetSignalOnly(row,col);
918 if ((j1<0)||(j1>GetNPixelsZ()-1)||(pulse1<GetThreshold())){
919 pulse1 = GetMap()->GetSignalOnly(row,col);
923 UpdateMapSignal(col,j1,ntrack,idhit,pulse1);
925 flag = 1; // only first next !!
928 // loop in column direction
932 if((j2<0)||(j2>(GetNPixelsX()-1))||(pulse2<GetThreshold())){
933 pulse2 = GetMap()->GetSignalOnly(row,col);
937 UpdateMapSignal(j2,row,ntrack,idhit,pulse2);
939 flag = 1; // only first next!!