]>
Commit | Line | Data |
---|---|---|
451f5018 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | ////////////////////////////////////////////////////////////////////////////// | |
21 | #include <TRandom.h> | |
22 | #include "TSeqCollection.h" | |
23 | #include "AliITSUSimulation.h" | |
24 | #include "AliITSUSDigit.h" | |
c92b1537 | 25 | #include "AliITSUModule.h" |
29ad4146 | 26 | #include "AliITSUParamList.h" |
a11ef2e4 | 27 | using namespace TMath; |
451f5018 | 28 | |
29 | ClassImp(AliITSUSimulation) | |
30 | ||
31 | //______________________________________________________________________ | |
32 | AliITSUSimulation::AliITSUSimulation() | |
33 | : fSeg(0) | |
34 | ,fCalibDead(0) | |
35 | ,fCalibNoisy(0) | |
36 | ,fSensMap(0) | |
37 | ,fSimuParam(0) | |
c92b1537 | 38 | ,fResponseParam(0) |
451f5018 | 39 | ,fModule(0) |
40 | ,fEvent(0) | |
41 | ,fDebug(0) | |
42 | { | |
43 | // Default constructor | |
44 | } | |
45 | //______________________________________________________________________ | |
46 | AliITSUSimulation::AliITSUSimulation(AliITSUSimuParam* sim,AliITSUSensMap* map) | |
47 | :fSeg(0) | |
48 | ,fCalibDead(0) | |
49 | ,fCalibNoisy(0) | |
50 | ,fSensMap(map) | |
51 | ,fSimuParam(sim) | |
c92b1537 | 52 | ,fResponseParam(0) |
451f5018 | 53 | ,fModule(0) |
54 | ,fEvent(0) | |
55 | ,fDebug(0) | |
56 | { | |
57 | // Default constructor | |
58 | } | |
59 | ||
60 | //__________________________________________________________________________ | |
61 | AliITSUSimulation::AliITSUSimulation(const AliITSUSimulation &s) | |
62 | :TObject(s) | |
63 | ,fSeg(s.fSeg) | |
64 | ,fCalibDead(s.fCalibDead) | |
65 | ,fCalibNoisy(s.fCalibNoisy) | |
66 | ,fSensMap(s.fSensMap) | |
67 | ,fSimuParam(s.fSimuParam) | |
c92b1537 | 68 | ,fResponseParam(s.fResponseParam) |
451f5018 | 69 | ,fModule(s.fModule) |
70 | ,fEvent(s.fEvent) | |
71 | ,fDebug(s.fDebug) | |
72 | { | |
73 | // Copy Constructor | |
74 | } | |
75 | ||
76 | //_________________________________________________________________________ | |
77 | AliITSUSimulation& AliITSUSimulation::operator=(const AliITSUSimulation &s) | |
78 | { | |
79 | // Assignment operator | |
80 | if(&s == this) return *this; | |
81 | fSeg = s.fSeg; | |
82 | fCalibDead = s.fCalibDead; | |
83 | fCalibNoisy= s.fCalibNoisy; | |
84 | fSensMap = s.fSensMap; | |
85 | fSimuParam = s.fSimuParam; | |
c92b1537 | 86 | fResponseParam = s.fResponseParam; |
451f5018 | 87 | fModule = s.fModule; |
88 | fEvent = s.fEvent; | |
89 | return *this; | |
90 | } | |
91 | ||
92 | //______________________________________________________________________ | |
29ad4146 | 93 | void AliITSUSimulation::InitSimulationModule(AliITSUModule* mod, Int_t event, AliITSsegmentation* seg, AliITSUParamList* resp) |
451f5018 | 94 | { |
95 | // This function creates maps to build the list of tracks for each | |
96 | // summable digit. Inputs defined by base class. | |
97 | // | |
c92b1537 | 98 | SetModule(mod); |
451f5018 | 99 | SetSegmentation(seg); |
c92b1537 | 100 | SetResponseParam(resp); |
451f5018 | 101 | ClearMap(); |
c92b1537 | 102 | // |
0ebc85cf | 103 | if (event != fEvent) GenerateReadOutCycleOffset(); |
c92b1537 | 104 | SetEvent(event); |
105 | ||
451f5018 | 106 | } |
107 | ||
108 | //______________________________________________________________________ | |
109 | Bool_t AliITSUSimulation::AddSDigitsToModule(TSeqCollection *pItemArr,Int_t mask ) | |
110 | { | |
111 | // Add Summable digits to module maps. | |
112 | // Inputs: | |
113 | // pItemArr Array of AliITSpListItems (SDigits). | |
114 | // mask Track number off set value | |
115 | // | |
116 | Int_t nItems = pItemArr->GetEntries(); | |
117 | Bool_t sig = kFALSE; | |
118 | // | |
119 | for( Int_t i=0; i<nItems; i++ ) { | |
120 | AliITSUSDigit * pItem = (AliITSUSDigit *)(pItemArr->At( i )); | |
c92b1537 | 121 | if(pItem->GetModule() != int(fModule->GetIndex()) ) AliFatal(Form("SDigits module %d != current module %d: exit", pItem->GetModule(),fModule->GetIndex())); |
451f5018 | 122 | if(pItem->GetSumSignal()>0.0 ) sig = kTRUE; |
123 | AliITSUSDigit* oldItem = (AliITSUSDigit*)fSensMap->GetItem(pItem); | |
124 | if (!oldItem) { | |
125 | oldItem = (AliITSUSDigit*)fSensMap->RegisterItem( new(fSensMap->GetFree()) AliITSUSDigit(*pItem) ); | |
126 | if (mask) oldItem->ShiftIndices(mask); | |
127 | } | |
128 | else oldItem->AddTo(mask, pItem); | |
129 | } | |
130 | return sig; | |
131 | } | |
132 | ||
133 | //______________________________________________________________________ | |
134 | void AliITSUSimulation::UpdateMapSignal(UInt_t dim0,UInt_t dim1,Int_t trk,Int_t ht,Double_t signal) | |
135 | { | |
136 | // update map with new hit | |
137 | UInt_t ind = fSensMap->GetIndex(dim0,dim1); | |
138 | AliITSUSDigit* oldItem = (AliITSUSDigit*)fSensMap->GetItem(ind); | |
c92b1537 | 139 | if (!oldItem) fSensMap->RegisterItem( new(fSensMap->GetFree()) AliITSUSDigit(trk,ht,fModule->GetIndex(),ind,signal) ); |
451f5018 | 140 | else oldItem->AddSignal(trk,ht,signal); |
141 | } | |
142 | ||
143 | //______________________________________________________________________ | |
144 | void AliITSUSimulation::UpdateMapNoise(UInt_t dim0,UInt_t dim1,Double_t noise) | |
145 | { | |
146 | // update map with new hit | |
147 | UInt_t ind = fSensMap->GetIndex(dim0,dim1); | |
148 | AliITSUSDigit* oldItem = (AliITSUSDigit*)fSensMap->GetItem(ind); | |
c92b1537 | 149 | if (!oldItem) fSensMap->RegisterItem( new(fSensMap->GetFree()) AliITSUSDigit(fModule->GetIndex(),ind,noise) ); |
451f5018 | 150 | else oldItem->AddNoise(noise); |
151 | } | |
152 | ||
153 | //______________________________________________________________________ | |
154 | Int_t AliITSUSimulation::GenOrderedSample(UInt_t nmax,UInt_t ngen,TArrayI &vals,TArrayI &indx) | |
155 | { | |
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(); | |
162 | if (ngen>=nmax) { | |
163 | ngen = nmax-1; | |
164 | for (int i=(int)ngen;i--;) {valA[i]=indA[i]=i;} | |
165 | return ngen; | |
166 | } | |
167 | Bool_t rep; | |
168 | for (int i=0;i<(int)ngen;i++) { | |
169 | do { // exclude repetitions | |
170 | rep = kFALSE; | |
171 | valA[i] = gRandom->Rndm()*nmax; | |
172 | for (int j=i;j--;) if (valA[j]==valA[i]) {rep=kTRUE;break;} | |
173 | } while(rep); | |
174 | } | |
a11ef2e4 | 175 | Sort((int)ngen,valA,indA,kFALSE); |
451f5018 | 176 | return ngen; |
177 | } |