1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.14.4.4 2000/05/19 10:10:21 nilsen
19 fix for bug with HP and Sun unix + fix for event display in ITS-working branch
21 Revision 1.14.4.3 2000/03/04 23:46:38 nilsen
22 Fixed up the comments/documentation.
24 Revision 1.14.4.2 2000/03/02 21:53:02 nilsen
25 To make it compatable with the changes in AliRun/AliModule.
27 Revision 1.14.4.1 2000/01/12 19:03:33 nilsen
28 This is the version of the files after the merging done in December 1999.
29 See the ReadMe110100.txt file for details
31 Revision 1.14 1999/10/22 08:16:49 fca
32 Correct destructors, thanks to I.Hrivnacova
34 Revision 1.13 1999/10/06 10:15:19 fca
35 Correct bug in allocation of layer name and add destructor
37 Revision 1.12 1999/10/05 08:05:09 fca
38 Minor corrections for uninitialised variables.
40 Revision 1.11 1999/09/29 09:24:20 fca
41 Introduction of the Copyright and cvs Log
45 ///////////////////////////////////////////////////////////////////////////////
47 // Inner Traking System version 5
48 // This class contains the base procedures for the Inner Tracking System
50 // Authors: R. Barbera, B. S. Nilsen.
52 // Created September 17 1999.
54 ///////////////////////////////////////////////////////////////////////////////
56 // See AliITSv5::StepManager().
57 #define ALIITSPRINTGEOM 0 // default. don't print out gemetry information
58 //#define ALIITSPRINTGEOM 1 // print out geometry information
63 #include <TGeometry.h>
66 #include <TFile.h> // only required for Tracking function?
68 #include <TObjArray.h>
69 #include <TClonesArray.h>
73 #if ALIITSPRINTGEOM==1
74 #include "../TGeant3/TGeant3.h"
76 #include "AliITShit.h"
79 #include "AliITSgeom.h"
83 //_____________________________________________________________________________
84 AliITSv5::AliITSv5() {
85 ////////////////////////////////////////////////////////////////////////
86 // Standard default constructor for the ITS version 5.
87 ////////////////////////////////////////////////////////////////////////
90 fIdName = new TString[fIdN];
97 fIdSens = new Int_t[fIdN];
98 for (Int_t i=0;i<fIdN;i++) fIdSens[i]=fIdName[i].Length();
101 //____________________________________________________________________________
102 AliITSv5::AliITSv5(const AliITSv5 &source){
103 ////////////////////////////////////////////////////////////////////////
104 // Copy Constructor for ITS version 5.
105 ////////////////////////////////////////////////////////////////////////
106 if(&source == this) return;
107 printf("Not allowed to copy AliITSv5\n");
110 //_____________________________________________________________________________
111 AliITSv5& AliITSv5::operator=(const AliITSv5 &source){
112 ////////////////////////////////////////////////////////////////////////
113 // Assignment operator for the ITS version 1.
114 ////////////////////////////////////////////////////////////////////////
116 if(&source == this) return *this;
117 printf("Not allowed to copy AliITSv3\n");
121 //_____________________________________________________________________________
122 AliITSv5::~AliITSv5() {
123 ////////////////////////////////////////////////////////////////////////
124 // Standard destructor for the ITS version 5.
125 ////////////////////////////////////////////////////////////////////////
127 //_____________________________________________________________________________
128 AliITSv5::AliITSv5(const char *name, const char *title) : AliITS(name, title){
129 ////////////////////////////////////////////////////////////////////////
130 // Standard constructor for the ITS version 5.
131 ////////////////////////////////////////////////////////////////////////
133 fIdName = new TString[fIdN];
140 fIdSens = new Int_t[fIdN];
141 for (Int_t i=0;i<fIdN;i++) fIdSens[i]=fIdName[i].Length();
144 fEuclidMaterial = "$ALICE_ROOT/Euclid/ITSgeometry_5.tme";
145 fEuclidGeometry = "$ALICE_ROOT/Euclid/ITSgeometry_5.euc";
147 //_____________________________________________________________________________
148 void AliITSv5::BuildGeometry(){
149 ////////////////////////////////////////////////////////////////////////
150 // Geometry builder for the ITS version 5.
151 ////////////////////////////////////////////////////////////////////////
153 // Build ITS TNODE geometry for event display using detailed geometry.
154 // This function builds a simple ITS geometry used by the ROOT macro
159 //const int kColorITSSPD=kRed;
160 //const int kColorITSSDD=kGreen;
161 const int kColorITSSSD=kBlue;
163 top=gAlice->GetGeometry()->GetNode("alice");
164 AliITSgeom *gm = this->GetITSgeom();
173 //TCanvas *c1 = new TCanvas("c1","ITS");
175 for(lay=1;lay<=2;lay++)
176 for(lad=1;lad<=gm->GetNladders(lay);lad++)
177 for(det=1;det<=gm->GetNdetectors(lay);det++){
179 box = new TBRIK ("ActiveSPD","Active volume of SPD","SPD SI DET",
182 cout << "EXCEPTION in box = new TBRIK" << endl;
185 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
186 gm->GetRotMatrix(lay,lad,det,rt);
187 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
188 for(i=0;i<9;i++) rtd[i] = rt[i];
190 rm = new TRotMatrix(name,name,rtd);
192 cout << "EXCEPTION in new TRotMatrix" << endl;
196 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
198 nd = new TNode("SPD"," ",box,xg[0],xg[1],xg[2],rm);
200 cout << "EXCEPTION in new TNode" << endl;
203 nd->SetLineColor(kColorITSSSD);
207 for(lay=3;lay<=3;lay++)
208 for(lad=1;lad<=gm->GetNladders(lay);lad++)
209 for(det=1;det<=gm->GetNdetectors(lay);det++){
211 box = new TBRIK ("ActiveSDD","Active volume of SDD","SDD SI DET",
214 cout << "EXCEPTION in box = new TBRIK" << endl;
217 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
218 gm->GetRotMatrix(lay,lad,det,rt);
219 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
220 for(i=0;i<9;i++) rtd[i] = rt[i];
222 rm = new TRotMatrix(name,name,rtd);
224 cout << "EXCEPTION in new TRotMatrix" << endl;
228 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
230 nd = new TNode("SDD"," ",box,xg[0],xg[1],xg[2],rm);
232 cout << "EXCEPTION in new TNode" << endl;
235 nd->SetLineColor(kColorITSSSD);
239 for(lay=4;lay<=4;lay++)
240 for(lad=1;lad<=gm->GetNladders(lay);lad++)
241 for(det=1;det<=gm->GetNdetectors(lay);det++){
243 box = new TBRIK ("ActiveSDD","Active volume of SDD","SDD SI DET",
246 cout << "EXCEPTION in box = new TBRIK" << endl;
249 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
250 gm->GetRotMatrix(lay,lad,det,rt);
251 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
252 for(i=0;i<9;i++) rtd[i] = rt[i];
254 rm = new TRotMatrix(name,name,rtd);
256 cout << "EXCEPTION in new TRotMatrix" << endl;
260 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
262 nd = new TNode("SDD"," ",box,xg[0],xg[1],xg[2],rm);
264 cout << "EXCEPTION in new TNode" << endl;
267 nd->SetLineColor(kColorITSSSD);
270 for(lay=5;lay<=5;lay++)
271 for(lad=1;lad<=gm->GetNladders(lay);lad++)
272 for(det=1;det<=gm->GetNdetectors(lay);det++){
274 box = new TBRIK ("ActiveSSD","Active volume of SSD","SSD SI DET",
277 cout << "EXCEPTION in box = new TBRIK" << endl;
280 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
281 gm->GetRotMatrix(lay,lad,det,rt);
282 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
283 for(i=0;i<9;i++) rtd[i] = rt[i];
285 rm = new TRotMatrix(name,name,rtd);
287 cout << "EXCEPTION in new TRotMatrix" << endl;
291 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
293 nd = new TNode("SSD"," ",box,xg[0],xg[1],xg[2],rm);
295 cout << "EXCEPTION in new TNode" << endl;
298 nd->SetLineColor(kColorITSSSD);
302 for(lay=6;lay<=6;lay++)
303 for(lad=1;lad<=gm->GetNladders(lay);lad++)
304 for(det=1;det<=gm->GetNdetectors(lay);det++){
306 box = new TBRIK ("ActiveSSD","Active volume of SSD","SSD SI DET",
309 cout << "EXCEPTION in box = new TBRIK" << endl;
313 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
314 gm->GetRotMatrix(lay,lad,det,rt);
315 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
316 for(i=0;i<9;i++) rtd[i] = rt[i];
318 rm = new TRotMatrix(name,name,rtd);
320 cout << "EXCEPTION in new TRotMatrix" << endl;
324 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
326 nd = new TNode("SSD"," ",box,xg[0],xg[1],xg[2],rm);
328 cout << "EXCEPTION in new TNode" << endl;
331 nd->SetLineColor(kColorITSSSD);
337 //_____________________________________________________________________________
338 void AliITSv5::CreateMaterials(){
339 ////////////////////////////////////////////////////////////////////////
340 // Read a file containing the materials for the ITS version 5.
341 ////////////////////////////////////////////////////////////////////////
344 filtmp = gSystem->ExpandPathName(fEuclidMaterial.Data());
346 FILE *file = fopen(filtmp,"r");
349 ReadEuclidMedia(filtmp);
351 Error("CreateMaterials"," THE MEDIA FILE %s DOES NOT EXIST !",filtmp);
355 //_____________________________________________________________________________
356 void AliITSv5::CreateGeometry(){
357 //////////////////////////////////////////////////////////////////////
358 // This is the geometry used for the ITS Pre-TDR and comes from an
359 // Euclid to Geant conversion. The only difference
360 // is in the details of the ITS supports. The detectors elements,
361 // detector numbering, and local and global reference frames are shown in
362 // the following figures.
365 <img src="picts/ITS/its1+2_convention_front_5.gif">
368 <font size=+2 color=red>
369 <p>This shows the front view of the SPDs.
372 <img src="picts/ITS/its1+2_convention_side_5.gif">
375 <font size=+2 color=red>
376 <p>This shows the perspective view of the SPDs.
378 <img src="picts/ITS/its1+2_tree.gif">
381 <font size=+2 color=red>
382 <p>This shows the geometry Tree for the SPDs.
387 <img src="picts/ITS/its3+4_convention_front_5.gif">
390 <font size=+2 color=red>
391 <p>This shows the front view of the SDDs.
394 <img src="picts/ITS/its3+4_convention_side_5.gif">
397 <font size=+2 color=red>
398 <p>This shows the perspective view of the SDDs.
400 <img src="picts/ITS/its3+4_tree.gif">
403 <font size=+2 color=red>
404 <p>This shows the geometry Tree for the SDDs.
409 <img src="picts/ITS/its5+6_convention_front_5.gif">
412 <font size=+2 color=red>
413 <p>This shows the front view of the SSDs.
416 <img src="picts/ITS/its5+6_convention_side_5.gif">
419 <font size=+2 color=red>
420 <p>This shows the perspective view of the SSDs.
423 <img src="picts/ITS/its5+6_tree.gif">
426 <font size=+2 color=red>
427 <p>This shows the geometry Tree for the SSDs.
432 <img src="picts/ITS/its_layer1-6_2.gif">
435 <font size=+2 color=red>
436 <p>This shows the front view of the whole ITS..
440 <img src="picts/ITS/its_layer1-6_1.gif">
443 <font size=+2 color=red>
444 <p>This shows the perspective view of the whole ITS..
448 <img src="picts/ITS/its1-6_tree.gif">
451 <font size=+2 color=red>
452 <p>This shows the geometry Tree for the whole ITS.
459 // Here are shown the details of the ITS support cones and services.
460 // First is a GEANT tree showing the organization of all of the volumes
461 // that make up the ITS supports and services.
464 <img src="picts/ITS/supports_tree.gif">
467 // What follows are a number of figures showing what these support
468 // structures look like.
472 <img src="picts/ITS/supports_3.gif">
475 <font size=+2 color=red>
476 <p>This shows the geometry of the supports for the Drift and Strip layers only.
480 <img src="picts/ITS/supports_2.gif">
483 <font size=+2 color=red>
484 <p>This shows the geometry of the supports for the Drift and Strip layers in front cut out.
488 <img src="picts/ITS/supports_1.gif">
491 <font size=+2 color=red>
492 <p>This shows the geometry of the supports for the Drift and Strip layers in a back cut out..
496 <img src="picts/ITS/suppssd.gif">
499 <font size=+2 color=red>
500 <p>This shows the geometry for the Strip layers supports.
504 <img src="picts/ITS/suppsdd.gif">
507 <font size=+2 color=red>
508 <p>This shows the geometry for the Drift layers supports.
514 // Read a file containing the geometry for the ITS version 5.
515 ////////////////////////////////////////////////////////////////////////
521 filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
522 FILE *file = fopen(filtmp,"r");
526 printf("Ready to read Euclid geometry file\n");
527 ReadEuclid(fEuclidGeometry.Data(),topvol);
528 printf("Read in euclid geometries\n");
530 Error("CreateGeometry"," THE GEOM FILE %s DOES NOT EXIST !",
531 fEuclidGeometry.Data());
535 // Place the ITS ghost volume ITSV in its mother volume (ALIC) and make it
538 gMC->Gspos("ITSV",1,"ALIC",0,0,0,0,"ONLY");
540 // Outputs the geometry tree in the EUCLID/CAD format if requested to do so
543 gMC->WriteEuclid("ITSgeometry", "ITSV", 1, 5);
544 } // end if (fEuclidOut)
546 // read in the file containing the transformations for the active
547 // volumes for the ITS version 5. This is expected to be in a file
548 // ending in .det. This geometry is kept in the AliITSgeom class.
549 filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
550 size = strlen(filtmp);
552 filtmp[size-3] = 'd'; // change from .euc to .det
553 filtmp[size-2] = 'e';
554 filtmp[size-1] = 't';
555 file = fopen(filtmp,"r");
556 if(file){ // if file exists use it to fill AliITSgeom structure.
558 printf("ready to read .det file %s\n",filtmp);
559 fITSgeom = new AliITSgeom(filtmp);
562 // fill AliITSgeom structure from geant structure just filled above
566 printf("finished with euclid geometrys\n");
568 //_____________________________________________________________________________
569 void AliITSv5::Init(){
570 ////////////////////////////////////////////////////////////////////////
571 // Initialise the ITS after it has been created.
572 ////////////////////////////////////////////////////////////////////////
578 //_____________________________________________________________________________
579 void AliITSv5::StepManager(){
580 ////////////////////////////////////////////////////////////////////////
581 // Called for every step in the ITS, then calles the AliITShit class
582 // creator with the information to be recoreded about that hit.
583 // The value of the macro ALIITSPRINTGEOM if set to 1 will allow the
584 // printing of information to a file which can be used to create a .det
585 // file read in by the routine CreateGeometry(). If set to 0 or any other
586 // value except 1, the default behavior, then no such file is created nor
587 // it the extra variables and the like used in the printing allocated.
588 ////////////////////////////////////////////////////////////////////////
593 TLorentzVector position, momentum;
594 TClonesArray &lhits = *fHits;
595 #if ALIITSPRINTGEOM==1
598 Float_t xl[3],xt[3],angl[6];
599 // Float_t par[20],att[20];
601 static Bool_t first=kTRUE,printit[6][50][50];
602 if(first){ for(copy1=0;copy1<6;copy1++)for(copy2=0;copy2<50;copy2++)
603 for(id=0;id<50;id++) printit[copy1][copy2][id] = kTRUE;
611 if(gMC->IsTrackInside()) vol[3] += 1;
612 if(gMC->IsTrackEntering()) vol[3] += 2;
613 if(gMC->IsTrackExiting()) vol[3] += 4;
614 if(gMC->IsTrackOut()) vol[3] += 8;
615 if(gMC->IsTrackDisappeared()) vol[3] += 16;
616 if(gMC->IsTrackStop()) vol[3] += 32;
617 if(gMC->IsTrackAlive()) vol[3] += 64;
619 // Fill hit structure.
620 if(!(gMC->TrackCharge())) return;
622 // Only entering charged tracks
623 if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
625 id = gMC->CurrentVolOffID(0,copy);
626 //detector copy in the ladder = 1<->4 (ITS1)
628 gMC->CurrentVolOffID(1,copy1);
629 //ladder copy in the module = 1<->2 (I186)
630 gMC->CurrentVolOffID(2,copy2);
631 //module copy in the layer = 1<->10 (I132)
632 vol[2] = copy1+(copy2-1)*2;//# of ladders in one module = 2
633 } else if(id == fIdSens[1]){
635 id = gMC->CurrentVolOffID(0,copy);
636 //detector copy in the ladder = 1<->4 (ITS2)
638 gMC->CurrentVolOffID(1,copy1);
639 //ladder copy in the module = 1<->4 (I131)
640 gMC->CurrentVolOffID(2,copy2);
641 //module copy in the layer = 1<->10 (I132)
642 vol[2] = copy1+(copy2-1)*4;//# of ladders in one module = 4
643 } else if(id == fIdSens[2]){
645 id = gMC->CurrentVolOffID(1,copy);
646 //detector copy in the ladder = 1<->5 (ITS3 is inside I314)
648 id = gMC->CurrentVolOffID(2,copy);
649 //ladder copy in the layer = 1<->12 (I316)
651 } else if(id == fIdSens[3]){
653 id = gMC->CurrentVolOffID(1,copy);
654 //detector copy in the ladder = 1<->8 (ITS4 is inside I414)
656 id = gMC->CurrentVolOffID(2,copy);
657 //ladder copy in the layer = 1<->22 (I417)
659 }else if(id == fIdSens[4]){
661 id = gMC->CurrentVolOffID(1,copy);
662 //detector copy in the ladder = 1<->23 (ITS5 is inside I562)
664 id = gMC->CurrentVolOffID(2,copy);
665 //ladder copy in the layer = 1<->34 (I565)
667 }else if(id == fIdSens[5]){
669 id = gMC->CurrentVolOffID(1,copy);
670 //detector copy in the ladder = 1<->26 (ITS6 is inside I566)
672 id = gMC->CurrentVolOffID(2,copy);
673 //ladder copy in the layer = 1<->38 (I569)
676 return; // not an ITS volume?
677 } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
679 gMC->TrackPosition(position);
680 gMC->TrackMomentum(momentum);
688 hits[7]=gMC->TrackTime();
689 // Fill hit structure with this new hit.
690 new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->CurrentTrack(),vol,hits);
691 #if ALIITSPRINTGEOM==1
692 if(printit[vol[0]][vol[2]][vol[1]]){
693 printit[vol[0]][vol[2]][vol[1]] = kFALSE;
694 xl[0] = xl[1] = xl[2] = 0.0;
696 for(i=0;i<9;i++) mat[i] = 0.0;
697 mat[0] = mat[4] = mat[8] = 1.0; // default with identity matrix
700 gMC->Gdtom(xl,&(mat[0]),2);
703 gMC->Gdtom(xl,&(mat[3]),2);
706 gMC->Gdtom(xl,&(mat[6]),2);
708 angl[0] = TMath::ACos(mat[2]);
709 if(mat[2]==1.0) angl[0] = 0.0;
710 angl[1] = TMath::ATan2(mat[1],mat[0]);
711 if(angl[1]<0.0) angl[1] += 2.0*TMath::Pi();
713 angl[2] = TMath::ACos(mat[5]);
714 if(mat[5]==1.0) angl[2] = 0.0;
715 angl[3] = TMath::ATan2(mat[4],mat[3]);
716 if(angl[3]<0.0) angl[3] += 2.0*TMath::Pi();
718 angl[4] = TMath::ACos(mat[8]);
719 if(mat[8]==1.0) angl[4] = 0.0;
720 angl[5] = TMath::ATan2(mat[7],mat[6]);
721 if(angl[5]<0.0) angl[5] += 2.0*TMath::Pi();
723 for(i=0;i<6;i++) angl[i] *= 180.0/TMath::Pi(); // degrees
724 fp = fopen("ITSgeometry_v5.det","a");
725 fprintf(fp,"%2d %2d %2d %9e %9e %9e %9e %9e %9e %9e %9e %9e ",
726 vol[0],vol[2],vol[1], // layer ladder detector
727 xt[0],xt[1],xt[2], // Translation vector
728 angl[0],angl[1],angl[2],angl[3],angl[4],angl[5] // Geant rotaion
731 fprintf(fp,"%9e %9e %9e %9e %9e %9e %9e %9e %9e",
732 mat[0],mat[1],mat[2],mat[3],mat[4],mat[5],mat[6],mat[7],mat[8]
733 ); // Adding the rotation matrix.
736 } // end if printit[layer][ladder][detector]
740 //____________________________________________________________________________
741 void AliITSv5::Streamer(TBuffer &R__b){
742 ////////////////////////////////////////////////////////////////////////
743 // A dummy Streamer function for this class AliITSv5. By default it
744 // only streams the AliITS class as it is required. Since this class
745 // dosen't contain any "real" data to be saved, it doesn't.
746 ////////////////////////////////////////////////////////////////////////
748 if (R__b.IsReading()) {
749 Version_t R__v = R__b.ReadVersion();
751 AliITS::Streamer(R__b);
753 AliITS::Streamer(R__b);
756 R__b.WriteVersion(AliITSv5::IsA());
757 AliITS::Streamer(R__b);
758 } // end if R__b.IsReading()