1 /**************************************************************************
2 * Copyright(c) 2007-2008, 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 **************************************************************************/
17 //************************************************************************
19 // Inner Traking System geometry v11
21 // Based on ROOT geometrical modeler
23 // B. Nilsen, L. Gaudichet
24 //************************************************************************
27 #include <TClonesArray.h>
28 #include <TLorentzVector.h>
31 #include "AliITSDetTypeSim.h"
32 #include <TVirtualMC.h>
34 #include "AliITSgeom.h"
35 #include "AliITShit.h"
37 #include "AliITSCalibrationSDD.h"
39 #include "AliITSsegmentationSDD.h"
40 #include "AliITSsegmentationSPD.h"
41 #include "AliITSsegmentationSSD.h"
44 #include "AliTrackReference.h"
47 #include <TGeoManager.h>
48 #include <TGeoVolume.h>
50 #include "AliITSv11.h"
51 #include "AliITSv11GeometrySPD.h"
52 #include "AliITSv11GeometrySDD.h"
53 #include "AliITSv11GeometrySSD.h"
54 #include "AliITSv11GeometrySupport.h"
62 //______________________________________________________________________
63 AliITSv11::AliITSv11() :
68 fMajorVersion(IsVersion()),
79 // Standard default constructor for the ITS version 11.
85 for(i=0;i<60;i++) fRead[i] = '\0';
86 for(i=0;i<60;i++) fWrite[i] = '\0';
87 for(i=0;i<60;i++) fEuclidGeomDet[i] = '\0';
88 strncpy(fRead,"$ALICE_ROOT/ITS/ITSgeometry_vPPRasymmFMD.det",60);
92 //______________________________________________________________________
93 AliITSv11::AliITSv11(const char *name, const char *title):
98 fMajorVersion(IsVersion()),
109 // Standard constructor for the ITS version 11.
111 fSDDgeom = new AliITSv11GeometrySDD(0);
115 fIdName = new TString[fIdN];
116 fIdName[0] = name; // removes warning message
119 fIdName[2] = fSDDgeom->GetSenstiveVolumeName3();
120 fIdName[3] = fSDDgeom->GetSenstiveVolumeName4();
123 fIdSens = new Int_t[fIdN];
124 for(i=0;i<fIdN;i++) fIdSens[i] = 0;
125 // not needed, fByThick set to kTRUE in in the member initialization lis
128 fEuclidGeometry="$ALICE_ROOT/ITS/ITSgeometry_vPPRasymm2.euc";
129 strncpy(fEuclidGeomDet,"$ALICE_ROOT/ITS/ITSgeometry_vPPRasymm2.det",60);
130 strncpy(fRead,fEuclidGeomDet,60);
131 strncpy(fWrite,fEuclidGeomDet,60);
132 strncpy(fRead,"$ALICE_ROOT/ITS/ITSgeometry_vPPRasymmFMD.det",60);
134 //______________________________________________________________________
135 AliITSv11::AliITSv11(Int_t debugITS,Int_t debugSPD,Int_t debugSDD,
136 Int_t debugSSD,Int_t debugSUP) :
137 AliITS("ITS","ITS geometry v11"),
141 fMajorVersion(IsVersion()),
152 // Standard default constructor for the ITS version 11.
155 // fSPDgeom = new AliITSv11GeometrySPD(debugSPD);
156 fSDDgeom = new AliITSv11GeometrySDD(debugSDD);
157 fSDDgeom->SetDebug(debugSDD);
158 // fSupgeom = new AliITSv11GeometrySupport(debugSUP);
162 fIdName = new TString[fIdN];
163 fIdName[0] = fSPDgeom->GetSenstiveVolumeName1();
164 fIdName[1] = fSPDgeom->GetSenstiveVolumeName2();
165 fIdName[2] = fSDDgeom->GetSenstiveVolumeName3();
166 fIdName[3] = fSDDgeom->GetSenstiveVolumeName4();
167 fIdName[4] = fSSDgeom->GetSenstiveVolumeName5();
168 fIdName[5] = fSSDgeom->GetSenstiveVolumeName6();
169 fIdSens = new Int_t[fIdN];
170 for(i=0;i<fIdN;i++) fIdSens[i] = 0;
171 fEuclidOut = kFALSE; // Don't write Euclide file
173 fEuclidGeometry="$ALICE_ROOT/ITS/ITSgeometry_vPPRasymm2.euc";
174 strncpy(fEuclidGeomDet,"$ALICE_ROOT/ITS/ITSgeometry_vPPRasymm2.det",60);
175 strncpy(fRead,fEuclidGeomDet,60);
176 strncpy(fWrite,fEuclidGeomDet,60);
177 strncpy(fRead,"$ALICE_ROOT/ITS/ITSgeometry_vPPRasymmFMD.det",60);
179 debugITS = (debugSPD && debugSSD && debugSUP && debugSDD); //remove temp. warnings
181 //______________________________________________________________________
182 AliITSv11::~AliITSv11() {
185 //______________________________________________________________________
186 void AliITSv11::BuildGeometry(){
189 //______________________________________________________________________
190 void AliITSv11::CreateGeometry(){
192 // Create ROOT geometry
194 // These constant character strings are set by cvs during commit
195 // do not change them unless you know what you are doing!
196 const Char_t *cvsDate="$Date$";
197 const Char_t *cvsRevision="$Revision$";
199 TGeoManager *geoManager = gGeoManager;
200 TGeoVolume *vALIC = geoManager->GetTopVolume();
202 TGeoPcon *sITS = new TGeoPcon("ITS Top Volume",0.0,360.0,2);
204 // DefineSection(section number, Z, Rmin, Rmax).
205 const Double_t kcm = 1.0;
206 sITS->DefineSection(0,-300.0*kcm,0.01*kcm,50.0*kcm);
207 sITS->DefineSection(1,+300.0*kcm,0.01*kcm,50.0*kcm);
209 TGeoMedium *air = gGeoManager->GetMedium("ITS_AIR$");
210 TGeoVolume *vITS = new TGeoVolume("ITSV",sITS,air);
211 vITS->SetVisibility(kFALSE);
212 const Int_t length=100;
213 Char_t vstrng[length];
214 if(fIgm.WriteVersionString(vstrng,length,(AliITSVersion_t)IsVersion(),
215 fMinorVersion,cvsDate,cvsRevision))
216 vITS->SetTitle(vstrng);
217 //printf("Title set to %s\n",vstrng);
218 vALIC->AddNode(vITS,1,0);
220 // fSPDgeom->CenteralSPD(vITS);
222 fSDDgeom->Layer3(vITS);
223 fSDDgeom->Layer4(vITS);
225 // fSupgeom->SPDCone(vITS);
226 // fSupgeom->SPDThermalSheald(vITS);
227 // fSupgeom->SDDCone(vITS);
228 // fSupgeom->SSDCone(vITS);
229 // fSupgeom->ServicesCableSupport(vITS);
232 //______________________________________________________________________
233 void AliITSv11::CreateMaterials(){
234 // Create Standard ITS Materials
244 fSPDgeom->AliITSv11Geometry::CreateDefaultMaterials();
245 // Detector specific material definistions
246 fSPDgeom->CreateMaterials();
247 fSDDgeom->CreateMaterials();
248 fSSDgeom->CreateMaterials();
249 fSupgeom->CreateMaterials();
252 //______________________________________________________________________
253 void AliITSv11::InitAliITSgeom(){
255 // Fill fITSgeom with the 3 sub-detector geometries
258 if (gGeoManager) gGeoManager->Export("geometry.root");
260 const Int_t knlayers = 6;
261 const Int_t kndeep = 3;
262 const AliITSDetector kidet[knlayers]={kSPD,kSPD,kSDD,kSDD,kSSD,kSSD};
263 const TString knames[knlayers] = {
264 "AliITSv11:spd missing", // lay=1
265 "AliITSv11:spd missing", // lay=2
266 "/ALIC_1/ITSV_1/ITSsddLayer3_1/ITSsddLadd_%d/ITSsddSensor_%d/ITSsddWafer_%d", // lay=3
267 "/ALIC_1/ITSV_1/ITSsddLayer4_1/ITSsddLadd_%d/ITSsddSensor_%d/ITSsddWafer_%d", // lay=4
268 "AliITSv11:ssd missing", // lay=5
269 "AliITSv11:ssd missing" // lay=6
272 const Int_t kitsGeomTreeCopys[knlayers][kndeep]= {{10, 2, 4},// lay=1
278 Int_t nlad[knlayers],ndet[knlayers];
279 Int_t mod,lay,lad=0,det=0,i,j,k,cp0,cp1,cp2;
280 TString path,shapeName;
282 Double_t trans[3]={3*0.0},rot[10]={9*0.0,1.0};
285 Bool_t shapeDefined[3]={kFALSE,kFALSE,kFALSE};
287 AliDebug(1,"Reading Geometry transformation directly from Modler.");
289 for(i=0;i<knlayers;i++){
291 for(j=0;j<kndeep;j++) if(kitsGeomTreeCopys[i][j]!=0)
292 k *= TMath::Abs(kitsGeomTreeCopys[i][j]);
297 nlad[0]=20;nlad[1]=40;nlad[2]=14;nlad[3]=22;nlad[4]=34;nlad[5]=38;
298 ndet[0]= 4;ndet[1]= 4;ndet[2]= 6;ndet[3]= 8;ndet[4]=22;ndet[5]=25;
299 AliITSgeom* geom = new AliITSgeom(0,6,nlad,ndet,mod);
302 for(lay=1;lay<=knlayers;lay++){
304 for(cp0=0; cp0<kitsGeomTreeCopys[lay-1][0]; cp0++){
305 for(cp1=0; cp1<kitsGeomTreeCopys[lay-1][1]; cp1++){
306 for(cp2=1; cp2<=kitsGeomTreeCopys[lay-1][2]; cp2++){
308 path.Form(knames[lay-1].Data(),
319 case 3: case 4: case 5: case 6:{
324 //AliInfo(Form("path=%s lay=%d lad=%d det=%d",
325 // path.Data(),lay,lad,det));
326 gMC->GetTransformation(path.Data(),materix);
327 gMC->GetShape(path.Data(),shapeName,shapePar);
328 shapeParF.Set(shapePar.GetSize());
329 for(i=0;i<shapePar.GetSize();i++) shapeParF[i]=shapePar[i];
330 geom->CreateMatrix(mod,lay,lad,det,kidet[lay-1],trans,rot);
331 geom->SetTrans(mod,materix.GetTranslation());
332 geom->SetRotMatrix(mod,materix.GetRotationMatrix());
333 geom->GetGeomMatrix(mod)->SetPath(path.Data());
336 if(!shapeDefined[kSPD]){
337 geom->ReSetShape(kSPD,new AliITSgeomSPD425Short(
338 shapeParF.GetSize(),shapeParF.GetArray()));
339 shapeDefined[kSPD] = kTRUE;
342 if(!shapeDefined[kSDD]){
343 geom->ReSetShape(kSDD,new AliITSgeomSDD256(
344 shapeParF.GetSize(),shapeParF.GetArray()));
345 shapeDefined[kSDD] = kTRUE;
348 if(!shapeDefined[kSSD]){
349 geom->ReSetShape(kSSD,new AliITSgeomSSD75and275(
350 shapeParF.GetSize(),shapeParF.GetArray()));
351 shapeDefined[kSSD] = kTRUE;
362 // fSDDgeom->ExportSensorGeometry(GetITSgeom(), +3, 0); //SDD
365 //______________________________________________________________________
366 void AliITSv11::Init(){
368 // Initialise the ITS after it has been created.
371 //AliInfo(Form("Minor version %d",fMinorVersion));
373 UpdateInternalGeometry();
375 if(fGeomDetOut) GetITSgeom()->WriteNewFile(fWrite);
379 if(fRead[0]=='\0') strncpy(fRead,fEuclidGeomDet,60);
380 if(fWrite[0]=='\0') strncpy(fWrite,fEuclidGeomDet,60);
381 if(GetITSgeom()!=0) SetITSgeom(0x0);
382 AliITSgeom* geom = new AliITSgeom();
384 if(fGeomDetIn) GetITSgeom()->ReadNewFile(fRead);
385 else this->InitAliITSgeom();
386 if(fGeomDetOut) GetITSgeom()->WriteNewFile(fWrite);
392 //______________________________________________________________________
393 void AliITSv11::SetDefaults(){
395 // Set response and segmentation models for SPD, SDD and SSD
398 // if(!fDetTypeSim) fDetTypeSim = new AliITSDetTypeSim();
399 // fDetTypeSim->SetITSgeom(GetITSgeom());
401 Warning("SetDefaults","Error fDetTypeSim not defined");
405 fDetTypeSim->ResetCalibrationArray();
406 fDetTypeSim->ResetSegmentation();
407 fDetTypeSim->SetDefaults();
410 Warning("SetDefaults",
411 "Only the four basic detector types are initialised!");
422 //______________________________________________________________________
423 void AliITSv11::DrawModule() const{
427 // //______________________________________________________________________
428 // void AliITSv11::StepManager(){
430 // // Called for every step in the ITS, then calles the AliITShit class
431 // // creator with the information to be recoreded about that hit.
434 // TLorentzVector position, momentum;
435 // static TLorentzVector position0;
436 // static Int_t stat0=0;
438 // if(!(this->IsActive())){
440 // } // end if !Active volume.
442 // if(!(gMC->TrackCharge())) return;
444 // id=gMC->CurrentVolID(copy);
446 // Bool_t sensvol = kFALSE;
447 // for(Int_t kk=0;kk<6;kk++)if(id == fIdSens[kk])sensvol=kTRUE;
448 // if(sensvol && (gMC->IsTrackExiting())){
449 // copy = fTrackReferences->GetEntriesFast();
450 // TClonesArray &lTR = *fTrackReferences;
451 // // Fill TrackReference structure with this new TrackReference.
452 // new(lTR[copy]) AliTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
453 // } // if Outer ITS mother Volume
456 // Int_t copy1,copy2;
458 // TClonesArray &lhits = *fHits;
463 // if(gMC->IsTrackInside()) vol[3] += 1;
464 // if(gMC->IsTrackEntering()) vol[3] += 2;
465 // if(gMC->IsTrackExiting()) vol[3] += 4;
466 // if(gMC->IsTrackOut()) vol[3] += 8;
467 // if(gMC->IsTrackDisappeared()) vol[3] += 16;
468 // if(gMC->IsTrackStop()) vol[3] += 32;
469 // if(gMC->IsTrackAlive()) vol[3] += 64;
471 // // Fill hit structure.
472 // if(!(gMC->TrackCharge())) return;
474 // // Only entering charged tracks
475 // if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
477 // id = gMC->CurrentVolOffID(2,copy);
478 // //detector copy in the ladder = 1<->4 (ITS1 < I101 < I103 < I10A)
480 // gMC->CurrentVolOffID(3,copy1);
481 // //ladder copy in the module = 1<->2 (I10A < I12A)
482 // gMC->CurrentVolOffID(4,copy2);
483 // //module copy in the layer = 1<->10 (I12A < IT12)
484 // vol[2] = copy1+(copy2-1)*2;//# of ladders in one module = 2
485 // } else if(id == fIdSens[1]){
487 // id = gMC->CurrentVolOffID(2,copy);
488 // //detector copy in the ladder = 1<->4 (ITS2 < I1D1 < I1D3 < I20A)
490 // gMC->CurrentVolOffID(3,copy1);
491 // //ladder copy in the module = 1<->4 (I20A < I12A)
492 // gMC->CurrentVolOffID(4,copy2);
493 // //module copy in the layer = 1<->10 (I12A < IT12)
494 // vol[2] = copy1+(copy2-1)*4;//# of ladders in one module = 4
495 // } else if(id == fIdSens[2]){
497 // id = gMC->CurrentVolOffID(1,copy);
498 // //detector copy in the ladder = 1<->6 (ITS3 < I302 < I004)
500 // id = gMC->CurrentVolOffID(2,copy);
501 // //ladder copy in the layer = 1<->14 (I004 < IT34)
503 // } else if(id == fIdSens[3]){
505 // id = gMC->CurrentVolOffID(1,copy);
506 // //detector copy in the ladder = 1<->8 (ITS4 < I402 < I005)
508 // id = gMC->CurrentVolOffID(2,copy);
509 // //ladder copy in the layer = 1<->22 (I005 < IT34))
511 // }else if(id == fIdSens[4]){
513 // id = gMC->CurrentVolOffID(1,copy);
514 // //detector copy in the ladder = 1<->22 (ITS5 < I562 < I565)
516 // id = gMC->CurrentVolOffID(2,copy);
517 // //ladder copy in the layer = 1<->34 (I565 < IT56)
519 // }else if(id == fIdSens[5]){
521 // id = gMC->CurrentVolOffID(1,copy);
522 // //detector copy in the ladder = 1<->25 (ITS6 < I566 < I569)
524 // id = gMC->CurrentVolOffID(2,copy);
525 // //ladder copy in the layer = 1<->38 (I569 < IT56)
528 // return; // not an ITS volume?
529 // } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
531 // gMC->TrackPosition(position);
532 // gMC->TrackMomentum(momentum);
534 // if(gMC->IsTrackEntering()){
535 // position0 = position;
538 // } // end if IsEntering
539 // // Fill hit structure with this new hit.
541 // new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,
542 // gMC->Edep(),gMC->TrackTime(),position,
543 // position0,momentum);
545 // position0 = position;
552 //______________________________________________________________________
553 void AliITSv11::StepManager(){
555 // Called for every step in the ITS, then calles the AliITShit class
556 // creator with the information to be recoreded about that hit.
559 TLorentzVector position, momentum;
560 static TLorentzVector position0;
561 static Int_t stat0=0;
563 if(!(this->IsActive())){
565 } // end if !Active volume.
567 if(!(gMC->TrackCharge())) return;
569 id=gMC->CurrentVolID(copy);
571 Bool_t sensvol = kFALSE;
572 for(Int_t kk=0;kk<6;kk++)if(id == fIdSens[kk])sensvol=kTRUE;
573 if(sensvol && (gMC->IsTrackExiting())){
574 AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), AliTrackReference::kITS);
575 } // if Outer ITS mother Volume
580 TClonesArray &lhits = *fHits;
585 if(gMC->IsTrackInside()) vol[3] += 1;
586 if(gMC->IsTrackEntering()) vol[3] += 2;
587 if(gMC->IsTrackExiting()) vol[3] += 4;
588 if(gMC->IsTrackOut()) vol[3] += 8;
589 if(gMC->IsTrackDisappeared()) vol[3] += 16;
590 if(gMC->IsTrackStop()) vol[3] += 32;
591 if(gMC->IsTrackAlive()) vol[3] += 64;
593 // Fill hit structure.
594 if(!(gMC->TrackCharge())) return;
596 // Only entering charged tracks
597 if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
599 id = gMC->CurrentVolOffID(2,copy);
600 //detector copy in the ladder = 1<->4 (ITS1 < I101 < I103 < I10A)
602 gMC->CurrentVolOffID(3,copy1);
603 //ladder copy in the module = 1<->2 (I10A < I12A)
604 gMC->CurrentVolOffID(4,copy2);
605 //module copy in the layer = 1<->10 (I12A < IT12)
606 vol[2] = copy1+(copy2-1)*2;//# of ladders in one module = 2
608 } else if(id == fIdSens[1]){
610 id = gMC->CurrentVolOffID(2,copy);
611 //detector copy in the ladder = 1<->4 (ITS2 < I1D1 < I1D3 < I20A)
613 gMC->CurrentVolOffID(3,copy1);
614 //ladder copy in the module = 1<->4 (I20A < I12A)
615 gMC->CurrentVolOffID(4,copy2);
616 //module copy in the layer = 1<->10 (I12A < IT12)
617 vol[2] = copy1+(copy2-1)*4;//# of ladders in one module = 4
619 } else if(id == fIdSens[2]){
621 id = gMC->CurrentVolOffID(1,copy);
622 //detector copy in the ladder = 1<->6 (ITS3 < I302 < I004)
624 id = gMC->CurrentVolOffID(2,copy);
625 //ladder copy in the layer = 1<->14 (I004 < IT34)
628 } else if(id == fIdSens[3]){
630 id = gMC->CurrentVolOffID(1,copy);
631 //detector copy in the ladder = 1<->8 (ITS4 < I402 < I005)
633 id = gMC->CurrentVolOffID(2,copy);
634 //ladder copy in the layer = 1<->22 (I005 < IT34))
637 }else if(id == fIdSens[4]){
639 id = gMC->CurrentVolOffID(1,copy);
640 //detector copy in the ladder = 1<->22 (ITS5 < I562 < I565)
642 id = gMC->CurrentVolOffID(2,copy);
643 //ladder copy in the layer = 1<->34 (I565 < IT56)
646 }else if(id == fIdSens[5]){
648 id = gMC->CurrentVolOffID(1,copy);
649 //detector copy in the ladder = 1<->25 (ITS6 < I566 < I569)
651 id = gMC->CurrentVolOffID(2,copy);
652 //ladder copy in the layer = 1<->38 (I569 < IT56)
655 return; // not an ITS volume?
656 } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
658 gMC->TrackPosition(position);
659 gMC->TrackMomentum(momentum);
661 if(gMC->IsTrackEntering()){
662 position0 = position;
665 } // end if IsEntering
666 // Fill hit structure with this new hit.
668 new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,
669 gMC->Edep(),gMC->TrackTime(),position,
672 position0 = position;