]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSDetTypeSim.cxx
New Class' to A) separate out the simulation from the reconstruction. and
[u/mrichter/AliRoot.git] / ITS / AliITSDetTypeSim.cxx
CommitLineData
3b9df642 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/*
17 $Id$
18*/
19
20/*********************************************************************
21 * This class defines the "Standard" reconstruction for the ITS
22 * detector.
23 **********************************************************************/
24#include "AliITSDetTypeSim.h"
25
26ClassImp(AliITSDetTypeSim)
27
28//----------------------------------------------------------------------
29AliITSDetTypeSim::AliITSDetTypeSim():
30TObject(),
31fGeom(), //
32fSimulation(), // [NDet]
33fSegmentation(), // [NDet]
34fResponse(), // [NMod]
35fPreProcess(), // [] e.g. Fill fHitModule with hits
36fPostProcess(), // [] e.g. Wright Raw data
37fHitModule(), //! [NMod][Nhits]
38fNhits(0), //! number of hits
39fHits(), //! local pointer
40fNSDigits(0), //! number of SDigits
41fSDigits(), //! [NMod][NSDigits]
42fNDigits(0), //! number of Digits
43fDigits(), //! [NMod][NDigits]
44fHitClassName(), // String with Hit class name.
45fSDigClassName(),// String with SDigit class name.
46fDigClassName(){ // String with digit class name.
47 // Default Constructor
48 // Inputs:
49 // none.
50 // Outputs:
51 // none.
52 // Return:
53 // A properly zero-ed AliITSDetTypeSim class.
54}
55//----------------------------------------------------------------------
56AliITSDetTypeSim::~AliITSDetTypeSim(){
57 // Destructor
58 // Inputs:
59 // none.
60 // Outputs:
61 // none.
62 // Return:
63 // Nothing.
64
65 delete fGeom;
66 delete fSimulation;
67 delete fSegmentation;
68 delete fResponse;
69 delete fPreProcess;
70 delete fPostProcess;
71 delete fHitModule;
72 // Do not delete fSDigits Not owned by this class see AliITS
73 // Do not delete fDigits Not owned by this class see AliITS
74}
75//----------------------------------------------------------------------
76AliITSDetTypeSim::AliITSDetTypeSim(const AliITSDetTypeSim &s) : TObject(s){
77 // Copy Constructor for object AliITSDetTypeSim
78 // Inputs:
79 // AliITSDetTypeSim &s The copy Sourse
80 // Outputs:
81 // none.
82 // Return:
83 // A new AliITSDetTypeSim Object with the same data as that in the
84 // source s.
85
86 if(&s==this) return;
87 *this = source;
88 return;
89}
90//----------------------------------------------------------------------
91AliITSDetTypeSim::operator=(const AliITSDetTypeSim &s) : TObject(s){
92 // The = operator for object AliITSDetTypeSim
93 // Inputs:
94 // AliITSDetTypeSim &s The copy Sourse
95 // Outputs:
96 // none.
97 // Return:
98 // A new AliITSDetTypeSim Object with the same data as that in the
99 // source s.
100
101 if(&s==this) return;
102 // Make copies of the objects in the arrays as well
103 this->fGeom = new AliITSgeom(s.fGeom);// Create a new instance
104 if(this->fSimulation!=0) delete this->fSimulation;
105 this->fSimulation = new TObjArray(s.fSimulation->GetSize(),
106 s.fSimulation->LowerBound());
107 for(i=0;i<s.fSimulation->GetSize();i++) if(s.fSimulation[i]!=0)
108 this->fSimulation[i] = new AliITSsimulation(*(s.fSimulation[i]));
109 else this->fSimulation[i] = 0;
110 if(this->fSegmentation!=0) delete this->fSegentation;
111 this->fSegmentation = new TObjArray(s.fSegmentation->GetSize(),
112 s.fSegmentation->GetLowerBound());
113 for(i=0;i<s.fSegmentation->GetSize();i++) if(s.fSegmentation[i]!=0)
114 this->fSegmentation[i] = new AliITSsegmentation(*(s.fSegmentation[i]));
115 else this->fSegmentation[i] = 0;
116 if(this->fResponse!=0) delete fResponse;
117 this->fResponse = new TObjArray(s.fResponse->GetSize(),
118 s.fResponse->GetLowerBound());
119 for(i=0;i<s.fResponse->GetSize();i++) if(s.Response[i]!=0)
120 this->fResponse[i] = new AliITSresponse(*(s.fResponse[i]));
121 else this->fResponse[i] = 0;
122 this->fPreProcess = s.fPreProcess; // Improper copy
123 this->fPostProcess = s.fPostProcess; // Improper copy
124 this->fHitModule = s.fHitModule; // Improper copy
125 this->fNhits = s.fNhits; //
126 this->fHits = s.fHits; // copy pointer address only
127 this->fNSDigits = s.fNSDigits; //
128 this->fSDigits = s.fSDigits; // copy pointer address only
129 this->fNDigits = s.fNDigits; //
130 this->fDigits = s.fDigits; // copy pointer address only
131 this->fHitClassName = s.fHitClassName;
132 this->fSDigitClassName = s.fSDigitClassName;
133 this->fDigitClassName = s.FDigitClassName;
134 return *this;
135}
136//______________________________________________________________________
137void AliITSDetTypeSim::InitModules(Int_t size,Int_t &nmodules){
138 // Initialize the modules array.
139 // Inputs:
140 // Int_t size Size of array of the number of modules to be
141 // created. If size <=0 then the number of modules
142 // is gotten from AliITSgeom class kept in fGeom.
143 // Outputs:
144 // Int_t &nmodules The number of modules existing.
145 // Return:
146 // none.
147
148 if(fHitModule){
149 fHitModule->Delete();
150 delete fHitModule;
151 } // end fir fITSmoudles
152
153 Int_t nl,indexMAX,index;
154
155 if(size<=0){ // default to using data stored in AliITSgeom
156 if(fGeom==0) {
157 Error("InitModules","fGeom not defined");
158 return;
159 } // end if fGeom==0
160 nl = fGeom->GetNlayers();
161 indexMAX = fGeom->GetIndexMax();
162 nmodules = indexMAX;
163 fHitModule = new TObjArray(indexMAX);
164 for(index=0;index<indexMAX;index++){
165 fHitModule->AddAt( new AliITSmodule(index),index);
166 } // end for index
167 }else{
168 fHitModule = new TObjArray(size);
169 for(index=0;index<size;index++) {
170 fHitModule->AddAt( new AliITSmodule(index),index);
171 } // end for index
172
173 nmodules = size;
174 } // end i size<=0
175}
176//______________________________________________________________________
177void AliITSDetTypeSim::FillModules(TTree *treeH, Int_t mask) {
178 // fill the modules with the sorted by module hits;
179 // can be called many times to do a merging
180 // Inputs:
181 // TTree *treeH The tree containing the hits to be copied into
182 // the modules.
183 // Int_t mask The track number mask to indecate which file
184 // this hits came from.
185 // Outputs:
186 // none.
187 // Return:
188 // none.
189
190 if (treeH == 0x0){Error("FillModules","Tree is NULL");return;}
191
192 Int_t lay,lad,det,index;
193 AliITShit *itsHit=0;
194 AliITSmodule *mod=0;
195 TBranch *branch = treeH->GetBranch(fHitClassName.Data());
196 if (!branch){Error("FillModules","%s branch in TreeH not found",
197 fHitClassName.Data());return;} // end if !branch
198 branch->SetAddress(&fHits);
199 Int_t nTracks =(Int_t) treeH->GetEntries();
200 Int_t iPrimTrack,h;
201 for(iPrimTrack=0; iPrimTrack<nTracks; iPrimTrack++){
202 ResetHits();
203 Int_t nBytes = treeH->GetEvent(iPrimTrack);
204 if (nBytes <= 0) continue;
205 Int_t nHits = fHits->GetEntriesFast();
206 for(h=0; h<nHits; h++){
207 itsHit = (AliITShit *)fHits->UncheckedAt(h);
208 itsHit->GetDetectorID(lay,lad,det);
209 if (fGeom) index = fGeom->GetModuleIndex(lay,lad,det);
210 else index=det-1; // This should not be used.
211 mod = GetModule(index);
212 itsHit->SetTrack(itsHit->GetTrack()+mask); // Set track mask.
213 mod->AddHit(itsHit,iPrimTrack,h);
214 } // end loop over hits
215 } // end loop over tracks
216}