1 ////////////////////////////////////////////////
2 // Manager and hits classes for set:PHOS //
3 ////////////////////////////////////////////////
14 // --- Standard library ---
19 // --- galice header files ---
23 //______________________________________________________________________________
28 //______________________________________________________________________________
30 AliPHOS::~AliPHOS(void)
32 delete fHits; // 28.12.1998
33 delete fTreePHOS; // 28.12.1998
38 //______________________________________________________________________________
43 fBranchNameOfCradles ("AliPHOSCradles"),
48 if( NULL==(fCradles=new TObjArray) )
50 Error("AliPHOS","Can not create fCradles");
56 //______________________________________________________________________________
58 AliPHOS::AliPHOS(const char *name, const char *title)
59 : AliDetector (name,title),
62 fBranchNameOfCradles ("AliPHOSCradles"),
67 <img src="picts/aliphos.gif">
71 fHits = new TClonesArray("AliPHOShit", 405);
75 SetMarkerColor(kGreen);
79 if( NULL==(fCradles=new TObjArray) ) {
80 Error("AliPHOS","Can not create fCradles");
86 //______________________________________________________________________________
88 void AliPHOS::DefPars()
133 //______________________________________________________________________________
135 void AliPHOS::AddHit(Int_t track, Int_t *vol, Float_t *hits)
137 TClonesArray &lhits = *fHits;
138 new(lhits[fNhits++]) AliPHOShit(fIshunt,track,vol,hits);
141 //___________________________________________
142 void AliPHOS::BuildGeometry()
147 const int kColorPHOS = kRed;
149 Top=gAlice->GetGeometry()->GetNode("alice");
153 Float_t pphi=12.9399462;
154 new TRotMatrix("rot988","rot988",90,-3*pphi,90,90-3*pphi,0,0);
155 new TRotMatrix("rot989","rot989",90,- pphi,90,90- pphi,0,0);
156 new TRotMatrix("rot990","rot990",90, pphi,90,90+ pphi,0,0);
157 new TRotMatrix("rot991","rot991",90, 3*pphi,90,90+3*pphi,0,0);
158 new TBRIK("S_PHOS","PHOS box","void",107.3,40,130);
160 Node = new TNode("PHOS1","PHOS1","S_PHOS",-317.824921,-395.014343,0,"rot988");
161 Node->SetLineColor(kColorPHOS);
164 Node = new TNode("PHOS2","PHOS2","S_PHOS",-113.532333,-494.124908,0,"rot989");
166 Node->SetLineColor(kColorPHOS);
168 Node = new TNode("PHOS3","PHOS3","S_PHOS", 113.532333,-494.124908,0,"rot990");
169 Node->SetLineColor(kColorPHOS);
172 Node = new TNode("PHOS4","PHOS4","S_PHOS", 317.824921,-395.014343,0,"rot991");
173 Node->SetLineColor(kColorPHOS);
177 //___________________________________________
178 void AliPHOS::CreateMaterials()
180 // *** DEFINITION OF AVAILABLE PHOS MATERIALS ***
182 // CALLED BY : PHOS_MEDIA
183 // ORIGIN : NICK VAN EIJNDHOVEN
187 Int_t ISXFLD = gAlice->Field()->Integ();
188 Float_t SXMGMX = gAlice->Field()->Max();
190 // --- The PbWO4 crystals ---
191 Float_t ax[3] = { 207.19,183.85,16. };
192 Float_t zx[3] = { 82.,74.,8. };
193 Float_t wx[3] = { 1.,1.,4. };
195 // --- Stainless Steel ---
196 Float_t as[5] = { 55.847,12.011,51.9961,58.69,28.0855 };
197 Float_t zs[5] = { 26.,6.,24.,28.,14. };
198 Float_t ws[5] = { .6392,8e-4,.2,.14,.02 };
200 // --- The polysterene scintillator (CH) ---
201 Float_t ap[2] = { 12.011,1.00794 };
202 Float_t zp[2] = { 6.,1. };
203 Float_t wp[2] = { 1.,1. };
206 Float_t at[2] = { 12.011,1.00794 };
207 Float_t zt[2] = { 6.,1. };
208 Float_t wt[2] = { 1.,2. };
210 // --- Polystyrene foam ---
211 Float_t af[2] = { 12.011,1.00794 };
212 Float_t zf[2] = { 6.,1. };
213 Float_t wf[2] = { 1.,1. };
215 //--- Foam thermo insulation (actual chemical composition unknown yet!) ---
216 Float_t ati[2] = { 12.011,1.00794 };
217 Float_t zti[2] = { 6.,1. };
218 Float_t wti[2] = { 1.,1. };
220 // --- Textolit (actual chemical composition unknown yet!) ---
221 Float_t atx[2] = { 12.011,1.00794 };
222 Float_t ztx[2] = { 6.,1. };
223 Float_t wtx[2] = { 1.,1. };
226 Int_t *idtmed = fIdtmed->GetArray()-699;
228 AliMixture( 0, "PbWO4$", ax, zx, dx, -3, wx);
229 AliMixture( 1, "Polystyrene$", ap, zp, dp, -2, wp);
230 AliMaterial( 2, "Al$", 26.98, 13., 2.7, 8.9, 999);
231 // --- Absorption length^ is ignored ---
232 AliMixture( 3, "Tyvek$", at, zt, dt, -2, wt);
233 AliMixture( 4, "Foam$", af, zf, df, -2, wf);
234 AliMixture( 5, "Stainless Steel$", as, zs, ds, 5, ws);
235 AliMaterial( 6, "Si$", 28.09, 14., 2.33, 9.36, 42.3);
236 AliMixture( 7, "Thermo Insul.$", ati, zti, dti, -2, wti);
237 AliMixture( 8, "Textolit$", atx, ztx, dtx, -2, wtx);
238 AliMaterial(99, "Air$", 14.61, 7.3, .001205, 30420., 67500);
240 AliMedium(0, "PHOS Xtal $", 0, 1, ISXFLD, SXMGMX, 10., .1, .1, .1, .1);
241 AliMedium(2, "Al parts $", 2, 0, ISXFLD, SXMGMX, 10., .1, .1, .001, .001);
242 AliMedium(3, "Tyvek wrapper$", 3, 0, ISXFLD, SXMGMX, 10., .1, .1, .001, .001);
243 AliMedium(4, "Polyst. foam $", 4, 0, ISXFLD, SXMGMX, 10., .1, .1, .1, .1);
244 AliMedium(5, "Steel cover $", 5, 0, ISXFLD, SXMGMX, 10., .1, .1, 1e-4, 1e-4);
245 AliMedium(6, "Si PIN $", 6, 0, ISXFLD, SXMGMX, 10., .1, .1, .01, .01);
246 AliMedium(7, "Thermo Insul.$", 7, 0, ISXFLD, SXMGMX, 10., .1, .1, .1, .1);
247 AliMedium(8, "Textolit $", 8, 0, ISXFLD, SXMGMX, 10., .1, .1, .1, .1);
248 AliMedium(99, "Air $",99, 0, ISXFLD, SXMGMX, 10., 1., .1, .1, 10);
250 // --- Generate explicitly delta rays in the steel cover ---
251 gMC->Gstpar(idtmed[704], "LOSS", 3.);
252 gMC->Gstpar(idtmed[704], "DRAY", 1.);
253 // --- and in aluminium parts ---
254 gMC->Gstpar(idtmed[701], "LOSS", 3.);
255 gMC->Gstpar(idtmed[701], "DRAY", 1.);
258 //______________________________________________________________________________
260 void AliPHOS::AddPHOSCradles()
263 for(i=0;i<GetCradlesAmount();i++) {
265 int n = fCradles->GetEntries();
266 fCradles->Add(new AliPHOSCradle( IsVersion(), // geometry.
267 GetCrystalSideSize (),
276 GetCradleAngle (i)));
278 if( n+1 != fCradles->GetEntries() || NULL == fCradles->At(n) )
280 cout << " Can not create or add AliPHOSCradle.\n";
286 //______________________________________________________________________________
288 Int_t AliPHOS::DistancetoPrimitive(Int_t , Int_t )
293 //___________________________________________
299 for(i=0;i<35;i++) printf("*");
300 printf(" PHOS_INIT ");
301 for(i=0;i<35;i++) printf("*");
304 // Here the ABSO initialisation code (if any!)
305 for(i=0;i<80;i++) printf("*");
309 //______________________________________________________________________________
311 void AliPHOS::MakeBranch(Option_t *)
313 // ROOT output initialization to ROOT file.
315 // AliDetector::MakeBranch() is always called.
317 // There will be also special tree "PHOS" with one branch "AliPHOSCradles"
318 // if it was set next flag in the galice card file:
319 // * PHOSflags: YES: X<>0 NO: X=0
320 // * PHOSflags(1) : -----X. Create branch for TObjArray of AliPHOSCradle
324 // In that case special bit CradlesBranch_Bit will be set for AliPHOS
326 AliDetector::MakeBranch();
329 float t = GetPHOS_flag(0)/10;
331 i = (int) ((t-i)*10);
335 SetBit(CradlesBranch_Bit);
337 if( NULL==(fTreePHOS=new TTree(fTreeName.Data(),"PHOS events tree")) )
339 Error("MakeBranch","Can not create TTree");
343 if( NULL==fTreePHOS->GetCurrentFile() )
345 Error("MakeBranch","There is no opened ROOT file");
349 // Create a new branch in the current Root Tree.
351 if( NULL==fTreePHOS->Branch(fBranchNameOfCradles.Data(),"TObjArray",&fCradles,4000,0) )
353 Error("MakeBranch","Can not create branch");
357 printf("The branch %s has been created\n",fBranchNameOfCradles.Data());
360 //______________________________________________________________________________
362 void AliPHOS::SetTreeAddress(void)
364 // ROOT input initialization.
366 // AliDetector::SetTreeAddress() is always called.
368 // If CradlesBranch_Bit is set (see AliPHOS::MakeBranch) than fTreePHOS is
371 AliDetector::SetTreeAddress();
373 if( !TestBit(CradlesBranch_Bit) )
376 if( NULL==(fTreePHOS=(TTree*)gDirectory->Get((char*)(fTreeName.Data())) ) )
378 Error("SetTreeAddress","Can not find Tree \"%s\"\n",fTreeName.Data());
382 TBranch *branch = fTreePHOS->GetBranch(fBranchNameOfCradles.Data());
385 Error("SetTreeAddress","Can not find branch %s in TTree:%s",fBranchNameOfCradles.Data(),fTreeName.Data());
389 branch->SetAddress(&fCradles);
392 //______________________________________________________________________________
394 AliPHOSCradle *AliPHOS::GetCradleOfTheParticle(const TVector3 &p,const TVector3 &v) const
396 // For a given direction 'p' and source point 'v' returns pointer to AliPHOSCradle
397 // in that direction or NULL if AliPHOSCradle was not found.
399 for( int m=0; m<fCradles->GetEntries(); m++ )
401 AliPHOS *PHOS = (AliPHOS *)this; // Removing 'const'...
402 AliPHOSCradle *cradle = (AliPHOSCradle *)PHOS->fCradles->operator[](m);
405 const float d = cradle->GetRadius();
406 cradle->GetXY(p,v,d,x,y,l);
408 if( l>0 && TMath::Abs(x)<cradle->GetNz ()*cradle->GetCellSideSize()/2
409 && TMath::Abs(y)<cradle->GetNphi()*cradle->GetCellSideSize()/2 )
416 //______________________________________________________________________________
418 void AliPHOS::Reconstruction(Float_t signal_step, UInt_t min_signal_reject)
420 // Call AliPHOSCradle::Reconstruction(Float_t signal_step, UInt_t min_signal_reject)
421 // for all AliPHOSCradles.
423 for( int i=0; i<fCradles->GetEntries(); i++ )
424 GetCradle(i).Reconstruction(signal_step,min_signal_reject);
427 //______________________________________________________________________________
429 void AliPHOS::ResetDigits(void)
431 AliDetector::ResetDigits();
433 for( int i=0; i<fCradles->GetEntries(); i++ )
434 ((AliPHOSCradle*)(*fCradles)[i]) -> Clear();
437 //______________________________________________________________________________
439 void AliPHOS::FinishEvent(void)
441 // Called at the end of each 'galice' event.
443 if( NULL!=fTreePHOS )
447 //______________________________________________________________________________
449 void AliPHOS::FinishRun(void)
453 //______________________________________________________________________________
455 void AliPHOS::Print(Option_t *opt)
457 // Print PHOS information.
458 // For each AliPHOSCradle the function AliPHOSCradle::Print(opt) is called.
460 AliPHOS &PHOS = *(AliPHOS *)this; // Removing 'const'...
462 for( int i=0; i<fCradles->GetEntries(); i++ )
464 printf("PHOS cradle %d from %d\n",i+1, fCradles->GetEntries());
465 PHOS.GetCradle(i).Print(opt);
466 printf( "---------------------------------------------------\n");
470 //______________________________________________________________________________
471 void AliPHOS::SetFlags(Float_t p1,Float_t p2,Float_t p3,Float_t p4,
472 Float_t p5,Float_t p6,Float_t p7,Float_t p8,Float_t p9)
485 //______________________________________________________________________________
486 void AliPHOS::SetCell(Float_t p1,Float_t p2,Float_t p3,Float_t p4,
487 Float_t p5,Float_t p6,Float_t p7,Float_t p8,Float_t p9)
500 //______________________________________________________________________________
501 void AliPHOS::SetRadius(Float_t radius)
506 //______________________________________________________________________________
507 void AliPHOS::SetCradleSize(Int_t nz, Int_t nphi, Int_t ncradles)
511 PHOSsize[2]=ncradles;
514 //______________________________________________________________________________
515 void AliPHOS::SetCradleA(Float_t angle)
520 //______________________________________________________________________________
521 void AliPHOS::SetExtra(Float_t p1,Float_t p2,Float_t p3,Float_t p4,
522 Float_t p5,Float_t p6,Float_t p7,Float_t p8,Float_t p9)
535 //______________________________________________________________________________
536 void AliPHOS::SetTextolitWall(Float_t dx, Float_t dy, Float_t dz)
543 //______________________________________________________________________________
544 void AliPHOS::SetInnerAir(Float_t dx, Float_t dy, Float_t dz)
551 //______________________________________________________________________________
552 void AliPHOS::SetFoam(Float_t dx, Float_t dy, Float_t dz, Float_t dr)
560 ClassImp(AliPHOSCradle)
562 //______________________________________________________________________________
564 AliPHOSCradle::AliPHOSCradle(void) {}
566 //______________________________________________________________________________
568 AliPHOSCradle::AliPHOSCradle( int Geometry ,
569 float CrystalSideSize ,
570 float CrystalLength ,
571 float WrapThickness ,
579 fGeometry (Geometry),
581 // fChargedTracksInPIN (),
582 fCrystalSideSize (CrystalSideSize),
583 fCrystalLength (CrystalLength),
584 fWrapThickness (WrapThickness),
585 fAirThickness (AirThickness),
586 fPIN_SideSize (PIN_SideSize),
587 fPIN_Length (PIN_Length),
593 fCellEnergy = TH2F("CellE","Energy deposition in a cells",fNz,0,fNz,fNphi,0,fNphi);
594 fCellEnergy .SetDirectory(0);
595 fChargedTracksInPIN = TH2S("PINCtracks","Amount of charged tracks in PIN",fNz,0,fNz,fNphi,0,fNphi);
596 fChargedTracksInPIN .SetDirectory(0);
599 //______________________________________________________________________________
601 AliPHOSCradle::~AliPHOSCradle(void) // 28.12.1998
603 fGammasReconstructed.Delete();
604 fParticles .Delete();
607 //______________________________________________________________________________
609 void AliPHOSCradle::Clear(Option_t *)
611 // Clear digit. information.
613 fCellEnergy .Reset();
614 fChargedTracksInPIN .Reset();
615 GetParticles() .Delete();
616 GetParticles() .Compress();
617 GetGammasReconstructed() .Delete();
618 GetGammasReconstructed() .Compress();
622 //______________________________________________________________________________
624 void AliPHOSCradle::GetXY(const TVector3 &p,const TVector3 &v,float R,float &x,float &y,float &l) const
626 // This function calculates hit position (x,y) in the CRADLE cells plain from particle in
627 // the direction given by 'p' (not required to be normalized) and start point
628 // given by 3-vector 'v'. So the particle trajectory is t(l) = v + p*l
629 // were 'l' is a number (distance from 'v' to CRADLE cells plain) and 't' is resulting
630 // three-vector of trajectory point.
632 // After the call to this function user should test that l>=0 (the particle HITED the
633 // plain) and (x,y) are in the region of CRADLE:
636 // AliPHOSCradle cradle(......);
637 // TVector3 p(....), v(....);
639 // cradle.GetXY(p,v,x,y,l);
640 // if( l<0 || TMath::Abs(x)>cradle.GetNz() *cradle.GetCellSideSize()/2
641 // || TMath::Abs(y)>cradle.GetNphi()*cradle.GetCellSideSize()/2 )
642 // cout << "Outside the CRADLE.\n";
644 // We have to create three vectors:
645 // s - central point on the PHOS surface
646 // n1 - first vector in CRADLE plain
647 // n2 - second vector in CRADLE plain
648 // This three vectors are orthonormalized.
650 double phi = fPhi/180*TMath::Pi();
651 TVector3 n1( 0.0 , 0.0 , 1.0 ), // Z direction (X)
652 n2( -sin(phi) , cos(phi) , 0 ), // around beam (Y)
653 s ( R*cos(phi) , R*sin(phi) , 0 ); // central point
655 const double l1_min = 1e-2;
657 p_n1 = p*n1, // * - scalar product.
664 if ( TMath::Abs(l1=p.X()-n1.X()*p_n1-n2.X()*p_n2)>l1_min )
665 { l = (-v.X()+s.X()+n1.X()*(v_n1-s_n1)+n2.X()*(v_n2-s_n2))/l1; }
666 else if ( TMath::Abs(l1=p.Y()-n1.Y()*p_n1-n2.Y()*p_n2)>l1_min )
667 { l = (-v.Y()+s.Y()+n1.Y()*(v_n1-s_n1)+n2.Y()*(v_n2-s_n2))/l1; }
668 else if ( TMath::Abs(l1=p.Z()-n1.Z()*p_n1-n2.Z()*p_n2)>l1_min )
669 { l = (-v.Z()+s.Z()+n1.Z()*(v_n1-s_n1)+n2.Z()*(v_n2-s_n2))/l1; }
671 // double lx = (-v.X()+s.X()+n1.X()*(v.dot(n1)-s.dot(n1))+n2.X()*(v.dot(n2)-s.dot(n2)))/
672 // (p.X()-n1.X()*p.dot(n1)-n2.X()*p.dot(n2)),
673 // ly = (-v.Y()+s.Y()+n1.Y()*(v.dot(n1)-s.dot(n1))+n2.Y()*(v.dot(n2)-s.dot(n2)))/
674 // (p.Y()-n1.Y()*p.dot(n1)-n2.Y()*p.dot(n2)),
675 // lz = (-v.Z()+s.Z()+n1.Z()*(v.dot(n1)-s.dot(n1))+n2.Z()*(v.dot(n2)-s.dot(n2)))/
676 // (p.Z()-n1.Z()*p.dot(n1)-n2.Z()*p.dot(n2));
677 // cout.form("x: %g %g %g %g\n",lx,-v.X()+s.X()+n1.X()*(v.dot(n1)-s.dot(n1))+n2.X()*(v.dot(n2)-s.dot(n2)),p.X()-n1.X()*p.dot(n1)-n2.X()*p.dot(n2));
678 // cout.form("y: %g %g %g %g\n",lx,-v.Y()+s.Y()+n1.Y()*(v.dot(n1)-s.dot(n1))+n2.Y()*(v.dot(n2)-s.dot(n2)),p.Y()-n1.Y()*p.dot(n1)-n2.Y()*p.dot(n2));
679 // cout.form("z: %g %g %g %g\n",lx,-v.Z()+s.Z()+n1.Z()*(v.dot(n1)-s.dot(n1))+n2.Z()*(v.dot(n2)-s.dot(n2)),p.Z()-n1.Z()*p.dot(n1)-n2.Z()*p.dot(n2));
680 // cout.form("lx,ly,lz = %g,%g,%g\n",lx,ly,lz);
682 x = p_n1*l + v_n1 - s_n1;
683 y = p_n2*l + v_n2 - s_n2;
686 //______________________________________________________________________________
688 void AliPHOSCradle::Print(Option_t *opt)
690 // Print AliPHOSCradle information.
692 // options: 'd' - print energy deposition for EVERY cell
693 // 'p' - print particles list that hit the cradle
694 // 'r' - print list of reconstructed particles
696 AliPHOSCradle *cr = (AliPHOSCradle *)this; // Removing 'const'...
698 printf("AliPHOSCradle: Nz=%d Nphi=%d, fPhi=%f, E=%g\n",fNz,fNphi,fPhi,
699 cr->fCellEnergy.GetSumOfWeights());
701 if( NULL!=strchr(opt,'d') )
703 printf("\n\nCells Energy (in MeV):\n\n |");
704 for( int x=0; x<fNz; x++ )
708 for( int y=fNphi-1; y>=0; y-- )
711 for( int x=0; x<fNz; x++ )
712 printf("%6d",(int)(cr->fCellEnergy.GetBinContent(cr->fCellEnergy.GetBin(x,y))*1000));
718 if( NULL!=strchr(opt,'p') )
720 printf("This cradle was hit by %d particles\n",
721 ((AliPHOSCradle*)this)->GetParticles().GetEntries());
722 TObjArray &p=((AliPHOSCradle*)this)->GetParticles();
723 for( int i=0; i<p.GetEntries(); i++ )
724 ((AliPHOSgamma*)(p[i]))->Print();
727 if( NULL!=strchr(opt,'p') )
729 printf("Amount of reconstructed gammas is %d\n",
730 ((AliPHOSCradle*)this)->GetGammasReconstructed().GetEntries());
732 TObjArray &p=((AliPHOSCradle*)this)->GetGammasReconstructed();
733 for( int i=0; i<p.GetEntries(); i++ )
734 ((AliPHOSgamma*)(p[i]))->Print();
738 //______________________________________________________________________________
740 void AliPHOSCradle::Distortion(const TH2F *Noise, const TH2F *Stochastic, const TH2F *Calibration)
742 // This function changes histogram of cell energies fCellEnergy on the base of input
743 // histograms Noise, Stochastic, Calibration. The histograms must have
746 //////////////////////////////////
747 // Testing the histograms size. //
748 //////////////////////////////////
750 if( fNz!=fCellEnergy.GetNbinsX() || fNphi!=fCellEnergy.GetNbinsY() )
752 printf ("Bad size of CellEnergy! Must be: Nz x Nphi = %d x %d\n"
753 "but size of CellEnergy is: %d x %d\n",
754 fNz,fNphi,fCellEnergy.GetNbinsX(),fCellEnergy.GetNbinsY());
758 if( fNz!=fChargedTracksInPIN.GetNbinsX() || fNphi!=fChargedTracksInPIN.GetNbinsY() )
760 printf ("Bad size of ChargedTracksInPIN! Must be: Nz x Nphi = %d x %d\n"
761 "but size of ChargedTracksInPIN is: %d x %d\n",
762 fNz,fNphi,fChargedTracksInPIN.GetNbinsX(),fChargedTracksInPIN.GetNbinsY());
766 if( NULL!=Noise && (fNz!=Noise->GetNbinsX() || fNphi!=Noise->GetNbinsX()) )
768 printf ("Bad size of Noise! Must be: Nz x Nphi = %d x %d\n"
769 "but size of Noise is: %d x %d\n",
770 fNz,fNphi,fChargedTracksInPIN.GetNbinsX(),fChargedTracksInPIN.GetNbinsY());
774 if( NULL!=Stochastic && (fNz!=Stochastic->GetNbinsX() || fNphi!=Stochastic->GetNbinsX()) )
776 printf ("Bad size of Stochastic! Must be: Nz x Nphi = %d x %d\n"
777 "but size of Stochastic is: %d x %d\n",
778 fNz,fNphi,fChargedTracksInPIN.GetNbinsX(),fChargedTracksInPIN.GetNbinsY());
782 if( NULL!=Calibration && (fNz!=Calibration->GetNbinsX() || fNphi!=Calibration->GetNbinsX()) )
784 printf ("Bad size of Calibration! Must be: Nz x Nphi = %d x %d\n"
785 "but size of Calibration is: %d x %d\n",
786 fNz,fNphi,fChargedTracksInPIN.GetNbinsX(),fChargedTracksInPIN.GetNbinsY());
794 for( int y=0; y<fNphi; y++ )
795 for( int x=0; x<fNz; x++ )
797 const int n = fCellEnergy.GetBin(x,y); // Bin number
800 Float_t E_old=fCellEnergy.GetBinContent(n), E_new=E_old;
802 if( NULL!=Stochastic )
803 E_new = r.Gaus(E_old,sqrt(E_old)*GetDistortedValue(Stochastic,n));
805 if( NULL!=Calibration )
806 E_new *= GetDistortedValue(Calibration,n);
809 E_new += GetDistortedValue(Noise,n);
811 fCellEnergy.SetBinContent(n,E_new);
815 ////////////////////////////////////////////////////////////////////////////////
817 TH2F* AliPHOSCradle::CreateHistForDistortion(const char *name, const char *title,
819 Float_t MU_mu, Float_t MU_sigma,
820 Float_t SIGMA_mu, Float_t SIGMA_sigma)
822 // Create (new TH2F(...)) histogram with information (for every bin) that will
823 // be used for VALUE creation.
824 // Two values will be created for each bin:
825 // MU = TRandom::Gaus(MU_mu,MU_sigma)
827 // SIGMA = TRandom::Gaus(SIGMA_mu,SIGMA_sigma)
828 // The VALUE in a particluar bin will be equal
829 // VALUE = TRandom::Gaus(MU,SIGMA)
831 // Do not forget to delete the histogram at the end of the work.
833 TH2F *h = new TH2F( name,title, Nx,1,Nx, Ny,1,Ny );
836 Error("CreateHistForDistortion","Can not create the histogram");
841 for( int y=0; y<Ny; y++ )
842 for( int x=0; x<Nx; x++ )
844 const int n = h->GetBin(x,y);
845 h->SetBinContent(n,r.Gaus( MU_mu, MU_sigma));
846 h->SetBinError (n,r.Gaus(SIGMA_mu,SIGMA_sigma));
852 ////////////////////////////////////////////////////////////////////////////////
854 Float_t AliPHOSCradle::GetDistortedValue(const TH2F *h, UInt_t n)
856 return r.Gaus(((TH2F*)h)->GetBinContent(n),n);
859 ////////////////////////////////////////////////////////////////////////////////
860 //______________________________________________________________________________
863 #define common_for_event_storing COMMON_FOR_EVENT_STORING
865 #define common_for_event_storing common_for_event_storing_
870 enum { crystals_matrix_amount_max=4, crystals_in_matrix_amount_max=40000 };
872 // Event-independent information
873 UShort_t crystals_matrix_amount_PHOS,
875 amount_of_crystals_on_Z,
876 amount_of_crystals_on_PHI;
880 matrix_coordinate_Z [crystals_matrix_amount_max],
881 matrix_coordinate_PHI [crystals_matrix_amount_max];
883 UShort_t crystals_amount_with_amplitudes [crystals_matrix_amount_max],
884 crystals_amplitudes_Iad [crystals_matrix_amount_max]
885 [crystals_in_matrix_amount_max][2];
886 } common_for_event_storing;
888 // integer*4 crystals_amount_max,crystals_in_matrix_amount_max,
889 // + crystals_matrix_amount_max
890 // parameter (crystals_matrix_amount_max=4)
891 // parameter (crystals_in_matrix_amount_max=40000)
892 // parameter (crystals_amount_max =crystals_matrix_amount_max*
893 // + crystals_in_matrix_amount_max)
895 // * All units are in GeV, cm, radian
896 // real crystal_amplitudes_unit, radius_unit,
897 // + crystal_size_unit, crystal_length_unit,
898 // + matrix_coordinate_Z_unit, matrix_coordinate_PHI_unit
899 // integer crystal_amplitudes_in_units_min
900 // parameter (crystal_amplitudes_in_units_min = 1)
901 // parameter (crystal_amplitudes_unit = 0.001 ) ! 1.0 MeV
902 // parameter (radius_unit = 0.1 ) ! 0.1 cm
903 // parameter (crystal_size_unit = 0.01 ) ! 0.01 cm
904 // parameter (crystal_length_unit = 0.01 ) ! 0.01 cm
905 // parameter (matrix_coordinate_Z_unit = 0.1 ) ! 0.1 cm
906 // parameter (matrix_coordinate_PHI_unit = 1e-4 ) ! 1e-4 radian
908 // integer*2 crystals_matrix_amount_PHOS, crystal_matrix_type,
909 // + amount_of_crystals_on_Z, amount_of_crystals_on_PHI,
910 // + crystals_amount_with_amplitudes, crystals_amplitudes_Iad
911 // integer*4 event_number
913 // real radius, crystal_size, crystal_length,
914 // + matrix_coordinate_Z, matrix_coordinate_PHI
916 // real crystals_amplitudes, crystals_energy_total
917 // integer event_file_unit_number
919 // common /common_for_event_storing/
920 // + ! Event-independent information
921 // + crystals_matrix_amount_PHOS,
922 // + crystal_matrix_type,
923 // + amount_of_crystals_on_Z,
924 // + amount_of_crystals_on_PHI,
928 // + matrix_coordinate_Z (crystals_matrix_amount_max),
929 // + matrix_coordinate_PHI (crystals_matrix_amount_max),
931 // + ! Event-dependent information
933 // + crystals_amount_with_amplitudes
934 // + (crystals_matrix_amount_max),
935 // + crystals_amplitudes_Iad (2,crystals_in_matrix_amount_max,
936 // + crystals_matrix_amount_max),
938 // + ! These information don't store in data file
939 // + crystals_amplitudes (crystals_amount_max),
940 // + crystals_energy_total,
941 // + event_file_unit_number
944 // parameter (NGp=1000,nsps=10,nvertmax=1000)
945 // COMMON /GAMMA/KG,MW(ngp),ID(ngp),JD(ngp),E(ngp),E4(ngp),
946 // , XW(ngp),YW(ngp),ES(nsps,ngp),ET(nsps,ngp),ISsd(ngp),
947 // , IGDEV(ngp),ZGDEV(ngp),sigexy(3,ngp),Emimx(2,nsps,ngp),
948 // , kgfix,igfix(ngp),cgfix(3,ngp),sgfix(3,ngp),hiw(ngp),
949 // , wsw(nsps,ngp),h1w(ngp),h0w(ngp),raxay(5,ngp),
950 // , sigmaes0(nsps,ngp),dispeces(nsps,ngp),
955 #define rcgamma RCGAMMA
957 #define rcgamma rcgamma_
962 enum {NGP=1000, nsps=10, nvertmax=1000};
963 int recons_gammas_amount, mw[NGP],ID[NGP],JD[NGP];
964 float E[NGP], E4[NGP], XW[NGP], YW[NGP], ES[NGP][nsps],ET[NGP][nsps],ISsd[NGP],
965 igdev[NGP],Zgdev[NGP];
966 // sigexy(3,ngp),Emimx(2,nsps,ngp),
967 // , kgfix,igfix(ngp),cgfix(3,ngp),sgfix(3,ngp),hiw(ngp),
968 // , wsw(nsps,ngp),h1w(ngp),h0w(ngp),raxay(5,ngp),
969 // , sigmaes0(nsps,ngp),dispeces(nsps,ngp),
974 #define reconsfirst RECONSFIRST
975 #define type_of_call _stdcall
977 #define reconsfirst reconsfirst_
981 extern "C" void type_of_call reconsfirst(const float &,const float &);
983 void AliPHOSCradle::Reconstruction(Float_t signal_step, UInt_t min_signal_reject)
985 // Call of PHOS reconstruction program.
986 // signal_step=0.001 GeV (1MeV)
987 // min_signal_reject = 15 or 30 MeV
990 common_for_event_storing.event_number = 0; // We do not know event number?
991 common_for_event_storing.crystals_matrix_amount_PHOS = 1;
992 common_for_event_storing.crystal_matrix_type = 1; // 1 - rectangular
993 common_for_event_storing.amount_of_crystals_on_Z = fNz;
994 common_for_event_storing.amount_of_crystals_on_PHI = fNphi;
996 common_for_event_storing.radius = fRadius;
997 common_for_event_storing.crystal_size = GetCellSideSize();
998 common_for_event_storing.crystal_length = fCrystalLength;
1000 common_for_event_storing.matrix_coordinate_Z [0] = 0;
1001 common_for_event_storing.matrix_coordinate_PHI [0] = fPhi;
1003 #define k common_for_event_storing.crystals_amount_with_amplitudes[0]
1006 for( int y=0; y<fNphi; y++ )
1007 for( int x=0; x<fNz; x++ )
1009 UInt_t n = fCellEnergy.GetBin(x,y);
1010 UInt_t signal = (int) (fCellEnergy.GetBinContent(n)/signal_step);
1011 if( signal>=min_signal_reject )
1013 common_for_event_storing.crystals_amplitudes_Iad[0][k][0] = signal;
1014 common_for_event_storing.crystals_amplitudes_Iad[0][k][1] = x + y*fNz;
1020 GetGammasReconstructed().Delete();
1021 GetGammasReconstructed().Compress();
1023 const float stochastic_term = 0.03, // per cents over sqrt(E); E in GeV
1024 electronic_noise = 0.01; // GeV
1025 reconsfirst(stochastic_term,electronic_noise); // Call of reconstruction program.
1027 for( int i=0; i<rcgamma.recons_gammas_amount; i++ )
1029 // new (GetGammasReconstructed().UncheckedAt(i) ) AliPHOSgamma;
1030 // AliPHOSgamma &g = *(AliPHOSgamma*)(GetGammasReconstructed().UncheckedAt(i));
1032 AliPHOSgamma *gggg = new AliPHOSgamma;
1035 Error("Reconstruction","Can not create AliPHOSgamma");
1039 GetGammasReconstructed().Add(gggg);
1040 AliPHOSgamma &g=*gggg;
1042 Float_t thetta, alpha, betta, R=fRadius+rcgamma.Zgdev[i]/10;
1044 g.fX = rcgamma.YW[i]/10;
1045 g.fY = rcgamma.XW[i]/10;
1046 g.fE = rcgamma.E [i];
1048 thetta = atan(g.fX/R);
1050 alpha = atan(g.fY/R);
1051 betta = fPhi/180*TMath::Pi() + alpha;
1053 g.fPx = g.fE * cos(thetta) * cos(betta);
1054 g.fPy = g.fE * cos(thetta) * sin(betta);
1055 g.fPz = g.fE * sin(thetta);
1059 //______________________________________________________________________________
1060 //______________________________________________________________________________
1061 //______________________________________________________________________________
1062 //______________________________________________________________________________
1063 //______________________________________________________________________________
1065 ClassImp(AliPHOSgamma)
1067 //______________________________________________________________________________
1069 void AliPHOSgamma::Print(Option_t *)
1071 float mass = fE*fE - fPx*fPx - fPy*fPy - fPz*fPz;
1076 mass = -sqrt(-mass);
1078 printf("XY=(%+7.2f,%+7.2f) (%+7.2f,%+7.2f,%+7.2f;%7.2f) mass=%8.4f Ipart=%2d\n",
1079 fX,fY,fPx,fPy,fPz,fE,mass,fIpart);
1082 //______________________________________________________________________________
1084 AliPHOSgamma &AliPHOSgamma::operator=(const AliPHOSgamma &g)
1097 //______________________________________________________________________________
1098 //______________________________________________________________________________
1099 //______________________________________________________________________________
1100 //______________________________________________________________________________
1101 //______________________________________________________________________________
1103 ClassImp(AliPHOShit)
1105 //______________________________________________________________________________
1107 AliPHOShit::AliPHOShit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits):
1108 AliHit(shunt, track)
1111 for (i=0;i<5;i++) fVolume[i] = vol[i];
1118 //______________________________________________________________________________