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 + PPSD has name GPS2:
22 // Produces cumulated hits
24 // Layout EMC + CPV has name IHEP:
25 // Produces hits for CPV, cumulated hits
27 // Layout EMC + CPV + PPSD has name GPS:
28 // Produces hits for CPV, cumulated hits
30 //*-- Author: Yves Schutz (SUBATECH)
33 // --- ROOT system ---
41 // --- Standard library ---
46 #include <strstream.h>
48 // --- AliRoot header files ---
50 #include "AliPHOSv1.h"
51 #include "AliPHOSHit.h"
52 #include "AliPHOSDigit.h"
53 #include "AliPHOSReconstructioner.h"
59 //____________________________________________________________________________
60 AliPHOSv1::AliPHOSv1():
65 fReconstructioner = 0;
66 fTrackSegmentMaker = 0;
70 //____________________________________________________________________________
71 AliPHOSv1::AliPHOSv1(const char *name, const char *title):
74 // ctor : title is used to identify the layout
75 // GPS2 = 5 modules (EMC + PPSD)
76 // IHEP = 5 modules (EMC + CPV )
77 // MIXT = 4 modules (EMC + CPV ) and 1 module (EMC + PPSD)
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).
85 fPinElectronicNoise = 0.010 ;
86 fDigitThreshold = 0.01 ; // 1 GeV
88 fDigitizeB = 10000000. ;
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
94 // and the TreeD at the end of the event (branch is set in FinishEvent() ).
96 fHits= new TClonesArray("AliPHOSHit",1000) ;
100 fReconstructioner = 0;
101 fTrackSegmentMaker = 0;
103 fIshunt = 1 ; // All hits are associated with primary particles
107 //____________________________________________________________________________
108 AliPHOSv1::AliPHOSv1(AliPHOSReconstructioner * Reconstructioner, const char *name, const char *title):
109 AliPHOSv0(name,title)
111 // ctor : title is used to identify the layout
112 // GPS2 = 5 modules (EMC + PPSD)
114 fPinElectronicNoise = 0.010 ;
116 // We do not want to save in TreeH the raw hits
119 fHits= new TClonesArray("AliPHOSHit",1000) ;
123 fIshunt = 1 ; // All hits are associated with primary particles
125 // gets an instance of the geometry parameters class
126 AliPHOSGeometry::GetInstance(title, "") ;
128 if (GetGeometry()->IsInitialized() )
129 Info("AliPHOSv1", "AliPHOS %d : PHOS geometry intialized for %s", Version(), GetGeometry()->GetName() );
131 Info("AliPHOSv1", "AliPHOS %d : PHOS geometry initialization failed !", Version() ) ;
133 // Defining the PHOS Reconstructioner
135 fReconstructioner = Reconstructioner ;
139 //____________________________________________________________________________
140 AliPHOSv1::~AliPHOSv1()
162 if ( fEmcRecPoints ) {
163 fEmcRecPoints->Delete() ;
164 delete fEmcRecPoints ;
168 if ( fPpsdRecPoints ) {
169 fPpsdRecPoints->Delete() ;
170 delete fPpsdRecPoints ;
174 if ( fTrackSegments ) {
175 fTrackSegments->Delete() ;
176 delete fTrackSegments ;
182 //____________________________________________________________________________
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)
185 // Add a hit to the hit list.
186 // A PHOS hit is the sum of all hits in a single crystal
187 // or in a single PPSD gas cell
192 Bool_t deja = kFALSE ;
194 newHit = new AliPHOSHit(shunt, primary, tracknumber, Id, hits, trackpid, p, lpos) ;
196 for ( hitCounter = fNhits-1 ; hitCounter >= 0 && !deja ; hitCounter-- ) {
197 curHit = (AliPHOSHit*) (*fHits)[hitCounter] ;
198 if( *curHit == *newHit ) {
199 *curHit = *curHit + *newHit ;
205 new((*fHits)[fNhits]) AliPHOSHit(*newHit) ;
212 //____________________________________________________________________________
213 void AliPHOSv1::Hits2SDigits()
215 // Collects all hits in the same active volume into digit
216 // OBSOLETE replace by SDigitizer
221 AliPHOSDigit * newdigit ;
222 AliPHOSDigit * curdigit ;
223 Bool_t deja = kFALSE ;
227 for (itrack=0; itrack<gAlice->GetNtrack(); itrack++){
229 //=========== Get the Hits Tree for the Primary track itrack
231 gAlice->TreeH()->GetEvent(itrack);
234 for ( i = 0 ; i < fHits->GetEntries() ; i++ ) {
235 hit = (AliPHOSHit*)fHits->At(i) ;
237 // Assign primary number only if contribution is significant
238 if( hit->GetEnergy() > fDigitThreshold)
239 newdigit = new AliPHOSDigit( hit->GetPrimary(), hit->GetId(), Digitize( hit->GetEnergy() ) ) ;
241 newdigit = new AliPHOSDigit( -1 , hit->GetId(), Digitize( hit->GetEnergy() ) ) ;
244 for ( j = 0 ; j < fnSdigits ; j++) {
245 curdigit = (AliPHOSDigit*) fSDigits->At(j) ;
246 if ( *curdigit == *newdigit) {
247 *curdigit = *curdigit + *newdigit ;
253 new((*fSDigits)[fnSdigits]) AliPHOSDigit(* newdigit) ;
260 } // loop over tracks
264 fnSdigits = fSDigits->GetEntries() ;
265 fSDigits->Expand(fnSdigits) ;
267 for (i = 0 ; i < fnSdigits ; i++) {
268 AliPHOSDigit * digit = (AliPHOSDigit *) fSDigits->At(i) ;
269 digit->SetIndexInList(i) ;
272 gAlice->TreeS()->Fill() ;
273 gAlice->TreeS()->Write(0,TObject::kOverwrite) ;
277 //____________________________________________________________________________
278 void AliPHOSv1::SDigits2Digits()
280 // Adds noise to the summable digits and removes everething below thresholds
281 // Note, that sDigits should be SORTED in accordance with abs ID.
282 // OBSOLETE Replaced by Digitzer
284 gAlice->TreeS()->GetEvent(0) ;
286 // First calculate noise induced by the PIN diode of the PbWO crystals
287 Int_t iCurSDigit = 0 ;
289 //we assume, that there is al least one EMC digit...
290 if(fSDigits->GetEntries() == 0) {
291 Warning("SDigits2Digits", "No SDigits !!! Do not produce Digits ") ;
295 Int_t idCurSDigit = ((AliPHOSDigit *)fSDigits->At(0))->GetId() ;
298 for(absID = 1; absID < GetGeometry()->GetNModules()*GetGeometry()->GetNPhi()*GetGeometry()->GetNZ(); absID++){
299 Float_t noise = gRandom->Gaus(0., fPinElectronicNoise) ;
300 if(absID < idCurSDigit ){
301 if(noise >fDigitThreshold ){
302 new((*fDigits)[fNdigits]) AliPHOSDigit( -1,absID,Digitize(noise) ) ;
306 else{ //add noise and may be remove the true hit
307 Float_t signal = noise + Calibrate(((AliPHOSDigit *)fSDigits->At(iCurSDigit))->GetAmp()) ;
308 if( signal >fDigitThreshold ){
309 AliPHOSDigit * digit = (AliPHOSDigit*) fSDigits->At(iCurSDigit) ;
310 new((*fDigits)[fNdigits]) AliPHOSDigit( *digit ) ;
311 ((AliPHOSDigit *)fDigits->At(fNdigits))->SetAmp(Digitize(signal));
315 if(iCurSDigit < fSDigits->GetEntries()-1){
317 idCurSDigit = ((AliPHOSDigit*)fSDigits->At(iCurSDigit))->GetId() ;
320 idCurSDigit = 10000000; //no real hits left
325 //remove PPSD/CPV digits below thresholds
327 for(idigit = iCurSDigit; idigit < fSDigits->GetEntries() ; idigit++){ //loop over CPV/PPSD digits
329 AliPHOSDigit * digit = (AliPHOSDigit *) fSDigits->At(idigit) ;
330 Float_t ene = Calibrate(digit->GetAmp()) ;
333 GetGeometry()->AbsToRelNumbering(digit->GetId(), relid) ;
334 if ( relid[0] > GetGeometry()->GetNCPVModules() ){ //ppsd
335 if ( ( (relid[1] > 0) && (ene > fPpsdEnergyThreshold)) || //PPSD digit
336 ( (relid[1] < 0) && (ene > fCpvEnergyThreshold ) ) ) //CPV digit
337 new((*fDigits)[fNdigits]) AliPHOSDigit( *digit ) ;
342 fDigits->Compress() ;
344 fNdigits = fDigits->GetEntries() ;
345 fDigits->Expand(fNdigits) ;
348 for (i = 0 ; i < fNdigits ; i++) {
349 AliPHOSDigit * digit = (AliPHOSDigit *) fDigits->At(i) ;
350 digit->SetIndexInList(i) ;
353 gAlice->TreeD()->Fill() ;
355 gAlice->TreeD()->Write(0,TObject::kOverwrite) ;
359 //___________________________________________________________________________
360 void AliPHOSv1::MakeBranch(Option_t* opt, char *file)
365 // Create new branche in the current Root Tree in the digit Tree
366 AliDetector::MakeBranch(opt) ;
369 cH = strstr(opt,"S");
370 //Create a branch for SDigits
373 sprintf(branchname,"%s",GetName());
378 gAlice->MakeBranchInTree(gAlice->TreeS(),branchname,&fSDigits,fBufferSize,file);
381 cH = strstr(opt,"D");
382 //Create a branch for Digits
385 sprintf(branchname,"%s",GetName());
390 gAlice->MakeBranchInTree(gAlice->TreeD(),branchname,&fDigits,fBufferSize,file);
393 cH = strstr(opt,"R");
394 //Create a branch for Reconstruction
398 Int_t splitlevel = 0 ;
401 fEmcRecPoints->Delete() ;
403 if ( fEmcRecPoints && gAlice->TreeR() ) {
404 sprintf(branchname,"%sEmcRP",GetName()) ;
405 gAlice->MakeBranchInTree(gAlice->TreeR(),branchname,"TObjArray",&fEmcRecPoints, fBufferSize, splitlevel,file);
409 fPpsdRecPoints->Delete() ;
411 if ( fPpsdRecPoints && gAlice->TreeR() ) {
412 sprintf(branchname,"%sPpsdRP",GetName()) ;
413 gAlice->MakeBranchInTree(gAlice->TreeR(),branchname,"TObjArray",&fPpsdRecPoints, fBufferSize, splitlevel,file);
417 fTrackSegments->Clear() ;
419 if ( fTrackSegments && gAlice->TreeR() ) {
420 sprintf(branchname,"%sTS",GetName()) ;
421 gAlice->MakeBranchInTree(gAlice->TreeR(),branchname,&fTrackSegments,fBufferSize,file);
425 fRecParticles->Clear() ;
427 if ( fRecParticles && gAlice->TreeR() ) {
428 sprintf(branchname,"%sRP",GetName()) ;
429 gAlice->MakeBranchInTree(gAlice->TreeR(),branchname,&fRecParticles,fBufferSize,file);
436 //_____________________________________________________________________________
437 void AliPHOSv1::Reconstruction(AliPHOSReconstructioner * Reconstructioner)
439 // 1. Reinitializes the existing RecPoint, TrackSegment, and RecParticles Lists and
440 // 2. Creates TreeR with a branch for each list
441 // 3. Steers the reconstruction processes
442 // 4. Saves the 3 lists in TreeR
443 // 5. Write the Tree to File
445 fReconstructioner = Reconstructioner ;
449 // gAlice->MakeTree("R") ;
455 fReconstructioner->Make(fDigits, fEmcRecPoints, fPpsdRecPoints, fTrackSegments, fRecParticles);
457 printf("Reconstruction: %d %d %d %d\n",
458 fEmcRecPoints->GetEntries(),fPpsdRecPoints->GetEntries(),
459 fTrackSegments->GetEntries(),fRecParticles->GetEntries());
461 // 4. Expand or Shrink the arrays to the proper size
465 size = fEmcRecPoints->GetEntries() ;
466 fEmcRecPoints->Expand(size) ;
468 size = fPpsdRecPoints->GetEntries() ;
469 fPpsdRecPoints->Expand(size) ;
471 size = fTrackSegments->GetEntries() ;
472 fTrackSegments->Expand(size) ;
474 size = fRecParticles->GetEntries() ;
475 fRecParticles->Expand(size) ;
477 gAlice->TreeR()->Fill() ;
480 gAlice->TreeR()->Write(0,TObject::kOverwrite) ;
482 // Deleting reconstructed objects
483 ResetReconstruction();
487 //____________________________________________________________________________
488 void AliPHOSv1::ResetReconstruction()
490 // Deleting reconstructed objects
492 if ( fEmcRecPoints ) fEmcRecPoints ->Delete();
493 if ( fPpsdRecPoints ) fPpsdRecPoints->Delete();
494 if ( fTrackSegments ) fTrackSegments->Delete();
495 if ( fRecParticles ) fRecParticles ->Delete();
499 //____________________________________________________________________________
501 void AliPHOSv1::StepManager(void)
503 // Accumulates hits as long as the track stays in a single crystal or PPSD gas Cell
505 Int_t relid[4] ; // (box, layer, row, column) indices
506 Int_t absid ; // absolute cell ID number
507 Float_t xyze[4]={0,0,0,0} ; // position wrt MRS and energy deposited
508 TLorentzVector pos ; // Lorentz vector of the track current position
509 TLorentzVector pmom ; //momentum of the particle initiated hit
510 Float_t xyd[3]={0,0,0} ; //local posiiton of the entering
511 Bool_t entered = kFALSE ;
514 Int_t tracknumber = gAlice->CurrentTrack() ;
515 Int_t primary = gAlice->GetPrimary( gAlice->CurrentTrack() );
516 TString name = GetGeometry()->GetName() ;
519 if( gMC->IsTrackEntering() ){ // create hit with position and momentum of new particle,
520 // but may be without energy deposition
522 // Current position of the hit in the local ref. system
523 gMC -> TrackPosition(pos);
524 Float_t xyzm[3], xyzd[3] ;
526 for (i=0; i<3; i++) xyzm[i] = pos[i];
527 gMC -> Gmtod (xyzm, xyzd, 1); // transform coordinate from master to daughter system
533 // Current momentum of the hit's track in the local ref. system
534 gMC -> TrackMomentum(pmom);
535 Float_t pm[3], pd[3];
536 for (i=0; i<3; i++) pm[i] = pmom[i];
537 gMC -> Gmtod (pm, pd, 2); // transform 3-momentum from master to daughter system
542 trackpid = gMC->TrackPid();
543 entered = kTRUE ; // Mark to create hit even withou energy deposition
548 if ( name == "GPS2" || name == "MIXT" ) { // ======> CPV is a GPS' PPSD
550 if( gMC->CurrentVolID(copy) == gMC->VolId("PPCE") ) // We are inside a gas cell
552 gMC->TrackPosition(pos) ;
556 xyze[3] = gMC->Edep() ;
558 if ( (xyze[3] != 0) || entered ) { // there is deposited energy or new particle entering PPSD
559 gMC->CurrentVolOffID(5, relid[0]) ; // get the PHOS Module number
560 if ( name == "MIXT" && strcmp(gMC->CurrentVolOffName(5),"PHO1") == 0 ){
561 relid[0] += GetGeometry()->GetNModules() - GetGeometry()->GetNPPSDModules();
563 gMC->CurrentVolOffID(3, relid[1]) ; // get the Micromegas Module number
564 // 1-> GetGeometry()->GetNumberOfModulesPhi() * GetGeometry()->GetNumberOfModulesZ() upper
565 // > GetGeometry()->GetNumberOfModulesPhi() * GetGeometry()->GetNumberOfModulesZ() lower
566 gMC->CurrentVolOffID(1, relid[2]) ; // get the row number of the cell
567 gMC->CurrentVolID(relid[3]) ; // get the column number
569 // get the absolute Id number
571 GetGeometry()->RelToAbsNumbering(relid, absid) ;
573 // add current hit to the hit list
574 AddHit(fIshunt, primary, tracknumber, absid, xyze, trackpid, pmom, xyd);
577 } // there is deposited energy
578 } // We are inside the gas of the CPV
579 } // GPS2 configuration
581 if ( name == "IHEP" || name == "MIXT" ) { // ======> CPV is a IHEP's one
583 // Yuri Kharlov, 28 September 2000
585 if( gMC->CurrentVolID(copy) == gMC->VolId("PCPQ") &&
587 gMC->TrackCharge() != 0) {
589 // Digitize the current CPV hit:
591 // 1. find pad response and
594 gMC->CurrentVolOffID(3,moduleNumber);
598 TClonesArray *cpvDigits = new TClonesArray("AliPHOSCPVDigit",0); // array of digits for current hit
599 CPVDigitize(pmom,xyd,moduleNumber,cpvDigits);
604 Int_t idigit,ndigits;
606 // 2. go through the current digit list and sum digits in pads
608 ndigits = cpvDigits->GetEntriesFast();
609 for (idigit=0; idigit<ndigits-1; idigit++) {
610 AliPHOSCPVDigit *cpvDigit1 = (AliPHOSCPVDigit*) cpvDigits->UncheckedAt(idigit);
611 Float_t x1 = cpvDigit1->GetXpad() ;
612 Float_t z1 = cpvDigit1->GetYpad() ;
613 for (Int_t jdigit=idigit+1; jdigit<ndigits; jdigit++) {
614 AliPHOSCPVDigit *cpvDigit2 = (AliPHOSCPVDigit*) cpvDigits->UncheckedAt(jdigit);
615 Float_t x2 = cpvDigit2->GetXpad() ;
616 Float_t z2 = cpvDigit2->GetYpad() ;
617 if (x1==x2 && z1==z2) {
618 Float_t qsum = cpvDigit1->GetQpad() + cpvDigit2->GetQpad() ;
619 cpvDigit2->SetQpad(qsum) ;
620 cpvDigits->RemoveAt(idigit) ;
624 cpvDigits->Compress() ;
626 // 3. add digits to temporary hit list fTmpHits
628 ndigits = cpvDigits->GetEntriesFast();
629 for (idigit=0; idigit<ndigits; idigit++) {
630 AliPHOSCPVDigit *cpvDigit = (AliPHOSCPVDigit*) cpvDigits->UncheckedAt(idigit);
631 relid[0] = moduleNumber + 1 ; // CPV (or PHOS) module number
632 relid[1] =-1 ; // means CPV
633 relid[2] = cpvDigit->GetXpad() ; // column number of a pad
634 relid[3] = cpvDigit->GetYpad() ; // row number of a pad
636 // get the absolute Id number
637 GetGeometry()->RelToAbsNumbering(relid, absid) ;
639 // add current digit to the temporary hit list
643 xyze[3] = cpvDigit->GetQpad() ; // amplitude in a pad
644 primary = -1; // No need in primary for CPV
645 AddHit(fIshunt, primary, tracknumber, absid, xyze, trackpid, pmom, xyd);
647 if (cpvDigit->GetQpad() > 0.02) {
648 xmean += cpvDigit->GetQpad() * (cpvDigit->GetXpad() + 0.5);
649 zmean += cpvDigit->GetQpad() * (cpvDigit->GetYpad() + 0.5);
650 qsum += cpvDigit->GetQpad();
655 } // end of IHEP configuration
658 if(gMC->CurrentVolID(copy) == gMC->VolId("PXTL") ) { // We are inside a PBWO crystal
659 gMC->TrackPosition(pos) ;
663 xyze[3] = gMC->Edep() ;
666 if ( (xyze[3] != 0) || entered ) { // Track is inside the crystal and deposits some energy or just entered
668 gMC->CurrentVolOffID(10, relid[0]) ; // get the PHOS module number ;
670 if ( name == "MIXT" && strcmp(gMC->CurrentVolOffName(10),"PHO1") == 0 )
671 relid[0] += GetGeometry()->GetNModules() - GetGeometry()->GetNPPSDModules();
673 relid[1] = 0 ; // means PBW04
674 gMC->CurrentVolOffID(4, relid[2]) ; // get the row number inside the module
675 gMC->CurrentVolOffID(3, relid[3]) ; // get the cell number inside the module
677 // get the absolute Id number
678 GetGeometry()->RelToAbsNumbering(relid, absid) ;
680 // add current hit to the hit list
681 AddHit(fIshunt, primary,tracknumber, absid, xyze, trackpid,pmom, xyd);
684 } // there is deposited energy
685 } // we are inside a PHOS Xtal
690 //____________________________________________________________________________
691 void AliPHOSv1::CPVDigitize (TLorentzVector p, Float_t *zxhit, Int_t moduleNumber, TClonesArray *cpvDigits)
693 // ------------------------------------------------------------------------
694 // Digitize one CPV hit:
695 // On input take exact 4-momentum p and position zxhit of the hit,
696 // find the pad response around this hit and
697 // put the amplitudes in the pads into array digits
699 // Author: Yuri Kharlov (after Serguei Sadovsky)
701 // ------------------------------------------------------------------------
703 const Float_t kCelWr = GetGeometry()->GetPadSizePhi()/2; // Distance between wires (2 wires above 1 pad)
704 const Float_t kDetR = 0.1; // Relative energy fluctuation in track for 100 e-
705 const Float_t kdEdx = 4.0; // Average energy loss in CPV;
706 const Int_t kNgamz = 5; // Ionization size in Z
707 const Int_t kNgamx = 9; // Ionization size in Phi
708 const Float_t kNoise = 0.03; // charge noise in one pad
712 // Just a reminder on axes notation in the CPV module:
713 // axis Z goes along the beam
714 // axis X goes across the beam in the module plane
715 // axis Y is a normal to the module plane showing from the IP
717 Float_t hitX = zxhit[0];
718 Float_t hitZ =-zxhit[1];
721 Float_t pNorm = p.Py();
722 Float_t eloss = kdEdx;
724 Float_t dZY = pZ/pNorm * GetGeometry()->GetCPVGasThickness();
725 Float_t dXY = pX/pNorm * GetGeometry()->GetCPVGasThickness();
726 gRandom->Rannor(rnor1,rnor2);
727 eloss *= (1 + kDetR*rnor1) *
728 TMath::Sqrt((1 + ( pow(dZY,2) + pow(dXY,2) ) / pow(GetGeometry()->GetCPVGasThickness(),2)));
729 Float_t zhit1 = hitZ + GetGeometry()->GetCPVActiveSize(1)/2 - dZY/2;
730 Float_t xhit1 = hitX + GetGeometry()->GetCPVActiveSize(0)/2 - dXY/2;
731 Float_t zhit2 = zhit1 + dZY;
732 Float_t xhit2 = xhit1 + dXY;
734 Int_t iwht1 = (Int_t) (xhit1 / kCelWr); // wire (x) coordinate "in"
735 Int_t iwht2 = (Int_t) (xhit2 / kCelWr); // wire (x) coordinate "out"
739 if (iwht1==iwht2) { // incline 1-wire hit
741 zxe[0][0] = (zhit1 + zhit2 - dZY*0.57735) / 2;
742 zxe[1][0] = (iwht1 + 0.5) * kCelWr;
744 zxe[0][1] = (zhit1 + zhit2 + dZY*0.57735) / 2;
745 zxe[1][1] = (iwht1 + 0.5) * kCelWr;
748 else if (TMath::Abs(iwht1-iwht2) != 1) { // incline 3-wire hit
750 Int_t iwht3 = (iwht1 + iwht2) / 2;
751 Float_t xwht1 = (iwht1 + 0.5) * kCelWr; // wire 1
752 Float_t xwht2 = (iwht2 + 0.5) * kCelWr; // wire 2
753 Float_t xwht3 = (iwht3 + 0.5) * kCelWr; // wire 3
754 Float_t xwr13 = (xwht1 + xwht3) / 2; // center 13
755 Float_t xwr23 = (xwht2 + xwht3) / 2; // center 23
756 Float_t dxw1 = xhit1 - xwr13;
757 Float_t dxw2 = xhit2 - xwr23;
758 Float_t egm1 = TMath::Abs(dxw1) / ( TMath::Abs(dxw1) + TMath::Abs(dxw2) + kCelWr );
759 Float_t egm2 = TMath::Abs(dxw2) / ( TMath::Abs(dxw1) + TMath::Abs(dxw2) + kCelWr );
760 Float_t egm3 = kCelWr / ( TMath::Abs(dxw1) + TMath::Abs(dxw2) + kCelWr );
761 zxe[0][0] = (dXY*(xwr13-xwht1)/dXY + zhit1 + zhit1) / 2;
763 zxe[2][0] = eloss * egm1;
764 zxe[0][1] = (dXY*(xwr23-xwht1)/dXY + zhit1 + zhit2) / 2;
766 zxe[2][1] = eloss * egm2;
767 zxe[0][2] = dXY*(xwht3-xwht1)/dXY + zhit1;
769 zxe[2][2] = eloss * egm3;
771 else { // incline 2-wire hit
773 Float_t xwht1 = (iwht1 + 0.5) * kCelWr;
774 Float_t xwht2 = (iwht2 + 0.5) * kCelWr;
775 Float_t xwr12 = (xwht1 + xwht2) / 2;
776 Float_t dxw1 = xhit1 - xwr12;
777 Float_t dxw2 = xhit2 - xwr12;
778 Float_t egm1 = TMath::Abs(dxw1) / ( TMath::Abs(dxw1) + TMath::Abs(dxw2) );
779 Float_t egm2 = TMath::Abs(dxw2) / ( TMath::Abs(dxw1) + TMath::Abs(dxw2) );
780 zxe[0][0] = (zhit1 + zhit2 - dZY*egm1) / 2;
782 zxe[2][0] = eloss * egm1;
783 zxe[0][1] = (zhit1 + zhit2 + dZY*egm2) / 2;
785 zxe[2][1] = eloss * egm2;
788 // Finite size of ionization region
790 Int_t nCellZ = GetGeometry()->GetNumberOfCPVPadsZ();
791 Int_t nCellX = GetGeometry()->GetNumberOfCPVPadsPhi();
792 Int_t nz3 = (kNgamz+1)/2;
793 Int_t nx3 = (kNgamx+1)/2;
794 cpvDigits->Expand(nIter*kNgamx*kNgamz);
795 TClonesArray &ldigits = *(TClonesArray *)cpvDigits;
797 for (Int_t iter=0; iter<nIter; iter++) {
799 Float_t zhit = zxe[0][iter];
800 Float_t xhit = zxe[1][iter];
801 Float_t qhit = zxe[2][iter];
802 Float_t zcell = zhit / GetGeometry()->GetPadSizeZ();
803 Float_t xcell = xhit / GetGeometry()->GetPadSizePhi();
804 if ( zcell<=0 || xcell<=0 ||
805 zcell>=nCellZ || xcell>=nCellX) return;
806 Int_t izcell = (Int_t) zcell;
807 Int_t ixcell = (Int_t) xcell;
808 Float_t zc = zcell - izcell - 0.5;
809 Float_t xc = xcell - ixcell - 0.5;
810 for (Int_t iz=1; iz<=kNgamz; iz++) {
811 Int_t kzg = izcell + iz - nz3;
812 if (kzg<=0 || kzg>nCellZ) continue;
813 Float_t zg = (Float_t)(iz-nz3) - zc;
814 for (Int_t ix=1; ix<=kNgamx; ix++) {
815 Int_t kxg = ixcell + ix - nx3;
816 if (kxg<=0 || kxg>nCellX) continue;
817 Float_t xg = (Float_t)(ix-nx3) - xc;
819 // Now calculate pad response
820 Float_t qpad = CPVPadResponseFunction(qhit,zg,xg);
821 qpad += kNoise*rnor2;
822 if (qpad<0) continue;
824 // Fill the array with pad response ID and amplitude
825 new(ldigits[cpvDigits->GetEntriesFast()]) AliPHOSCPVDigit(kxg,kzg,qpad);
831 //____________________________________________________________________________
832 Float_t AliPHOSv1::CPVPadResponseFunction(Float_t qhit, Float_t zhit, Float_t xhit) {
833 // ------------------------------------------------------------------------
834 // Calculate the amplitude in one CPV pad using the
835 // cumulative pad response function
836 // Author: Yuri Kharlov (after Serguei Sadovski)
838 // ------------------------------------------------------------------------
840 Double_t dz = GetGeometry()->GetPadSizeZ() / 2;
841 Double_t dx = GetGeometry()->GetPadSizePhi() / 2;
842 Double_t z = zhit * GetGeometry()->GetPadSizeZ();
843 Double_t x = xhit * GetGeometry()->GetPadSizePhi();
844 Double_t amplitude = qhit *
845 (CPVCumulPadResponse(z+dz,x+dx) - CPVCumulPadResponse(z+dz,x-dx) -
846 CPVCumulPadResponse(z-dz,x+dx) + CPVCumulPadResponse(z-dz,x-dx));
847 return (Float_t)amplitude;
850 //____________________________________________________________________________
851 Double_t AliPHOSv1::CPVCumulPadResponse(Double_t x, Double_t y) {
852 // ------------------------------------------------------------------------
853 // Cumulative pad response function
854 // It includes several terms from the CF decomposition in electrostatics
855 // Note: this cumulative function is wrong since omits some terms
856 // but the cell amplitude obtained with it is correct because
857 // these omitting terms cancel
858 // Author: Yuri Kharlov (after Serguei Sadovski)
860 // ------------------------------------------------------------------------
862 const Double_t kA=1.0;
863 const Double_t kB=0.7;
865 Double_t r2 = x*x + y*y;
867 Double_t cumulPRF = 0;
868 for (Int_t i=0; i<=4; i++) {
869 Double_t b1 = (2*i + 1) * kB;
870 cumulPRF += TMath::Power(-1,i) * TMath::ATan( xy / (b1*TMath::Sqrt(b1*b1 + r2)) );
872 cumulPRF *= kA/(2*TMath::Pi());