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 using namespace TMath;
27 ClassImp(AliITSUSimulation)
29 //______________________________________________________________________
30 AliITSUSimulation::AliITSUSimulation()
40 // Default constructor
42 //______________________________________________________________________
43 AliITSUSimulation::AliITSUSimulation(AliITSUSimuParam* sim,AliITSUSensMap* map)
53 // Default constructor
56 //__________________________________________________________________________
57 AliITSUSimulation::AliITSUSimulation(const AliITSUSimulation &s)
60 ,fCalibDead(s.fCalibDead)
61 ,fCalibNoisy(s.fCalibNoisy)
63 ,fSimuParam(s.fSimuParam)
71 //_________________________________________________________________________
72 AliITSUSimulation& AliITSUSimulation::operator=(const AliITSUSimulation &s)
74 // Assignment operator
75 if(&s == this) return *this;
77 fCalibDead = s.fCalibDead;
78 fCalibNoisy= s.fCalibNoisy;
79 fSensMap = s.fSensMap;
80 fSimuParam = s.fSimuParam;
86 //______________________________________________________________________
87 void AliITSUSimulation::InitSimulationModule(Int_t module, Int_t event, AliITSsegmentation* seg)
89 // This function creates maps to build the list of tracks for each
90 // summable digit. Inputs defined by base class.
98 //______________________________________________________________________
99 Bool_t AliITSUSimulation::AddSDigitsToModule(TSeqCollection *pItemArr,Int_t mask )
101 // Add Summable digits to module maps.
103 // pItemArr Array of AliITSpListItems (SDigits).
104 // mask Track number off set value
106 Int_t nItems = pItemArr->GetEntries();
109 for( Int_t i=0; i<nItems; i++ ) {
110 AliITSUSDigit * pItem = (AliITSUSDigit *)(pItemArr->At( i ));
111 if( pItem->GetModule() != fModule ) AliFatal(Form("SDigits module %d != current module %d: exit", pItem->GetModule(), fModule ));
112 if(pItem->GetSumSignal()>0.0 ) sig = kTRUE;
113 AliITSUSDigit* oldItem = (AliITSUSDigit*)fSensMap->GetItem(pItem);
115 oldItem = (AliITSUSDigit*)fSensMap->RegisterItem( new(fSensMap->GetFree()) AliITSUSDigit(*pItem) );
116 if (mask) oldItem->ShiftIndices(mask);
118 else oldItem->AddTo(mask, pItem);
123 //______________________________________________________________________
124 void AliITSUSimulation::UpdateMapSignal(UInt_t dim0,UInt_t dim1,Int_t trk,Int_t ht,Double_t signal)
126 // update map with new hit
127 UInt_t ind = fSensMap->GetIndex(dim0,dim1);
128 AliITSUSDigit* oldItem = (AliITSUSDigit*)fSensMap->GetItem(ind);
129 if (!oldItem) fSensMap->RegisterItem( new(fSensMap->GetFree()) AliITSUSDigit(trk,ht,fModule,ind,signal) );
130 else oldItem->AddSignal(trk,ht,signal);
133 //______________________________________________________________________
134 void AliITSUSimulation::UpdateMapNoise(UInt_t dim0,UInt_t dim1,Double_t noise)
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(fModule,ind,noise) );
140 else oldItem->AddNoise(noise);
143 //______________________________________________________________________
144 Int_t AliITSUSimulation::GenOrderedSample(UInt_t nmax,UInt_t ngen,TArrayI &vals,TArrayI &indx)
146 // generate random sample [0:nmax] of ngen variables, and fill orreder indices
147 // return actual number of generated values
148 if (vals.GetSize()<(int)ngen) vals.Set(ngen);
149 if (indx.GetSize()<(int)ngen) indx.Set(ngen);
150 int* valA = vals.GetArray();
151 int* indA = indx.GetArray();
154 for (int i=(int)ngen;i--;) {valA[i]=indA[i]=i;}
158 for (int i=0;i<(int)ngen;i++) {
159 do { // exclude repetitions
161 valA[i] = gRandom->Rndm()*nmax;
162 for (int j=i;j--;) if (valA[j]==valA[i]) {rep=kTRUE;break;}
165 Sort((int)ngen,valA,indA,kFALSE);