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