]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/UPGRADE/AliITSUSimulation.cxx
Fixes, changes in debug info logging
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSUSimulation.cxx
CommitLineData
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 27using namespace TMath;
451f5018 28
29ClassImp(AliITSUSimulation)
30
31//______________________________________________________________________
32AliITSUSimulation::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//______________________________________________________________________
46AliITSUSimulation::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//__________________________________________________________________________
61AliITSUSimulation::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//_________________________________________________________________________
77AliITSUSimulation& 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 93void 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//______________________________________________________________________
109Bool_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//______________________________________________________________________
b2679935 134void AliITSUSimulation::UpdateMapSignal(UInt_t col,UInt_t row,Int_t trk,Int_t ht,Double_t signal, Int_t roCycle)
451f5018 135{
136 // update map with new hit
b2679935 137 // Note: roCycle can be anything between -kMaxROCycleAccept : kMaxROCycleAccept, but the index should be built with pos.number
138 UInt_t ind = fSensMap->GetIndex(col,row,roCycle+kMaxROCycleAccept);
451f5018 139 AliITSUSDigit* oldItem = (AliITSUSDigit*)fSensMap->GetItem(ind);
b2679935 140 if (!oldItem) fSensMap->RegisterItem( new(fSensMap->GetFree()) AliITSUSDigit(trk,ht,fModule->GetIndex(),ind,signal,roCycle) );
451f5018 141 else oldItem->AddSignal(trk,ht,signal);
142}
143
144//______________________________________________________________________
b2679935 145void AliITSUSimulation::UpdateMapNoise(UInt_t col,UInt_t row,Double_t noise, Int_t roCycle)
451f5018 146{
147 // update map with new hit
b2679935 148 UInt_t ind = fSensMap->GetIndex(col,row,roCycle);
451f5018 149 AliITSUSDigit* oldItem = (AliITSUSDigit*)fSensMap->GetItem(ind);
b2679935 150 if (!oldItem) fSensMap->RegisterItem( new(fSensMap->GetFree()) AliITSUSDigit(fModule->GetIndex(),ind,noise,roCycle) );
451f5018 151 else oldItem->AddNoise(noise);
152}
153
154//______________________________________________________________________
155Int_t AliITSUSimulation::GenOrderedSample(UInt_t nmax,UInt_t ngen,TArrayI &vals,TArrayI &indx)
156{
157 // generate random sample [0:nmax] of ngen variables, and fill orreder indices
158 // return actual number of generated values
159 if (vals.GetSize()<(int)ngen) vals.Set(ngen);
160 if (indx.GetSize()<(int)ngen) indx.Set(ngen);
161 int* valA = vals.GetArray();
162 int* indA = indx.GetArray();
163 if (ngen>=nmax) {
164 ngen = nmax-1;
165 for (int i=(int)ngen;i--;) {valA[i]=indA[i]=i;}
166 return ngen;
167 }
168 Bool_t rep;
169 for (int i=0;i<(int)ngen;i++) {
170 do { // exclude repetitions
171 rep = kFALSE;
172 valA[i] = gRandom->Rndm()*nmax;
173 for (int j=i;j--;) if (valA[j]==valA[i]) {rep=kTRUE;break;}
174 } while(rep);
175 }
a11ef2e4 176 Sort((int)ngen,valA,indA,kFALSE);
451f5018 177 return ngen;
178}