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()
142 //______________________________________________________________________________
144 void AliPHOS::AddHit(Int_t track, Int_t *vol, Float_t *hits)
146 TClonesArray &lhits = *fHits;
147 new(lhits[fNhits++]) AliPHOShit(fIshunt,track,vol,hits);
150 //___________________________________________
151 void AliPHOS::BuildGeometry()
156 const int kColorPHOS = kRed;
158 Top=gAlice->GetGeometry()->GetNode("alice");
162 Float_t pphi=12.9399462;
163 new TRotMatrix("rot988","rot988",90,-3*pphi,90,90-3*pphi,0,0);
164 new TRotMatrix("rot989","rot989",90,- pphi,90,90- pphi,0,0);
165 new TRotMatrix("rot990","rot990",90, pphi,90,90+ pphi,0,0);
166 new TRotMatrix("rot991","rot991",90, 3*pphi,90,90+3*pphi,0,0);
167 new TBRIK("S_PHOS","PHOS box","void",107.3,40,130);
169 Node = new TNode("PHOS1","PHOS1","S_PHOS",-317.824921,-395.014343,0,"rot988");
170 Node->SetLineColor(kColorPHOS);
173 Node = new TNode("PHOS2","PHOS2","S_PHOS",-113.532333,-494.124908,0,"rot989");
175 Node->SetLineColor(kColorPHOS);
177 Node = new TNode("PHOS3","PHOS3","S_PHOS", 113.532333,-494.124908,0,"rot990");
178 Node->SetLineColor(kColorPHOS);
181 Node = new TNode("PHOS4","PHOS4","S_PHOS", 317.824921,-395.014343,0,"rot991");
182 Node->SetLineColor(kColorPHOS);
186 //___________________________________________
187 void AliPHOS::CreateMaterials()
189 // *** DEFINITION OF AVAILABLE PHOS MATERIALS ***
191 // CALLED BY : PHOS_MEDIA
192 // ORIGIN : NICK VAN EIJNDHOVEN
196 Int_t ISXFLD = gAlice->Field()->Integ();
197 Float_t SXMGMX = gAlice->Field()->Max();
199 // --- The PbWO4 crystals ---
200 Float_t ax[3] = { 207.19,183.85,16. };
201 Float_t zx[3] = { 82.,74.,8. };
202 Float_t wx[3] = { 1.,1.,4. };
204 // --- Stainless Steel ---
205 Float_t as[5] = { 55.847,12.011,51.9961,58.69,28.0855 };
206 Float_t zs[5] = { 26.,6.,24.,28.,14. };
207 Float_t ws[5] = { .6392,8e-4,.2,.14,.02 };
209 // --- The polysterene scintillator (CH) ---
210 Float_t ap[2] = { 12.011,1.00794 };
211 Float_t zp[2] = { 6.,1. };
212 Float_t wp[2] = { 1.,1. };
215 Float_t at[2] = { 12.011,1.00794 };
216 Float_t zt[2] = { 6.,1. };
217 Float_t wt[2] = { 1.,2. };
219 // --- Polystyrene foam ---
220 Float_t af[2] = { 12.011,1.00794 };
221 Float_t zf[2] = { 6.,1. };
222 Float_t wf[2] = { 1.,1. };
224 //--- Foam thermo insulation (actual chemical composition unknown yet!) ---
225 Float_t ati[2] = { 12.011,1.00794 };
226 Float_t zti[2] = { 6.,1. };
227 Float_t wti[2] = { 1.,1. };
229 // --- Textolit (actual chemical composition unknown yet!) ---
230 Float_t atx[2] = { 12.011,1.00794 };
231 Float_t ztx[2] = { 6.,1. };
232 Float_t wtx[2] = { 1.,1. };
235 Int_t *idtmed = fIdtmed->GetArray()-699;
237 AliMixture( 0, "PbWO4$", ax, zx, dx, -3, wx);
238 AliMixture( 1, "Polystyrene$", ap, zp, dp, -2, wp);
239 AliMaterial( 2, "Al$", 26.98, 13., 2.7, 8.9, 999);
240 // --- Absorption length^ is ignored ---
241 AliMixture( 3, "Tyvek$", at, zt, dt, -2, wt);
242 AliMixture( 4, "Foam$", af, zf, df, -2, wf);
243 AliMixture( 5, "Stainless Steel$", as, zs, ds, 5, ws);
244 AliMaterial( 6, "Si$", 28.09, 14., 2.33, 9.36, 42.3);
245 AliMixture( 7, "Thermo Insul.$", ati, zti, dti, -2, wti);
246 AliMixture( 8, "Textolit$", atx, ztx, dtx, -2, wtx);
247 AliMaterial(99, "Air$", 14.61, 7.3, .001205, 30420., 67500);
249 AliMedium(0, "PHOS Xtal $", 0, 1, ISXFLD, SXMGMX, 10., .1, .1, .1, .1);
250 AliMedium(1, "CPV scint. $", 1, 1, ISXFLD, SXMGMX, 10., .1, .1, .1, .1);
251 AliMedium(2, "Al parts $", 2, 0, ISXFLD, SXMGMX, 10., .1, .1, .001, .001);
252 AliMedium(3, "Tyvek wrapper$", 3, 0, ISXFLD, SXMGMX, 10., .1, .1, .001, .001);
253 AliMedium(4, "Polyst. foam $", 4, 0, ISXFLD, SXMGMX, 10., .1, .1, .1, .1);
254 AliMedium(5, "Steel cover $", 5, 0, ISXFLD, SXMGMX, 10., .1, .1, 1e-4, 1e-4);
255 AliMedium(6, "Si PIN $", 6, 0, ISXFLD, SXMGMX, 10., .1, .1, .01, .01);
256 AliMedium(7, "Thermo Insul.$", 7, 0, ISXFLD, SXMGMX, 10., .1, .1, .1, .1);
257 AliMedium(8, "Textolit $", 8, 0, ISXFLD, SXMGMX, 10., .1, .1, .1, .1);
258 AliMedium(99, "Air $",99, 0, ISXFLD, SXMGMX, 10., 1., .1, .1, 10);
260 // --- Generate explicitly delta rays in the steel cover ---
261 gMC->Gstpar(idtmed[704], "LOSS", 3.);
262 gMC->Gstpar(idtmed[704], "DRAY", 1.);
263 // --- and in aluminium parts ---
264 gMC->Gstpar(idtmed[701], "LOSS", 3.);
265 gMC->Gstpar(idtmed[701], "DRAY", 1.);
268 //______________________________________________________________________________
270 void AliPHOS::AddPHOSCradles()
273 for(i=0;i<GetCradlesAmount();i++) {
275 int n = fCradles->GetEntries();
276 fCradles->Add(new AliPHOSCradle( IsVersion(), // geometry.
277 GetCrystalSideSize (),
285 GetCPV_PHOS_Distance (),
288 GetCradleAngle (i)));
290 if( n+1 != fCradles->GetEntries() || NULL == fCradles->At(n) )
292 cout << " Can not create or add AliPHOSCradle.\n";
298 //______________________________________________________________________________
300 Int_t AliPHOS::DistancetoPrimitive(Int_t , Int_t )
305 //___________________________________________
311 for(i=0;i<35;i++) printf("*");
312 printf(" PHOS_INIT ");
313 for(i=0;i<35;i++) printf("*");
316 // Here the ABSO initialisation code (if any!)
317 for(i=0;i<80;i++) printf("*");
321 //______________________________________________________________________________
323 void AliPHOS::MakeBranch(Option_t *)
325 // ROOT output initialization to ROOT file.
327 // AliDetector::MakeBranch() is always called.
329 // There will be also special tree "PHOS" with one branch "AliPHOSCradles"
330 // if it was set next flag in the galice card file:
331 // * PHOSflags: YES: X<>0 NO: X=0
332 // * PHOSflags(1) : -----X. Create branch for TObjArray of AliPHOSCradle
336 // In that case special bit CradlesBranch_Bit will be set for AliPHOS
338 AliDetector::MakeBranch();
341 float t = GetPHOS_flag(0)/10;
343 i = (int) ((t-i)*10);
347 SetBit(CradlesBranch_Bit);
349 if( NULL==(fTreePHOS=new TTree(fTreeName.Data(),"PHOS events tree")) )
351 Error("MakeBranch","Can not create TTree");
355 if( NULL==fTreePHOS->GetCurrentFile() )
357 Error("MakeBranch","There is no opened ROOT file");
361 // Create a new branch in the current Root Tree.
363 if( NULL==fTreePHOS->Branch(fBranchNameOfCradles.Data(),"TObjArray",&fCradles,4000,0) )
365 Error("MakeBranch","Can not create branch");
369 printf("The branch %s has been created\n",fBranchNameOfCradles.Data());
372 //______________________________________________________________________________
374 void AliPHOS::SetTreeAddress(void)
376 // ROOT input initialization.
378 // AliDetector::SetTreeAddress() is always called.
380 // If CradlesBranch_Bit is set (see AliPHOS::MakeBranch) than fTreePHOS is
383 AliDetector::SetTreeAddress();
385 if( !TestBit(CradlesBranch_Bit) )
388 if( NULL==(fTreePHOS=(TTree*)gDirectory->Get((char*)(fTreeName.Data())) ) )
390 Error("Can not find Tree \"%s\"\n",fTreeName.Data());
394 TBranch *branch = fTreePHOS->GetBranch(fBranchNameOfCradles.Data());
397 Error("SetTreeAddress","Can not find branch %s in TTree:%s",fBranchNameOfCradles.Data(),fTreeName.Data());
401 branch->SetAddress(&fCradles);
404 //______________________________________________________________________________
406 AliPHOSCradle *AliPHOS::GetCradleOfTheParticle(const TVector3 &p,const TVector3 &v) const
408 // For a given direction 'p' and source point 'v' returns pointer to AliPHOSCradle
409 // in that direction or NULL if AliPHOSCradle was not found.
411 for( int m=0; m<fCradles->GetEntries(); m++ )
413 AliPHOS *PHOS = (AliPHOS *)this; // Removing 'const'...
414 AliPHOSCradle *cradle = (AliPHOSCradle *)PHOS->fCradles->operator[](m);
417 const float d = cradle->GetRadius()-cradle->GetCPV_PHOS_Distance()-cradle->GetCPV_Thikness();
418 cradle->GetXY(p,v,d,x,y,l);
420 if( l>0 && TMath::Abs(x)<cradle->GetNz ()*cradle->GetCellSideSize()/2
421 && TMath::Abs(y)<cradle->GetNphi()*cradle->GetCellSideSize()/2 )
428 //______________________________________________________________________________
430 void AliPHOS::Reconstruction(Float_t signal_step, UInt_t min_signal_reject)
432 // Call AliPHOSCradle::Reconstruction(Float_t signal_step, UInt_t min_signal_reject)
433 // for all AliPHOSCradles.
435 for( int i=0; i<fCradles->GetEntries(); i++ )
436 GetCradle(i).Reconstruction(signal_step,min_signal_reject);
439 //______________________________________________________________________________
441 void AliPHOS::ResetDigits(void)
443 AliDetector::ResetDigits();
445 for( int i=0; i<fCradles->GetEntries(); i++ )
446 ((AliPHOSCradle*)(*fCradles)[i]) -> Clear();
449 //______________________________________________________________________________
451 void AliPHOS::FinishEvent(void)
453 // Called at the end of each 'galice' event.
455 if( NULL!=fTreePHOS )
459 //______________________________________________________________________________
461 void AliPHOS::FinishRun(void)
465 //______________________________________________________________________________
467 void AliPHOS::Print(Option_t *opt)
469 // Print PHOS information.
470 // For each AliPHOSCradle the function AliPHOSCradle::Print(opt) is called.
472 AliPHOS &PHOS = *(AliPHOS *)this; // Removing 'const'...
474 for( int i=0; i<fCradles->GetEntries(); i++ )
476 printf("PHOS cradle %d from %d\n",i+1, fCradles->GetEntries());
477 PHOS.GetCradle(i).Print(opt);
478 printf( "---------------------------------------------------\n");
482 //______________________________________________________________________________
483 void AliPHOS::SetFlags(Float_t p1,Float_t p2,Float_t p3,Float_t p4,
484 Float_t p5,Float_t p6,Float_t p7,Float_t p8,Float_t p9)
497 //______________________________________________________________________________
498 void AliPHOS::SetCell(Float_t p1,Float_t p2,Float_t p3,Float_t p4,
499 Float_t p5,Float_t p6,Float_t p7,Float_t p8,Float_t p9)
512 //______________________________________________________________________________
513 void AliPHOS::SetRadius(Float_t radius)
518 //______________________________________________________________________________
519 void AliPHOS::SetCradleSize(Int_t nz, Int_t nphi, Int_t ncradles)
523 PHOSsize[2]=ncradles;
526 //______________________________________________________________________________
527 void AliPHOS::SetCradleA(Float_t angle)
532 //______________________________________________________________________________
533 void AliPHOS::SetCPV(Float_t p1,Float_t p2,Float_t p3,Float_t p4,
534 Float_t p5,Float_t p6,Float_t p7,Float_t p8,Float_t p9)
547 //______________________________________________________________________________
548 void AliPHOS::SetExtra(Float_t p1,Float_t p2,Float_t p3,Float_t p4,
549 Float_t p5,Float_t p6,Float_t p7,Float_t p8,Float_t p9)
562 //______________________________________________________________________________
563 void AliPHOS::SetTextolitWall(Float_t dx, Float_t dy, Float_t dz)
570 //______________________________________________________________________________
571 void AliPHOS::SetInnerAir(Float_t dx, Float_t dy, Float_t dz)
578 //______________________________________________________________________________
579 void AliPHOS::SetFoam(Float_t dx, Float_t dy, Float_t dz, Float_t dr)
587 ClassImp(AliPHOSCradle)
589 //______________________________________________________________________________
591 AliPHOSCradle::AliPHOSCradle(void) {}
593 //______________________________________________________________________________
595 AliPHOSCradle::AliPHOSCradle( int Geometry ,
596 float CrystalSideSize ,
597 float CrystalLength ,
598 float WrapThickness ,
603 float CPV_Thickness ,
604 float CPV_PHOS_Distance ,
608 fGeometry (Geometry),
610 // fChargedTracksInPIN (),
613 fCrystalSideSize (CrystalSideSize),
614 fCrystalLength (CrystalLength),
615 fWrapThickness (WrapThickness),
616 fAirThickness (AirThickness),
617 fPIN_SideSize (PIN_SideSize),
618 fPIN_Length (PIN_Length),
620 fCPV_PHOS_Distance (CPV_PHOS_Distance),
621 fCPV_Thickness (CPV_Thickness),
626 fCellEnergy = TH2F("CellE","Energy deposition in a cells",fNz,0,fNz,fNphi,0,fNphi);
627 fCellEnergy .SetDirectory(0);
628 fChargedTracksInPIN = TH2S("PINCtracks","Amount of charged tracks in PIN",fNz,0,fNz,fNphi,0,fNphi);
629 fChargedTracksInPIN .SetDirectory(0);
632 //______________________________________________________________________________
634 AliPHOSCradle::~AliPHOSCradle(void) // 28.12.1998
636 fGammasReconstructed.Delete();
637 fParticles .Delete();
640 //______________________________________________________________________________
642 void AliPHOSCradle::Clear(Option_t *)
644 // Clear digit. information.
646 fCellEnergy .Reset();
647 fChargedTracksInPIN .Reset();
648 GetParticles() .Delete();
649 GetParticles() .Compress();
650 GetGammasReconstructed() .Delete();
651 GetGammasReconstructed() .Compress();
657 //______________________________________________________________________________
659 void AliPHOSCradle::AddCPVHit(float x,float y)
661 // Add this hit to the hits list in CPV detector.
663 TArrayF a(fCPV_hitsX.GetSize()+1);
665 memcpy(a.GetArray(),fCPV_hitsX.GetArray(),sizeof(Float_t)*fCPV_hitsX.GetSize());
666 a[fCPV_hitsX.GetSize()] = x;
669 // It must be: fCPV_hitsX.GetSize() == fCPV_hitsY.GetSize()
671 memcpy(a.GetArray(),fCPV_hitsY.GetArray(),sizeof(Float_t)*fCPV_hitsY.GetSize());
672 a[fCPV_hitsY.GetSize()] = y;
676 //______________________________________________________________________________
678 void AliPHOSCradle::GetXY(const TVector3 &p,const TVector3 &v,float R,float &x,float &y,float &l) const
680 // This function calculates hit position (x,y) in the CRADLE cells plain from particle in
681 // the direction given by 'p' (not required to be normalized) and start point
682 // given by 3-vector 'v'. So the particle trajectory is t(l) = v + p*l
683 // were 'l' is a number (distance from 'v' to CRADLE cells plain) and 't' is resulting
684 // three-vector of trajectory point.
686 // After the call to this function user should test that l>=0 (the particle HITED the
687 // plain) and (x,y) are in the region of CRADLE:
690 // AliPHOSCradle cradle(......);
691 // TVector3 p(....), v(....);
693 // cradle.GetXY(p,v,x,y,l);
694 // if( l<0 || TMath::Abs(x)>cradle.GetNz() *cradle.GetCellSideSize()/2
695 // || TMath::Abs(y)>cradle.GetNphi()*cradle.GetCellSideSize()/2 )
696 // cout << "Outside the CRADLE.\n";
698 // We have to create three vectors:
699 // s - central point on the PHOS surface
700 // n1 - first vector in CRADLE plain
701 // n2 - second vector in CRADLE plain
702 // This three vectors are orthonormalized.
704 double phi = fPhi/180*TMath::Pi();
705 TVector3 n1( 0.0 , 0.0 , 1.0 ), // Z direction (X)
706 n2( -sin(phi) , cos(phi) , 0 ), // around beam (Y)
707 s ( R*cos(phi) , R*sin(phi) , 0 ); // central point
709 const double l1_min = 1e-2;
711 p_n1 = p*n1, // * - scalar product.
718 if ( TMath::Abs(l1=p.X()-n1.X()*p_n1-n2.X()*p_n2)>l1_min )
719 { l = (-v.X()+s.X()+n1.X()*(v_n1-s_n1)+n2.X()*(v_n2-s_n2))/l1; }
720 else if ( TMath::Abs(l1=p.Y()-n1.Y()*p_n1-n2.Y()*p_n2)>l1_min )
721 { l = (-v.Y()+s.Y()+n1.Y()*(v_n1-s_n1)+n2.Y()*(v_n2-s_n2))/l1; }
722 else if ( TMath::Abs(l1=p.Z()-n1.Z()*p_n1-n2.Z()*p_n2)>l1_min )
723 { l = (-v.Z()+s.Z()+n1.Z()*(v_n1-s_n1)+n2.Z()*(v_n2-s_n2))/l1; }
725 // double lx = (-v.X()+s.X()+n1.X()*(v.dot(n1)-s.dot(n1))+n2.X()*(v.dot(n2)-s.dot(n2)))/
726 // (p.X()-n1.X()*p.dot(n1)-n2.X()*p.dot(n2)),
727 // ly = (-v.Y()+s.Y()+n1.Y()*(v.dot(n1)-s.dot(n1))+n2.Y()*(v.dot(n2)-s.dot(n2)))/
728 // (p.Y()-n1.Y()*p.dot(n1)-n2.Y()*p.dot(n2)),
729 // lz = (-v.Z()+s.Z()+n1.Z()*(v.dot(n1)-s.dot(n1))+n2.Z()*(v.dot(n2)-s.dot(n2)))/
730 // (p.Z()-n1.Z()*p.dot(n1)-n2.Z()*p.dot(n2));
731 // 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));
732 // 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));
733 // 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));
734 // cout.form("lx,ly,lz = %g,%g,%g\n",lx,ly,lz);
736 x = p_n1*l + v_n1 - s_n1;
737 y = p_n2*l + v_n2 - s_n2;
740 //______________________________________________________________________________
742 void AliPHOSCradle::Print(Option_t *opt)
744 // Print AliPHOSCradle information.
746 // options: 'd' - print energy deposition for EVERY cell
747 // 'p' - print particles list that hit the cradle
748 // 'r' - print list of reconstructed particles
750 AliPHOSCradle *cr = (AliPHOSCradle *)this; // Removing 'const'...
752 printf("AliPHOSCradle: Nz=%d Nphi=%d, fPhi=%f, E=%g, CPV hits amount = %d\n",fNz,fNphi,fPhi,
753 cr->fCellEnergy.GetSumOfWeights(),fCPV_hitsX.GetSize());
755 if( NULL!=strchr(opt,'d') )
757 printf("\n\nCells Energy (in MeV):\n\n |");
758 for( int x=0; x<fNz; x++ )
762 for( int y=fNphi-1; y>=0; y-- )
765 for( int x=0; x<fNz; x++ )
766 printf("%6d",(int)(cr->fCellEnergy.GetBinContent(cr->fCellEnergy.GetBin(x,y))*1000));
772 if( NULL!=strchr(opt,'p') )
774 printf("This cradle was hit by %d particles\n",
775 ((AliPHOSCradle*)this)->GetParticles().GetEntries());
776 TObjArray &p=((AliPHOSCradle*)this)->GetParticles();
777 for( int i=0; i<p.GetEntries(); i++ )
778 ((AliPHOSgamma*)(p[i]))->Print();
781 if( NULL!=strchr(opt,'p') )
783 printf("Amount of reconstructed gammas is %d\n",
784 ((AliPHOSCradle*)this)->GetGammasReconstructed().GetEntries());
786 TObjArray &p=((AliPHOSCradle*)this)->GetGammasReconstructed();
787 for( int i=0; i<p.GetEntries(); i++ )
788 ((AliPHOSgamma*)(p[i]))->Print();
792 //______________________________________________________________________________
794 void AliPHOSCradle::Distortion(const TH2F *Noise, const TH2F *Stochastic, const TH2F *Calibration)
796 // This function changes histogram of cell energies fCellEnergy on the base of input
797 // histograms Noise, Stochastic, Calibration. The histograms must have
800 //////////////////////////////////
801 // Testing the histograms size. //
802 //////////////////////////////////
804 if( fNz!=fCellEnergy.GetNbinsX() || fNphi!=fCellEnergy.GetNbinsY() )
806 printf ("Bad size of CellEnergy! Must be: Nz x Nphi = %d x %d\n"
807 "but size of CellEnergy is: %d x %d\n",
808 fNz,fNphi,fCellEnergy.GetNbinsX(),fCellEnergy.GetNbinsY());
812 if( fNz!=fChargedTracksInPIN.GetNbinsX() || fNphi!=fChargedTracksInPIN.GetNbinsY() )
814 printf ("Bad size of ChargedTracksInPIN! Must be: Nz x Nphi = %d x %d\n"
815 "but size of ChargedTracksInPIN is: %d x %d\n",
816 fNz,fNphi,fChargedTracksInPIN.GetNbinsX(),fChargedTracksInPIN.GetNbinsY());
820 if( NULL!=Noise && (fNz!=Noise->GetNbinsX() || fNphi!=Noise->GetNbinsX()) )
822 printf ("Bad size of Noise! Must be: Nz x Nphi = %d x %d\n"
823 "but size of Noise is: %d x %d\n",
824 fNz,fNphi,fChargedTracksInPIN.GetNbinsX(),fChargedTracksInPIN.GetNbinsY());
828 if( NULL!=Stochastic && (fNz!=Stochastic->GetNbinsX() || fNphi!=Stochastic->GetNbinsX()) )
830 printf ("Bad size of Stochastic! Must be: Nz x Nphi = %d x %d\n"
831 "but size of Stochastic is: %d x %d\n",
832 fNz,fNphi,fChargedTracksInPIN.GetNbinsX(),fChargedTracksInPIN.GetNbinsY());
836 if( NULL!=Calibration && (fNz!=Calibration->GetNbinsX() || fNphi!=Calibration->GetNbinsX()) )
838 printf ("Bad size of Calibration! Must be: Nz x Nphi = %d x %d\n"
839 "but size of Calibration is: %d x %d\n",
840 fNz,fNphi,fChargedTracksInPIN.GetNbinsX(),fChargedTracksInPIN.GetNbinsY());
848 for( int y=0; y<fNphi; y++ )
849 for( int x=0; x<fNz; x++ )
851 const int n = fCellEnergy.GetBin(x,y); // Bin number
854 Float_t E_old=fCellEnergy.GetBinContent(n), E_new=E_old;
856 if( NULL!=Stochastic )
857 E_new = r.Gaus(E_old,sqrt(E_old)*GetDistortedValue(Stochastic,n));
859 if( NULL!=Calibration )
860 E_new *= GetDistortedValue(Calibration,n);
863 E_new += GetDistortedValue(Noise,n);
865 fCellEnergy.SetBinContent(n,E_new);
869 ////////////////////////////////////////////////////////////////////////////////
871 TH2F* AliPHOSCradle::CreateHistForDistortion(const char *name, const char *title,
873 Float_t MU_mu, Float_t MU_sigma,
874 Float_t SIGMA_mu, Float_t SIGMA_sigma)
876 // Create (new TH2F(...)) histogram with information (for every bin) that will
877 // be used for VALUE creation.
878 // Two values will be created for each bin:
879 // MU = TRandom::Gaus(MU_mu,MU_sigma)
881 // SIGMA = TRandom::Gaus(SIGMA_mu,SIGMA_sigma)
882 // The VALUE in a particluar bin will be equal
883 // VALUE = TRandom::Gaus(MU,SIGMA)
885 // Do not forget to delete the histogram at the end of the work.
887 TH2F *h = new TH2F( name,title, Nx,1,Nx, Ny,1,Ny );
890 Error("CreateHistForDistortion","Can not create the histogram");
895 for( int y=0; y<Ny; y++ )
896 for( int x=0; x<Nx; x++ )
898 const int n = h->GetBin(x,y);
899 h->SetBinContent(n,r.Gaus( MU_mu, MU_sigma));
900 h->SetBinError (n,r.Gaus(SIGMA_mu,SIGMA_sigma));
906 ////////////////////////////////////////////////////////////////////////////////
908 Float_t AliPHOSCradle::GetDistortedValue(const TH2F *h, UInt_t n)
910 return r.Gaus(((TH2F*)h)->GetBinContent(n),n);
913 ////////////////////////////////////////////////////////////////////////////////
914 //______________________________________________________________________________
917 #define common_for_event_storing COMMON_FOR_EVENT_STORING
919 #define common_for_event_storing common_for_event_storing_
924 enum { crystals_matrix_amount_max=4, crystals_in_matrix_amount_max=40000 };
926 // Event-independent information
927 UShort_t crystals_matrix_amount_PHOS,
929 amount_of_crystals_on_Z,
930 amount_of_crystals_on_PHI;
934 matrix_coordinate_Z [crystals_matrix_amount_max],
935 matrix_coordinate_PHI [crystals_matrix_amount_max];
937 UShort_t crystals_amount_with_amplitudes [crystals_matrix_amount_max],
938 crystals_amplitudes_Iad [crystals_matrix_amount_max]
939 [crystals_in_matrix_amount_max][2];
940 } common_for_event_storing;
942 // integer*4 crystals_amount_max,crystals_in_matrix_amount_max,
943 // + crystals_matrix_amount_max
944 // parameter (crystals_matrix_amount_max=4)
945 // parameter (crystals_in_matrix_amount_max=40000)
946 // parameter (crystals_amount_max =crystals_matrix_amount_max*
947 // + crystals_in_matrix_amount_max)
949 // * All units are in GeV, cm, radian
950 // real crystal_amplitudes_unit, radius_unit,
951 // + crystal_size_unit, crystal_length_unit,
952 // + matrix_coordinate_Z_unit, matrix_coordinate_PHI_unit
953 // integer crystal_amplitudes_in_units_min
954 // parameter (crystal_amplitudes_in_units_min = 1)
955 // parameter (crystal_amplitudes_unit = 0.001 ) ! 1.0 MeV
956 // parameter (radius_unit = 0.1 ) ! 0.1 cm
957 // parameter (crystal_size_unit = 0.01 ) ! 0.01 cm
958 // parameter (crystal_length_unit = 0.01 ) ! 0.01 cm
959 // parameter (matrix_coordinate_Z_unit = 0.1 ) ! 0.1 cm
960 // parameter (matrix_coordinate_PHI_unit = 1e-4 ) ! 1e-4 radian
962 // integer*2 crystals_matrix_amount_PHOS, crystal_matrix_type,
963 // + amount_of_crystals_on_Z, amount_of_crystals_on_PHI,
964 // + crystals_amount_with_amplitudes, crystals_amplitudes_Iad
965 // integer*4 event_number
967 // real radius, crystal_size, crystal_length,
968 // + matrix_coordinate_Z, matrix_coordinate_PHI
970 // real crystals_amplitudes, crystals_energy_total
971 // integer event_file_unit_number
973 // common /common_for_event_storing/
974 // + ! Event-independent information
975 // + crystals_matrix_amount_PHOS,
976 // + crystal_matrix_type,
977 // + amount_of_crystals_on_Z,
978 // + amount_of_crystals_on_PHI,
982 // + matrix_coordinate_Z (crystals_matrix_amount_max),
983 // + matrix_coordinate_PHI (crystals_matrix_amount_max),
985 // + ! Event-dependent information
987 // + crystals_amount_with_amplitudes
988 // + (crystals_matrix_amount_max),
989 // + crystals_amplitudes_Iad (2,crystals_in_matrix_amount_max,
990 // + crystals_matrix_amount_max),
992 // + ! These information don't store in data file
993 // + crystals_amplitudes (crystals_amount_max),
994 // + crystals_energy_total,
995 // + event_file_unit_number
998 // parameter (NGp=1000,nsps=10,nvertmax=1000)
999 // COMMON /GAMMA/KG,MW(ngp),ID(ngp),JD(ngp),E(ngp),E4(ngp),
1000 // , XW(ngp),YW(ngp),ES(nsps,ngp),ET(nsps,ngp),ISsd(ngp),
1001 // , IGDEV(ngp),ZGDEV(ngp),sigexy(3,ngp),Emimx(2,nsps,ngp),
1002 // , kgfix,igfix(ngp),cgfix(3,ngp),sgfix(3,ngp),hiw(ngp),
1003 // , wsw(nsps,ngp),h1w(ngp),h0w(ngp),raxay(5,ngp),
1004 // , sigmaes0(nsps,ngp),dispeces(nsps,ngp),
1009 #define rcgamma RCGAMMA
1011 #define rcgamma rcgamma_
1016 enum {NGP=1000, nsps=10, nvertmax=1000};
1017 int recons_gammas_amount, mw[NGP],ID[NGP],JD[NGP];
1018 float E[NGP], E4[NGP], XW[NGP], YW[NGP], ES[NGP][nsps],ET[NGP][nsps],ISsd[NGP],
1019 igdev[NGP],Zgdev[NGP];
1020 // sigexy(3,ngp),Emimx(2,nsps,ngp),
1021 // , kgfix,igfix(ngp),cgfix(3,ngp),sgfix(3,ngp),hiw(ngp),
1022 // , wsw(nsps,ngp),h1w(ngp),h0w(ngp),raxay(5,ngp),
1023 // , sigmaes0(nsps,ngp),dispeces(nsps,ngp),
1028 #define reconsfirst RECONSFIRST
1029 #define type_of_call _stdcall
1031 #define reconsfirst reconsfirst_
1032 #define type_of_call
1035 extern "C" void type_of_call reconsfirst(const float &,const float &);
1037 void AliPHOSCradle::Reconstruction(Float_t signal_step, UInt_t min_signal_reject)
1039 // Call of PHOS reconstruction program.
1040 // signal_step=0.001 GeV (1MeV)
1041 // min_signal_reject = 15 or 30 MeV
1044 common_for_event_storing.event_number = 0; // We do not know event number?
1045 common_for_event_storing.crystals_matrix_amount_PHOS = 1;
1046 common_for_event_storing.crystal_matrix_type = 1; // 1 - rectangular
1047 common_for_event_storing.amount_of_crystals_on_Z = fNz;
1048 common_for_event_storing.amount_of_crystals_on_PHI = fNphi;
1050 common_for_event_storing.radius = fRadius;
1051 common_for_event_storing.crystal_size = GetCellSideSize();
1052 common_for_event_storing.crystal_length = fCrystalLength;
1054 common_for_event_storing.matrix_coordinate_Z [0] = 0;
1055 common_for_event_storing.matrix_coordinate_PHI [0] = fPhi;
1057 #define k common_for_event_storing.crystals_amount_with_amplitudes[0]
1060 for( int y=0; y<fNphi; y++ )
1061 for( int x=0; x<fNz; x++ )
1063 UInt_t n = fCellEnergy.GetBin(x,y);
1064 UInt_t signal = (int) (fCellEnergy.GetBinContent(n)/signal_step);
1065 if( signal>=min_signal_reject )
1067 common_for_event_storing.crystals_amplitudes_Iad[0][k][0] = signal;
1068 common_for_event_storing.crystals_amplitudes_Iad[0][k][1] = x + y*fNz;
1074 GetGammasReconstructed().Delete();
1075 GetGammasReconstructed().Compress();
1077 const float stochastic_term = 0.03, // per cents over sqrt(E); E in GeV
1078 electronic_noise = 0.01; // GeV
1079 reconsfirst(stochastic_term,electronic_noise); // Call of reconstruction program.
1081 for( int i=0; i<rcgamma.recons_gammas_amount; i++ )
1083 // new (GetGammasReconstructed().UncheckedAt(i) ) AliPHOSgamma;
1084 // AliPHOSgamma &g = *(AliPHOSgamma*)(GetGammasReconstructed().UncheckedAt(i));
1086 AliPHOSgamma *gggg = new AliPHOSgamma;
1089 Error("Reconstruction","Can not create AliPHOSgamma");
1093 GetGammasReconstructed().Add(gggg);
1094 AliPHOSgamma &g=*gggg;
1096 Float_t thetta, alpha, betta, R=fRadius+rcgamma.Zgdev[i]/10;
1098 g.fX = rcgamma.YW[i]/10;
1099 g.fY = rcgamma.XW[i]/10;
1100 g.fE = rcgamma.E [i];
1102 thetta = atan(g.fX/R);
1104 alpha = atan(g.fY/R);
1105 betta = fPhi/180*TMath::Pi() + alpha;
1107 g.fPx = g.fE * cos(thetta) * cos(betta);
1108 g.fPy = g.fE * cos(thetta) * sin(betta);
1109 g.fPz = g.fE * sin(thetta);
1113 //______________________________________________________________________________
1114 //______________________________________________________________________________
1115 //______________________________________________________________________________
1116 //______________________________________________________________________________
1117 //______________________________________________________________________________
1119 ClassImp(AliPHOSgamma)
1121 //______________________________________________________________________________
1123 void AliPHOSgamma::Print(Option_t *)
1125 float mass = fE*fE - fPx*fPx - fPy*fPy - fPz*fPz;
1130 mass = -sqrt(-mass);
1132 printf("XY=(%+7.2f,%+7.2f) (%+7.2f,%+7.2f,%+7.2f;%7.2f) mass=%8.4f Ipart=%2d\n",
1133 fX,fY,fPx,fPy,fPz,fE,mass,fIpart);
1136 //______________________________________________________________________________
1138 AliPHOSgamma &AliPHOSgamma::operator=(const AliPHOSgamma &g)
1151 //______________________________________________________________________________
1152 //______________________________________________________________________________
1153 //______________________________________________________________________________
1154 //______________________________________________________________________________
1155 //______________________________________________________________________________
1157 ClassImp(AliPHOShit)
1159 //______________________________________________________________________________
1161 AliPHOShit::AliPHOShit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits):
1162 AliHit(shunt, track)
1165 for (i=0;i<5;i++) fVolume[i] = vol[i];
1172 //______________________________________________________________________________