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 Revision 1.9 1999/11/08 07:12:31 fca
19 Minor corrections thanks to I.Hrivnacova
21 Revision 1.8 1999/09/29 09:24:23 fca
22 Introduction of the Copyright and cvs Log
26 ////////////////////////////////////////////////
27 // Manager and hits classes for set:PHOS //
28 ////////////////////////////////////////////////
30 // --- ROOT system ---
39 // --- Standard library ---
45 // --- galice header files ---
49 //______________________________________________________________________________
54 //______________________________________________________________________________
56 AliPHOS::~AliPHOS(void)
58 delete fHits; // 28.12.1998
59 delete fTreePHOS; // 28.12.1998
64 //______________________________________________________________________________
69 fBranchNameOfCradles ("AliPHOSCradles"),
74 if( NULL==(fCradles=new TObjArray) )
76 Error("AliPHOS","Can not create fCradles");
82 //______________________________________________________________________________
84 AliPHOS::AliPHOS(const char *name, const char *title)
85 : AliDetector (name,title),
88 fBranchNameOfCradles ("AliPHOSCradles"),
93 <img src="picts/aliphos.gif">
97 fHits = new TClonesArray("AliPHOShit", 405);
101 SetMarkerColor(kGreen);
105 if( NULL==(fCradles=new TObjArray) ) {
106 Error("AliPHOS","Can not create fCradles");
112 //______________________________________________________________________________
114 void AliPHOS::DefPars()
159 //______________________________________________________________________________
161 void AliPHOS::AddHit(Int_t track, Int_t *vol, Float_t *hits)
163 TClonesArray &lhits = *fHits;
164 new(lhits[fNhits++]) AliPHOShit(fIshunt,track,vol,hits);
167 //___________________________________________
168 void AliPHOS::BuildGeometry()
173 const int kColorPHOS = kRed;
175 Top=gAlice->GetGeometry()->GetNode("alice");
179 Float_t pphi=12.9399462;
180 new TRotMatrix("rot988","rot988",90,-3*pphi,90,90-3*pphi,0,0);
181 new TRotMatrix("rot989","rot989",90,- pphi,90,90- pphi,0,0);
182 new TRotMatrix("rot990","rot990",90, pphi,90,90+ pphi,0,0);
183 new TRotMatrix("rot991","rot991",90, 3*pphi,90,90+3*pphi,0,0);
184 new TBRIK("S_PHOS","PHOS box","void",107.3,40,130);
186 Node = new TNode("PHOS1","PHOS1","S_PHOS",-317.824921,-395.014343,0,"rot988");
187 Node->SetLineColor(kColorPHOS);
190 Node = new TNode("PHOS2","PHOS2","S_PHOS",-113.532333,-494.124908,0,"rot989");
192 Node->SetLineColor(kColorPHOS);
194 Node = new TNode("PHOS3","PHOS3","S_PHOS", 113.532333,-494.124908,0,"rot990");
195 Node->SetLineColor(kColorPHOS);
198 Node = new TNode("PHOS4","PHOS4","S_PHOS", 317.824921,-395.014343,0,"rot991");
199 Node->SetLineColor(kColorPHOS);
203 //___________________________________________
204 void AliPHOS::CreateMaterials()
206 // *** DEFINITION OF AVAILABLE PHOS MATERIALS ***
208 // CALLED BY : PHOS_MEDIA
209 // ORIGIN : NICK VAN EIJNDHOVEN
213 Int_t ISXFLD = gAlice->Field()->Integ();
214 Float_t SXMGMX = gAlice->Field()->Max();
216 // --- The PbWO4 crystals ---
217 Float_t ax[3] = { 207.19,183.85,16. };
218 Float_t zx[3] = { 82.,74.,8. };
219 Float_t wx[3] = { 1.,1.,4. };
221 // --- Stainless Steel ---
222 Float_t as[5] = { 55.847,12.011,51.9961,58.69,28.0855 };
223 Float_t zs[5] = { 26.,6.,24.,28.,14. };
224 Float_t ws[5] = { .6392,8e-4,.2,.14,.02 };
226 // --- The polysterene scintillator (CH) ---
227 Float_t ap[2] = { 12.011,1.00794 };
228 Float_t zp[2] = { 6.,1. };
229 Float_t wp[2] = { 1.,1. };
232 Float_t at[2] = { 12.011,1.00794 };
233 Float_t zt[2] = { 6.,1. };
234 Float_t wt[2] = { 1.,2. };
236 // --- Polystyrene foam ---
237 Float_t af[2] = { 12.011,1.00794 };
238 Float_t zf[2] = { 6.,1. };
239 Float_t wf[2] = { 1.,1. };
241 //--- Foam thermo insulation (actual chemical composition unknown yet!) ---
242 Float_t ati[2] = { 12.011,1.00794 };
243 Float_t zti[2] = { 6.,1. };
244 Float_t wti[2] = { 1.,1. };
246 // --- Textolit (actual chemical composition unknown yet!) ---
247 Float_t atx[2] = { 12.011,1.00794 };
248 Float_t ztx[2] = { 6.,1. };
249 Float_t wtx[2] = { 1.,1. };
252 Int_t *idtmed = fIdtmed->GetArray()-699;
254 AliMixture( 0, "PbWO4$", ax, zx, dx, -3, wx);
255 AliMixture( 1, "Polystyrene$", ap, zp, dp, -2, wp);
256 AliMaterial( 2, "Al$", 26.98, 13., 2.7, 8.9, 999);
257 // --- Absorption length^ is ignored ---
258 AliMixture( 3, "Tyvek$", at, zt, dt, -2, wt);
259 AliMixture( 4, "Foam$", af, zf, df, -2, wf);
260 AliMixture( 5, "Stainless Steel$", as, zs, ds, 5, ws);
261 AliMaterial( 6, "Si$", 28.09, 14., 2.33, 9.36, 42.3);
262 AliMixture( 7, "Thermo Insul.$", ati, zti, dti, -2, wti);
263 AliMixture( 8, "Textolit$", atx, ztx, dtx, -2, wtx);
264 AliMaterial(99, "Air$", 14.61, 7.3, .001205, 30420., 67500);
266 AliMedium(0, "PHOS Xtal $", 0, 1, ISXFLD, SXMGMX, 10., .1, .1, .1, .1);
267 AliMedium(2, "Al parts $", 2, 0, ISXFLD, SXMGMX, 10., .1, .1, .001, .001);
268 AliMedium(3, "Tyvek wrapper$", 3, 0, ISXFLD, SXMGMX, 10., .1, .1, .001, .001);
269 AliMedium(4, "Polyst. foam $", 4, 0, ISXFLD, SXMGMX, 10., .1, .1, .1, .1);
270 AliMedium(5, "Steel cover $", 5, 0, ISXFLD, SXMGMX, 10., .1, .1, 1e-4, 1e-4);
271 AliMedium(6, "Si PIN $", 6, 0, ISXFLD, SXMGMX, 10., .1, .1, .01, .01);
272 AliMedium(7, "Thermo Insul.$", 7, 0, ISXFLD, SXMGMX, 10., .1, .1, .1, .1);
273 AliMedium(8, "Textolit $", 8, 0, ISXFLD, SXMGMX, 10., .1, .1, .1, .1);
274 AliMedium(99, "Air $",99, 0, ISXFLD, SXMGMX, 10., 1., .1, .1, 10);
276 // --- Generate explicitly delta rays in the steel cover ---
277 gMC->Gstpar(idtmed[704], "LOSS", 3.);
278 gMC->Gstpar(idtmed[704], "DRAY", 1.);
279 // --- and in aluminium parts ---
280 gMC->Gstpar(idtmed[701], "LOSS", 3.);
281 gMC->Gstpar(idtmed[701], "DRAY", 1.);
284 //______________________________________________________________________________
286 void AliPHOS::AddPHOSCradles()
289 for(i=0;i<GetCradlesAmount();i++) {
291 int n = fCradles->GetEntries();
292 fCradles->Add(new AliPHOSCradle( IsVersion(), // geometry.
293 GetCrystalSideSize (),
302 GetCradleAngle (i)));
304 if( n+1 != fCradles->GetEntries() || NULL == fCradles->At(n) )
306 cout << " Can not create or add AliPHOSCradle.\n";
312 //______________________________________________________________________________
314 Int_t AliPHOS::DistancetoPrimitive(Int_t , Int_t )
319 //___________________________________________
325 for(i=0;i<35;i++) printf("*");
326 printf(" PHOS_INIT ");
327 for(i=0;i<35;i++) printf("*");
330 // Here the ABSO initialisation code (if any!)
331 for(i=0;i<80;i++) printf("*");
335 //______________________________________________________________________________
337 void AliPHOS::MakeBranch(Option_t *)
339 // ROOT output initialization to ROOT file.
341 // AliDetector::MakeBranch() is always called.
343 // There will be also special tree "PHOS" with one branch "AliPHOSCradles"
344 // if it was set next flag in the galice card file:
345 // * PHOSflags: YES: X<>0 NO: X=0
346 // * PHOSflags(1) : -----X. Create branch for TObjArray of AliPHOSCradle
350 // In that case special bit CradlesBranch_Bit will be set for AliPHOS
352 AliDetector::MakeBranch();
355 float t = GetPHOS_flag(0)/10;
357 i = (int) ((t-i)*10);
361 SetBit(CradlesBranch_Bit);
363 if( NULL==(fTreePHOS=new TTree(fTreeName.Data(),"PHOS events tree")) )
365 Error("MakeBranch","Can not create TTree");
369 if( NULL==fTreePHOS->GetCurrentFile() )
371 Error("MakeBranch","There is no opened ROOT file");
375 // Create a new branch in the current Root Tree.
377 if( NULL==fTreePHOS->Branch(fBranchNameOfCradles.Data(),"TObjArray",&fCradles,4000,0) )
379 Error("MakeBranch","Can not create branch");
383 printf("The branch %s has been created\n",fBranchNameOfCradles.Data());
386 //______________________________________________________________________________
388 void AliPHOS::SetTreeAddress(void)
390 // ROOT input initialization.
392 // AliDetector::SetTreeAddress() is always called.
394 // If CradlesBranch_Bit is set (see AliPHOS::MakeBranch) than fTreePHOS is
397 AliDetector::SetTreeAddress();
399 if( !TestBit(CradlesBranch_Bit) )
402 if( NULL==(fTreePHOS=(TTree*)gDirectory->Get((char*)(fTreeName.Data())) ) )
404 Error("SetTreeAddress","Can not find Tree \"%s\"\n",fTreeName.Data());
408 TBranch *branch = fTreePHOS->GetBranch(fBranchNameOfCradles.Data());
411 Error("SetTreeAddress","Can not find branch %s in TTree:%s",fBranchNameOfCradles.Data(),fTreeName.Data());
415 branch->SetAddress(&fCradles);
418 //______________________________________________________________________________
420 AliPHOSCradle *AliPHOS::GetCradleOfTheParticle(const TVector3 &p,const TVector3 &v) const
422 // For a given direction 'p' and source point 'v' returns pointer to AliPHOSCradle
423 // in that direction or NULL if AliPHOSCradle was not found.
425 for( int m=0; m<fCradles->GetEntries(); m++ )
427 AliPHOS *PHOS = (AliPHOS *)this; // Removing 'const'...
428 AliPHOSCradle *cradle = (AliPHOSCradle *)PHOS->fCradles->operator[](m);
431 const float d = cradle->GetRadius();
432 cradle->GetXY(p,v,d,x,y,l);
434 if( l>0 && TMath::Abs(x)<cradle->GetNz ()*cradle->GetCellSideSize()/2
435 && TMath::Abs(y)<cradle->GetNphi()*cradle->GetCellSideSize()/2 )
442 //______________________________________________________________________________
444 void AliPHOS::Reconstruction(Float_t signal_step, UInt_t min_signal_reject)
446 // Call AliPHOSCradle::Reconstruction(Float_t signal_step, UInt_t min_signal_reject)
447 // for all AliPHOSCradles.
449 for( int i=0; i<fCradles->GetEntries(); i++ )
450 GetCradle(i).Reconstruction(signal_step,min_signal_reject);
453 //______________________________________________________________________________
455 void AliPHOS::ResetDigits(void)
457 AliDetector::ResetDigits();
459 for( int i=0; i<fCradles->GetEntries(); i++ )
460 ((AliPHOSCradle*)(*fCradles)[i]) -> Clear();
463 //______________________________________________________________________________
465 void AliPHOS::FinishEvent(void)
467 // Called at the end of each 'galice' event.
469 if( NULL!=fTreePHOS )
473 //______________________________________________________________________________
475 void AliPHOS::FinishRun(void)
479 //______________________________________________________________________________
481 void AliPHOS::Print(Option_t *opt)
483 // Print PHOS information.
484 // For each AliPHOSCradle the function AliPHOSCradle::Print(opt) is called.
486 AliPHOS &PHOS = *(AliPHOS *)this; // Removing 'const'...
488 for( int i=0; i<fCradles->GetEntries(); i++ )
490 printf("PHOS cradle %d from %d\n",i+1, fCradles->GetEntries());
491 PHOS.GetCradle(i).Print(opt);
492 printf( "---------------------------------------------------\n");
496 //______________________________________________________________________________
497 void AliPHOS::SetFlags(Float_t p1,Float_t p2,Float_t p3,Float_t p4,
498 Float_t p5,Float_t p6,Float_t p7,Float_t p8,Float_t p9)
511 //______________________________________________________________________________
512 void AliPHOS::SetCell(Float_t p1,Float_t p2,Float_t p3,Float_t p4,
513 Float_t p5,Float_t p6,Float_t p7,Float_t p8,Float_t p9)
526 //______________________________________________________________________________
527 void AliPHOS::SetRadius(Float_t radius)
532 //______________________________________________________________________________
533 void AliPHOS::SetCradleSize(Int_t nz, Int_t nphi, Int_t ncradles)
537 PHOSsize[2]=ncradles;
540 //______________________________________________________________________________
541 void AliPHOS::SetCradleA(Float_t angle)
546 //______________________________________________________________________________
547 void AliPHOS::SetExtra(Float_t p1,Float_t p2,Float_t p3,Float_t p4,
548 Float_t p5,Float_t p6,Float_t p7,Float_t p8,Float_t p9)
561 //______________________________________________________________________________
562 void AliPHOS::SetTextolitWall(Float_t dx, Float_t dy, Float_t dz)
569 //______________________________________________________________________________
570 void AliPHOS::SetInnerAir(Float_t dx, Float_t dy, Float_t dz)
577 //______________________________________________________________________________
578 void AliPHOS::SetFoam(Float_t dx, Float_t dy, Float_t dz, Float_t dr)
586 ClassImp(AliPHOSCradle)
588 //______________________________________________________________________________
590 AliPHOSCradle::AliPHOSCradle(void) {}
592 //______________________________________________________________________________
594 AliPHOSCradle::AliPHOSCradle( int Geometry ,
595 float CrystalSideSize ,
596 float CrystalLength ,
597 float WrapThickness ,
605 fGeometry (Geometry),
607 // fChargedTracksInPIN (),
608 fCrystalSideSize (CrystalSideSize),
609 fCrystalLength (CrystalLength),
610 fWrapThickness (WrapThickness),
611 fAirThickness (AirThickness),
612 fPIN_SideSize (PIN_SideSize),
613 fPIN_Length (PIN_Length),
619 fCellEnergy = TH2F("CellE","Energy deposition in a cells",fNz,0,fNz,fNphi,0,fNphi);
620 fCellEnergy .SetDirectory(0);
621 fChargedTracksInPIN = TH2S("PINCtracks","Amount of charged tracks in PIN",fNz,0,fNz,fNphi,0,fNphi);
622 fChargedTracksInPIN .SetDirectory(0);
625 //______________________________________________________________________________
627 AliPHOSCradle::~AliPHOSCradle(void) // 28.12.1998
629 fGammasReconstructed.Delete();
630 fParticles .Delete();
633 //______________________________________________________________________________
635 void AliPHOSCradle::Clear(Option_t *)
637 // Clear digit. information.
639 fCellEnergy .Reset();
640 fChargedTracksInPIN .Reset();
641 GetParticles() .Delete();
642 GetParticles() .Compress();
643 GetGammasReconstructed() .Delete();
644 GetGammasReconstructed() .Compress();
648 //______________________________________________________________________________
650 void AliPHOSCradle::GetXY(const TVector3 &p,const TVector3 &v,float R,float &x,float &y,float &l) const
652 // This function calculates hit position (x,y) in the CRADLE cells plain from particle in
653 // the direction given by 'p' (not required to be normalized) and start point
654 // given by 3-vector 'v'. So the particle trajectory is t(l) = v + p*l
655 // were 'l' is a number (distance from 'v' to CRADLE cells plain) and 't' is resulting
656 // three-vector of trajectory point.
658 // After the call to this function user should test that l>=0 (the particle HITED the
659 // plain) and (x,y) are in the region of CRADLE:
662 // AliPHOSCradle cradle(......);
663 // TVector3 p(....), v(....);
665 // cradle.GetXY(p,v,x,y,l);
666 // if( l<0 || TMath::Abs(x)>cradle.GetNz() *cradle.GetCellSideSize()/2
667 // || TMath::Abs(y)>cradle.GetNphi()*cradle.GetCellSideSize()/2 )
668 // cout << "Outside the CRADLE.\n";
670 // We have to create three vectors:
671 // s - central point on the PHOS surface
672 // n1 - first vector in CRADLE plain
673 // n2 - second vector in CRADLE plain
674 // This three vectors are orthonormalized.
676 double phi = fPhi/180*TMath::Pi();
677 TVector3 n1( 0.0 , 0.0 , 1.0 ), // Z direction (X)
678 n2( -sin(phi) , cos(phi) , 0 ), // around beam (Y)
679 s ( R*cos(phi) , R*sin(phi) , 0 ); // central point
681 const double l1_min = 1e-2;
683 p_n1 = p*n1, // * - scalar product.
690 if ( TMath::Abs(l1=p.X()-n1.X()*p_n1-n2.X()*p_n2)>l1_min )
691 { l = (-v.X()+s.X()+n1.X()*(v_n1-s_n1)+n2.X()*(v_n2-s_n2))/l1; }
692 else if ( TMath::Abs(l1=p.Y()-n1.Y()*p_n1-n2.Y()*p_n2)>l1_min )
693 { l = (-v.Y()+s.Y()+n1.Y()*(v_n1-s_n1)+n2.Y()*(v_n2-s_n2))/l1; }
694 else if ( TMath::Abs(l1=p.Z()-n1.Z()*p_n1-n2.Z()*p_n2)>l1_min )
695 { l = (-v.Z()+s.Z()+n1.Z()*(v_n1-s_n1)+n2.Z()*(v_n2-s_n2))/l1; }
697 // double lx = (-v.X()+s.X()+n1.X()*(v.dot(n1)-s.dot(n1))+n2.X()*(v.dot(n2)-s.dot(n2)))/
698 // (p.X()-n1.X()*p.dot(n1)-n2.X()*p.dot(n2)),
699 // ly = (-v.Y()+s.Y()+n1.Y()*(v.dot(n1)-s.dot(n1))+n2.Y()*(v.dot(n2)-s.dot(n2)))/
700 // (p.Y()-n1.Y()*p.dot(n1)-n2.Y()*p.dot(n2)),
701 // lz = (-v.Z()+s.Z()+n1.Z()*(v.dot(n1)-s.dot(n1))+n2.Z()*(v.dot(n2)-s.dot(n2)))/
702 // (p.Z()-n1.Z()*p.dot(n1)-n2.Z()*p.dot(n2));
703 // 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));
704 // 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));
705 // 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));
706 // cout.form("lx,ly,lz = %g,%g,%g\n",lx,ly,lz);
708 x = p_n1*l + v_n1 - s_n1;
709 y = p_n2*l + v_n2 - s_n2;
712 //______________________________________________________________________________
714 void AliPHOSCradle::Print(Option_t *opt)
716 // Print AliPHOSCradle information.
718 // options: 'd' - print energy deposition for EVERY cell
719 // 'p' - print particles list that hit the cradle
720 // 'r' - print list of reconstructed particles
722 AliPHOSCradle *cr = (AliPHOSCradle *)this; // Removing 'const'...
724 printf("AliPHOSCradle: Nz=%d Nphi=%d, fPhi=%f, E=%g\n",fNz,fNphi,fPhi,
725 cr->fCellEnergy.GetSumOfWeights());
727 if( NULL!=strchr(opt,'d') )
729 printf("\n\nCells Energy (in MeV):\n\n |");
730 for( int x=0; x<fNz; x++ )
734 for( int y=fNphi-1; y>=0; y-- )
737 for( int x=0; x<fNz; x++ )
738 printf("%6d",(int)(cr->fCellEnergy.GetBinContent(cr->fCellEnergy.GetBin(x,y))*1000));
744 if( NULL!=strchr(opt,'p') )
746 printf("This cradle was hit by %d particles\n",
747 ((AliPHOSCradle*)this)->GetParticles().GetEntries());
748 TObjArray &p=((AliPHOSCradle*)this)->GetParticles();
749 for( int i=0; i<p.GetEntries(); i++ )
750 ((AliPHOSgamma*)(p[i]))->Print();
753 if( NULL!=strchr(opt,'p') )
755 printf("Amount of reconstructed gammas is %d\n",
756 ((AliPHOSCradle*)this)->GetGammasReconstructed().GetEntries());
758 TObjArray &p=((AliPHOSCradle*)this)->GetGammasReconstructed();
759 for( int i=0; i<p.GetEntries(); i++ )
760 ((AliPHOSgamma*)(p[i]))->Print();
764 //______________________________________________________________________________
766 void AliPHOSCradle::Distortion(const TH2F *Noise, const TH2F *Stochastic, const TH2F *Calibration)
768 // This function changes histogram of cell energies fCellEnergy on the base of input
769 // histograms Noise, Stochastic, Calibration. The histograms must have
772 //////////////////////////////////
773 // Testing the histograms size. //
774 //////////////////////////////////
776 if( fNz!=fCellEnergy.GetNbinsX() || fNphi!=fCellEnergy.GetNbinsY() )
778 printf ("Bad size of CellEnergy! Must be: Nz x Nphi = %d x %d\n"
779 "but size of CellEnergy is: %d x %d\n",
780 fNz,fNphi,fCellEnergy.GetNbinsX(),fCellEnergy.GetNbinsY());
784 if( fNz!=fChargedTracksInPIN.GetNbinsX() || fNphi!=fChargedTracksInPIN.GetNbinsY() )
786 printf ("Bad size of ChargedTracksInPIN! Must be: Nz x Nphi = %d x %d\n"
787 "but size of ChargedTracksInPIN is: %d x %d\n",
788 fNz,fNphi,fChargedTracksInPIN.GetNbinsX(),fChargedTracksInPIN.GetNbinsY());
792 if( NULL!=Noise && (fNz!=Noise->GetNbinsX() || fNphi!=Noise->GetNbinsX()) )
794 printf ("Bad size of Noise! Must be: Nz x Nphi = %d x %d\n"
795 "but size of Noise is: %d x %d\n",
796 fNz,fNphi,fChargedTracksInPIN.GetNbinsX(),fChargedTracksInPIN.GetNbinsY());
800 if( NULL!=Stochastic && (fNz!=Stochastic->GetNbinsX() || fNphi!=Stochastic->GetNbinsX()) )
802 printf ("Bad size of Stochastic! Must be: Nz x Nphi = %d x %d\n"
803 "but size of Stochastic is: %d x %d\n",
804 fNz,fNphi,fChargedTracksInPIN.GetNbinsX(),fChargedTracksInPIN.GetNbinsY());
808 if( NULL!=Calibration && (fNz!=Calibration->GetNbinsX() || fNphi!=Calibration->GetNbinsX()) )
810 printf ("Bad size of Calibration! Must be: Nz x Nphi = %d x %d\n"
811 "but size of Calibration is: %d x %d\n",
812 fNz,fNphi,fChargedTracksInPIN.GetNbinsX(),fChargedTracksInPIN.GetNbinsY());
820 for( int y=0; y<fNphi; y++ )
821 for( int x=0; x<fNz; x++ )
823 const int n = fCellEnergy.GetBin(x,y); // Bin number
826 Float_t E_old=fCellEnergy.GetBinContent(n), E_new=E_old;
828 if( NULL!=Stochastic )
829 E_new = r.Gaus(E_old,sqrt(E_old)*GetDistortedValue(Stochastic,n));
831 if( NULL!=Calibration )
832 E_new *= GetDistortedValue(Calibration,n);
835 E_new += GetDistortedValue(Noise,n);
837 fCellEnergy.SetBinContent(n,E_new);
841 ////////////////////////////////////////////////////////////////////////////////
843 TH2F* AliPHOSCradle::CreateHistForDistortion(const char *name, const char *title,
845 Float_t MU_mu, Float_t MU_sigma,
846 Float_t SIGMA_mu, Float_t SIGMA_sigma)
848 // Create (new TH2F(...)) histogram with information (for every bin) that will
849 // be used for VALUE creation.
850 // Two values will be created for each bin:
851 // MU = TRandom::Gaus(MU_mu,MU_sigma)
853 // SIGMA = TRandom::Gaus(SIGMA_mu,SIGMA_sigma)
854 // The VALUE in a particluar bin will be equal
855 // VALUE = TRandom::Gaus(MU,SIGMA)
857 // Do not forget to delete the histogram at the end of the work.
859 TH2F *h = new TH2F( name,title, Nx,1,Nx, Ny,1,Ny );
862 Error("CreateHistForDistortion","Can not create the histogram");
867 for( int y=0; y<Ny; y++ )
868 for( int x=0; x<Nx; x++ )
870 const int n = h->GetBin(x,y);
871 h->SetBinContent(n,r.Gaus( MU_mu, MU_sigma));
872 h->SetBinError (n,r.Gaus(SIGMA_mu,SIGMA_sigma));
878 ////////////////////////////////////////////////////////////////////////////////
880 Float_t AliPHOSCradle::GetDistortedValue(const TH2F *h, UInt_t n)
882 return r.Gaus(((TH2F*)h)->GetBinContent(n),n);
885 ////////////////////////////////////////////////////////////////////////////////
886 //______________________________________________________________________________
889 #define common_for_event_storing COMMON_FOR_EVENT_STORING
891 #define common_for_event_storing common_for_event_storing_
894 /* extern "C" */ struct
896 enum { crystals_matrix_amount_max=4, crystals_in_matrix_amount_max=40000 };
898 // Event-independent information
899 UShort_t crystals_matrix_amount_PHOS,
901 amount_of_crystals_on_Z,
902 amount_of_crystals_on_PHI;
906 matrix_coordinate_Z [crystals_matrix_amount_max],
907 matrix_coordinate_PHI [crystals_matrix_amount_max];
909 UShort_t crystals_amount_with_amplitudes [crystals_matrix_amount_max],
910 crystals_amplitudes_Iad [crystals_matrix_amount_max]
911 [crystals_in_matrix_amount_max][2];
912 } common_for_event_storing;
914 // integer*4 crystals_amount_max,crystals_in_matrix_amount_max,
915 // + crystals_matrix_amount_max
916 // parameter (crystals_matrix_amount_max=4)
917 // parameter (crystals_in_matrix_amount_max=40000)
918 // parameter (crystals_amount_max =crystals_matrix_amount_max*
919 // + crystals_in_matrix_amount_max)
921 // * All units are in GeV, cm, radian
922 // real crystal_amplitudes_unit, radius_unit,
923 // + crystal_size_unit, crystal_length_unit,
924 // + matrix_coordinate_Z_unit, matrix_coordinate_PHI_unit
925 // integer crystal_amplitudes_in_units_min
926 // parameter (crystal_amplitudes_in_units_min = 1)
927 // parameter (crystal_amplitudes_unit = 0.001 ) ! 1.0 MeV
928 // parameter (radius_unit = 0.1 ) ! 0.1 cm
929 // parameter (crystal_size_unit = 0.01 ) ! 0.01 cm
930 // parameter (crystal_length_unit = 0.01 ) ! 0.01 cm
931 // parameter (matrix_coordinate_Z_unit = 0.1 ) ! 0.1 cm
932 // parameter (matrix_coordinate_PHI_unit = 1e-4 ) ! 1e-4 radian
934 // integer*2 crystals_matrix_amount_PHOS, crystal_matrix_type,
935 // + amount_of_crystals_on_Z, amount_of_crystals_on_PHI,
936 // + crystals_amount_with_amplitudes, crystals_amplitudes_Iad
937 // integer*4 event_number
939 // real radius, crystal_size, crystal_length,
940 // + matrix_coordinate_Z, matrix_coordinate_PHI
942 // real crystals_amplitudes, crystals_energy_total
943 // integer event_file_unit_number
945 // common /common_for_event_storing/
946 // + ! Event-independent information
947 // + crystals_matrix_amount_PHOS,
948 // + crystal_matrix_type,
949 // + amount_of_crystals_on_Z,
950 // + amount_of_crystals_on_PHI,
954 // + matrix_coordinate_Z (crystals_matrix_amount_max),
955 // + matrix_coordinate_PHI (crystals_matrix_amount_max),
957 // + ! Event-dependent information
959 // + crystals_amount_with_amplitudes
960 // + (crystals_matrix_amount_max),
961 // + crystals_amplitudes_Iad (2,crystals_in_matrix_amount_max,
962 // + crystals_matrix_amount_max),
964 // + ! These information don't store in data file
965 // + crystals_amplitudes (crystals_amount_max),
966 // + crystals_energy_total,
967 // + event_file_unit_number
970 // parameter (NGp=1000,nsps=10,nvertmax=1000)
971 // COMMON /GAMMA/KG,MW(ngp),ID(ngp),JD(ngp),E(ngp),E4(ngp),
972 // , XW(ngp),YW(ngp),ES(nsps,ngp),ET(nsps,ngp),ISsd(ngp),
973 // , IGDEV(ngp),ZGDEV(ngp),sigexy(3,ngp),Emimx(2,nsps,ngp),
974 // , kgfix,igfix(ngp),cgfix(3,ngp),sgfix(3,ngp),hiw(ngp),
975 // , wsw(nsps,ngp),h1w(ngp),h0w(ngp),raxay(5,ngp),
976 // , sigmaes0(nsps,ngp),dispeces(nsps,ngp),
981 #define rcgamma RCGAMMA
983 #define rcgamma rcgamma_
986 /* extern "C" */ struct
988 enum {NGP=1000, nsps=10, nvertmax=1000};
989 int recons_gammas_amount, mw[NGP],ID[NGP],JD[NGP];
990 float E[NGP], E4[NGP], XW[NGP], YW[NGP], ES[NGP][nsps],ET[NGP][nsps],ISsd[NGP],
991 igdev[NGP],Zgdev[NGP];
992 // sigexy(3,ngp),Emimx(2,nsps,ngp),
993 // , kgfix,igfix(ngp),cgfix(3,ngp),sgfix(3,ngp),hiw(ngp),
994 // , wsw(nsps,ngp),h1w(ngp),h0w(ngp),raxay(5,ngp),
995 // , sigmaes0(nsps,ngp),dispeces(nsps,ngp),
1000 #define reconsfirst RECONSFIRST
1001 #define type_of_call _stdcall
1003 #define reconsfirst reconsfirst_
1004 #define type_of_call
1007 extern "C" void type_of_call reconsfirst(const float &,const float &);
1009 void AliPHOSCradle::Reconstruction(Float_t signal_step, UInt_t min_signal_reject)
1011 // Call of PHOS reconstruction program.
1012 // signal_step=0.001 GeV (1MeV)
1013 // min_signal_reject = 15 or 30 MeV
1016 common_for_event_storing.event_number = 0; // We do not know event number?
1017 common_for_event_storing.crystals_matrix_amount_PHOS = 1;
1018 common_for_event_storing.crystal_matrix_type = 1; // 1 - rectangular
1019 common_for_event_storing.amount_of_crystals_on_Z = fNz;
1020 common_for_event_storing.amount_of_crystals_on_PHI = fNphi;
1022 common_for_event_storing.radius = fRadius;
1023 common_for_event_storing.crystal_size = GetCellSideSize();
1024 common_for_event_storing.crystal_length = fCrystalLength;
1026 common_for_event_storing.matrix_coordinate_Z [0] = 0;
1027 common_for_event_storing.matrix_coordinate_PHI [0] = fPhi;
1029 #define k common_for_event_storing.crystals_amount_with_amplitudes[0]
1032 for( int y=0; y<fNphi; y++ )
1033 for( int x=0; x<fNz; x++ )
1035 UInt_t n = fCellEnergy.GetBin(x,y);
1036 UInt_t signal = (int) (fCellEnergy.GetBinContent(n)/signal_step);
1037 if( signal>=min_signal_reject )
1039 common_for_event_storing.crystals_amplitudes_Iad[0][k][0] = signal;
1040 common_for_event_storing.crystals_amplitudes_Iad[0][k][1] = x + y*fNz;
1046 GetGammasReconstructed().Delete();
1047 GetGammasReconstructed().Compress();
1049 const float stochastic_term = 0.03, // per cents over sqrt(E); E in GeV
1050 electronic_noise = 0.01; // GeV
1051 reconsfirst(stochastic_term,electronic_noise); // Call of reconstruction program.
1053 for( int i=0; i<rcgamma.recons_gammas_amount; i++ )
1055 // new (GetGammasReconstructed().UncheckedAt(i) ) AliPHOSgamma;
1056 // AliPHOSgamma &g = *(AliPHOSgamma*)(GetGammasReconstructed().UncheckedAt(i));
1058 AliPHOSgamma *gggg = new AliPHOSgamma;
1061 Error("Reconstruction","Can not create AliPHOSgamma");
1065 GetGammasReconstructed().Add(gggg);
1066 AliPHOSgamma &g=*gggg;
1068 Float_t thetta, alpha, betta, R=fRadius+rcgamma.Zgdev[i]/10;
1070 g.fX = rcgamma.YW[i]/10;
1071 g.fY = rcgamma.XW[i]/10;
1072 g.fE = rcgamma.E [i];
1074 thetta = atan(g.fX/R);
1076 alpha = atan(g.fY/R);
1077 betta = fPhi/180*TMath::Pi() + alpha;
1079 g.fPx = g.fE * cos(thetta) * cos(betta);
1080 g.fPy = g.fE * cos(thetta) * sin(betta);
1081 g.fPz = g.fE * sin(thetta);
1085 //______________________________________________________________________________
1086 //______________________________________________________________________________
1087 //______________________________________________________________________________
1088 //______________________________________________________________________________
1089 //______________________________________________________________________________
1091 ClassImp(AliPHOSgamma)
1093 //______________________________________________________________________________
1095 void AliPHOSgamma::Print(Option_t *)
1097 float mass = fE*fE - fPx*fPx - fPy*fPy - fPz*fPz;
1102 mass = -sqrt(-mass);
1104 printf("XY=(%+7.2f,%+7.2f) (%+7.2f,%+7.2f,%+7.2f;%7.2f) mass=%8.4f Ipart=%2d\n",
1105 fX,fY,fPx,fPy,fPz,fE,mass,fIpart);
1108 //______________________________________________________________________________
1110 AliPHOSgamma &AliPHOSgamma::operator=(const AliPHOSgamma &g)
1123 //______________________________________________________________________________
1124 //______________________________________________________________________________
1125 //______________________________________________________________________________
1126 //______________________________________________________________________________
1127 //______________________________________________________________________________
1129 ClassImp(AliPHOShit)
1131 //______________________________________________________________________________
1133 AliPHOShit::AliPHOShit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits):
1134 AliHit(shunt, track)
1137 for (i=0;i<5;i++) fVolume[i] = vol[i];
1144 //______________________________________________________________________________