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"
25 #include "AliITSUModule.h"
26 #include "AliITSUParamList.h"
27 using namespace TMath;
29 ClassImp(AliITSUSimulation)
31 //______________________________________________________________________
32 AliITSUSimulation::AliITSUSimulation()
43 // Default constructor
45 //______________________________________________________________________
46 AliITSUSimulation::AliITSUSimulation(AliITSUSimuParam* sim,AliITSUSensMap* map)
57 // Default constructor
60 //__________________________________________________________________________
61 AliITSUSimulation::AliITSUSimulation(const AliITSUSimulation &s)
64 ,fCalibDead(s.fCalibDead)
65 ,fCalibNoisy(s.fCalibNoisy)
67 ,fSimuParam(s.fSimuParam)
68 ,fResponseParam(s.fResponseParam)
76 //_________________________________________________________________________
77 AliITSUSimulation& AliITSUSimulation::operator=(const AliITSUSimulation &s)
79 // Assignment operator
80 if(&s == this) return *this;
82 fCalibDead = s.fCalibDead;
83 fCalibNoisy= s.fCalibNoisy;
84 fSensMap = s.fSensMap;
85 fSimuParam = s.fSimuParam;
86 fResponseParam = s.fResponseParam;
92 //______________________________________________________________________
93 void AliITSUSimulation::InitSimulationModule(AliITSUModule* mod, Int_t event, AliITSsegmentation* seg, AliITSUParamList* resp)
95 // This function creates maps to build the list of tracks for each
96 // summable digit. Inputs defined by base class.
100 SetResponseParam(resp);
103 if (event != fEvent) GenerateReadOutCycleOffset();
108 //______________________________________________________________________
109 Bool_t AliITSUSimulation::AddSDigitsToModule(TSeqCollection *pItemArr,Int_t mask )
111 // Add Summable digits to module maps.
113 // pItemArr Array of AliITSpListItems (SDigits).
114 // mask Track number off set value
116 Int_t nItems = pItemArr->GetEntries();
119 for( Int_t i=0; i<nItems; i++ ) {
120 AliITSUSDigit * pItem = (AliITSUSDigit *)(pItemArr->At( i ));
121 if(pItem->GetModule() != int(fModule->GetIndex()) ) AliFatal(Form("SDigits module %d != current module %d: exit", pItem->GetModule(),fModule->GetIndex()));
122 if(pItem->GetSumSignal()>0.0 ) sig = kTRUE;
123 AliITSUSDigit* oldItem = (AliITSUSDigit*)fSensMap->GetItem(pItem);
125 oldItem = (AliITSUSDigit*)fSensMap->RegisterItem( new(fSensMap->GetFree()) AliITSUSDigit(*pItem) );
126 if (mask) oldItem->ShiftIndices(mask);
128 else oldItem->AddTo(mask, pItem);
133 //______________________________________________________________________
134 void AliITSUSimulation::UpdateMapSignal(UInt_t dim0,UInt_t dim1,Int_t trk,Int_t ht,Double_t signal)
136 // update map with new hit
137 UInt_t ind = fSensMap->GetIndex(dim0,dim1);
138 AliITSUSDigit* oldItem = (AliITSUSDigit*)fSensMap->GetItem(ind);
139 if (!oldItem) fSensMap->RegisterItem( new(fSensMap->GetFree()) AliITSUSDigit(trk,ht,fModule->GetIndex(),ind,signal) );
140 else oldItem->AddSignal(trk,ht,signal);
143 //______________________________________________________________________
144 void AliITSUSimulation::UpdateMapNoise(UInt_t dim0,UInt_t dim1,Double_t noise)
146 // update map with new hit
147 UInt_t ind = fSensMap->GetIndex(dim0,dim1);
148 AliITSUSDigit* oldItem = (AliITSUSDigit*)fSensMap->GetItem(ind);
149 if (!oldItem) fSensMap->RegisterItem( new(fSensMap->GetFree()) AliITSUSDigit(fModule->GetIndex(),ind,noise) );
150 else oldItem->AddNoise(noise);
153 //______________________________________________________________________
154 Int_t AliITSUSimulation::GenOrderedSample(UInt_t nmax,UInt_t ngen,TArrayI &vals,TArrayI &indx)
156 // generate random sample [0:nmax] of ngen variables, and fill orreder indices
157 // return actual number of generated values
158 if (vals.GetSize()<(int)ngen) vals.Set(ngen);
159 if (indx.GetSize()<(int)ngen) indx.Set(ngen);
160 int* valA = vals.GetArray();
161 int* indA = indx.GetArray();
164 for (int i=(int)ngen;i--;) {valA[i]=indA[i]=i;}
168 for (int i=0;i<(int)ngen;i++) {
169 do { // exclude repetitions
171 valA[i] = gRandom->Rndm()*nmax;
172 for (int j=i;j--;) if (valA[j]==valA[i]) {rep=kTRUE;break;}
175 Sort((int)ngen,valA,indA,kFALSE);