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.23 2000/10/02 16:35:23 barbera
19 Forward declarations added
21 Revision 1.14.4.12 2000/10/02 16:04:03 barbera
22 Forward declarations added
24 Revision 1.22 2000/07/10 16:07:19 fca
25 Release version of ITS code
27 Revision 1.14.4.4 2000/05/19 10:10:21 nilsen
28 fix for bug with HP and Sun unix + fix for event display in ITS-working branch
30 Revision 1.14.4.3 2000/03/04 23:46:38 nilsen
31 Fixed up the comments/documentation.
33 Revision 1.14.4.2 2000/03/02 21:53:02 nilsen
34 To make it compatable with the changes in AliRun/AliModule.
36 Revision 1.14.4.1 2000/01/12 19:03:33 nilsen
37 This is the version of the files after the merging done in December 1999.
38 See the ReadMe110100.txt file for details
40 Revision 1.14 1999/10/22 08:16:49 fca
41 Correct destructors, thanks to I.Hrivnacova
43 Revision 1.13 1999/10/06 10:15:19 fca
44 Correct bug in allocation of layer name and add destructor
46 Revision 1.12 1999/10/05 08:05:09 fca
47 Minor corrections for uninitialised variables.
49 Revision 1.11 1999/09/29 09:24:20 fca
50 Introduction of the Copyright and cvs Log
54 ///////////////////////////////////////////////////////////////////////////////
56 // Inner Traking System version 5
57 // This class contains the base procedures for the Inner Tracking System
59 // Authors: R. Barbera, B. S. Nilsen.
61 // Created September 17 1999.
63 ///////////////////////////////////////////////////////////////////////////////
65 // See AliITSv5::StepManager().
66 #define ALIITSPRINTGEOM 0 // default. don't print out gemetry information
67 //#define ALIITSPRINTGEOM 1 // print out geometry information
72 #include <TGeometry.h>
75 #include <TFile.h> // only required for Tracking function?
77 #include <TObjArray.h>
78 #include <TClonesArray.h>
84 #if ALIITSPRINTGEOM==1
85 #include "../TGeant3/TGeant3.h"
87 #include "AliITShit.h"
90 #include "AliITSgeom.h"
94 //_____________________________________________________________________________
95 AliITSv5::AliITSv5() {
96 ////////////////////////////////////////////////////////////////////////
97 // Standard default constructor for the ITS version 5.
98 ////////////////////////////////////////////////////////////////////////
101 fIdName = new TString[fIdN];
108 fIdSens = new Int_t[fIdN];
109 for (Int_t i=0;i<fIdN;i++) fIdSens[i]=fIdName[i].Length();
112 //____________________________________________________________________________
113 AliITSv5::AliITSv5(const AliITSv5 &source){
114 ////////////////////////////////////////////////////////////////////////
115 // Copy Constructor for ITS version 5.
116 ////////////////////////////////////////////////////////////////////////
117 if(&source == this) return;
118 printf("Not allowed to copy AliITSv5\n");
121 //_____________________________________________________________________________
122 AliITSv5& AliITSv5::operator=(const AliITSv5 &source){
123 ////////////////////////////////////////////////////////////////////////
124 // Assignment operator for the ITS version 1.
125 ////////////////////////////////////////////////////////////////////////
127 if(&source == this) return *this;
128 printf("Not allowed to copy AliITSv3\n");
132 //_____________________________________________________________________________
133 AliITSv5::~AliITSv5() {
134 ////////////////////////////////////////////////////////////////////////
135 // Standard destructor for the ITS version 5.
136 ////////////////////////////////////////////////////////////////////////
138 //_____________________________________________________________________________
139 AliITSv5::AliITSv5(const char *name, const char *title) : AliITS(name, title){
140 ////////////////////////////////////////////////////////////////////////
141 // Standard constructor for the ITS version 5.
142 ////////////////////////////////////////////////////////////////////////
144 fIdName = new TString[fIdN];
151 fIdSens = new Int_t[fIdN];
152 for (Int_t i=0;i<fIdN;i++) fIdSens[i]=fIdName[i].Length();
155 fEuclidMaterial = "$ALICE_ROOT/Euclid/ITSgeometry_5.tme";
156 fEuclidGeometry = "$ALICE_ROOT/Euclid/ITSgeometry_5.euc";
158 //_____________________________________________________________________________
159 void AliITSv5::BuildGeometry(){
160 ////////////////////////////////////////////////////////////////////////
161 // Geometry builder for the ITS version 5.
162 ////////////////////////////////////////////////////////////////////////
164 // Build ITS TNODE geometry for event display using detailed geometry.
165 // This function builds a simple ITS geometry used by the ROOT macro
170 //const int kColorITSSPD=kRed;
171 //const int kColorITSSDD=kGreen;
172 const int kColorITSSSD=kBlue;
174 top=gAlice->GetGeometry()->GetNode("alice");
175 AliITSgeom *gm = this->GetITSgeom();
184 //TCanvas *c1 = new TCanvas("c1","ITS");
186 for(lay=1;lay<=2;lay++)
187 for(lad=1;lad<=gm->GetNladders(lay);lad++)
188 for(det=1;det<=gm->GetNdetectors(lay);det++){
190 box = new TBRIK ("ActiveSPD","Active volume of SPD","SPD SI DET",
193 cout << "EXCEPTION in box = new TBRIK" << endl;
196 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
197 gm->GetRotMatrix(lay,lad,det,rt);
198 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
199 for(i=0;i<9;i++) rtd[i] = rt[i];
201 rm = new TRotMatrix(name,name,rtd);
203 cout << "EXCEPTION in new TRotMatrix" << endl;
207 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
209 nd = new TNode("SPD"," ",box,xg[0],xg[1],xg[2],rm);
211 cout << "EXCEPTION in new TNode" << endl;
214 nd->SetLineColor(kColorITSSSD);
218 for(lay=3;lay<=3;lay++)
219 for(lad=1;lad<=gm->GetNladders(lay);lad++)
220 for(det=1;det<=gm->GetNdetectors(lay);det++){
222 box = new TBRIK ("ActiveSDD","Active volume of SDD","SDD SI DET",
225 cout << "EXCEPTION in box = new TBRIK" << endl;
228 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
229 gm->GetRotMatrix(lay,lad,det,rt);
230 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
231 for(i=0;i<9;i++) rtd[i] = rt[i];
233 rm = new TRotMatrix(name,name,rtd);
235 cout << "EXCEPTION in new TRotMatrix" << endl;
239 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
241 nd = new TNode("SDD"," ",box,xg[0],xg[1],xg[2],rm);
243 cout << "EXCEPTION in new TNode" << endl;
246 nd->SetLineColor(kColorITSSSD);
250 for(lay=4;lay<=4;lay++)
251 for(lad=1;lad<=gm->GetNladders(lay);lad++)
252 for(det=1;det<=gm->GetNdetectors(lay);det++){
254 box = new TBRIK ("ActiveSDD","Active volume of SDD","SDD SI DET",
257 cout << "EXCEPTION in box = new TBRIK" << endl;
260 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
261 gm->GetRotMatrix(lay,lad,det,rt);
262 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
263 for(i=0;i<9;i++) rtd[i] = rt[i];
265 rm = new TRotMatrix(name,name,rtd);
267 cout << "EXCEPTION in new TRotMatrix" << endl;
271 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
273 nd = new TNode("SDD"," ",box,xg[0],xg[1],xg[2],rm);
275 cout << "EXCEPTION in new TNode" << endl;
278 nd->SetLineColor(kColorITSSSD);
281 for(lay=5;lay<=5;lay++)
282 for(lad=1;lad<=gm->GetNladders(lay);lad++)
283 for(det=1;det<=gm->GetNdetectors(lay);det++){
285 box = new TBRIK ("ActiveSSD","Active volume of SSD","SSD SI DET",
288 cout << "EXCEPTION in box = new TBRIK" << endl;
291 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
292 gm->GetRotMatrix(lay,lad,det,rt);
293 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
294 for(i=0;i<9;i++) rtd[i] = rt[i];
296 rm = new TRotMatrix(name,name,rtd);
298 cout << "EXCEPTION in new TRotMatrix" << endl;
302 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
304 nd = new TNode("SSD"," ",box,xg[0],xg[1],xg[2],rm);
306 cout << "EXCEPTION in new TNode" << endl;
309 nd->SetLineColor(kColorITSSSD);
313 for(lay=6;lay<=6;lay++)
314 for(lad=1;lad<=gm->GetNladders(lay);lad++)
315 for(det=1;det<=gm->GetNdetectors(lay);det++){
317 box = new TBRIK ("ActiveSSD","Active volume of SSD","SSD SI DET",
320 cout << "EXCEPTION in box = new TBRIK" << endl;
324 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
325 gm->GetRotMatrix(lay,lad,det,rt);
326 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
327 for(i=0;i<9;i++) rtd[i] = rt[i];
329 rm = new TRotMatrix(name,name,rtd);
331 cout << "EXCEPTION in new TRotMatrix" << endl;
335 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
337 nd = new TNode("SSD"," ",box,xg[0],xg[1],xg[2],rm);
339 cout << "EXCEPTION in new TNode" << endl;
342 nd->SetLineColor(kColorITSSSD);
348 //_____________________________________________________________________________
349 void AliITSv5::CreateMaterials(){
350 ////////////////////////////////////////////////////////////////////////
351 // Read a file containing the materials for the ITS version 5.
352 ////////////////////////////////////////////////////////////////////////
355 filtmp = gSystem->ExpandPathName(fEuclidMaterial.Data());
357 FILE *file = fopen(filtmp,"r");
360 ReadEuclidMedia(filtmp);
362 Error("CreateMaterials"," THE MEDIA FILE %s DOES NOT EXIST !",filtmp);
366 //_____________________________________________________________________________
367 void AliITSv5::CreateGeometry(){
368 //////////////////////////////////////////////////////////////////////
369 // This is the geometry used for the ITS Pre-TDR and comes from an
370 // Euclid to Geant conversion. The only difference
371 // is in the details of the ITS supports. The detectors elements,
372 // detector numbering, and local and global reference frames are shown in
373 // the following figures.
376 <img src="picts/ITS/its1+2_convention_front_5.gif">
379 <font size=+2 color=red>
380 <p>This shows the front view of the SPDs.
383 <img src="picts/ITS/its1+2_convention_side_5.gif">
386 <font size=+2 color=red>
387 <p>This shows the perspective view of the SPDs.
389 <img src="picts/ITS/its1+2_tree.gif">
392 <font size=+2 color=red>
393 <p>This shows the geometry Tree for the SPDs.
398 <img src="picts/ITS/its3+4_convention_front_5.gif">
401 <font size=+2 color=red>
402 <p>This shows the front view of the SDDs.
405 <img src="picts/ITS/its3+4_convention_side_5.gif">
408 <font size=+2 color=red>
409 <p>This shows the perspective view of the SDDs.
411 <img src="picts/ITS/its3+4_tree.gif">
414 <font size=+2 color=red>
415 <p>This shows the geometry Tree for the SDDs.
420 <img src="picts/ITS/its5+6_convention_front_5.gif">
423 <font size=+2 color=red>
424 <p>This shows the front view of the SSDs.
427 <img src="picts/ITS/its5+6_convention_side_5.gif">
430 <font size=+2 color=red>
431 <p>This shows the perspective view of the SSDs.
434 <img src="picts/ITS/its5+6_tree.gif">
437 <font size=+2 color=red>
438 <p>This shows the geometry Tree for the SSDs.
443 <img src="picts/ITS/its_layer1-6_2.gif">
446 <font size=+2 color=red>
447 <p>This shows the front view of the whole ITS..
451 <img src="picts/ITS/its_layer1-6_1.gif">
454 <font size=+2 color=red>
455 <p>This shows the perspective view of the whole ITS..
459 <img src="picts/ITS/its1-6_tree.gif">
462 <font size=+2 color=red>
463 <p>This shows the geometry Tree for the whole ITS.
470 // Here are shown the details of the ITS support cones and services.
471 // First is a GEANT tree showing the organization of all of the volumes
472 // that make up the ITS supports and services.
475 <img src="picts/ITS/supports_tree.gif">
478 // What follows are a number of figures showing what these support
479 // structures look like.
483 <img src="picts/ITS/supports_3.gif">
486 <font size=+2 color=red>
487 <p>This shows the geometry of the supports for the Drift and Strip layers only.
491 <img src="picts/ITS/supports_2.gif">
494 <font size=+2 color=red>
495 <p>This shows the geometry of the supports for the Drift and Strip layers in front cut out.
499 <img src="picts/ITS/supports_1.gif">
502 <font size=+2 color=red>
503 <p>This shows the geometry of the supports for the Drift and Strip layers in a back cut out..
507 <img src="picts/ITS/suppssd.gif">
510 <font size=+2 color=red>
511 <p>This shows the geometry for the Strip layers supports.
515 <img src="picts/ITS/suppsdd.gif">
518 <font size=+2 color=red>
519 <p>This shows the geometry for the Drift layers supports.
525 // Read a file containing the geometry for the ITS version 5.
526 ////////////////////////////////////////////////////////////////////////
532 filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
533 FILE *file = fopen(filtmp,"r");
537 printf("Ready to read Euclid geometry file\n");
538 ReadEuclid(fEuclidGeometry.Data(),topvol);
539 printf("Read in euclid geometries\n");
541 Error("CreateGeometry"," THE GEOM FILE %s DOES NOT EXIST !",
542 fEuclidGeometry.Data());
546 // Place the ITS ghost volume ITSV in its mother volume (ALIC) and make it
549 gMC->Gspos("ITSV",1,"ALIC",0,0,0,0,"ONLY");
551 // Outputs the geometry tree in the EUCLID/CAD format if requested to do so
554 gMC->WriteEuclid("ITSgeometry", "ITSV", 1, 5);
555 } // end if (fEuclidOut)
557 // read in the file containing the transformations for the active
558 // volumes for the ITS version 5. This is expected to be in a file
559 // ending in .det. This geometry is kept in the AliITSgeom class.
560 filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
561 size = strlen(filtmp);
563 filtmp[size-3] = 'd'; // change from .euc to .det
564 filtmp[size-2] = 'e';
565 filtmp[size-1] = 't';
566 file = fopen(filtmp,"r");
567 if(file){ // if file exists use it to fill AliITSgeom structure.
569 printf("ready to read .det file %s\n",filtmp);
570 fITSgeom = new AliITSgeom(filtmp);
573 // fill AliITSgeom structure from geant structure just filled above
577 printf("finished with euclid geometrys\n");
579 //_____________________________________________________________________________
580 void AliITSv5::Init(){
581 ////////////////////////////////////////////////////////////////////////
582 // Initialise the ITS after it has been created.
583 ////////////////////////////////////////////////////////////////////////
589 //_____________________________________________________________________________
590 void AliITSv5::StepManager(){
591 ////////////////////////////////////////////////////////////////////////
592 // Called for every step in the ITS, then calles the AliITShit class
593 // creator with the information to be recoreded about that hit.
594 // The value of the macro ALIITSPRINTGEOM if set to 1 will allow the
595 // printing of information to a file which can be used to create a .det
596 // file read in by the routine CreateGeometry(). If set to 0 or any other
597 // value except 1, the default behavior, then no such file is created nor
598 // it the extra variables and the like used in the printing allocated.
599 ////////////////////////////////////////////////////////////////////////
604 TLorentzVector position, momentum;
605 TClonesArray &lhits = *fHits;
606 #if ALIITSPRINTGEOM==1
609 Float_t xl[3],xt[3],angl[6];
610 // Float_t par[20],att[20];
612 static Bool_t first=kTRUE,printit[6][50][50];
613 if(first){ for(copy1=0;copy1<6;copy1++)for(copy2=0;copy2<50;copy2++)
614 for(id=0;id<50;id++) printit[copy1][copy2][id] = kTRUE;
622 if(gMC->IsTrackInside()) vol[3] += 1;
623 if(gMC->IsTrackEntering()) vol[3] += 2;
624 if(gMC->IsTrackExiting()) vol[3] += 4;
625 if(gMC->IsTrackOut()) vol[3] += 8;
626 if(gMC->IsTrackDisappeared()) vol[3] += 16;
627 if(gMC->IsTrackStop()) vol[3] += 32;
628 if(gMC->IsTrackAlive()) vol[3] += 64;
630 // Fill hit structure.
631 if(!(gMC->TrackCharge())) return;
633 // Only entering charged tracks
634 if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
636 id = gMC->CurrentVolOffID(0,copy);
637 //detector copy in the ladder = 1<->4 (ITS1)
639 gMC->CurrentVolOffID(1,copy1);
640 //ladder copy in the module = 1<->2 (I186)
641 gMC->CurrentVolOffID(2,copy2);
642 //module copy in the layer = 1<->10 (I132)
643 vol[2] = copy1+(copy2-1)*2;//# of ladders in one module = 2
644 } else if(id == fIdSens[1]){
646 id = gMC->CurrentVolOffID(0,copy);
647 //detector copy in the ladder = 1<->4 (ITS2)
649 gMC->CurrentVolOffID(1,copy1);
650 //ladder copy in the module = 1<->4 (I131)
651 gMC->CurrentVolOffID(2,copy2);
652 //module copy in the layer = 1<->10 (I132)
653 vol[2] = copy1+(copy2-1)*4;//# of ladders in one module = 4
654 } else if(id == fIdSens[2]){
656 id = gMC->CurrentVolOffID(1,copy);
657 //detector copy in the ladder = 1<->5 (ITS3 is inside I314)
659 id = gMC->CurrentVolOffID(2,copy);
660 //ladder copy in the layer = 1<->12 (I316)
662 } else if(id == fIdSens[3]){
664 id = gMC->CurrentVolOffID(1,copy);
665 //detector copy in the ladder = 1<->8 (ITS4 is inside I414)
667 id = gMC->CurrentVolOffID(2,copy);
668 //ladder copy in the layer = 1<->22 (I417)
670 }else if(id == fIdSens[4]){
672 id = gMC->CurrentVolOffID(1,copy);
673 //detector copy in the ladder = 1<->23 (ITS5 is inside I562)
675 id = gMC->CurrentVolOffID(2,copy);
676 //ladder copy in the layer = 1<->34 (I565)
678 }else if(id == fIdSens[5]){
680 id = gMC->CurrentVolOffID(1,copy);
681 //detector copy in the ladder = 1<->26 (ITS6 is inside I566)
683 id = gMC->CurrentVolOffID(2,copy);
684 //ladder copy in the layer = 1<->38 (I569)
687 return; // not an ITS volume?
688 } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
690 gMC->TrackPosition(position);
691 gMC->TrackMomentum(momentum);
699 hits[7]=gMC->TrackTime();
700 // Fill hit structure with this new hit.
701 new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->CurrentTrack(),vol,hits);
702 #if ALIITSPRINTGEOM==1
703 if(printit[vol[0]][vol[2]][vol[1]]){
704 printit[vol[0]][vol[2]][vol[1]] = kFALSE;
705 xl[0] = xl[1] = xl[2] = 0.0;
707 for(i=0;i<9;i++) mat[i] = 0.0;
708 mat[0] = mat[4] = mat[8] = 1.0; // default with identity matrix
711 gMC->Gdtom(xl,&(mat[0]),2);
714 gMC->Gdtom(xl,&(mat[3]),2);
717 gMC->Gdtom(xl,&(mat[6]),2);
719 angl[0] = TMath::ACos(mat[2]);
720 if(mat[2]==1.0) angl[0] = 0.0;
721 angl[1] = TMath::ATan2(mat[1],mat[0]);
722 if(angl[1]<0.0) angl[1] += 2.0*TMath::Pi();
724 angl[2] = TMath::ACos(mat[5]);
725 if(mat[5]==1.0) angl[2] = 0.0;
726 angl[3] = TMath::ATan2(mat[4],mat[3]);
727 if(angl[3]<0.0) angl[3] += 2.0*TMath::Pi();
729 angl[4] = TMath::ACos(mat[8]);
730 if(mat[8]==1.0) angl[4] = 0.0;
731 angl[5] = TMath::ATan2(mat[7],mat[6]);
732 if(angl[5]<0.0) angl[5] += 2.0*TMath::Pi();
734 for(i=0;i<6;i++) angl[i] *= 180.0/TMath::Pi(); // degrees
735 fp = fopen("ITSgeometry_v5.det","a");
736 fprintf(fp,"%2d %2d %2d %9e %9e %9e %9e %9e %9e %9e %9e %9e ",
737 vol[0],vol[2],vol[1], // layer ladder detector
738 xt[0],xt[1],xt[2], // Translation vector
739 angl[0],angl[1],angl[2],angl[3],angl[4],angl[5] // Geant rotaion
742 fprintf(fp,"%9e %9e %9e %9e %9e %9e %9e %9e %9e",
743 mat[0],mat[1],mat[2],mat[3],mat[4],mat[5],mat[6],mat[7],mat[8]
744 ); // Adding the rotation matrix.
747 } // end if printit[layer][ladder][detector]
751 //____________________________________________________________________________
752 void AliITSv5::Streamer(TBuffer &R__b){
753 ////////////////////////////////////////////////////////////////////////
754 // A dummy Streamer function for this class AliITSv5. By default it
755 // only streams the AliITS class as it is required. Since this class
756 // dosen't contain any "real" data to be saved, it doesn't.
757 ////////////////////////////////////////////////////////////////////////
759 if (R__b.IsReading()) {
760 Version_t R__v = R__b.ReadVersion();
762 AliITS::Streamer(R__b);
764 AliITS::Streamer(R__b);
767 R__b.WriteVersion(AliITSv5::IsA());
768 AliITS::Streamer(R__b);
769 } // end if R__b.IsReading()