1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 //_________________________________________________________________________
19 // Implementation version v1 of PHOS Manager class
21 // Layout EMC + CPV has name IHEP:
22 // Produces hits for CPV, cumulated hits
24 //*-- Author: Yves Schutz (SUBATECH)
27 // --- ROOT system ---
35 // --- Standard library ---
40 #include <strstream.h>
42 // --- AliRoot header files ---
44 #include "AliPHOSv1.h"
45 #include "AliPHOSHit.h"
46 #include "AliPHOSDigit.h"
47 #include "AliPHOSReconstructioner.h"
54 //____________________________________________________________________________
55 AliPHOSv1::AliPHOSv1():
60 fReconstructioner = 0;
61 fTrackSegmentMaker = 0;
65 //____________________________________________________________________________
66 AliPHOSv1::AliPHOSv1(const char *name, const char *title):
69 // ctor : title is used to identify the layout
70 // IHEP = 5 modules (EMC + CPV )
73 // - fHits (the "normal" one), which retains the hits associated with
74 // the current primary particle being tracked
75 // (this array is reset after each primary has been tracked).
78 fPinElectronicNoise = 0.010 ;
79 fDigitThreshold = 0.01 ; // 1 GeV
81 fDigitizeB = 10000000. ;
84 // We do not want to save in TreeH the raw hits
85 // But save the cumulated hits instead (need to create the branch myself)
86 // It is put in the Digit Tree because the TreeH is filled after each primary
87 // and the TreeD at the end of the event (branch is set in FinishEvent() ).
89 fHits= new TClonesArray("AliPHOSHit",1000) ;
93 fReconstructioner = 0;
94 fTrackSegmentMaker = 0;
96 fIshunt = 1 ; // All hits are associated with primary particles
100 //____________________________________________________________________________
101 AliPHOSv1::AliPHOSv1(AliPHOSReconstructioner * Reconstructioner, const char *name, const char *title):
102 AliPHOSv0(name,title)
104 // ctor : title is used to identify the layout
106 fPinElectronicNoise = 0.010 ;
108 // We do not want to save in TreeH the raw hits
111 fHits= new TClonesArray("AliPHOSHit",1000) ;
115 fIshunt = 1 ; // All hits are associated with primary particles
117 // gets an instance of the geometry parameters class
118 AliPHOSGeometry::GetInstance(title, "") ;
120 if (GetGeometry()->IsInitialized() )
121 Info("AliPHOSv1", "AliPHOS %d : PHOS geometry intialized for %s", Version(), GetGeometry()->GetName() );
123 Info("AliPHOSv1", "AliPHOS %d : PHOS geometry initialization failed !", Version() ) ;
125 // Defining the PHOS Reconstructioner
127 fReconstructioner = Reconstructioner ;
131 //____________________________________________________________________________
132 AliPHOSv1::~AliPHOSv1()
154 if ( fEmcRecPoints ) {
155 fEmcRecPoints->Delete() ;
156 delete fEmcRecPoints ;
160 if ( fPpsdRecPoints ) {
161 fPpsdRecPoints->Delete() ;
162 delete fPpsdRecPoints ;
166 if ( fTrackSegments ) {
167 fTrackSegments->Delete() ;
168 delete fTrackSegments ;
174 //____________________________________________________________________________
175 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)
177 // Add a hit to the hit list.
178 // A PHOS hit is the sum of all hits in a single crystal
179 // or in a single PPSD gas cell
184 Bool_t deja = kFALSE ;
186 newHit = new AliPHOSHit(shunt, primary, tracknumber, Id, hits, trackpid, p, lpos) ;
188 for ( hitCounter = fNhits-1 ; hitCounter >= 0 && !deja ; hitCounter-- ) {
189 curHit = (AliPHOSHit*) (*fHits)[hitCounter] ;
190 if( *curHit == *newHit ) {
191 *curHit = *curHit + *newHit ;
197 new((*fHits)[fNhits]) AliPHOSHit(*newHit) ;
204 //____________________________________________________________________________
205 void AliPHOSv1::Hits2SDigits()
207 // Collects all hits in the same active volume into digit
208 // OBSOLETE replace by SDigitizer
213 AliPHOSDigit * newdigit ;
214 AliPHOSDigit * curdigit ;
215 Bool_t deja = kFALSE ;
219 for (itrack=0; itrack<gAlice->GetNtrack(); itrack++){
221 //=========== Get the Hits Tree for the Primary track itrack
225 Error("Hits2SDigits","Can not find TreeH in the folder");
228 TreeH()->GetEvent(itrack);
231 for ( i = 0 ; i < fHits->GetEntries() ; i++ ) {
232 hit = (AliPHOSHit*)fHits->At(i) ;
234 // Assign primary number only if contribution is significant
235 if( hit->GetEnergy() > fDigitThreshold)
236 newdigit = new AliPHOSDigit( hit->GetPrimary(), hit->GetId(), Digitize( hit->GetEnergy() ) ) ;
238 newdigit = new AliPHOSDigit( -1 , hit->GetId(), Digitize( hit->GetEnergy() ) ) ;
241 for ( j = 0 ; j < fnSdigits ; j++) {
242 curdigit = (AliPHOSDigit*) fSDigits->At(j) ;
243 if ( *curdigit == *newdigit) {
244 *curdigit = *curdigit + *newdigit ;
250 new((*fSDigits)[fnSdigits]) AliPHOSDigit(* newdigit) ;
257 } // loop over tracks
261 fnSdigits = fSDigits->GetEntries() ;
262 fSDigits->Expand(fnSdigits) ;
264 for (i = 0 ; i < fnSdigits ; i++) {
265 AliPHOSDigit * digit = (AliPHOSDigit *) fSDigits->At(i) ;
266 digit->SetIndexInList(i) ;
269 gAlice->TreeS()->Fill() ;
270 gAlice->TreeS()->Write(0,TObject::kOverwrite) ;
274 //____________________________________________________________________________
275 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 // OBSOLETE Replaced by Digitzer
281 gAlice->TreeS()->GetEvent(0) ;
283 // First calculate noise induced by the PIN diode of the PbWO crystals
284 Int_t iCurSDigit = 0 ;
286 //we assume, that there is al least one EMC digit...
287 if(fSDigits->GetEntries() == 0) {
288 Warning("SDigits2Digits", "No SDigits !!! Do not produce Digits ") ;
292 Int_t idCurSDigit = ((AliPHOSDigit *)fSDigits->At(0))->GetId() ;
295 for(absID = 1; absID < GetGeometry()->GetNModules()*GetGeometry()->GetNPhi()*GetGeometry()->GetNZ(); absID++){
296 Float_t noise = gRandom->Gaus(0., fPinElectronicNoise) ;
297 if(absID < idCurSDigit ){
298 if(noise >fDigitThreshold ){
299 new((*fDigits)[fNdigits]) AliPHOSDigit( -1,absID,Digitize(noise) ) ;
303 else{ //add noise and may be remove the true hit
304 Float_t signal = noise + Calibrate(((AliPHOSDigit *)fSDigits->At(iCurSDigit))->GetAmp()) ;
305 if( signal >fDigitThreshold ){
306 AliPHOSDigit * digit = (AliPHOSDigit*) fSDigits->At(iCurSDigit) ;
307 new((*fDigits)[fNdigits]) AliPHOSDigit( *digit ) ;
308 ((AliPHOSDigit *)fDigits->At(fNdigits))->SetAmp(Digitize(signal));
312 if(iCurSDigit < fSDigits->GetEntries()-1){
314 idCurSDigit = ((AliPHOSDigit*)fSDigits->At(iCurSDigit))->GetId() ;
317 idCurSDigit = 10000000; //no real hits left
322 //remove PPSD/CPV digits below thresholds
324 for(idigit = iCurSDigit; idigit < fSDigits->GetEntries() ; idigit++){ //loop over CPV/PPSD digits
326 AliPHOSDigit * digit = (AliPHOSDigit *) fSDigits->At(idigit) ;
327 Float_t ene = Calibrate(digit->GetAmp()) ;
330 GetGeometry()->AbsToRelNumbering(digit->GetId(), relid) ;
331 if ( relid[0] > GetGeometry()->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 ) ;
339 fDigits->Compress() ;
341 fNdigits = fDigits->GetEntries() ;
342 fDigits->Expand(fNdigits) ;
345 for (i = 0 ; i < fNdigits ; i++) {
346 AliPHOSDigit * digit = (AliPHOSDigit *) fDigits->At(i) ;
347 digit->SetIndexInList(i) ;
350 gAlice->TreeD()->Fill() ;
352 gAlice->TreeD()->Write(0,TObject::kOverwrite) ;
356 //___________________________________________________________________________
357 void AliPHOSv1::MakeBranch(Option_t* opt, char *file)
362 // Create new branche in the current Root Tree in the digit Tree
363 AliDetector::MakeBranch(opt) ;
366 cH = strstr(opt,"S");
367 //Create a branch for SDigits
370 sprintf(branchname,"%s",GetName());
375 gAlice->MakeBranchInTree(gAlice->TreeS(),branchname,&fSDigits,fBufferSize,file);
378 cH = strstr(opt,"D");
379 //Create a branch for Digits
382 sprintf(branchname,"%s",GetName());
387 gAlice->MakeBranchInTree(gAlice->TreeD(),branchname,&fDigits,fBufferSize,file);
390 cH = strstr(opt,"R");
391 //Create a branch for Reconstruction
395 Int_t splitlevel = 0 ;
398 fEmcRecPoints->Delete() ;
400 if ( fEmcRecPoints && gAlice->TreeR() ) {
401 sprintf(branchname,"%sEmcRP",GetName()) ;
402 gAlice->MakeBranchInTree(gAlice->TreeR(),branchname,"TObjArray",&fEmcRecPoints, fBufferSize, splitlevel,file);
406 fPpsdRecPoints->Delete() ;
408 if ( fPpsdRecPoints && gAlice->TreeR() ) {
409 sprintf(branchname,"%sPpsdRP",GetName()) ;
410 gAlice->MakeBranchInTree(gAlice->TreeR(),branchname,"TObjArray",&fPpsdRecPoints, fBufferSize, splitlevel,file);
414 fTrackSegments->Clear() ;
416 if ( fTrackSegments && gAlice->TreeR() ) {
417 sprintf(branchname,"%sTS",GetName()) ;
418 gAlice->MakeBranchInTree(gAlice->TreeR(),branchname,&fTrackSegments,fBufferSize,file);
422 fRecParticles->Clear() ;
424 if ( fRecParticles && gAlice->TreeR() ) {
425 sprintf(branchname,"%sRP",GetName()) ;
426 gAlice->MakeBranchInTree(gAlice->TreeR(),branchname,&fRecParticles,fBufferSize,file);
433 //_____________________________________________________________________________
434 void AliPHOSv1::Reconstruction(AliPHOSReconstructioner * Reconstructioner)
436 // 1. Reinitializes the existing RecPoint, TrackSegment, and RecParticles Lists and
437 // 2. Creates TreeR with a branch for each list
438 // 3. Steers the reconstruction processes
439 // 4. Saves the 3 lists in TreeR
440 // 5. Write the Tree to File
442 fReconstructioner = Reconstructioner ;
446 // gAlice->MakeTree("R") ;
452 fReconstructioner->Make(fDigits, fEmcRecPoints, fPpsdRecPoints, fTrackSegments, fRecParticles);
454 printf("Reconstruction: %d %d %d %d\n",
455 fEmcRecPoints->GetEntries(),fPpsdRecPoints->GetEntries(),
456 fTrackSegments->GetEntries(),fRecParticles->GetEntries());
458 // 4. Expand or Shrink the arrays to the proper size
462 size = fEmcRecPoints->GetEntries() ;
463 fEmcRecPoints->Expand(size) ;
465 size = fPpsdRecPoints->GetEntries() ;
466 fPpsdRecPoints->Expand(size) ;
468 size = fTrackSegments->GetEntries() ;
469 fTrackSegments->Expand(size) ;
471 size = fRecParticles->GetEntries() ;
472 fRecParticles->Expand(size) ;
474 gAlice->TreeR()->Fill() ;
477 gAlice->TreeR()->Write(0,TObject::kOverwrite) ;
479 // Deleting reconstructed objects
480 ResetReconstruction();
484 //____________________________________________________________________________
485 void AliPHOSv1::ResetReconstruction()
487 // Deleting reconstructed objects
489 if ( fEmcRecPoints ) fEmcRecPoints ->Delete();
490 if ( fPpsdRecPoints ) fPpsdRecPoints->Delete();
491 if ( fTrackSegments ) fTrackSegments->Delete();
492 if ( fRecParticles ) fRecParticles ->Delete();
496 //____________________________________________________________________________
498 void AliPHOSv1::StepManager(void)
500 // Accumulates hits as long as the track stays in a single crystal or PPSD gas Cell
502 Int_t relid[4] ; // (box, layer, row, column) indices
503 Int_t absid ; // absolute cell ID number
504 Float_t xyze[4]={0,0,0,0} ; // position wrt MRS and energy deposited
505 TLorentzVector pos ; // Lorentz vector of the track current position
506 TLorentzVector pmom ; //momentum of the particle initiated hit
507 Float_t xyd[3]={0,0,0} ; //local posiiton of the entering
508 Bool_t entered = kFALSE ;
511 Int_t tracknumber = gAlice->GetCurrentTrackNumber() ;
512 Int_t primary = gAlice->GetPrimary( gAlice->GetCurrentTrackNumber() );
513 TString name = GetGeometry()->GetName() ;
516 if( gMC->IsTrackEntering() ){ // create hit with position and momentum of new particle,
517 // but may be without energy deposition
519 // Current position of the hit in the local ref. system
520 gMC -> TrackPosition(pos);
521 Float_t xyzm[3], xyzd[3] ;
523 for (i=0; i<3; i++) xyzm[i] = pos[i];
524 gMC -> Gmtod (xyzm, xyzd, 1); // transform coordinate from master to daughter system
530 // Current momentum of the hit's track in the local ref. system
531 gMC -> TrackMomentum(pmom);
532 Float_t pm[3], pd[3];
533 for (i=0; i<3; i++) pm[i] = pmom[i];
534 gMC -> Gmtod (pm, pd, 2); // transform 3-momentum from master to daughter system
539 trackpid = gMC->TrackPid();
540 entered = kTRUE ; // Mark to create hit even withou energy deposition
545 if ( name == "IHEP" ) { // ======> CPV is a IHEP's one
547 // Yuri Kharlov, 28 September 2000
549 if( gMC->CurrentVolID(copy) == gMC->VolId("PCPQ") &&
551 gMC->TrackCharge() != 0) {
553 // Digitize the current CPV hit:
555 // 1. find pad response and
558 gMC->CurrentVolOffID(3,moduleNumber);
562 TClonesArray *cpvDigits = new TClonesArray("AliPHOSCPVDigit",0); // array of digits for current hit
563 CPVDigitize(pmom,xyd,moduleNumber,cpvDigits);
568 Int_t idigit,ndigits;
570 // 2. go through the current digit list and sum digits in pads
572 ndigits = cpvDigits->GetEntriesFast();
573 for (idigit=0; idigit<ndigits-1; idigit++) {
574 AliPHOSCPVDigit *cpvDigit1 = (AliPHOSCPVDigit*) cpvDigits->UncheckedAt(idigit);
575 Float_t x1 = cpvDigit1->GetXpad() ;
576 Float_t z1 = cpvDigit1->GetYpad() ;
577 for (Int_t jdigit=idigit+1; jdigit<ndigits; jdigit++) {
578 AliPHOSCPVDigit *cpvDigit2 = (AliPHOSCPVDigit*) cpvDigits->UncheckedAt(jdigit);
579 Float_t x2 = cpvDigit2->GetXpad() ;
580 Float_t z2 = cpvDigit2->GetYpad() ;
581 if (x1==x2 && z1==z2) {
582 Float_t qsum = cpvDigit1->GetQpad() + cpvDigit2->GetQpad() ;
583 cpvDigit2->SetQpad(qsum) ;
584 cpvDigits->RemoveAt(idigit) ;
588 cpvDigits->Compress() ;
590 // 3. add digits to temporary hit list fTmpHits
592 ndigits = cpvDigits->GetEntriesFast();
593 for (idigit=0; idigit<ndigits; idigit++) {
594 AliPHOSCPVDigit *cpvDigit = (AliPHOSCPVDigit*) cpvDigits->UncheckedAt(idigit);
595 relid[0] = moduleNumber + 1 ; // CPV (or PHOS) module number
596 relid[1] =-1 ; // means CPV
597 relid[2] = cpvDigit->GetXpad() ; // column number of a pad
598 relid[3] = cpvDigit->GetYpad() ; // row number of a pad
600 // get the absolute Id number
601 GetGeometry()->RelToAbsNumbering(relid, absid) ;
603 // add current digit to the temporary hit list
607 xyze[3] = cpvDigit->GetQpad() ; // amplitude in a pad
608 primary = -1; // No need in primary for CPV
609 AddHit(fIshunt, primary, tracknumber, absid, xyze, trackpid, pmom, xyd);
611 if (cpvDigit->GetQpad() > 0.02) {
612 xmean += cpvDigit->GetQpad() * (cpvDigit->GetXpad() + 0.5);
613 zmean += cpvDigit->GetQpad() * (cpvDigit->GetYpad() + 0.5);
614 qsum += cpvDigit->GetQpad();
619 } // end of IHEP configuration
622 if(gMC->CurrentVolID(copy) == gMC->VolId("PXTL") ) { // We are inside a PBWO crystal
623 gMC->TrackPosition(pos) ;
627 xyze[3] = gMC->Edep() ;
630 if ( (xyze[3] != 0) || entered ) { // Track is inside the crystal and deposits some energy or just entered
632 gMC->CurrentVolOffID(10, relid[0]) ; // get the PHOS module number ;
634 relid[1] = 0 ; // means PBW04
635 gMC->CurrentVolOffID(4, relid[2]) ; // get the row number inside the module
636 gMC->CurrentVolOffID(3, relid[3]) ; // get the cell number inside the module
638 // get the absolute Id number
639 GetGeometry()->RelToAbsNumbering(relid, absid) ;
641 // add current hit to the hit list
642 AddHit(fIshunt, primary,tracknumber, absid, xyze, trackpid,pmom, xyd);
645 } // there is deposited energy
646 } // we are inside a PHOS Xtal
651 //____________________________________________________________________________
652 void AliPHOSv1::CPVDigitize (TLorentzVector p, Float_t *zxhit, Int_t moduleNumber, TClonesArray *cpvDigits)
654 // ------------------------------------------------------------------------
655 // Digitize one CPV hit:
656 // On input take exact 4-momentum p and position zxhit of the hit,
657 // find the pad response around this hit and
658 // put the amplitudes in the pads into array digits
660 // Author: Yuri Kharlov (after Serguei Sadovsky)
662 // ------------------------------------------------------------------------
664 const Float_t kCelWr = GetGeometry()->GetPadSizePhi()/2; // Distance between wires (2 wires above 1 pad)
665 const Float_t kDetR = 0.1; // Relative energy fluctuation in track for 100 e-
666 const Float_t kdEdx = 4.0; // Average energy loss in CPV;
667 const Int_t kNgamz = 5; // Ionization size in Z
668 const Int_t kNgamx = 9; // Ionization size in Phi
669 const Float_t kNoise = 0.03; // charge noise in one pad
673 // Just a reminder on axes notation in the CPV module:
674 // axis Z goes along the beam
675 // axis X goes across the beam in the module plane
676 // axis Y is a normal to the module plane showing from the IP
678 Float_t hitX = zxhit[0];
679 Float_t hitZ =-zxhit[1];
682 Float_t pNorm = p.Py();
683 Float_t eloss = kdEdx;
685 Float_t dZY = pZ/pNorm * GetGeometry()->GetCPVGasThickness();
686 Float_t dXY = pX/pNorm * GetGeometry()->GetCPVGasThickness();
687 gRandom->Rannor(rnor1,rnor2);
688 eloss *= (1 + kDetR*rnor1) *
689 TMath::Sqrt((1 + ( pow(dZY,2) + pow(dXY,2) ) / pow(GetGeometry()->GetCPVGasThickness(),2)));
690 Float_t zhit1 = hitZ + GetGeometry()->GetCPVActiveSize(1)/2 - dZY/2;
691 Float_t xhit1 = hitX + GetGeometry()->GetCPVActiveSize(0)/2 - dXY/2;
692 Float_t zhit2 = zhit1 + dZY;
693 Float_t xhit2 = xhit1 + dXY;
695 Int_t iwht1 = (Int_t) (xhit1 / kCelWr); // wire (x) coordinate "in"
696 Int_t iwht2 = (Int_t) (xhit2 / kCelWr); // wire (x) coordinate "out"
700 if (iwht1==iwht2) { // incline 1-wire hit
702 zxe[0][0] = (zhit1 + zhit2 - dZY*0.57735) / 2;
703 zxe[1][0] = (iwht1 + 0.5) * kCelWr;
705 zxe[0][1] = (zhit1 + zhit2 + dZY*0.57735) / 2;
706 zxe[1][1] = (iwht1 + 0.5) * kCelWr;
709 else if (TMath::Abs(iwht1-iwht2) != 1) { // incline 3-wire hit
711 Int_t iwht3 = (iwht1 + iwht2) / 2;
712 Float_t xwht1 = (iwht1 + 0.5) * kCelWr; // wire 1
713 Float_t xwht2 = (iwht2 + 0.5) * kCelWr; // wire 2
714 Float_t xwht3 = (iwht3 + 0.5) * kCelWr; // wire 3
715 Float_t xwr13 = (xwht1 + xwht3) / 2; // center 13
716 Float_t xwr23 = (xwht2 + xwht3) / 2; // center 23
717 Float_t dxw1 = xhit1 - xwr13;
718 Float_t dxw2 = xhit2 - xwr23;
719 Float_t egm1 = TMath::Abs(dxw1) / ( TMath::Abs(dxw1) + TMath::Abs(dxw2) + kCelWr );
720 Float_t egm2 = TMath::Abs(dxw2) / ( TMath::Abs(dxw1) + TMath::Abs(dxw2) + kCelWr );
721 Float_t egm3 = kCelWr / ( TMath::Abs(dxw1) + TMath::Abs(dxw2) + kCelWr );
722 zxe[0][0] = (dXY*(xwr13-xwht1)/dXY + zhit1 + zhit1) / 2;
724 zxe[2][0] = eloss * egm1;
725 zxe[0][1] = (dXY*(xwr23-xwht1)/dXY + zhit1 + zhit2) / 2;
727 zxe[2][1] = eloss * egm2;
728 zxe[0][2] = dXY*(xwht3-xwht1)/dXY + zhit1;
730 zxe[2][2] = eloss * egm3;
732 else { // incline 2-wire hit
734 Float_t xwht1 = (iwht1 + 0.5) * kCelWr;
735 Float_t xwht2 = (iwht2 + 0.5) * kCelWr;
736 Float_t xwr12 = (xwht1 + xwht2) / 2;
737 Float_t dxw1 = xhit1 - xwr12;
738 Float_t dxw2 = xhit2 - xwr12;
739 Float_t egm1 = TMath::Abs(dxw1) / ( TMath::Abs(dxw1) + TMath::Abs(dxw2) );
740 Float_t egm2 = TMath::Abs(dxw2) / ( TMath::Abs(dxw1) + TMath::Abs(dxw2) );
741 zxe[0][0] = (zhit1 + zhit2 - dZY*egm1) / 2;
743 zxe[2][0] = eloss * egm1;
744 zxe[0][1] = (zhit1 + zhit2 + dZY*egm2) / 2;
746 zxe[2][1] = eloss * egm2;
749 // Finite size of ionization region
751 Int_t nCellZ = GetGeometry()->GetNumberOfCPVPadsZ();
752 Int_t nCellX = GetGeometry()->GetNumberOfCPVPadsPhi();
753 Int_t nz3 = (kNgamz+1)/2;
754 Int_t nx3 = (kNgamx+1)/2;
755 cpvDigits->Expand(nIter*kNgamx*kNgamz);
756 TClonesArray &ldigits = *(TClonesArray *)cpvDigits;
758 for (Int_t iter=0; iter<nIter; iter++) {
760 Float_t zhit = zxe[0][iter];
761 Float_t xhit = zxe[1][iter];
762 Float_t qhit = zxe[2][iter];
763 Float_t zcell = zhit / GetGeometry()->GetPadSizeZ();
764 Float_t xcell = xhit / GetGeometry()->GetPadSizePhi();
765 if ( zcell<=0 || xcell<=0 ||
766 zcell>=nCellZ || xcell>=nCellX) return;
767 Int_t izcell = (Int_t) zcell;
768 Int_t ixcell = (Int_t) xcell;
769 Float_t zc = zcell - izcell - 0.5;
770 Float_t xc = xcell - ixcell - 0.5;
771 for (Int_t iz=1; iz<=kNgamz; iz++) {
772 Int_t kzg = izcell + iz - nz3;
773 if (kzg<=0 || kzg>nCellZ) continue;
774 Float_t zg = (Float_t)(iz-nz3) - zc;
775 for (Int_t ix=1; ix<=kNgamx; ix++) {
776 Int_t kxg = ixcell + ix - nx3;
777 if (kxg<=0 || kxg>nCellX) continue;
778 Float_t xg = (Float_t)(ix-nx3) - xc;
780 // Now calculate pad response
781 Float_t qpad = CPVPadResponseFunction(qhit,zg,xg);
782 qpad += kNoise*rnor2;
783 if (qpad<0) continue;
785 // Fill the array with pad response ID and amplitude
786 new(ldigits[cpvDigits->GetEntriesFast()]) AliPHOSCPVDigit(kxg,kzg,qpad);
792 //____________________________________________________________________________
793 Float_t AliPHOSv1::CPVPadResponseFunction(Float_t qhit, Float_t zhit, Float_t xhit) {
794 // ------------------------------------------------------------------------
795 // Calculate the amplitude in one CPV pad using the
796 // cumulative pad response function
797 // Author: Yuri Kharlov (after Serguei Sadovski)
799 // ------------------------------------------------------------------------
801 Double_t dz = GetGeometry()->GetPadSizeZ() / 2;
802 Double_t dx = GetGeometry()->GetPadSizePhi() / 2;
803 Double_t z = zhit * GetGeometry()->GetPadSizeZ();
804 Double_t x = xhit * GetGeometry()->GetPadSizePhi();
805 Double_t amplitude = qhit *
806 (CPVCumulPadResponse(z+dz,x+dx) - CPVCumulPadResponse(z+dz,x-dx) -
807 CPVCumulPadResponse(z-dz,x+dx) + CPVCumulPadResponse(z-dz,x-dx));
808 return (Float_t)amplitude;
811 //____________________________________________________________________________
812 Double_t AliPHOSv1::CPVCumulPadResponse(Double_t x, Double_t y) {
813 // ------------------------------------------------------------------------
814 // Cumulative pad response function
815 // It includes several terms from the CF decomposition in electrostatics
816 // Note: this cumulative function is wrong since omits some terms
817 // but the cell amplitude obtained with it is correct because
818 // these omitting terms cancel
819 // Author: Yuri Kharlov (after Serguei Sadovski)
821 // ------------------------------------------------------------------------
823 const Double_t kA=1.0;
824 const Double_t kB=0.7;
826 Double_t r2 = x*x + y*y;
828 Double_t cumulPRF = 0;
829 for (Int_t i=0; i<=4; i++) {
830 Double_t b1 = (2*i + 1) * kB;
831 cumulPRF += TMath::Power(-1,i) * TMath::ATan( xy / (b1*TMath::Sqrt(b1*b1 + r2)) );
833 cumulPRF *= kA/(2*TMath::Pi());