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.1 2000/10/07 15:46:29 barbera
19 Version 5 of the geometry with symmetric services
21 Revision 1.25 2000/10/05 20:50:00 nilsen
22 Now using root generated streamers.
24 Revision 1.14.4.12 2000/10/02 16:04:03 barbera
25 Forward declarations added
27 Revision 1.22 2000/07/10 16:07:19 fca
28 Release version of ITS code
30 Revision 1.14.4.4 2000/05/19 10:10:21 nilsen
31 fix for bug with HP and Sun unix + fix for event display in ITS-working branch
33 Revision 1.14.4.3 2000/03/04 23:46:38 nilsen
34 Fixed up the comments/documentation.
36 Revision 1.14.4.2 2000/03/02 21:53:02 nilsen
37 To make it compatable with the changes in AliRun/AliModule.
39 Revision 1.14.4.1 2000/01/12 19:03:33 nilsen
40 This is the version of the files after the merging done in December 1999.
41 See the ReadMe110100.txt file for details
43 Revision 1.14 1999/10/22 08:16:49 fca
44 Correct destructors, thanks to I.Hrivnacova
46 Revision 1.13 1999/10/06 10:15:19 fca
47 Correct bug in allocation of layer name and add destructor
49 Revision 1.12 1999/10/05 08:05:09 fca
50 Minor corrections for uninitialised variables.
52 Revision 1.11 1999/09/29 09:24:20 fca
53 Introduction of the Copyright and cvs Log
57 ///////////////////////////////////////////////////////////////////////////////
59 // Inner Traking System version 5 with symmetric services
60 // This class contains the base procedures for the Inner Tracking System
62 // Authors: R. Barbera, B. S. Nilsen.
64 // Created October 7 2000.
66 ///////////////////////////////////////////////////////////////////////////////
68 // See AliITSv5symm::StepManager().
69 #define ALIITSPRINTGEOM 0 // default. don't print out gemetry information
70 //#define ALIITSPRINTGEOM 1 // print out geometry information
75 #include <TGeometry.h>
78 #include <TFile.h> // only required for Tracking function?
80 #include <TObjArray.h>
81 #include <TLorentzVector.h>
82 #include <TObjString.h>
83 #include <TClonesArray.h>
89 #if ALIITSPRINTGEOM==1
90 #include "../TGeant3/TGeant3.h"
92 #include "AliITShit.h"
94 #include "AliITSv5symm.h"
95 #include "AliITSgeom.h"
97 ClassImp(AliITSv5symm)
99 //_____________________________________________________________________________
100 AliITSv5symm::AliITSv5symm() {
101 ////////////////////////////////////////////////////////////////////////
102 // Standard default constructor for the ITS version 5.
103 ////////////////////////////////////////////////////////////////////////
111 //____________________________________________________________________________
112 AliITSv5symm::AliITSv5symm(const AliITSv5symm &source){
113 ////////////////////////////////////////////////////////////////////////
114 // Copy Constructor for ITS version 5.
115 ////////////////////////////////////////////////////////////////////////
116 if(&source == this) return;
117 printf("Not allowed to copy AliITSv5symm\n");
120 //_____________________________________________________________________________
121 AliITSv5symm& AliITSv5symm::operator=(const AliITSv5symm &source){
122 ////////////////////////////////////////////////////////////////////////
123 // Assignment operator for the ITS version 1.
124 ////////////////////////////////////////////////////////////////////////
126 if(&source == this) return *this;
127 printf("Not allowed to copy AliITSv3\n");
131 //_____________________________________________________________________________
132 AliITSv5symm::~AliITSv5symm() {
133 ////////////////////////////////////////////////////////////////////////
134 // Standard destructor for the ITS version 5.
135 ////////////////////////////////////////////////////////////////////////
137 //_____________________________________________________________________________
138 AliITSv5symm::AliITSv5symm(const char *name, const char *title) : AliITS(name, title){
139 /////////////////////////////////////////////////////////////////////////////
140 // Standard constructor for the ITS version 5 with symmetrical services.
141 /////////////////////////////////////////////////////////////////////////////
144 // TObjArray of TObjStrings
145 fIdName = new TObjArray(fIdN);
146 fIdName->AddAt(new TObjString("ITS1"),0);
147 fIdName->AddAt(new TObjString("ITS2"),1);
148 fIdName->AddAt(new TObjString("ITS3"),2);
149 fIdName->AddAt(new TObjString("ITS4"),3);
150 fIdName->AddAt(new TObjString("ITS5"),4);
151 fIdName->AddAt(new TObjString("ITS6"),5);
153 // Array of TStrings.
154 fIdName = new TString[fIdN];
161 fIdSens = new Int_t[fIdN];
162 for (Int_t i=0;i<fIdN;i++) fIdSens[i] = 0;
166 fEuclidMaterial = "$ALICE_ROOT/Euclid/ITSgeometry_5symm.tme";
167 fEuclidGeometry = "$ALICE_ROOT/Euclid/ITSgeometry_5symm.euc";
169 //_____________________________________________________________________________
170 void AliITSv5symm::BuildGeometry(){
171 ////////////////////////////////////////////////////////////////////////
172 // Geometry builder for the ITS version 5.
173 ////////////////////////////////////////////////////////////////////////
175 // Build ITS TNODE geometry for event display using detailed geometry.
176 // This function builds a simple ITS geometry used by the ROOT macro
181 //const int kColorITSSPD=kRed;
182 //const int kColorITSSDD=kGreen;
183 const int kColorITSSSD=kBlue;
185 top=gAlice->GetGeometry()->GetNode("alice");
186 AliITSgeom *gm = this->GetITSgeom();
195 //TCanvas *c1 = new TCanvas("c1","ITS");
197 for(lay=1;lay<=2;lay++)
198 for(lad=1;lad<=gm->GetNladders(lay);lad++)
199 for(det=1;det<=gm->GetNdetectors(lay);det++){
201 box = new TBRIK ("ActiveSPD","Active volume of SPD","SPD SI DET",
204 cout << "EXCEPTION in box = new TBRIK" << endl;
207 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
208 gm->GetRotMatrix(lay,lad,det,rt);
209 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
210 for(i=0;i<9;i++) rtd[i] = rt[i];
212 rm = new TRotMatrix(name,name,rtd);
214 cout << "EXCEPTION in new TRotMatrix" << endl;
218 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
220 nd = new TNode("SPD"," ",box,xg[0],xg[1],xg[2],rm);
222 cout << "EXCEPTION in new TNode" << endl;
225 nd->SetLineColor(kColorITSSSD);
229 for(lay=3;lay<=3;lay++)
230 for(lad=1;lad<=gm->GetNladders(lay);lad++)
231 for(det=1;det<=gm->GetNdetectors(lay);det++){
233 box = new TBRIK ("ActiveSDD","Active volume of SDD","SDD SI DET",
236 cout << "EXCEPTION in box = new TBRIK" << endl;
239 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
240 gm->GetRotMatrix(lay,lad,det,rt);
241 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
242 for(i=0;i<9;i++) rtd[i] = rt[i];
244 rm = new TRotMatrix(name,name,rtd);
246 cout << "EXCEPTION in new TRotMatrix" << endl;
250 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
252 nd = new TNode("SDD"," ",box,xg[0],xg[1],xg[2],rm);
254 cout << "EXCEPTION in new TNode" << endl;
257 nd->SetLineColor(kColorITSSSD);
261 for(lay=4;lay<=4;lay++)
262 for(lad=1;lad<=gm->GetNladders(lay);lad++)
263 for(det=1;det<=gm->GetNdetectors(lay);det++){
265 box = new TBRIK ("ActiveSDD","Active volume of SDD","SDD SI DET",
268 cout << "EXCEPTION in box = new TBRIK" << endl;
271 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
272 gm->GetRotMatrix(lay,lad,det,rt);
273 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
274 for(i=0;i<9;i++) rtd[i] = rt[i];
276 rm = new TRotMatrix(name,name,rtd);
278 cout << "EXCEPTION in new TRotMatrix" << endl;
282 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
284 nd = new TNode("SDD"," ",box,xg[0],xg[1],xg[2],rm);
286 cout << "EXCEPTION in new TNode" << endl;
289 nd->SetLineColor(kColorITSSSD);
292 for(lay=5;lay<=5;lay++)
293 for(lad=1;lad<=gm->GetNladders(lay);lad++)
294 for(det=1;det<=gm->GetNdetectors(lay);det++){
296 box = new TBRIK ("ActiveSSD","Active volume of SSD","SSD SI DET",
299 cout << "EXCEPTION in box = new TBRIK" << endl;
302 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
303 gm->GetRotMatrix(lay,lad,det,rt);
304 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
305 for(i=0;i<9;i++) rtd[i] = rt[i];
307 rm = new TRotMatrix(name,name,rtd);
309 cout << "EXCEPTION in new TRotMatrix" << endl;
313 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
315 nd = new TNode("SSD"," ",box,xg[0],xg[1],xg[2],rm);
317 cout << "EXCEPTION in new TNode" << endl;
320 nd->SetLineColor(kColorITSSSD);
324 for(lay=6;lay<=6;lay++)
325 for(lad=1;lad<=gm->GetNladders(lay);lad++)
326 for(det=1;det<=gm->GetNdetectors(lay);det++){
328 box = new TBRIK ("ActiveSSD","Active volume of SSD","SSD SI DET",
331 cout << "EXCEPTION in box = new TBRIK" << endl;
335 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
336 gm->GetRotMatrix(lay,lad,det,rt);
337 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
338 for(i=0;i<9;i++) rtd[i] = rt[i];
340 rm = new TRotMatrix(name,name,rtd);
342 cout << "EXCEPTION in new TRotMatrix" << endl;
346 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
348 nd = new TNode("SSD"," ",box,xg[0],xg[1],xg[2],rm);
350 cout << "EXCEPTION in new TNode" << endl;
353 nd->SetLineColor(kColorITSSSD);
359 //_____________________________________________________________________________
360 void AliITSv5symm::CreateMaterials(){
361 ////////////////////////////////////////////////////////////////////////
362 // Read a file containing the materials for the ITS version 5.
363 ////////////////////////////////////////////////////////////////////////
366 filtmp = gSystem->ExpandPathName(fEuclidMaterial.Data());
368 FILE *file = fopen(filtmp,"r");
371 ReadEuclidMedia(filtmp);
373 Error("CreateMaterials"," THE MEDIA FILE %s DOES NOT EXIST !",filtmp);
377 //_____________________________________________________________________________
378 void AliITSv5symm::CreateGeometry(){
379 //////////////////////////////////////////////////////////////////////
380 // This is the geometry used for the ITS Pre-TDR and comes from an
381 // Euclid to Geant conversion. The only difference
382 // is in the details of the ITS supports. The detectors elements,
383 // detector numbering, and local and global reference frames are shown in
384 // the following figures.
387 <img src="picts/ITS/its1+2_convention_front_5.gif">
390 <font size=+2 color=red>
391 <p>This shows the front view of the SPDs.
394 <img src="picts/ITS/its1+2_convention_side_5.gif">
397 <font size=+2 color=red>
398 <p>This shows the perspective view of the SPDs.
400 <img src="picts/ITS/its1+2_tree.gif">
403 <font size=+2 color=red>
404 <p>This shows the geometry Tree for the SPDs.
409 <img src="picts/ITS/its3+4_convention_front_5.gif">
412 <font size=+2 color=red>
413 <p>This shows the front view of the SDDs.
416 <img src="picts/ITS/its3+4_convention_side_5.gif">
419 <font size=+2 color=red>
420 <p>This shows the perspective view of the SDDs.
422 <img src="picts/ITS/its3+4_tree.gif">
425 <font size=+2 color=red>
426 <p>This shows the geometry Tree for the SDDs.
431 <img src="picts/ITS/its5+6_convention_front_5.gif">
434 <font size=+2 color=red>
435 <p>This shows the front view of the SSDs.
438 <img src="picts/ITS/its5+6_convention_side_5.gif">
441 <font size=+2 color=red>
442 <p>This shows the perspective view of the SSDs.
445 <img src="picts/ITS/its5+6_tree.gif">
448 <font size=+2 color=red>
449 <p>This shows the geometry Tree for the SSDs.
454 <img src="picts/ITS/its_layer1-6_2.gif">
457 <font size=+2 color=red>
458 <p>This shows the front view of the whole ITS..
462 <img src="picts/ITS/its_layer1-6_1.gif">
465 <font size=+2 color=red>
466 <p>This shows the perspective view of the whole ITS..
470 <img src="picts/ITS/its1-6_tree.gif">
473 <font size=+2 color=red>
474 <p>This shows the geometry Tree for the whole ITS.
481 // Here are shown the details of the ITS support cones and services.
482 // First is a GEANT tree showing the organization of all of the volumes
483 // that make up the ITS supports and services.
486 <img src="picts/ITS/supports_tree.gif">
489 // What follows are a number of figures showing what these support
490 // structures look like.
494 <img src="picts/ITS/supports_3.gif">
497 <font size=+2 color=red>
498 <p>This shows the geometry of the supports for the Drift and Strip layers only.
502 <img src="picts/ITS/supports_2.gif">
505 <font size=+2 color=red>
506 <p>This shows the geometry of the supports for the Drift and Strip layers in front cut out.
510 <img src="picts/ITS/supports_1.gif">
513 <font size=+2 color=red>
514 <p>This shows the geometry of the supports for the Drift and Strip layers in a back cut out..
518 <img src="picts/ITS/suppssd.gif">
521 <font size=+2 color=red>
522 <p>This shows the geometry for the Strip layers supports.
526 <img src="picts/ITS/suppsdd.gif">
529 <font size=+2 color=red>
530 <p>This shows the geometry for the Drift layers supports.
536 // Read a file containing the geometry for the ITS version 5.
537 ////////////////////////////////////////////////////////////////////////
543 filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
544 FILE *file = fopen(filtmp,"r");
548 printf("Ready to read Euclid geometry file\n");
549 ReadEuclid(fEuclidGeometry.Data(),topvol);
550 printf("Read in euclid geometries\n");
552 Error("CreateGeometry"," THE GEOM FILE %s DOES NOT EXIST !",
553 fEuclidGeometry.Data());
557 // Place the ITS ghost volume ITSV in its mother volume (ALIC) and make it
560 gMC->Gspos("ITSV",1,"ALIC",0,0,0,0,"ONLY");
562 // Outputs the geometry tree in the EUCLID/CAD format if requested to do so
565 gMC->WriteEuclid("ITSgeometry", "ITSV", 1, 5);
566 } // end if (fEuclidOut)
568 // read in the file containing the transformations for the active
569 // volumes for the ITS version 5. This is expected to be in a file
570 // ending in .det. This geometry is kept in the AliITSgeom class.
571 filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
572 size = strlen(filtmp);
574 filtmp[size-3] = 'd'; // change from .euc to .det
575 filtmp[size-2] = 'e';
576 filtmp[size-1] = 't';
577 file = fopen(filtmp,"r");
578 if(file){ // if file exists use it to fill AliITSgeom structure.
580 printf("ready to read .det file %s\n",filtmp);
581 fITSgeom = new AliITSgeom(filtmp);
584 // fill AliITSgeom structure from geant structure just filled above
588 printf("finished with euclid geometrys\n");
590 //_____________________________________________________________________________
591 void AliITSv5symm::Init(){
592 ////////////////////////////////////////////////////////////////////////
593 // Initialise the ITS after it has been created.
594 ////////////////////////////////////////////////////////////////////////
600 //_____________________________________________________________________________
601 void AliITSv5symm::StepManager(){
602 ////////////////////////////////////////////////////////////////////////
603 // Called for every step in the ITS, then calles the AliITShit class
604 // creator with the information to be recoreded about that hit.
605 // The value of the macro ALIITSPRINTGEOM if set to 1 will allow the
606 // printing of information to a file which can be used to create a .det
607 // file read in by the routine CreateGeometry(). If set to 0 or any other
608 // value except 1, the default behavior, then no such file is created nor
609 // it the extra variables and the like used in the printing allocated.
610 ////////////////////////////////////////////////////////////////////////
615 TLorentzVector position, momentum;
616 TClonesArray &lhits = *fHits;
617 #if ALIITSPRINTGEOM==1
620 Float_t xl[3],xt[3],angl[6];
621 // Float_t par[20],att[20];
623 static Bool_t first=kTRUE,printit[6][50][50];
624 if(first){ for(copy1=0;copy1<6;copy1++)for(copy2=0;copy2<50;copy2++)
625 for(id=0;id<50;id++) printit[copy1][copy2][id] = kTRUE;
633 if(gMC->IsTrackInside()) vol[3] += 1;
634 if(gMC->IsTrackEntering()) vol[3] += 2;
635 if(gMC->IsTrackExiting()) vol[3] += 4;
636 if(gMC->IsTrackOut()) vol[3] += 8;
637 if(gMC->IsTrackDisappeared()) vol[3] += 16;
638 if(gMC->IsTrackStop()) vol[3] += 32;
639 if(gMC->IsTrackAlive()) vol[3] += 64;
641 // Fill hit structure.
642 if(!(gMC->TrackCharge())) return;
644 // Only entering charged tracks
645 if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
647 id = gMC->CurrentVolOffID(0,copy);
648 //detector copy in the ladder = 1<->4 (ITS1)
650 gMC->CurrentVolOffID(1,copy1);
651 //ladder copy in the module = 1<->2 (I186)
652 gMC->CurrentVolOffID(2,copy2);
653 //module copy in the layer = 1<->10 (I132)
654 vol[2] = copy1+(copy2-1)*2;//# of ladders in one module = 2
655 } else if(id == fIdSens[1]){
657 id = gMC->CurrentVolOffID(0,copy);
658 //detector copy in the ladder = 1<->4 (ITS2)
660 gMC->CurrentVolOffID(1,copy1);
661 //ladder copy in the module = 1<->4 (I131)
662 gMC->CurrentVolOffID(2,copy2);
663 //module copy in the layer = 1<->10 (I132)
664 vol[2] = copy1+(copy2-1)*4;//# of ladders in one module = 4
665 } else if(id == fIdSens[2]){
667 id = gMC->CurrentVolOffID(1,copy);
668 //detector copy in the ladder = 1<->5 (ITS3 is inside I314)
670 id = gMC->CurrentVolOffID(2,copy);
671 //ladder copy in the layer = 1<->12 (I316)
673 } else if(id == fIdSens[3]){
675 id = gMC->CurrentVolOffID(1,copy);
676 //detector copy in the ladder = 1<->8 (ITS4 is inside I414)
678 id = gMC->CurrentVolOffID(2,copy);
679 //ladder copy in the layer = 1<->22 (I417)
681 }else if(id == fIdSens[4]){
683 id = gMC->CurrentVolOffID(1,copy);
684 //detector copy in the ladder = 1<->23 (ITS5 is inside I562)
686 id = gMC->CurrentVolOffID(2,copy);
687 //ladder copy in the layer = 1<->34 (I565)
689 }else if(id == fIdSens[5]){
691 id = gMC->CurrentVolOffID(1,copy);
692 //detector copy in the ladder = 1<->26 (ITS6 is inside I566)
694 id = gMC->CurrentVolOffID(2,copy);
695 //ladder copy in the layer = 1<->38 (I569)
698 return; // not an ITS volume?
699 } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
701 gMC->TrackPosition(position);
702 gMC->TrackMomentum(momentum);
710 hits[7]=gMC->TrackTime();
711 // Fill hit structure with this new hit.
712 new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->CurrentTrack(),vol,hits);
713 #if ALIITSPRINTGEOM==1
714 if(printit[vol[0]][vol[2]][vol[1]]){
715 printit[vol[0]][vol[2]][vol[1]] = kFALSE;
716 xl[0] = xl[1] = xl[2] = 0.0;
718 for(i=0;i<9;i++) mat[i] = 0.0;
719 mat[0] = mat[4] = mat[8] = 1.0; // default with identity matrix
722 gMC->Gdtom(xl,&(mat[0]),2);
725 gMC->Gdtom(xl,&(mat[3]),2);
728 gMC->Gdtom(xl,&(mat[6]),2);
730 angl[0] = TMath::ACos(mat[2]);
731 if(mat[2]==1.0) angl[0] = 0.0;
732 angl[1] = TMath::ATan2(mat[1],mat[0]);
733 if(angl[1]<0.0) angl[1] += 2.0*TMath::Pi();
735 angl[2] = TMath::ACos(mat[5]);
736 if(mat[5]==1.0) angl[2] = 0.0;
737 angl[3] = TMath::ATan2(mat[4],mat[3]);
738 if(angl[3]<0.0) angl[3] += 2.0*TMath::Pi();
740 angl[4] = TMath::ACos(mat[8]);
741 if(mat[8]==1.0) angl[4] = 0.0;
742 angl[5] = TMath::ATan2(mat[7],mat[6]);
743 if(angl[5]<0.0) angl[5] += 2.0*TMath::Pi();
745 for(i=0;i<6;i++) angl[i] *= 180.0/TMath::Pi(); // degrees
746 fp = fopen("ITSgeometry_v5.det","a");
747 fprintf(fp,"%2d %2d %2d %9e %9e %9e %9e %9e %9e %9e %9e %9e ",
748 vol[0],vol[2],vol[1], // layer ladder detector
749 xt[0],xt[1],xt[2], // Translation vector
750 angl[0],angl[1],angl[2],angl[3],angl[4],angl[5] // Geant rotaion
753 fprintf(fp,"%9e %9e %9e %9e %9e %9e %9e %9e %9e",
754 mat[0],mat[1],mat[2],mat[3],mat[4],mat[5],mat[6],mat[7],mat[8]
755 ); // Adding the rotation matrix.
758 } // end if printit[layer][ladder][detector]
763 //____________________________________________________________________________
764 void AliITSv5symm::Streamer(TBuffer &R__b){
765 ////////////////////////////////////////////////////////////////////////
766 // A dummy Streamer function for this class AliITSv5symm. By default it
767 // only streams the AliITS class as it is required. Since this class
768 // dosen't contain any "real" data to be saved, it doesn't.
769 ////////////////////////////////////////////////////////////////////////
771 if (R__b.IsReading()) {
772 Version_t R__v = R__b.ReadVersion();
774 AliITS::Streamer(R__b);
776 AliITS::Streamer(R__b);
779 R__b.WriteVersion(AliITSv5symm::IsA());
780 AliITS::Streamer(R__b);
781 } // end if R__b.IsReading()