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 **************************************************************************/
16 //_________________________________________________________________________
17 // This is a TTask that constructs ReconstParticles (reconstructed particles)
20 //-- Authors: Evgeny Karpechev(INR) and Alla Maevsksia
21 //////////////////////////////////////////////////////////////////////////////
23 // --- ROOT system ---
31 // --- Standard library ---
33 #include "Riostream.h"
35 // --- AliRoot header files ---
37 #include "AliFMDdigit.h"
38 #include "AliFMDhit.h"
39 #include "AliFMDReconstParticles.h"
42 #include "AliFMDReconstruction.h"
44 #include "AliHeader.h"
45 #include "AliGenEventHeader.h"
46 ClassImp(AliFMDReconstruction)
49 //____________________________________________________________________________
51 AliFMDReconstruction::AliFMDReconstruction():TTask("AliFMDReconstruction","")
53 fNevents = 0 ; // Number of events to rreconnstraction, 0 means all events in current file
54 // add Task to //root/Tasks folder
55 TTask * roottasks = (TTask*)gROOT->GetRootFolder()->FindObject("Tasks") ;
56 roottasks->Add(this) ;
58 //____________________________________________________________________________
60 AliFMDReconstruction::AliFMDReconstruction(char* HeaderFile, char *ReconstParticlesFile):TTask("AliFMDReconstruction","")
62 fNevents = 0 ; // Number of events to rreconnstraction, 0 means all events in current file
63 fReconstParticlesFile=ReconstParticlesFile ;
64 fHeadersFile=HeaderFile ;
65 //add Task to //root/Tasks folder
66 TTask * roottasks = (TTask*)gROOT->GetRootFolder()->FindObject("Tasks") ;
67 roottasks->Add(this) ;
70 //____________________________________________________________________________
72 AliFMDReconstruction::~AliFMDReconstruction()
75 //----------------------------------------------------------------------------
77 void AliFMDReconstruction::Exec(Option_t *option)
79 //Collects all digits in the same active volume into number of particles
80 cout<<"\nStart AliFMDReconstruction::Exec(...)"<<endl;
81 Int_t const NumVolums=5;
82 Int_t const NumSectors=40;
83 Int_t const NumRings=768;
84 Int_t PadADC[10][50][800];
85 Float_t eta, etain,etaout,rad,theta;
86 Int_t ivol, iSector, iRing;
87 Float_t rin[5]={4.2,15.4,4.2,15.4,4.2};
88 Float_t rout[5]={17.4,28.4,17.4,28.4,17.4};
89 Float_t z[5]={62.8, 75.2, -83.4, -75.2, -340.};
90 Int_t NumberOfRings[5]={768,384,768,384,768};
91 Int_t NumberOfSectors[5]= {20,40,20,40,20};
92 Int_t NumberOfEtaIntervals[5];
93 // number of ring for boundary 0.1 eta
96 AliFMD * FMD = (AliFMD *) gAlice->GetDetector("FMD");
97 TClonesArray *fReconParticles=FMD->ReconParticles();
98 if(fNevents == 0) fNevents=(Int_t)gAlice->TreeE()->GetEntries();
99 cout<<" fNevents "<<fNevents<<endl;
100 for(Int_t ievent=0;ievent<fNevents;ievent++)
102 cout<<" ievent "<<ievent<<endl;
103 for (Int_t i=0; i<NumVolums; i++)
104 for(Int_t j=0; j<NumSectors; j++)
105 for(Int_t ij=0; ij<NumRings; ij++)
106 PadADC[i][j][ij]=0; //zhachem ???
107 gAlice->GetEvent(ievent) ;
108 if(gAlice->TreeH()==0) return;
109 if(gAlice->TreeD()==0) return;
110 brDigits=gAlice->TreeD()->GetBranch("FMD");
112 cerr<<"EXEC Branch FMD digits not found"<<endl;
116 if(gAlice->TreeR()==0) gAlice->MakeTree("R");
118 FMD->MakeBranch("R");
123 AliFMDdigit *fmdDigit;
126 gAlice->TreeD()->GetEvent(0);
127 TClonesArray *FMDdigits=FMD->Digits();
128 Int_t nDigits=FMDdigits->GetEntries();
129 cout<<" nDigits "<<nDigits<<endl;
130 Int_t RecParticles[6];
133 Int_t NumberOfPads=0; //To avoid warning
135 Float_t channelWidth=(22400*50)/1024;
136 for (Int_t digit=0;digit<nDigits;digit++)
138 fmdDigit=(AliFMDdigit*)FMDdigits->UncheckedAt(digit);
139 ivol=fmdDigit->Volume();
140 iSector=fmdDigit->NumberOfSector();
141 iRing=fmdDigit->NumberOfRing();
142 pedestal=Int_t(gRandom->Gaus(500,250));
143 PadADC[ivol-1][iSector-1][iRing-1]=
144 fmdDigit->ADCsignal()
145 -Int_t(Float_t(pedestal)/channelWidth);
146 if (PadADC[ivol-1][iSector-1][iRing-1]<0)
147 PadADC[ivol-1][iSector-1][iRing-1]=0;
149 Int_t Rmin=0; Int_t Rmax=0; //To avoid warning
150 Int_t Smin=0; Int_t Smax=0; //To avoid warning
151 AliHeader *header = gAlice->GetHeader();
152 AliGenEventHeader* genHeader = header->GenEventHeader();
153 TArrayF *o = new TArrayF(3);
154 genHeader->PrimaryVertex(*o);
155 Float_t zVertex=o->At(2);
156 for (ivol=0; ivol<NumVolums; ivol++)
158 Float_t realZ=zVertex+z[ivol];
159 theta=TMath::ATan(rin[ivol]/TMath::Abs(realZ));
160 etain = - TMath::Log( TMath::Tan(theta/2.));
161 theta=TMath::ATan(rout[ivol]/TMath::Abs(realZ));
162 etaout=- TMath::Log( TMath::Tan(theta/2.));
163 NumberOfEtaIntervals[ivol]=Int_t ((etain-etaout)*10);
165 for (Int_t e1=0;e1<=NumberOfEtaIntervals[ivol];e1++)
167 theta = 2.*TMath::ATan (TMath::Exp (-eta));
168 Float_t radmin = TMath::Abs(realZ) * (TMath::Tan (theta));
169 Rmin= Int_t ( (radmin-rin[ivol])*NumberOfRings[ivol]/(rout[ivol]-rin[ivol]));
171 theta = 2.*TMath::ATan (TMath::Exp (-eta));
172 rad = TMath::Abs(realZ) * (TMath::Tan (theta));
173 Rmax=Int_t( (rad-rin[ivol])*NumberOfRings[ivol]/(rout[ivol]-rin[ivol]));
176 Smax=NumberOfSectors[ivol];
177 for (Int_t iring=Rmin; iring<Rmax; iring++)
179 NumberOfPads=(Rmax-Rmin)*(Smax-Smin);
182 isector<=NumberOfSectors[ivol];
184 if(PadADC[ivol][isector-1][iring-1]<zeroADC)
188 (Float_t)ZeroPads/(Float_t)NumberOfPads;
189 RecParticles[0]=ivol;
190 RecParticles[1]=Smin;
191 RecParticles[2]=Smax;
192 RecParticles[3]=Rmin;
193 RecParticles[4]=Rmax;
194 if (zerosRatio>0.1 ||(ivol==2||ivol==4))
196 Determination_by_Poisson
197 (PadADC,ivol+1,Rmin,Rmax,Smin,Smax);
200 Determination_by_thresholds
201 (PadADC,ivol+1,Rmin,Rmax,Smin,Smax);
202 new((*fReconParticles)[nRecPart++])
203 AliFMDReconstParticles(RecParticles);
208 gAlice->TreeR()->Reset();
209 gAlice->TreeR()->Fill();
210 gAlice->TreeR()->Write(0,TObject::kOverwrite);
212 cout<<"\nAliFMDReconstruction::Exec finished"<<endl;
215 //------------------------------------------------------------
216 Int_t AliFMDReconstruction::Determination_by_thresholds
217 (Int_t PadADC[][50][800],Int_t volume, Int_t Rmin, Int_t Rmax,
218 Int_t Smin, Int_t Smax)
220 cout<<"\nStart threshold method\n";
222 Int_t thresholdInner[30]={
224 72, 89, 104, 124, 129,
225 164, 174, 179, 208, 228,
226 248, 268, 317, 337, 357,
227 392, 407, 416, 426, 436,
228 461, 468, 493, 506, 515};
230 Int_t thresholdOuter[30]={0, 18, 48, 77, 105,
237 for (Int_t it=0; it<30; it++) {
238 if(volume==1||volume==3||volume==5) threshold[it]=thresholdInner[it];
239 if(volume==2||volume==4) threshold[it]=thresholdOuter[it];
241 Int_t threshold_array_size = 30;
244 for (Int_t iring=Rmin; iring<Rmax; iring++)
246 for (Int_t isector=Smin; isector<Smax; isector++)
248 for (int i=0;i<threshold_array_size-1;i++)
250 if(PadADC[volume-1][isector][iring]>threshold[i]
251 &&PadADC[volume-1][isector][iring]<=threshold[i+1])
255 }; // if in threshol interval
256 }; //threshold_array_size
259 cout<<"\nEnd threshol method"<<endl;
264 //__________________________________________________________________
266 Int_t AliFMDReconstruction::Determination_by_Poisson (Int_t PadADC[][50][800],
267 Int_t vol, Int_t rmin, Int_t rmax,
268 Int_t secmin, Int_t secmax)
270 // cout<<"\nStart Poisson method";
271 Int_t threshold_adc=1;
273 for (Int_t i=rmin;i<rmax;i++)
275 for (Int_t j=secmin;j<secmax;j++)
277 if (PadADC[vol-1][j][i]<threshold_adc) zeropads++;
280 Float_t lambda=-TMath::Log(Float_t(zeropads)/
281 ( Float_t(secmax-secmin)*
282 Float_t(rmax-rmin))); //+1 zdes' ne nado
283 Int_t Recon=(Int_t)(lambda*(secmax-secmin)*(rmax-rmin)); //+1 zdes' ne nado
284 // cout<<"\nEnd Poisson method"<<endl;
288 //------------------------------------------------------------------