1 ////////////////////////////////////////////////
2 // Manager and hits classes for set:PHOS //
3 ////////////////////////////////////////////////
13 // --- Standard library ---
18 // --- galice header files ---
24 //______________________________________________________________________________
29 //______________________________________________________________________________
31 AliPHOS::~AliPHOS(void)
37 //______________________________________________________________________________
42 fBranchNameOfCradles ("AliPHOSCradles"),
47 if( NULL==(fCradles=new TObjArray) )
49 Error("AliPHOS","Can not create fCradles");
55 //______________________________________________________________________________
57 AliPHOS::AliPHOS(const char *name, const char *title)
58 : AliDetector (name,title),
61 fBranchNameOfCradles ("AliPHOSCradles"),
66 <img src="gif/aliphos.gif">
70 fHits = new TClonesArray("AliPHOShit", 405);
74 SetMarkerColor(kGreen);
78 if( NULL==(fCradles=new TObjArray) ) {
79 Error("AliPHOS","Can not create fCradles");
85 //______________________________________________________________________________
87 void AliPHOS::DefPars()
141 //______________________________________________________________________________
143 void AliPHOS::AddHit(Int_t track, Int_t *vol, Float_t *hits)
145 TClonesArray &lhits = *fHits;
146 new(lhits[fNhits++]) AliPHOShit(fIshunt,track,vol,hits);
149 //___________________________________________
150 void AliPHOS::BuildGeometry()
155 const int kColorPHOS = kRed;
157 Top=gAlice->GetGeometry()->GetNode("alice");
161 Float_t pphi=12.9399462;
162 new TRotMatrix("rot988","rot988",90,-3*pphi,90,90-3*pphi,0,0);
163 new TRotMatrix("rot989","rot989",90,- pphi,90,90- pphi,0,0);
164 new TRotMatrix("rot990","rot990",90, pphi,90,90+ pphi,0,0);
165 new TRotMatrix("rot991","rot991",90, 3*pphi,90,90+3*pphi,0,0);
166 new TBRIK("S_PHOS","PHOS box","void",107.3,40,130);
168 Node = new TNode("PHOS1","PHOS1","S_PHOS",-317.824921,-395.014343,0,"rot988");
169 Node->SetLineColor(kColorPHOS);
172 Node = new TNode("PHOS2","PHOS2","S_PHOS",-113.532333,-494.124908,0,"rot989");
174 Node->SetLineColor(kColorPHOS);
176 Node = new TNode("PHOS3","PHOS3","S_PHOS", 113.532333,-494.124908,0,"rot990");
177 Node->SetLineColor(kColorPHOS);
180 Node = new TNode("PHOS4","PHOS4","S_PHOS", 317.824921,-395.014343,0,"rot991");
181 Node->SetLineColor(kColorPHOS);
185 //___________________________________________
186 void AliPHOS::CreateMaterials()
188 // *** DEFINITION OF AVAILABLE PHOS MATERIALS ***
190 // CALLED BY : PHOS_MEDIA
191 // ORIGIN : NICK VAN EIJNDHOVEN
194 AliMC* pMC = AliMC::GetMC();
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 = gAlice->Idtmed();
238 AliMixture( 0, "PbWO4$", ax, zx, dx, -3, wx);
239 AliMixture( 1, "Polystyrene$", ap, zp, dp, -2, wp);
240 AliMaterial( 2, "Al$", 26.98, 13., 2.7, 8.9, 999);
241 // --- Absorption length^ is ignored ---
242 AliMixture( 3, "Tyvek$", at, zt, dt, -2, wt);
243 AliMixture( 4, "Foam$", af, zf, df, -2, wf);
244 AliMixture( 5, "Stainless Steel$", as, zs, ds, 5, ws);
245 AliMaterial( 6, "Si$", 28.09, 14., 2.33, 9.36, 42.3);
246 AliMixture( 7, "Thermo Insul.$", ati, zti, dti, -2, wti);
247 AliMixture( 8, "Textolit$", atx, ztx, dtx, -2, wtx);
248 AliMaterial(99, "Air$", 14.61, 7.3, .001205, 30420., 67500);
250 AliMedium(700, "PHOS Xtal $", 0, 1, ISXFLD, SXMGMX, 10., .1, .1, .1, .1);
251 AliMedium(701, "CPV scint. $", 1, 1, ISXFLD, SXMGMX, 10., .1, .1, .1, .1);
252 AliMedium(702, "Al parts $", 2, 0, ISXFLD, SXMGMX, 10., .1, .1, .001, .001);
253 AliMedium(703, "Tyvek wrapper$", 3, 0, ISXFLD, SXMGMX, 10., .1, .1, .001, .001);
254 AliMedium(704, "Polyst. foam $", 4, 0, ISXFLD, SXMGMX, 10., .1, .1, .1, .1);
255 AliMedium(705, "Steel cover $", 5, 0, ISXFLD, SXMGMX, 10., .1, .1, 1e-4, 1e-4);
256 AliMedium(706, "Si PIN $", 6, 0, ISXFLD, SXMGMX, 10., .1, .1, .01, .01);
257 AliMedium(707, "Thermo Insul.$", 7, 0, ISXFLD, SXMGMX, 10., .1, .1, .1, .1);
258 AliMedium(708, "Textolit $", 8, 0, ISXFLD, SXMGMX, 10., .1, .1, .1, .1);
259 AliMedium(799, "Air $",99, 0, ISXFLD, SXMGMX, 10., 1., .1, .1, 10);
261 // --- Generate explicitly delta rays in the steel cover ---
262 pMC->Gstpar(idtmed[704], "LOSS", 3.);
263 pMC->Gstpar(idtmed[704], "DRAY", 1.);
264 // --- and in aluminium parts ---
265 pMC->Gstpar(idtmed[701], "LOSS", 3.);
266 pMC->Gstpar(idtmed[701], "DRAY", 1.);
269 //______________________________________________________________________________
271 void AliPHOS::AddPHOSCradles()
274 for(i=0;i<GetCradlesAmount();i++) {
276 int n = fCradles->GetEntries();
277 fCradles->Add(new AliPHOSCradle( IsVersion(), // geometry.
278 GetCrystalSideSize (),
286 GetCPV_PHOS_Distance (),
289 GetCradleAngle (i)));
291 if( n+1 != fCradles->GetEntries() || NULL == fCradles->At(n) )
293 cout << " Can not create or add AliPHOSCradle.\n";
299 //______________________________________________________________________________
301 Int_t AliPHOS::DistancetoPrimitive(Int_t , Int_t )
306 //___________________________________________
312 for(i=0;i<35;i++) printf("*");
313 printf(" PHOS_INIT ");
314 for(i=0;i<35;i++) printf("*");
317 // Here the ABSO initialisation code (if any!)
318 for(i=0;i<80;i++) printf("*");
322 //______________________________________________________________________________
324 void AliPHOS::MakeBranch(Option_t *)
326 // ROOT output initialization to ROOT file.
328 // AliDetector::MakeBranch() is always called.
330 // There will be also special tree "PHOS" with one branch "AliPHOSCradles"
331 // if it was set next flag in the galice card file:
332 // * PHOSflags: YES: X<>0 NO: X=0
333 // * PHOSflags(1) : -----X. Create branch for TObjArray of AliPHOSCradle
337 // In that case special bit CradlesBranch_Bit will be set for AliPHOS
339 AliDetector::MakeBranch();
342 float t = GetPHOS_flag(0)/10;
344 i = (int) ((t-i)*10);
348 SetBit(CradlesBranch_Bit);
350 if( NULL==(fTreePHOS=new TTree(fTreeName.Data(),"PHOS events tree")) )
352 Error("MakeBranch","Can not create TTree");
356 if( NULL==fTreePHOS->GetCurrentFile() )
358 Error("MakeBranch","There is no opened ROOT file");
362 // Create a new branch in the current Root Tree.
364 if( NULL==fTreePHOS->Branch(fBranchNameOfCradles.Data(),"TObjArray",&fCradles,4000,0) )
366 Error("MakeBranch","Can not create branch");
370 printf("The branch %s has been created\n",fBranchNameOfCradles.Data());
373 //______________________________________________________________________________
375 void AliPHOS::SetTreeAddress(void)
377 // ROOT input initialization.
379 // AliDetector::SetTreeAddress() is always called.
381 // If CradlesBranch_Bit is set (see AliPHOS::MakeBranch) than fTreePHOS is
384 AliDetector::SetTreeAddress();
386 if( !TestBit(CradlesBranch_Bit) )
389 if( NULL==(fTreePHOS=(TTree*)gDirectory->Get((char*)(fTreeName.Data())) ) )
391 Error("Can not find Tree \"%s\"\n",fTreeName.Data());
395 TBranch *branch = fTreePHOS->GetBranch(fBranchNameOfCradles.Data());
398 Error("SetTreeAddress","Can not find branch %s in TTree:%s",fBranchNameOfCradles.Data(),fTreeName.Data());
402 branch->SetAddress(&fCradles);
405 //______________________________________________________________________________
407 AliPHOSCradle *AliPHOS::GetCradleOfTheParticle(const Hep3Vector &p,const Hep3Vector &v) const
409 // For a given direction 'p' and source point 'v' returns pointer to AliPHOSCradle
410 // in that direction or NULL if AliPHOSCradle was not found.
412 for( int m=0; m<fCradles->GetEntries(); m++ )
414 AliPHOS *PHOS = (AliPHOS *)this; // Removing 'const'...
415 AliPHOSCradle *cradle = (AliPHOSCradle *)PHOS->fCradles->operator[](m);
418 const float d = cradle->GetRadius()-cradle->GetCPV_PHOS_Distance()-cradle->GetCPV_Thikness();
419 cradle->GetXY(p,v,d,x,y,l);
421 if( l>0 && fabs(x)<cradle->GetNz ()*cradle->GetCellSideSize()/2
422 && fabs(y)<cradle->GetNphi()*cradle->GetCellSideSize()/2 )
429 //______________________________________________________________________________
431 void AliPHOS::Reconstruction(Float_t signal_step, UInt_t min_signal_reject)
433 // Call AliPHOSCradle::Reconstruction(Float_t signal_step, UInt_t min_signal_reject)
434 // for all AliPHOSCradles.
436 for( int i=0; i<fCradles->GetEntries(); i++ )
437 GetCradle(i).Reconstruction(signal_step,min_signal_reject);
440 //______________________________________________________________________________
442 void AliPHOS::ResetDigits(void)
444 AliDetector::ResetDigits();
446 for( int i=0; i<fCradles->GetEntries(); i++ )
447 ((AliPHOSCradle*)(*fCradles)[i]) -> Clear();
450 //______________________________________________________________________________
452 void AliPHOS::FinishEvent(void)
454 // Called at the end of each 'galice' event.
456 if( NULL!=fTreePHOS )
460 //______________________________________________________________________________
462 void AliPHOS::FinishRun(void)
466 //______________________________________________________________________________
468 void AliPHOS::Print(Option_t *opt)
470 // Print PHOS information.
471 // For each AliPHOSCradle the function AliPHOSCradle::Print(opt) is called.
473 AliPHOS &PHOS = *(AliPHOS *)this; // Removing 'const'...
475 for( int i=0; i<fCradles->GetEntries(); i++ )
477 printf("PHOS cradle %d from %d\n",i+1, fCradles->GetEntries());
478 PHOS.GetCradle(i).Print(opt);
479 printf( "---------------------------------------------------\n");
483 //______________________________________________________________________________
484 void AliPHOS::SetFlags(Float_t p1,Float_t p2,Float_t p3,Float_t p4,
485 Float_t p5,Float_t p6,Float_t p7,Float_t p8,Float_t p9)
498 //______________________________________________________________________________
499 void AliPHOS::SetCell(Float_t p1,Float_t p2,Float_t p3,Float_t p4,
500 Float_t p5,Float_t p6,Float_t p7,Float_t p8,Float_t p9)
513 //______________________________________________________________________________
514 void AliPHOS::SetRadius(Float_t radius)
519 //______________________________________________________________________________
520 void AliPHOS::SetCradleSize(Int_t nz, Int_t nphi, Int_t ncradles)
524 PHOSsize[2]=ncradles;
527 //______________________________________________________________________________
528 void AliPHOS::SetCradleA(Float_t angle)
533 //______________________________________________________________________________
534 void AliPHOS::SetCPV(Float_t p1,Float_t p2,Float_t p3,Float_t p4,
535 Float_t p5,Float_t p6,Float_t p7,Float_t p8,Float_t p9)
548 //______________________________________________________________________________
549 void AliPHOS::SetExtra(Float_t p1,Float_t p2,Float_t p3,Float_t p4,
550 Float_t p5,Float_t p6,Float_t p7,Float_t p8,Float_t p9)
563 //______________________________________________________________________________
564 void AliPHOS::SetTextolitWall(Float_t dx, Float_t dy, Float_t dz)
571 //______________________________________________________________________________
572 void AliPHOS::SetInnerAir(Float_t dx, Float_t dy, Float_t dz)
579 //______________________________________________________________________________
580 void AliPHOS::SetFoam(Float_t dx, Float_t dy, Float_t dz, Float_t dr)
588 ClassImp(AliPHOSCradle)
590 //______________________________________________________________________________
592 AliPHOSCradle::AliPHOSCradle(void) {}
594 //______________________________________________________________________________
596 AliPHOSCradle::AliPHOSCradle( int Geometry ,
597 float CrystalSideSize ,
598 float CrystalLength ,
599 float WrapThickness ,
604 float CPV_Thickness ,
605 float CPV_PHOS_Distance ,
609 fGeometry (Geometry),
611 // fChargedTracksInPIN (),
614 fCrystalSideSize (CrystalSideSize),
615 fCrystalLength (CrystalLength),
616 fWrapThickness (WrapThickness),
617 fAirThickness (AirThickness),
618 fPIN_SideSize (PIN_SideSize),
619 fPIN_Length (PIN_Length),
621 fCPV_PHOS_Distance (CPV_PHOS_Distance),
622 fCPV_Thickness (CPV_Thickness),
627 fCellEnergy = TH2F("CellE","Energy deposition in a cells",fNz,0,fNz,fNphi,0,fNphi);
628 fCellEnergy .SetDirectory(0);
629 fChargedTracksInPIN = TH2S("PINCtracks","Amount of charged tracks in PIN",fNz,0,fNz,fNphi,0,fNphi);
630 fChargedTracksInPIN .SetDirectory(0);
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();
650 //______________________________________________________________________________
652 void AliPHOSCradle::AddCPVHit(float x,float y)
654 // Add this hit to the hits list in CPV detector.
656 TArrayF a(fCPV_hitsX.GetSize()+1);
658 memcpy(a.GetArray(),fCPV_hitsX.GetArray(),sizeof(Float_t)*fCPV_hitsX.GetSize());
659 a[fCPV_hitsX.GetSize()] = x;
662 // It must be: fCPV_hitsX.GetSize() == fCPV_hitsY.GetSize()
664 memcpy(a.GetArray(),fCPV_hitsY.GetArray(),sizeof(Float_t)*fCPV_hitsY.GetSize());
665 a[fCPV_hitsY.GetSize()] = y;
669 //______________________________________________________________________________
671 void AliPHOSCradle::GetXY(const Hep3Vector &p,const Hep3Vector &v,float R,float &x,float &y,float &l) const
673 // This function calculates hit position (x,y) in the CRADLE cells plain from particle in
674 // the direction given by 'p' (not required to be normalized) and start point
675 // given by 3-vector 'v'. So the particle trajectory is t(l) = v + p*l
676 // were 'l' is a number (distance from 'v' to CRADLE cells plain) and 't' is resulting
677 // three-vector of trajectory point.
679 // After the call to this function user should test that l>=0 (the particle HITED the
680 // plain) and (x,y) are in the region of CRADLE:
683 // AliPHOSCradle cradle(......);
684 // Hep3Vector p(....), v(....);
686 // cradle.GetXY(p,v,x,y,l);
687 // if( l<0 || fabs(x)>cradle.GetNz() *cradle.GetCellSideSize()/2
688 // || fabs(y)>cradle.GetNphi()*cradle.GetCellSideSize()/2 )
689 // cout << "Outside the CRADLE.\n";
691 // We have to create three vectors:
692 // s - central point on the PHOS surface
693 // n1 - first vector in CRADLE plain
694 // n2 - second vector in CRADLE plain
695 // This three vectors are orthonormalized.
697 double phi = fPhi/180*M_PI;
698 Hep3Vector n1( 0 , 0 , 1 ), // Z direction (X)
699 n2( -sin(phi) , cos(phi) , 0 ), // around beam (Y)
700 s ( R*cos(phi) , R*sin(phi) , 0 ); // central point
702 const double l1_min = 1e-2;
704 p_n1 = p.dot(n1), // dot() - scalar product.
708 s_n1 = s.dot(n1), // 0
709 s_n2 = s.dot(n2); // 0
711 if ( fabs(l1=p.x()-n1.x()*p_n1-n2.x()*p_n2)>l1_min )
712 { l = (-v.x()+s.x()+n1.x()*(v_n1-s_n1)+n2.x()*(v_n2-s_n2))/l1; }
713 else if ( fabs(l1=p.y()-n1.y()*p_n1-n2.y()*p_n2)>l1_min )
714 { l = (-v.y()+s.y()+n1.y()*(v_n1-s_n1)+n2.y()*(v_n2-s_n2))/l1; }
715 else if ( fabs(l1=p.z()-n1.z()*p_n1-n2.z()*p_n2)>l1_min )
716 { l = (-v.z()+s.z()+n1.z()*(v_n1-s_n1)+n2.z()*(v_n2-s_n2))/l1; }
718 // double lx = (-v.x()+s.x()+n1.x()*(v.dot(n1)-s.dot(n1))+n2.x()*(v.dot(n2)-s.dot(n2)))/
719 // (p.x()-n1.x()*p.dot(n1)-n2.x()*p.dot(n2)),
720 // ly = (-v.y()+s.y()+n1.y()*(v.dot(n1)-s.dot(n1))+n2.y()*(v.dot(n2)-s.dot(n2)))/
721 // (p.y()-n1.y()*p.dot(n1)-n2.y()*p.dot(n2)),
722 // lz = (-v.z()+s.z()+n1.z()*(v.dot(n1)-s.dot(n1))+n2.z()*(v.dot(n2)-s.dot(n2)))/
723 // (p.z()-n1.z()*p.dot(n1)-n2.z()*p.dot(n2));
724 // 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));
725 // 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));
726 // 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));
727 // cout.form("lx,ly,lz = %g,%g,%g\n",lx,ly,lz);
729 x = p_n1*l + v_n1 - s_n1;
730 y = p_n2*l + v_n2 - s_n2;
733 //______________________________________________________________________________
735 void AliPHOSCradle::Print(Option_t *opt)
737 // Print AliPHOSCradle information.
739 // options: 'd' - print energy deposition for EVERY cell
740 // 'p' - print particles list that hit the cradle
741 // 'r' - print list of reconstructed particles
743 AliPHOSCradle *cr = (AliPHOSCradle *)this; // Removing 'const'...
745 printf("AliPHOSCradle: Nz=%d Nphi=%d, fPhi=%f, E=%g, CPV hits amount = %d\n",fNz,fNphi,fPhi,
746 cr->fCellEnergy.GetSumOfWeights(),fCPV_hitsX.GetSize());
748 if( NULL!=strchr(opt,'d') )
750 printf("\n\nCells Energy (in MeV):\n\n |");
751 for( int x=0; x<fNz; x++ )
755 for( int y=fNphi-1; y>=0; y-- )
758 for( int x=0; x<fNz; x++ )
759 printf("%6d",(int)(cr->fCellEnergy.GetBinContent(cr->fCellEnergy.GetBin(x,y))*1000));
765 if( NULL!=strchr(opt,'p') )
767 printf("This cradle was hit by %d particles\n",
768 ((AliPHOSCradle*)this)->GetParticles().GetEntries());
769 TObjArray &p=((AliPHOSCradle*)this)->GetParticles();
770 for( int i=0; i<p.GetEntries(); i++ )
771 ((AliPHOSgamma*)(p[i]))->Print();
774 if( NULL!=strchr(opt,'p') )
776 printf("Amount of reconstructed gammas is %d\n",
777 ((AliPHOSCradle*)this)->GetGammasReconstructed().GetEntries());
779 TObjArray &p=((AliPHOSCradle*)this)->GetGammasReconstructed();
780 for( int i=0; i<p.GetEntries(); i++ )
781 ((AliPHOSgamma*)(p[i]))->Print();
785 //______________________________________________________________________________
787 void AliPHOSCradle::Distortion(const TH2F *Noise, const TH2F *Stochastic, const TH2F *Calibration)
789 // This function changes histogram of cell energies fCellEnergy on the base of input
790 // histograms Noise, Stochastic, Calibration. The histograms must have
793 //////////////////////////////////
794 // Testing the histograms size. //
795 //////////////////////////////////
797 if( fNz!=fCellEnergy.GetNbinsX() || fNphi!=fCellEnergy.GetNbinsY() )
799 printf ("Bad size of CellEnergy! Must be: Nz x Nphi = %d x %d\n"
800 "but size of CellEnergy is: %d x %d\n",
801 fNz,fNphi,fCellEnergy.GetNbinsX(),fCellEnergy.GetNbinsY());
805 if( fNz!=fChargedTracksInPIN.GetNbinsX() || fNphi!=fChargedTracksInPIN.GetNbinsY() )
807 printf ("Bad size of ChargedTracksInPIN! Must be: Nz x Nphi = %d x %d\n"
808 "but size of ChargedTracksInPIN is: %d x %d\n",
809 fNz,fNphi,fChargedTracksInPIN.GetNbinsX(),fChargedTracksInPIN.GetNbinsY());
813 if( NULL!=Noise && (fNz!=Noise->GetNbinsX() || fNphi!=Noise->GetNbinsX()) )
815 printf ("Bad size of Noise! Must be: Nz x Nphi = %d x %d\n"
816 "but size of Noise is: %d x %d\n",
817 fNz,fNphi,fChargedTracksInPIN.GetNbinsX(),fChargedTracksInPIN.GetNbinsY());
821 if( NULL!=Stochastic && (fNz!=Stochastic->GetNbinsX() || fNphi!=Stochastic->GetNbinsX()) )
823 printf ("Bad size of Stochastic! Must be: Nz x Nphi = %d x %d\n"
824 "but size of Stochastic is: %d x %d\n",
825 fNz,fNphi,fChargedTracksInPIN.GetNbinsX(),fChargedTracksInPIN.GetNbinsY());
829 if( NULL!=Calibration && (fNz!=Calibration->GetNbinsX() || fNphi!=Calibration->GetNbinsX()) )
831 printf ("Bad size of Calibration! Must be: Nz x Nphi = %d x %d\n"
832 "but size of Calibration is: %d x %d\n",
833 fNz,fNphi,fChargedTracksInPIN.GetNbinsX(),fChargedTracksInPIN.GetNbinsY());
841 for( int y=0; y<fNphi; y++ )
842 for( int x=0; x<fNz; x++ )
844 const int n = fCellEnergy.GetBin(x,y); // Bin number
847 Float_t E_old=fCellEnergy.GetBinContent(n), E_new=E_old;
849 if( NULL!=Stochastic )
850 E_new = r.Gaus(E_old,sqrt(E_old)*GetDistortedValue(Stochastic,n));
852 if( NULL!=Calibration )
853 E_new *= GetDistortedValue(Calibration,n);
856 E_new += GetDistortedValue(Noise,n);
858 fCellEnergy.SetBinContent(n,E_new);
862 ////////////////////////////////////////////////////////////////////////////////
864 TH2F* AliPHOSCradle::CreateHistForDistortion(const char *name, const char *title,
866 Float_t MU_mu, Float_t MU_sigma,
867 Float_t SIGMA_mu, Float_t SIGMA_sigma)
869 // Create (new TH2F(...)) histogram with information (for every bin) that will
870 // be used for VALUE creation.
871 // Two values will be created for each bin:
872 // MU = TRandom::Gaus(MU_mu,MU_sigma)
874 // SIGMA = TRandom::Gaus(SIGMA_mu,SIGMA_sigma)
875 // The VALUE in a particluar bin will be equal
876 // VALUE = TRandom::Gaus(MU,SIGMA)
878 // Do not forget to delete the histogram at the end of the work.
880 TH2F *h = new TH2F( name,title, Nx,1,Nx, Ny,1,Ny );
883 Error("CreateHistForDistortion","Can not create the histogram");
888 for( int y=0; y<Ny; y++ )
889 for( int x=0; x<Nx; x++ )
891 const int n = h->GetBin(x,y);
892 h->SetBinContent(n,r.Gaus( MU_mu, MU_sigma));
893 h->SetBinError (n,r.Gaus(SIGMA_mu,SIGMA_sigma));
899 ////////////////////////////////////////////////////////////////////////////////
901 Float_t AliPHOSCradle::GetDistortedValue(const TH2F *h, UInt_t n)
903 return r.Gaus(((TH2F*)h)->GetBinContent(n),n);
906 ////////////////////////////////////////////////////////////////////////////////
907 //______________________________________________________________________________
910 #define common_for_event_storing COMMON_FOR_EVENT_STORING
912 #define common_for_event_storing common_for_event_storing_
917 enum { crystals_matrix_amount_max=4, crystals_in_matrix_amount_max=40000 };
919 // Event-independent information
920 UShort_t crystals_matrix_amount_PHOS,
922 amount_of_crystals_on_Z,
923 amount_of_crystals_on_PHI;
927 matrix_coordinate_Z [crystals_matrix_amount_max],
928 matrix_coordinate_PHI [crystals_matrix_amount_max];
930 UShort_t crystals_amount_with_amplitudes [crystals_matrix_amount_max],
931 crystals_amplitudes_Iad [crystals_matrix_amount_max]
932 [crystals_in_matrix_amount_max][2];
933 } common_for_event_storing;
935 // integer*4 crystals_amount_max,crystals_in_matrix_amount_max,
936 // + crystals_matrix_amount_max
937 // parameter (crystals_matrix_amount_max=4)
938 // parameter (crystals_in_matrix_amount_max=40000)
939 // parameter (crystals_amount_max =crystals_matrix_amount_max*
940 // + crystals_in_matrix_amount_max)
942 // * All units are in GeV, cm, radian
943 // real crystal_amplitudes_unit, radius_unit,
944 // + crystal_size_unit, crystal_length_unit,
945 // + matrix_coordinate_Z_unit, matrix_coordinate_PHI_unit
946 // integer crystal_amplitudes_in_units_min
947 // parameter (crystal_amplitudes_in_units_min = 1)
948 // parameter (crystal_amplitudes_unit = 0.001 ) ! 1.0 MeV
949 // parameter (radius_unit = 0.1 ) ! 0.1 cm
950 // parameter (crystal_size_unit = 0.01 ) ! 0.01 cm
951 // parameter (crystal_length_unit = 0.01 ) ! 0.01 cm
952 // parameter (matrix_coordinate_Z_unit = 0.1 ) ! 0.1 cm
953 // parameter (matrix_coordinate_PHI_unit = 1e-4 ) ! 1e-4 radian
955 // integer*2 crystals_matrix_amount_PHOS, crystal_matrix_type,
956 // + amount_of_crystals_on_Z, amount_of_crystals_on_PHI,
957 // + crystals_amount_with_amplitudes, crystals_amplitudes_Iad
958 // integer*4 event_number
960 // real radius, crystal_size, crystal_length,
961 // + matrix_coordinate_Z, matrix_coordinate_PHI
963 // real crystals_amplitudes, crystals_energy_total
964 // integer event_file_unit_number
966 // common /common_for_event_storing/
967 // + ! Event-independent information
968 // + crystals_matrix_amount_PHOS,
969 // + crystal_matrix_type,
970 // + amount_of_crystals_on_Z,
971 // + amount_of_crystals_on_PHI,
975 // + matrix_coordinate_Z (crystals_matrix_amount_max),
976 // + matrix_coordinate_PHI (crystals_matrix_amount_max),
978 // + ! Event-dependent information
980 // + crystals_amount_with_amplitudes
981 // + (crystals_matrix_amount_max),
982 // + crystals_amplitudes_Iad (2,crystals_in_matrix_amount_max,
983 // + crystals_matrix_amount_max),
985 // + ! These information don't store in data file
986 // + crystals_amplitudes (crystals_amount_max),
987 // + crystals_energy_total,
988 // + event_file_unit_number
991 // parameter (NGp=1000,nsps=10,nvertmax=1000)
992 // COMMON /GAMMA/KG,MW(ngp),ID(ngp),JD(ngp),E(ngp),E4(ngp),
993 // , XW(ngp),YW(ngp),ES(nsps,ngp),ET(nsps,ngp),ISsd(ngp),
994 // , IGDEV(ngp),ZGDEV(ngp),sigexy(3,ngp),Emimx(2,nsps,ngp),
995 // , kgfix,igfix(ngp),cgfix(3,ngp),sgfix(3,ngp),hiw(ngp),
996 // , wsw(nsps,ngp),h1w(ngp),h0w(ngp),raxay(5,ngp),
997 // , sigmaes0(nsps,ngp),dispeces(nsps,ngp),
1002 #define rcgamma RCGAMMA
1004 #define rcgamma rcgamma_
1009 enum {NGP=1000, nsps=10, nvertmax=1000};
1010 int recons_gammas_amount, mw[NGP],ID[NGP],JD[NGP];
1011 float E[NGP], E4[NGP], XW[NGP], YW[NGP], ES[NGP][nsps],ET[NGP][nsps],ISsd[NGP],
1012 igdev[NGP],Zgdev[NGP];
1013 // sigexy(3,ngp),Emimx(2,nsps,ngp),
1014 // , kgfix,igfix(ngp),cgfix(3,ngp),sgfix(3,ngp),hiw(ngp),
1015 // , wsw(nsps,ngp),h1w(ngp),h0w(ngp),raxay(5,ngp),
1016 // , sigmaes0(nsps,ngp),dispeces(nsps,ngp),
1021 #define reconsfirst RECONSFIRST
1022 #define type_of_call _stdcall
1024 #define reconsfirst reconsfirst_
1025 #define type_of_call
1028 extern "C" void type_of_call reconsfirst(const float &,const float &);
1030 void AliPHOSCradle::Reconstruction(Float_t signal_step, UInt_t min_signal_reject)
1032 // Call of PHOS reconstruction program.
1033 // signal_step=0.001 GeV (1MeV)
1034 // min_signal_reject = 15 or 30 MeV
1036 common_for_event_storing.event_number = 0; // We do not know event number?
1037 common_for_event_storing.crystals_matrix_amount_PHOS = 1;
1038 common_for_event_storing.crystal_matrix_type = 1; // 1 - rectangular
1039 common_for_event_storing.amount_of_crystals_on_Z = fNz;
1040 common_for_event_storing.amount_of_crystals_on_PHI = fNphi;
1042 common_for_event_storing.radius = fRadius;
1043 common_for_event_storing.crystal_size = GetCellSideSize();
1044 common_for_event_storing.crystal_length = fCrystalLength;
1046 common_for_event_storing.matrix_coordinate_Z [0] = 0;
1047 common_for_event_storing.matrix_coordinate_PHI [0] = fPhi;
1049 #define k common_for_event_storing.crystals_amount_with_amplitudes[0]
1052 for( int y=0; y<fNphi; y++ )
1053 for( int x=0; x<fNz; x++ )
1055 UInt_t n = fCellEnergy.GetBin(x,y);
1056 UInt_t signal = (int) (fCellEnergy.GetBinContent(n)/signal_step);
1057 if( signal>=min_signal_reject )
1059 common_for_event_storing.crystals_amplitudes_Iad[0][k][0] = signal;
1060 common_for_event_storing.crystals_amplitudes_Iad[0][k][1] = x + y*fNz;
1066 GetGammasReconstructed().Delete();
1067 GetGammasReconstructed().Compress();
1069 const float stochastic_term = 0.03, // per cents over sqrt(E); E in GeV
1070 electronic_noise = 0.01; // GeV
1071 reconsfirst(stochastic_term,electronic_noise); // Call of reconstruction program.
1074 for( int i=0; i<rcgamma.recons_gammas_amount; i++ )
1076 // new (GetGammasReconstructed().UncheckedAt(i) ) AliPHOSgamma;
1077 // AliPHOSgamma &g = *(AliPHOSgamma*)(GetGammasReconstructed().UncheckedAt(i));
1079 AliPHOSgamma *gggg = new AliPHOSgamma;
1082 Error("Reconstruction","Can not create AliPHOSgamma");
1086 GetGammasReconstructed().Add(gggg);
1087 AliPHOSgamma &g=*gggg;
1089 Float_t thetta, alpha, betta, R=fRadius+rcgamma.Zgdev[i]/10;
1091 g.fX = rcgamma.YW[i]/10;
1093 g.fY = rcgamma.XW[i]/10;
1095 g.fE = rcgamma.E [i];
1096 g.fEsigma = 0.01*sqrt(rcgamma.E[i])+0.05;
1098 thetta = atan(g.fX/R);
1100 alpha = atan(g.fY/R);
1101 betta = fPhi/180*M_PI + alpha;
1103 g.fPx = g.fE * cos(thetta) * cos(betta);
1104 g.fPy = g.fE * cos(thetta) * sin(betta);
1105 g.fPz = g.fE * sin(thetta);
1109 //______________________________________________________________________________
1110 //______________________________________________________________________________
1111 //______________________________________________________________________________
1112 //______________________________________________________________________________
1113 //______________________________________________________________________________
1115 ClassImp(AliPHOSgamma)
1117 //______________________________________________________________________________
1119 void AliPHOSgamma::Print(Option_t *)
1121 float mass = fE*fE - fPx*fPx - fPy*fPy - fPz*fPz;
1126 mass = -sqrt(-mass);
1128 printf("XY=(%+7.2f,%+7.2f) (%+7.2f,%+7.2f,%+7.2f;%7.2f) mass=%8.4f\n",
1129 fX,fY,fPx,fPy,fPz,fE,mass);
1132 //______________________________________________________________________________
1134 AliPHOSgamma &AliPHOSgamma::operator=(const AliPHOSgamma &g)
1137 fXsigma = g.fXsigma;
1139 fYsigma = g.fYsigma;
1141 fEsigma = g.fEsigma;
1149 //______________________________________________________________________________
1150 //______________________________________________________________________________
1151 //______________________________________________________________________________
1152 //______________________________________________________________________________
1153 //______________________________________________________________________________
1155 ClassImp(AliPHOShit)
1157 //______________________________________________________________________________
1159 AliPHOShit::AliPHOShit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits):
1160 AliHit(shunt, track)
1163 for (i=0;i<5;i++) fVolume[i] = vol[i];
1170 //______________________________________________________________________________