]>
Commit | Line | Data |
---|---|---|
4c039060 | 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 | /* | |
17 | $Log$ | |
18 | */ | |
19 | ||
da85f059 | 20 | //////////////////////////////////////////////// |
21 | // Manager and hits classes for set:CPV // | |
22 | // // | |
23 | // Author: Yuri Kharlov, IHEP, Protvino // | |
24 | // e-mail: Yuri.Kharlov@cern.ch // | |
25 | // Last modified: 18 September 1999 // | |
26 | //////////////////////////////////////////////// | |
27 | ||
28 | // --- ROOT system --- | |
29 | #include "TH1.h" | |
30 | #include "TRandom.h" | |
31 | #include "TFile.h" | |
32 | #include "TTree.h" | |
33 | #include "TBRIK.h" | |
34 | #include "TNode.h" | |
35 | #include "TMath.h" | |
36 | ||
37 | // --- Standard library --- | |
38 | #include <stdio.h> | |
39 | #include <string.h> | |
40 | #include <stdlib.h> | |
41 | ||
42 | // --- galice header files --- | |
43 | #include "AliCPV.h" | |
44 | #include "AliRun.h" | |
45 | ||
46 | extern "C" void cpvrec_ (Float_t *x1, Float_t *x2, Float_t *x3, Int_t *x4, | |
47 | Float_t *x5, Float_t *x6, Int_t *x7, Float_t *x8); | |
48 | ||
49 | //============================================================================== | |
50 | // AliCPVExactHit | |
51 | //============================================================================== | |
52 | ||
53 | ClassImp(AliCPVExactHit) | |
54 | ||
55 | //______________________________________________________________________________ | |
56 | ||
57 | AliCPVExactHit::AliCPVExactHit(TLorentzVector p, Float_t *xy, Int_t ipart) | |
58 | { | |
59 | // | |
60 | // Creates an exact CPV hit object | |
61 | // | |
62 | ||
63 | Int_t i; | |
64 | for (i=0; i<2; i++) fXYhit[i] = xy[i]; | |
65 | fMomentum = p; | |
66 | fIpart = ipart; | |
67 | } | |
68 | ||
69 | //______________________________________________________________________________ | |
70 | ||
71 | void AliCPVExactHit::Print() | |
72 | { | |
73 | // Print exact hit | |
74 | ||
75 | printf("CPV hit: p = (%f, %f, %f, %f) GeV,\n", | |
76 | fMomentum.Px(),fMomentum.Py(),fMomentum.Pz(),fMomentum.E()); | |
77 | printf(" xy = (%f, %f) cm, ipart = %d\n", | |
78 | fXYhit[0],fXYhit[1],fIpart); | |
79 | } | |
80 | ||
81 | //============================================================================== | |
82 | // AliCPVHit | |
83 | //============================================================================== | |
84 | ||
85 | ClassImp(AliCPVHit) | |
86 | ||
87 | //______________________________________________________________________________ | |
88 | ||
89 | AliCPVHit::AliCPVHit(Float_t *xy) | |
90 | { | |
91 | // | |
92 | // Creates a CPV hit object | |
93 | // | |
94 | ||
95 | Int_t i; | |
96 | for (i=0; i<2; i++) fXYhit[i] = xy[i]; | |
97 | } | |
98 | ||
99 | //______________________________________________________________________________ | |
100 | ||
101 | void AliCPVHit::Print() | |
102 | { | |
103 | // Print reconstructed hit | |
104 | ||
105 | printf("CPV hit: xy = (%f, %f) cm\n", | |
106 | fXYhit[0],fXYhit[1]); | |
107 | } | |
108 | ||
109 | //============================================================================== | |
110 | // AliCPVCradle | |
111 | //============================================================================== | |
112 | ||
113 | ClassImp(AliCPVCradle) | |
114 | ||
115 | //______________________________________________________________________________ | |
116 | ||
117 | AliCPVCradle::AliCPVCradle(void) { | |
118 | // Default constructor | |
119 | ||
120 | fNhitsExact = 0; | |
121 | fNhitsReconstructed = 0; | |
122 | ||
123 | // Allocate the array of exact and reconstructed hits | |
124 | fHitExact = new TClonesArray("AliCPVExactHit", 100); | |
125 | fHitReconstructed = new TClonesArray("AliCPVHit", 100); | |
126 | } | |
127 | ||
128 | //______________________________________________________________________________ | |
129 | ||
130 | AliCPVCradle::AliCPVCradle(Int_t Geometry , | |
131 | Float_t PadZSize , | |
132 | Float_t PadPhiSize, | |
133 | Float_t Radius , | |
134 | Float_t Thickness , | |
135 | Float_t Angle , | |
136 | Int_t Nz , | |
137 | Int_t Nphi ) | |
138 | { | |
139 | // Set geometry parameters and allocate space for the hit storage | |
140 | ||
141 | fPadZSize = PadZSize; | |
142 | fPadPhiSize = PadPhiSize; | |
143 | fRadius = Radius; | |
144 | fThickness = Thickness; | |
145 | fAngle = Angle; | |
146 | fNz = Nz; | |
147 | fNphi = Nphi; | |
148 | fNhitsExact = 0; | |
149 | fNhitsReconstructed = 0; | |
150 | ||
151 | // Allocate the array of exact and reconstructed hits | |
152 | fHitExact = new TClonesArray("AliCPVExactHit", 100); | |
153 | fHitReconstructed = new TClonesArray("AliCPVHit", 100); | |
154 | } | |
155 | ||
156 | //______________________________________________________________________________ | |
157 | ||
158 | AliCPVCradle::~AliCPVCradle(void) | |
159 | { | |
160 | // Default destructor | |
161 | ||
162 | Clear(); | |
163 | } | |
164 | ||
165 | //______________________________________________________________________________ | |
166 | ||
167 | void AliCPVCradle::Clear(Option_t *opt="") | |
168 | { | |
169 | // Clear hit information | |
170 | ||
171 | fHitExact -> Clear(opt); | |
172 | fHitReconstructed -> Clear(opt); | |
173 | fNhitsExact = 0; | |
174 | fNhitsReconstructed = 0; | |
175 | } | |
176 | ||
177 | //______________________________________________________________________________ | |
178 | ||
179 | void AliCPVCradle::AddHit(TLorentzVector p, Float_t *xy, Int_t ipart) | |
180 | { | |
181 | // Add this hit to the hits list in CPV detector. | |
182 | ||
183 | TClonesArray &lhits = *fHitExact; | |
184 | new(lhits[fNhitsExact++]) AliCPVExactHit(p,xy,ipart); | |
185 | } | |
186 | ||
187 | //______________________________________________________________________________ | |
188 | ||
189 | void AliCPVCradle::Print(Option_t *opt) | |
190 | { | |
191 | // Print AliCPVCradle information. | |
192 | // | |
193 | // options: 'g' - print cradle geometry | |
194 | // 'p' - print generated hits in the cradle | |
195 | // 'r' - print reconstructed hits in the cradle | |
196 | ||
197 | if (strcmp(opt,"g")==0) { | |
198 | printf ("CPVCradle: size = %f x %f cm\n",fPadZSize*fNz, | |
199 | fPadPhiSize*fNphi); | |
200 | } | |
201 | else if (strcmp(opt,"p")==0) { | |
202 | printf ("CPV cradle has %d generated hits\n",fNhitsExact); | |
203 | TIter next(fHitExact); | |
204 | AliCPVExactHit *hit0; | |
205 | while ( (hit0 = (AliCPVExactHit*)next()) ) hit0 -> Print(); | |
206 | } | |
207 | else if (strcmp(opt,"r")==0) { | |
208 | printf ("CPV cradle has %d reconstructed hits\n",fNhitsReconstructed); | |
209 | TIter next(fHitReconstructed); | |
210 | AliCPVHit *hit0; | |
211 | while ( (hit0 = (AliCPVHit*)next()) ) hit0 -> Print(); | |
212 | } | |
213 | } | |
214 | ||
215 | //______________________________________________________________________________ | |
216 | ||
217 | void AliCPVCradle::Reconstruction(Float_t min_distance, Float_t min_signal) | |
218 | { | |
219 | // This function: | |
220 | // 1) Takes on input the array of generated (exact) hits in the CPV cradle, | |
221 | // 2) Founds the pad response according the known pad-response function, | |
222 | // 3) Solves the inverse problem to find the array of reconstructed hits | |
223 | ||
224 | Float_t DzCPV=fPadZSize*fNz/2, | |
225 | DyCPV=fPadPhiSize*fNphi/2, | |
226 | DxCPV=fThickness/2; | |
227 | Float_t Xin[5000][2], | |
228 | Pin[5000][4], | |
229 | Xout[5000][2]; | |
230 | fHitReconstructed->Clear(); | |
231 | fNhitsReconstructed=0; | |
232 | if (fHitExact) { | |
233 | TIter next(fHitExact); | |
234 | AliCPVExactHit *hit; | |
235 | TClonesArray &lhits = *fHitReconstructed; | |
236 | for(int i=0;i<fNhitsExact;i++) { | |
237 | hit = (AliCPVExactHit*)next(); | |
238 | Xin[i][0]=hit->fXYhit[0]; | |
239 | Xin[i][1]=hit->fXYhit[1]; | |
240 | Pin[i][0]=hit->fMomentum.Pz(); | |
241 | Pin[i][1]=hit->fMomentum.Py(); | |
242 | Pin[i][2]=hit->fMomentum.Px(); | |
243 | Pin[i][3]=hit->fMomentum.E(); | |
244 | } | |
245 | cpvrec_(&DzCPV,&DyCPV,&DxCPV,&fNhitsExact,&Xin[0][0],&Pin[0][0], | |
246 | &fNhitsReconstructed,&Xout[0][0]); | |
247 | for(int i=0;i<fNhitsReconstructed;i++) new(lhits[i]) AliCPVHit(Xout[i]); | |
248 | } | |
249 | } | |
250 | ||
251 | //============================================================================== | |
252 | // AliCPV | |
253 | //============================================================================== | |
254 | ||
255 | ClassImp(AliCPV) | |
256 | ||
257 | //______________________________________________________________________________ | |
258 | ||
259 | AliCPV::~AliCPV(void) | |
260 | { | |
261 | fCradles->Delete(); | |
262 | delete fCradles; | |
263 | } | |
264 | ||
265 | //______________________________________________________________________________ | |
266 | ||
267 | AliCPV::AliCPV() : | |
268 | fDebugLevel (0) | |
269 | { | |
270 | fNCradles = 4; // Number of cradles | |
271 | ||
272 | if( NULL==(fCradles=new TClonesArray("AliCPVCradle",fNCradles)) ) | |
273 | { | |
274 | Error("AliCPV","Can not create fCradles"); | |
275 | exit(1); | |
276 | } | |
277 | } | |
278 | ||
279 | //______________________________________________________________________________ | |
280 | ||
281 | AliCPV::AliCPV(const char *name, const char *title) | |
282 | : AliDetector (name,title), | |
283 | fDebugLevel (0) | |
284 | { | |
285 | //Begin_Html | |
286 | /* | |
287 | <img src="picts/aliCPV.gif"> | |
288 | */ | |
289 | //End_Html | |
290 | ||
291 | SetMarkerColor(kGreen); | |
292 | SetMarkerStyle(2); | |
293 | SetMarkerSize(0.4); | |
294 | ||
295 | fNCradles = 4; // Number of cradles | |
296 | fPadZSize = 2.26; // Pad size along beam [cm] | |
297 | fPadPhiSize = 1.13; // Pad size across beam [cm] | |
298 | fRadius = 455.; // Distance of CPV from IP [cm] | |
299 | fThickness = 1.; // CPV thickness [cm] | |
300 | fAngle = 27.0; // Angle between CPV cradles [deg] | |
301 | fNz = 52; // Number of pads along beam | |
302 | fNphi = 176; // Number of pads across beam | |
303 | ||
304 | if( NULL==(fCradles=new TClonesArray("AliCPVCradle",fNCradles)) ) | |
305 | { | |
306 | Error("AliCPV","Can not create fCradles"); | |
307 | exit(1); | |
308 | } | |
309 | } | |
310 | ||
311 | //______________________________________________________________________________ | |
312 | ||
313 | void AliCPV::SetGeometry (Int_t ncradles, Int_t nz, Int_t nphi, Float_t angle) | |
314 | { | |
315 | // Set CPV geometry which differs from the default one | |
316 | ||
317 | fNCradles = ncradles; // Number of cradles | |
318 | fNz = nz; // Number of pads along beam | |
319 | fNphi = nphi; // Number of pads across beam | |
320 | fAngle = angle; // Angle between CPV cradles [deg] | |
321 | } | |
322 | ||
323 | //______________________________________________________________________________ | |
324 | ||
325 | void AliCPV::Init() | |
326 | { | |
327 | Int_t i; | |
328 | printf("\n"); | |
329 | for(i=0;i<35;i++) printf("*"); | |
330 | printf(" CPV_INIT "); | |
331 | for(i=0;i<35;i++) printf("*"); | |
332 | printf("\n"); | |
333 | for(i=0;i<80;i++) printf("*"); | |
334 | printf("\n"); | |
335 | } | |
336 | ||
337 | //______________________________________________________________________________ | |
338 | ||
339 | void AliCPV::BuildGeometry() | |
340 | { | |
341 | // | |
342 | // Build simple ROOT TNode geometry for event display | |
343 | // | |
344 | ||
345 | TNode *Node, *Top; | |
346 | ||
347 | const int kColorCPV = kGreen; | |
348 | // | |
349 | Top=gAlice->GetGeometry()->GetNode("alice"); | |
350 | ||
351 | ||
352 | // CPV | |
353 | Float_t pphi=fAngle; | |
354 | new TRotMatrix("rotCPV1","rotCPV1",90,-3*pphi,90,90-3*pphi,0,0); | |
355 | new TRotMatrix("rotCPV2","rotCPV2",90,- pphi,90,90- pphi,0,0); | |
356 | new TRotMatrix("rotCPV3","rotCPV3",90, pphi,90,90+ pphi,0,0); | |
357 | new TRotMatrix("rotCPV4","rotCPV4",90, 3*pphi,90,90+3*pphi,0,0); | |
358 | new TBRIK("S_CPV","CPV box","void",99.44,0.50,58.76); | |
359 | Top->cd(); | |
360 | Node = new TNode("CPV1","CPV1","S_CPV",-317.824921,-395.014343,0,"rot988"); | |
361 | Node->SetLineColor(kColorCPV); | |
362 | fNodes->Add(Node); | |
363 | Top->cd(); | |
364 | Node = new TNode("CPV2","CPV2","S_CPV",-113.532333,-494.124908,0,"rot989"); | |
365 | fNodes->Add(Node); | |
366 | Node->SetLineColor(kColorCPV); | |
367 | Top->cd(); | |
368 | Node = new TNode("CPV3","CPV3","S_CPV", 113.532333,-494.124908,0,"rot990"); | |
369 | Node->SetLineColor(kColorCPV); | |
370 | fNodes->Add(Node); | |
371 | Top->cd(); | |
372 | Node = new TNode("CPV4","CPV4","S_CPV", 317.824921,-395.014343,0,"rot991"); | |
373 | Node->SetLineColor(kColorCPV); | |
374 | fNodes->Add(Node); | |
375 | } | |
376 | ||
377 | //______________________________________________________________________________ | |
378 | void AliCPV::CreateMaterials() | |
379 | { | |
380 | // *** DEFINITION OF AVAILABLE CPV MATERIALS *** | |
381 | ||
382 | // CALLED BY : CPV_MEDIA | |
383 | // ORIGIN : NICK VAN EIJNDHOVEN | |
384 | ||
385 | Int_t *idtmed = fIdtmed->GetArray()-1999; | |
386 | ||
387 | Int_t ISXFLD = gAlice->Field()->Integ(); | |
388 | Float_t SXMGMX = gAlice->Field()->Max(); | |
389 | ||
390 | // --- The polysterene scintillator (CH) --- | |
391 | Float_t ap[2] = { 12.011,1.00794 }; | |
392 | Float_t zp[2] = { 6.,1. }; | |
393 | Float_t wp[2] = { 1.,1. }; | |
394 | Float_t dp = 1.032; | |
395 | ||
396 | AliMixture ( 1, "Polystyrene$", ap, zp, dp, -2, wp); | |
397 | AliMedium ( 1, "CPV scint. $", 1, 1, ISXFLD, SXMGMX, 10., .1, .1, .1, .1); | |
398 | ||
399 | // --- Generate explicitly delta rays in the CPV media --- | |
400 | gMC->Gstpar(idtmed[2000], "LOSS", 3.); | |
401 | gMC->Gstpar(idtmed[2000], "DRAY", 1.); | |
402 | } | |
403 | ||
404 | //______________________________________________________________________________ | |
405 | ||
406 | void AliCPV::AddCPVCradles() | |
407 | { | |
408 | // Create array of CPV cradles | |
409 | ||
410 | TClonesArray &lcradle = *fCradles; | |
411 | for(Int_t i=0; i<fNCradles; i++) { | |
412 | new(lcradle[i]) AliCPVCradle( IsVersion(), | |
413 | fPadZSize , | |
414 | fPadPhiSize, | |
415 | fRadius , | |
416 | fThickness , | |
417 | fAngle , | |
418 | fNz , | |
419 | fNphi ); | |
420 | } | |
421 | } | |
422 | ||
423 | //______________________________________________________________________________ | |
424 | ||
425 | void AliCPV::Reconstruction(Float_t min_distance, Float_t min_signal) | |
426 | { | |
427 | // Performs reconstruction for all CPV cradles | |
428 | ||
429 | for( Int_t i=0; i<fNCradles; i++ ) | |
430 | GetCradle(i).Reconstruction(min_distance, min_signal); | |
431 | } | |
432 | ||
433 | //______________________________________________________________________________ | |
434 | ||
435 | void AliCPV::ResetDigits(void) | |
436 | { | |
437 | AliDetector::ResetDigits(); | |
438 | ||
439 | for( int i=0; i<fNCradles; i++ ) | |
440 | ((AliCPVCradle*)(*fCradles)[i]) -> Clear(); | |
441 | } | |
442 | ||
443 | //______________________________________________________________________________ | |
444 | ||
445 | void AliCPV::FinishEvent(void) | |
446 | { | |
447 | // Called at the end of each 'galice' event. | |
448 | ||
449 | } | |
450 | ||
451 | //______________________________________________________________________________ | |
452 | ||
453 | void AliCPV::FinishRun(void) | |
454 | { | |
455 | } | |
456 | ||
457 | //______________________________________________________________________________ | |
458 | ||
459 | void AliCPV::Print(Option_t *opt) | |
460 | { | |
461 | // Print CPV information. | |
462 | // For each AliCPVCradle the function AliCPVCradle::Print(opt) is called. | |
463 | ||
464 | AliCPV &CPV = *(AliCPV *)this; // Removing 'const'... | |
465 | ||
466 | if (strcmp(opt,"g")==0) { | |
467 | for( Int_t i=0; i<fNCradles; i++ ) { | |
468 | printf("CPV cradle %d of %d\n",i+1, fNCradles); | |
469 | CPV.GetCradle(i).Print(opt); | |
470 | printf( "-------------------------------------------------------------\n"); | |
471 | } | |
472 | } | |
473 | else if (strcmp(opt,"p")==0) { | |
474 | for( Int_t i=0; i<fNCradles; i++ ) { | |
475 | if ( (CPV.GetCradle(i).GetHitExact())->GetEntries()!=0 ) { | |
476 | printf("CPV cradle %d of %d\n",i+1, fNCradles); | |
477 | CPV.GetCradle(i).Print(opt); | |
478 | printf( "-------------------------------------------------------------\n"); | |
479 | } | |
480 | } | |
481 | } | |
482 | else if (strcmp(opt,"r")==0) { | |
483 | for( Int_t i=0; i<fNCradles; i++ ) { | |
484 | if ( (CPV.GetCradle(i).GetHitReconstructed())->GetEntries()!=0 ) { | |
485 | printf("CPV cradle %d of %d\n",i+1, fNCradles); | |
486 | CPV.GetCradle(i).Print(opt); | |
487 | printf( "-------------------------------------------------------------\n"); | |
488 | } | |
489 | } | |
490 | } | |
491 | } |