]>
Commit | Line | Data |
---|---|---|
1d9af2d5 | 1 | // ************************************************************************** |
2 | // * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | // * * | |
4 | // * Author: The ALICE Off-line Project. * | |
5 | // * Contributors are mentioned in the code where appropriate. * | |
6 | // * * | |
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 | // ************************************************************************** | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
18 | #include <TArrayD.h> //new constructor | |
19 | #include <TFile.h> | |
0ac80088 | 20 | #include <TGeoManager.h> |
1d9af2d5 | 21 | #include <TGeoVolume.h> //CreateGeometry() |
0ac80088 | 22 | #include <TGeoMatrix.h> |
1d9af2d5 | 23 | #include <TVirtualMC.h> //->gMC in StepManager |
24 | #include <TPDGCode.h> //StepHistory | |
25 | #include <TClonesArray.h> | |
2accaff0 | 26 | #include <TGeoGlobalMagField.h> |
1d9af2d5 | 27 | #include "AliRun.h" //CreateMaterials() |
28 | #include "AliMC.h" //CreateMaterials() | |
29 | #include "AliMagF.h" //CreateMaterials() | |
1d9af2d5 | 30 | #include "AliITSupgrade.h" //class header |
31 | #include "AliITShit.h" // StepManager() | |
32 | #include "AliITSDigitUpgrade.h" | |
33 | #include "AliTrackReference.h" // StepManager() | |
a19b4e8c | 34 | #include "AliITSsegmentationUpgrade.h" |
35 | ||
1d9af2d5 | 36 | ClassImp(AliITSupgrade) |
37 | //__________________________________________________________________________________________________ | |
38 | AliITSupgrade::AliITSupgrade(): | |
39 | AliITS(), | |
40 | fWidths(0), | |
41 | fRadii(0), | |
0ac80088 | 42 | fNSectors(20), |
1d9af2d5 | 43 | fRadiiCu(0), |
44 | fWidthsCu(0), | |
45 | fCopper(0), | |
46 | fBeampipe(0), | |
47 | fRadiusBP(0), | |
48 | fWidthBP(0), | |
49 | fHalfLengthBP(0), | |
50 | fNlayers(0), | |
51 | fHalfLength(0), | |
52 | fSdigits(0), | |
a19b4e8c | 53 | fDigitArray(0), |
1d9af2d5 | 54 | fSegmentation(0x0) |
55 | { | |
56 | // | |
57 | // default ctor | |
387f1a9e | 58 | // |
59 | } | |
60 | ||
61 | //__________________________________________________________________________________________________ | |
62 | AliITSupgrade::AliITSupgrade(const char *name,const char *title, Bool_t isBeamPipe): | |
63 | AliITS(name,title), | |
64 | fWidths(0), | |
65 | fRadii(0), | |
0ac80088 | 66 | fNSectors(20), |
387f1a9e | 67 | fRadiiCu(0), |
68 | fWidthsCu(0), | |
69 | fCopper(0), | |
70 | fBeampipe(isBeamPipe), | |
71 | fRadiusBP(0), | |
72 | fWidthBP(0), | |
73 | fHalfLengthBP(0), | |
74 | fNlayers(0), | |
75 | fHalfLength(0), | |
76 | fSdigits(0), | |
a19b4e8c | 77 | fDigitArray(0), |
387f1a9e | 78 | fSegmentation(0x0) |
79 | { | |
a19b4e8c | 80 | // Default values are used in order to simulate the standard ITS material budget (see The ALICE Collaboration et al 2008 JINST 3 S08002 - Figure 3.2). |
81 | // The cell segmentation is chosen to achieve the tracking resolution as described in Table 3.2 of The ALICE Collaboration et al 2008 JINST 3 S08002, | |
82 | // apart from SPD0 where the 9 um value is considered : resolution*sqrt(12) | |
83 | // Cilinder lenghts are chosen according to Table 1 of the Alignment paper : http://iopscience.iop.org/1748-0221/5/03/P03003 | |
84 | ||
387f1a9e | 85 | fNlayers = 6; |
86 | fWidths.Set(fNlayers); | |
87 | fRadii.Set(fNlayers); | |
88 | fRadiiCu.Set(fNlayers); | |
89 | fWidthsCu.Set(fNlayers); | |
90 | fCopper.Set(fNlayers); | |
91 | fHalfLength.Set(fNlayers); | |
92 | ||
387f1a9e | 93 | |
a19b4e8c | 94 | Double_t xsz[6]={31.18*1e-04,41.6*1e-04,121.2e-04,121.4*1e-04,69.3*1e-04,69.3*1e-04}; |
387f1a9e | 95 | Double_t zsz[6]={416*1e-04,416*1e-04,97*1e-04,97*1e-04,2875*1e-04,2875*1e-04}; |
a19b4e8c | 96 | Double_t halfL[6]={14.1,14.1,22.2,29.7,43.1,48.9}; |
387f1a9e | 97 | Double_t r[6]={4.,7.6,14.9,23.8,39.1,43.6}; |
98 | Double_t thick[6]={75.*1e-04,150.*1e-04,150.*1e-04,150.*1e-04,150.*1e-04,150.*1e-04}; | |
99 | ||
100 | Int_t nlayers =6; | |
101 | TArrayD xsizeSi(nlayers); | |
102 | TArrayD zsizeSi(nlayers); | |
103 | ||
104 | // adding beam pipe upgrade | |
105 | if(isBeamPipe){ | |
106 | fRadiusBP = 2.9; | |
107 | fWidthBP = 0.08; | |
a19b4e8c | 108 | fHalfLengthBP = halfL[0]; |
387f1a9e | 109 | } |
110 | ||
111 | // setting the geonetry parameters and the segmentation | |
112 | Int_t npixHalf[6], npixR[6]; | |
a19b4e8c | 113 | Double_t halfLmod[6], xszInt[6]; |
387f1a9e | 114 | Int_t c[6]={1,1,1,1,1,1}; |
115 | ||
116 | for(Int_t i=0; i<nlayers; i++){ | |
117 | // recalc length | |
a19b4e8c | 118 | npixHalf[i]=(Int_t)(halfL[i]/zsz[i]); |
119 | halfLmod[i]=npixHalf[i]*zsz[i]; | |
387f1a9e | 120 | // recalc segmentation |
121 | npixR[i] = (Int_t)(2*TMath::Pi()*r[i]/xsz[i]); | |
122 | xszInt[i]= 2*TMath::Pi()*r[i]/npixR[i]; | |
123 | xsizeSi.AddAt(xszInt[i],i); | |
124 | zsizeSi.AddAt(zsz[i],i); | |
125 | ||
a19b4e8c | 126 | fHalfLength.AddAt(halfLmod[i],i); |
387f1a9e | 127 | |
128 | fRadii.AddAt(r[i],i); | |
129 | fWidths.AddAt(thick[i],i); | |
130 | ||
131 | fRadiiCu.AddAt(r[i]+thick[i],i); | |
132 | fWidthsCu.AddAt(0.015,i);//micron | |
133 | fCopper.AddAt(c[i],i); | |
134 | } | |
135 | ||
136 | SetFullSegmentation(xsizeSi,zsizeSi); | |
1d9af2d5 | 137 | } |
138 | //__________________________________________________________________________________________________ | |
139 | AliITSupgrade::AliITSupgrade(const char *name,const char *title, TArrayD widths, TArrayD radii,TArrayD halfLengths, TArrayD radiiCu, TArrayD widthsCu, TArrayS copper,Bool_t bp,Double_t radiusBP, Double_t widthBP, Double_t halfLengthBP): | |
140 | AliITS(name,title), | |
141 | fWidths(0), | |
142 | fRadii(0), | |
0ac80088 | 143 | fNSectors(20), |
1d9af2d5 | 144 | fRadiiCu(radiiCu), |
145 | fWidthsCu(widthsCu), | |
146 | fCopper(copper), | |
147 | fBeampipe(bp), | |
387f1a9e | 148 | fRadiusBP(0), |
149 | fWidthBP(0), | |
150 | fHalfLengthBP(0), | |
1d9af2d5 | 151 | fNlayers(widths.GetSize()), |
152 | fHalfLength(halfLengths), | |
153 | fSdigits(0), | |
a19b4e8c | 154 | fDigitArray(0), |
1d9af2d5 | 155 | fSegmentation(0x0) |
156 | { | |
1d9af2d5 | 157 | // |
a19b4e8c | 158 | // constructor to set all the geometrical/segmentation specs from outside |
159 | // | |
1d9af2d5 | 160 | for(Int_t i=0;i<fNlayers;i++){ |
161 | fWidths.Set(i+1); | |
162 | fWidths.AddAt(widths.At(i),i); | |
163 | fRadii.Set(i+1); | |
164 | fRadii.AddAt(radii.At(i),i); | |
165 | AliDebug(1,"Creating Volume"); | |
166 | } | |
387f1a9e | 167 | |
168 | if(bp){ | |
169 | fRadiusBP=radiusBP; | |
170 | fWidthBP=widthBP; | |
171 | fHalfLengthBP=halfLengthBP; | |
172 | } | |
1d9af2d5 | 173 | Init(); |
174 | ||
175 | } | |
176 | ||
177 | AliITSupgrade::~AliITSupgrade(){ | |
178 | ||
179 | if(fSdigits) {fSdigits->Delete(); delete fSdigits;} | |
a19b4e8c | 180 | if(fDigitArray) {fDigitArray->Delete(); delete fDigitArray;} |
1d9af2d5 | 181 | } |
182 | ||
183 | ||
184 | ||
185 | //_________________________________________________________________________________________________ | |
186 | void AliITSupgrade::AddAlignableVolumes()const | |
187 | { | |
188 | //not needed | |
189 | return; | |
190 | } | |
191 | ||
192 | //__________________________________________________________________________________________________ | |
193 | ||
194 | void AliITSupgrade::CreateMaterials() | |
195 | { | |
196 | // | |
197 | // Definition of ITS materials | |
198 | // | |
199 | ||
200 | AliInfo("Start ITS materials"); | |
201 | //data from PDG booklet 2002 density [gr/cm^3] rad len [cm] abs len [cm] | |
202 | Float_t aAir[4]={12,14,16,36} , zAir[4]={6,7,8,18} , wAir[4]={0.000124,0.755267,0.231781,0.012827} , dAir=0.00120479; Int_t nAir=4;//mixture | |
203 | Float_t aBe = 9.012 , zBe = 4 , dBe = 1.848 , radBe = 65.19/dBe , absBe = 77.8/dBe ; // UPGRADE -> beryllium beampipe | |
204 | Float_t aSi = 28.085 , zSi = 14 , dSi = 2.329 , radSi = 21.82/dSi , absSi = 108.4/dSi ; // UPGRADE -> Si tube | |
205 | Float_t aCu = 63.54, zCu = 29 , dCu= 8.96 , radCu = 12.86/dCu, absCu= 137.3/dCu;//Upgrade -> Copper Tube | |
206 | ||
207 | Int_t matId=0; //tmp material id number | |
208 | Int_t unsens = 0, sens=1; //sensitive or unsensitive medium | |
209 | Int_t itgfld = 3; //type of field intergration 0 no field -1 user in guswim 1 Runge Kutta 2 helix 3 const field along z | |
210 | Float_t maxfld = 5.; //max field value | |
211 | Float_t tmaxfd = -10.0; //max deflection angle due to magnetic field in one step | |
212 | Float_t deemax = - 0.2; //max fractional energy loss in one step | |
213 | Float_t stemax = - 0.1; //max step allowed [cm] | |
a346a81b | 214 | Float_t epsil = 0.001; //abs tracking precision [cm] |
1d9af2d5 | 215 | Float_t stmin = - 0.001; //min step size [cm] in continius process transport, negative value: choose it automatically |
216 | Float_t tmaxfdSi = 0.1; // .10000E+01; // Degree | |
217 | Float_t stemaxSi = 0.0075; // .10000E+01; // cm | |
218 | Float_t deemaxSi = 0.1; // 0.30000E-02; // Fraction of particle's energy 0<deemax<=1 | |
219 | Float_t epsilSi = 1.0E-4;// .10000E+01; | |
220 | Float_t stminSi = 0.0; // cm "Default value used" | |
221 | ||
222 | Float_t epsilBe = .001; // Tracking precision, | |
223 | Float_t stemaxBe = -0.01; // Maximum displacement for multiple scat | |
224 | Float_t tmaxfdBe = -20.; // Maximum angle due to field deflection | |
225 | Float_t deemaxBe = -.3; // Maximum fractional energy loss, DLS | |
226 | Float_t stminBe = -.8; | |
2accaff0 | 227 | Int_t isxfld = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Integ();//from CreateMaterials in STRUCT/AliPIPEv3.cxx |
228 | Float_t sxmgmx = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Max();//from CreateMaterials in STRUCT/AliPIPEv3.cxx | |
1d9af2d5 | 229 | |
230 | ||
231 | AliMixture(++matId,"UpgradeAir" ,aAir ,zAir ,dAir ,nAir ,wAir ); | |
232 | AliMedium(kAir ,"UpgradeAir" ,matId, unsens, itgfld, maxfld, tmaxfd, stemax, deemax, epsil, stmin); | |
233 | ||
234 | AliMaterial(++matId,"UpgradeSi" ,aSi ,zSi ,dSi ,radSi ,absSi ); | |
a346a81b | 235 | AliMedium(kSi ,"UpgradeSi" , matId, sens, isxfld, sxmgmx, tmaxfdSi, stemaxSi, deemaxSi, epsilSi, stminSi); |
1d9af2d5 | 236 | |
237 | AliMaterial(++matId,"UpgradeBe" ,aBe ,zBe ,dBe ,radBe ,absBe ); | |
2accaff0 | 238 | AliMedium(kBe ,"UpgradeBe" , matId, unsens, isxfld, sxmgmx, tmaxfdBe, stemaxBe, deemaxBe, epsilBe, stminBe); |
1d9af2d5 | 239 | |
240 | AliMaterial(++matId, "UpgradeCu", aCu, zCu, dCu, radCu, absCu); | |
241 | AliMedium(kCu, "UpgradeCu", matId, unsens, itgfld, maxfld, tmaxfd, stemax, deemax, epsil, stmin); | |
242 | ||
243 | AliInfo("End ITS materials"); | |
244 | ||
245 | }//void AliITS::CreateMaterials() | |
246 | //__________________________________________________________________________________________________ | |
247 | void AliITSupgrade::CreateGeometry() | |
248 | { | |
249 | // | |
250 | //Creates detailed geometry simulation (currently GEANT volumes tree) | |
251 | // | |
252 | AliInfo("Start ITS upgrade preliminary version building"); | |
253 | if(!gMC->IsRootGeometrySupported()) return; | |
254 | TGeoVolumeAssembly *vol= CreateVol(); | |
255 | gGeoManager->GetVolume("ALIC")->AddNode(vol,0); | |
256 | AliInfo("Stop ITS upgrade preliminary version building"); | |
387f1a9e | 257 | PrintSummary(); |
1d9af2d5 | 258 | } |
259 | //__________________________________________________________________________________________________ | |
1d9af2d5 | 260 | void AliITSupgrade::StepManager() |
261 | { | |
262 | // Full Step Manager. | |
263 | // Arguments: none | |
264 | // Returns: none | |
a346a81b | 265 | // StepHistory(); return; //uncomment to print tracks history |
1d9af2d5 | 266 | // StepCount(); return; //uncomment to count photons |
0ac80088 | 267 | |
268 | if(!fSegmentation) AliFatal("No segmentation available"); | |
269 | ||
1d9af2d5 | 270 | if(!(this->IsActive())) return; |
271 | if(!(gMC->TrackCharge())) return; | |
272 | TString volumeName=gMC->CurrentVolName(); | |
0ac80088 | 273 | if(volumeName.Contains("Be")) return; |
274 | if(volumeName.Contains("Cu")) return; | |
275 | if(gMC->IsTrackExiting()) { | |
1d9af2d5 | 276 | AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), AliTrackReference::kITS); |
277 | } // if Outer ITS mother Volume | |
278 | ||
279 | static TLorentzVector position, momentum; // Saves on calls to construtors | |
280 | static AliITShit hit;// Saves on calls to constructors | |
281 | ||
282 | ||
283 | Int_t status = 0; | |
284 | ||
285 | // | |
286 | // Track status | |
287 | if(gMC->IsTrackInside()) status += 1; | |
288 | if(gMC->IsTrackEntering()) status += 2; | |
289 | if(gMC->IsTrackExiting()) status += 4; | |
290 | if(gMC->IsTrackOut()) status += 8; | |
291 | if(gMC->IsTrackDisappeared()) status += 16; | |
292 | if(gMC->IsTrackStop()) status += 32; | |
293 | if(gMC->IsTrackAlive()) status += 64; | |
294 | ||
295 | // | |
296 | // Fill hit structure. | |
297 | // | |
0ac80088 | 298 | Int_t copy=-1; |
299 | gMC->CurrentVolID(copy); | |
300 | ||
301 | volumeName.Remove(0,12); // remove letters to get the layer number | |
302 | hit.SetModule(fSegmentation->GetIdIndex(volumeName.Atoi(),copy)); // layer and sector information are together in the IdIndex (if copy=0 the idIndex is the layer)); | |
1d9af2d5 | 303 | hit.SetTrack(gAlice->GetMCApp()->GetCurrentTrackNumber()); |
304 | ||
305 | gMC->TrackPosition(position); | |
306 | gMC->TrackMomentum(momentum); | |
307 | hit.SetPosition(position); | |
308 | ||
309 | hit.SetTime(gMC->TrackTime()); | |
310 | hit.SetMomentum(momentum); | |
311 | hit.SetStatus(status); | |
312 | hit.SetEdep(gMC->Edep()); | |
313 | hit.SetShunt(GetIshunt()); | |
314 | if(gMC->IsTrackEntering()){ | |
315 | hit.SetStartPosition(position); | |
316 | hit.SetStartTime(gMC->TrackTime()); | |
317 | hit.SetStartStatus(status); | |
318 | return; // don't save entering hit. | |
319 | } | |
387f1a9e | 320 | // Fill hit structure with this new hit. |
1d9af2d5 | 321 | |
322 | new((*fHits)[fNhits++]) AliITShit(hit); // Use Copy Construtor. | |
323 | // Save old position... for next hit. | |
324 | hit.SetStartPosition(position); | |
325 | hit.SetStartTime(gMC->TrackTime()); | |
326 | hit.SetStartStatus(status); | |
327 | return; | |
328 | ||
329 | } | |
330 | //__________________________________________________________________________________________________ | |
331 | TGeoVolumeAssembly * AliITSupgrade::CreateVol() | |
332 | { | |
a19b4e8c | 333 | // |
334 | // method to create the Upgrade Geometry (silicon, copper cylinders and beampipe) | |
335 | // | |
336 | TGeoVolumeAssembly *vol = new TGeoVolumeAssembly("ITSupgrade"); | |
1d9af2d5 | 337 | TGeoMedium *si =gGeoManager->GetMedium("ITS_UpgradeSi"); |
338 | TGeoMedium *cu =gGeoManager->GetMedium("ITS_UpgradeCu"); | |
339 | TGeoMedium *be =gGeoManager->GetMedium("ITS_UpgradeBe"); | |
340 | for(Int_t ivol=0;ivol<fNlayers;ivol++){ | |
1d9af2d5 | 341 | |
0ac80088 | 342 | if(fNSectors<1){ |
343 | TGeoVolume *layer=gGeoManager->MakeTube(Form("LayerSilicon%i",ivol),si , fRadii.At(ivol) , fRadii.At(ivol)+fWidths.At(ivol) , fHalfLength.At(ivol)); //upgraded situation | |
344 | ||
345 | TGeoVolume *layerCu=gGeoManager->MakeTube(Form("LayerCu%i",ivol),cu , fRadiiCu.At(ivol) , fRadiiCu.At(ivol)+fWidthsCu.At(ivol) , fHalfLength.At(ivol) ); //upgraded situation | |
346 | ||
347 | vol ->AddNode(layer,ivol); | |
348 | if(fCopper.At(ivol)){ | |
349 | vol->AddNode(layerCu,ivol); | |
350 | } | |
0ac80088 | 351 | }else{ |
352 | ||
353 | TGeoVolume *layer = gGeoManager->MakeTubs(Form("LayerSilicon%i",ivol),si, fRadii.At(ivol), fRadii.At(ivol)+fWidths.At(ivol) ,fHalfLength.At(ivol),0,(360./fNSectors)); | |
354 | TGeoVolume *layerCu = gGeoManager->MakeTubs(Form("LayerCu%i",ivol),cu , fRadiiCu.At(ivol) , fRadiiCu.At(ivol)+fWidthsCu.At(ivol) , fHalfLength.At(ivol) ,0,(360./fNSectors)); | |
355 | ||
356 | ||
357 | for(Int_t i=0;i<fNSectors;i++){ | |
358 | TGeoRotation *rot1 = new TGeoRotation(" ",0.0,0.0,360.*i/fNSectors);//sector rotation | |
359 | TGeoRotation *rot2 = new TGeoRotation(" ",0.0,0.0,360.*i/fNSectors);// | |
360 | vol->AddNode(layer,i,rot1); | |
361 | if(fCopper.At(ivol)){ | |
362 | vol->AddNode(layerCu,i,rot2); | |
363 | } | |
364 | } | |
1d9af2d5 | 365 | } |
366 | } | |
0ac80088 | 367 | |
368 | ||
369 | if(fBeampipe) { | |
370 | TGeoVolume *beampipe=gGeoManager->MakeTube("BeamPipe", be , fRadiusBP , fRadiusBP+ fWidthBP , fHalfLengthBP ); //upgraded situation | |
371 | vol->AddNode(beampipe,0); | |
372 | } | |
373 | return vol; | |
1d9af2d5 | 374 | } |
375 | //_________________________________________________________________________________________________ | |
376 | void AliITSupgrade::SetFullSegmentation(TArrayD xsize,TArrayD zsize){ | |
a19b4e8c | 377 | // |
378 | // Upgrade detector specs specified in used constructor are stored in a file . | |
379 | // for further usage (loc<->master<->tracking reference system changes) | |
0ac80088 | 380 | |
a19b4e8c | 381 | Bool_t check=kFALSE; |
0ac80088 | 382 | for(Int_t lay = 0; lay< xsize.GetSize(); lay++){ |
383 | Double_t arch = fRadii.At(lay)*(TMath::Pi()*2/fNSectors); | |
384 | Int_t nPixRPhi = (Int_t)(arch/xsize.At(lay)); | |
385 | Int_t nPixZed = (Int_t)((2*fHalfLength.At(lay))/zsize.At(lay)); | |
a19b4e8c | 386 | if(nPixRPhi>9999)check=kTRUE; |
387 | if(nPixZed>99999)check=kTRUE; | |
0ac80088 | 388 | } |
a19b4e8c | 389 | if(check) AliFatal(" Segmentation is too small!! "); |
0ac80088 | 390 | if(fSegmentation) fSegmentation->SetNSectors(fNSectors); |
391 | TArrayD nSect(1); | |
392 | nSect.AddAt(fNSectors,0); | |
1d9af2d5 | 393 | TFile *file= TFile::Open("Segmentation.root","recreate"); |
394 | file->WriteObjectAny(&xsize,"TArrayD","CellSizeX"); | |
0ac80088 | 395 | file->WriteObjectAny(&zsize,"TArrayD","CellSizeZ"); |
396 | file->WriteObjectAny(&nSect,"TArrayD","nSectors"); | |
1d9af2d5 | 397 | file->Close(); |
398 | } | |
399 | //_________________________________________________________________________________________________ | |
400 | void AliITSupgrade::StepHistory() | |
401 | { | |
402 | // This methode is invoked from StepManager() in order to print out | |
a346a81b | 403 | TString volumeName=gMC->CurrentVolName(); |
404 | if(!volumeName.Contains("Silicon")) return; | |
1d9af2d5 | 405 | static Int_t iStepN; |
406 | const char *sParticle; | |
407 | switch(gMC->TrackPid()){ | |
408 | case kProton: sParticle="PROTON" ;break; | |
409 | case kNeutron: sParticle="neutron" ;break; | |
410 | case kGamma: sParticle="gamma" ;break; | |
411 | case kPi0: sParticle="Pi0" ;break; | |
412 | case kPiPlus: sParticle="Pi+" ;break; | |
413 | case kPiMinus: sParticle="Pi-" ;break; | |
414 | case kElectron: sParticle="electron" ;break; | |
415 | default: sParticle="not known" ;break; | |
416 | } | |
417 | ||
418 | TString flag="fanny combination"; | |
419 | if(gMC->IsTrackAlive()) | |
420 | if(gMC->IsTrackEntering()) flag="enters to"; | |
421 | else if(gMC->IsTrackExiting()) flag="exits from"; | |
422 | else if(gMC->IsTrackInside()) flag="inside"; | |
423 | else if(gMC->IsTrackStop()) flag="stopped in"; | |
424 | ||
425 | Int_t vid=0,copy=0; | |
426 | TString path=gMC->CurrentVolName(); path.Prepend("-");path.Prepend(gMC->CurrentVolOffName(1));//current volume and his mother are always there | |
427 | vid=gMC->CurrentVolOffID(2,copy); if(vid) {path.Prepend("-");path.Prepend(gMC->VolName(vid));} | |
428 | vid=gMC->CurrentVolOffID(3,copy); if(vid) {path.Prepend("-");path.Prepend(gMC->VolName(vid));} | |
a346a81b | 429 | |
1d9af2d5 | 430 | |
a346a81b | 431 | AliInfo(Form("\n Step %i: %s (%i) %s %s m=%.6f GeV q=%.1f dEdX=%.4f Etot=%.4f",iStepN,sParticle,gMC->TrackPid(),flag.Data(),path.Data(),gMC->TrackMass(),gMC->TrackCharge(),gMC->Edep()*1e9,gMC->Etot())); |
1d9af2d5 | 432 | |
433 | Double_t gMcTrackPos[3]; gMC->TrackPosition(gMcTrackPos[0],gMcTrackPos[1],gMcTrackPos[2]); | |
434 | Double_t gMcTrackPosLoc[3]; gMC->Gmtod(gMcTrackPos,gMcTrackPosLoc,1); | |
a346a81b | 435 | TString v(volumeName.Data()); |
436 | v.ReplaceAll("LayerSilicon",""); | |
437 | Int_t ilayer = v.Atoi(); | |
438 | Double_t rXY = TMath::Sqrt(gMcTrackPos[0]*gMcTrackPos[0]+gMcTrackPos[1]*gMcTrackPos[1]); | |
439 | AliInfo(Form("gMC Track Position (MARS) x: %5.3lf, y: %5.3lf, z: %5.3lf (r: %5.3lf) (deltaR %5.5lf - width %5.5f)",gMcTrackPos[0],gMcTrackPos[1],gMcTrackPos[2], rXY , rXY - (fRadii.At(ilayer)),fWidths.At(ilayer))); | |
1d9af2d5 | 440 | |
441 | ||
442 | AliDebug(10,Form("Step %i: tid=%i flags alive=%i disap=%i enter=%i exit=%i inside=%i out=%i stop=%i new=%i", | |
443 | iStepN, gAlice->GetMCApp()->GetCurrentTrackNumber(), | |
444 | gMC->IsTrackAlive(), gMC->IsTrackDisappeared(),gMC->IsTrackEntering(), gMC->IsTrackExiting(), | |
445 | gMC->IsTrackInside(),gMC->IsTrackOut(), gMC->IsTrackStop(), gMC->IsNewTrack())); | |
446 | ||
447 | Float_t a,z,den,rad,abs; a=z=den=rad=abs=-1; | |
448 | Int_t mid=gMC->CurrentMaterial(a,z,den,rad,abs); | |
449 | AliDebug(10, Form("Step %i: mid=%i a=%7.2f z=%7.2f den=%9.4f rad=%9.2f abs=%9.2f\n\n",iStepN,mid,a,z,den,rad,abs)); | |
450 | ||
451 | TArrayI proc; gMC->StepProcesses(proc); | |
a346a81b | 452 | AliInfo("Processes in this step:"); |
1d9af2d5 | 453 | for ( int i = 0 ; i < proc.GetSize(); i++) |
454 | { | |
a346a81b | 455 | printf(Form(" - %s - ",TMCProcessName[proc.At(i)])); |
1d9af2d5 | 456 | } |
a346a81b | 457 | printf("\n"); |
458 | AliInfo("End process list"); | |
1d9af2d5 | 459 | iStepN++; |
460 | }//StepHistory() | |
461 | //______________________________________________________ | |
462 | void AliITSupgrade::Hits2SDigits(){ | |
463 | ||
464 | // Interface method ivoked from AliSimulation to create a list of sdigits corresponding to list of hits. Every hit generates one or more sdigits. | |
465 | // Arguments: none | |
466 | // Returns: none | |
467 | AliDebug(1,"Start Hits2SDigits."); | |
468 | ||
469 | if(!fSegmentation)fSegmentation=new AliITSsegmentationUpgrade(); | |
470 | ||
471 | if(!GetLoader()->TreeH()) {GetLoader()->LoadHits();} | |
472 | if(!GetLoader()->TreeS()) | |
473 | ||
474 | for(Int_t iEvt=0;iEvt < GetLoader()->GetRunLoader()->GetNumberOfEvents();iEvt++){//events loop | |
475 | GetLoader()->GetRunLoader()->GetEvent(iEvt); //get next event | |
476 | { | |
477 | GetLoader()->MakeTree("S"); | |
478 | MakeBranch("S"); | |
479 | } | |
480 | SetTreeAddress(); | |
481 | Int_t nSdigit[10]; for(Int_t i=0;i<10;i++) nSdigit[i] =0; | |
482 | for(Int_t iEnt=0;iEnt<GetLoader()->TreeH()->GetEntries();iEnt++){//prims loop | |
483 | GetLoader()->TreeH()->GetEntry(iEnt); | |
484 | Hit2SumDig(Hits(),SDigitsList(),nSdigit);//convert this hit to list of sdigits | |
485 | }//prims loop | |
486 | GetLoader()->TreeS()->Fill(); | |
487 | GetLoader()->WriteSDigits("OVERWRITE"); | |
488 | SDigitsReset(); | |
489 | }//events loop | |
490 | GetLoader()->UnloadHits(); | |
491 | GetLoader()->UnloadSDigits(); | |
492 | AliDebug(1,"Stop Hits2SDigits."); | |
493 | ||
494 | } | |
495 | //____________________________ | |
a19b4e8c | 496 | void AliITSupgrade::Hit2SumDig(TClonesArray *hits,const TObjArray *pSDig, Int_t *nSdigit) |
1d9af2d5 | 497 | { |
498 | // Adds sdigits of this hit to the list | |
499 | // Returns: none | |
500 | ||
501 | AliDebug(1,"Start Hit2SumDig"); | |
502 | ||
503 | ||
504 | if(!fSegmentation){ | |
505 | AliDebug(1,"Segmentation Not inizialized!!"); | |
506 | return ; | |
507 | } | |
508 | ||
3303c513 | 509 | TClonesArray *pSdigList[8]; // is is the max number of layers allowed in the tracking |
510 | for(Int_t il=0; il<8; il++) pSdigList[il]=0x0; | |
1d9af2d5 | 511 | for(Int_t i=0;i<fNlayers;i++){ |
512 | pSdigList[i]=(TClonesArray*)(*pSDig)[i]; | |
513 | if(pSdigList[i]->GetEntries()!=0) AliErrorClass("Some of sdigits lists is not empty"); //in principle those lists should be empty | |
514 | } | |
515 | ||
1d9af2d5 | 516 | for(Int_t iHit=0;iHit<hits->GetEntries();iHit++){ //hits loop |
517 | AliITShit *hit = (AliITShit*)hits->At(iHit); | |
518 | Double_t xz[2]; | |
0ac80088 | 519 | |
14b8503a | 520 | Int_t module=99; |
0ac80088 | 521 | if(!fSegmentation->GlobalToDet(fSegmentation->GetLayerFromIdIndex(hit->GetModule()),hit->GetXG(),hit->GetYG(),hit->GetZG(),xz[0],xz[1],module)) continue; |
1d9af2d5 | 522 | AliITSDigitUpgrade digit; |
523 | digit.SetSignal(hit->GetIonization()); | |
524 | digit.SetNelectrons(hit->GetIonization()/(3.62*1e-09)); | |
0ac80088 | 525 | digit.SetLayer(fSegmentation->GetLayerFromIdIndex(hit->GetModule())); |
526 | digit.SetModule(fSegmentation->GetModuleFromIdIndex(hit->GetModule()));//set the module (=sector) of ITSupgrade | |
1d9af2d5 | 527 | digit.SetTrackID(hit->GetTrack()); |
528 | ||
529 | Int_t xpix = 999; | |
1d9af2d5 | 530 | Int_t zpix = 999; // shift at the next line to have zpix always positive. Such numbers are used to build the Pixel Id in the layer (> 0!) |
0ac80088 | 531 | fSegmentation->DetToPixID(xz[0], xz[1],fSegmentation->GetLayerFromIdIndex(hit->GetModule()), xpix, zpix); |
1d9af2d5 | 532 | digit.SetPixId(xpix,zpix); |
0ac80088 | 533 | new((*pSdigList[fSegmentation->GetLayerFromIdIndex(hit->GetModule())])[nSdigit[fSegmentation->GetLayerFromIdIndex(hit->GetModule())]++]) AliITSDigitUpgrade(digit); |
1d9af2d5 | 534 | |
1d9af2d5 | 535 | } |
536 | ||
537 | AliDebug(1,"Stop Hit2SumDig."); | |
538 | } | |
539 | //_______________________________________________________________________________________________ | |
540 | void AliITSupgrade::MakeBranch(Option_t *option){ | |
1d9af2d5 | 541 | //Create Tree branches |
542 | AliDebug(1,Form("Start with option= %s.",option)); | |
543 | ||
544 | const Int_t kBufSize = 4000; | |
545 | ||
546 | const char *cH = strstr(option,"H"); | |
547 | const char *cD = strstr(option,"D"); | |
6ea6235b | 548 | //const char *cR = strstr(option,"R"); |
1d9af2d5 | 549 | const char *cS = strstr(option,"S"); |
550 | ||
551 | if(cH&&fLoader->TreeH()){ | |
552 | ||
553 | HitCreate(); | |
554 | MakeBranchInTree(fLoader->TreeH(),"ITSupgrade",&fHits,kBufSize,0); | |
555 | } | |
556 | ||
557 | ||
558 | if(cS&&fLoader->TreeS()){ | |
559 | SDigitsCreate(); | |
560 | for(Int_t i=0;i<fNlayers;i++) MakeBranchInTree(fLoader->TreeS(),Form("Layer%d",i),&((*fSdigits)[i]),kBufSize,0); | |
561 | } | |
562 | ||
563 | ||
564 | if(cD&&fLoader->TreeD()){ | |
565 | DigitsCreate(); | |
a19b4e8c | 566 | for(Int_t i=0;i<fNlayers;i++) MakeBranchInTree(fLoader->TreeD(),Form("Layer%d",i),&((*fDigitArray)[i]),kBufSize,0); |
1d9af2d5 | 567 | } |
1d9af2d5 | 568 | AliDebug(1,"Stop."); |
569 | } | |
570 | //____________________________________________________________________________________________________ | |
571 | void AliITSupgrade::SetTreeAddress() | |
572 | { | |
573 | //Set branch address for the Hits and Digits Tree. | |
574 | AliDebug(1,"Start."); | |
575 | if(fLoader->TreeH() && fLoader->TreeH()->GetBranch("ITSupgrade" )){ | |
576 | HitCreate(); | |
577 | fLoader->TreeH()->SetBranchAddress("ITSupgrade",&fHits); | |
578 | ||
579 | } | |
1d9af2d5 | 580 | |
581 | if(fLoader->TreeS() && fLoader->TreeS()->GetBranch("Layer0" )){ | |
582 | SDigitsCreate(); | |
583 | for(int i=0;i<fNlayers;i++){ | |
584 | fLoader->TreeS()->SetBranchAddress(Form("Layer%d",i),&((*fSdigits)[i])); | |
585 | } | |
586 | } | |
1d9af2d5 | 587 | |
588 | if(fLoader->TreeD() && fLoader->TreeD()->GetBranch("Layer0")){ | |
589 | DigitsCreate(); | |
590 | for(int i=0;i<fNlayers;i++){ | |
a19b4e8c | 591 | fLoader->TreeD()->SetBranchAddress(Form("Layer%d",i),&((*fDigitArray)[i])); |
1d9af2d5 | 592 | } |
593 | } | |
1d9af2d5 | 594 | AliDebug(1,"Stop."); |
595 | } | |
387f1a9e | 596 | //____________________________________________________________________________________________________ |
597 | void AliITSupgrade::PrintSummary() | |
598 | { | |
599 | ||
600 | // pdg booklet or http://pdg.lbl.gov/2010/reviews/rpp2010-rev-atomic-nuclear-prop.pdf | |
601 | ||
602 | // X0 as X0[g/cm^2]/density | |
603 | Double_t beX0= 65.19/1.848; | |
604 | Double_t cuX0= 12.86/8.96; | |
605 | Double_t siX0= 21.82/2.329; | |
606 | ||
607 | if(!fSegmentation) fSegmentation= new AliITSsegmentationUpgrade(); | |
608 | printf(" %10s %10s %10s %10s %10s %10s %10s %10s\n","Name","R [cm]","x/X0 [%]","Phi res[um]","Z res[um]","X segm[um]","Y segm[um]","widths [um]"); | |
ebaa7604 | 609 | |
610 | if(fBeampipe) printf(" Beampipe %10.3f %10f %10s %10s %10s %10s %10.1f\n", fRadiusBP, 100.*fWidthBP/beX0,"-","-","-","-",fWidthBP*1.e+4); | |
611 | else printf(" * No Beam Pipe Upgrade \n"); | |
387f1a9e | 612 | for(Int_t i=0; i< fNlayers; i++){ |
613 | printf(" Si Layer %1i %10.3f %10f %10.2f %10.2f %10.2f %10.2f %10.1f\n",i, fRadii.At(i), 100.*fWidths.At(i)/siX0, (fSegmentation->GetCellSizeX(i) *1.e+4)/TMath::Sqrt(12.), (fSegmentation->GetCellSizeZ(i)*1.e+4)/TMath::Sqrt(12.),fSegmentation->GetCellSizeX(i) *1.e+4, fSegmentation->GetCellSizeZ(i)*1.e+4,fWidths.At(i)*1.e+4); | |
614 | printf(" Cu Layer %10.3f %10f %10s %10s %10s %10s %10.1f\n", fRadiiCu.At(i), 100.*fWidthsCu.At(i)/cuX0,"-","-","-","-",fWidthsCu.At(i)*1.e+4); | |
615 | } | |
616 | } | |
617 | //____________________________________________________________________________________________________ | |
618 | void AliITSupgrade::SetSegmentationX(Double_t x, Int_t lay){ | |
a19b4e8c | 619 | // |
620 | // Virtual dimension in X direction is written into the file | |
621 | // (-> see SetFullSegmentation) | |
622 | ||
387f1a9e | 623 | TFile *f = TFile::Open("Segmentation.root","UPDATE"); |
624 | if(!f) { | |
625 | AliError("\n\n\n Segmentation.root file does not exist. The segmentation is 0! \n\n\n"); | |
626 | return; | |
627 | } | |
628 | else { | |
629 | TArrayD *a = (TArrayD*)f->Get("CellSizeX"); | |
630 | if(!a) { | |
631 | AliError("CessSizeX array does not exist!"); | |
632 | return; | |
633 | } | |
634 | a->AddAt(x,lay); | |
635 | f->WriteObjectAny(a,"TArrayD","CellSizeX"); | |
636 | f->Close(); | |
637 | delete f; | |
638 | } | |
639 | } | |
640 | //____________________________________________________________________________________________________ | |
641 | void AliITSupgrade::SetSegmentationZ(Double_t z, Int_t lay){ | |
a19b4e8c | 642 | // |
643 | // Virtual dimension in X direction is written into the file | |
644 | // (-> see SetFullSegmentation) | |
645 | // | |
646 | ||
387f1a9e | 647 | |
648 | TFile *f = TFile::Open("Segmentation.root","UPDATE"); | |
649 | if(!f) { | |
650 | AliError("\n\n\n Segmentation.root file does not exist. The segmentation is 0! \n\n\n"); | |
651 | return; | |
652 | } | |
653 | else { | |
654 | TArrayD *a = (TArrayD*)f->Get("CellSizeZ"); | |
655 | if(!a) { | |
656 | AliError("CellSizeZ array does not exist!"); | |
657 | return; | |
658 | } | |
659 | a->AddAt(z,lay); | |
660 | f->WriteObjectAny(a,"TArrayD","CellSizeZ"); | |
661 | f->Close(); | |
662 | delete f; | |
663 | } | |
664 | ||
665 | } |