1 ////////////////////////////////////////////////
2 // Manager and hits classes for set:PHOS //
3 ////////////////////////////////////////////////
14 // --- Standard library ---
19 // --- galice header files ---
25 //______________________________________________________________________________
30 //______________________________________________________________________________
32 AliPHOS::~AliPHOS(void)
34 delete fHits; // 28.12.1998
35 delete fTreePHOS; // 28.12.1998
40 //______________________________________________________________________________
45 fBranchNameOfCradles ("AliPHOSCradles"),
50 if( NULL==(fCradles=new TObjArray) )
52 Error("AliPHOS","Can not create fCradles");
58 //______________________________________________________________________________
60 AliPHOS::AliPHOS(const char *name, const char *title)
61 : AliDetector (name,title),
64 fBranchNameOfCradles ("AliPHOSCradles"),
69 <img src="gif/aliphos.gif">
73 fHits = new TClonesArray("AliPHOShit", 405);
77 SetMarkerColor(kGreen);
81 if( NULL==(fCradles=new TObjArray) ) {
82 Error("AliPHOS","Can not create fCradles");
88 //______________________________________________________________________________
90 void AliPHOS::DefPars()
144 //______________________________________________________________________________
146 void AliPHOS::AddHit(Int_t track, Int_t *vol, Float_t *hits)
148 TClonesArray &lhits = *fHits;
149 new(lhits[fNhits++]) AliPHOShit(fIshunt,track,vol,hits);
152 //___________________________________________
153 void AliPHOS::BuildGeometry()
158 const int kColorPHOS = kRed;
160 Top=gAlice->GetGeometry()->GetNode("alice");
164 Float_t pphi=12.9399462;
165 new TRotMatrix("rot988","rot988",90,-3*pphi,90,90-3*pphi,0,0);
166 new TRotMatrix("rot989","rot989",90,- pphi,90,90- pphi,0,0);
167 new TRotMatrix("rot990","rot990",90, pphi,90,90+ pphi,0,0);
168 new TRotMatrix("rot991","rot991",90, 3*pphi,90,90+3*pphi,0,0);
169 new TBRIK("S_PHOS","PHOS box","void",107.3,40,130);
171 Node = new TNode("PHOS1","PHOS1","S_PHOS",-317.824921,-395.014343,0,"rot988");
172 Node->SetLineColor(kColorPHOS);
175 Node = new TNode("PHOS2","PHOS2","S_PHOS",-113.532333,-494.124908,0,"rot989");
177 Node->SetLineColor(kColorPHOS);
179 Node = new TNode("PHOS3","PHOS3","S_PHOS", 113.532333,-494.124908,0,"rot990");
180 Node->SetLineColor(kColorPHOS);
183 Node = new TNode("PHOS4","PHOS4","S_PHOS", 317.824921,-395.014343,0,"rot991");
184 Node->SetLineColor(kColorPHOS);
188 //___________________________________________
189 void AliPHOS::CreateMaterials()
191 // *** DEFINITION OF AVAILABLE PHOS MATERIALS ***
193 // CALLED BY : PHOS_MEDIA
194 // ORIGIN : NICK VAN EIJNDHOVEN
197 AliMC* pMC = AliMC::GetMC();
199 Int_t ISXFLD = gAlice->Field()->Integ();
200 Float_t SXMGMX = gAlice->Field()->Max();
202 // --- The PbWO4 crystals ---
203 Float_t ax[3] = { 207.19,183.85,16. };
204 Float_t zx[3] = { 82.,74.,8. };
205 Float_t wx[3] = { 1.,1.,4. };
207 // --- Stainless Steel ---
208 Float_t as[5] = { 55.847,12.011,51.9961,58.69,28.0855 };
209 Float_t zs[5] = { 26.,6.,24.,28.,14. };
210 Float_t ws[5] = { .6392,8e-4,.2,.14,.02 };
212 // --- The polysterene scintillator (CH) ---
213 Float_t ap[2] = { 12.011,1.00794 };
214 Float_t zp[2] = { 6.,1. };
215 Float_t wp[2] = { 1.,1. };
218 Float_t at[2] = { 12.011,1.00794 };
219 Float_t zt[2] = { 6.,1. };
220 Float_t wt[2] = { 1.,2. };
222 // --- Polystyrene foam ---
223 Float_t af[2] = { 12.011,1.00794 };
224 Float_t zf[2] = { 6.,1. };
225 Float_t wf[2] = { 1.,1. };
227 //--- Foam thermo insulation (actual chemical composition unknown yet!) ---
228 Float_t ati[2] = { 12.011,1.00794 };
229 Float_t zti[2] = { 6.,1. };
230 Float_t wti[2] = { 1.,1. };
232 // --- Textolit (actual chemical composition unknown yet!) ---
233 Float_t atx[2] = { 12.011,1.00794 };
234 Float_t ztx[2] = { 6.,1. };
235 Float_t wtx[2] = { 1.,1. };
238 Int_t *idtmed = gAlice->Idtmed();
241 AliMixture( 0, "PbWO4$", ax, zx, dx, -3, wx);
242 AliMixture( 1, "Polystyrene$", ap, zp, dp, -2, wp);
243 AliMaterial( 2, "Al$", 26.98, 13., 2.7, 8.9, 999);
244 // --- Absorption length^ is ignored ---
245 AliMixture( 3, "Tyvek$", at, zt, dt, -2, wt);
246 AliMixture( 4, "Foam$", af, zf, df, -2, wf);
247 AliMixture( 5, "Stainless Steel$", as, zs, ds, 5, ws);
248 AliMaterial( 6, "Si$", 28.09, 14., 2.33, 9.36, 42.3);
249 AliMixture( 7, "Thermo Insul.$", ati, zti, dti, -2, wti);
250 AliMixture( 8, "Textolit$", atx, ztx, dtx, -2, wtx);
251 AliMaterial(99, "Air$", 14.61, 7.3, .001205, 30420., 67500);
253 AliMedium(700, "PHOS Xtal $", 0, 1, ISXFLD, SXMGMX, 10., .1, .1, .1, .1);
254 AliMedium(701, "CPV scint. $", 1, 1, ISXFLD, SXMGMX, 10., .1, .1, .1, .1);
255 AliMedium(702, "Al parts $", 2, 0, ISXFLD, SXMGMX, 10., .1, .1, .001, .001);
256 AliMedium(703, "Tyvek wrapper$", 3, 0, ISXFLD, SXMGMX, 10., .1, .1, .001, .001);
257 AliMedium(704, "Polyst. foam $", 4, 0, ISXFLD, SXMGMX, 10., .1, .1, .1, .1);
258 AliMedium(705, "Steel cover $", 5, 0, ISXFLD, SXMGMX, 10., .1, .1, 1e-4, 1e-4);
259 AliMedium(706, "Si PIN $", 6, 0, ISXFLD, SXMGMX, 10., .1, .1, .01, .01);
260 AliMedium(707, "Thermo Insul.$", 7, 0, ISXFLD, SXMGMX, 10., .1, .1, .1, .1);
261 AliMedium(708, "Textolit $", 8, 0, ISXFLD, SXMGMX, 10., .1, .1, .1, .1);
262 AliMedium(799, "Air $",99, 0, ISXFLD, SXMGMX, 10., 1., .1, .1, 10);
264 // --- Generate explicitly delta rays in the steel cover ---
265 pMC->Gstpar(idtmed[704], "LOSS", 3.);
266 pMC->Gstpar(idtmed[704], "DRAY", 1.);
267 // --- and in aluminium parts ---
268 pMC->Gstpar(idtmed[701], "LOSS", 3.);
269 pMC->Gstpar(idtmed[701], "DRAY", 1.);
272 //______________________________________________________________________________
274 void AliPHOS::AddPHOSCradles()
277 for(i=0;i<GetCradlesAmount();i++) {
279 int n = fCradles->GetEntries();
280 fCradles->Add(new AliPHOSCradle( IsVersion(), // geometry.
281 GetCrystalSideSize (),
289 GetCPV_PHOS_Distance (),
292 GetCradleAngle (i)));
294 if( n+1 != fCradles->GetEntries() || NULL == fCradles->At(n) )
296 cout << " Can not create or add AliPHOSCradle.\n";
302 //______________________________________________________________________________
304 Int_t AliPHOS::DistancetoPrimitive(Int_t , Int_t )
309 //___________________________________________
315 for(i=0;i<35;i++) printf("*");
316 printf(" PHOS_INIT ");
317 for(i=0;i<35;i++) printf("*");
320 // Here the ABSO initialisation code (if any!)
321 for(i=0;i<80;i++) printf("*");
325 //______________________________________________________________________________
327 void AliPHOS::MakeBranch(Option_t *)
329 // ROOT output initialization to ROOT file.
331 // AliDetector::MakeBranch() is always called.
333 // There will be also special tree "PHOS" with one branch "AliPHOSCradles"
334 // if it was set next flag in the galice card file:
335 // * PHOSflags: YES: X<>0 NO: X=0
336 // * PHOSflags(1) : -----X. Create branch for TObjArray of AliPHOSCradle
340 // In that case special bit CradlesBranch_Bit will be set for AliPHOS
342 AliDetector::MakeBranch();
345 float t = GetPHOS_flag(0)/10;
347 i = (int) ((t-i)*10);
351 SetBit(CradlesBranch_Bit);
353 if( NULL==(fTreePHOS=new TTree(fTreeName.Data(),"PHOS events tree")) )
355 Error("MakeBranch","Can not create TTree");
359 if( NULL==fTreePHOS->GetCurrentFile() )
361 Error("MakeBranch","There is no opened ROOT file");
365 // Create a new branch in the current Root Tree.
367 if( NULL==fTreePHOS->Branch(fBranchNameOfCradles.Data(),"TObjArray",&fCradles,4000,0) )
369 Error("MakeBranch","Can not create branch");
373 printf("The branch %s has been created\n",fBranchNameOfCradles.Data());
376 //______________________________________________________________________________
378 void AliPHOS::SetTreeAddress(void)
380 // ROOT input initialization.
382 // AliDetector::SetTreeAddress() is always called.
384 // If CradlesBranch_Bit is set (see AliPHOS::MakeBranch) than fTreePHOS is
387 AliDetector::SetTreeAddress();
389 if( !TestBit(CradlesBranch_Bit) )
392 if( NULL==(fTreePHOS=(TTree*)gDirectory->Get((char*)(fTreeName.Data())) ) )
394 Error("Can not find Tree \"%s\"\n",fTreeName.Data());
398 TBranch *branch = fTreePHOS->GetBranch(fBranchNameOfCradles.Data());
401 Error("SetTreeAddress","Can not find branch %s in TTree:%s",fBranchNameOfCradles.Data(),fTreeName.Data());
405 branch->SetAddress(&fCradles);
408 //______________________________________________________________________________
410 AliPHOSCradle *AliPHOS::GetCradleOfTheParticle(const TVector3 &p,const TVector3 &v) const
412 // For a given direction 'p' and source point 'v' returns pointer to AliPHOSCradle
413 // in that direction or NULL if AliPHOSCradle was not found.
415 for( int m=0; m<fCradles->GetEntries(); m++ )
417 AliPHOS *PHOS = (AliPHOS *)this; // Removing 'const'...
418 AliPHOSCradle *cradle = (AliPHOSCradle *)PHOS->fCradles->operator[](m);
421 const float d = cradle->GetRadius()-cradle->GetCPV_PHOS_Distance()-cradle->GetCPV_Thikness();
422 cradle->GetXY(p,v,d,x,y,l);
424 if( l>0 && TMath::Abs(x)<cradle->GetNz ()*cradle->GetCellSideSize()/2
425 && TMath::Abs(y)<cradle->GetNphi()*cradle->GetCellSideSize()/2 )
432 //______________________________________________________________________________
434 void AliPHOS::Reconstruction(Float_t signal_step, UInt_t min_signal_reject)
436 // Call AliPHOSCradle::Reconstruction(Float_t signal_step, UInt_t min_signal_reject)
437 // for all AliPHOSCradles.
439 for( int i=0; i<fCradles->GetEntries(); i++ )
440 GetCradle(i).Reconstruction(signal_step,min_signal_reject);
443 //______________________________________________________________________________
445 void AliPHOS::ResetDigits(void)
447 AliDetector::ResetDigits();
449 for( int i=0; i<fCradles->GetEntries(); i++ )
450 ((AliPHOSCradle*)(*fCradles)[i]) -> Clear();
453 //______________________________________________________________________________
455 void AliPHOS::FinishEvent(void)
457 // Called at the end of each 'galice' event.
459 if( NULL!=fTreePHOS )
463 //______________________________________________________________________________
465 void AliPHOS::FinishRun(void)
469 //______________________________________________________________________________
471 void AliPHOS::Print(Option_t *opt)
473 // Print PHOS information.
474 // For each AliPHOSCradle the function AliPHOSCradle::Print(opt) is called.
476 AliPHOS &PHOS = *(AliPHOS *)this; // Removing 'const'...
478 for( int i=0; i<fCradles->GetEntries(); i++ )
480 printf("PHOS cradle %d from %d\n",i+1, fCradles->GetEntries());
481 PHOS.GetCradle(i).Print(opt);
482 printf( "---------------------------------------------------\n");
486 //______________________________________________________________________________
487 void AliPHOS::SetFlags(Float_t p1,Float_t p2,Float_t p3,Float_t p4,
488 Float_t p5,Float_t p6,Float_t p7,Float_t p8,Float_t p9)
501 //______________________________________________________________________________
502 void AliPHOS::SetCell(Float_t p1,Float_t p2,Float_t p3,Float_t p4,
503 Float_t p5,Float_t p6,Float_t p7,Float_t p8,Float_t p9)
516 //______________________________________________________________________________
517 void AliPHOS::SetRadius(Float_t radius)
522 //______________________________________________________________________________
523 void AliPHOS::SetCradleSize(Int_t nz, Int_t nphi, Int_t ncradles)
527 PHOSsize[2]=ncradles;
530 //______________________________________________________________________________
531 void AliPHOS::SetCradleA(Float_t angle)
536 //______________________________________________________________________________
537 void AliPHOS::SetCPV(Float_t p1,Float_t p2,Float_t p3,Float_t p4,
538 Float_t p5,Float_t p6,Float_t p7,Float_t p8,Float_t p9)
551 //______________________________________________________________________________
552 void AliPHOS::SetExtra(Float_t p1,Float_t p2,Float_t p3,Float_t p4,
553 Float_t p5,Float_t p6,Float_t p7,Float_t p8,Float_t p9)
566 //______________________________________________________________________________
567 void AliPHOS::SetTextolitWall(Float_t dx, Float_t dy, Float_t dz)
574 //______________________________________________________________________________
575 void AliPHOS::SetInnerAir(Float_t dx, Float_t dy, Float_t dz)
582 //______________________________________________________________________________
583 void AliPHOS::SetFoam(Float_t dx, Float_t dy, Float_t dz, Float_t dr)
591 ClassImp(AliPHOSCradle)
593 //______________________________________________________________________________
595 AliPHOSCradle::AliPHOSCradle(void) {}
597 //______________________________________________________________________________
599 AliPHOSCradle::AliPHOSCradle( int Geometry ,
600 float CrystalSideSize ,
601 float CrystalLength ,
602 float WrapThickness ,
607 float CPV_Thickness ,
608 float CPV_PHOS_Distance ,
612 fGeometry (Geometry),
614 // fChargedTracksInPIN (),
617 fCrystalSideSize (CrystalSideSize),
618 fCrystalLength (CrystalLength),
619 fWrapThickness (WrapThickness),
620 fAirThickness (AirThickness),
621 fPIN_SideSize (PIN_SideSize),
622 fPIN_Length (PIN_Length),
624 fCPV_PHOS_Distance (CPV_PHOS_Distance),
625 fCPV_Thickness (CPV_Thickness),
630 fCellEnergy = TH2F("CellE","Energy deposition in a cells",fNz,0,fNz,fNphi,0,fNphi);
631 fCellEnergy .SetDirectory(0);
632 fChargedTracksInPIN = TH2S("PINCtracks","Amount of charged tracks in PIN",fNz,0,fNz,fNphi,0,fNphi);
633 fChargedTracksInPIN .SetDirectory(0);
636 //______________________________________________________________________________
638 AliPHOSCradle::~AliPHOSCradle(void) // 28.12.1998
640 fGammasReconstructed.Delete();
641 fParticles .Delete();
644 //______________________________________________________________________________
646 void AliPHOSCradle::Clear(Option_t *)
648 // Clear digit. information.
650 fCellEnergy .Reset();
651 fChargedTracksInPIN .Reset();
652 GetParticles() .Delete();
653 GetParticles() .Compress();
654 GetGammasReconstructed() .Delete();
655 GetGammasReconstructed() .Compress();
661 //______________________________________________________________________________
663 void AliPHOSCradle::AddCPVHit(float x,float y)
665 // Add this hit to the hits list in CPV detector.
667 TArrayF a(fCPV_hitsX.GetSize()+1);
669 memcpy(a.GetArray(),fCPV_hitsX.GetArray(),sizeof(Float_t)*fCPV_hitsX.GetSize());
670 a[fCPV_hitsX.GetSize()] = x;
673 // It must be: fCPV_hitsX.GetSize() == fCPV_hitsY.GetSize()
675 memcpy(a.GetArray(),fCPV_hitsY.GetArray(),sizeof(Float_t)*fCPV_hitsY.GetSize());
676 a[fCPV_hitsY.GetSize()] = y;
680 //______________________________________________________________________________
682 void AliPHOSCradle::GetXY(const TVector3 &p,const TVector3 &v,float R,float &x,float &y,float &l) const
684 // This function calculates hit position (x,y) in the CRADLE cells plain from particle in
685 // the direction given by 'p' (not required to be normalized) and start point
686 // given by 3-vector 'v'. So the particle trajectory is t(l) = v + p*l
687 // were 'l' is a number (distance from 'v' to CRADLE cells plain) and 't' is resulting
688 // three-vector of trajectory point.
690 // After the call to this function user should test that l>=0 (the particle HITED the
691 // plain) and (x,y) are in the region of CRADLE:
694 // AliPHOSCradle cradle(......);
695 // TVector3 p(....), v(....);
697 // cradle.GetXY(p,v,x,y,l);
698 // if( l<0 || TMath::Abs(x)>cradle.GetNz() *cradle.GetCellSideSize()/2
699 // || TMath::Abs(y)>cradle.GetNphi()*cradle.GetCellSideSize()/2 )
700 // cout << "Outside the CRADLE.\n";
702 // We have to create three vectors:
703 // s - central point on the PHOS surface
704 // n1 - first vector in CRADLE plain
705 // n2 - second vector in CRADLE plain
706 // This three vectors are orthonormalized.
708 double phi = fPhi/180*TMath::Pi();
709 TVector3 n1( 0.0 , 0.0 , 1.0 ), // Z direction (X)
710 n2( -sin(phi) , cos(phi) , 0 ), // around beam (Y)
711 s ( R*cos(phi) , R*sin(phi) , 0 ); // central point
713 const double l1_min = 1e-2;
715 p_n1 = p*n1, // * - scalar product.
722 if ( TMath::Abs(l1=p.X()-n1.X()*p_n1-n2.X()*p_n2)>l1_min )
723 { l = (-v.X()+s.X()+n1.X()*(v_n1-s_n1)+n2.X()*(v_n2-s_n2))/l1; }
724 else if ( TMath::Abs(l1=p.Y()-n1.Y()*p_n1-n2.Y()*p_n2)>l1_min )
725 { l = (-v.Y()+s.Y()+n1.Y()*(v_n1-s_n1)+n2.Y()*(v_n2-s_n2))/l1; }
726 else if ( TMath::Abs(l1=p.Z()-n1.Z()*p_n1-n2.Z()*p_n2)>l1_min )
727 { l = (-v.Z()+s.Z()+n1.Z()*(v_n1-s_n1)+n2.Z()*(v_n2-s_n2))/l1; }
729 // double lx = (-v.X()+s.X()+n1.X()*(v.dot(n1)-s.dot(n1))+n2.X()*(v.dot(n2)-s.dot(n2)))/
730 // (p.X()-n1.X()*p.dot(n1)-n2.X()*p.dot(n2)),
731 // ly = (-v.Y()+s.Y()+n1.Y()*(v.dot(n1)-s.dot(n1))+n2.Y()*(v.dot(n2)-s.dot(n2)))/
732 // (p.Y()-n1.Y()*p.dot(n1)-n2.Y()*p.dot(n2)),
733 // lz = (-v.Z()+s.Z()+n1.Z()*(v.dot(n1)-s.dot(n1))+n2.Z()*(v.dot(n2)-s.dot(n2)))/
734 // (p.Z()-n1.Z()*p.dot(n1)-n2.Z()*p.dot(n2));
735 // 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));
736 // 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));
737 // 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));
738 // cout.form("lx,ly,lz = %g,%g,%g\n",lx,ly,lz);
740 x = p_n1*l + v_n1 - s_n1;
741 y = p_n2*l + v_n2 - s_n2;
744 //______________________________________________________________________________
746 void AliPHOSCradle::Print(Option_t *opt)
748 // Print AliPHOSCradle information.
750 // options: 'd' - print energy deposition for EVERY cell
751 // 'p' - print particles list that hit the cradle
752 // 'r' - print list of reconstructed particles
754 AliPHOSCradle *cr = (AliPHOSCradle *)this; // Removing 'const'...
756 printf("AliPHOSCradle: Nz=%d Nphi=%d, fPhi=%f, E=%g, CPV hits amount = %d\n",fNz,fNphi,fPhi,
757 cr->fCellEnergy.GetSumOfWeights(),fCPV_hitsX.GetSize());
759 if( NULL!=strchr(opt,'d') )
761 printf("\n\nCells Energy (in MeV):\n\n |");
762 for( int x=0; x<fNz; x++ )
766 for( int y=fNphi-1; y>=0; y-- )
769 for( int x=0; x<fNz; x++ )
770 printf("%6d",(int)(cr->fCellEnergy.GetBinContent(cr->fCellEnergy.GetBin(x,y))*1000));
776 if( NULL!=strchr(opt,'p') )
778 printf("This cradle was hit by %d particles\n",
779 ((AliPHOSCradle*)this)->GetParticles().GetEntries());
780 TObjArray &p=((AliPHOSCradle*)this)->GetParticles();
781 for( int i=0; i<p.GetEntries(); i++ )
782 ((AliPHOSgamma*)(p[i]))->Print();
785 if( NULL!=strchr(opt,'p') )
787 printf("Amount of reconstructed gammas is %d\n",
788 ((AliPHOSCradle*)this)->GetGammasReconstructed().GetEntries());
790 TObjArray &p=((AliPHOSCradle*)this)->GetGammasReconstructed();
791 for( int i=0; i<p.GetEntries(); i++ )
792 ((AliPHOSgamma*)(p[i]))->Print();
796 //______________________________________________________________________________
798 void AliPHOSCradle::Distortion(const TH2F *Noise, const TH2F *Stochastic, const TH2F *Calibration)
800 // This function changes histogram of cell energies fCellEnergy on the base of input
801 // histograms Noise, Stochastic, Calibration. The histograms must have
804 //////////////////////////////////
805 // Testing the histograms size. //
806 //////////////////////////////////
808 if( fNz!=fCellEnergy.GetNbinsX() || fNphi!=fCellEnergy.GetNbinsY() )
810 printf ("Bad size of CellEnergy! Must be: Nz x Nphi = %d x %d\n"
811 "but size of CellEnergy is: %d x %d\n",
812 fNz,fNphi,fCellEnergy.GetNbinsX(),fCellEnergy.GetNbinsY());
816 if( fNz!=fChargedTracksInPIN.GetNbinsX() || fNphi!=fChargedTracksInPIN.GetNbinsY() )
818 printf ("Bad size of ChargedTracksInPIN! Must be: Nz x Nphi = %d x %d\n"
819 "but size of ChargedTracksInPIN is: %d x %d\n",
820 fNz,fNphi,fChargedTracksInPIN.GetNbinsX(),fChargedTracksInPIN.GetNbinsY());
824 if( NULL!=Noise && (fNz!=Noise->GetNbinsX() || fNphi!=Noise->GetNbinsX()) )
826 printf ("Bad size of Noise! Must be: Nz x Nphi = %d x %d\n"
827 "but size of Noise is: %d x %d\n",
828 fNz,fNphi,fChargedTracksInPIN.GetNbinsX(),fChargedTracksInPIN.GetNbinsY());
832 if( NULL!=Stochastic && (fNz!=Stochastic->GetNbinsX() || fNphi!=Stochastic->GetNbinsX()) )
834 printf ("Bad size of Stochastic! Must be: Nz x Nphi = %d x %d\n"
835 "but size of Stochastic is: %d x %d\n",
836 fNz,fNphi,fChargedTracksInPIN.GetNbinsX(),fChargedTracksInPIN.GetNbinsY());
840 if( NULL!=Calibration && (fNz!=Calibration->GetNbinsX() || fNphi!=Calibration->GetNbinsX()) )
842 printf ("Bad size of Calibration! Must be: Nz x Nphi = %d x %d\n"
843 "but size of Calibration is: %d x %d\n",
844 fNz,fNphi,fChargedTracksInPIN.GetNbinsX(),fChargedTracksInPIN.GetNbinsY());
852 for( int y=0; y<fNphi; y++ )
853 for( int x=0; x<fNz; x++ )
855 const int n = fCellEnergy.GetBin(x,y); // Bin number
858 Float_t E_old=fCellEnergy.GetBinContent(n), E_new=E_old;
860 if( NULL!=Stochastic )
861 E_new = r.Gaus(E_old,sqrt(E_old)*GetDistortedValue(Stochastic,n));
863 if( NULL!=Calibration )
864 E_new *= GetDistortedValue(Calibration,n);
867 E_new += GetDistortedValue(Noise,n);
869 fCellEnergy.SetBinContent(n,E_new);
873 ////////////////////////////////////////////////////////////////////////////////
875 TH2F* AliPHOSCradle::CreateHistForDistortion(const char *name, const char *title,
877 Float_t MU_mu, Float_t MU_sigma,
878 Float_t SIGMA_mu, Float_t SIGMA_sigma)
880 // Create (new TH2F(...)) histogram with information (for every bin) that will
881 // be used for VALUE creation.
882 // Two values will be created for each bin:
883 // MU = TRandom::Gaus(MU_mu,MU_sigma)
885 // SIGMA = TRandom::Gaus(SIGMA_mu,SIGMA_sigma)
886 // The VALUE in a particluar bin will be equal
887 // VALUE = TRandom::Gaus(MU,SIGMA)
889 // Do not forget to delete the histogram at the end of the work.
891 TH2F *h = new TH2F( name,title, Nx,1,Nx, Ny,1,Ny );
894 Error("CreateHistForDistortion","Can not create the histogram");
899 for( int y=0; y<Ny; y++ )
900 for( int x=0; x<Nx; x++ )
902 const int n = h->GetBin(x,y);
903 h->SetBinContent(n,r.Gaus( MU_mu, MU_sigma));
904 h->SetBinError (n,r.Gaus(SIGMA_mu,SIGMA_sigma));
910 ////////////////////////////////////////////////////////////////////////////////
912 Float_t AliPHOSCradle::GetDistortedValue(const TH2F *h, UInt_t n)
914 return r.Gaus(((TH2F*)h)->GetBinContent(n),n);
917 ////////////////////////////////////////////////////////////////////////////////
918 //______________________________________________________________________________
921 #define common_for_event_storing COMMON_FOR_EVENT_STORING
923 #define common_for_event_storing common_for_event_storing_
928 enum { crystals_matrix_amount_max=4, crystals_in_matrix_amount_max=40000 };
930 // Event-independent information
931 UShort_t crystals_matrix_amount_PHOS,
933 amount_of_crystals_on_Z,
934 amount_of_crystals_on_PHI;
938 matrix_coordinate_Z [crystals_matrix_amount_max],
939 matrix_coordinate_PHI [crystals_matrix_amount_max];
941 UShort_t crystals_amount_with_amplitudes [crystals_matrix_amount_max],
942 crystals_amplitudes_Iad [crystals_matrix_amount_max]
943 [crystals_in_matrix_amount_max][2];
944 } common_for_event_storing;
946 // integer*4 crystals_amount_max,crystals_in_matrix_amount_max,
947 // + crystals_matrix_amount_max
948 // parameter (crystals_matrix_amount_max=4)
949 // parameter (crystals_in_matrix_amount_max=40000)
950 // parameter (crystals_amount_max =crystals_matrix_amount_max*
951 // + crystals_in_matrix_amount_max)
953 // * All units are in GeV, cm, radian
954 // real crystal_amplitudes_unit, radius_unit,
955 // + crystal_size_unit, crystal_length_unit,
956 // + matrix_coordinate_Z_unit, matrix_coordinate_PHI_unit
957 // integer crystal_amplitudes_in_units_min
958 // parameter (crystal_amplitudes_in_units_min = 1)
959 // parameter (crystal_amplitudes_unit = 0.001 ) ! 1.0 MeV
960 // parameter (radius_unit = 0.1 ) ! 0.1 cm
961 // parameter (crystal_size_unit = 0.01 ) ! 0.01 cm
962 // parameter (crystal_length_unit = 0.01 ) ! 0.01 cm
963 // parameter (matrix_coordinate_Z_unit = 0.1 ) ! 0.1 cm
964 // parameter (matrix_coordinate_PHI_unit = 1e-4 ) ! 1e-4 radian
966 // integer*2 crystals_matrix_amount_PHOS, crystal_matrix_type,
967 // + amount_of_crystals_on_Z, amount_of_crystals_on_PHI,
968 // + crystals_amount_with_amplitudes, crystals_amplitudes_Iad
969 // integer*4 event_number
971 // real radius, crystal_size, crystal_length,
972 // + matrix_coordinate_Z, matrix_coordinate_PHI
974 // real crystals_amplitudes, crystals_energy_total
975 // integer event_file_unit_number
977 // common /common_for_event_storing/
978 // + ! Event-independent information
979 // + crystals_matrix_amount_PHOS,
980 // + crystal_matrix_type,
981 // + amount_of_crystals_on_Z,
982 // + amount_of_crystals_on_PHI,
986 // + matrix_coordinate_Z (crystals_matrix_amount_max),
987 // + matrix_coordinate_PHI (crystals_matrix_amount_max),
989 // + ! Event-dependent information
991 // + crystals_amount_with_amplitudes
992 // + (crystals_matrix_amount_max),
993 // + crystals_amplitudes_Iad (2,crystals_in_matrix_amount_max,
994 // + crystals_matrix_amount_max),
996 // + ! These information don't store in data file
997 // + crystals_amplitudes (crystals_amount_max),
998 // + crystals_energy_total,
999 // + event_file_unit_number
1002 // parameter (NGp=1000,nsps=10,nvertmax=1000)
1003 // COMMON /GAMMA/KG,MW(ngp),ID(ngp),JD(ngp),E(ngp),E4(ngp),
1004 // , XW(ngp),YW(ngp),ES(nsps,ngp),ET(nsps,ngp),ISsd(ngp),
1005 // , IGDEV(ngp),ZGDEV(ngp),sigexy(3,ngp),Emimx(2,nsps,ngp),
1006 // , kgfix,igfix(ngp),cgfix(3,ngp),sgfix(3,ngp),hiw(ngp),
1007 // , wsw(nsps,ngp),h1w(ngp),h0w(ngp),raxay(5,ngp),
1008 // , sigmaes0(nsps,ngp),dispeces(nsps,ngp),
1013 #define rcgamma RCGAMMA
1015 #define rcgamma rcgamma_
1020 enum {NGP=1000, nsps=10, nvertmax=1000};
1021 int recons_gammas_amount, mw[NGP],ID[NGP],JD[NGP];
1022 float E[NGP], E4[NGP], XW[NGP], YW[NGP], ES[NGP][nsps],ET[NGP][nsps],ISsd[NGP],
1023 igdev[NGP],Zgdev[NGP];
1024 // sigexy(3,ngp),Emimx(2,nsps,ngp),
1025 // , kgfix,igfix(ngp),cgfix(3,ngp),sgfix(3,ngp),hiw(ngp),
1026 // , wsw(nsps,ngp),h1w(ngp),h0w(ngp),raxay(5,ngp),
1027 // , sigmaes0(nsps,ngp),dispeces(nsps,ngp),
1032 #define reconsfirst RECONSFIRST
1033 #define type_of_call _stdcall
1035 #define reconsfirst reconsfirst_
1036 #define type_of_call
1039 extern "C" void type_of_call reconsfirst(const float &,const float &);
1041 void AliPHOSCradle::Reconstruction(Float_t signal_step, UInt_t min_signal_reject)
1043 // Call of PHOS reconstruction program.
1044 // signal_step=0.001 GeV (1MeV)
1045 // min_signal_reject = 15 or 30 MeV
1048 common_for_event_storing.event_number = 0; // We do not know event number?
1049 common_for_event_storing.crystals_matrix_amount_PHOS = 1;
1050 common_for_event_storing.crystal_matrix_type = 1; // 1 - rectangular
1051 common_for_event_storing.amount_of_crystals_on_Z = fNz;
1052 common_for_event_storing.amount_of_crystals_on_PHI = fNphi;
1054 common_for_event_storing.radius = fRadius;
1055 common_for_event_storing.crystal_size = GetCellSideSize();
1056 common_for_event_storing.crystal_length = fCrystalLength;
1058 common_for_event_storing.matrix_coordinate_Z [0] = 0;
1059 common_for_event_storing.matrix_coordinate_PHI [0] = fPhi;
1061 #define k common_for_event_storing.crystals_amount_with_amplitudes[0]
1064 for( int y=0; y<fNphi; y++ )
1065 for( int x=0; x<fNz; x++ )
1067 UInt_t n = fCellEnergy.GetBin(x,y);
1068 UInt_t signal = (int) (fCellEnergy.GetBinContent(n)/signal_step);
1069 if( signal>=min_signal_reject )
1071 common_for_event_storing.crystals_amplitudes_Iad[0][k][0] = signal;
1072 common_for_event_storing.crystals_amplitudes_Iad[0][k][1] = x + y*fNz;
1078 GetGammasReconstructed().Delete();
1079 GetGammasReconstructed().Compress();
1081 const float stochastic_term = 0.03, // per cents over sqrt(E); E in GeV
1082 electronic_noise = 0.01; // GeV
1083 reconsfirst(stochastic_term,electronic_noise); // Call of reconstruction program.
1085 for( int i=0; i<rcgamma.recons_gammas_amount; i++ )
1087 // new (GetGammasReconstructed().UncheckedAt(i) ) AliPHOSgamma;
1088 // AliPHOSgamma &g = *(AliPHOSgamma*)(GetGammasReconstructed().UncheckedAt(i));
1090 AliPHOSgamma *gggg = new AliPHOSgamma;
1093 Error("Reconstruction","Can not create AliPHOSgamma");
1097 GetGammasReconstructed().Add(gggg);
1098 AliPHOSgamma &g=*gggg;
1100 Float_t thetta, alpha, betta, R=fRadius+rcgamma.Zgdev[i]/10;
1102 g.fX = rcgamma.YW[i]/10;
1103 g.fY = rcgamma.XW[i]/10;
1104 g.fE = rcgamma.E [i];
1106 thetta = atan(g.fX/R);
1108 alpha = atan(g.fY/R);
1109 betta = fPhi/180*TMath::Pi() + alpha;
1111 g.fPx = g.fE * cos(thetta) * cos(betta);
1112 g.fPy = g.fE * cos(thetta) * sin(betta);
1113 g.fPz = g.fE * sin(thetta);
1117 //______________________________________________________________________________
1118 //______________________________________________________________________________
1119 //______________________________________________________________________________
1120 //______________________________________________________________________________
1121 //______________________________________________________________________________
1123 ClassImp(AliPHOSgamma)
1125 //______________________________________________________________________________
1127 void AliPHOSgamma::Print(Option_t *)
1129 float mass = fE*fE - fPx*fPx - fPy*fPy - fPz*fPz;
1134 mass = -sqrt(-mass);
1136 printf("XY=(%+7.2f,%+7.2f) (%+7.2f,%+7.2f,%+7.2f;%7.2f) mass=%8.4f Ipart=%2d\n",
1137 fX,fY,fPx,fPy,fPz,fE,mass,fIpart);
1140 //______________________________________________________________________________
1142 AliPHOSgamma &AliPHOSgamma::operator=(const AliPHOSgamma &g)
1155 //______________________________________________________________________________
1156 //______________________________________________________________________________
1157 //______________________________________________________________________________
1158 //______________________________________________________________________________
1159 //______________________________________________________________________________
1161 ClassImp(AliPHOShit)
1163 //______________________________________________________________________________
1165 AliPHOShit::AliPHOShit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits):
1166 AliHit(shunt, track)
1169 for (i=0;i<5;i++) fVolume[i] = vol[i];
1176 //______________________________________________________________________________