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>
21 #include <TObjArray.h>
24 #include <TGeoGlobalMagField.h>
25 #include "AliITSmodule.h"
26 #include "AliITSMapA2.h"
27 #include "AliITSpList.h"
28 #include "AliITSCalibrationSSD.h"
29 #include "AliITSsegmentationSSD.h"
30 //#include "AliITSdcsSSD.h"
32 #include "AliITShit.h"
33 #include "AliITSdigitSSD.h"
36 #include "AliITSgeom.h"
37 #include "AliITSsimulationSSD.h"
38 #include "AliITSTableSSD.h"
40 #include "AliMathBase.h"
44 ClassImp(AliITSsimulationSSD)
45 ////////////////////////////////////////////////////////////////////////
47 // Author: Enrico Fragiacomo //
48 // enrico.fragiacomo@ts.infn.it //
49 // Last revised: june 2008 //
51 // AliITSsimulationSSD is the simulation of SSD. //
52 ////////////////////////////////////////////////////////////////////////
54 //----------------------------------------------------------------------
55 AliITSsimulationSSD::AliITSsimulationSSD():AliITSsimulation(),
72 // A default construction AliITSsimulationSSD class
74 //----------------------------------------------------------------------
75 AliITSsimulationSSD::AliITSsimulationSSD(AliITSDetTypeSim* dettyp):
76 AliITSsimulation(dettyp),
89 // AliITSDetTypeSim Pointer to the SSD dettype to be used
93 // A standard constructed AliITSsimulationSSD class
95 fTimeResponse = new TF1("ftimeresponse",".5*x*exp(1.-.5*x)");
98 //----------------------------------------------------------------------
99 void AliITSsimulationSSD::Init(){
100 // Inilizer, Inilizes all of the variable as needed in a standard place.
102 // AliITSsegmentationSSD *seg Pointer to the SSD segmentation to be used
103 // AliITSCalibrationSSD *resp Pointer to the SSD responce class to be used
108 AliITSsegmentationSSD* seg = (AliITSsegmentationSSD*)GetSegmentationModel(2);
109 AliITSSimuParam* simpar = fDetType->GetSimuParam();
111 SetDriftVelocity(); // use default values in .h file
112 SetIonizeE(); // use default values in .h file
113 SetDiffConst(); // use default values in .h file
114 fpList = new AliITSpList(2,GetNStrips());
115 fMapA2 = new AliITSMapA2(seg);
116 SetLorentzDrift(simpar->GetSSDLorentzDrift());
117 if (fLorentz) SetTanLorAngle();
120 //______________________________________________________________________
121 Bool_t AliITSsimulationSSD::SetTanLorAngle() {
122 // This function set the Tangent of the Lorentz angles.
123 // output: Bool_t : kTRUE in case of success
127 AliError("AliITSsimulationSPD::SetTanLorAngle: AliITSDetTypeSim* fDetType not set ");
130 AliITSSimuParam* simpar = fDetType->GetSimuParam();
131 AliMagF* fld = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
132 if (!fld) AliFatal("The field is not initialized");
133 Double_t bz = fld->SolenoidField();
135 fTanLorAngN = TMath::Tan( simpar->LorentzAngleElectron(bz) );
136 fTanLorAngP = TMath::Tan( simpar->LorentzAngleHole(bz) );
141 //______________________________________________________________________
142 AliITSsimulationSSD& AliITSsimulationSSD::operator=(
143 const AliITSsimulationSSD &s){
146 if(this==&s) return *this;
148 // this->fDCS = new AliITSdcsSSD(*(s.fDCS));
149 this->fMapA2 = s.fMapA2;
150 this->fIonE = s.fIonE;
151 this->fDifConst[0] = s.fDifConst[0];
152 this->fDifConst[1] = s.fDifConst[1];
153 this->fDriftVel[0] = s.fDriftVel[0];
154 this->fDriftVel[1] = s.fDriftVel[1];
155 this->fTimeResponse = s.fTimeResponse;
156 this->fLorentz = s.fLorentz;
157 this->fTanLorAngP = s.fTanLorAngP;
158 this->fTanLorAngN = s.fTanLorAngN;
162 //______________________________________________________________________
163 AliITSsimulation& AliITSsimulationSSD::operator=(
164 const AliITSsimulation &s){
167 if(this==&s) return *this;
168 Error("AliITSsimulationSSD","Not allowed to make a = with "
169 "AliITSsimulationSSD Using default creater instead");
174 //______________________________________________________________________
175 AliITSsimulationSSD::AliITSsimulationSSD(const AliITSsimulationSSD &source):
176 AliITSsimulation(source),
177 fMapA2(source.fMapA2),
181 fTimeResponse(source.fTimeResponse),
182 fLorentz(source.fLorentz),
183 fTanLorAngP(source.fTanLorAngP),
184 fTanLorAngN(source.fTanLorAngN)
187 fDifConst[0] = source.fDifConst[0];
188 fDifConst[1] = source.fDifConst[1];
189 fDriftVel[0] = source.fDriftVel[0];
190 fDriftVel[1] = source.fDriftVel[1];
192 //______________________________________________________________________
193 AliITSsimulationSSD::~AliITSsimulationSSD() {
196 delete fTimeResponse;
199 //______________________________________________________________________
200 void AliITSsimulationSSD::InitSimulationModule(Int_t module,Int_t event){
201 // Creates maps to build the list of tracks for each sumable digit
203 // Int_t module // Module number to be simulated
204 // Int_t event // Event number to be simulated
210 SetModuleNumber(module);
211 SetEventNumber(event);
215 //______________________________________________________________________
216 void AliITSsimulationSSD::FinishSDigitiseModule(){
217 // Does the Sdigits to Digits work
225 FillMapFrompList(fpList); // need to check if needed here or not????
226 SDigitToDigit(fModule,fpList);
230 //______________________________________________________________________
231 void AliITSsimulationSSD::DigitiseModule(AliITSmodule *mod,Int_t,Int_t) {
232 // Digitizes hits for one SSD module
233 SetModuleNumber(mod->GetIndex());
235 HitsToAnalogDigits(mod,fpList);
236 SDigitToDigit(GetModuleNumber(),fpList);
241 //______________________________________________________________________
242 void AliITSsimulationSSD::SDigitiseModule(AliITSmodule *mod,Int_t,Int_t) {
243 // Produces Summable/Analog digits and writes them to the SDigit tree.
245 HitsToAnalogDigits(mod,fpList);
247 WriteSDigits(fpList);
252 //______________________________________________________________________
253 void AliITSsimulationSSD::SDigitToDigit(Int_t module,AliITSpList *pList){
254 // Takes the pList and finishes the digitization.
256 ApplyNoise(pList,module);
257 ApplyCoupling(pList,module);
258 ApplyDeadChannels(module);
260 ChargeToSignal(module,pList);
262 //______________________________________________________________________
263 void AliITSsimulationSSD::HitsToAnalogDigits(AliITSmodule *mod,
265 // Loops over all hits to produce Analog/floating point digits. This
266 // is also the first task in producing standard digits.
267 Int_t lasttrack = -2;
269 Double_t x0=0.0, y0=0.0, z0=0.0;
270 Double_t x1=0.0, y1=0.0, z1=0.0;
272 Int_t module = mod->GetIndex();
276 AliITSsegmentationSSD* seg = (AliITSsegmentationSSD*)GetSegmentationModel(2);
278 TObjArray *hits = mod->GetHits();
279 Int_t nhits = hits->GetEntriesFast();
280 if (nhits<=0) return;
281 AliITSTableSSD * tav = new AliITSTableSSD(GetNStrips());
282 module = mod->GetIndex();
283 if ( mod->GetLayer() == 6 ) seg->SetLayer(6);
284 if ( mod->GetLayer() == 5 ) seg->SetLayer(5);
286 for(Int_t i=0; i<nhits; i++) {
287 // LineSegmentL returns 0 if the hit is entering
288 // If hits is exiting returns positions of entering and exiting hits
289 // Returns also energy loss
292 cout << mod->GetHit(i)->GetXL() << " "<<mod->GetHit(i)->GetYL();
293 cout << " " << mod->GetHit(i)->GetZL();
296 if (mod->LineSegmentL(i, x0, x1, y0, y1, z0, z1, de, idtrack)) {
298 // Scale down dE/dx according to the hit's TOF wrt to the trigger
299 // Necessary for pileup simulation
301 tof = mod->GetHit(i)->GetTOF();
302 tof *= 1.E+6; // convert time in microsecond
303 if(tof<2.) de = de * fTimeResponse->Eval(-1.*tof+2.);
307 HitToDigit(module, x0, y0, z0, x1, y1, z1, de,tav);
308 if (lasttrack != idtrack || i==(nhits-1)) {
309 GetList(idtrack,i,module,pList,tav);
313 } // end loop over hits
317 //----------------------------------------------------------------------
318 void AliITSsimulationSSD::HitToDigit(Int_t module, Double_t x0, Double_t y0,
319 Double_t z0, Double_t x1, Double_t y1,
320 Double_t z1, Double_t de,
321 AliITSTableSSD *tav) {
323 // hit to digit conversion
325 AliITSsegmentationSSD* seg = (AliITSsegmentationSSD*)GetSegmentationModel(2);
326 // Turns hits in SSD module into one or more digits.
327 //Float_t tang[2] = {0.0,0.0};
328 //seg->Angles(tang[0], tang[1]);//stereo<<->tan(stereo)~=stereo
330 Double_t dex=0.0, dey=0.0, dez=0.0;
331 Double_t pairs; // pair generation energy per step.
332 Double_t sigma[2] = {0.,0.};// standard deviation of the diffusion gaussian
333 Double_t tdrift[2] = {0.,0.}; // time of drift
335 Double_t inf[2], sup[2], par0[2];
337 // Set up corrections for Lorentz drift (ExB)
338 Double_t tanLorAngP = fTanLorAngP;
339 Double_t tanLorAngN = fTanLorAngN;
340 if(seg->GetLayer()==6) {
341 tanLorAngP = -1.*fTanLorAngP;
342 tanLorAngN = -1.*fTanLorAngN;
345 // Steps in the module are determined "manually" (i.e. No Geant)
346 // NumOfSteps divide path between entering and exiting hits in steps
347 Int_t numOfSteps = NumOfSteps(x1, y1, z1, dex, dey, dez);
348 // Enery loss is equally distributed among steps
350 pairs = de/GetIonizeE(); // e-h pairs generated
352 //-----------------------------------------------------
354 //-----------------------------------------------------
355 for(Int_t j=0; j<numOfSteps; j++) { // stepping
357 x = x0 + (j+0.5)*dex;
358 y = y0 + (j+0.5)*dey;
359 if ( y > (seg->Dy()/2+10)*1.0E-4 ) {
360 // check if particle is within the detector
361 Warning("HitToDigit",
362 "hit out of detector y0=%e,y=%e,dey=%e,j =%d module=%d, exceed=%e",
363 y0,y,dey,j,module, y-(seg->Dy()/2+10)*1.0E-4);
366 z = z0 + (j+0.5)*dez;
368 if(GetDebug(4)) cout <<"HitToDigit "<<x<<" "<<y<<" "<<z<< " "
369 <<dex<<" "<<dey<<" "<<dez<<endl;
371 if(seg->GetLayer()==6) {
372 y=-y; // Lay6 module has sensor up-side-down!!!
376 //---------------------------------------------------------
378 //------------------------------------------------------------
381 // w is the coord. perpendicular to the strips
382 // Float_t xp=x*1.e+4,zp=z*1.e+4; // microns
385 // correction for the Lorentz's angle
387 Float_t deltaxp = (y+(seg->Dy()*1.0E-4)/2)*tanLorAngP;
391 seg->GetPadTxz(xp,zp);
393 // calculate drift time
394 // y is the minimum path
395 tdrift[0] = (y+(seg->Dy()*1.0E-4)/2)/GetDriftVelocity(0);
397 w = xp; // P side strip number
399 if((w<(-0.5)) || (w>(GetNStrips()-0.5))) {
400 // this check rejects hits in regions not covered by strips
401 // 0.5 takes into account boundaries
402 if(GetDebug(4)) cout << "Dead SSD region, x,z="<<x<<","<<z<<endl;
403 return; // There are dead region on the SSD sensitive volume!!!
405 // sigma is the standard deviation of the diffusion gaussian
406 if(tdrift[k]<0) return;
408 sigma[k] = TMath::Sqrt(2*GetDiffConst(k)*tdrift[k]);
409 sigma[k] /= (GetStripPitch()*1.0E-4); //units of Pitch
412 Error("HitToDigit"," sigma[%d]=0",k);
417 // we integrate the diffusion gaussian from -3sigma to 3sigma
418 inf[k] = w - 3*sigma[k]; // 3 sigma from the gaussian average
419 sup[k] = w + 3*sigma[k]; // 3 sigma from the gaussian average
420 // IntegrateGaussian does the actual
421 // integration of diffusion gaussian
422 IntegrateGaussian(k, par0[k], w, sigma[k], inf[k], sup[k],tav);
424 //------------------------------------------------------
426 //-------------------------------------------------------
428 //------------------------------------------------------
430 //-------------------------------------------------------
435 // correction for the Lorentz's angle
437 Float_t deltaxn = ((seg->Dy()*1.0E-4)/2-y)*tanLorAngN;
442 seg->GetPadTxz(xp,zp);
444 tdrift[1] = ((seg->Dy()*1.0E-4)/2-y)/GetDriftVelocity(1);
446 //tang[k]=TMath::Tan(tang[k]);
448 w = zp; // N side strip number
450 if((w<(-0.5)) || (w>(GetNStrips()-0.5))) {
451 // this check rejects hits in regions not covered by strips
452 // 0.5 takes into account boundaries
453 if(GetDebug(4)) cout << "Dead SSD region, x,z="<<x<<","<<z<<endl;
454 return; // There are dead region on the SSD sensitive volume.
457 // sigma is the standard deviation of the diffusion gaussian
458 if(tdrift[k]<0) return;
460 sigma[k] = TMath::Sqrt(2*GetDiffConst(k)*tdrift[k]);
461 sigma[k] /= (GetStripPitch()*1.0E-4); //units of Pitch
464 Error("HitToDigit"," sigma[%d]=0",k);
469 // we integrate the diffusion gaussian from -3sigma to 3sigma
470 inf[k] = w - 3*sigma[k]; // 3 sigma from the gaussian average
471 sup[k] = w + 3*sigma[k]; // 3 sigma from the gaussian average
472 // IntegrateGaussian does the actual
473 // integration of diffusion gaussian
474 IntegrateGaussian(k, par0[k], w, sigma[k], inf[k], sup[k],tav);
476 //-------------------------------------------------
478 //-------------------------------------------------
484 //______________________________________________________________________
485 void AliITSsimulationSSD::ApplyNoise(AliITSpList *pList,Int_t module){
488 Double_t signal,noise;
489 AliITSCalibrationSSD* res =(AliITSCalibrationSSD*)GetCalibrationModel(module);
492 for(ix=0;ix<GetNStrips();ix++){ // loop over strips
495 noise = (Double_t) gRandom->Gaus(0,res->GetNoiseP(ix));
497 // need to calibrate noise
498 // NOTE. noise from the calibration database comes uncalibrated,
499 // it needs to be calibrated in order to be added
500 // to the signal. It will be decalibrated later on together with the noise
501 noise *= (Double_t) res->GetGainP(ix);
503 // noise comes in ADC channels from the calibration database
504 // It needs to be converted back to electronVolts
505 noise /= res->GetSSDDEvToADC(1.);
507 // Finally, noise is added to the signal
508 signal = noise + fMapA2->GetSignal(0,ix);//get signal from map
509 fMapA2->SetHit(0,ix,signal); // give back signal to map
510 if(signal>0.0) pList->AddNoise(0,ix,module,noise);
514 for(ix=0;ix<GetNStrips();ix++){ // loop over strips
515 noise = (Double_t) gRandom->Gaus(0,res->GetNoiseN(ix));// give noise to signal
516 noise *= (Double_t) res->GetGainN(ix);
517 noise /= res->GetSSDDEvToADC(1.);
518 signal = noise + fMapA2->GetSignal(1,ix);//get signal from map
519 fMapA2->SetHit(1,ix,signal); // give back signal to map
520 if(signal>0.0) pList->AddNoise(1,ix,module,noise);
524 //______________________________________________________________________
525 void AliITSsimulationSSD::ApplyCoupling(AliITSpList *pList,Int_t module) {
526 // Apply the effect of electronic coupling between channels
529 //AliITSCalibrationSSD* res =(AliITSCalibrationSSD*)GetCalibrationModel(module);
530 AliITSSimuParam* res = fDetType->GetSimuParam();
532 Double_t *contrLeft = new Double_t[GetNStrips()];
533 Double_t *contrRight = new Double_t[GetNStrips()];
536 for(ix=0;ix<GetNStrips();ix++){
537 if(ix>0) contrLeft[ix] = fMapA2->GetSignal(0,ix-1)*res->GetSSDCouplingPL();
538 else contrLeft[ix] = 0.0;
539 if(ix<(GetNStrips()-1)) contrRight[ix] = fMapA2->GetSignal(0,ix+1)*res->GetSSDCouplingPR();
540 else contrRight[ix] = 0.0;
541 } // loop over strips
543 for(ix=0;ix<GetNStrips();ix++){
544 signal = contrLeft[ix] + contrRight[ix] - res->GetSSDCouplingPL() * fMapA2->GetSignal(0,ix)
545 - res->GetSSDCouplingPR() * fMapA2->GetSignal(0,ix);
546 fMapA2->AddSignal(0,ix,signal);
547 if(signal>0.0) pList->AddNoise(0,ix,module,signal);
548 } // loop over strips
551 for(ix=0;ix<GetNStrips();ix++){
552 if(ix>0) contrLeft[ix] = fMapA2->GetSignal(1,ix-1)*res->GetSSDCouplingNL();
553 else contrLeft[ix] = 0.0;
554 if(ix<(GetNStrips()-1)) contrRight[ix] = fMapA2->GetSignal(1,ix+1)*res->GetSSDCouplingNR();
555 else contrRight[ix] = 0.0;
556 } // loop over strips
558 for(ix=0;ix<GetNStrips();ix++){
559 signal = contrLeft[ix] + contrRight[ix] - res->GetSSDCouplingNL() * fMapA2->GetSignal(0,ix)
560 - res->GetSSDCouplingNR() * fMapA2->GetSignal(0,ix);
561 fMapA2->AddSignal(1,ix,signal);
562 if(signal>0.0) pList->AddNoise(1,ix,module,signal);
563 } // loop over strips
567 delete [] contrRight;
570 //______________________________________________________________________
571 void AliITSsimulationSSD::ApplyDeadChannels(Int_t module) {
572 // Kill dead channels setting gain to zero
574 AliITSCalibrationSSD* res = (AliITSCalibrationSSD*)GetCalibrationModel(module);
576 for(Int_t i=0;i<GetNStrips();i++){
578 if(res->IsPChannelBad(i)) res->SetGainP(i,0.0);
579 if(res->IsNChannelBad(i)) res->SetGainN(i,0.0);
581 } // loop over strips
585 //______________________________________________________________________
586 Float_t AliITSsimulationSSD::F(Float_t av, Float_t x, Float_t s) {
587 // Computes the integral of a gaussian using Error Function
588 Float_t sqrt2 = TMath::Sqrt(2.0);
589 Float_t sigm2 = sqrt2*s;
592 integral = 0.5 * AliMathBase::ErfFast( (x - av) / sigm2);
595 //______________________________________________________________________
596 void AliITSsimulationSSD::IntegrateGaussian(Int_t k,Double_t par, Double_t w,
598 Double_t inf, Double_t sup,
599 AliITSTableSSD *tav) {
600 // integrate the diffusion gaussian
601 // remind: inf and sup are w-3sigma and w+3sigma
602 // we could define them here instead of passing them
603 // this way we are free to introduce asimmetry
605 Double_t a=0.0, b=0.0;
606 Double_t dXCharge1 = 0.0, dXCharge2 = 0.0;
607 // dXCharge1 and 2 are the charge to two neighbouring strips
608 // Watch that we only involve at least two strips
609 // Numbers greater than 2 of strips in a cluster depend on
610 // geometry of the track and delta rays, not charge diffusion!
612 Double_t strip = TMath::Floor(w); // closest strip on the left
614 if ( TMath::Abs((strip - w)) < 0.5) {
615 // gaussian mean is closer to strip on the left
616 a = inf; // integration starting point
617 if((strip+0.5)<=sup) {
618 // this means that the tail of the gaussian goes beyond
619 // the middle point between strips ---> part of the signal
620 // is given to the strip on the right
621 b = strip + 0.5; // integration stopping point
622 dXCharge1 = F( w, b, sigma) - F(w, a, sigma);
623 dXCharge2 = F( w, sup, sigma) - F(w ,b, sigma);
625 // this means that all the charge is given to the strip on the left
627 dXCharge1 = 0.9973; // gaussian integral at 3 sigmas
630 dXCharge1 = par * dXCharge1;// normalize by mean of number of carriers
631 dXCharge2 = par * dXCharge2;
633 // for the time being, signal is the charge
634 // in ChargeToSignal signal is converted in ADC channel
635 fMapA2->AddSignal(k,(Int_t)strip,dXCharge1);
636 tav->Add(k,(Int_t)strip);
637 if(((Int_t) strip) < (GetNStrips()-1)) {
638 // strip doesn't have to be the last (remind: last=GetNStrips()-1)
639 // otherwise part of the charge is lost
640 fMapA2->AddSignal(k,((Int_t)strip+1),dXCharge2);
641 tav->Add(k,((Int_t)(strip+1)));
644 // gaussian mean is closer to strip on the right
645 strip++; // move to strip on the rigth
646 b = sup; // now you know where to stop integrating
647 if((strip-0.5)>=inf) {
648 // tail of diffusion gaussian on the left goes left of
649 // middle point between strips
650 a = strip - 0.5; // integration starting point
651 dXCharge1 = F(w, b, sigma) - F(w, a, sigma);
652 dXCharge2 = F(w, a, sigma) - F(w, inf, sigma);
655 dXCharge1 = 0.9973; // gaussian integral at 3 sigmas
658 dXCharge1 = par * dXCharge1; // normalize by means of carriers
659 dXCharge2 = par * dXCharge2;
660 // for the time being, signal is the charge
661 // in ChargeToSignal signal is converted in ADC channel
662 fMapA2->AddSignal(k,(Int_t)strip,dXCharge1);
663 tav->Add(k,(Int_t)strip);
664 if(((Int_t) strip) > 0) {
665 // strip doesn't have to be the first
666 // otherwise part of the charge is lost
667 fMapA2->AddSignal(k,((Int_t)strip-1),dXCharge2);
668 tav->Add(k,((Int_t)(strip-1)));
672 //______________________________________________________________________
673 Int_t AliITSsimulationSSD::NumOfSteps(Double_t x, Double_t y, Double_t z,
674 Double_t &dex,Double_t &dey,
677 // it also returns steps for each coord
678 //AliITSsegmentationSSD *seg = new AliITSsegmentationSSD();
680 Double_t step = 25E-4;
681 //step = (Double_t) seg->GetStepSize(); // step size (cm)
682 Int_t numOfSteps = (Int_t) (TMath::Sqrt(x*x+y*y+z*z)/step);
684 if (numOfSteps < 1) numOfSteps = 1; // one step, at least
687 // we could condition the stepping depending on the incident angle
695 //----------------------------------------------------------------------
696 void AliITSsimulationSSD::GetList(Int_t label,Int_t hit,Int_t mod,
697 AliITSpList *pList,AliITSTableSSD *tav) {
698 // loop over nonzero digits
702 for(Int_t k=0; k<2; k++) {
705 signal = fMapA2->GetSignal(k,ix);
709 } // end if signal==0.0
710 // check the signal magnitude
711 for(i=0;i<pList->GetNSignals(k,ix);i++){
712 signal -= pList->GetTSignal(k,ix,i);
714 // compare the new signal with already existing list
715 if(signal>0)pList->AddSignal(k,ix,label,hit,mod,signal);
717 } // end of loop on strips
718 } // end of loop on P/N side
721 //----------------------------------------------------------------------
722 void AliITSsimulationSSD::ChargeToSignal(Int_t module,const AliITSpList *pList) {
724 static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
725 Float_t threshold = 0.;
726 Int_t size = AliITSdigitSSD::GetNTracks();
727 Int_t * digits = new Int_t[size];
728 Int_t * tracks = new Int_t[size];
729 Int_t * hits = new Int_t[size];
731 Float_t charges[3] = {0.0,0.0,0.0};
733 AliITSCalibrationSSD* res =(AliITSCalibrationSSD*)GetCalibrationModel(module);
734 AliITSSimuParam* simpar = fDetType->GetSimuParam();
736 for(Int_t k=0;k<2;k++){ // both sides (0=Pside, 1=Nside)
737 for(Int_t ix=0;ix<GetNStrips();ix++){ // loop over strips
739 // if strip is dead -> gain=0
740 if( ((k==0)&&(res->GetGainP(ix)==0)) || ((k==1)&&(res->GetGainN(ix)==0))) continue;
742 signal = fMapA2->GetSignal(k,ix);
743 // signal has to be uncalibrated
744 // In real life, gains are supposed to be calculated from calibration runs,
745 // stored in the calibration DB and used in the reconstruction
746 // (see AliITSClusterFinderSSD.cxx)
747 if(k==0) signal /= res->GetGainP(ix);
748 else signal /= res->GetGainN(ix);
750 // signal is converted in unit of ADC
751 signal = res->GetSSDDEvToADC(signal);
752 if(signal>4095.) signal = 4095.;//if exceeding, accumulate last one
754 // threshold for zero suppression is set on the basis of the noise
755 // A good value is 3*sigma_noise
756 if(k==0) threshold = res->GetNoiseP(ix);
757 else threshold = res->GetNoiseN(ix);
759 threshold *= simpar->GetSSDZSThreshold(); // threshold at 3 sigma noise
761 if(signal < threshold) continue;
762 //cout<<signal<<" "<<threshold<<endl;
766 digits[2] = TMath::Nint(signal);
767 for(j1=0;j1<size;j1++)if(j1<pList->GetNEntries()){
768 // only three in digit.
769 tracks[j1] = pList->GetTrack(k,ix,j1);
770 hits[j1] = pList->GetHit(k,ix,j1);
776 aliITS->AddSimDigit(2,0,digits,tracks,hits,charges);
783 //______________________________________________________________________
784 void AliITSsimulationSSD::WriteSDigits(AliITSpList *pList){
785 // Fills the Summable digits Tree
787 static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
789 pList->GetMaxMapIndex(ni,nj);
790 for(i=0;i<ni;i++)for(j=0;j<nj;j++){
791 if(pList->GetSignalOnly(i,j)>0.0){
792 aliITS->AddSumDigit(*(pList->GetpListItem(i,j)));
793 if(GetDebug(4)) cout << "pListSSD: "<<*(pList->GetpListItem(i,j))
799 //______________________________________________________________________
800 void AliITSsimulationSSD::FillMapFrompList(AliITSpList *pList){
801 // Fills fMap2A from the pList of Summable digits
804 for(k=0;k<2;k++)for(ix=0;ix<GetNStrips();ix++)
805 fMapA2->AddSignal(k,ix,pList->GetSignal(k,ix));
808 //______________________________________________________________________
809 void AliITSsimulationSSD::Print(ostream *os){
810 //Standard output format for this class
812 //AliITSsimulation::Print(os);
814 *os << fDifConst[0] <<","<< fDifConst[1] <<",";
815 *os << fDriftVel[0] <<","<< fDriftVel[1];
816 //*os <<","; fDCS->Print(os);
817 //*os <<","; fMapA2->Print(os);
819 //______________________________________________________________________
820 void AliITSsimulationSSD::Read(istream *is){
821 // Standard output streaming function.
823 //AliITSsimulation::Read(is);
825 *is >> fDifConst[0] >> fDifConst[1];
826 *is >> fDriftVel[0] >> fDriftVel[1];
830 //______________________________________________________________________
831 ostream &operator<<(ostream &os,AliITSsimulationSSD &source){
832 // Standard output streaming function.
837 //______________________________________________________________________
838 istream &operator>>(istream &os,AliITSsimulationSSD &source){
839 // Standard output streaming function.
844 //______________________________________________________________________