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