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 #include <TClonesArray.h>
19 #include <TGeoGlobalMagField.h>
20 #include <TGeoManager.h>
21 #include <TGeoMatrix.h>
22 #include <TLorentzVector.h>
23 #include <TVirtualMC.h>
27 #include "AliTrackReference.h"
29 #include "AliITShit.h"
31 #include "AliITSvSPD02.h"
32 #include "AliITSgeom.h"
33 #include "AliITSgeomSPD.h"
34 #include "AliITSDetTypeSim.h"
35 #include "AliITSCalibrationSPD.h"
36 #include "AliITSsegmentationSPD.h"
37 #include "AliITSsimulationSPD.h"
41 ///////////////////////////////////////////////////////////////////////
46 // geometry of summer 2002
48 ///////////////////////////////////////////////////////////////////////
49 ClassImp(AliITSvSPD02)
51 //______________________________________________________________________
52 AliITSvSPD02::AliITSvSPD02():
54 fMajorVersion((Int_t)kvSPD02),
63 ////////////////////////////////////////////////////////////////////////
64 // Standard default constructor for the ITS SPD test beam 2002 version 1.
70 // A default created class.
71 ////////////////////////////////////////////////////////////////////////
73 //______________________________________________________________________
74 AliITSvSPD02::AliITSvSPD02(const char *title,Int_t gn) : AliITS("ITS", title),
84 ////////////////////////////////////////////////////////////////////////
85 // Standard constructor for the ITS SPD testbeam 2002 version 1.
87 // const char *title title for this ITS geometry.
88 // Int_t gn Geometry version number (year) default 2002.
92 // A standard created class.
93 ////////////////////////////////////////////////////////////////////////
98 fIdName = new TString[fIdN];
101 fIdSens = new Int_t[fIdN];
102 for(i=0;i<fIdN;i++) fIdSens[i] = 0;
109 //______________________________________________________________________
110 AliITSvSPD02::~AliITSvSPD02() {
111 ////////////////////////////////////////////////////////////////////////
112 // Standard destructor for the ITS SPD test beam 2002 version 1.
119 ////////////////////////////////////////////////////////////////////////
121 //______________________________________________________________________
122 void AliITSvSPD02::CreateGeometry(){
123 ////////////////////////////////////////////////////////////////////////
124 // This routine defines and Creates the geometry for version 1 of the ITS.
125 // ALIC ALICE Mother Volume
126 // |- ITSV ITS Mother Volume
127 // |- IDET Detector under Test
128 // | |- ITS0 SPD Si Chip
129 // | | |- ITST SPD Sensitivve Volume
130 // | |- IPC0 *5 Readout chip
131 // |- ITEL *4 SPD Telescope
132 // |- IMB0 SPD Si Chip
133 // | |- IMBS SPD Sensitive volume
134 // |- ICMB Chip MiniBus.
141 ////////////////////////////////////////////////////////////////////////
143 switch (fGeomNumber){
145 CreateGeometry2002();
148 CreateGeometry2002();
152 //______________________________________________________________________
153 void AliITSvSPD02::CreateGeometry2002(){
154 ////////////////////////////////////////////////////////////////////////
155 // This routine defines and Creates the geometry for version 1 of the ITS.
156 // ALIC ALICE Mother Volume
157 // |- ITSV ITS Mother Volume
158 // |- IDET Detector under Test
159 // | |- ITS0 SPD Si Chip
160 // | | |- ITST SPD Sensitivve Volume
161 // | |- IPC0 *5 Readout chip
162 // |- ITEL *4 SPD Telescope
163 // |- IMB0 SPD Si Chip
164 // | |- IMBS SPD Sensitive volume
165 // |- ICMB Chip MiniBus.
167 // ITEL ITEL IDET ITEL ITEL
168 // Z-> -38 -36 02 36.5 38.5
177 ////////////////////////////////////////////////////////////////////////
179 // Define media off-set
180 Int_t *idtmed = fIdtmed->GetArray()+1; // array of media indexes
181 Int_t idrotm[4]; // Array of rotation matrix indexes
182 Float_t ddettest=200.0E-4,ddettelescope=300.0E-4;
183 Float_t dchipMiniBus=750.0E-4,dchiptest=300.0E-4;
184 Float_t yposition= 0.0;
185 // These constant character strings are set by cvs during commit
186 // do not change them unless you know what you are doing!
187 const Char_t *cvsDate="$Date$";
188 const Char_t *cvsRevision="$Revision$";
191 // Define Rotation-reflextion Matrixes needed
192 // 0 is the unit matrix
193 AliMatrix(idrotm[0], 90.0,0.0, 0.0,0.0, 90.0,270.0);
198 gMC->Gsvolu("ITSV","BOX",idtmed[0],data,3);
199 gMC->Gspos("ITSV",1,"ALIC",0.0,0.0,0.0,0,"ONLY");
201 TGeoVolumeAssembly *itsV = gGeoManager->MakeVolumeAssembly("ITSV");
202 const Int_t length=100;
203 Char_t vstrng[length];
204 if(fIgm.WriteVersionString(vstrng,length,(AliITSVersion_t)IsVersion(),
205 fMinorVersion,cvsDate,cvsRevision))
206 itsV->SetTitle(vstrng);
207 else Error("CreateGeometry","Error writing/setting version string");
208 TGeoVolume *alic = gGeoManager->GetVolume("ALIC");
210 Error("CreateGeometry","alic=0");
213 // See idrotm[199] for angle definitions.
214 alic->AddNode(itsV,1,0);
216 //cout << "idtmed[0]=" << idtmed[0]<<endl;
217 //cout << "idtmed[1]=" << idtmed[1]<<endl;
218 Float_t detMiniBusX,detMiniBusY,detMiniBusZ;
219 // SPD part of telescope (MiniBuS)
220 data[0] = detMiniBusX = 0.705;
221 data[1] = detMiniBusY = 0.5*ddettelescope;
222 data[2] = detMiniBusZ = 3.536;
223 gMC->Gsvolu("IMB0", "BOX ", idtmed[1], data, 3); // contains detector
225 data[1] = 0.5*ddettelescope;
227 gMC->Gsvolu("IMBS","BOX ",idtmed[1],data,3); // sensitive detecor volulme
228 gMC->Gspos("IMBS",1,"IMB0",0.0,0.0,0.0,0,"ONLY"); // place IMBS inside
229 // IMB0 with no translation and unit rotation matrix.
230 Float_t chipMiniBusX,chipMiniBusY,chipMiniBusZ;
231 data[0] = chipMiniBusX = 0.793;
232 data[1] = chipMiniBusY = 0.5*dchipMiniBus;
233 data[2] = chipMiniBusZ = 0.68;
234 gMC->Gsvolu("ICMB","BOX ",idtmed[1],data, 3); // chip Minibus
235 data[0] = TMath::Max(detMiniBusX,chipMiniBusX);
236 data[1] = detMiniBusY+chipMiniBusY;
237 data[2] = TMath::Max(detMiniBusZ,chipMiniBusZ);
238 gMC->Gsvolu("ITEL","BOX ",idtmed[0],data,3);
239 gMC->Gspos("IMB0",1,"ITEL",0.0,data[1]-detMiniBusY,0.0,0,"ONLY");
240 gMC->Gspos("ICMB",1,"ITEL",0.0,-data[1]+chipMiniBusY,0.0,0,"ONLY");
243 Float_t spdX,spdY,spdZ,spdchipX,spdchipY,spdchipZ;
244 data[0] = spdX = 0.705;
245 data[1] = spdY = 0.5*ddettest;
246 data[2] = spdZ = 3.536;
247 gMC->Gsvolu("ITS0", "BOX ", idtmed[1], data, 3); // contains detector
249 data[1] = 0.5*ddettest;
251 gMC->Gsvolu("ITST","BOX ",idtmed[1],data,3);// sensitive detecor volume
252 gMC->Gspos("ITST",1,"ITS0",0.0,0.0,0.0,0,"ONLY"); // place ITST inside
253 // ITS0 with no translation and unit rotation matrix.
254 data[0] = spdchipX = 0.793;
255 data[1] = spdchipY = 0.5*dchiptest;
256 data[2] = spdchipZ = 0.68;
257 gMC->Gsvolu("IPC0", "BOX ", idtmed[1],data,3); // chip under test
258 data[0] = TMath::Max(spdchipX,spdX);
259 data[1] = spdY+spdchipY;
260 data[2] = TMath::Max(spdchipZ,spdZ);
261 gMC->Gsvolu("IDET","BOX ",idtmed[0],data,3);
262 gMC->Gspos("ITS0",1,"IDET",0.0,data[1]-spdY,0.0,0,"ONLY");
263 for(Int_t i=-2;i<3;i++) gMC->Gspos("IPC0",i+3,"IDET",0.0,-data[1]+spdchipY,
264 i*2.*spdchipZ+i*0.25*(spdZ-5.*spdchipZ),0,"ONLY");
266 // Positions detectors, Beam Axis Z, X to the right, Y up to the sky.
267 Float_t p00X,p00Y,p00Z,p01X,p01Y,p01Z,p10X,p10Y,p10Z,p11X,p11Y,p11Z;
271 gMC->Gspos("ITEL",1,"ITSV",p00X,p00Y,p00Z,idrotm[0],"ONLY");
275 gMC->Gspos("ITEL",2,"ITSV",p01X,p01Y,p01Z,idrotm[0],"ONLY");
276 Float_t pdetX,pdetY,pdetZ;
278 pdetY = 0.0+yposition;
280 gMC->Gspos("IDET",1,"ITSV",pdetX,pdetY,pdetZ,idrotm[0],"ONLY");
284 gMC->Gspos("ITEL",3,"ITSV",p10X,p10Y,p10Z,idrotm[0],"ONLY");
288 gMC->Gspos("ITEL",4,"ITSV",p11X,p11Y,p11Z,idrotm[0],"ONLY");
290 //______________________________________________________________________
291 void AliITSvSPD02::CreateMaterials(){
292 ////////////////////////////////////////////////////////////////////////
294 // Create ITS SPD test beam materials
295 // This function defines the default materials used in the Geant
296 // Monte Carlo simulations for the geometries AliITSv1, AliITSv3,
298 // In general it is automatically replaced by
299 // the CreateMaterials routine defined in AliITSv?. Should the function
300 // CreateMaterials not exist for the geometry version you are using this
301 // one is used. See the definition found in AliITSv5 or the other routine
302 // for a complete definition.
310 /////////////////////////////////////////////////////////////////////////
312 switch (fGeomNumber){
314 CreateMaterials2002();
317 CreateMaterials2002();
321 //______________________________________________________________________
322 void AliITSvSPD02::CreateMaterials2002(){
323 ////////////////////////////////////////////////////////////////////////
325 // Create ITS SPD test beam materials
326 // This function defines the default materials used in the Geant
327 // Monte Carlo simulations for the geometries AliITSv1, AliITSv3,
329 // In general it is automatically replaced by
330 // the CreateMaterials routine defined in AliITSv?. Should the function
331 // CreateMaterials not exist for the geometry version you are using this
332 // one is used. See the definition found in AliITSv5 or the other routine
333 // for a complete definition.
341 /////////////////////////////////////////////////////////////////////////
342 Float_t tmaxfdSi = 0.1; // Degree
343 Float_t stemaxSi = 0.0075; // cm
344 Float_t deemaxSi = 0.1; // Fraction of particle's energy 0<deemax<=1
345 Float_t epsilSi = 1.0E-4;//
346 Float_t stminSi = 0.0; // cm "Default value used"
348 Float_t tmaxfdAir = 0.1; // Degree
349 Float_t stemaxAir = .10000E+01; // cm
350 Float_t deemaxAir = 0.1; // Fraction of particle's energy 0<deemax<=1
351 Float_t epsilAir = 1.0E-4;//
352 Float_t stminAir = 0.0; // cm "Default value used"
353 Int_t ifield = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Integ();
354 Float_t fieldm = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Max();
356 AliMaterial(1,"AIR$",0.14610E+02,0.73000E+01,0.12050E-02,
357 0.30423E+05,0.99900E+03);
358 AliMedium(1,"AIR$",1,0,ifield,fieldm,tmaxfdAir,stemaxAir,deemaxAir,
361 AliMaterial(2,"SI$",0.28086E+02,0.14000E+02,0.23300E+01,
362 0.93600E+01,0.99900E+03);
363 AliMedium(2,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
366 //______________________________________________________________________
367 void AliITSvSPD02::Init(){
368 // Initialise the ITS after it has been created.
376 AliDebug(1,Form("Init: Major version %d Minor version %d",fMajorVersion,
379 UpdateInternalGeometry();
383 fIDMother = gMC->VolId("ITSV"); // ITS Mother Volume ID.
387 //______________________________________________________________________
388 void AliITSvSPD02::SetDefaults(){
389 // sets the default segmentation, response, digit and raw cluster classes
396 const Float_t kconv = 1.0e+04; // convert cm to microns
398 Info("SetDefaults","Setting up only SPD detector");
400 if(!fDetTypeSim) fDetTypeSim = new AliITSDetTypeSim();
401 fDetTypeSim->SetITSgeom(GetITSgeom());
404 Float_t bx[256],bz[280];
405 fDetTypeSim->ResetCalibrationArray();
406 fDetTypeSim->ResetSegmentation();
409 // Get shape info. Do it this way for now.
410 s0 = (AliITSgeomSPD*) GetITSgeom()->GetShape(kSPD);
411 AliITSCalibration *resp0=new AliITSCalibrationSPD();
412 resp0->SetTemperature();
413 resp0->SetDistanceOverVoltage();
414 SetCalibrationModel(0,resp0);
416 AliITSsegmentationSPD *seg0=new AliITSsegmentationSPD();
417 seg0->SetDetSize(s0->GetDx()*2.*kconv, // base this on AliITSgeomSPD
418 s0->GetDz()*2.*kconv, // for now.
419 s0->GetDy()*2.*kconv); // x,z,y full width in microns.
420 seg0->SetNPads(256,160);// Number of Bins in x and z
421 for(i=000;i<256;i++) bx[i] = 50.0; // in x all are 50 microns.
422 for(i=000;i<160;i++) bz[i] = 425.0; // most are 425 microns except below
423 for(i=160;i<280;i++) bz[i] = 0.0; // Outside of detector.
424 bz[ 31] = bz[ 32] = 625.0; // first chip boundry
425 bz[ 63] = bz[ 64] = 625.0; // first chip boundry
426 bz[ 95] = bz[ 96] = 625.0; // first chip boundry
427 bz[127] = bz[128] = 625.0; // first chip boundry
428 bz[160] = 425.0; // Set so that there is no zero pixel size for fNz.
429 seg0->SetBinSize(bx,bz); // Based on AliITSgeomSPD for now.
430 SetSegmentationModel(kSPD,seg0);
431 // set digit and raw cluster classes to be used
432 const char *kData0=(fDetTypeSim->GetCalibrationModel(0))->DataType();
433 if (strstr(kData0,"real")) fDetTypeSim->SetDigitClassName(kSPD,"AliITSdigit");
434 else fDetTypeSim->SetDigitClassName(kSPD,"AliITSdigitSPD");
435 // SetSimulationModel(kSPD,new AliITSsimulationSPDdubna(seg0,resp0));
436 // iDetType->ReconstructionModel(new AliITSClusterFinderSPD());
439 // SetResponseModel(kSDD,new AliITSCalibrationSDD());
440 // SetSegmentationModel(kSDD,new AliITSsegmentationSDD());
441 // DetType(kSDD)->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD");
443 // SetResponseModel(kSSD,new AliITSCalibrationSSD());
444 // SetSegmentationModel(kSSD,new AliITSsegmentationSSD());
445 // DetType(kSSD)->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD");
448 Warning("SetDefaults",
449 "Only the four basic detector types are initialised!");
453 //______________________________________________________________________
454 void AliITSvSPD02::SetDefaultSimulation(){
455 // sets the default simulation.
464 Warning("SetDefaultSimulation","ITS geometry is null!");
468 if(!fDetTypeSim) fDetTypeSim = new AliITSDetTypeSim();
469 AliITSsimulation *sim;
470 //AliITSsegmentation *seg;
471 //AliITSCalibration *res;
473 sim = fDetTypeSim->GetSimulationModel(kSPD);
475 //seg = (AliITSsegmentation*)fDetTypeSim->GetSegmentationModel(kSPD);
476 //res = (AliITSCalibration*)fDetTypeSim->GetResponseModel(GetITSgeom()->GetStartSPD());
477 sim = new AliITSsimulationSPD(fDetTypeSim);
478 SetSimulationModel(kSPD,sim);
479 }else{ // simulation exists, make sure it is set up properly.
480 sim->SetCalibrationModel(GetITSgeom()->GetStartSPD(),(AliITSCalibration*)fDetTypeSim->GetCalibrationModel(GetITSgeom()->GetStartSPD()));
481 sim->SetSegmentationModel(kSPD,(AliITSsegmentation*)fDetTypeSim->GetSegmentationModel(kSPD));
487 // sim = fDetTypeSim->GetSimulationModel(kSDD);
489 // seg = (AliITSsegmentation*)fDetTypeSim->GetSegmentationModel(kSDD);
490 // res = (AliITSCalibration*)fDetTypeSim->GetResponseModel(GetITSgeom()->GetStartSDD());
491 // sim = new AliITSsimulationSDD(seg,res);
492 // SetSimulationModel(kSDD,sim);
493 // }else{ // simulation exists, make sure it is set up properly.
494 // sim->SetResponseModel((AliITSCalibration*)fDetTypeSim->GetResponseModel(GetITSgeom()->GetStartSDD()));
495 // sim->SetSegmentationModel((AliITSsegmentation*)fDetTypeSim->GetSegmentationModel(kSDD));
498 // } // end if iDetType
500 // sim = fDetTypeSim->GetSimulationModel(kSSD);
502 // seg = (AliITSsegmentation*)fDetTypeSim->GetSegmentationModel(kSSD);
503 // res = (AliITSCalibration*)fDetTypeSim->GetResponseModel(GetITSgeom()->GetStartSSD());
504 // sim = new AliITSsimulationSSD(seg,res);
505 // SetSimulationModel(kSSD,sim);
506 // }else{ // simulation exists, make sure it is set up properly.
507 // sim->SetResponseModel((AliITSCalibration*)fDetTypeSim->GetResponseModel(GetITSgeom()->GetStartSSD()));
508 // sim->SetSegmentationModel((AliITSsegmentation*)fDetTypeSim->GetSegmentationModel(kSSD));
514 //______________________________________________________________________
515 void AliITSvSPD02::DrawModule() const {
516 ////////////////////////////////////////////////////////////////////////
517 // Draw a shaded view of the ITS SPD test beam version 1.
524 ////////////////////////////////////////////////////////////////////////
525 // Set everything unseen
526 gMC->Gsatt("*", "seen", -1);
527 // Set ALIC mother visible
528 gMC->Gsatt("ALIC","SEEN",0);
529 // Set ALIC ITS visible
530 gMC->Gsatt("ITSV","SEEN",0);
531 // Set ALIC Telescopes visible
532 gMC->Gsatt("ITEL","SEEN",0);
533 // Set ALIC detetcor visible
534 gMC->Gsatt("IDET","SEEN",0);
535 // Set Detector chip mother visible and drawn
536 gMC->Gsatt("IPC0","SEEN",1);
537 // Set Detector mother visible and drawn
538 gMC->Gsatt("ITS0","SEEN",1);
539 // Set minibus chip mother visible and drawn
540 gMC->Gsatt("ICMB","SEEN",1);
541 // Set minibus mother visible and drawn
542 gMC->Gsatt("IMB0","SEEN",1);
544 //______________________________________________________________________
545 void AliITSvSPD02::StepManager(){
546 ////////////////////////////////////////////////////////////////////////
547 // Called for every step in the ITS SPD test beam, then calles the
548 // AliITShit class creator with the information to be recoreded about
550 // The value of the macro ALIITSPRINTGEOM if set to 1 will allow the
551 // printing of information to a file which can be used to create a .det
552 // file read in by the routine CreateGeometry(). If set to 0 or any other
553 // value except 1, the default behavior, then no such file is created nor
554 // it the extra variables and the like used in the printing allocated.
561 ////////////////////////////////////////////////////////////////////////
563 if(!(this->IsActive())){
565 } // end if !Active volume.
566 if(!(gMC->TrackCharge())) return;
568 Int_t cpy0=0,cpy1=0,id,mod,ncpys,status;
569 TLorentzVector position, momentum;
570 static AliITShit hit;// Saves on calls to construtors
571 //TClonesArray &lhits = *(GetDetTypeSim()->GetHits());
572 TClonesArray &lhits = *(Hits());
577 if(gMC->IsTrackInside()) status += 1;
578 if(gMC->IsTrackEntering()) status += 2;
579 if(gMC->IsTrackExiting()) status += 4;
580 if(gMC->IsTrackOut()) status += 8;
581 if(gMC->IsTrackDisappeared()) status += 16;
582 if(gMC->IsTrackStop()) status += 32;
583 if(gMC->IsTrackAlive()) status += 64;
585 // Fill hit structure.
586 id = gMC->CurrentVolID(cpy0);
587 if(id==fIdSens[0]){ // Volume name "IMBS". Det=1, ladder=1
589 } else if(id == fIdSens[1]){ // Volume name "ITST"
591 } else return; // end if
592 id = gMC->CurrentVolOffID(2,cpy1);
593 fIgm.DecodeDetector(mod,ncpys,cpy0,cpy1,0);
595 // Fill hit structure.
598 hit.SetTrack(gAlice->GetMCApp()->GetCurrentTrackNumber());
599 gMC->TrackPosition(position);
600 gMC->TrackMomentum(momentum);
601 hit.SetPosition(position);
602 hit.SetTime(gMC->TrackTime());
603 hit.SetMomentum(momentum);
604 hit.SetStatus(status);
605 hit.SetEdep(gMC->Edep());
606 hit.SetShunt(GetIshunt());
607 if(gMC->IsTrackEntering()){
608 hit.SetStartPosition(position);
609 hit.SetStartTime(gMC->TrackTime());
610 hit.SetStartStatus(status);
611 return; // don't save entering hit.
612 } // end if IsEntering
613 // Fill hit structure with this new hit.
614 //Info("StepManager","Calling Copy Constructor");
615 new(lhits[fNhits++]) AliITShit(hit); // Use Copy Construtor.
616 // Save old position... for next hit.
617 hit.SetStartPosition(position);
618 hit.SetStartTime(gMC->TrackTime());
619 hit.SetStartStatus(status);