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 **************************************************************************/
20 ////////////////////////////////////////////////
21 // Manager and hits classes for set:PHOS //
22 ////////////////////////////////////////////////
24 // --- ROOT system ---
33 // --- Standard library ---
38 // --- galice header files ---
42 //______________________________________________________________________________
47 //______________________________________________________________________________
49 AliPHOS::~AliPHOS(void)
51 delete fHits; // 28.12.1998
52 delete fTreePHOS; // 28.12.1998
57 //______________________________________________________________________________
62 fBranchNameOfCradles ("AliPHOSCradles"),
67 if( NULL==(fCradles=new TObjArray) )
69 Error("AliPHOS","Can not create fCradles");
75 //______________________________________________________________________________
77 AliPHOS::AliPHOS(const char *name, const char *title)
78 : AliDetector (name,title),
81 fBranchNameOfCradles ("AliPHOSCradles"),
86 <img src="picts/aliphos.gif">
90 fHits = new TClonesArray("AliPHOShit", 405);
94 SetMarkerColor(kGreen);
98 if( NULL==(fCradles=new TObjArray) ) {
99 Error("AliPHOS","Can not create fCradles");
105 //______________________________________________________________________________
107 void AliPHOS::DefPars()
152 //______________________________________________________________________________
154 void AliPHOS::AddHit(Int_t track, Int_t *vol, Float_t *hits)
156 TClonesArray &lhits = *fHits;
157 new(lhits[fNhits++]) AliPHOShit(fIshunt,track,vol,hits);
160 //___________________________________________
161 void AliPHOS::BuildGeometry()
166 const int kColorPHOS = kRed;
168 Top=gAlice->GetGeometry()->GetNode("alice");
172 Float_t pphi=12.9399462;
173 new TRotMatrix("rot988","rot988",90,-3*pphi,90,90-3*pphi,0,0);
174 new TRotMatrix("rot989","rot989",90,- pphi,90,90- pphi,0,0);
175 new TRotMatrix("rot990","rot990",90, pphi,90,90+ pphi,0,0);
176 new TRotMatrix("rot991","rot991",90, 3*pphi,90,90+3*pphi,0,0);
177 new TBRIK("S_PHOS","PHOS box","void",107.3,40,130);
179 Node = new TNode("PHOS1","PHOS1","S_PHOS",-317.824921,-395.014343,0,"rot988");
180 Node->SetLineColor(kColorPHOS);
183 Node = new TNode("PHOS2","PHOS2","S_PHOS",-113.532333,-494.124908,0,"rot989");
185 Node->SetLineColor(kColorPHOS);
187 Node = new TNode("PHOS3","PHOS3","S_PHOS", 113.532333,-494.124908,0,"rot990");
188 Node->SetLineColor(kColorPHOS);
191 Node = new TNode("PHOS4","PHOS4","S_PHOS", 317.824921,-395.014343,0,"rot991");
192 Node->SetLineColor(kColorPHOS);
196 //___________________________________________
197 void AliPHOS::CreateMaterials()
199 // *** DEFINITION OF AVAILABLE PHOS MATERIALS ***
201 // CALLED BY : PHOS_MEDIA
202 // ORIGIN : NICK VAN EIJNDHOVEN
206 Int_t ISXFLD = gAlice->Field()->Integ();
207 Float_t SXMGMX = gAlice->Field()->Max();
209 // --- The PbWO4 crystals ---
210 Float_t ax[3] = { 207.19,183.85,16. };
211 Float_t zx[3] = { 82.,74.,8. };
212 Float_t wx[3] = { 1.,1.,4. };
214 // --- Stainless Steel ---
215 Float_t as[5] = { 55.847,12.011,51.9961,58.69,28.0855 };
216 Float_t zs[5] = { 26.,6.,24.,28.,14. };
217 Float_t ws[5] = { .6392,8e-4,.2,.14,.02 };
219 // --- The polysterene scintillator (CH) ---
220 Float_t ap[2] = { 12.011,1.00794 };
221 Float_t zp[2] = { 6.,1. };
222 Float_t wp[2] = { 1.,1. };
225 Float_t at[2] = { 12.011,1.00794 };
226 Float_t zt[2] = { 6.,1. };
227 Float_t wt[2] = { 1.,2. };
229 // --- Polystyrene foam ---
230 Float_t af[2] = { 12.011,1.00794 };
231 Float_t zf[2] = { 6.,1. };
232 Float_t wf[2] = { 1.,1. };
234 //--- Foam thermo insulation (actual chemical composition unknown yet!) ---
235 Float_t ati[2] = { 12.011,1.00794 };
236 Float_t zti[2] = { 6.,1. };
237 Float_t wti[2] = { 1.,1. };
239 // --- Textolit (actual chemical composition unknown yet!) ---
240 Float_t atx[2] = { 12.011,1.00794 };
241 Float_t ztx[2] = { 6.,1. };
242 Float_t wtx[2] = { 1.,1. };
245 Int_t *idtmed = fIdtmed->GetArray()-699;
247 AliMixture( 0, "PbWO4$", ax, zx, dx, -3, wx);
248 AliMixture( 1, "Polystyrene$", ap, zp, dp, -2, wp);
249 AliMaterial( 2, "Al$", 26.98, 13., 2.7, 8.9, 999);
250 // --- Absorption length^ is ignored ---
251 AliMixture( 3, "Tyvek$", at, zt, dt, -2, wt);
252 AliMixture( 4, "Foam$", af, zf, df, -2, wf);
253 AliMixture( 5, "Stainless Steel$", as, zs, ds, 5, ws);
254 AliMaterial( 6, "Si$", 28.09, 14., 2.33, 9.36, 42.3);
255 AliMixture( 7, "Thermo Insul.$", ati, zti, dti, -2, wti);
256 AliMixture( 8, "Textolit$", atx, ztx, dtx, -2, wtx);
257 AliMaterial(99, "Air$", 14.61, 7.3, .001205, 30420., 67500);
259 AliMedium(0, "PHOS Xtal $", 0, 1, ISXFLD, SXMGMX, 10., .1, .1, .1, .1);
260 AliMedium(2, "Al parts $", 2, 0, ISXFLD, SXMGMX, 10., .1, .1, .001, .001);
261 AliMedium(3, "Tyvek wrapper$", 3, 0, ISXFLD, SXMGMX, 10., .1, .1, .001, .001);
262 AliMedium(4, "Polyst. foam $", 4, 0, ISXFLD, SXMGMX, 10., .1, .1, .1, .1);
263 AliMedium(5, "Steel cover $", 5, 0, ISXFLD, SXMGMX, 10., .1, .1, 1e-4, 1e-4);
264 AliMedium(6, "Si PIN $", 6, 0, ISXFLD, SXMGMX, 10., .1, .1, .01, .01);
265 AliMedium(7, "Thermo Insul.$", 7, 0, ISXFLD, SXMGMX, 10., .1, .1, .1, .1);
266 AliMedium(8, "Textolit $", 8, 0, ISXFLD, SXMGMX, 10., .1, .1, .1, .1);
267 AliMedium(99, "Air $",99, 0, ISXFLD, SXMGMX, 10., 1., .1, .1, 10);
269 // --- Generate explicitly delta rays in the steel cover ---
270 gMC->Gstpar(idtmed[704], "LOSS", 3.);
271 gMC->Gstpar(idtmed[704], "DRAY", 1.);
272 // --- and in aluminium parts ---
273 gMC->Gstpar(idtmed[701], "LOSS", 3.);
274 gMC->Gstpar(idtmed[701], "DRAY", 1.);
277 //______________________________________________________________________________
279 void AliPHOS::AddPHOSCradles()
282 for(i=0;i<GetCradlesAmount();i++) {
284 int n = fCradles->GetEntries();
285 fCradles->Add(new AliPHOSCradle( IsVersion(), // geometry.
286 GetCrystalSideSize (),
295 GetCradleAngle (i)));
297 if( n+1 != fCradles->GetEntries() || NULL == fCradles->At(n) )
299 cout << " Can not create or add AliPHOSCradle.\n";
305 //______________________________________________________________________________
307 Int_t AliPHOS::DistancetoPrimitive(Int_t , Int_t )
312 //___________________________________________
318 for(i=0;i<35;i++) printf("*");
319 printf(" PHOS_INIT ");
320 for(i=0;i<35;i++) printf("*");
323 // Here the ABSO initialisation code (if any!)
324 for(i=0;i<80;i++) printf("*");
328 //______________________________________________________________________________
330 void AliPHOS::MakeBranch(Option_t *)
332 // ROOT output initialization to ROOT file.
334 // AliDetector::MakeBranch() is always called.
336 // There will be also special tree "PHOS" with one branch "AliPHOSCradles"
337 // if it was set next flag in the galice card file:
338 // * PHOSflags: YES: X<>0 NO: X=0
339 // * PHOSflags(1) : -----X. Create branch for TObjArray of AliPHOSCradle
343 // In that case special bit CradlesBranch_Bit will be set for AliPHOS
345 AliDetector::MakeBranch();
348 float t = GetPHOS_flag(0)/10;
350 i = (int) ((t-i)*10);
354 SetBit(CradlesBranch_Bit);
356 if( NULL==(fTreePHOS=new TTree(fTreeName.Data(),"PHOS events tree")) )
358 Error("MakeBranch","Can not create TTree");
362 if( NULL==fTreePHOS->GetCurrentFile() )
364 Error("MakeBranch","There is no opened ROOT file");
368 // Create a new branch in the current Root Tree.
370 if( NULL==fTreePHOS->Branch(fBranchNameOfCradles.Data(),"TObjArray",&fCradles,4000,0) )
372 Error("MakeBranch","Can not create branch");
376 printf("The branch %s has been created\n",fBranchNameOfCradles.Data());
379 //______________________________________________________________________________
381 void AliPHOS::SetTreeAddress(void)
383 // ROOT input initialization.
385 // AliDetector::SetTreeAddress() is always called.
387 // If CradlesBranch_Bit is set (see AliPHOS::MakeBranch) than fTreePHOS is
390 AliDetector::SetTreeAddress();
392 if( !TestBit(CradlesBranch_Bit) )
395 if( NULL==(fTreePHOS=(TTree*)gDirectory->Get((char*)(fTreeName.Data())) ) )
397 Error("SetTreeAddress","Can not find Tree \"%s\"\n",fTreeName.Data());
401 TBranch *branch = fTreePHOS->GetBranch(fBranchNameOfCradles.Data());
404 Error("SetTreeAddress","Can not find branch %s in TTree:%s",fBranchNameOfCradles.Data(),fTreeName.Data());
408 branch->SetAddress(&fCradles);
411 //______________________________________________________________________________
413 AliPHOSCradle *AliPHOS::GetCradleOfTheParticle(const TVector3 &p,const TVector3 &v) const
415 // For a given direction 'p' and source point 'v' returns pointer to AliPHOSCradle
416 // in that direction or NULL if AliPHOSCradle was not found.
418 for( int m=0; m<fCradles->GetEntries(); m++ )
420 AliPHOS *PHOS = (AliPHOS *)this; // Removing 'const'...
421 AliPHOSCradle *cradle = (AliPHOSCradle *)PHOS->fCradles->operator[](m);
424 const float d = cradle->GetRadius();
425 cradle->GetXY(p,v,d,x,y,l);
427 if( l>0 && TMath::Abs(x)<cradle->GetNz ()*cradle->GetCellSideSize()/2
428 && TMath::Abs(y)<cradle->GetNphi()*cradle->GetCellSideSize()/2 )
435 //______________________________________________________________________________
437 void AliPHOS::Reconstruction(Float_t signal_step, UInt_t min_signal_reject)
439 // Call AliPHOSCradle::Reconstruction(Float_t signal_step, UInt_t min_signal_reject)
440 // for all AliPHOSCradles.
442 for( int i=0; i<fCradles->GetEntries(); i++ )
443 GetCradle(i).Reconstruction(signal_step,min_signal_reject);
446 //______________________________________________________________________________
448 void AliPHOS::ResetDigits(void)
450 AliDetector::ResetDigits();
452 for( int i=0; i<fCradles->GetEntries(); i++ )
453 ((AliPHOSCradle*)(*fCradles)[i]) -> Clear();
456 //______________________________________________________________________________
458 void AliPHOS::FinishEvent(void)
460 // Called at the end of each 'galice' event.
462 if( NULL!=fTreePHOS )
466 //______________________________________________________________________________
468 void AliPHOS::FinishRun(void)
472 //______________________________________________________________________________
474 void AliPHOS::Print(Option_t *opt)
476 // Print PHOS information.
477 // For each AliPHOSCradle the function AliPHOSCradle::Print(opt) is called.
479 AliPHOS &PHOS = *(AliPHOS *)this; // Removing 'const'...
481 for( int i=0; i<fCradles->GetEntries(); i++ )
483 printf("PHOS cradle %d from %d\n",i+1, fCradles->GetEntries());
484 PHOS.GetCradle(i).Print(opt);
485 printf( "---------------------------------------------------\n");
489 //______________________________________________________________________________
490 void AliPHOS::SetFlags(Float_t p1,Float_t p2,Float_t p3,Float_t p4,
491 Float_t p5,Float_t p6,Float_t p7,Float_t p8,Float_t p9)
504 //______________________________________________________________________________
505 void AliPHOS::SetCell(Float_t p1,Float_t p2,Float_t p3,Float_t p4,
506 Float_t p5,Float_t p6,Float_t p7,Float_t p8,Float_t p9)
519 //______________________________________________________________________________
520 void AliPHOS::SetRadius(Float_t radius)
525 //______________________________________________________________________________
526 void AliPHOS::SetCradleSize(Int_t nz, Int_t nphi, Int_t ncradles)
530 PHOSsize[2]=ncradles;
533 //______________________________________________________________________________
534 void AliPHOS::SetCradleA(Float_t angle)
539 //______________________________________________________________________________
540 void AliPHOS::SetExtra(Float_t p1,Float_t p2,Float_t p3,Float_t p4,
541 Float_t p5,Float_t p6,Float_t p7,Float_t p8,Float_t p9)
554 //______________________________________________________________________________
555 void AliPHOS::SetTextolitWall(Float_t dx, Float_t dy, Float_t dz)
562 //______________________________________________________________________________
563 void AliPHOS::SetInnerAir(Float_t dx, Float_t dy, Float_t dz)
570 //______________________________________________________________________________
571 void AliPHOS::SetFoam(Float_t dx, Float_t dy, Float_t dz, Float_t dr)
579 ClassImp(AliPHOSCradle)
581 //______________________________________________________________________________
583 AliPHOSCradle::AliPHOSCradle(void) {}
585 //______________________________________________________________________________
587 AliPHOSCradle::AliPHOSCradle( int Geometry ,
588 float CrystalSideSize ,
589 float CrystalLength ,
590 float WrapThickness ,
598 fGeometry (Geometry),
600 // fChargedTracksInPIN (),
601 fCrystalSideSize (CrystalSideSize),
602 fCrystalLength (CrystalLength),
603 fWrapThickness (WrapThickness),
604 fAirThickness (AirThickness),
605 fPIN_SideSize (PIN_SideSize),
606 fPIN_Length (PIN_Length),
612 fCellEnergy = TH2F("CellE","Energy deposition in a cells",fNz,0,fNz,fNphi,0,fNphi);
613 fCellEnergy .SetDirectory(0);
614 fChargedTracksInPIN = TH2S("PINCtracks","Amount of charged tracks in PIN",fNz,0,fNz,fNphi,0,fNphi);
615 fChargedTracksInPIN .SetDirectory(0);
618 //______________________________________________________________________________
620 AliPHOSCradle::~AliPHOSCradle(void) // 28.12.1998
622 fGammasReconstructed.Delete();
623 fParticles .Delete();
626 //______________________________________________________________________________
628 void AliPHOSCradle::Clear(Option_t *)
630 // Clear digit. information.
632 fCellEnergy .Reset();
633 fChargedTracksInPIN .Reset();
634 GetParticles() .Delete();
635 GetParticles() .Compress();
636 GetGammasReconstructed() .Delete();
637 GetGammasReconstructed() .Compress();
641 //______________________________________________________________________________
643 void AliPHOSCradle::GetXY(const TVector3 &p,const TVector3 &v,float R,float &x,float &y,float &l) const
645 // This function calculates hit position (x,y) in the CRADLE cells plain from particle in
646 // the direction given by 'p' (not required to be normalized) and start point
647 // given by 3-vector 'v'. So the particle trajectory is t(l) = v + p*l
648 // were 'l' is a number (distance from 'v' to CRADLE cells plain) and 't' is resulting
649 // three-vector of trajectory point.
651 // After the call to this function user should test that l>=0 (the particle HITED the
652 // plain) and (x,y) are in the region of CRADLE:
655 // AliPHOSCradle cradle(......);
656 // TVector3 p(....), v(....);
658 // cradle.GetXY(p,v,x,y,l);
659 // if( l<0 || TMath::Abs(x)>cradle.GetNz() *cradle.GetCellSideSize()/2
660 // || TMath::Abs(y)>cradle.GetNphi()*cradle.GetCellSideSize()/2 )
661 // cout << "Outside the CRADLE.\n";
663 // We have to create three vectors:
664 // s - central point on the PHOS surface
665 // n1 - first vector in CRADLE plain
666 // n2 - second vector in CRADLE plain
667 // This three vectors are orthonormalized.
669 double phi = fPhi/180*TMath::Pi();
670 TVector3 n1( 0.0 , 0.0 , 1.0 ), // Z direction (X)
671 n2( -sin(phi) , cos(phi) , 0 ), // around beam (Y)
672 s ( R*cos(phi) , R*sin(phi) , 0 ); // central point
674 const double l1_min = 1e-2;
676 p_n1 = p*n1, // * - scalar product.
683 if ( TMath::Abs(l1=p.X()-n1.X()*p_n1-n2.X()*p_n2)>l1_min )
684 { l = (-v.X()+s.X()+n1.X()*(v_n1-s_n1)+n2.X()*(v_n2-s_n2))/l1; }
685 else if ( TMath::Abs(l1=p.Y()-n1.Y()*p_n1-n2.Y()*p_n2)>l1_min )
686 { l = (-v.Y()+s.Y()+n1.Y()*(v_n1-s_n1)+n2.Y()*(v_n2-s_n2))/l1; }
687 else if ( TMath::Abs(l1=p.Z()-n1.Z()*p_n1-n2.Z()*p_n2)>l1_min )
688 { l = (-v.Z()+s.Z()+n1.Z()*(v_n1-s_n1)+n2.Z()*(v_n2-s_n2))/l1; }
690 // double lx = (-v.X()+s.X()+n1.X()*(v.dot(n1)-s.dot(n1))+n2.X()*(v.dot(n2)-s.dot(n2)))/
691 // (p.X()-n1.X()*p.dot(n1)-n2.X()*p.dot(n2)),
692 // ly = (-v.Y()+s.Y()+n1.Y()*(v.dot(n1)-s.dot(n1))+n2.Y()*(v.dot(n2)-s.dot(n2)))/
693 // (p.Y()-n1.Y()*p.dot(n1)-n2.Y()*p.dot(n2)),
694 // lz = (-v.Z()+s.Z()+n1.Z()*(v.dot(n1)-s.dot(n1))+n2.Z()*(v.dot(n2)-s.dot(n2)))/
695 // (p.Z()-n1.Z()*p.dot(n1)-n2.Z()*p.dot(n2));
696 // 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));
697 // 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));
698 // 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));
699 // cout.form("lx,ly,lz = %g,%g,%g\n",lx,ly,lz);
701 x = p_n1*l + v_n1 - s_n1;
702 y = p_n2*l + v_n2 - s_n2;
705 //______________________________________________________________________________
707 void AliPHOSCradle::Print(Option_t *opt)
709 // Print AliPHOSCradle information.
711 // options: 'd' - print energy deposition for EVERY cell
712 // 'p' - print particles list that hit the cradle
713 // 'r' - print list of reconstructed particles
715 AliPHOSCradle *cr = (AliPHOSCradle *)this; // Removing 'const'...
717 printf("AliPHOSCradle: Nz=%d Nphi=%d, fPhi=%f, E=%g\n",fNz,fNphi,fPhi,
718 cr->fCellEnergy.GetSumOfWeights());
720 if( NULL!=strchr(opt,'d') )
722 printf("\n\nCells Energy (in MeV):\n\n |");
723 for( int x=0; x<fNz; x++ )
727 for( int y=fNphi-1; y>=0; y-- )
730 for( int x=0; x<fNz; x++ )
731 printf("%6d",(int)(cr->fCellEnergy.GetBinContent(cr->fCellEnergy.GetBin(x,y))*1000));
737 if( NULL!=strchr(opt,'p') )
739 printf("This cradle was hit by %d particles\n",
740 ((AliPHOSCradle*)this)->GetParticles().GetEntries());
741 TObjArray &p=((AliPHOSCradle*)this)->GetParticles();
742 for( int i=0; i<p.GetEntries(); i++ )
743 ((AliPHOSgamma*)(p[i]))->Print();
746 if( NULL!=strchr(opt,'p') )
748 printf("Amount of reconstructed gammas is %d\n",
749 ((AliPHOSCradle*)this)->GetGammasReconstructed().GetEntries());
751 TObjArray &p=((AliPHOSCradle*)this)->GetGammasReconstructed();
752 for( int i=0; i<p.GetEntries(); i++ )
753 ((AliPHOSgamma*)(p[i]))->Print();
757 //______________________________________________________________________________
759 void AliPHOSCradle::Distortion(const TH2F *Noise, const TH2F *Stochastic, const TH2F *Calibration)
761 // This function changes histogram of cell energies fCellEnergy on the base of input
762 // histograms Noise, Stochastic, Calibration. The histograms must have
765 //////////////////////////////////
766 // Testing the histograms size. //
767 //////////////////////////////////
769 if( fNz!=fCellEnergy.GetNbinsX() || fNphi!=fCellEnergy.GetNbinsY() )
771 printf ("Bad size of CellEnergy! Must be: Nz x Nphi = %d x %d\n"
772 "but size of CellEnergy is: %d x %d\n",
773 fNz,fNphi,fCellEnergy.GetNbinsX(),fCellEnergy.GetNbinsY());
777 if( fNz!=fChargedTracksInPIN.GetNbinsX() || fNphi!=fChargedTracksInPIN.GetNbinsY() )
779 printf ("Bad size of ChargedTracksInPIN! Must be: Nz x Nphi = %d x %d\n"
780 "but size of ChargedTracksInPIN is: %d x %d\n",
781 fNz,fNphi,fChargedTracksInPIN.GetNbinsX(),fChargedTracksInPIN.GetNbinsY());
785 if( NULL!=Noise && (fNz!=Noise->GetNbinsX() || fNphi!=Noise->GetNbinsX()) )
787 printf ("Bad size of Noise! Must be: Nz x Nphi = %d x %d\n"
788 "but size of Noise is: %d x %d\n",
789 fNz,fNphi,fChargedTracksInPIN.GetNbinsX(),fChargedTracksInPIN.GetNbinsY());
793 if( NULL!=Stochastic && (fNz!=Stochastic->GetNbinsX() || fNphi!=Stochastic->GetNbinsX()) )
795 printf ("Bad size of Stochastic! Must be: Nz x Nphi = %d x %d\n"
796 "but size of Stochastic is: %d x %d\n",
797 fNz,fNphi,fChargedTracksInPIN.GetNbinsX(),fChargedTracksInPIN.GetNbinsY());
801 if( NULL!=Calibration && (fNz!=Calibration->GetNbinsX() || fNphi!=Calibration->GetNbinsX()) )
803 printf ("Bad size of Calibration! Must be: Nz x Nphi = %d x %d\n"
804 "but size of Calibration is: %d x %d\n",
805 fNz,fNphi,fChargedTracksInPIN.GetNbinsX(),fChargedTracksInPIN.GetNbinsY());
813 for( int y=0; y<fNphi; y++ )
814 for( int x=0; x<fNz; x++ )
816 const int n = fCellEnergy.GetBin(x,y); // Bin number
819 Float_t E_old=fCellEnergy.GetBinContent(n), E_new=E_old;
821 if( NULL!=Stochastic )
822 E_new = r.Gaus(E_old,sqrt(E_old)*GetDistortedValue(Stochastic,n));
824 if( NULL!=Calibration )
825 E_new *= GetDistortedValue(Calibration,n);
828 E_new += GetDistortedValue(Noise,n);
830 fCellEnergy.SetBinContent(n,E_new);
834 ////////////////////////////////////////////////////////////////////////////////
836 TH2F* AliPHOSCradle::CreateHistForDistortion(const char *name, const char *title,
838 Float_t MU_mu, Float_t MU_sigma,
839 Float_t SIGMA_mu, Float_t SIGMA_sigma)
841 // Create (new TH2F(...)) histogram with information (for every bin) that will
842 // be used for VALUE creation.
843 // Two values will be created for each bin:
844 // MU = TRandom::Gaus(MU_mu,MU_sigma)
846 // SIGMA = TRandom::Gaus(SIGMA_mu,SIGMA_sigma)
847 // The VALUE in a particluar bin will be equal
848 // VALUE = TRandom::Gaus(MU,SIGMA)
850 // Do not forget to delete the histogram at the end of the work.
852 TH2F *h = new TH2F( name,title, Nx,1,Nx, Ny,1,Ny );
855 Error("CreateHistForDistortion","Can not create the histogram");
860 for( int y=0; y<Ny; y++ )
861 for( int x=0; x<Nx; x++ )
863 const int n = h->GetBin(x,y);
864 h->SetBinContent(n,r.Gaus( MU_mu, MU_sigma));
865 h->SetBinError (n,r.Gaus(SIGMA_mu,SIGMA_sigma));
871 ////////////////////////////////////////////////////////////////////////////////
873 Float_t AliPHOSCradle::GetDistortedValue(const TH2F *h, UInt_t n)
875 return r.Gaus(((TH2F*)h)->GetBinContent(n),n);
878 ////////////////////////////////////////////////////////////////////////////////
879 //______________________________________________________________________________
882 #define common_for_event_storing COMMON_FOR_EVENT_STORING
884 #define common_for_event_storing common_for_event_storing_
889 enum { crystals_matrix_amount_max=4, crystals_in_matrix_amount_max=40000 };
891 // Event-independent information
892 UShort_t crystals_matrix_amount_PHOS,
894 amount_of_crystals_on_Z,
895 amount_of_crystals_on_PHI;
899 matrix_coordinate_Z [crystals_matrix_amount_max],
900 matrix_coordinate_PHI [crystals_matrix_amount_max];
902 UShort_t crystals_amount_with_amplitudes [crystals_matrix_amount_max],
903 crystals_amplitudes_Iad [crystals_matrix_amount_max]
904 [crystals_in_matrix_amount_max][2];
905 } common_for_event_storing;
907 // integer*4 crystals_amount_max,crystals_in_matrix_amount_max,
908 // + crystals_matrix_amount_max
909 // parameter (crystals_matrix_amount_max=4)
910 // parameter (crystals_in_matrix_amount_max=40000)
911 // parameter (crystals_amount_max =crystals_matrix_amount_max*
912 // + crystals_in_matrix_amount_max)
914 // * All units are in GeV, cm, radian
915 // real crystal_amplitudes_unit, radius_unit,
916 // + crystal_size_unit, crystal_length_unit,
917 // + matrix_coordinate_Z_unit, matrix_coordinate_PHI_unit
918 // integer crystal_amplitudes_in_units_min
919 // parameter (crystal_amplitudes_in_units_min = 1)
920 // parameter (crystal_amplitudes_unit = 0.001 ) ! 1.0 MeV
921 // parameter (radius_unit = 0.1 ) ! 0.1 cm
922 // parameter (crystal_size_unit = 0.01 ) ! 0.01 cm
923 // parameter (crystal_length_unit = 0.01 ) ! 0.01 cm
924 // parameter (matrix_coordinate_Z_unit = 0.1 ) ! 0.1 cm
925 // parameter (matrix_coordinate_PHI_unit = 1e-4 ) ! 1e-4 radian
927 // integer*2 crystals_matrix_amount_PHOS, crystal_matrix_type,
928 // + amount_of_crystals_on_Z, amount_of_crystals_on_PHI,
929 // + crystals_amount_with_amplitudes, crystals_amplitudes_Iad
930 // integer*4 event_number
932 // real radius, crystal_size, crystal_length,
933 // + matrix_coordinate_Z, matrix_coordinate_PHI
935 // real crystals_amplitudes, crystals_energy_total
936 // integer event_file_unit_number
938 // common /common_for_event_storing/
939 // + ! Event-independent information
940 // + crystals_matrix_amount_PHOS,
941 // + crystal_matrix_type,
942 // + amount_of_crystals_on_Z,
943 // + amount_of_crystals_on_PHI,
947 // + matrix_coordinate_Z (crystals_matrix_amount_max),
948 // + matrix_coordinate_PHI (crystals_matrix_amount_max),
950 // + ! Event-dependent information
952 // + crystals_amount_with_amplitudes
953 // + (crystals_matrix_amount_max),
954 // + crystals_amplitudes_Iad (2,crystals_in_matrix_amount_max,
955 // + crystals_matrix_amount_max),
957 // + ! These information don't store in data file
958 // + crystals_amplitudes (crystals_amount_max),
959 // + crystals_energy_total,
960 // + event_file_unit_number
963 // parameter (NGp=1000,nsps=10,nvertmax=1000)
964 // COMMON /GAMMA/KG,MW(ngp),ID(ngp),JD(ngp),E(ngp),E4(ngp),
965 // , XW(ngp),YW(ngp),ES(nsps,ngp),ET(nsps,ngp),ISsd(ngp),
966 // , IGDEV(ngp),ZGDEV(ngp),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 rcgamma RCGAMMA
976 #define rcgamma rcgamma_
981 enum {NGP=1000, nsps=10, nvertmax=1000};
982 int recons_gammas_amount, mw[NGP],ID[NGP],JD[NGP];
983 float E[NGP], E4[NGP], XW[NGP], YW[NGP], ES[NGP][nsps],ET[NGP][nsps],ISsd[NGP],
984 igdev[NGP],Zgdev[NGP];
985 // sigexy(3,ngp),Emimx(2,nsps,ngp),
986 // , kgfix,igfix(ngp),cgfix(3,ngp),sgfix(3,ngp),hiw(ngp),
987 // , wsw(nsps,ngp),h1w(ngp),h0w(ngp),raxay(5,ngp),
988 // , sigmaes0(nsps,ngp),dispeces(nsps,ngp),
993 #define reconsfirst RECONSFIRST
994 #define type_of_call _stdcall
996 #define reconsfirst reconsfirst_
1000 extern "C" void type_of_call reconsfirst(const float &,const float &);
1002 void AliPHOSCradle::Reconstruction(Float_t signal_step, UInt_t min_signal_reject)
1004 // Call of PHOS reconstruction program.
1005 // signal_step=0.001 GeV (1MeV)
1006 // min_signal_reject = 15 or 30 MeV
1009 common_for_event_storing.event_number = 0; // We do not know event number?
1010 common_for_event_storing.crystals_matrix_amount_PHOS = 1;
1011 common_for_event_storing.crystal_matrix_type = 1; // 1 - rectangular
1012 common_for_event_storing.amount_of_crystals_on_Z = fNz;
1013 common_for_event_storing.amount_of_crystals_on_PHI = fNphi;
1015 common_for_event_storing.radius = fRadius;
1016 common_for_event_storing.crystal_size = GetCellSideSize();
1017 common_for_event_storing.crystal_length = fCrystalLength;
1019 common_for_event_storing.matrix_coordinate_Z [0] = 0;
1020 common_for_event_storing.matrix_coordinate_PHI [0] = fPhi;
1022 #define k common_for_event_storing.crystals_amount_with_amplitudes[0]
1025 for( int y=0; y<fNphi; y++ )
1026 for( int x=0; x<fNz; x++ )
1028 UInt_t n = fCellEnergy.GetBin(x,y);
1029 UInt_t signal = (int) (fCellEnergy.GetBinContent(n)/signal_step);
1030 if( signal>=min_signal_reject )
1032 common_for_event_storing.crystals_amplitudes_Iad[0][k][0] = signal;
1033 common_for_event_storing.crystals_amplitudes_Iad[0][k][1] = x + y*fNz;
1039 GetGammasReconstructed().Delete();
1040 GetGammasReconstructed().Compress();
1042 const float stochastic_term = 0.03, // per cents over sqrt(E); E in GeV
1043 electronic_noise = 0.01; // GeV
1044 reconsfirst(stochastic_term,electronic_noise); // Call of reconstruction program.
1046 for( int i=0; i<rcgamma.recons_gammas_amount; i++ )
1048 // new (GetGammasReconstructed().UncheckedAt(i) ) AliPHOSgamma;
1049 // AliPHOSgamma &g = *(AliPHOSgamma*)(GetGammasReconstructed().UncheckedAt(i));
1051 AliPHOSgamma *gggg = new AliPHOSgamma;
1054 Error("Reconstruction","Can not create AliPHOSgamma");
1058 GetGammasReconstructed().Add(gggg);
1059 AliPHOSgamma &g=*gggg;
1061 Float_t thetta, alpha, betta, R=fRadius+rcgamma.Zgdev[i]/10;
1063 g.fX = rcgamma.YW[i]/10;
1064 g.fY = rcgamma.XW[i]/10;
1065 g.fE = rcgamma.E [i];
1067 thetta = atan(g.fX/R);
1069 alpha = atan(g.fY/R);
1070 betta = fPhi/180*TMath::Pi() + alpha;
1072 g.fPx = g.fE * cos(thetta) * cos(betta);
1073 g.fPy = g.fE * cos(thetta) * sin(betta);
1074 g.fPz = g.fE * sin(thetta);
1078 //______________________________________________________________________________
1079 //______________________________________________________________________________
1080 //______________________________________________________________________________
1081 //______________________________________________________________________________
1082 //______________________________________________________________________________
1084 ClassImp(AliPHOSgamma)
1086 //______________________________________________________________________________
1088 void AliPHOSgamma::Print(Option_t *)
1090 float mass = fE*fE - fPx*fPx - fPy*fPy - fPz*fPz;
1095 mass = -sqrt(-mass);
1097 printf("XY=(%+7.2f,%+7.2f) (%+7.2f,%+7.2f,%+7.2f;%7.2f) mass=%8.4f Ipart=%2d\n",
1098 fX,fY,fPx,fPy,fPz,fE,mass,fIpart);
1101 //______________________________________________________________________________
1103 AliPHOSgamma &AliPHOSgamma::operator=(const AliPHOSgamma &g)
1116 //______________________________________________________________________________
1117 //______________________________________________________________________________
1118 //______________________________________________________________________________
1119 //______________________________________________________________________________
1120 //______________________________________________________________________________
1122 ClassImp(AliPHOShit)
1124 //______________________________________________________________________________
1126 AliPHOShit::AliPHOShit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits):
1127 AliHit(shunt, track)
1130 for (i=0;i<5;i++) fVolume[i] = vol[i];
1137 //______________________________________________________________________________