]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSv5symm.cxx
Streamers removed (R.Brun)
[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$
a8a6107b 18Revision 1.2 2000/11/30 11:13:11 barbera
19 Added changes suggested by Federico Carminati on nov, 30, 2000
20
a07ced09 21Revision 1.1 2000/10/07 15:46:29 barbera
22Version 5 of the geometry with symmetric services
23
e5745edc 24Revision 1.25 2000/10/05 20:50:00 nilsen
25Now using root generated streamers.
26
27Revision 1.14.4.12 2000/10/02 16:04:03 barbera
28Forward declarations added
29
30Revision 1.22 2000/07/10 16:07:19 fca
31Release version of ITS code
32
33Revision 1.14.4.4 2000/05/19 10:10:21 nilsen
34fix for bug with HP and Sun unix + fix for event display in ITS-working branch
35
36Revision 1.14.4.3 2000/03/04 23:46:38 nilsen
37Fixed up the comments/documentation.
38
39Revision 1.14.4.2 2000/03/02 21:53:02 nilsen
40To make it compatable with the changes in AliRun/AliModule.
41
42Revision 1.14.4.1 2000/01/12 19:03:33 nilsen
43This is the version of the files after the merging done in December 1999.
44See the ReadMe110100.txt file for details
45
46Revision 1.14 1999/10/22 08:16:49 fca
47Correct destructors, thanks to I.Hrivnacova
48
49Revision 1.13 1999/10/06 10:15:19 fca
50Correct bug in allocation of layer name and add destructor
51
52Revision 1.12 1999/10/05 08:05:09 fca
53Minor corrections for uninitialised variables.
54
55Revision 1.11 1999/09/29 09:24:20 fca
56Introduction of the Copyright and cvs Log
57
58*/
59
60///////////////////////////////////////////////////////////////////////////////
61//
62// Inner Traking System version 5 with symmetric services
63// This class contains the base procedures for the Inner Tracking System
64//
65// Authors: R. Barbera, B. S. Nilsen.
66// version 5.
67// Created October 7 2000.
68//
69///////////////////////////////////////////////////////////////////////////////
70
71// See AliITSv5symm::StepManager().
72#define ALIITSPRINTGEOM 0 // default. don't print out gemetry information
73//#define ALIITSPRINTGEOM 1 // print out geometry information
74
75#include <stdio.h>
76#include <stdlib.h>
77#include <TMath.h>
78#include <TGeometry.h>
79#include <TNode.h>
80#include <TTUBE.h>
81#include <TFile.h> // only required for Tracking function?
82#include <TCanvas.h>
83#include <TObjArray.h>
a07ced09 84#include <TLorentzVector.h>
e5745edc 85#include <TObjString.h>
86#include <TClonesArray.h>
87#include <TBRIK.h>
88#include <TSystem.h>
89
90#include "AliMC.h"
91#include "AliRun.h"
92#if ALIITSPRINTGEOM==1
93#include "../TGeant3/TGeant3.h"
94#endif
95#include "AliITShit.h"
96#include "AliITS.h"
97#include "AliITSv5symm.h"
98#include "AliITSgeom.h"
99
100ClassImp(AliITSv5symm)
101
102//_____________________________________________________________________________
103AliITSv5symm::AliITSv5symm() {
104////////////////////////////////////////////////////////////////////////
105// Standard default constructor for the ITS version 5.
106////////////////////////////////////////////////////////////////////////
107
108 fIdN = 0;
109 fIdName = 0;
110 fIdSens = 0;
111 fMajorVersion = 5;
112 fMinorVersion = -1;
113}
114//____________________________________________________________________________
115AliITSv5symm::AliITSv5symm(const AliITSv5symm &source){
116////////////////////////////////////////////////////////////////////////
117// Copy Constructor for ITS version 5.
118////////////////////////////////////////////////////////////////////////
119 if(&source == this) return;
120 printf("Not allowed to copy AliITSv5symm\n");
121 return;
122}
123//_____________________________________________________________________________
124AliITSv5symm& AliITSv5symm::operator=(const AliITSv5symm &source){
125////////////////////////////////////////////////////////////////////////
126// Assignment operator for the ITS version 1.
127////////////////////////////////////////////////////////////////////////
128
129 if(&source == this) return *this;
130 printf("Not allowed to copy AliITSv3\n");
131 return *this;
132
133}
134//_____________________________________________________________________________
135AliITSv5symm::~AliITSv5symm() {
136////////////////////////////////////////////////////////////////////////
137// Standard destructor for the ITS version 5.
138////////////////////////////////////////////////////////////////////////
139}
140//_____________________________________________________________________________
141AliITSv5symm::AliITSv5symm(const char *name, const char *title) : AliITS(name, title){
142/////////////////////////////////////////////////////////////////////////////
143// Standard constructor for the ITS version 5 with symmetrical services.
144/////////////////////////////////////////////////////////////////////////////
145 fIdN = 6;
146/*
147// TObjArray of TObjStrings
148 fIdName = new TObjArray(fIdN);
149 fIdName->AddAt(new TObjString("ITS1"),0);
150 fIdName->AddAt(new TObjString("ITS2"),1);
151 fIdName->AddAt(new TObjString("ITS3"),2);
152 fIdName->AddAt(new TObjString("ITS4"),3);
153 fIdName->AddAt(new TObjString("ITS5"),4);
154 fIdName->AddAt(new TObjString("ITS6"),5);
155*/
156// Array of TStrings.
157 fIdName = new TString[fIdN];
158 fIdName[0] = "ITS1";
159 fIdName[1] = "ITS2";
160 fIdName[2] = "ITS3";
161 fIdName[3] = "ITS4";
162 fIdName[4] = "ITS5";
163 fIdName[5] = "ITS6";
164 fIdSens = new Int_t[fIdN];
165 for (Int_t i=0;i<fIdN;i++) fIdSens[i] = 0;
166 fMajorVersion = 5;
167 fMinorVersion = 1;
168
169 fEuclidMaterial = "$ALICE_ROOT/Euclid/ITSgeometry_5symm.tme";
170 fEuclidGeometry = "$ALICE_ROOT/Euclid/ITSgeometry_5symm.euc";
171}
172//_____________________________________________________________________________
173void AliITSv5symm::BuildGeometry(){
174////////////////////////////////////////////////////////////////////////
175// Geometry builder for the ITS version 5.
176////////////////////////////////////////////////////////////////////////
177 //
178 // Build ITS TNODE geometry for event display using detailed geometry.
179 // This function builds a simple ITS geometry used by the ROOT macro
180 // ITSdisplay.C.
181
182 TNode *top;
183 TNode *nd;
184 //const int kColorITSSPD=kRed;
185 //const int kColorITSSDD=kGreen;
186 const int kColorITSSSD=kBlue;
187 //
188 top=gAlice->GetGeometry()->GetNode("alice");
189 AliITSgeom *gm = this->GetITSgeom();
190
191 Int_t lay,lad,det,i;
192 Text_t name[10];
193 Float_t xg[3];
194 Float_t rt[9];
195 Double_t rtd[9];
196 TBRIK *box;
197 TRotMatrix *rm;
198 //TCanvas *c1 = new TCanvas("c1","ITS");
199
200 for(lay=1;lay<=2;lay++)
201 for(lad=1;lad<=gm->GetNladders(lay);lad++)
202 for(det=1;det<=gm->GetNdetectors(lay);det++){
203 try {
204 box = new TBRIK ("ActiveSPD","Active volume of SPD","SPD SI DET",
205 0.64,0.0075,4.19);
206 } catch (...) {
207 cout << "EXCEPTION in box = new TBRIK" << endl;
208 return;
209 }
210 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
211 gm->GetRotMatrix(lay,lad,det,rt);
212 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
213 for(i=0;i<9;i++) rtd[i] = rt[i];
214 try {
215 rm = new TRotMatrix(name,name,rtd);
216 } catch (...) {
217 cout << "EXCEPTION in new TRotMatrix" << endl;
218 return;
219 }
220 top->cd();
221 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
222 try {
223 nd = new TNode("SPD"," ",box,xg[0],xg[1],xg[2],rm);
224 } catch (...) {
225 cout << "EXCEPTION in new TNode" << endl;
226 return;
227 }
228 nd->SetLineColor(kColorITSSSD);
229 fNodes->Add(nd);
230 }
231
232 for(lay=3;lay<=3;lay++)
233 for(lad=1;lad<=gm->GetNladders(lay);lad++)
234 for(det=1;det<=gm->GetNdetectors(lay);det++){
235 try {
236 box = new TBRIK ("ActiveSDD","Active volume of SDD","SDD SI DET",
237 3.5,0.014,3.763);
238 } catch (...) {
239 cout << "EXCEPTION in box = new TBRIK" << endl;
240 return;
241 }
242 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
243 gm->GetRotMatrix(lay,lad,det,rt);
244 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
245 for(i=0;i<9;i++) rtd[i] = rt[i];
246 try {
247 rm = new TRotMatrix(name,name,rtd);
248 } catch (...) {
249 cout << "EXCEPTION in new TRotMatrix" << endl;
250 return;
251 }
252 top->cd();
253 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
254 try {
255 nd = new TNode("SDD"," ",box,xg[0],xg[1],xg[2],rm);
256 } catch (...) {
257 cout << "EXCEPTION in new TNode" << endl;
258 return;
259 }
260 nd->SetLineColor(kColorITSSSD);
261 fNodes->Add(nd);
262 }
263
264 for(lay=4;lay<=4;lay++)
265 for(lad=1;lad<=gm->GetNladders(lay);lad++)
266 for(det=1;det<=gm->GetNdetectors(lay);det++){
267 try {
268 box = new TBRIK ("ActiveSDD","Active volume of SDD","SDD SI DET",
269 3.5,0.014,3.763);
270 } catch (...) {
271 cout << "EXCEPTION in box = new TBRIK" << endl;
272 return;
273 }
274 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
275 gm->GetRotMatrix(lay,lad,det,rt);
276 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
277 for(i=0;i<9;i++) rtd[i] = rt[i];
278 try {
279 rm = new TRotMatrix(name,name,rtd);
280 } catch (...) {
281 cout << "EXCEPTION in new TRotMatrix" << endl;
282 return;
283 }
284 top->cd();
285 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
286 try {
287 nd = new TNode("SDD"," ",box,xg[0],xg[1],xg[2],rm);
288 } catch (...) {
289 cout << "EXCEPTION in new TNode" << endl;
290 return;
291 }
292 nd->SetLineColor(kColorITSSSD);
293 fNodes->Add(nd);
294 }
295 for(lay=5;lay<=5;lay++)
296 for(lad=1;lad<=gm->GetNladders(lay);lad++)
297 for(det=1;det<=gm->GetNdetectors(lay);det++){
298 try {
299 box = new TBRIK ("ActiveSSD","Active volume of SSD","SSD SI DET",
300 3.65,0.015,2.0);
301 } catch (...) {
302 cout << "EXCEPTION in box = new TBRIK" << endl;
303 return;
304 }
305 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
306 gm->GetRotMatrix(lay,lad,det,rt);
307 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
308 for(i=0;i<9;i++) rtd[i] = rt[i];
309 try {
310 rm = new TRotMatrix(name,name,rtd);
311 } catch (...) {
312 cout << "EXCEPTION in new TRotMatrix" << endl;
313 return;
314 }
315 top->cd();
316 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
317 try {
318 nd = new TNode("SSD"," ",box,xg[0],xg[1],xg[2],rm);
319 } catch (...) {
320 cout << "EXCEPTION in new TNode" << endl;
321 return;
322 }
323 nd->SetLineColor(kColorITSSSD);
324 fNodes->Add(nd);
325 }
326
327 for(lay=6;lay<=6;lay++)
328 for(lad=1;lad<=gm->GetNladders(lay);lad++)
329 for(det=1;det<=gm->GetNdetectors(lay);det++){
330 try {
331 box = new TBRIK ("ActiveSSD","Active volume of SSD","SSD SI DET",
332 3.65,0.015,2.0);
333 } catch (...) {
334 cout << "EXCEPTION in box = new TBRIK" << endl;
335 return;
336 }
337
338 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
339 gm->GetRotMatrix(lay,lad,det,rt);
340 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
341 for(i=0;i<9;i++) rtd[i] = rt[i];
342 try {
343 rm = new TRotMatrix(name,name,rtd);
344 } catch (...) {
345 cout << "EXCEPTION in new TRotMatrix" << endl;
346 return;
347 }
348 top->cd();
349 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
350 try {
351 nd = new TNode("SSD"," ",box,xg[0],xg[1],xg[2],rm);
352 } catch (...) {
353 cout << "EXCEPTION in new TNode" << endl;
354 return;
355 }
356 nd->SetLineColor(kColorITSSSD);
357 fNodes->Add(nd);
358 }
359
360
361}
362//_____________________________________________________________________________
363void AliITSv5symm::CreateMaterials(){
364////////////////////////////////////////////////////////////////////////
365// Read a file containing the materials for the ITS version 5.
366////////////////////////////////////////////////////////////////////////
367 char *filtmp;
368
369 filtmp = gSystem->ExpandPathName(fEuclidMaterial.Data());
370
371 FILE *file = fopen(filtmp,"r");
372 if(file) {
373 fclose(file);
374 ReadEuclidMedia(filtmp);
375 } else {
376 Error("CreateMaterials"," THE MEDIA FILE %s DOES NOT EXIST !",filtmp);
377 exit(1);
378 } // end if(file)
379}
380//_____________________________________________________________________________
381void AliITSv5symm::CreateGeometry(){
382//////////////////////////////////////////////////////////////////////
383// This is the geometry used for the ITS Pre-TDR and comes from an
384// Euclid to Geant conversion. The only difference
385// is in the details of the ITS supports. The detectors elements,
386// detector numbering, and local and global reference frames are shown in
387// the following figures.
388//Begin_Html
389/*
390<img src="picts/ITS/its1+2_convention_front_5.gif">
391</pre>
392<br clear=left>
393<font size=+2 color=red>
394<p>This shows the front view of the SPDs.
395</font>
396<pre>
397<img src="picts/ITS/its1+2_convention_side_5.gif">
398</pre>
399<br clear=left>
400<font size=+2 color=red>
401<p>This shows the perspective view of the SPDs.
402</font>
403<img src="picts/ITS/its1+2_tree.gif">
404</pre>
405<br clear=left>
406<font size=+2 color=red>
407<p>This shows the geometry Tree for the SPDs.
408</font>
409<pre>
410
411<pre>
412<img src="picts/ITS/its3+4_convention_front_5.gif">
413</pre>
414<br clear=left>
415<font size=+2 color=red>
416<p>This shows the front view of the SDDs.
417</font>
418<pre>
419<img src="picts/ITS/its3+4_convention_side_5.gif">
420</pre>
421<br clear=left>
422<font size=+2 color=red>
423<p>This shows the perspective view of the SDDs.
424</font>
425<img src="picts/ITS/its3+4_tree.gif">
426</pre>
427<br clear=left>
428<font size=+2 color=red>
429<p>This shows the geometry Tree for the SDDs.
430</font>
431<pre>
432
433<pre>
434<img src="picts/ITS/its5+6_convention_front_5.gif">
435</pre>
436<br clear=left>
437<font size=+2 color=red>
438<p>This shows the front view of the SSDs.
439</font>
440<pre>
441<img src="picts/ITS/its5+6_convention_side_5.gif">
442</pre>
443<br clear=left>
444<font size=+2 color=red>
445<p>This shows the perspective view of the SSDs.
446</font>
447<pre>
448<img src="picts/ITS/its5+6_tree.gif">
449</pre>
450<br clear=left>
451<font size=+2 color=red>
452<p>This shows the geometry Tree for the SSDs.
453</font>
454<pre>
455
456
457<img src="picts/ITS/its_layer1-6_2.gif">
458</pre>
459<br clear=left>
460<font size=+2 color=red>
461<p>This shows the front view of the whole ITS..
462</font>
463<pre>
464
465<img src="picts/ITS/its_layer1-6_1.gif">
466</pre>
467<br clear=left>
468<font size=+2 color=red>
469<p>This shows the perspective view of the whole ITS..
470</font>
471<pre>
472
473<img src="picts/ITS/its1-6_tree.gif">
474</pre>
475<br clear=left>
476<font size=+2 color=red>
477<p>This shows the geometry Tree for the whole ITS.
478</font>
479<pre>
480*/
481//End_Html
482//
483//
484// Here are shown the details of the ITS support cones and services.
485// First is a GEANT tree showing the organization of all of the volumes
486// that make up the ITS supports and services.
487//Begin_Html
488/*
489<img src="picts/ITS/supports_tree.gif">
490 */
491//End_Html
492// What follows are a number of figures showing what these support
493// structures look like.
494//Begin_Html
495/*
496
497<img src="picts/ITS/supports_3.gif">
498</pre>
499<br clear=left>
500<font size=+2 color=red>
501<p>This shows the geometry of the supports for the Drift and Strip layers only.
502</font>
503<pre>
504
505<img src="picts/ITS/supports_2.gif">
506</pre>
507<br clear=left>
508<font size=+2 color=red>
509<p>This shows the geometry of the supports for the Drift and Strip layers in front cut out.
510</font>
511<pre>
512
513<img src="picts/ITS/supports_1.gif">
514</pre>
515<br clear=left>
516<font size=+2 color=red>
517<p>This shows the geometry of the supports for the Drift and Strip layers in a back cut out..
518</font>
519<pre>
520
521<img src="picts/ITS/suppssd.gif">
522</pre>
523<br clear=left>
524<font size=+2 color=red>
525<p>This shows the geometry for the Strip layers supports.
526</font>
527<pre>
528
529<img src="picts/ITS/suppsdd.gif">
530</pre>
531<br clear=left>
532<font size=+2 color=red>
533<p>This shows the geometry for the Drift layers supports.
534</font>
535<pre>
536 */
537//End_Html
538//
539// Read a file containing the geometry for the ITS version 5.
540////////////////////////////////////////////////////////////////////////
541
542 Int_t size;
543 char topvol[5];
544 char *filtmp;
545
546 filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
547 FILE *file = fopen(filtmp,"r");
548 delete [] filtmp;
549 if(file) {
550 fclose(file);
551 printf("Ready to read Euclid geometry file\n");
552 ReadEuclid(fEuclidGeometry.Data(),topvol);
553 printf("Read in euclid geometries\n");
554 } else {
555 Error("CreateGeometry"," THE GEOM FILE %s DOES NOT EXIST !",
556 fEuclidGeometry.Data());
557 exit(1);
558 } // end if(file)
559 //
560 // Place the ITS ghost volume ITSV in its mother volume (ALIC) and make it
561 // invisible
562 //
563 gMC->Gspos("ITSV",1,"ALIC",0,0,0,0,"ONLY");
564 //
565 // Outputs the geometry tree in the EUCLID/CAD format if requested to do so
566
567 if (fEuclidOut) {
568 gMC->WriteEuclid("ITSgeometry", "ITSV", 1, 5);
569 } // end if (fEuclidOut)
570
571 // read in the file containing the transformations for the active
572 // volumes for the ITS version 5. This is expected to be in a file
573 // ending in .det. This geometry is kept in the AliITSgeom class.
574 filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
575 size = strlen(filtmp);
576 if(size>4){
577 filtmp[size-3] = 'd'; // change from .euc to .det
578 filtmp[size-2] = 'e';
579 filtmp[size-1] = 't';
580 file = fopen(filtmp,"r");
581 if(file){ // if file exists use it to fill AliITSgeom structure.
582 fclose(file);
583 printf("ready to read .det file %s\n",filtmp);
584 fITSgeom = new AliITSgeom(filtmp);
585 }else{
586 fITSgeom = 0;
587 // fill AliITSgeom structure from geant structure just filled above
588 }// end if(file)
589 delete [] filtmp;
590 }// end if(size>4)
591 printf("finished with euclid geometrys\n");
592}
593//_____________________________________________________________________________
594void AliITSv5symm::Init(){
595////////////////////////////////////////////////////////////////////////
596// Initialise the ITS after it has been created.
597////////////////////////////////////////////////////////////////////////
598
599 AliITS::Init();
600 fMajorVersion = 5;
601 fMinorVersion = 0;
602}
603//_____________________________________________________________________________
604void AliITSv5symm::StepManager(){
605////////////////////////////////////////////////////////////////////////
606// Called for every step in the ITS, then calles the AliITShit class
607// creator with the information to be recoreded about that hit.
608// The value of the macro ALIITSPRINTGEOM if set to 1 will allow the
609// printing of information to a file which can be used to create a .det
610// file read in by the routine CreateGeometry(). If set to 0 or any other
611// value except 1, the default behavior, then no such file is created nor
612// it the extra variables and the like used in the printing allocated.
613////////////////////////////////////////////////////////////////////////
614 Int_t copy, id;
615 Int_t copy1,copy2;
616 Float_t hits[8];
617 Int_t vol[4];
618 TLorentzVector position, momentum;
619 TClonesArray &lhits = *fHits;
620#if ALIITSPRINTGEOM==1
621 FILE *fp;
622 Int_t i;
623 Float_t xl[3],xt[3],angl[6];
624// Float_t par[20],att[20];
625 Float_t mat[9];
626 static Bool_t first=kTRUE,printit[6][50][50];
627 if(first){ for(copy1=0;copy1<6;copy1++)for(copy2=0;copy2<50;copy2++)
628 for(id=0;id<50;id++) printit[copy1][copy2][id] = kTRUE;
629 first = kFALSE;
630 }
631 // end if first
632#endif
633 //
634 // Track status
635 vol[3] = 0;
636 if(gMC->IsTrackInside()) vol[3] += 1;
637 if(gMC->IsTrackEntering()) vol[3] += 2;
638 if(gMC->IsTrackExiting()) vol[3] += 4;
639 if(gMC->IsTrackOut()) vol[3] += 8;
640 if(gMC->IsTrackDisappeared()) vol[3] += 16;
641 if(gMC->IsTrackStop()) vol[3] += 32;
642 if(gMC->IsTrackAlive()) vol[3] += 64;
643 //
644 // Fill hit structure.
645 if(!(gMC->TrackCharge())) return;
646 //
647 // Only entering charged tracks
648 if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
649 vol[0] = 1;
650 id = gMC->CurrentVolOffID(0,copy);
651 //detector copy in the ladder = 1<->4 (ITS1)
652 vol[1] = copy;
653 gMC->CurrentVolOffID(1,copy1);
654 //ladder copy in the module = 1<->2 (I186)
655 gMC->CurrentVolOffID(2,copy2);
656 //module copy in the layer = 1<->10 (I132)
657 vol[2] = copy1+(copy2-1)*2;//# of ladders in one module = 2
658 } else if(id == fIdSens[1]){
659 vol[0] = 2;
660 id = gMC->CurrentVolOffID(0,copy);
661 //detector copy in the ladder = 1<->4 (ITS2)
662 vol[1] = copy;
663 gMC->CurrentVolOffID(1,copy1);
664 //ladder copy in the module = 1<->4 (I131)
665 gMC->CurrentVolOffID(2,copy2);
666 //module copy in the layer = 1<->10 (I132)
667 vol[2] = copy1+(copy2-1)*4;//# of ladders in one module = 4
668 } else if(id == fIdSens[2]){
669 vol[0] = 3;
670 id = gMC->CurrentVolOffID(1,copy);
671 //detector copy in the ladder = 1<->5 (ITS3 is inside I314)
672 vol[1] = copy;
673 id = gMC->CurrentVolOffID(2,copy);
674 //ladder copy in the layer = 1<->12 (I316)
675 vol[2] = copy;
676 } else if(id == fIdSens[3]){
677 vol[0] = 4;
678 id = gMC->CurrentVolOffID(1,copy);
679 //detector copy in the ladder = 1<->8 (ITS4 is inside I414)
680 vol[1] = copy;
681 id = gMC->CurrentVolOffID(2,copy);
682 //ladder copy in the layer = 1<->22 (I417)
683 vol[2] = copy;
684 }else if(id == fIdSens[4]){
685 vol[0] = 5;
686 id = gMC->CurrentVolOffID(1,copy);
687 //detector copy in the ladder = 1<->23 (ITS5 is inside I562)
688 vol[1] = copy;
689 id = gMC->CurrentVolOffID(2,copy);
690 //ladder copy in the layer = 1<->34 (I565)
691 vol[2] = copy;
692 }else if(id == fIdSens[5]){
693 vol[0] = 6;
694 id = gMC->CurrentVolOffID(1,copy);
695 //detector copy in the ladder = 1<->26 (ITS6 is inside I566)
696 vol[1] = copy;
697 id = gMC->CurrentVolOffID(2,copy);
698 //ladder copy in the layer = 1<->38 (I569)
699 vol[2] = copy;
700 } else {
701 return; // not an ITS volume?
702 } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
703//
704 gMC->TrackPosition(position);
705 gMC->TrackMomentum(momentum);
706 hits[0]=position[0];
707 hits[1]=position[1];
708 hits[2]=position[2];
709 hits[3]=momentum[0];
710 hits[4]=momentum[1];
711 hits[5]=momentum[2];
712 hits[6]=gMC->Edep();
713 hits[7]=gMC->TrackTime();
714 // Fill hit structure with this new hit.
715 new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->CurrentTrack(),vol,hits);
716#if ALIITSPRINTGEOM==1
717 if(printit[vol[0]][vol[2]][vol[1]]){
718 printit[vol[0]][vol[2]][vol[1]] = kFALSE;
719 xl[0] = xl[1] = xl[2] = 0.0;
720 gMC->Gdtom(xl,xt,1);
721 for(i=0;i<9;i++) mat[i] = 0.0;
722 mat[0] = mat[4] = mat[8] = 1.0; // default with identity matrix
723 xl[0] = 1.0;
724 xl[1] = xl[2] =0.0;
725 gMC->Gdtom(xl,&(mat[0]),2);
726 xl[1] = 1.0;
727 xl[0] = xl[2] =0.0;
728 gMC->Gdtom(xl,&(mat[3]),2);
729 xl[2] = 1.0;
730 xl[1] = xl[0] =0.0;
731 gMC->Gdtom(xl,&(mat[6]),2);
732
733 angl[0] = TMath::ACos(mat[2]);
734 if(mat[2]==1.0) angl[0] = 0.0;
735 angl[1] = TMath::ATan2(mat[1],mat[0]);
736 if(angl[1]<0.0) angl[1] += 2.0*TMath::Pi();
737
738 angl[2] = TMath::ACos(mat[5]);
739 if(mat[5]==1.0) angl[2] = 0.0;
740 angl[3] = TMath::ATan2(mat[4],mat[3]);
741 if(angl[3]<0.0) angl[3] += 2.0*TMath::Pi();
742
743 angl[4] = TMath::ACos(mat[8]);
744 if(mat[8]==1.0) angl[4] = 0.0;
745 angl[5] = TMath::ATan2(mat[7],mat[6]);
746 if(angl[5]<0.0) angl[5] += 2.0*TMath::Pi();
747
748 for(i=0;i<6;i++) angl[i] *= 180.0/TMath::Pi(); // degrees
749 fp = fopen("ITSgeometry_v5.det","a");
750 fprintf(fp,"%2d %2d %2d %9e %9e %9e %9e %9e %9e %9e %9e %9e ",
751 vol[0],vol[2],vol[1], // layer ladder detector
752 xt[0],xt[1],xt[2], // Translation vector
753 angl[0],angl[1],angl[2],angl[3],angl[4],angl[5] // Geant rotaion
754 // angles (degrees)
755 );
756 fprintf(fp,"%9e %9e %9e %9e %9e %9e %9e %9e %9e",
757 mat[0],mat[1],mat[2],mat[3],mat[4],mat[5],mat[6],mat[7],mat[8]
758 ); // Adding the rotation matrix.
759 fprintf(fp,"\n");
760 fclose(fp);
761 } // end if printit[layer][ladder][detector]
762#endif
763 return;
764}