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 **************************************************************************/
15 //////////////////////////////////////////////////////////////////////////////
16 // This is the base class for ITS detector signal simulations. Data members //
17 // include are a pointer to the AliITSDetTypeSim clas in order to access //
18 // segmentation and response objects //
19 // classes. See the detector specific implementations for the propper code. //
20 //////////////////////////////////////////////////////////////////////////////
22 #include "TSeqCollection.h"
23 #include "AliITSUSimulation.h"
24 #include "AliITSUSDigit.h"
26 ClassImp(AliITSUSimulation)
28 //______________________________________________________________________
29 AliITSUSimulation::AliITSUSimulation()
39 // Default constructor
41 //______________________________________________________________________
42 AliITSUSimulation::AliITSUSimulation(AliITSUSimuParam* sim,AliITSUSensMap* map)
52 // Default constructor
55 //__________________________________________________________________________
56 AliITSUSimulation::AliITSUSimulation(const AliITSUSimulation &s)
59 ,fCalibDead(s.fCalibDead)
60 ,fCalibNoisy(s.fCalibNoisy)
62 ,fSimuParam(s.fSimuParam)
70 //_________________________________________________________________________
71 AliITSUSimulation& AliITSUSimulation::operator=(const AliITSUSimulation &s)
73 // Assignment operator
74 if(&s == this) return *this;
76 fCalibDead = s.fCalibDead;
77 fCalibNoisy= s.fCalibNoisy;
78 fSensMap = s.fSensMap;
79 fSimuParam = s.fSimuParam;
85 //______________________________________________________________________
86 void AliITSUSimulation::InitSimulationModule(Int_t module, Int_t event, AliITSsegmentation* seg)
88 // This function creates maps to build the list of tracks for each
89 // summable digit. Inputs defined by base class.
97 //______________________________________________________________________
98 Bool_t AliITSUSimulation::AddSDigitsToModule(TSeqCollection *pItemArr,Int_t mask )
100 // Add Summable digits to module maps.
102 // pItemArr Array of AliITSpListItems (SDigits).
103 // mask Track number off set value
105 Int_t nItems = pItemArr->GetEntries();
108 for( Int_t i=0; i<nItems; i++ ) {
109 AliITSUSDigit * pItem = (AliITSUSDigit *)(pItemArr->At( i ));
110 if( pItem->GetModule() != fModule ) AliFatal(Form("SDigits module %d != current module %d: exit", pItem->GetModule(), fModule ));
111 if(pItem->GetSumSignal()>0.0 ) sig = kTRUE;
112 AliITSUSDigit* oldItem = (AliITSUSDigit*)fSensMap->GetItem(pItem);
114 oldItem = (AliITSUSDigit*)fSensMap->RegisterItem( new(fSensMap->GetFree()) AliITSUSDigit(*pItem) );
115 if (mask) oldItem->ShiftIndices(mask);
117 else oldItem->AddTo(mask, pItem);
122 //______________________________________________________________________
123 void AliITSUSimulation::UpdateMapSignal(UInt_t dim0,UInt_t dim1,Int_t trk,Int_t ht,Double_t signal)
125 // update map with new hit
126 UInt_t ind = fSensMap->GetIndex(dim0,dim1);
127 AliITSUSDigit* oldItem = (AliITSUSDigit*)fSensMap->GetItem(ind);
128 if (!oldItem) fSensMap->RegisterItem( new(fSensMap->GetFree()) AliITSUSDigit(trk,ht,fModule,ind,signal) );
129 else oldItem->AddSignal(trk,ht,signal);
132 //______________________________________________________________________
133 void AliITSUSimulation::UpdateMapNoise(UInt_t dim0,UInt_t dim1,Double_t noise)
135 // update map with new hit
136 UInt_t ind = fSensMap->GetIndex(dim0,dim1);
137 AliITSUSDigit* oldItem = (AliITSUSDigit*)fSensMap->GetItem(ind);
138 if (!oldItem) fSensMap->RegisterItem( new(fSensMap->GetFree()) AliITSUSDigit(fModule,ind,noise) );
139 else oldItem->AddNoise(noise);
142 //______________________________________________________________________
143 Int_t AliITSUSimulation::GenOrderedSample(UInt_t nmax,UInt_t ngen,TArrayI &vals,TArrayI &indx)
145 // generate random sample [0:nmax] of ngen variables, and fill orreder indices
146 // return actual number of generated values
147 if (vals.GetSize()<(int)ngen) vals.Set(ngen);
148 if (indx.GetSize()<(int)ngen) indx.Set(ngen);
149 int* valA = vals.GetArray();
150 int* indA = indx.GetArray();
153 for (int i=(int)ngen;i--;) {valA[i]=indA[i]=i;}
157 for (int i=0;i<(int)ngen;i++) {
158 do { // exclude repetitions
160 valA[i] = gRandom->Rndm()*nmax;
161 for (int j=i;j--;) if (valA[j]==valA[i]) {rep=kTRUE;break;}
164 TMath::Sort((int)ngen,valA,indA,kFALSE);