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.12 2000/10/02 16:04:03 barbera
19 Forward declarations added
21 Revision 1.22 2000/07/10 16:07:19 fca
22 Release version of ITS code
24 Revision 1.14.4.4 2000/05/19 10:10:21 nilsen
25 fix for bug with HP and Sun unix + fix for event display in ITS-working branch
27 Revision 1.14.4.3 2000/03/04 23:46:38 nilsen
28 Fixed up the comments/documentation.
30 Revision 1.14.4.2 2000/03/02 21:53:02 nilsen
31 To make it compatable with the changes in AliRun/AliModule.
33 Revision 1.14.4.1 2000/01/12 19:03:33 nilsen
34 This is the version of the files after the merging done in December 1999.
35 See the ReadMe110100.txt file for details
37 Revision 1.14 1999/10/22 08:16:49 fca
38 Correct destructors, thanks to I.Hrivnacova
40 Revision 1.13 1999/10/06 10:15:19 fca
41 Correct bug in allocation of layer name and add destructor
43 Revision 1.12 1999/10/05 08:05:09 fca
44 Minor corrections for uninitialised variables.
46 Revision 1.11 1999/09/29 09:24:20 fca
47 Introduction of the Copyright and cvs Log
51 ///////////////////////////////////////////////////////////////////////////////
53 // Inner Traking System version 5
54 // This class contains the base procedures for the Inner Tracking System
56 // Authors: R. Barbera, B. S. Nilsen.
58 // Created September 17 1999.
60 ///////////////////////////////////////////////////////////////////////////////
62 // See AliITSv5::StepManager().
63 #define ALIITSPRINTGEOM 0 // default. don't print out gemetry information
64 //#define ALIITSPRINTGEOM 1 // print out geometry information
69 #include <TGeometry.h>
72 #include <TFile.h> // only required for Tracking function?
74 #include <TObjArray.h>
75 #include <TClonesArray.h>
80 #if ALIITSPRINTGEOM==1
81 #include "../TGeant3/TGeant3.h"
83 #include "AliITShit.h"
86 #include "AliITSgeom.h"
90 //_____________________________________________________________________________
91 AliITSv5::AliITSv5() {
92 ////////////////////////////////////////////////////////////////////////
93 // Standard default constructor for the ITS version 5.
94 ////////////////////////////////////////////////////////////////////////
97 fIdName = new TString[fIdN];
104 fIdSens = new Int_t[fIdN];
105 for (Int_t i=0;i<fIdN;i++) fIdSens[i]=fIdName[i].Length();
108 //____________________________________________________________________________
109 AliITSv5::AliITSv5(const AliITSv5 &source){
110 ////////////////////////////////////////////////////////////////////////
111 // Copy Constructor for ITS version 5.
112 ////////////////////////////////////////////////////////////////////////
113 if(&source == this) return;
114 printf("Not allowed to copy AliITSv5\n");
117 //_____________________________________________________________________________
118 AliITSv5& AliITSv5::operator=(const AliITSv5 &source){
119 ////////////////////////////////////////////////////////////////////////
120 // Assignment operator for the ITS version 1.
121 ////////////////////////////////////////////////////////////////////////
123 if(&source == this) return *this;
124 printf("Not allowed to copy AliITSv3\n");
128 //_____________________________________________________________________________
129 AliITSv5::~AliITSv5() {
130 ////////////////////////////////////////////////////////////////////////
131 // Standard destructor for the ITS version 5.
132 ////////////////////////////////////////////////////////////////////////
134 //_____________________________________________________________________________
135 AliITSv5::AliITSv5(const char *name, const char *title) : AliITS(name, title){
136 ////////////////////////////////////////////////////////////////////////
137 // Standard constructor for the ITS version 5.
138 ////////////////////////////////////////////////////////////////////////
140 fIdName = new TString[fIdN];
147 fIdSens = new Int_t[fIdN];
148 for (Int_t i=0;i<fIdN;i++) fIdSens[i]=fIdName[i].Length();
151 fEuclidMaterial = "$ALICE_ROOT/Euclid/ITSgeometry_5.tme";
152 fEuclidGeometry = "$ALICE_ROOT/Euclid/ITSgeometry_5.euc";
154 //_____________________________________________________________________________
155 void AliITSv5::BuildGeometry(){
156 ////////////////////////////////////////////////////////////////////////
157 // Geometry builder for the ITS version 5.
158 ////////////////////////////////////////////////////////////////////////
160 // Build ITS TNODE geometry for event display using detailed geometry.
161 // This function builds a simple ITS geometry used by the ROOT macro
166 //const int kColorITSSPD=kRed;
167 //const int kColorITSSDD=kGreen;
168 const int kColorITSSSD=kBlue;
170 top=gAlice->GetGeometry()->GetNode("alice");
171 AliITSgeom *gm = this->GetITSgeom();
180 //TCanvas *c1 = new TCanvas("c1","ITS");
182 for(lay=1;lay<=2;lay++)
183 for(lad=1;lad<=gm->GetNladders(lay);lad++)
184 for(det=1;det<=gm->GetNdetectors(lay);det++){
186 box = new TBRIK ("ActiveSPD","Active volume of SPD","SPD SI DET",
189 cout << "EXCEPTION in box = new TBRIK" << endl;
192 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
193 gm->GetRotMatrix(lay,lad,det,rt);
194 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
195 for(i=0;i<9;i++) rtd[i] = rt[i];
197 rm = new TRotMatrix(name,name,rtd);
199 cout << "EXCEPTION in new TRotMatrix" << endl;
203 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
205 nd = new TNode("SPD"," ",box,xg[0],xg[1],xg[2],rm);
207 cout << "EXCEPTION in new TNode" << endl;
210 nd->SetLineColor(kColorITSSSD);
214 for(lay=3;lay<=3;lay++)
215 for(lad=1;lad<=gm->GetNladders(lay);lad++)
216 for(det=1;det<=gm->GetNdetectors(lay);det++){
218 box = new TBRIK ("ActiveSDD","Active volume of SDD","SDD SI DET",
221 cout << "EXCEPTION in box = new TBRIK" << endl;
224 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
225 gm->GetRotMatrix(lay,lad,det,rt);
226 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
227 for(i=0;i<9;i++) rtd[i] = rt[i];
229 rm = new TRotMatrix(name,name,rtd);
231 cout << "EXCEPTION in new TRotMatrix" << endl;
235 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
237 nd = new TNode("SDD"," ",box,xg[0],xg[1],xg[2],rm);
239 cout << "EXCEPTION in new TNode" << endl;
242 nd->SetLineColor(kColorITSSSD);
246 for(lay=4;lay<=4;lay++)
247 for(lad=1;lad<=gm->GetNladders(lay);lad++)
248 for(det=1;det<=gm->GetNdetectors(lay);det++){
250 box = new TBRIK ("ActiveSDD","Active volume of SDD","SDD SI DET",
253 cout << "EXCEPTION in box = new TBRIK" << endl;
256 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
257 gm->GetRotMatrix(lay,lad,det,rt);
258 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
259 for(i=0;i<9;i++) rtd[i] = rt[i];
261 rm = new TRotMatrix(name,name,rtd);
263 cout << "EXCEPTION in new TRotMatrix" << endl;
267 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
269 nd = new TNode("SDD"," ",box,xg[0],xg[1],xg[2],rm);
271 cout << "EXCEPTION in new TNode" << endl;
274 nd->SetLineColor(kColorITSSSD);
277 for(lay=5;lay<=5;lay++)
278 for(lad=1;lad<=gm->GetNladders(lay);lad++)
279 for(det=1;det<=gm->GetNdetectors(lay);det++){
281 box = new TBRIK ("ActiveSSD","Active volume of SSD","SSD SI DET",
284 cout << "EXCEPTION in box = new TBRIK" << endl;
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];
292 rm = new TRotMatrix(name,name,rtd);
294 cout << "EXCEPTION in new TRotMatrix" << endl;
298 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
300 nd = new TNode("SSD"," ",box,xg[0],xg[1],xg[2],rm);
302 cout << "EXCEPTION in new TNode" << endl;
305 nd->SetLineColor(kColorITSSSD);
309 for(lay=6;lay<=6;lay++)
310 for(lad=1;lad<=gm->GetNladders(lay);lad++)
311 for(det=1;det<=gm->GetNdetectors(lay);det++){
313 box = new TBRIK ("ActiveSSD","Active volume of SSD","SSD SI DET",
316 cout << "EXCEPTION in box = new TBRIK" << endl;
320 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
321 gm->GetRotMatrix(lay,lad,det,rt);
322 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
323 for(i=0;i<9;i++) rtd[i] = rt[i];
325 rm = new TRotMatrix(name,name,rtd);
327 cout << "EXCEPTION in new TRotMatrix" << endl;
331 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
333 nd = new TNode("SSD"," ",box,xg[0],xg[1],xg[2],rm);
335 cout << "EXCEPTION in new TNode" << endl;
338 nd->SetLineColor(kColorITSSSD);
344 //_____________________________________________________________________________
345 void AliITSv5::CreateMaterials(){
346 ////////////////////////////////////////////////////////////////////////
347 // Read a file containing the materials for the ITS version 5.
348 ////////////////////////////////////////////////////////////////////////
351 filtmp = gSystem->ExpandPathName(fEuclidMaterial.Data());
353 FILE *file = fopen(filtmp,"r");
356 ReadEuclidMedia(filtmp);
358 Error("CreateMaterials"," THE MEDIA FILE %s DOES NOT EXIST !",filtmp);
362 //_____________________________________________________________________________
363 void AliITSv5::CreateGeometry(){
364 //////////////////////////////////////////////////////////////////////
365 // This is the geometry used for the ITS Pre-TDR and comes from an
366 // Euclid to Geant conversion. The only difference
367 // is in the details of the ITS supports. The detectors elements,
368 // detector numbering, and local and global reference frames are shown in
369 // the following figures.
372 <img src="picts/ITS/its1+2_convention_front_5.gif">
375 <font size=+2 color=red>
376 <p>This shows the front view of the SPDs.
379 <img src="picts/ITS/its1+2_convention_side_5.gif">
382 <font size=+2 color=red>
383 <p>This shows the perspective view of the SPDs.
385 <img src="picts/ITS/its1+2_tree.gif">
388 <font size=+2 color=red>
389 <p>This shows the geometry Tree for the SPDs.
394 <img src="picts/ITS/its3+4_convention_front_5.gif">
397 <font size=+2 color=red>
398 <p>This shows the front view of the SDDs.
401 <img src="picts/ITS/its3+4_convention_side_5.gif">
404 <font size=+2 color=red>
405 <p>This shows the perspective view of the SDDs.
407 <img src="picts/ITS/its3+4_tree.gif">
410 <font size=+2 color=red>
411 <p>This shows the geometry Tree for the SDDs.
416 <img src="picts/ITS/its5+6_convention_front_5.gif">
419 <font size=+2 color=red>
420 <p>This shows the front view of the SSDs.
423 <img src="picts/ITS/its5+6_convention_side_5.gif">
426 <font size=+2 color=red>
427 <p>This shows the perspective view of the SSDs.
430 <img src="picts/ITS/its5+6_tree.gif">
433 <font size=+2 color=red>
434 <p>This shows the geometry Tree for the SSDs.
439 <img src="picts/ITS/its_layer1-6_2.gif">
442 <font size=+2 color=red>
443 <p>This shows the front view of the whole ITS..
447 <img src="picts/ITS/its_layer1-6_1.gif">
450 <font size=+2 color=red>
451 <p>This shows the perspective view of the whole ITS..
455 <img src="picts/ITS/its1-6_tree.gif">
458 <font size=+2 color=red>
459 <p>This shows the geometry Tree for the whole ITS.
466 // Here are shown the details of the ITS support cones and services.
467 // First is a GEANT tree showing the organization of all of the volumes
468 // that make up the ITS supports and services.
471 <img src="picts/ITS/supports_tree.gif">
474 // What follows are a number of figures showing what these support
475 // structures look like.
479 <img src="picts/ITS/supports_3.gif">
482 <font size=+2 color=red>
483 <p>This shows the geometry of the supports for the Drift and Strip layers only.
487 <img src="picts/ITS/supports_2.gif">
490 <font size=+2 color=red>
491 <p>This shows the geometry of the supports for the Drift and Strip layers in front cut out.
495 <img src="picts/ITS/supports_1.gif">
498 <font size=+2 color=red>
499 <p>This shows the geometry of the supports for the Drift and Strip layers in a back cut out..
503 <img src="picts/ITS/suppssd.gif">
506 <font size=+2 color=red>
507 <p>This shows the geometry for the Strip layers supports.
511 <img src="picts/ITS/suppsdd.gif">
514 <font size=+2 color=red>
515 <p>This shows the geometry for the Drift layers supports.
521 // Read a file containing the geometry for the ITS version 5.
522 ////////////////////////////////////////////////////////////////////////
528 filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
529 FILE *file = fopen(filtmp,"r");
533 printf("Ready to read Euclid geometry file\n");
534 ReadEuclid(fEuclidGeometry.Data(),topvol);
535 printf("Read in euclid geometries\n");
537 Error("CreateGeometry"," THE GEOM FILE %s DOES NOT EXIST !",
538 fEuclidGeometry.Data());
542 // Place the ITS ghost volume ITSV in its mother volume (ALIC) and make it
545 gMC->Gspos("ITSV",1,"ALIC",0,0,0,0,"ONLY");
547 // Outputs the geometry tree in the EUCLID/CAD format if requested to do so
550 gMC->WriteEuclid("ITSgeometry", "ITSV", 1, 5);
551 } // end if (fEuclidOut)
553 // read in the file containing the transformations for the active
554 // volumes for the ITS version 5. This is expected to be in a file
555 // ending in .det. This geometry is kept in the AliITSgeom class.
556 filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
557 size = strlen(filtmp);
559 filtmp[size-3] = 'd'; // change from .euc to .det
560 filtmp[size-2] = 'e';
561 filtmp[size-1] = 't';
562 file = fopen(filtmp,"r");
563 if(file){ // if file exists use it to fill AliITSgeom structure.
565 printf("ready to read .det file %s\n",filtmp);
566 fITSgeom = new AliITSgeom(filtmp);
569 // fill AliITSgeom structure from geant structure just filled above
573 printf("finished with euclid geometrys\n");
575 //_____________________________________________________________________________
576 void AliITSv5::Init(){
577 ////////////////////////////////////////////////////////////////////////
578 // Initialise the ITS after it has been created.
579 ////////////////////////////////////////////////////////////////////////
585 //_____________________________________________________________________________
586 void AliITSv5::StepManager(){
587 ////////////////////////////////////////////////////////////////////////
588 // Called for every step in the ITS, then calles the AliITShit class
589 // creator with the information to be recoreded about that hit.
590 // The value of the macro ALIITSPRINTGEOM if set to 1 will allow the
591 // printing of information to a file which can be used to create a .det
592 // file read in by the routine CreateGeometry(). If set to 0 or any other
593 // value except 1, the default behavior, then no such file is created nor
594 // it the extra variables and the like used in the printing allocated.
595 ////////////////////////////////////////////////////////////////////////
600 TLorentzVector position, momentum;
601 TClonesArray &lhits = *fHits;
602 #if ALIITSPRINTGEOM==1
605 Float_t xl[3],xt[3],angl[6];
606 // Float_t par[20],att[20];
608 static Bool_t first=kTRUE,printit[6][50][50];
609 if(first){ for(copy1=0;copy1<6;copy1++)for(copy2=0;copy2<50;copy2++)
610 for(id=0;id<50;id++) printit[copy1][copy2][id] = kTRUE;
618 if(gMC->IsTrackInside()) vol[3] += 1;
619 if(gMC->IsTrackEntering()) vol[3] += 2;
620 if(gMC->IsTrackExiting()) vol[3] += 4;
621 if(gMC->IsTrackOut()) vol[3] += 8;
622 if(gMC->IsTrackDisappeared()) vol[3] += 16;
623 if(gMC->IsTrackStop()) vol[3] += 32;
624 if(gMC->IsTrackAlive()) vol[3] += 64;
626 // Fill hit structure.
627 if(!(gMC->TrackCharge())) return;
629 // Only entering charged tracks
630 if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
632 id = gMC->CurrentVolOffID(0,copy);
633 //detector copy in the ladder = 1<->4 (ITS1)
635 gMC->CurrentVolOffID(1,copy1);
636 //ladder copy in the module = 1<->2 (I186)
637 gMC->CurrentVolOffID(2,copy2);
638 //module copy in the layer = 1<->10 (I132)
639 vol[2] = copy1+(copy2-1)*2;//# of ladders in one module = 2
640 } else if(id == fIdSens[1]){
642 id = gMC->CurrentVolOffID(0,copy);
643 //detector copy in the ladder = 1<->4 (ITS2)
645 gMC->CurrentVolOffID(1,copy1);
646 //ladder copy in the module = 1<->4 (I131)
647 gMC->CurrentVolOffID(2,copy2);
648 //module copy in the layer = 1<->10 (I132)
649 vol[2] = copy1+(copy2-1)*4;//# of ladders in one module = 4
650 } else if(id == fIdSens[2]){
652 id = gMC->CurrentVolOffID(1,copy);
653 //detector copy in the ladder = 1<->5 (ITS3 is inside I314)
655 id = gMC->CurrentVolOffID(2,copy);
656 //ladder copy in the layer = 1<->12 (I316)
658 } else if(id == fIdSens[3]){
660 id = gMC->CurrentVolOffID(1,copy);
661 //detector copy in the ladder = 1<->8 (ITS4 is inside I414)
663 id = gMC->CurrentVolOffID(2,copy);
664 //ladder copy in the layer = 1<->22 (I417)
666 }else if(id == fIdSens[4]){
668 id = gMC->CurrentVolOffID(1,copy);
669 //detector copy in the ladder = 1<->23 (ITS5 is inside I562)
671 id = gMC->CurrentVolOffID(2,copy);
672 //ladder copy in the layer = 1<->34 (I565)
674 }else if(id == fIdSens[5]){
676 id = gMC->CurrentVolOffID(1,copy);
677 //detector copy in the ladder = 1<->26 (ITS6 is inside I566)
679 id = gMC->CurrentVolOffID(2,copy);
680 //ladder copy in the layer = 1<->38 (I569)
683 return; // not an ITS volume?
684 } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
686 gMC->TrackPosition(position);
687 gMC->TrackMomentum(momentum);
695 hits[7]=gMC->TrackTime();
696 // Fill hit structure with this new hit.
697 new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->CurrentTrack(),vol,hits);
698 #if ALIITSPRINTGEOM==1
699 if(printit[vol[0]][vol[2]][vol[1]]){
700 printit[vol[0]][vol[2]][vol[1]] = kFALSE;
701 xl[0] = xl[1] = xl[2] = 0.0;
703 for(i=0;i<9;i++) mat[i] = 0.0;
704 mat[0] = mat[4] = mat[8] = 1.0; // default with identity matrix
707 gMC->Gdtom(xl,&(mat[0]),2);
710 gMC->Gdtom(xl,&(mat[3]),2);
713 gMC->Gdtom(xl,&(mat[6]),2);
715 angl[0] = TMath::ACos(mat[2]);
716 if(mat[2]==1.0) angl[0] = 0.0;
717 angl[1] = TMath::ATan2(mat[1],mat[0]);
718 if(angl[1]<0.0) angl[1] += 2.0*TMath::Pi();
720 angl[2] = TMath::ACos(mat[5]);
721 if(mat[5]==1.0) angl[2] = 0.0;
722 angl[3] = TMath::ATan2(mat[4],mat[3]);
723 if(angl[3]<0.0) angl[3] += 2.0*TMath::Pi();
725 angl[4] = TMath::ACos(mat[8]);
726 if(mat[8]==1.0) angl[4] = 0.0;
727 angl[5] = TMath::ATan2(mat[7],mat[6]);
728 if(angl[5]<0.0) angl[5] += 2.0*TMath::Pi();
730 for(i=0;i<6;i++) angl[i] *= 180.0/TMath::Pi(); // degrees
731 fp = fopen("ITSgeometry_v5.det","a");
732 fprintf(fp,"%2d %2d %2d %9e %9e %9e %9e %9e %9e %9e %9e %9e ",
733 vol[0],vol[2],vol[1], // layer ladder detector
734 xt[0],xt[1],xt[2], // Translation vector
735 angl[0],angl[1],angl[2],angl[3],angl[4],angl[5] // Geant rotaion
738 fprintf(fp,"%9e %9e %9e %9e %9e %9e %9e %9e %9e",
739 mat[0],mat[1],mat[2],mat[3],mat[4],mat[5],mat[6],mat[7],mat[8]
740 ); // Adding the rotation matrix.
743 } // end if printit[layer][ladder][detector]
747 //____________________________________________________________________________
748 void AliITSv5::Streamer(TBuffer &R__b){
749 ////////////////////////////////////////////////////////////////////////
750 // A dummy Streamer function for this class AliITSv5. By default it
751 // only streams the AliITS class as it is required. Since this class
752 // dosen't contain any "real" data to be saved, it doesn't.
753 ////////////////////////////////////////////////////////////////////////
755 if (R__b.IsReading()) {
756 Version_t R__v = R__b.ReadVersion();
758 AliITS::Streamer(R__b);
760 AliITS::Streamer(R__b);
763 R__b.WriteVersion(AliITSv5::IsA());
764 AliITS::Streamer(R__b);
765 } // end if R__b.IsReading()