4c039060 |
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 | $Log$ |
c9a71be1 |
18 | Revision 1.10 2000/01/19 17:16:51 fca |
19 | Introducing a list of lists of hits -- more hits allowed for detector now |
20 | |
1cedd08a |
21 | Revision 1.9 1999/11/14 14:33:25 fca |
22 | Correct problems with distructors and pointers, thanks to I.Hrivnacova |
23 | |
6c854497 |
24 | Revision 1.8 1999/09/29 09:24:19 fca |
25 | Introduction of the Copyright and cvs Log |
26 | |
4c039060 |
27 | */ |
28 | |
fe4da5cc |
29 | /////////////////////////////////////////////////////////////////////////////// |
58005f18 |
30 | // |
31 | // An overview of the basic philosophy of the ITS code development |
32 | // and analysis is show in the figure below. |
fe4da5cc |
33 | //Begin_Html |
34 | /* |
a92b2b7d |
35 | <img src="picts/ITS/ITS_Analysis_schema.gif"> |
fe4da5cc |
36 | </pre> |
37 | <br clear=left> |
38 | <font size=+2 color=red> |
58005f18 |
39 | <p>Roberto Barbera is in charge of the ITS Offline code (1999). |
fe4da5cc |
40 | <a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>. |
41 | </font> |
42 | <pre> |
43 | */ |
44 | //End_Html |
58005f18 |
45 | // |
46 | // AliITS. Inner Traking System base class. |
47 | // This class contains the base procedures for the Inner Tracking System |
48 | // |
49 | //Begin_Html |
50 | /* |
a92b2b7d |
51 | <img src="picts/ITS/AliITS_Class_Diagram.gif"> |
58005f18 |
52 | </pre> |
53 | <br clear=left> |
54 | <font size=+2 color=red> |
55 | <p>This show the class diagram of the different elements that are part of |
56 | the AliITS class. |
57 | </font> |
58 | <pre> |
59 | */ |
60 | //End_Html |
61 | // |
62 | // Version: 0 |
63 | // Written by Rene Brun, Federico Carminati, and Roberto Barbera |
64 | // |
65 | // Version: 1 |
66 | // Modified and documented by Bjorn S. Nilsen |
67 | // July 11 1999 |
68 | // |
69 | // AliITS is the general base class for the ITS. Also see AliDetector for |
70 | // futher information. |
71 | // |
fe4da5cc |
72 | /////////////////////////////////////////////////////////////////////////////// |
73 | |
74 | #include <TMath.h> |
75 | #include <TRandom.h> |
76 | #include <TVector.h> |
77 | #include <TGeometry.h> |
78 | #include <TNode.h> |
79 | #include <TTUBE.h> |
bb8ac1e0 |
80 | |
58005f18 |
81 | #include "AliITSmodule.h" |
82 | #include "AliDetector.h" |
fe4da5cc |
83 | #include "AliITS.h" |
58005f18 |
84 | #include "TClonesArray.h" |
85 | #include "TObjArray.h" |
86 | #include "AliITShit.h" |
87 | #include "AliITSdigit.h" |
fe4da5cc |
88 | #include "AliRun.h" |
89 | |
fe4da5cc |
90 | ClassImp(AliITS) |
c9a71be1 |
91 | |
92 | //////////////////////////////////////////////////////////////////////// |
93 | // |
94 | // An overview of the basic philosophy of the ITS code development |
95 | // and analysis is show in the figure below. |
96 | //Begin_Html |
97 | /* |
98 | <img src="picts/ITS/ITS_Analysis_schema.gif"> |
99 | </pre> |
100 | <br clear=left> |
101 | <font size=+2 color=red> |
102 | <p>Roberto Barbera is in charge of the ITS Offline code (1999). |
103 | <a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>. |
104 | </font> |
105 | <pre> |
106 | */ |
107 | //End_Html |
108 | // |
109 | // Version: 0 |
110 | // Written by Rene Brun, Federico Carminati, and Roberto Barbera |
111 | // |
112 | // Version: 1 |
113 | // Modified and documented by Bjorn S. Nilsen |
114 | // July 11 1999 |
115 | // |
116 | // AliITS is the general base class for the ITS. Also see AliDetector for |
117 | // futher information. |
118 | // |
119 | // Data members: |
120 | // |
121 | // AliITSgeom *fITSgeom |
122 | // All of the geometry information about the active volumes that |
123 | // make up the ITS are described in the AliITSgeom class. This includes |
124 | // the transformation functions between the local and global coordinate |
125 | // systems and the like. See the full description found in the AliITSgeom |
126 | // class. Here in the AliITS class is kept the pointer to the geometry |
127 | // used in the simulations or that thought to be the correct one for the |
128 | // data. Until a more general class is define and a more appropriate |
129 | // place is found to keep this geometry information, it is kept here in |
130 | // AliITS. |
131 | // |
132 | // TObjArray *fITSpoints |
133 | // This is a pointer to the points, to be used by the tracking algorithms |
134 | // for example, found in the detectors of the ITS. To allow for the most |
135 | // general points structure it is defined to be a pointer to a TObjArray where |
136 | // each array element would be one point found in the ITS detectors. An |
137 | // Addpoints function is defined below. By default an array of 16 TObjects are |
138 | // defined during the initialization of AliITS. This is automatically expanded |
139 | // when necessary by the Addpoints function. |
140 | // |
141 | // Bool_t fEuclidOut |
142 | // This is a flag used to indicate that an Euclid compatible CAD |
143 | // file will be created upon the creation of the ITS Monte Carlo |
144 | // geometry definition, in the function CreatGeometry. If fEuclidOut is |
145 | // true, then a file called ITSgeometry.euc will be created. |
146 | // |
147 | // Int_t fIdN |
148 | // This variable contains the number of layers defined in the ITS |
149 | // geometry. It is primarily used as a size indicator for fIdSens and |
150 | // fIdName described below. In general the number of layers, ladders, or |
151 | // detectors should be gotten from the AliITSgeom functions. Upon |
152 | // creating the AliITS object it is set to zero. |
153 | // |
154 | // Int_t *fIdSens |
155 | // This is a pointer to an array containing the Monte Carlo volume |
156 | // numbers for the different layers of the ITS. These numbers are needed |
157 | // by the StepManager function to determine what layer a hit was on. It |
158 | // is sized and initialized in the Init function and the AliITSv? Init |
159 | // function, called after a call to CreateGeometry. Upon creating the |
160 | // AliITS object it points to zero. This variable is made a pointer |
161 | // in order to keep the maximum flexibility at this level of the code. |
162 | // |
163 | // char **fIdName |
164 | // This is a pointer to an array of characters containing the names of |
165 | // the different ITS layers as defined in the Monte Carlo geometry data- |
166 | // base. It is sized and filled in the AliITSv? Init function, called |
167 | // after a call to CreatGeometry. Upon creating the AliITS object it |
168 | // points to zero. This variable is make a pointer in order to keep the |
169 | // maximum flexibility at this level of the code. |
170 | // |
171 | // Member Functions: |
172 | // |
173 | // AliITS() |
174 | // The default constructor of the AliITS class. In addition to |
175 | // creating the AliITS class it zeros the variables fIshunt (a member |
176 | // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers |
177 | // fITSpoints, fIdSens, and fIdName. The AliDetector default constructor |
178 | // is also called. |
179 | // |
180 | // AliITS(const char *name, const char *title) |
181 | // The constructor of the AliITS class. In addition to creating the |
182 | // AliITS class, it allocates memory for the TClonesArrays fHits and |
183 | // fDigits, and for the TObjArray fITSpoints. It also zeros the variables |
184 | // fIshunt (a member of AliDetector class), fEuclidOut, and fIdN, and zeros |
185 | // the pointers fIdSens and fIdName. To help in displaying hits via the ROOT |
186 | // macro display.C AliITS also sets the marker color to red. The variables |
187 | // passes with this constructor, const char *name and *title, are used by |
188 | // the constructor of AliDetector class. See AliDetector class for a |
189 | // description of these parameters and its constructor functions. |
190 | // |
191 | // ~AliITS() |
192 | // The default destructor of the AliITS class. In addition to deleting |
193 | // the AliITS class it deletes the memory pointed to by the fHits, fDigits, |
194 | // fIdSens, fIdName, and fITSpoints. |
195 | // |
196 | // AddHit(Int_t track, Int_t *vol, Float_t *hits) |
197 | // The function to add information to the AliITShit class. See the |
198 | // AliITShit class for a full description. This function allocates the |
199 | // necessary new space for the hit information and passes the variable |
200 | // track, and the pointers *vol and *hits to the AliITShit constructor |
201 | // function. |
202 | // |
203 | // AddDigit(Int_t *track, Int_t *digits) |
204 | // The function to add information to the AliITSdigits class. See the |
205 | // AliITSdigits class for a full description. This function allocates the |
206 | // necessary new space for the digits information and passes the pointers |
207 | // *track and *digits to the AliITSdigits constructor function. |
208 | // |
209 | // BuildGeometry() |
210 | // This function builds a simple ITS geometry used by the ROOT macro |
211 | // display.C. In general the geometry as coded is wrong. |
212 | // |
213 | // CreateGeometry() |
214 | // This function builds the detailed geometry used by the Geant |
215 | // Monte Carlo. As defined here it is a dummy routine to be replaced |
216 | // by the version coded up in AliITSv? where the specific geometry to |
217 | // be used by the simulation is defined. See the definition of AliITSv5 |
218 | // or the other routines for a complete definition. |
219 | // |
220 | // CreateMaterials() |
221 | // This function defines the default materials used in the Geant |
222 | // Monte Carlo simulations. In general it is automatically replaced by |
223 | // the CreatMaterials routine defined in AliITSv?. Should the function |
224 | // CreateMaterials not exist for the geometry version you are using this |
225 | // one is used. See the definition found in AliITSv5 or the other routine |
226 | // for a complete definition. |
227 | // |
228 | // IsVersion() |
229 | // Returns the version number of the AliITS class. At present it is |
230 | // version 1. |
231 | // |
232 | // DistancetoPrimitive(Int_t x, Int_t y) |
233 | // A dummy routine used by the ROOT macro display.C to allow for the |
234 | // use of the mouse (pointing device) in the macro. In general this should |
235 | // never be called. If it is it returns the number 9999 for any value of |
236 | // x and y. |
237 | // |
238 | // Init() |
239 | // This routine initializes the AliITS class. It is intended to be called |
240 | // from the Init function in AliITSv?. Besides displaying a banner |
241 | // indicating that it has been called it initializes the array fIdSens. |
242 | // Therefore it should be called after a call to CreateGeometry. |
243 | // |
244 | // MakeBranch(Option_t *Opt=" ") |
245 | // Creates the TTree branch where the class AliITS is kept. |
246 | // |
247 | // SetEUCLID(bool_t euclid=1) |
248 | // Sets the flag fEuclidOut to true (default) of false (euclid=0). |
249 | // By setting or clearing the fEuclidOut flag you can controls whether |
250 | // or not a euclid formatted output file of the ITS geometry is written. |
251 | // If fEuclidOut is set true then a file called ITSgeometry.euc will be |
252 | // written after the ITS geometry is defined in the Monte Carlo. If |
253 | // fEuclidOut is set false then no file is created. |
254 | // |
255 | // StepManager() |
256 | // Dummy routine which is replaced by the routine StepManager() defined |
257 | // in AliITSv?. If no such routine exist then this routine returns zero. |
258 | // See AliITSv? for a detailed description of the step manager routines. |
259 | // |
260 | // GetITSgeom() |
261 | // Returns the value of the pointer fITSgeom. This is used to get |
262 | // access to the ITS geometry stored in the file. See AliITSgeom for a |
263 | // full description of the geometry package. |
264 | // |
265 | // GetITSpoints() |
266 | // Returns the value of the pointer fITSpoints. This is used to get |
267 | // access to the ITS cluster objects, if filled, stored in the file. See |
268 | // AliITSCluster for a full description of the cluster data. |
269 | //////////////////////////////////////////////////////////////////////// |
fe4da5cc |
270 | //_____________________________________________________________________________ |
6c854497 |
271 | AliITS::AliITS() { |
fe4da5cc |
272 | // |
273 | // Default initialiser for ITS |
58005f18 |
274 | // The default constructor of the AliITS class. In addition to |
275 | // creating the AliITS class it zeros the variables fIshunt (a member |
276 | // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers |
6c854497 |
277 | // fITSpoints, fIdSens, and fIdName. |
fe4da5cc |
278 | // |
58005f18 |
279 | fITSpoints = 0; |
280 | fIshunt = 0; |
281 | fEuclidOut = 0; |
282 | fIdN = 0; |
283 | fIdName = 0; |
284 | fIdSens = 0; |
6c854497 |
285 | fITSmodules = 0; |
58005f18 |
286 | |
fe4da5cc |
287 | } |
fe4da5cc |
288 | //_____________________________________________________________________________ |
58005f18 |
289 | AliITS::AliITS(const char *name, const char *title):AliDetector(name,title){ |
fe4da5cc |
290 | // |
291 | // Default initialiser for ITS |
58005f18 |
292 | // The constructor of the AliITS class. In addition to creating the |
293 | // AliITS class, it allocates memory for the TClonesArrays fHits and |
294 | // fDigits, and for the TObjArray fITSpoints. It also zeros the variables |
295 | // fIshunt (a member of AliDetector class), fEuclidOut, and fIdN, and zeros |
296 | // the pointers fIdSens and fIdName. To help in displaying hits via the ROOT |
297 | // macro display.C AliITS also sets the marker color to red. The variables |
298 | // passes with this constructor, const char *name and *title, are used by |
299 | // the constructor of AliDetector class. See AliDetector class for a |
300 | // description of these parameters and its constructor functions. |
fe4da5cc |
301 | // |
58005f18 |
302 | |
303 | fHits = new TClonesArray("AliITShit", 1560); |
1cedd08a |
304 | gAlice->AddHitList(fHits); |
58005f18 |
305 | fDigits = new TClonesArray("AliITSdigit",1000); |
306 | fITSpoints = new TObjArray(); |
6c854497 |
307 | fITSmodules = 0; //new AliITSmodules(); |
58005f18 |
308 | |
309 | fIshunt = 0; |
310 | fEuclidOut = 0; |
311 | fIdN = 0; |
312 | fIdName = 0; |
313 | fIdSens = 0; |
314 | |
fe4da5cc |
315 | SetMarkerColor(kRed); |
58005f18 |
316 | |
fe4da5cc |
317 | } |
318 | |
319 | //_____________________________________________________________________________ |
58005f18 |
320 | AliITS::~AliITS(){ |
fe4da5cc |
321 | // |
322 | // Default distructor for ITS |
58005f18 |
323 | // The default destructor of the AliITS class. In addition to deleting |
324 | // the AliITS class it deletes the memory pointed to by the fHits, fDigits, |
325 | // fIdSens, fIdName, and fITSpoints. |
fe4da5cc |
326 | // |
327 | delete fHits; |
328 | delete fDigits; |
58005f18 |
329 | if(fIdName!=0) delete[] fIdName; |
330 | if(fIdSens!=0) delete[] fIdSens; |
331 | delete fITSmodules; |
332 | if(fITSpoints!=0) delete fITSpoints; |
fe4da5cc |
333 | } |
334 | |
335 | //_____________________________________________________________________________ |
58005f18 |
336 | void AliITS::AddDigit(Int_t *tracks, Int_t *digits){ |
fe4da5cc |
337 | // |
338 | // Add an ITS Digit |
58005f18 |
339 | // The function to add information to the AliITSdigits class. See the |
340 | // AliITSdigits class for a full description. This function allocates the |
341 | // necessary new space for the digits information and passes the pointers |
342 | // *track and *digits to the AliITSdigits constructor function. |
fe4da5cc |
343 | // |
344 | TClonesArray &ldigits = *fDigits; |
345 | new(ldigits[fNdigits++]) AliITSdigit(tracks,digits); |
346 | } |
347 | |
58005f18 |
348 | Int_t AliITS::AddDigit(AliITSdigit* d) { |
349 | |
350 | fDigits->Add(d); |
351 | fNdigits = fDigits->GetEntriesFast(); |
352 | return fNdigits; |
353 | } |
354 | |
fe4da5cc |
355 | //_____________________________________________________________________________ |
58005f18 |
356 | void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){ |
fe4da5cc |
357 | // |
358 | // Add an ITS hit |
58005f18 |
359 | // The function to add information to the AliITShit class. See the |
360 | // AliITShit class for a full description. This function allocates the |
361 | // necessary new space for the hit information and passes the variable |
362 | // track, and the pointers *vol and *hits to the AliITShit constructor |
363 | // function. |
fe4da5cc |
364 | // |
365 | TClonesArray &lhits = *fHits; |
366 | new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits); |
367 | } |
fe4da5cc |
368 | //_____________________________________________________________________________ |
58005f18 |
369 | Int_t AliITS::DistancetoPrimitive(Int_t , Int_t ){ |
fe4da5cc |
370 | // |
371 | // Distance from mouse to ITS on the screen. Dummy routine |
58005f18 |
372 | // A dummy routine used by the ROOT macro display.C to allow for the |
373 | // use of the mouse (pointing device) in the macro. In general this should |
374 | // never be called. If it is it returns the number 9999 for any value of |
375 | // x and y. |
fe4da5cc |
376 | // |
377 | return 9999; |
378 | } |
379 | |
380 | //_____________________________________________________________________________ |
58005f18 |
381 | void AliITS::Init(){ |
fe4da5cc |
382 | // |
383 | // Initialise ITS after it has been built |
58005f18 |
384 | // This routine initializes the AliITS class. It is intended to be called |
385 | // from the Init function in AliITSv?. Besides displaying a banner |
386 | // indicating that it has been called it initializes the array fIdSens. |
387 | // Therefore it should be called after a call to CreateGeometry. |
fe4da5cc |
388 | // |
389 | Int_t i; |
fe4da5cc |
390 | // |
391 | printf("\n"); |
392 | for(i=0;i<35;i++) printf("*"); |
393 | printf(" ITS_INIT "); |
394 | for(i=0;i<35;i++) printf("*"); |
395 | printf("\n"); |
396 | // |
397 | // |
58005f18 |
398 | for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]); |
fe4da5cc |
399 | // |
400 | for(i=0;i<80;i++) printf("*"); |
401 | printf("\n"); |
402 | } |
403 | |
404 | //_____________________________________________________________________________ |
58005f18 |
405 | void AliITS::MakeBranch(Option_t* option){ |
fe4da5cc |
406 | // |
407 | // Create Tree branches for the ITS. |
58005f18 |
408 | // Creates the TTree branch where the class AliITS is kept. |
fe4da5cc |
409 | // |
410 | Int_t buffersize = 4000; |
411 | char branchname[10]; |
412 | sprintf(branchname,"%s",GetName()); |
413 | |
414 | AliDetector::MakeBranch(option); |
415 | |
416 | char *D = strstr(option,"D"); |
417 | |
418 | if (fDigits && gAlice->TreeD() && D) { |
419 | gAlice->TreeD()->Branch(branchname,&fDigits, buffersize); |
420 | printf("Making Branch %s for digits\n",branchname); |
58005f18 |
421 | } // end if |
fe4da5cc |
422 | } |
423 | |
58005f18 |
424 | //____________________________________________________________________________ |
425 | void AliITS::Streamer(TBuffer &R__b){ |
426 | // Stream an object of class AliITS. |
427 | Int_t i,j,l; |
428 | |
429 | if (R__b.IsReading()) { |
430 | Version_t R__v = R__b.ReadVersion(); |
431 | if (R__v == 1) { |
432 | AliDetector::Streamer(R__b); |
433 | R__b >> fITSgeom; |
434 | // R__b >> fITSmodules; //We do not write out modules so don't read them |
435 | R__b >> fITSpoints; |
436 | R__b >> fEuclidOut; |
437 | R__b >> fIdN; |
438 | if(fIdSens!=0) delete[] fIdSens; |
439 | if(fIdName!=0) delete[] fIdName; |
440 | fIdSens = new Int_t[fIdN]; |
441 | fIdName = new char*[fIdN]; |
442 | for(i=0;i<fIdN;i++) R__b >> fIdSens[i]; |
443 | for(i=0;i<fIdN;i++){ |
444 | R__b >> l; |
445 | fIdName[i] = new char[l+1]; // add room for null character. |
446 | for(j=0;j<l;j++) R__b >> fIdName[i][j]; |
447 | fIdName[i][l] = '\0'; // Null terminate this string. |
448 | } // end for i |
449 | R__b >> fMajorVersion; |
450 | R__b >> fMinorVersion; |
451 | } // end if (R__v) |
452 | } else { |
453 | R__b.WriteVersion(AliITS::IsA()); |
454 | AliDetector::Streamer(R__b); |
455 | R__b << fITSgeom; |
456 | // R__b << fITSmodules; //We don't want to write out the modules class. |
457 | R__b << fITSpoints; |
458 | R__b << fEuclidOut; |
459 | R__b << fIdN; |
460 | for(i=0;i<fIdN;i++) R__b <<fIdSens[i]; |
461 | for(i=0;i<fIdN;i++){ |
462 | l = strlen(fIdName[i]); |
463 | R__b << l; |
464 | for(j=0;j<l;j++) R__b << fIdName[i][j]; |
465 | } // end for i |
466 | R__b << fMajorVersion; |
467 | R__b << fMinorVersion; |
468 | } |
fe4da5cc |
469 | } |