]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSv5symm.cxx
New TTask based method to do Digits To clusters. Works with files of multiple
[u/mrichter/AliRoot.git] / ITS / AliITSv5symm.cxx
CommitLineData
e5745edc 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$
cbfdea0d 18Revision 1.12 2001/05/30 15:55:35 hristov
19Strings compared instead of pointers
20
268b9c60 21Revision 1.11 2001/05/30 14:04:31 hristov
22Dynamic cast replaced (F.Carminati)
23
4154d3d8 24Revision 1.10 2001/05/25 06:47:16 hristov
25Bug fix in the creation of the AliITSgeom::fShape entry for SPD. Now there is both a proper shape entry and a default, should there be future changes. This bug was related to fMinorVersion=3 was not antisipated. (B.Nilsen)
26
3e225ff6 27Revision 1.9 2001/04/18 12:07:37 barbera
28Number of modules in layer 5 and 6 re-set to 23 and 26
29
18c21458 30Revision 1.8 2001/03/23 00:12:23 nilsen
31Set Reading of AliITSgeom data from Geant3 common blocks as the default and
32not a .det file. Removed redundent calls to BuildGeometry.
33
0646a0e8 34Revision 1.7 2001/02/13 16:53:35 nilsen
35Fixed a but when trying to use GEANT4. Needed to replace
36if(!((TGeant3*)gMC)) with if(!(dynamic_casst<TGeant3*>(gMC)))
37because just casting gMC to be TGeant3* even when it realy is a TGeant3 pointer
38did not result in a zero value. For AliITSv5asymm and AliITSv5symm, needed
39to fix a bug in the initilizers and a bug in BuildGeometry. This is now done
40in the same way as in AliITSv5.cxx.
41
9a4c6ea3 42Revision 1.6 2001/02/09 20:06:26 nilsen
43Fixed bug in distructor. Can't distroy fixxed length arrays. Thanks Peter.
44
58e13d99 45Revision 1.5 2001/02/09 00:05:31 nilsen
46Added fMajor/MinorVersion variables and made other changes to better make
47use of the new code changes in AliITSgeom related classes.
48
bae7e562 49Revision 1.4 2001/02/02 23:57:29 nilsen
50Added include file that are no londer included in AliITSgeom.h
51
d953664a 52Revision 1.3 2001/01/30 09:23:13 hristov
53Streamers removed (R.Brun)
54
a8a6107b 55Revision 1.2 2000/11/30 11:13:11 barbera
56 Added changes suggested by Federico Carminati on nov, 30, 2000
57
a07ced09 58Revision 1.1 2000/10/07 15:46:29 barbera
59Version 5 of the geometry with symmetric services
60
e5745edc 61Revision 1.25 2000/10/05 20:50:00 nilsen
62Now using root generated streamers.
63
64Revision 1.14.4.12 2000/10/02 16:04:03 barbera
65Forward declarations added
66
67Revision 1.22 2000/07/10 16:07:19 fca
68Release version of ITS code
69
70Revision 1.14.4.4 2000/05/19 10:10:21 nilsen
71fix for bug with HP and Sun unix + fix for event display in ITS-working branch
72
73Revision 1.14.4.3 2000/03/04 23:46:38 nilsen
74Fixed up the comments/documentation.
75
76Revision 1.14.4.2 2000/03/02 21:53:02 nilsen
77To make it compatable with the changes in AliRun/AliModule.
78
79Revision 1.14.4.1 2000/01/12 19:03:33 nilsen
80This is the version of the files after the merging done in December 1999.
81See the ReadMe110100.txt file for details
82
83Revision 1.14 1999/10/22 08:16:49 fca
84Correct destructors, thanks to I.Hrivnacova
85
86Revision 1.13 1999/10/06 10:15:19 fca
87Correct bug in allocation of layer name and add destructor
88
89Revision 1.12 1999/10/05 08:05:09 fca
90Minor corrections for uninitialised variables.
91
92Revision 1.11 1999/09/29 09:24:20 fca
93Introduction of the Copyright and cvs Log
94
95*/
96
97///////////////////////////////////////////////////////////////////////////////
98//
99// Inner Traking System version 5 with symmetric services
100// This class contains the base procedures for the Inner Tracking System
101//
102// Authors: R. Barbera, B. S. Nilsen.
103// version 5.
104// Created October 7 2000.
105//
106///////////////////////////////////////////////////////////////////////////////
d953664a 107#include <iostream.h>
108#include <iomanip.h>
e5745edc 109#include <stdio.h>
110#include <stdlib.h>
111#include <TMath.h>
112#include <TGeometry.h>
113#include <TNode.h>
114#include <TTUBE.h>
115#include <TFile.h> // only required for Tracking function?
116#include <TCanvas.h>
117#include <TObjArray.h>
a07ced09 118#include <TLorentzVector.h>
e5745edc 119#include <TObjString.h>
120#include <TClonesArray.h>
121#include <TBRIK.h>
122#include <TSystem.h>
123
124#include "AliMC.h"
125#include "AliRun.h"
cbfdea0d 126#include "AliGeant3.h"
e5745edc 127#include "AliITShit.h"
bae7e562 128#include "AliITSGeant3Geometry.h"
e5745edc 129#include "AliITS.h"
130#include "AliITSv5symm.h"
131#include "AliITSgeom.h"
bae7e562 132#include "AliITSgeomSPD.h"
133#include "AliITSgeomSDD.h"
134#include "AliITSgeomSSD.h"
e5745edc 135
136ClassImp(AliITSv5symm)
137
138//_____________________________________________________________________________
139AliITSv5symm::AliITSv5symm() {
140////////////////////////////////////////////////////////////////////////
141// Standard default constructor for the ITS version 5.
142////////////////////////////////////////////////////////////////////////
bae7e562 143 Int_t i;
e5745edc 144
145 fIdN = 0;
146 fIdName = 0;
147 fIdSens = 0;
bae7e562 148 fEuclidOut = kFALSE; // Don't write Euclide file
149 fGeomDetOut = kFALSE; // Don't write .det file
0646a0e8 150 fGeomDetIn = kFALSE; // Don't Read .det file
151 fGeomOldDetIn = kFALSE; // Don't Read old formatted .det file
bae7e562 152 fMajorVersion = IsVersion();
153 fMinorVersion = 2;
154 for(i=0;i<60;i++) fRead[i] = '\0';
155 for(i=0;i<60;i++) fWrite[i] = '\0';
156 for(i=0;i<60;i++) fEuclidGeomDet[i] = '\0';
157}
158//_____________________________________________________________________________
159AliITSv5symm::AliITSv5symm(const char *name, const char *title) : AliITS(name, title){
160/////////////////////////////////////////////////////////////////////////////
161// Standard constructor for the ITS version 5 with symmetrical services.
162/////////////////////////////////////////////////////////////////////////////
163 Int_t i;
164
165 fIdN = 6;
166 fIdName = new TString[fIdN];
167 fIdName[0] = "ITS1";
168 fIdName[1] = "ITS2";
169 fIdName[2] = "ITS3";
170 fIdName[3] = "ITS4";
171 fIdName[4] = "ITS5";
172 fIdName[5] = "ITS6";
173 fIdSens = new Int_t[fIdN];
174 for (i=0;i<fIdN;i++) fIdSens[i] = 0;
175 fEuclidOut = kFALSE; // Don't write Euclide file
176 fGeomDetOut = kFALSE; // Don't write .det file
0646a0e8 177 fGeomDetIn = kFALSE; // Don't Read .det file
178 fGeomOldDetIn = kFALSE; // Don't Read old formatted .det file
bae7e562 179 fMajorVersion = IsVersion();
180 fMinorVersion = 2;
181 for(i=0;i<60;i++) fRead[i] = '\0';
182 for(i=0;i<60;i++) fWrite[i] = '\0';
183
184 fEuclidMaterial = "$ALICE_ROOT/Euclid/ITSgeometry_5symm.tme";
185 fEuclidGeometry = "$ALICE_ROOT/Euclid/ITSgeometry_5symm.euc";
186 strncpy(fEuclidGeomDet,"$ALICE_ROOT/ITS/ITSgeometry_v5symm.det",60);
187 strncpy(fRead,fEuclidGeomDet,60);
188 strncpy(fWrite,fEuclidGeomDet,60);
e5745edc 189}
190//____________________________________________________________________________
191AliITSv5symm::AliITSv5symm(const AliITSv5symm &source){
192////////////////////////////////////////////////////////////////////////
193// Copy Constructor for ITS version 5.
194////////////////////////////////////////////////////////////////////////
195 if(&source == this) return;
bae7e562 196 Warning("Copy Constructor","Not allowed to copy AliITSv5symm");
e5745edc 197 return;
198}
199//_____________________________________________________________________________
200AliITSv5symm& AliITSv5symm::operator=(const AliITSv5symm &source){
201////////////////////////////////////////////////////////////////////////
bae7e562 202// Assignment operator for the ITS version 5.
e5745edc 203////////////////////////////////////////////////////////////////////////
204
205 if(&source == this) return *this;
bae7e562 206 Warning("= operator","Not allowed to copy AliITSv5symm");
e5745edc 207 return *this;
208
209}
210//_____________________________________________________________________________
211AliITSv5symm::~AliITSv5symm() {
212////////////////////////////////////////////////////////////////////////
213// Standard destructor for the ITS version 5.
214////////////////////////////////////////////////////////////////////////
e5745edc 215}
216//_____________________________________________________________________________
217void AliITSv5symm::BuildGeometry(){
218////////////////////////////////////////////////////////////////////////
219// Geometry builder for the ITS version 5.
220////////////////////////////////////////////////////////////////////////
221 //
222 // Build ITS TNODE geometry for event display using detailed geometry.
223 // This function builds a simple ITS geometry used by the ROOT macro
224 // ITSdisplay.C.
225
226 TNode *top;
227 TNode *nd;
228 //const int kColorITSSPD=kRed;
229 //const int kColorITSSDD=kGreen;
230 const int kColorITSSSD=kBlue;
231 //
e5745edc 232 AliITSgeom *gm = this->GetITSgeom();
9a4c6ea3 233 if(gm==0) return;
234 top=gAlice->GetGeometry()->GetNode("alice");
e5745edc 235
236 Int_t lay,lad,det,i;
237 Text_t name[10];
238 Float_t xg[3];
239 Float_t rt[9];
240 Double_t rtd[9];
241 TBRIK *box;
242 TRotMatrix *rm;
243 //TCanvas *c1 = new TCanvas("c1","ITS");
244
245 for(lay=1;lay<=2;lay++)
246 for(lad=1;lad<=gm->GetNladders(lay);lad++)
247 for(det=1;det<=gm->GetNdetectors(lay);det++){
248 try {
249 box = new TBRIK ("ActiveSPD","Active volume of SPD","SPD SI DET",
250 0.64,0.0075,4.19);
251 } catch (...) {
252 cout << "EXCEPTION in box = new TBRIK" << endl;
253 return;
254 }
255 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
256 gm->GetRotMatrix(lay,lad,det,rt);
257 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
258 for(i=0;i<9;i++) rtd[i] = rt[i];
259 try {
260 rm = new TRotMatrix(name,name,rtd);
261 } catch (...) {
262 cout << "EXCEPTION in new TRotMatrix" << endl;
263 return;
264 }
265 top->cd();
266 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
267 try {
268 nd = new TNode("SPD"," ",box,xg[0],xg[1],xg[2],rm);
269 } catch (...) {
270 cout << "EXCEPTION in new TNode" << endl;
271 return;
272 }
273 nd->SetLineColor(kColorITSSSD);
274 fNodes->Add(nd);
275 }
276
277 for(lay=3;lay<=3;lay++)
278 for(lad=1;lad<=gm->GetNladders(lay);lad++)
279 for(det=1;det<=gm->GetNdetectors(lay);det++){
280 try {
281 box = new TBRIK ("ActiveSDD","Active volume of SDD","SDD SI DET",
282 3.5,0.014,3.763);
283 } catch (...) {
284 cout << "EXCEPTION in box = new TBRIK" << endl;
285 return;
286 }
287 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
288 gm->GetRotMatrix(lay,lad,det,rt);
289 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
290 for(i=0;i<9;i++) rtd[i] = rt[i];
291 try {
292 rm = new TRotMatrix(name,name,rtd);
293 } catch (...) {
294 cout << "EXCEPTION in new TRotMatrix" << endl;
295 return;
296 }
297 top->cd();
298 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
299 try {
300 nd = new TNode("SDD"," ",box,xg[0],xg[1],xg[2],rm);
301 } catch (...) {
302 cout << "EXCEPTION in new TNode" << endl;
303 return;
304 }
305 nd->SetLineColor(kColorITSSSD);
306 fNodes->Add(nd);
307 }
308
309 for(lay=4;lay<=4;lay++)
310 for(lad=1;lad<=gm->GetNladders(lay);lad++)
311 for(det=1;det<=gm->GetNdetectors(lay);det++){
312 try {
313 box = new TBRIK ("ActiveSDD","Active volume of SDD","SDD SI DET",
314 3.5,0.014,3.763);
315 } catch (...) {
316 cout << "EXCEPTION in box = new TBRIK" << endl;
317 return;
318 }
319 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
320 gm->GetRotMatrix(lay,lad,det,rt);
321 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
322 for(i=0;i<9;i++) rtd[i] = rt[i];
323 try {
324 rm = new TRotMatrix(name,name,rtd);
325 } catch (...) {
326 cout << "EXCEPTION in new TRotMatrix" << endl;
327 return;
328 }
329 top->cd();
330 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
331 try {
332 nd = new TNode("SDD"," ",box,xg[0],xg[1],xg[2],rm);
333 } catch (...) {
334 cout << "EXCEPTION in new TNode" << endl;
335 return;
336 }
337 nd->SetLineColor(kColorITSSSD);
338 fNodes->Add(nd);
339 }
340 for(lay=5;lay<=5;lay++)
341 for(lad=1;lad<=gm->GetNladders(lay);lad++)
342 for(det=1;det<=gm->GetNdetectors(lay);det++){
343 try {
344 box = new TBRIK ("ActiveSSD","Active volume of SSD","SSD SI DET",
345 3.65,0.015,2.0);
346 } catch (...) {
347 cout << "EXCEPTION in box = new TBRIK" << endl;
348 return;
349 }
350 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
351 gm->GetRotMatrix(lay,lad,det,rt);
352 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
353 for(i=0;i<9;i++) rtd[i] = rt[i];
354 try {
355 rm = new TRotMatrix(name,name,rtd);
356 } catch (...) {
357 cout << "EXCEPTION in new TRotMatrix" << endl;
358 return;
359 }
360 top->cd();
361 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
362 try {
363 nd = new TNode("SSD"," ",box,xg[0],xg[1],xg[2],rm);
364 } catch (...) {
365 cout << "EXCEPTION in new TNode" << endl;
366 return;
367 }
368 nd->SetLineColor(kColorITSSSD);
369 fNodes->Add(nd);
370 }
371
372 for(lay=6;lay<=6;lay++)
373 for(lad=1;lad<=gm->GetNladders(lay);lad++)
374 for(det=1;det<=gm->GetNdetectors(lay);det++){
375 try {
376 box = new TBRIK ("ActiveSSD","Active volume of SSD","SSD SI DET",
377 3.65,0.015,2.0);
378 } catch (...) {
379 cout << "EXCEPTION in box = new TBRIK" << endl;
380 return;
381 }
382
383 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
384 gm->GetRotMatrix(lay,lad,det,rt);
385 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
386 for(i=0;i<9;i++) rtd[i] = rt[i];
387 try {
388 rm = new TRotMatrix(name,name,rtd);
389 } catch (...) {
390 cout << "EXCEPTION in new TRotMatrix" << endl;
391 return;
392 }
393 top->cd();
394 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
395 try {
396 nd = new TNode("SSD"," ",box,xg[0],xg[1],xg[2],rm);
397 } catch (...) {
398 cout << "EXCEPTION in new TNode" << endl;
399 return;
400 }
401 nd->SetLineColor(kColorITSSSD);
402 fNodes->Add(nd);
403 }
404
405
406}
407//_____________________________________________________________________________
408void AliITSv5symm::CreateMaterials(){
409////////////////////////////////////////////////////////////////////////
410// Read a file containing the materials for the ITS version 5.
411////////////////////////////////////////////////////////////////////////
412 char *filtmp;
413
414 filtmp = gSystem->ExpandPathName(fEuclidMaterial.Data());
415
416 FILE *file = fopen(filtmp,"r");
417 if(file) {
418 fclose(file);
419 ReadEuclidMedia(filtmp);
420 } else {
421 Error("CreateMaterials"," THE MEDIA FILE %s DOES NOT EXIST !",filtmp);
422 exit(1);
423 } // end if(file)
424}
425//_____________________________________________________________________________
426void AliITSv5symm::CreateGeometry(){
427//////////////////////////////////////////////////////////////////////
428// This is the geometry used for the ITS Pre-TDR and comes from an
429// Euclid to Geant conversion. The only difference
430// is in the details of the ITS supports. The detectors elements,
431// detector numbering, and local and global reference frames are shown in
432// the following figures.
433//Begin_Html
434/*
435<img src="picts/ITS/its1+2_convention_front_5.gif">
436</pre>
437<br clear=left>
438<font size=+2 color=red>
439<p>This shows the front view of the SPDs.
440</font>
441<pre>
442<img src="picts/ITS/its1+2_convention_side_5.gif">
443</pre>
444<br clear=left>
445<font size=+2 color=red>
446<p>This shows the perspective view of the SPDs.
447</font>
448<img src="picts/ITS/its1+2_tree.gif">
449</pre>
450<br clear=left>
451<font size=+2 color=red>
452<p>This shows the geometry Tree for the SPDs.
453</font>
454<pre>
455
456<pre>
457<img src="picts/ITS/its3+4_convention_front_5.gif">
458</pre>
459<br clear=left>
460<font size=+2 color=red>
461<p>This shows the front view of the SDDs.
462</font>
463<pre>
464<img src="picts/ITS/its3+4_convention_side_5.gif">
465</pre>
466<br clear=left>
467<font size=+2 color=red>
468<p>This shows the perspective view of the SDDs.
469</font>
470<img src="picts/ITS/its3+4_tree.gif">
471</pre>
472<br clear=left>
473<font size=+2 color=red>
474<p>This shows the geometry Tree for the SDDs.
475</font>
476<pre>
477
478<pre>
479<img src="picts/ITS/its5+6_convention_front_5.gif">
480</pre>
481<br clear=left>
482<font size=+2 color=red>
483<p>This shows the front view of the SSDs.
484</font>
485<pre>
486<img src="picts/ITS/its5+6_convention_side_5.gif">
487</pre>
488<br clear=left>
489<font size=+2 color=red>
490<p>This shows the perspective view of the SSDs.
491</font>
492<pre>
493<img src="picts/ITS/its5+6_tree.gif">
494</pre>
495<br clear=left>
496<font size=+2 color=red>
497<p>This shows the geometry Tree for the SSDs.
498</font>
499<pre>
500
501
502<img src="picts/ITS/its_layer1-6_2.gif">
503</pre>
504<br clear=left>
505<font size=+2 color=red>
506<p>This shows the front view of the whole ITS..
507</font>
508<pre>
509
510<img src="picts/ITS/its_layer1-6_1.gif">
511</pre>
512<br clear=left>
513<font size=+2 color=red>
514<p>This shows the perspective view of the whole ITS..
515</font>
516<pre>
517
518<img src="picts/ITS/its1-6_tree.gif">
519</pre>
520<br clear=left>
521<font size=+2 color=red>
522<p>This shows the geometry Tree for the whole ITS.
523</font>
524<pre>
525*/
526//End_Html
527//
528//
529// Here are shown the details of the ITS support cones and services.
530// First is a GEANT tree showing the organization of all of the volumes
531// that make up the ITS supports and services.
532//Begin_Html
533/*
534<img src="picts/ITS/supports_tree.gif">
535 */
536//End_Html
537// What follows are a number of figures showing what these support
538// structures look like.
539//Begin_Html
540/*
541
542<img src="picts/ITS/supports_3.gif">
543</pre>
544<br clear=left>
545<font size=+2 color=red>
546<p>This shows the geometry of the supports for the Drift and Strip layers only.
547</font>
548<pre>
549
550<img src="picts/ITS/supports_2.gif">
551</pre>
552<br clear=left>
553<font size=+2 color=red>
554<p>This shows the geometry of the supports for the Drift and Strip layers in front cut out.
555</font>
556<pre>
557
558<img src="picts/ITS/supports_1.gif">
559</pre>
560<br clear=left>
561<font size=+2 color=red>
562<p>This shows the geometry of the supports for the Drift and Strip layers in a back cut out..
563</font>
564<pre>
565
566<img src="picts/ITS/suppssd.gif">
567</pre>
568<br clear=left>
569<font size=+2 color=red>
570<p>This shows the geometry for the Strip layers supports.
571</font>
572<pre>
573
574<img src="picts/ITS/suppsdd.gif">
575</pre>
576<br clear=left>
577<font size=+2 color=red>
578<p>This shows the geometry for the Drift layers supports.
579</font>
580<pre>
581 */
582//End_Html
583//
584// Read a file containing the geometry for the ITS version 5.
585////////////////////////////////////////////////////////////////////////
e5745edc 586 char topvol[5];
587 char *filtmp;
588
589 filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
590 FILE *file = fopen(filtmp,"r");
591 delete [] filtmp;
592 if(file) {
593 fclose(file);
594 printf("Ready to read Euclid geometry file\n");
595 ReadEuclid(fEuclidGeometry.Data(),topvol);
596 printf("Read in euclid geometries\n");
597 } else {
598 Error("CreateGeometry"," THE GEOM FILE %s DOES NOT EXIST !",
599 fEuclidGeometry.Data());
600 exit(1);
601 } // end if(file)
602 //
603 // Place the ITS ghost volume ITSV in its mother volume (ALIC) and make it
604 // invisible
605 //
606 gMC->Gspos("ITSV",1,"ALIC",0,0,0,0,"ONLY");
607 //
608 // Outputs the geometry tree in the EUCLID/CAD format if requested to do so
609
610 if (fEuclidOut) {
611 gMC->WriteEuclid("ITSgeometry", "ITSV", 1, 5);
612 } // end if (fEuclidOut)
bae7e562 613 cout << "finished with euclid geometrys" << endl;
614}
615//______________________________________________________________________
616void AliITSv5symm::ReadOldGeometry(const char *filename){
e5745edc 617 // read in the file containing the transformations for the active
618 // volumes for the ITS version 5. This is expected to be in a file
619 // ending in .det. This geometry is kept in the AliITSgeom class.
bae7e562 620 Int_t size;
621 char *filtmp;
622 FILE *file;
623
624 filtmp = gSystem->ExpandPathName(filename);
e5745edc 625 size = strlen(filtmp);
bae7e562 626 if(size>4 && fGeomDetIn){
627 filtmp[size-3] = 'd'; // change from .euc to .det
e5745edc 628 filtmp[size-2] = 'e';
629 filtmp[size-1] = 't';
bae7e562 630 file = fopen(filtmp,"r");
631 if(file){ // if file exists use it to fill AliITSgeom structure.
632 fclose(file);
633 fITSgeom = new AliITSgeom(filtmp);
634 fITSgeom->DefineShapes(3); // if fShape isn't defined define it.
635 // Now define the detector types/shapes.
636 fITSgeom->ReSetShape(kSPD,(TObject *) new AliITSgeomSPD300());
637 fITSgeom->ReSetShape(kSDD,(TObject *) new AliITSgeomSDD300());
638 fITSgeom->ReSetShape(kSSD,(TObject *) new AliITSgeomSSD());
639 }else{
640 fITSgeom = 0;
641 // fill AliITSgeom structure from geant structure just filled above
642 }// end if(file)
e5745edc 643 delete [] filtmp;
644 }// end if(size>4)
bae7e562 645}
646//______________________________________________________________________
647void AliITSv5symm::InitAliITSgeom(){
648// Based on the geometry tree defined in Geant 3.21, this
649// routine initilizes the Class AliITSgeom from the Geant 3.21 ITS geometry
650// sturture.
cbfdea0d 651 if(gMC->IsA()!=AliGeant3::Class()) {
bae7e562 652 Error("InitAliITSgeom",
653 "Wrong Monte Carlo. InitAliITSgeom uses TGeant3 calls");
654 return;
655 } // end if
656 cout << "Reading Geometry transformation directly from Geant 3." << endl;
657 const Int_t nlayers = 6;
658 const Int_t ndeep = 7;
659 Int_t itsGeomTreeNames[nlayers][ndeep],lnam[20],lnum[20];
660 Int_t nlad[nlayers],ndet[nlayers];
661 Double_t t[3],r[10];
662 Float_t par[20],att[20];
663 Int_t npar,natt,idshape,imat,imed;
664 AliITSGeant3Geometry *ig = new AliITSGeant3Geometry();
665 Int_t mod,lay,lad,det,i,j,k;
666 char *names[nlayers][ndeep] = {
667 {"ALIC","ITSV","ITSD","IT12","I132","I186","ITS1"}, // lay=1
668 {"ALIC","ITSV","ITSD","IT12","I132","I131","ITS2"}, // lay=2
669 {"ALIC","ITSV","ITSD","IT34","I004","I302","ITS3"}, // lay=3
670 {"ALIC","ITSV","ITSD","IT34","I005","I402","ITS4"}, // lay=4
671 {"ALIC","ITSV","ITSD","IT56","I565","I562","ITS5"}, // lay=5
672 {"ALIC","ITSV","ITSD","IT56","I569","I566","ITS6"}};// lay=6
673 Int_t itsGeomTreeCopys[nlayers][ndeep] = {{1,1,1,1,10, 2,4}, // lay=1
674 {1,1,1,1,10, 4,4}, // lay=2
675 {1,1,1,1,14, 6,1}, // lay=3
676 {1,1,1,1,22, 8,1}, // lay=4
677 {1,1,1,1,34,23,1}, // lay=5
678 {1,1,1,1,38,26,1}};// lay=6
679
680 // Sorry, but this is not very pritty code. It should be replaced
681 // at some point with a version that can search through the geometry
682 // tree its self.
683 cout << "Reading Geometry informaton from Geant3 common blocks" << endl;
684 for(i=0;i<20;i++) lnam[i] = lnum[i] = 0;
685 for(i=0;i<nlayers;i++)for(j=0;j<ndeep;j++)
686 itsGeomTreeNames[i][j] = ig->StringToInt(names[i][j]);
687 mod = 0;
688 for(i=0;i<nlayers;i++){
689 k = 1;
690 for(j=0;j<ndeep;j++) if(itsGeomTreeCopys[i][j]!=0)
691 k *= TMath::Abs(itsGeomTreeCopys[i][j]);
692 mod += k;
693 } // end for i
694
695 if(fITSgeom!=0) delete fITSgeom;
696 nlad[0]=20;nlad[1]=40;nlad[2]=14;nlad[3]=22;nlad[4]=34;nlad[5]=38;
18c21458 697 ndet[0]=4;ndet[1]=4;ndet[2]=6;ndet[3]=8;ndet[4]=23;ndet[5]=26;
bae7e562 698 fITSgeom = new AliITSgeom(0,6,nlad,ndet,mod);
699 mod = -1;
700 for(lay=1;lay<=nlayers;lay++){
701 for(j=0;j<ndeep;j++) lnam[j] = itsGeomTreeNames[lay-1][j];
702 for(j=0;j<ndeep;j++) lnum[j] = itsGeomTreeCopys[lay-1][j];
703 switch (lay){
704 case 1: case 2: // layers 1 and 2 are a bit special
705 lad = 0;
706 for(j=1;j<=itsGeomTreeCopys[lay-1][4];j++){
707 lnum[4] = j;
708 for(k=1;k<=itsGeomTreeCopys[lay-1][5];k++){
709 lad++;
710 lnum[5] = k;
711 for(det=1;det<=itsGeomTreeCopys[lay-1][6];det++){
712 lnum[6] = det;
713 mod++;
714 ig->GetGeometry(ndeep,lnam,lnum,t,r,idshape,npar,natt,
715 par,att,imat,imed);
716 fITSgeom->CreatMatrix(mod,lay,lad,det,kSPD,t,r);
717 if(!(fITSgeom->IsShapeDefined((Int_t)kSPD)))
718 if(fMinorVersion==1){
719 fITSgeom->ReSetShape(kSPD,
720 new AliITSgeomSPD300());
3e225ff6 721 } else if(fMinorVersion==2){
722 fITSgeom->ReSetShape(kSPD,
723 new AliITSgeomSPD300());
724 }else if(fMinorVersion==3){
725 fITSgeom->ReSetShape(kSPD,
726 new AliITSgeomSPD425Long());
727 }else{
bae7e562 728 fITSgeom->ReSetShape(kSPD,
729 new AliITSgeomSPD300());
3e225ff6 730 } // end if
bae7e562 731 } // end for det
732 } // end for k
733 } // end for j
734 break;
735 case 3: case 4: case 5: case 6: // layers 3-6
736 lnum[6] = 1;
737 for(lad=1;lad<=itsGeomTreeCopys[lay-1][4];lad++){
738 lnum[4] = lad;
739 for(det=1;det<=itsGeomTreeCopys[lay-1][5];det++){
740 lnum[5] = det;
741 mod++;
742 ig->GetGeometry(7,lnam,lnum,t,r,idshape,npar,natt,
743 par,att,imat,imed);
744 switch (lay){
745 case 3: case 4:
746 fITSgeom->CreatMatrix(mod,lay,lad,det,kSDD,t,r);
747 if(!(fITSgeom->IsShapeDefined(kSDD)))
748 fITSgeom->ReSetShape(kSDD,new AliITSgeomSDD300());
749 break;
750 case 5: case 6:
751 fITSgeom->CreatMatrix(mod,lay,lad,det,kSSD,t,r);
752 if(!(fITSgeom->IsShapeDefined(kSSD)))
753 fITSgeom->ReSetShape(kSSD,new AliITSgeomSSD175());
754 break;
755 } // end switch
756 } // end for det
757 } // end for lad
758 break;
759 } // end switch
760 } // end for lay
761 return;
e5745edc 762}
763//_____________________________________________________________________________
764void AliITSv5symm::Init(){
765////////////////////////////////////////////////////////////////////////
766// Initialise the ITS after it has been created.
767////////////////////////////////////////////////////////////////////////
bae7e562 768 Int_t i;
e5745edc 769
bae7e562 770 cout << endl;
0646a0e8 771 for(i=0;i<28;i++) cout << "*";cout << " ITSv5symm_Init ";
772 for(i=0;i<28;i++) cout << "*";cout << endl;
bae7e562 773//
774 if(fRead[0]=='\0') strncpy(fRead,fEuclidGeomDet,60);
775 if(fWrite[0]=='\0') strncpy(fWrite,fEuclidGeomDet,60);
776 if(fITSgeom!=0) delete fITSgeom;
777 fITSgeom = new AliITSgeom();
778 if(fGeomDetIn && !fGeomOldDetIn) fITSgeom->ReadNewFile(fRead);
779 if(fGeomDetIn && fGeomOldDetIn) this->ReadOldGeometry(fRead);
780
781 if(!fGeomDetIn) this->InitAliITSgeom();
782 if(fGeomDetOut) fITSgeom->WriteNewFile(fWrite);
e5745edc 783 AliITS::Init();
bae7e562 784//
785 for(i=0;i<72;i++) cout << "*";
786 cout << endl;
e5745edc 787}
788//_____________________________________________________________________________
789void AliITSv5symm::StepManager(){
790////////////////////////////////////////////////////////////////////////
791// Called for every step in the ITS, then calles the AliITShit class
792// creator with the information to be recoreded about that hit.
793// The value of the macro ALIITSPRINTGEOM if set to 1 will allow the
794// printing of information to a file which can be used to create a .det
795// file read in by the routine CreateGeometry(). If set to 0 or any other
796// value except 1, the default behavior, then no such file is created nor
797// it the extra variables and the like used in the printing allocated.
798////////////////////////////////////////////////////////////////////////
799 Int_t copy, id;
800 Int_t copy1,copy2;
801 Float_t hits[8];
802 Int_t vol[4];
803 TLorentzVector position, momentum;
804 TClonesArray &lhits = *fHits;
e5745edc 805 //
806 // Track status
807 vol[3] = 0;
808 if(gMC->IsTrackInside()) vol[3] += 1;
809 if(gMC->IsTrackEntering()) vol[3] += 2;
810 if(gMC->IsTrackExiting()) vol[3] += 4;
811 if(gMC->IsTrackOut()) vol[3] += 8;
812 if(gMC->IsTrackDisappeared()) vol[3] += 16;
813 if(gMC->IsTrackStop()) vol[3] += 32;
814 if(gMC->IsTrackAlive()) vol[3] += 64;
815 //
816 // Fill hit structure.
817 if(!(gMC->TrackCharge())) return;
818 //
819 // Only entering charged tracks
820 if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
821 vol[0] = 1;
822 id = gMC->CurrentVolOffID(0,copy);
823 //detector copy in the ladder = 1<->4 (ITS1)
824 vol[1] = copy;
825 gMC->CurrentVolOffID(1,copy1);
826 //ladder copy in the module = 1<->2 (I186)
827 gMC->CurrentVolOffID(2,copy2);
828 //module copy in the layer = 1<->10 (I132)
829 vol[2] = copy1+(copy2-1)*2;//# of ladders in one module = 2
830 } else if(id == fIdSens[1]){
831 vol[0] = 2;
832 id = gMC->CurrentVolOffID(0,copy);
833 //detector copy in the ladder = 1<->4 (ITS2)
834 vol[1] = copy;
835 gMC->CurrentVolOffID(1,copy1);
836 //ladder copy in the module = 1<->4 (I131)
837 gMC->CurrentVolOffID(2,copy2);
838 //module copy in the layer = 1<->10 (I132)
839 vol[2] = copy1+(copy2-1)*4;//# of ladders in one module = 4
840 } else if(id == fIdSens[2]){
841 vol[0] = 3;
842 id = gMC->CurrentVolOffID(1,copy);
843 //detector copy in the ladder = 1<->5 (ITS3 is inside I314)
844 vol[1] = copy;
845 id = gMC->CurrentVolOffID(2,copy);
846 //ladder copy in the layer = 1<->12 (I316)
847 vol[2] = copy;
848 } else if(id == fIdSens[3]){
849 vol[0] = 4;
850 id = gMC->CurrentVolOffID(1,copy);
851 //detector copy in the ladder = 1<->8 (ITS4 is inside I414)
852 vol[1] = copy;
853 id = gMC->CurrentVolOffID(2,copy);
854 //ladder copy in the layer = 1<->22 (I417)
855 vol[2] = copy;
856 }else if(id == fIdSens[4]){
857 vol[0] = 5;
858 id = gMC->CurrentVolOffID(1,copy);
859 //detector copy in the ladder = 1<->23 (ITS5 is inside I562)
860 vol[1] = copy;
861 id = gMC->CurrentVolOffID(2,copy);
862 //ladder copy in the layer = 1<->34 (I565)
863 vol[2] = copy;
864 }else if(id == fIdSens[5]){
865 vol[0] = 6;
866 id = gMC->CurrentVolOffID(1,copy);
867 //detector copy in the ladder = 1<->26 (ITS6 is inside I566)
868 vol[1] = copy;
869 id = gMC->CurrentVolOffID(2,copy);
870 //ladder copy in the layer = 1<->38 (I569)
871 vol[2] = copy;
872 } else {
873 return; // not an ITS volume?
874 } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
875//
876 gMC->TrackPosition(position);
877 gMC->TrackMomentum(momentum);
878 hits[0]=position[0];
879 hits[1]=position[1];
880 hits[2]=position[2];
881 hits[3]=momentum[0];
882 hits[4]=momentum[1];
883 hits[5]=momentum[2];
884 hits[6]=gMC->Edep();
885 hits[7]=gMC->TrackTime();
886 // Fill hit structure with this new hit.
887 new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->CurrentTrack(),vol,hits);
e5745edc 888 return;
889}