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 <TObjString.h>
76 #include <TClonesArray.h>
82 #if ALIITSPRINTGEOM==1
83 #include "../TGeant3/TGeant3.h"
85 #include "AliITShit.h"
88 #include "AliITSgeom.h"
92 //_____________________________________________________________________________
93 AliITSv5::AliITSv5() {
94 ////////////////////////////////////////////////////////////////////////
95 // Standard default constructor for the ITS version 5.
96 ////////////////////////////////////////////////////////////////////////
104 //____________________________________________________________________________
105 AliITSv5::AliITSv5(const AliITSv5 &source){
106 ////////////////////////////////////////////////////////////////////////
107 // Copy Constructor for ITS version 5.
108 ////////////////////////////////////////////////////////////////////////
109 if(&source == this) return;
110 printf("Not allowed to copy AliITSv5\n");
113 //_____________________________________________________________________________
114 AliITSv5& AliITSv5::operator=(const AliITSv5 &source){
115 ////////////////////////////////////////////////////////////////////////
116 // Assignment operator for the ITS version 1.
117 ////////////////////////////////////////////////////////////////////////
119 if(&source == this) return *this;
120 printf("Not allowed to copy AliITSv3\n");
124 //_____________________________________________________________________________
125 AliITSv5::~AliITSv5() {
126 ////////////////////////////////////////////////////////////////////////
127 // Standard destructor for the ITS version 5.
128 ////////////////////////////////////////////////////////////////////////
130 //_____________________________________________________________________________
131 AliITSv5::AliITSv5(const char *name, const char *title) : AliITS(name, title){
132 ////////////////////////////////////////////////////////////////////////
133 // Standard constructor for the ITS version 5.
134 ////////////////////////////////////////////////////////////////////////
137 // TObjArray of TObjStrings
138 fIdName = new TObjArray(fIdN);
139 fIdName->AddAt(new TObjString("ITS1"),0);
140 fIdName->AddAt(new TObjString("ITS2"),1);
141 fIdName->AddAt(new TObjString("ITS3"),2);
142 fIdName->AddAt(new TObjString("ITS4"),3);
143 fIdName->AddAt(new TObjString("ITS5"),4);
144 fIdName->AddAt(new TObjString("ITS6"),5);
146 // Array of TStrings.
147 fIdName = new TString[fIdN];
154 fIdSens = new Int_t[fIdN];
155 for (Int_t i=0;i<fIdN;i++) fIdSens[i] = 0;
159 fEuclidMaterial = "$ALICE_ROOT/Euclid/ITSgeometry_5.tme";
160 fEuclidGeometry = "$ALICE_ROOT/Euclid/ITSgeometry_5.euc";
162 //_____________________________________________________________________________
163 void AliITSv5::BuildGeometry(){
164 ////////////////////////////////////////////////////////////////////////
165 // Geometry builder for the ITS version 5.
166 ////////////////////////////////////////////////////////////////////////
168 // Build ITS TNODE geometry for event display using detailed geometry.
169 // This function builds a simple ITS geometry used by the ROOT macro
174 //const int kColorITSSPD=kRed;
175 //const int kColorITSSDD=kGreen;
176 const int kColorITSSSD=kBlue;
178 top=gAlice->GetGeometry()->GetNode("alice");
179 AliITSgeom *gm = this->GetITSgeom();
188 //TCanvas *c1 = new TCanvas("c1","ITS");
190 for(lay=1;lay<=2;lay++)
191 for(lad=1;lad<=gm->GetNladders(lay);lad++)
192 for(det=1;det<=gm->GetNdetectors(lay);det++){
194 box = new TBRIK ("ActiveSPD","Active volume of SPD","SPD SI DET",
197 cout << "EXCEPTION in box = new TBRIK" << endl;
200 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
201 gm->GetRotMatrix(lay,lad,det,rt);
202 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
203 for(i=0;i<9;i++) rtd[i] = rt[i];
205 rm = new TRotMatrix(name,name,rtd);
207 cout << "EXCEPTION in new TRotMatrix" << endl;
211 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
213 nd = new TNode("SPD"," ",box,xg[0],xg[1],xg[2],rm);
215 cout << "EXCEPTION in new TNode" << endl;
218 nd->SetLineColor(kColorITSSSD);
222 for(lay=3;lay<=3;lay++)
223 for(lad=1;lad<=gm->GetNladders(lay);lad++)
224 for(det=1;det<=gm->GetNdetectors(lay);det++){
226 box = new TBRIK ("ActiveSDD","Active volume of SDD","SDD SI DET",
229 cout << "EXCEPTION in box = new TBRIK" << endl;
232 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
233 gm->GetRotMatrix(lay,lad,det,rt);
234 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
235 for(i=0;i<9;i++) rtd[i] = rt[i];
237 rm = new TRotMatrix(name,name,rtd);
239 cout << "EXCEPTION in new TRotMatrix" << endl;
243 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
245 nd = new TNode("SDD"," ",box,xg[0],xg[1],xg[2],rm);
247 cout << "EXCEPTION in new TNode" << endl;
250 nd->SetLineColor(kColorITSSSD);
254 for(lay=4;lay<=4;lay++)
255 for(lad=1;lad<=gm->GetNladders(lay);lad++)
256 for(det=1;det<=gm->GetNdetectors(lay);det++){
258 box = new TBRIK ("ActiveSDD","Active volume of SDD","SDD SI DET",
261 cout << "EXCEPTION in box = new TBRIK" << endl;
264 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
265 gm->GetRotMatrix(lay,lad,det,rt);
266 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
267 for(i=0;i<9;i++) rtd[i] = rt[i];
269 rm = new TRotMatrix(name,name,rtd);
271 cout << "EXCEPTION in new TRotMatrix" << endl;
275 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
277 nd = new TNode("SDD"," ",box,xg[0],xg[1],xg[2],rm);
279 cout << "EXCEPTION in new TNode" << endl;
282 nd->SetLineColor(kColorITSSSD);
285 for(lay=5;lay<=5;lay++)
286 for(lad=1;lad<=gm->GetNladders(lay);lad++)
287 for(det=1;det<=gm->GetNdetectors(lay);det++){
289 box = new TBRIK ("ActiveSSD","Active volume of SSD","SSD SI DET",
292 cout << "EXCEPTION in box = new TBRIK" << endl;
295 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
296 gm->GetRotMatrix(lay,lad,det,rt);
297 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
298 for(i=0;i<9;i++) rtd[i] = rt[i];
300 rm = new TRotMatrix(name,name,rtd);
302 cout << "EXCEPTION in new TRotMatrix" << endl;
306 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
308 nd = new TNode("SSD"," ",box,xg[0],xg[1],xg[2],rm);
310 cout << "EXCEPTION in new TNode" << endl;
313 nd->SetLineColor(kColorITSSSD);
317 for(lay=6;lay<=6;lay++)
318 for(lad=1;lad<=gm->GetNladders(lay);lad++)
319 for(det=1;det<=gm->GetNdetectors(lay);det++){
321 box = new TBRIK ("ActiveSSD","Active volume of SSD","SSD SI DET",
324 cout << "EXCEPTION in box = new TBRIK" << endl;
328 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
329 gm->GetRotMatrix(lay,lad,det,rt);
330 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
331 for(i=0;i<9;i++) rtd[i] = rt[i];
333 rm = new TRotMatrix(name,name,rtd);
335 cout << "EXCEPTION in new TRotMatrix" << endl;
339 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
341 nd = new TNode("SSD"," ",box,xg[0],xg[1],xg[2],rm);
343 cout << "EXCEPTION in new TNode" << endl;
346 nd->SetLineColor(kColorITSSSD);
352 //_____________________________________________________________________________
353 void AliITSv5::CreateMaterials(){
354 ////////////////////////////////////////////////////////////////////////
355 // Read a file containing the materials for the ITS version 5.
356 ////////////////////////////////////////////////////////////////////////
359 filtmp = gSystem->ExpandPathName(fEuclidMaterial.Data());
361 FILE *file = fopen(filtmp,"r");
364 ReadEuclidMedia(filtmp);
366 Error("CreateMaterials"," THE MEDIA FILE %s DOES NOT EXIST !",filtmp);
370 //_____________________________________________________________________________
371 void AliITSv5::CreateGeometry(){
372 //////////////////////////////////////////////////////////////////////
373 // This is the geometry used for the ITS Pre-TDR and comes from an
374 // Euclid to Geant conversion. The only difference
375 // is in the details of the ITS supports. The detectors elements,
376 // detector numbering, and local and global reference frames are shown in
377 // the following figures.
380 <img src="picts/ITS/its1+2_convention_front_5.gif">
383 <font size=+2 color=red>
384 <p>This shows the front view of the SPDs.
387 <img src="picts/ITS/its1+2_convention_side_5.gif">
390 <font size=+2 color=red>
391 <p>This shows the perspective view of the SPDs.
393 <img src="picts/ITS/its1+2_tree.gif">
396 <font size=+2 color=red>
397 <p>This shows the geometry Tree for the SPDs.
402 <img src="picts/ITS/its3+4_convention_front_5.gif">
405 <font size=+2 color=red>
406 <p>This shows the front view of the SDDs.
409 <img src="picts/ITS/its3+4_convention_side_5.gif">
412 <font size=+2 color=red>
413 <p>This shows the perspective view of the SDDs.
415 <img src="picts/ITS/its3+4_tree.gif">
418 <font size=+2 color=red>
419 <p>This shows the geometry Tree for the SDDs.
424 <img src="picts/ITS/its5+6_convention_front_5.gif">
427 <font size=+2 color=red>
428 <p>This shows the front view of the SSDs.
431 <img src="picts/ITS/its5+6_convention_side_5.gif">
434 <font size=+2 color=red>
435 <p>This shows the perspective view of the SSDs.
438 <img src="picts/ITS/its5+6_tree.gif">
441 <font size=+2 color=red>
442 <p>This shows the geometry Tree for the SSDs.
447 <img src="picts/ITS/its_layer1-6_2.gif">
450 <font size=+2 color=red>
451 <p>This shows the front view of the whole ITS..
455 <img src="picts/ITS/its_layer1-6_1.gif">
458 <font size=+2 color=red>
459 <p>This shows the perspective view of the whole ITS..
463 <img src="picts/ITS/its1-6_tree.gif">
466 <font size=+2 color=red>
467 <p>This shows the geometry Tree for the whole ITS.
474 // Here are shown the details of the ITS support cones and services.
475 // First is a GEANT tree showing the organization of all of the volumes
476 // that make up the ITS supports and services.
479 <img src="picts/ITS/supports_tree.gif">
482 // What follows are a number of figures showing what these support
483 // structures look like.
487 <img src="picts/ITS/supports_3.gif">
490 <font size=+2 color=red>
491 <p>This shows the geometry of the supports for the Drift and Strip layers only.
495 <img src="picts/ITS/supports_2.gif">
498 <font size=+2 color=red>
499 <p>This shows the geometry of the supports for the Drift and Strip layers in front cut out.
503 <img src="picts/ITS/supports_1.gif">
506 <font size=+2 color=red>
507 <p>This shows the geometry of the supports for the Drift and Strip layers in a back cut out..
511 <img src="picts/ITS/suppssd.gif">
514 <font size=+2 color=red>
515 <p>This shows the geometry for the Strip layers supports.
519 <img src="picts/ITS/suppsdd.gif">
522 <font size=+2 color=red>
523 <p>This shows the geometry for the Drift layers supports.
529 // Read a file containing the geometry for the ITS version 5.
530 ////////////////////////////////////////////////////////////////////////
536 filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
537 FILE *file = fopen(filtmp,"r");
541 printf("Ready to read Euclid geometry file\n");
542 ReadEuclid(fEuclidGeometry.Data(),topvol);
543 printf("Read in euclid geometries\n");
545 Error("CreateGeometry"," THE GEOM FILE %s DOES NOT EXIST !",
546 fEuclidGeometry.Data());
550 // Place the ITS ghost volume ITSV in its mother volume (ALIC) and make it
553 gMC->Gspos("ITSV",1,"ALIC",0,0,0,0,"ONLY");
555 // Outputs the geometry tree in the EUCLID/CAD format if requested to do so
558 gMC->WriteEuclid("ITSgeometry", "ITSV", 1, 5);
559 } // end if (fEuclidOut)
561 // read in the file containing the transformations for the active
562 // volumes for the ITS version 5. This is expected to be in a file
563 // ending in .det. This geometry is kept in the AliITSgeom class.
564 filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
565 size = strlen(filtmp);
567 filtmp[size-3] = 'd'; // change from .euc to .det
568 filtmp[size-2] = 'e';
569 filtmp[size-1] = 't';
570 file = fopen(filtmp,"r");
571 if(file){ // if file exists use it to fill AliITSgeom structure.
573 printf("ready to read .det file %s\n",filtmp);
574 fITSgeom = new AliITSgeom(filtmp);
577 // fill AliITSgeom structure from geant structure just filled above
581 printf("finished with euclid geometrys\n");
583 //_____________________________________________________________________________
584 void AliITSv5::Init(){
585 ////////////////////////////////////////////////////////////////////////
586 // Initialise the ITS after it has been created.
587 ////////////////////////////////////////////////////////////////////////
593 //_____________________________________________________________________________
594 void AliITSv5::StepManager(){
595 ////////////////////////////////////////////////////////////////////////
596 // Called for every step in the ITS, then calles the AliITShit class
597 // creator with the information to be recoreded about that hit.
598 // The value of the macro ALIITSPRINTGEOM if set to 1 will allow the
599 // printing of information to a file which can be used to create a .det
600 // file read in by the routine CreateGeometry(). If set to 0 or any other
601 // value except 1, the default behavior, then no such file is created nor
602 // it the extra variables and the like used in the printing allocated.
603 ////////////////////////////////////////////////////////////////////////
608 TLorentzVector position, momentum;
609 TClonesArray &lhits = *fHits;
610 #if ALIITSPRINTGEOM==1
613 Float_t xl[3],xt[3],angl[6];
614 // Float_t par[20],att[20];
616 static Bool_t first=kTRUE,printit[6][50][50];
617 if(first){ for(copy1=0;copy1<6;copy1++)for(copy2=0;copy2<50;copy2++)
618 for(id=0;id<50;id++) printit[copy1][copy2][id] = kTRUE;
626 if(gMC->IsTrackInside()) vol[3] += 1;
627 if(gMC->IsTrackEntering()) vol[3] += 2;
628 if(gMC->IsTrackExiting()) vol[3] += 4;
629 if(gMC->IsTrackOut()) vol[3] += 8;
630 if(gMC->IsTrackDisappeared()) vol[3] += 16;
631 if(gMC->IsTrackStop()) vol[3] += 32;
632 if(gMC->IsTrackAlive()) vol[3] += 64;
634 // Fill hit structure.
635 if(!(gMC->TrackCharge())) return;
637 // Only entering charged tracks
638 if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
640 id = gMC->CurrentVolOffID(0,copy);
641 //detector copy in the ladder = 1<->4 (ITS1)
643 gMC->CurrentVolOffID(1,copy1);
644 //ladder copy in the module = 1<->2 (I186)
645 gMC->CurrentVolOffID(2,copy2);
646 //module copy in the layer = 1<->10 (I132)
647 vol[2] = copy1+(copy2-1)*2;//# of ladders in one module = 2
648 } else if(id == fIdSens[1]){
650 id = gMC->CurrentVolOffID(0,copy);
651 //detector copy in the ladder = 1<->4 (ITS2)
653 gMC->CurrentVolOffID(1,copy1);
654 //ladder copy in the module = 1<->4 (I131)
655 gMC->CurrentVolOffID(2,copy2);
656 //module copy in the layer = 1<->10 (I132)
657 vol[2] = copy1+(copy2-1)*4;//# of ladders in one module = 4
658 } else if(id == fIdSens[2]){
660 id = gMC->CurrentVolOffID(1,copy);
661 //detector copy in the ladder = 1<->5 (ITS3 is inside I314)
663 id = gMC->CurrentVolOffID(2,copy);
664 //ladder copy in the layer = 1<->12 (I316)
666 } else if(id == fIdSens[3]){
668 id = gMC->CurrentVolOffID(1,copy);
669 //detector copy in the ladder = 1<->8 (ITS4 is inside I414)
671 id = gMC->CurrentVolOffID(2,copy);
672 //ladder copy in the layer = 1<->22 (I417)
674 }else if(id == fIdSens[4]){
676 id = gMC->CurrentVolOffID(1,copy);
677 //detector copy in the ladder = 1<->23 (ITS5 is inside I562)
679 id = gMC->CurrentVolOffID(2,copy);
680 //ladder copy in the layer = 1<->34 (I565)
682 }else if(id == fIdSens[5]){
684 id = gMC->CurrentVolOffID(1,copy);
685 //detector copy in the ladder = 1<->26 (ITS6 is inside I566)
687 id = gMC->CurrentVolOffID(2,copy);
688 //ladder copy in the layer = 1<->38 (I569)
691 return; // not an ITS volume?
692 } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
694 gMC->TrackPosition(position);
695 gMC->TrackMomentum(momentum);
703 hits[7]=gMC->TrackTime();
704 // Fill hit structure with this new hit.
705 new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->CurrentTrack(),vol,hits);
706 #if ALIITSPRINTGEOM==1
707 if(printit[vol[0]][vol[2]][vol[1]]){
708 printit[vol[0]][vol[2]][vol[1]] = kFALSE;
709 xl[0] = xl[1] = xl[2] = 0.0;
711 for(i=0;i<9;i++) mat[i] = 0.0;
712 mat[0] = mat[4] = mat[8] = 1.0; // default with identity matrix
715 gMC->Gdtom(xl,&(mat[0]),2);
718 gMC->Gdtom(xl,&(mat[3]),2);
721 gMC->Gdtom(xl,&(mat[6]),2);
723 angl[0] = TMath::ACos(mat[2]);
724 if(mat[2]==1.0) angl[0] = 0.0;
725 angl[1] = TMath::ATan2(mat[1],mat[0]);
726 if(angl[1]<0.0) angl[1] += 2.0*TMath::Pi();
728 angl[2] = TMath::ACos(mat[5]);
729 if(mat[5]==1.0) angl[2] = 0.0;
730 angl[3] = TMath::ATan2(mat[4],mat[3]);
731 if(angl[3]<0.0) angl[3] += 2.0*TMath::Pi();
733 angl[4] = TMath::ACos(mat[8]);
734 if(mat[8]==1.0) angl[4] = 0.0;
735 angl[5] = TMath::ATan2(mat[7],mat[6]);
736 if(angl[5]<0.0) angl[5] += 2.0*TMath::Pi();
738 for(i=0;i<6;i++) angl[i] *= 180.0/TMath::Pi(); // degrees
739 fp = fopen("ITSgeometry_v5.det","a");
740 fprintf(fp,"%2d %2d %2d %9e %9e %9e %9e %9e %9e %9e %9e %9e ",
741 vol[0],vol[2],vol[1], // layer ladder detector
742 xt[0],xt[1],xt[2], // Translation vector
743 angl[0],angl[1],angl[2],angl[3],angl[4],angl[5] // Geant rotaion
746 fprintf(fp,"%9e %9e %9e %9e %9e %9e %9e %9e %9e",
747 mat[0],mat[1],mat[2],mat[3],mat[4],mat[5],mat[6],mat[7],mat[8]
748 ); // Adding the rotation matrix.
751 } // end if printit[layer][ladder][detector]
756 //____________________________________________________________________________
757 void AliITSv5::Streamer(TBuffer &R__b){
758 ////////////////////////////////////////////////////////////////////////
759 // A dummy Streamer function for this class AliITSv5. By default it
760 // only streams the AliITS class as it is required. Since this class
761 // dosen't contain any "real" data to be saved, it doesn't.
762 ////////////////////////////////////////////////////////////////////////
764 if (R__b.IsReading()) {
765 Version_t R__v = R__b.ReadVersion();
767 AliITS::Streamer(R__b);
769 AliITS::Streamer(R__b);
772 R__b.WriteVersion(AliITSv5::IsA());
773 AliITS::Streamer(R__b);
774 } // end if R__b.IsReading()