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