7587f5a5 |
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 | |
b2a60966 |
16 | /* $Id$ */ |
5f20d3fb |
17 | |
7587f5a5 |
18 | //_________________________________________________________________________ |
5f20d3fb |
19 | // Implementation version v1 of PHOS Manager class |
a3dfe79c |
20 | //--- |
21 | // Layout EMC + PPSD has name GPS2: |
ed4205d8 |
22 | // Produces cumulated hits |
a3dfe79c |
23 | //--- |
24 | // Layout EMC + CPV has name IHEP: |
ed4205d8 |
25 | // Produces hits for CPV, cumulated hits |
26 | //--- |
27 | // Layout EMC + CPV + PPSD has name GPS: |
28 | // Produces hits for CPV, cumulated hits |
29 | //--- |
5f20d3fb |
30 | //*-- Author: Yves Schutz (SUBATECH) |
b2a60966 |
31 | |
7587f5a5 |
32 | |
33 | // --- ROOT system --- |
bea63bea |
34 | |
35 | #include "TBRIK.h" |
36 | #include "TNode.h" |
7587f5a5 |
37 | #include "TRandom.h" |
94de3818 |
38 | #include "TTree.h" |
7587f5a5 |
39 | |
5f20d3fb |
40 | |
7587f5a5 |
41 | // --- Standard library --- |
42 | |
de9ec31b |
43 | #include <stdio.h> |
44 | #include <string.h> |
45 | #include <stdlib.h> |
46 | #include <strstream.h> |
7587f5a5 |
47 | |
48 | // --- AliRoot header files --- |
49 | |
50 | #include "AliPHOSv1.h" |
51 | #include "AliPHOSHit.h" |
52 | #include "AliPHOSDigit.h" |
bea63bea |
53 | #include "AliPHOSReconstructioner.h" |
7587f5a5 |
54 | #include "AliRun.h" |
55 | #include "AliConst.h" |
94de3818 |
56 | #include "AliMC.h" |
7587f5a5 |
57 | |
58 | ClassImp(AliPHOSv1) |
59 | |
bea63bea |
60 | //____________________________________________________________________________ |
61 | AliPHOSv1::AliPHOSv1() |
62 | { |
5f20d3fb |
63 | // ctor |
ed4205d8 |
64 | |
65 | fReconstructioner = 0; |
66 | fTrackSegmentMaker = 0; |
037cc66d |
67 | |
bea63bea |
68 | } |
69 | |
7587f5a5 |
70 | //____________________________________________________________________________ |
71 | AliPHOSv1::AliPHOSv1(const char *name, const char *title): |
e04976bd |
72 | AliPHOSv0(name,title) |
7587f5a5 |
73 | { |
5f20d3fb |
74 | // ctor : title is used to identify the layout |
fa412d9b |
75 | // GPS2 = 5 modules (EMC + PPSD) |
76 | // IHEP = 5 modules (EMC + CPV ) |
ed4205d8 |
77 | // MIXT = 4 modules (EMC + CPV ) and 1 module (EMC + PPSD) |
5f20d3fb |
78 | // |
ed4205d8 |
79 | // We store hits : |
5f20d3fb |
80 | // - fHits (the "normal" one), which retains the hits associated with |
81 | // the current primary particle being tracked |
82 | // (this array is reset after each primary has been tracked). |
83 | // |
fa412d9b |
84 | |
5f20d3fb |
85 | fPinElectronicNoise = 0.010 ; |
037cc66d |
86 | fDigitThreshold = 0.01 ; // 1 GeV |
87 | fDigitizeA= 0. ; |
88 | fDigitizeB = 10000000. ; |
89 | |
5f20d3fb |
90 | |
91 | // We do not want to save in TreeH the raw hits |
92 | // But save the cumulated hits instead (need to create the branch myself) |
93 | // It is put in the Digit Tree because the TreeH is filled after each primary |
fa412d9b |
94 | // and the TreeD at the end of the event (branch is set in FinishEvent() ). |
5f20d3fb |
95 | |
ed4205d8 |
96 | fHits= new TClonesArray("AliPHOSHit",1000) ; |
5f20d3fb |
97 | |
ed4205d8 |
98 | fNhits = 0 ; |
5f20d3fb |
99 | |
ed4205d8 |
100 | fReconstructioner = 0; |
101 | fTrackSegmentMaker = 0; |
5f20d3fb |
102 | |
5f20d3fb |
103 | fIshunt = 1 ; // All hits are associated with primary particles |
fa412d9b |
104 | |
5f20d3fb |
105 | } |
106 | |
107 | //____________________________________________________________________________ |
108 | AliPHOSv1::AliPHOSv1(AliPHOSReconstructioner * Reconstructioner, const char *name, const char *title): |
109 | AliPHOSv0(name,title) |
110 | { |
111 | // ctor : title is used to identify the layout |
112 | // GPS2 = 5 modules (EMC + PPSD) |
5f20d3fb |
113 | |
114 | fPinElectronicNoise = 0.010 ; |
115 | |
116 | // We do not want to save in TreeH the raw hits |
5f20d3fb |
117 | |
ed4205d8 |
118 | fDigits = 0 ; |
119 | fHits= new TClonesArray("AliPHOSHit",1000) ; |
b73f246d |
120 | |
ed4205d8 |
121 | fNhits = 0 ; |
5f20d3fb |
122 | |
123 | fIshunt = 1 ; // All hits are associated with primary particles |
124 | |
125 | // gets an instance of the geometry parameters class |
126 | fGeom = AliPHOSGeometry::GetInstance(title, "") ; |
127 | |
128 | if (fGeom->IsInitialized() ) |
88bdfa12 |
129 | cout << "AliPHOS" << Version() << " : PHOS geometry intialized for " << fGeom->GetName() << endl ; |
5f20d3fb |
130 | else |
fc879520 |
131 | cout << "AliPHOS" << Version() << " : PHOS geometry initialization failed !" << endl ; |
5f20d3fb |
132 | |
133 | // Defining the PHOS Reconstructioner |
134 | |
135 | fReconstructioner = Reconstructioner ; |
136 | |
7587f5a5 |
137 | } |
b2a60966 |
138 | |
7587f5a5 |
139 | //____________________________________________________________________________ |
bea63bea |
140 | AliPHOSv1::~AliPHOSv1() |
b2a60966 |
141 | { |
bea63bea |
142 | // dtor |
5f20d3fb |
143 | |
ed4205d8 |
144 | if ( fHits) { |
145 | fHits->Delete() ; |
146 | delete fHits ; |
147 | fHits = 0 ; |
8dfa469d |
148 | } |
5f20d3fb |
149 | |
037cc66d |
150 | if ( fSDigits) { |
151 | fSDigits->Delete() ; |
152 | delete fSDigits ; |
153 | fSDigits = 0 ; |
154 | } |
155 | |
ed4205d8 |
156 | if ( fDigits) { |
157 | fDigits->Delete() ; |
158 | delete fDigits ; |
159 | fDigits = 0 ; |
160 | } |
5f20d3fb |
161 | |
ed4205d8 |
162 | if ( fEmcRecPoints ) { |
163 | fEmcRecPoints->Delete() ; |
164 | delete fEmcRecPoints ; |
165 | fEmcRecPoints = 0 ; |
166 | } |
167 | |
168 | if ( fPpsdRecPoints ) { |
169 | fPpsdRecPoints->Delete() ; |
170 | delete fPpsdRecPoints ; |
171 | fPpsdRecPoints = 0 ; |
172 | } |
fad3e5b9 |
173 | |
ed4205d8 |
174 | if ( fTrackSegments ) { |
175 | fTrackSegments->Delete() ; |
176 | delete fTrackSegments ; |
177 | fTrackSegments = 0 ; |
178 | } |
179 | |
7587f5a5 |
180 | } |
181 | |
7587f5a5 |
182 | //____________________________________________________________________________ |
037cc66d |
183 | void AliPHOSv1::AddHit(Int_t shunt, Int_t primary, Int_t tracknumber, Int_t Id, Float_t * hits, Int_t trackpid, TLorentzVector p, Float_t * lpos) |
bea63bea |
184 | { |
185 | // Add a hit to the hit list. |
5f20d3fb |
186 | // A PHOS hit is the sum of all hits in a single crystal |
187 | // or in a single PPSD gas cell |
bea63bea |
188 | |
5f20d3fb |
189 | Int_t hitCounter ; |
bea63bea |
190 | AliPHOSHit *newHit ; |
5f20d3fb |
191 | AliPHOSHit *curHit ; |
192 | Bool_t deja = kFALSE ; |
bea63bea |
193 | |
037cc66d |
194 | newHit = new AliPHOSHit(shunt, primary, tracknumber, Id, hits, trackpid, p, lpos) ; |
bea63bea |
195 | |
7854a24a |
196 | for ( hitCounter = fNhits-1 ; hitCounter >= 0 && !deja ; hitCounter-- ) { |
ed4205d8 |
197 | curHit = (AliPHOSHit*) (*fHits)[hitCounter] ; |
198 | if( *curHit == *newHit ) { |
199 | *curHit = *curHit + *newHit ; |
200 | deja = kTRUE ; |
5f20d3fb |
201 | } |
202 | } |
203 | |
204 | if ( !deja ) { |
ed4205d8 |
205 | new((*fHits)[fNhits]) AliPHOSHit(*newHit) ; |
206 | fNhits++ ; |
5f20d3fb |
207 | } |
208 | |
bea63bea |
209 | delete newHit; |
bea63bea |
210 | } |
211 | |
ed4205d8 |
212 | //____________________________________________________________________________ |
037cc66d |
213 | void AliPHOSv1::Hits2SDigits(){ |
214 | //Collects all hits in the same active volume into digit |
ed4205d8 |
215 | |
bea63bea |
216 | Int_t i ; |
bea63bea |
217 | Int_t j ; |
fa412d9b |
218 | AliPHOSHit * hit ; |
bea63bea |
219 | AliPHOSDigit * newdigit ; |
220 | AliPHOSDigit * curdigit ; |
221 | Bool_t deja = kFALSE ; |
222 | |
037cc66d |
223 | |
ed4205d8 |
224 | Int_t itrack ; |
037cc66d |
225 | for (itrack=0; itrack<gAlice->GetNtrack(); itrack++){ |
226 | |
ed4205d8 |
227 | //=========== Get the Hits Tree for the Primary track itrack |
228 | gAlice->ResetHits(); |
229 | gAlice->TreeH()->GetEvent(itrack); |
230 | |
037cc66d |
231 | |
ed4205d8 |
232 | for ( i = 0 ; i < fHits->GetEntries() ; i++ ) { |
233 | hit = (AliPHOSHit*)fHits->At(i) ; |
234 | |
235 | // Assign primary number only if contribution is significant |
236 | if( hit->GetEnergy() > fDigitThreshold) |
237 | newdigit = new AliPHOSDigit( hit->GetPrimary(), hit->GetId(), Digitize( hit->GetEnergy() ) ) ; |
238 | else |
239 | newdigit = new AliPHOSDigit( -1 , hit->GetId(), Digitize( hit->GetEnergy() ) ) ; |
240 | deja =kFALSE ; |
241 | |
037cc66d |
242 | for ( j = 0 ; j < fnSdigits ; j++) { |
243 | curdigit = (AliPHOSDigit*) fSDigits->At(j) ; |
ed4205d8 |
244 | if ( *curdigit == *newdigit) { |
245 | *curdigit = *curdigit + *newdigit ; |
246 | deja = kTRUE ; |
247 | } |
bea63bea |
248 | } |
bea63bea |
249 | |
ed4205d8 |
250 | if ( !deja ) { |
037cc66d |
251 | new((*fSDigits)[fnSdigits]) AliPHOSDigit(* newdigit) ; |
252 | fnSdigits++ ; |
ed4205d8 |
253 | } |
254 | |
255 | delete newdigit ; |
256 | } |
257 | |
258 | } // loop over tracks |
037cc66d |
259 | |
260 | fSDigits->Sort() ; |
261 | |
262 | fnSdigits = fSDigits->GetEntries() ; |
263 | fSDigits->Expand(fnSdigits) ; |
264 | |
265 | for (i = 0 ; i < fnSdigits ; i++) { |
266 | AliPHOSDigit * digit = (AliPHOSDigit *) fSDigits->At(i) ; |
267 | digit->SetIndexInList(i) ; |
268 | } |
269 | |
270 | gAlice->TreeS()->Fill() ; |
550bee17 |
271 | gAlice->TreeS()->Write(0,TObject::kOverwrite) ; |
272 | |
037cc66d |
273 | |
274 | } |
275 | //____________________________________________________________________________ |
276 | void AliPHOSv1::SDigits2Digits(){ |
277 | //Adds noise to the summable digits and removes everething below thresholds |
278 | //Note, that sDigits should be SORTED in accordance with abs ID. |
279 | |
280 | |
281 | gAlice->TreeS()->GetEvent(0) ; |
037cc66d |
282 | |
ad8cfaf4 |
283 | // First calculate noise induced by the PIN diode of the PbWO crystals |
037cc66d |
284 | Int_t iCurSDigit = 0 ; |
ad8cfaf4 |
285 | |
037cc66d |
286 | //we assume, that there is al least one EMC digit... |
550bee17 |
287 | if(fSDigits->GetEntries() == 0) { |
288 | cout << "PHOS::SDigits2Digits> No SDigits !!! Do not produce Digits " << endl ; |
289 | return ; |
290 | } |
037cc66d |
291 | |
550bee17 |
292 | Int_t idCurSDigit = ((AliPHOSDigit *)fSDigits->At(0))->GetId() ; |
037cc66d |
293 | |
294 | Int_t absID ; |
295 | for(absID = 1; absID < fGeom->GetNModules()*fGeom->GetNPhi()*fGeom->GetNZ(); absID++){ |
037cc66d |
296 | Float_t noise = gRandom->Gaus(0., fPinElectronicNoise) ; |
297 | if(absID < idCurSDigit ){ |
037cc66d |
298 | if(noise >fDigitThreshold ){ |
037cc66d |
299 | new((*fDigits)[fNdigits]) AliPHOSDigit( -1,absID,Digitize(noise) ) ; |
037cc66d |
300 | fNdigits++ ; |
301 | } |
302 | } |
303 | else{ //add noise and may be remove the true hit |
037cc66d |
304 | Float_t signal = noise + Calibrate(((AliPHOSDigit *)fSDigits->At(iCurSDigit))->GetAmp()) ; |
037cc66d |
305 | if( signal >fDigitThreshold ){ |
037cc66d |
306 | AliPHOSDigit * digit = (AliPHOSDigit*) fSDigits->At(iCurSDigit) ; |
307 | new((*fDigits)[fNdigits]) AliPHOSDigit( *digit ) ; |
308 | ((AliPHOSDigit *)fDigits->At(fNdigits))->SetAmp(Digitize(signal)); |
037cc66d |
309 | fNdigits++ ; |
310 | } |
311 | |
312 | if(iCurSDigit < fSDigits->GetEntries()-1){ |
313 | iCurSDigit++ ; |
314 | idCurSDigit = ((AliPHOSDigit*)fSDigits->At(iCurSDigit))->GetId() ; |
315 | } |
316 | else |
317 | idCurSDigit = 10000000; //no real hits left |
318 | } |
ed4205d8 |
319 | |
037cc66d |
320 | } |
321 | |
322 | //remove PPSD/CPV digits below thresholds |
323 | Int_t idigit ; |
324 | for(idigit = iCurSDigit; idigit < fSDigits->GetEntries() ; idigit++){ //loop over CPV/PPSD digits |
325 | |
326 | AliPHOSDigit * digit = (AliPHOSDigit *) fSDigits->At(idigit) ; |
327 | Float_t ene = Calibrate(digit->GetAmp()) ; |
328 | |
329 | Int_t relid[4] ; |
330 | fGeom->AbsToRelNumbering(digit->GetId(), relid) ; |
331 | if ( relid[0] > fGeom->GetNCPVModules() ){ //ppsd |
332 | if ( ( (relid[1] > 0) && (ene > fPpsdEnergyThreshold)) || //PPSD digit |
333 | ( (relid[1] < 0) && (ene > fCpvEnergyThreshold ) ) ) //CPV digit |
334 | new((*fDigits)[fNdigits]) AliPHOSDigit( *digit ) ; |
335 | fNdigits++ ; |
bea63bea |
336 | } |
037cc66d |
337 | } |
ed4205d8 |
338 | |
bea63bea |
339 | fDigits->Compress() ; |
ed4205d8 |
340 | |
341 | fNdigits = fDigits->GetEntries() ; |
342 | fDigits->Expand(fNdigits) ; |
bea63bea |
343 | |
037cc66d |
344 | Int_t i ; |
bea63bea |
345 | for (i = 0 ; i < fNdigits ; i++) { |
037cc66d |
346 | AliPHOSDigit * digit = (AliPHOSDigit *) fDigits->At(i) ; |
347 | digit->SetIndexInList(i) ; |
bea63bea |
348 | } |
fa412d9b |
349 | |
ed4205d8 |
350 | gAlice->TreeD()->Fill() ; |
5f20d3fb |
351 | |
ed4205d8 |
352 | gAlice->TreeD()->Write(0,TObject::kOverwrite) ; |
353 | |
354 | } |
2ab0c725 |
355 | |
5f20d3fb |
356 | //___________________________________________________________________________ |
2ab0c725 |
357 | void AliPHOSv1::MakeBranch(Option_t* opt, char *file) |
037cc66d |
358 | { |
359 | |
360 | |
361 | char *cH ; |
5f20d3fb |
362 | // Create new branche in the current Root Tree in the digit Tree |
5f20d3fb |
363 | AliDetector::MakeBranch(opt) ; |
037cc66d |
364 | |
365 | |
366 | cH = strstr(opt,"S"); |
367 | //Create a branch for SDigits |
368 | if( cH ){ |
369 | char branchname[20]; |
370 | sprintf(branchname,"%s",GetName()); |
371 | if(fSDigits) |
372 | fSDigits->Clear(); |
373 | else |
374 | fSDigits = new TClonesArray("AliPHOSDigit",1000); |
ad8cfaf4 |
375 | |
037cc66d |
376 | fnSdigits = 0 ; |
037cc66d |
377 | gAlice->MakeBranchInTree(gAlice->TreeS(),branchname,&fSDigits,fBufferSize,file); |
fa412d9b |
378 | } |
ed4205d8 |
379 | |
037cc66d |
380 | cH = strstr(opt,"D"); |
381 | //Create a branch for Digits |
382 | if( cH ){ |
383 | char branchname[20]; |
384 | sprintf(branchname,"%s",GetName()); |
ad8cfaf4 |
385 | |
386 | if(fDigits) |
037cc66d |
387 | fDigits->Clear(); |
388 | else |
389 | fDigits = new TClonesArray("AliPHOSDigit",1000); |
390 | fNdigits = 0 ; |
391 | |
ad8cfaf4 |
392 | gAlice->MakeBranchInTree(gAlice->TreeD(),branchname,&fDigits,fBufferSize,file); |
037cc66d |
393 | } |
394 | |
395 | cH = strstr(opt,"R"); |
396 | //Create a branch for Reconstruction |
397 | if( cH ){ |
398 | char branchname[20]; |
399 | |
400 | Int_t splitlevel = 0 ; |
ad8cfaf4 |
401 | |
402 | if(fEmcRecPoints) |
403 | fEmcRecPoints->Delete() ; |
404 | else |
405 | fEmcRecPoints = new TObjArray(100) ; |
037cc66d |
406 | |
407 | if ( fEmcRecPoints && gAlice->TreeR() ) { |
408 | sprintf(branchname,"%sEmcRP",GetName()) ; |
409 | gAlice->TreeR()->Branch(branchname, "TObjArray", &fEmcRecPoints, fBufferSize, splitlevel) ; |
410 | } |
411 | |
ad8cfaf4 |
412 | if(fPpsdRecPoints) |
413 | fPpsdRecPoints->Delete() ; |
414 | else |
415 | fPpsdRecPoints = new TObjArray(100) ; |
037cc66d |
416 | |
417 | if ( fPpsdRecPoints && gAlice->TreeR() ) { |
418 | sprintf(branchname,"%sPpsdRP",GetName()) ; |
419 | gAlice->TreeR()->Branch(branchname, "TObjArray", &fPpsdRecPoints, fBufferSize, splitlevel) ; |
420 | } |
421 | |
ad8cfaf4 |
422 | if(fTrackSegments) |
423 | fTrackSegments->Delete() ; |
424 | else |
425 | fTrackSegments = new TClonesArray("AliPHOSTrackSegment",100) ; |
037cc66d |
426 | |
427 | if ( fTrackSegments && gAlice->TreeR() ) { |
428 | sprintf(branchname,"%sTS",GetName()) ; |
429 | gAlice->TreeR()->Branch(branchname, &fTrackSegments, fBufferSize) ; |
430 | } |
431 | |
ad8cfaf4 |
432 | if(fRecParticles) |
433 | fRecParticles->Delete() ; |
434 | else |
435 | fRecParticles = new TClonesArray("AliPHOSRecParticle",100) ; |
037cc66d |
436 | |
437 | if ( fRecParticles && gAlice->TreeR() ) { |
438 | sprintf(branchname,"%sRP",GetName()) ; |
439 | gAlice->TreeR()->Branch(branchname, &fRecParticles, fBufferSize) ; |
440 | } |
441 | |
442 | } |
443 | |
bea63bea |
444 | } |
445 | |
5f20d3fb |
446 | //_____________________________________________________________________________ |
447 | void AliPHOSv1::Reconstruction(AliPHOSReconstructioner * Reconstructioner) |
448 | { |
449 | // 1. Reinitializes the existing RecPoint, TrackSegment, and RecParticles Lists and |
450 | // 2. Creates TreeR with a branch for each list |
451 | // 3. Steers the reconstruction processes |
452 | // 4. Saves the 3 lists in TreeR |
453 | // 5. Write the Tree to File |
454 | |
455 | fReconstructioner = Reconstructioner ; |
037cc66d |
456 | |
5f20d3fb |
457 | // 1. |
458 | |
459 | // gAlice->MakeTree("R") ; |
5f20d3fb |
460 | |
037cc66d |
461 | MakeBranch("R") ; |
5f20d3fb |
462 | |
463 | // 3. |
b73f246d |
464 | |
fad3e5b9 |
465 | fReconstructioner->Make(fDigits, fEmcRecPoints, fPpsdRecPoints, fTrackSegments, fRecParticles); |
b73f246d |
466 | |
fad3e5b9 |
467 | printf("Reconstruction: %d %d %d %d\n", |
468 | fEmcRecPoints->GetEntries(),fPpsdRecPoints->GetEntries(), |
b73f246d |
469 | fTrackSegments->GetEntries(),fRecParticles->GetEntries()); |
5f20d3fb |
470 | |
471 | // 4. Expand or Shrink the arrays to the proper size |
472 | |
473 | Int_t size ; |
474 | |
475 | size = fEmcRecPoints->GetEntries() ; |
476 | fEmcRecPoints->Expand(size) ; |
ed4205d8 |
477 | |
5f20d3fb |
478 | size = fPpsdRecPoints->GetEntries() ; |
479 | fPpsdRecPoints->Expand(size) ; |
480 | |
481 | size = fTrackSegments->GetEntries() ; |
482 | fTrackSegments->Expand(size) ; |
483 | |
484 | size = fRecParticles->GetEntries() ; |
485 | fRecParticles->Expand(size) ; |
486 | |
487 | gAlice->TreeR()->Fill() ; |
5f20d3fb |
488 | // 5. |
489 | |
4a2ca5e9 |
490 | gAlice->TreeR()->Write(0,TObject::kOverwrite) ; |
5f20d3fb |
491 | |
492 | // Deleting reconstructed objects |
493 | ResetReconstruction(); |
494 | |
495 | } |
496 | |
5f20d3fb |
497 | //____________________________________________________________________________ |
498 | void AliPHOSv1::ResetReconstruction() |
499 | { |
500 | // Deleting reconstructed objects |
501 | |
b73f246d |
502 | if ( fEmcRecPoints ) fEmcRecPoints ->Delete(); |
5f20d3fb |
503 | if ( fPpsdRecPoints ) fPpsdRecPoints->Delete(); |
504 | if ( fTrackSegments ) fTrackSegments->Delete(); |
b73f246d |
505 | if ( fRecParticles ) fRecParticles ->Delete(); |
5f20d3fb |
506 | |
507 | } |
5f20d3fb |
508 | |
5f20d3fb |
509 | //____________________________________________________________________________ |
510 | |
7587f5a5 |
511 | void AliPHOSv1::StepManager(void) |
512 | { |
b2a60966 |
513 | // Accumulates hits as long as the track stays in a single crystal or PPSD gas Cell |
b2a60966 |
514 | |
4f5bbbd4 |
515 | Int_t relid[4] ; // (box, layer, row, column) indices |
516 | Int_t absid ; // absolute cell ID number |
2168f43b |
517 | Float_t xyze[4]={0,0,0,0} ; // position wrt MRS and energy deposited |
4f5bbbd4 |
518 | TLorentzVector pos ; // Lorentz vector of the track current position |
5c617c31 |
519 | TLorentzVector pmom ; //momentum of the particle initiated hit |
4f5bbbd4 |
520 | Float_t xyd[3]={0,0,0} ; //local posiiton of the entering |
521 | Bool_t entered = kFALSE ; |
fa412d9b |
522 | Int_t copy ; |
7587f5a5 |
523 | |
bea63bea |
524 | Int_t tracknumber = gAlice->CurrentTrack() ; |
fa412d9b |
525 | Int_t primary = gAlice->GetPrimary( gAlice->CurrentTrack() ); |
526 | TString name = fGeom->GetName() ; |
037cc66d |
527 | Int_t trackpid = 0 ; |
528 | |
529 | if( gMC->IsTrackEntering() ){ // create hit with position and momentum of new particle, |
530 | // but may be without energy deposition |
531 | |
532 | // Current position of the hit in the local ref. system |
533 | gMC -> TrackPosition(pos); |
534 | Float_t xyzm[3], xyzd[3] ; |
535 | Int_t i; |
536 | for (i=0; i<3; i++) xyzm[i] = pos[i]; |
537 | gMC -> Gmtod (xyzm, xyzd, 1); // transform coordinate from master to daughter system |
538 | xyd[0] = xyzd[0]; |
7854a24a |
539 | xyd[1] =-xyzd[1]; |
540 | xyd[2] =-xyzd[2]; |
541 | |
037cc66d |
542 | |
543 | // Current momentum of the hit's track in the local ref. system |
544 | gMC -> TrackMomentum(pmom); |
545 | Float_t pm[3], pd[3]; |
546 | for (i=0; i<3; i++) pm[i] = pmom[i]; |
547 | gMC -> Gmtod (pm, pd, 2); // transform 3-momentum from master to daughter system |
548 | pmom[0] = pd[0]; |
549 | pmom[1] =-pd[1]; |
550 | pmom[2] =-pd[2]; |
551 | |
552 | trackpid = gMC->TrackPid(); |
553 | entered = kTRUE ; // Mark to create hit even withou energy deposition |
554 | |
555 | } |
556 | |
557 | |
ed4205d8 |
558 | if ( name == "GPS2" || name == "MIXT" ) { // ======> CPV is a GPS' PPSD |
fa412d9b |
559 | |
b2a60966 |
560 | if( gMC->CurrentVolID(copy) == gMC->VolId("GCEL") ) // We are inside a gas cell |
7587f5a5 |
561 | { |
562 | gMC->TrackPosition(pos) ; |
563 | xyze[0] = pos[0] ; |
564 | xyze[1] = pos[1] ; |
565 | xyze[2] = pos[2] ; |
bea63bea |
566 | xyze[3] = gMC->Edep() ; |
7587f5a5 |
567 | |
037cc66d |
568 | if ( (xyze[3] != 0) || entered ) { // there is deposited energy or new particle entering PPSD |
7587f5a5 |
569 | gMC->CurrentVolOffID(5, relid[0]) ; // get the PHOS Module number |
fad3e5b9 |
570 | if ( name == "MIXT" && strcmp(gMC->CurrentVolOffName(5),"PHO1") == 0 ){ |
ed4205d8 |
571 | relid[0] += fGeom->GetNModules() - fGeom->GetNPPSDModules(); |
fad3e5b9 |
572 | } |
7587f5a5 |
573 | gMC->CurrentVolOffID(3, relid[1]) ; // get the Micromegas Module number |
ed4205d8 |
574 | // 1-> fGeom->GetNumberOfModulesPhi() * fGeom->GetNumberOfModulesZ() upper |
575 | // > fGeom->GetNumberOfModulesPhi() * fGeom->GetNumberOfModulesZ() lower |
7587f5a5 |
576 | gMC->CurrentVolOffID(1, relid[2]) ; // get the row number of the cell |
577 | gMC->CurrentVolID(relid[3]) ; // get the column number |
578 | |
579 | // get the absolute Id number |
580 | |
bea63bea |
581 | fGeom->RelToAbsNumbering(relid, absid) ; |
7587f5a5 |
582 | |
bea63bea |
583 | // add current hit to the hit list |
037cc66d |
584 | AddHit(fIshunt, primary, tracknumber, absid, xyze, trackpid, pmom, xyd); |
585 | |
7587f5a5 |
586 | |
587 | } // there is deposited energy |
fa412d9b |
588 | } // We are inside the gas of the CPV |
589 | } // GPS2 configuration |
590 | |
ed4205d8 |
591 | if ( name == "IHEP" || name == "MIXT" ) { // ======> CPV is a IHEP's one |
fa412d9b |
592 | |
593 | // Yuri Kharlov, 28 September 2000 |
594 | |
595 | if( gMC->CurrentVolID(copy) == gMC->VolId("CPVQ") && |
037cc66d |
596 | entered && |
597 | gMC->TrackCharge() != 0) { |
fa412d9b |
598 | |
037cc66d |
599 | // Digitize the current CPV hit: |
600 | |
601 | // 1. find pad response and |
fa412d9b |
602 | |
a3dfe79c |
603 | Int_t moduleNumber; |
604 | gMC->CurrentVolOffID(3,moduleNumber); |
605 | moduleNumber--; |
fa412d9b |
606 | |
fa412d9b |
607 | |
3d402178 |
608 | TClonesArray *cpvDigits = new TClonesArray("AliPHOSCPVDigit",0); // array of digits for current hit |
a3dfe79c |
609 | CPVDigitize(pmom,xyd,moduleNumber,cpvDigits); |
fa412d9b |
610 | |
611 | Float_t xmean = 0; |
612 | Float_t zmean = 0; |
613 | Float_t qsum = 0; |
cd461ab8 |
614 | Int_t idigit,ndigits; |
fa412d9b |
615 | |
616 | // 2. go through the current digit list and sum digits in pads |
617 | |
618 | ndigits = cpvDigits->GetEntriesFast(); |
cd461ab8 |
619 | for (idigit=0; idigit<ndigits-1; idigit++) { |
3d402178 |
620 | AliPHOSCPVDigit *cpvDigit1 = (AliPHOSCPVDigit*) cpvDigits->UncheckedAt(idigit); |
fa412d9b |
621 | Float_t x1 = cpvDigit1->GetXpad() ; |
622 | Float_t z1 = cpvDigit1->GetYpad() ; |
623 | for (Int_t jdigit=idigit+1; jdigit<ndigits; jdigit++) { |
3d402178 |
624 | AliPHOSCPVDigit *cpvDigit2 = (AliPHOSCPVDigit*) cpvDigits->UncheckedAt(jdigit); |
fa412d9b |
625 | Float_t x2 = cpvDigit2->GetXpad() ; |
626 | Float_t z2 = cpvDigit2->GetYpad() ; |
627 | if (x1==x2 && z1==z2) { |
628 | Float_t qsum = cpvDigit1->GetQpad() + cpvDigit2->GetQpad() ; |
629 | cpvDigit2->SetQpad(qsum) ; |
630 | cpvDigits->RemoveAt(idigit) ; |
631 | } |
632 | } |
633 | } |
634 | cpvDigits->Compress() ; |
635 | |
636 | // 3. add digits to temporary hit list fTmpHits |
637 | |
638 | ndigits = cpvDigits->GetEntriesFast(); |
cd461ab8 |
639 | for (idigit=0; idigit<ndigits; idigit++) { |
3d402178 |
640 | AliPHOSCPVDigit *cpvDigit = (AliPHOSCPVDigit*) cpvDigits->UncheckedAt(idigit); |
a3dfe79c |
641 | relid[0] = moduleNumber + 1 ; // CPV (or PHOS) module number |
fa412d9b |
642 | relid[1] =-1 ; // means CPV |
643 | relid[2] = cpvDigit->GetXpad() ; // column number of a pad |
644 | relid[3] = cpvDigit->GetYpad() ; // row number of a pad |
645 | |
646 | // get the absolute Id number |
647 | fGeom->RelToAbsNumbering(relid, absid) ; |
648 | |
649 | // add current digit to the temporary hit list |
650 | xyze[0] = 0. ; |
651 | xyze[1] = 0. ; |
652 | xyze[2] = 0. ; |
653 | xyze[3] = cpvDigit->GetQpad() ; // amplitude in a pad |
654 | primary = -1; // No need in primary for CPV |
037cc66d |
655 | AddHit(fIshunt, primary, tracknumber, absid, xyze, trackpid, pmom, xyd); |
fa412d9b |
656 | |
657 | if (cpvDigit->GetQpad() > 0.02) { |
658 | xmean += cpvDigit->GetQpad() * (cpvDigit->GetXpad() + 0.5); |
659 | zmean += cpvDigit->GetQpad() * (cpvDigit->GetYpad() + 0.5); |
660 | qsum += cpvDigit->GetQpad(); |
661 | } |
662 | } |
663 | delete cpvDigits; |
664 | } |
665 | } // end of IHEP configuration |
7587f5a5 |
666 | |
037cc66d |
667 | |
fa412d9b |
668 | if(gMC->CurrentVolID(copy) == gMC->VolId("PXTL") ) { // We are inside a PBWO crystal |
669 | gMC->TrackPosition(pos) ; |
670 | xyze[0] = pos[0] ; |
671 | xyze[1] = pos[1] ; |
672 | xyze[2] = pos[2] ; |
673 | xyze[3] = gMC->Edep() ; |
ed4205d8 |
674 | |
037cc66d |
675 | |
676 | if ( (xyze[3] != 0) || entered ) { // Track is inside the crystal and deposits some energy or just entered |
ed4205d8 |
677 | |
fa412d9b |
678 | gMC->CurrentVolOffID(10, relid[0]) ; // get the PHOS module number ; |
037cc66d |
679 | |
fad3e5b9 |
680 | if ( name == "MIXT" && strcmp(gMC->CurrentVolOffName(10),"PHO1") == 0 ) |
681 | relid[0] += fGeom->GetNModules() - fGeom->GetNPPSDModules(); |
682 | |
fa412d9b |
683 | relid[1] = 0 ; // means PBW04 |
684 | gMC->CurrentVolOffID(4, relid[2]) ; // get the row number inside the module |
685 | gMC->CurrentVolOffID(3, relid[3]) ; // get the cell number inside the module |
686 | |
687 | // get the absolute Id number |
fa412d9b |
688 | fGeom->RelToAbsNumbering(relid, absid) ; |
ed4205d8 |
689 | |
fa412d9b |
690 | // add current hit to the hit list |
037cc66d |
691 | AddHit(fIshunt, primary,tracknumber, absid, xyze, trackpid,pmom, xyd); |
692 | |
ed4205d8 |
693 | |
fa412d9b |
694 | } // there is deposited energy |
695 | } // we are inside a PHOS Xtal |
037cc66d |
696 | |
697 | |
fa412d9b |
698 | } |
699 | |
700 | //____________________________________________________________________________ |
701 | void AliPHOSv1::CPVDigitize (TLorentzVector p, Float_t *zxhit, Int_t moduleNumber, TClonesArray *cpvDigits) |
702 | { |
703 | // ------------------------------------------------------------------------ |
704 | // Digitize one CPV hit: |
705 | // On input take exact 4-momentum p and position zxhit of the hit, |
706 | // find the pad response around this hit and |
707 | // put the amplitudes in the pads into array digits |
708 | // |
709 | // Author: Yuri Kharlov (after Serguei Sadovsky) |
710 | // 2 October 2000 |
711 | // ------------------------------------------------------------------------ |
712 | |
a3dfe79c |
713 | const Float_t kCelWr = fGeom->GetPadSizePhi()/2; // Distance between wires (2 wires above 1 pad) |
714 | const Float_t kDetR = 0.1; // Relative energy fluctuation in track for 100 e- |
715 | const Float_t kdEdx = 4.0; // Average energy loss in CPV; |
716 | const Int_t kNgamz = 5; // Ionization size in Z |
717 | const Int_t kNgamx = 9; // Ionization size in Phi |
718 | const Float_t kNoise = 0.03; // charge noise in one pad |
fa412d9b |
719 | |
720 | Float_t rnor1,rnor2; |
721 | |
722 | // Just a reminder on axes notation in the CPV module: |
723 | // axis Z goes along the beam |
724 | // axis X goes across the beam in the module plane |
725 | // axis Y is a normal to the module plane showing from the IP |
726 | |
727 | Float_t hitX = zxhit[0]; |
728 | Float_t hitZ =-zxhit[1]; |
729 | Float_t pX = p.Px(); |
730 | Float_t pZ =-p.Pz(); |
731 | Float_t pNorm = p.Py(); |
a3dfe79c |
732 | Float_t eloss = kdEdx; |
3d402178 |
733 | |
7eb9d12d |
734 | // cout << "CPVDigitize: YVK : "<<hitX<<" "<<hitZ<<" | "<<pX<<" "<<pZ<<" "<<pNorm<<endl; |
735 | |
fa412d9b |
736 | Float_t dZY = pZ/pNorm * fGeom->GetCPVGasThickness(); |
737 | Float_t dXY = pX/pNorm * fGeom->GetCPVGasThickness(); |
738 | gRandom->Rannor(rnor1,rnor2); |
a3dfe79c |
739 | eloss *= (1 + kDetR*rnor1) * |
740 | TMath::Sqrt((1 + ( pow(dZY,2) + pow(dXY,2) ) / pow(fGeom->GetCPVGasThickness(),2))); |
fa412d9b |
741 | Float_t zhit1 = hitZ + fGeom->GetCPVActiveSize(1)/2 - dZY/2; |
742 | Float_t xhit1 = hitX + fGeom->GetCPVActiveSize(0)/2 - dXY/2; |
743 | Float_t zhit2 = zhit1 + dZY; |
744 | Float_t xhit2 = xhit1 + dXY; |
745 | |
a3dfe79c |
746 | Int_t iwht1 = (Int_t) (xhit1 / kCelWr); // wire (x) coordinate "in" |
747 | Int_t iwht2 = (Int_t) (xhit2 / kCelWr); // wire (x) coordinate "out" |
fa412d9b |
748 | |
749 | Int_t nIter; |
750 | Float_t zxe[3][5]; |
751 | if (iwht1==iwht2) { // incline 1-wire hit |
752 | nIter = 2; |
753 | zxe[0][0] = (zhit1 + zhit2 - dZY*0.57735) / 2; |
a3dfe79c |
754 | zxe[1][0] = (iwht1 + 0.5) * kCelWr; |
755 | zxe[2][0] = eloss/2; |
fa412d9b |
756 | zxe[0][1] = (zhit1 + zhit2 + dZY*0.57735) / 2; |
a3dfe79c |
757 | zxe[1][1] = (iwht1 + 0.5) * kCelWr; |
758 | zxe[2][1] = eloss/2; |
fa412d9b |
759 | } |
760 | else if (TMath::Abs(iwht1-iwht2) != 1) { // incline 3-wire hit |
761 | nIter = 3; |
762 | Int_t iwht3 = (iwht1 + iwht2) / 2; |
a3dfe79c |
763 | Float_t xwht1 = (iwht1 + 0.5) * kCelWr; // wire 1 |
764 | Float_t xwht2 = (iwht2 + 0.5) * kCelWr; // wire 2 |
765 | Float_t xwht3 = (iwht3 + 0.5) * kCelWr; // wire 3 |
fa412d9b |
766 | Float_t xwr13 = (xwht1 + xwht3) / 2; // center 13 |
767 | Float_t xwr23 = (xwht2 + xwht3) / 2; // center 23 |
768 | Float_t dxw1 = xhit1 - xwr13; |
769 | Float_t dxw2 = xhit2 - xwr23; |
a3dfe79c |
770 | Float_t egm1 = TMath::Abs(dxw1) / ( TMath::Abs(dxw1) + TMath::Abs(dxw2) + kCelWr ); |
771 | Float_t egm2 = TMath::Abs(dxw2) / ( TMath::Abs(dxw1) + TMath::Abs(dxw2) + kCelWr ); |
772 | Float_t egm3 = kCelWr / ( TMath::Abs(dxw1) + TMath::Abs(dxw2) + kCelWr ); |
fa412d9b |
773 | zxe[0][0] = (dXY*(xwr13-xwht1)/dXY + zhit1 + zhit1) / 2; |
774 | zxe[1][0] = xwht1; |
a3dfe79c |
775 | zxe[2][0] = eloss * egm1; |
fa412d9b |
776 | zxe[0][1] = (dXY*(xwr23-xwht1)/dXY + zhit1 + zhit2) / 2; |
777 | zxe[1][1] = xwht2; |
a3dfe79c |
778 | zxe[2][1] = eloss * egm2; |
fa412d9b |
779 | zxe[0][2] = dXY*(xwht3-xwht1)/dXY + zhit1; |
780 | zxe[1][2] = xwht3; |
a3dfe79c |
781 | zxe[2][2] = eloss * egm3; |
fa412d9b |
782 | } |
783 | else { // incline 2-wire hit |
784 | nIter = 2; |
a3dfe79c |
785 | Float_t xwht1 = (iwht1 + 0.5) * kCelWr; |
786 | Float_t xwht2 = (iwht2 + 0.5) * kCelWr; |
fa412d9b |
787 | Float_t xwr12 = (xwht1 + xwht2) / 2; |
788 | Float_t dxw1 = xhit1 - xwr12; |
789 | Float_t dxw2 = xhit2 - xwr12; |
790 | Float_t egm1 = TMath::Abs(dxw1) / ( TMath::Abs(dxw1) + TMath::Abs(dxw2) ); |
791 | Float_t egm2 = TMath::Abs(dxw2) / ( TMath::Abs(dxw1) + TMath::Abs(dxw2) ); |
792 | zxe[0][0] = (zhit1 + zhit2 - dZY*egm1) / 2; |
793 | zxe[1][0] = xwht1; |
a3dfe79c |
794 | zxe[2][0] = eloss * egm1; |
fa412d9b |
795 | zxe[0][1] = (zhit1 + zhit2 + dZY*egm2) / 2; |
796 | zxe[1][1] = xwht2; |
a3dfe79c |
797 | zxe[2][1] = eloss * egm2; |
fa412d9b |
798 | } |
bea63bea |
799 | |
fa412d9b |
800 | // Finite size of ionization region |
801 | |
ed4205d8 |
802 | Int_t nCellZ = fGeom->GetNumberOfCPVPadsZ(); |
803 | Int_t nCellX = fGeom->GetNumberOfCPVPadsPhi(); |
a3dfe79c |
804 | Int_t nz3 = (kNgamz+1)/2; |
805 | Int_t nx3 = (kNgamx+1)/2; |
806 | cpvDigits->Expand(nIter*kNgamx*kNgamz); |
fa412d9b |
807 | TClonesArray &ldigits = *(TClonesArray *)cpvDigits; |
808 | |
809 | for (Int_t iter=0; iter<nIter; iter++) { |
810 | |
811 | Float_t zhit = zxe[0][iter]; |
812 | Float_t xhit = zxe[1][iter]; |
813 | Float_t qhit = zxe[2][iter]; |
814 | Float_t zcell = zhit / fGeom->GetPadSizeZ(); |
815 | Float_t xcell = xhit / fGeom->GetPadSizePhi(); |
816 | if ( zcell<=0 || xcell<=0 || |
817 | zcell>=nCellZ || xcell>=nCellX) return; |
818 | Int_t izcell = (Int_t) zcell; |
819 | Int_t ixcell = (Int_t) xcell; |
820 | Float_t zc = zcell - izcell - 0.5; |
821 | Float_t xc = xcell - ixcell - 0.5; |
a3dfe79c |
822 | for (Int_t iz=1; iz<=kNgamz; iz++) { |
fa412d9b |
823 | Int_t kzg = izcell + iz - nz3; |
824 | if (kzg<=0 || kzg>nCellZ) continue; |
825 | Float_t zg = (Float_t)(iz-nz3) - zc; |
a3dfe79c |
826 | for (Int_t ix=1; ix<=kNgamx; ix++) { |
fa412d9b |
827 | Int_t kxg = ixcell + ix - nx3; |
828 | if (kxg<=0 || kxg>nCellX) continue; |
829 | Float_t xg = (Float_t)(ix-nx3) - xc; |
830 | |
831 | // Now calculate pad response |
832 | Float_t qpad = CPVPadResponseFunction(qhit,zg,xg); |
a3dfe79c |
833 | qpad += kNoise*rnor2; |
fa412d9b |
834 | if (qpad<0) continue; |
835 | |
836 | // Fill the array with pad response ID and amplitude |
3d402178 |
837 | new(ldigits[cpvDigits->GetEntriesFast()]) AliPHOSCPVDigit(kxg,kzg,qpad); |
fa412d9b |
838 | } |
fa412d9b |
839 | } |
fa412d9b |
840 | } |
841 | } |
842 | |
843 | //____________________________________________________________________________ |
844 | Float_t AliPHOSv1::CPVPadResponseFunction(Float_t qhit, Float_t zhit, Float_t xhit) { |
845 | // ------------------------------------------------------------------------ |
846 | // Calculate the amplitude in one CPV pad using the |
847 | // cumulative pad response function |
848 | // Author: Yuri Kharlov (after Serguei Sadovski) |
849 | // 3 October 2000 |
850 | // ------------------------------------------------------------------------ |
851 | |
852 | Double_t dz = fGeom->GetPadSizeZ() / 2; |
853 | Double_t dx = fGeom->GetPadSizePhi() / 2; |
854 | Double_t z = zhit * fGeom->GetPadSizeZ(); |
855 | Double_t x = xhit * fGeom->GetPadSizePhi(); |
856 | Double_t amplitude = qhit * |
857 | (CPVCumulPadResponse(z+dz,x+dx) - CPVCumulPadResponse(z+dz,x-dx) - |
858 | CPVCumulPadResponse(z-dz,x+dx) + CPVCumulPadResponse(z-dz,x-dx)); |
859 | return (Float_t)amplitude; |
7587f5a5 |
860 | } |
861 | |
fa412d9b |
862 | //____________________________________________________________________________ |
863 | Double_t AliPHOSv1::CPVCumulPadResponse(Double_t x, Double_t y) { |
864 | // ------------------------------------------------------------------------ |
865 | // Cumulative pad response function |
866 | // It includes several terms from the CF decomposition in electrostatics |
867 | // Note: this cumulative function is wrong since omits some terms |
868 | // but the cell amplitude obtained with it is correct because |
869 | // these omitting terms cancel |
870 | // Author: Yuri Kharlov (after Serguei Sadovski) |
871 | // 3 October 2000 |
872 | // ------------------------------------------------------------------------ |
873 | |
a3dfe79c |
874 | const Double_t kA=1.0; |
875 | const Double_t kB=0.7; |
fa412d9b |
876 | |
877 | Double_t r2 = x*x + y*y; |
878 | Double_t xy = x*y; |
879 | Double_t cumulPRF = 0; |
880 | for (Int_t i=0; i<=4; i++) { |
a3dfe79c |
881 | Double_t b1 = (2*i + 1) * kB; |
fa412d9b |
882 | cumulPRF += TMath::Power(-1,i) * TMath::ATan( xy / (b1*TMath::Sqrt(b1*b1 + r2)) ); |
883 | } |
a3dfe79c |
884 | cumulPRF *= kA/(2*TMath::Pi()); |
fa412d9b |
885 | return cumulPRF; |
886 | } |
7eb9d12d |
887 | |