11 #include <TProfile2D.h>
13 #include <AliFMDInput.h>
14 #include <AliFMDAnaRing.h>
15 #include <AliFMDGeometry.h>
16 #include <AliCDBManager.h>
19 //====================================================================
20 class AliFMDAnaBgRing : public AliFMDAnaRing
23 AliFMDAnaBgRing(UShort_t det, Char_t ring,
24 Float_t deta, Float_t etaMin, Float_t etaMax)
25 : AliFMDAnaRing(det, ring, 0, 0, 0),
26 fTotal(Form("total_%s", fName), "Total number of hits",
27 Int_t((etaMax-etaMin)/deta+.5), etaMin, etaMax,
28 fNSeq, 0, 2*TMath::Pi()),
29 fPrimary(Form("primary_%s", fName), "Number of hits from primary",
30 Int_t((etaMax-etaMin)/deta+.5), etaMin, etaMax,
31 fNSeq, 0, 2*TMath::Pi()),
32 fRatio(Form("ratio_%s", fName), "Correction factors",
33 Int_t((etaMax-etaMin)/deta+.5), etaMin, etaMax,
34 fNSeq, 0, 2*TMath::Pi()),
35 fInverse(Form("inverse_%s", fName), "Inverse Correction factors",
36 Int_t((etaMax-etaMin)/deta+.5), etaMin, etaMax,
37 fNSeq, 0, 2*TMath::Pi())
39 fTotal.SetDirectory(0);
41 fTotal.SetXTitle("#eta");
42 fTotal.SetYTitle("#varphi");
43 fTotal.SetZTitle("# of hits");
44 fPrimary.SetDirectory(0);
46 fPrimary.SetXTitle("#eta");
47 fPrimary.SetYTitle("#varphi");
48 fPrimary.SetZTitle("# of primary");
49 fRatio.SetDirectory(0);
51 fRatio.SetXTitle("#eta");
52 fRatio.SetYTitle("#varphi");
53 fRatio.SetZTitle("# of primary/# of hits");
54 fInverse.SetDirectory(0);
56 fInverse.SetXTitle("#eta");
57 fInverse.SetYTitle("#varphi");
58 fInverse.SetZTitle("# of hits/# of primary");
60 void Fill(Float_t phi, Float_t eta, Float_t mult)
62 fTotal.Fill(eta, phi);
63 if (mult >= 1) fPrimary.Fill(eta,phi);
67 fRatio.Add(&fPrimary);
68 fRatio.Divide(&fTotal);
69 fInverse.Add(&fTotal);
70 fInverse.Divide(&fPrimary);
72 void Browse(TBrowser* b)
74 // AliFMDAnaRing::Browse(b);
86 //====================================================================
87 class AliFMDAnaBg : public AliFMDInput
90 //__________________________________________________________________
92 AliFMDAnaBg(Float_t deta=.1)
95 fTotal("total", "Total number of hits",
96 Int_t((fEtaMax-fEtaMin)/deta+.5), fEtaMin, fEtaMax,
97 40, 0, 2*TMath::Pi()),
98 fPrimary("primary", "Number of hits from primary",
99 Int_t((fEtaMax-fEtaMin)/deta+.5), fEtaMin, fEtaMax,
100 40, 0, 2*TMath::Pi()),
101 fRatio("ratio", "Correction factors",
102 Int_t((fEtaMax-fEtaMin)/deta+.5), fEtaMin, fEtaMax,
103 40, 0, 2*TMath::Pi())
105 fTotal.SetDirectory(0);
107 fTotal.SetXTitle("#eta");
108 fTotal.SetYTitle("#varphi");
109 fTotal.SetZTitle("# of hits");
110 fPrimary.SetDirectory(0);
112 fPrimary.SetXTitle("#eta");
113 fPrimary.SetYTitle("#varphi");
114 fPrimary.SetZTitle("# of primary");
115 fRatio.SetDirectory(0);
117 fRatio.SetXTitle("#eta");
118 fRatio.SetYTitle("#varphi");
119 fRatio.SetZTitle("# of primary/# of hits");
121 AliCDBManager::Instance()->SetRun(0);
124 AddLoad(kKinematics);
126 for (int i = 0; i < 5; i++) {
127 UShort_t det = (i == 0 ? 1 : (i <= 2 ? 2 : 3));
128 Char_t rng = (i == 0 ? 'I' : (i % 2 == 1 ? 'I' : 'O'));
129 fRing[i] = new AliFMDAnaBgRing(det,rng,deta,EtaMin(i)-.2,EtaMax(i)+.12);
132 //__________________________________________________________________
133 Int_t FindRing(UShort_t det, Char_t ring) const
137 case 1: idx = 0; break;
138 case 2: idx = 1 + (ring == 'O' || ring == 'o' ? 1 : 0); break;
139 case 3: idx = 3 + (ring == 'O' || ring == 'o' ? 1 : 0); break;
143 //__________________________________________________________________
147 Bool_t ret = AliFMDInput::Init();
148 for (size_t i = 0; i < 5; i++) fRing[i]->Init();
149 AliFMDGeometry::Instance()->Init();
150 AliFMDGeometry::Instance()->InitTransformations();
153 //__________________________________________________________________
154 /** Called at the beginning of an event */
155 Bool_t Begin(Int_t ev)
157 for (size_t i = 0; i < 5; i++) fRing[i]->Begin();
158 return AliFMDInput::Begin(ev);
160 //__________________________________________________________________
161 /** Called at the beginning of an event */
162 Bool_t ProcessHit(AliFMDHit* hit, TParticle* p)
164 Float_t mult = p->IsPrimary() ? 1 : 0;
165 UShort_t det = hit->Detector();
166 Char_t rng = hit->Ring();
167 UShort_t sec = hit->Sector();
168 UShort_t str = hit->Strip();
169 AliFMDAnaBgRing* frn = fRing[FindRing(det, rng)];
171 AliFMDGeometry::Instance()->Detector2XYZ(det,rng,sec,str,x,y,z);
172 Double_t phi = TMath::ATan2(y,x);
173 Double_t r = TMath::Sqrt(x * x + y * y);
174 Double_t the = TMath::ATan2(r, z);
175 Double_t eta = -TMath::Log(TMath::Tan(the/2));
176 if (phi < 0) phi += 2*TMath::Pi();
177 frn->Fill(phi, eta, mult);
178 Fill(phi, eta, mult);
182 //__________________________________________________________________
183 /** Fill in one strip */
184 void Fill(Float_t phi, Float_t eta, Float_t mult)
186 fTotal.Fill(eta, phi);
187 if (mult >= 1) fPrimary.Fill(eta,phi);
189 //__________________________________________________________________
190 /** Called at the end of an event */
193 for (UShort_t i = 0; i < 5; i++) fRing[i]->End();
194 return AliFMDInput::End();
196 //__________________________________________________________________
197 /** called at the end of a run */
200 gStyle->SetPalette(1);
201 gStyle->SetOptTitle(0);
202 gStyle->SetOptStat(0);
204 fRatio.Add(&fPrimary);
205 fRatio.Divide(&fTotal);
207 for (UShort_t i = 0; i < 5; i++) fRing[i]->Finish();
209 TCanvas* c = new TCanvas("c1", "Result", 800, 600);
212 c->SetTopMargin(0.02);
213 c->SetRightMargin(0.02);
217 c->SetHighLightColor(0);
219 for (UShort_t i = 0; i < 5; i++) {
221 fRing[i]->fRatio.Draw("colz");
224 c = new TCanvas("c2", "All", 800, 600);
227 c->SetTopMargin(0.02);
228 c->SetRightMargin(0.02);
232 c->SetHighLightColor(0);
236 // gROOT->GetListOfSpecials()->Add(this);
239 //__________________________________________________________________
240 Bool_t IsFolder() const { return kTRUE; }
241 //__________________________________________________________________
242 void Browse(TBrowser* b)
244 for (size_t i = 0; i < 5; i++)
245 b->Add(fRing[i], fRing[i]->Name());
247 //__________________________________________________________________
248 /** Get min pseudo rapidity of ring idx */
249 Float_t EtaMin(Int_t idx) const {
251 case 0: return 3.61728; break; // FMD1I
252 case 1: return 2.18122; break; // FMD2I
253 case 2: return 1.79821; break; // FMD2O
254 case 3: return -3.39913; break; // FMD3I
255 case 4: return -2.28925; break; // FMD3O
259 //__________________________________________________________________
260 /** Get max pseudo rapidity of ring idx */
261 Float_t EtaMax(Int_t idx) const {
263 case 0: return 5.02643; break; // FMD1I
264 case 1: return 3.57899; break; // FMD2I
265 case 2: return 2.39085; break; // FMD2O
266 case 3: return -2.00644; break; // FMD3I
267 case 4: return -1.70080; break; // FMD3O
272 AliFMDAnaBgRing* fRing[5];
278 ClassDef(AliFMDAnaBg,1)
281 //____________________________________________________________________