1 /* Copyright (C) 2007 Christian Holm Christensen <cholm@nbi.dk>
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public License
5 * as published by the Free Software Foundation; either version 2.1 of
6 * the License, or (at your option) any later version.
8 * This library is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18 //___________________________________________________________________
24 Root> gSystem->Load("libFMDflow.so");
25 Root> gSystem->AddIncludePath("-I$ALICE_ROOT/FMD")
26 Root> .x FMD/flow/TestFlow.C
31 $ g++ `root-config --cflags --libs` -I$ALICE_ROOT/include \
32 -I$ALICE_ROOT/FMD $ALICE_ROOT/FMD/flow/TestFlow.C -o testflow
36 #include <FMD/flow/AliFMDFlowBinned1D.h>
37 #include <FMD/flow/AliFMDFlowTrue.h>
38 #include <FMD/flow/AliFMDFlowUtil.h>
41 #include <TVirtualPad.h>
49 //____________________________________________________________________
50 /** Generate events */
54 @param psi Possibly fixed event plane (if <0 -> random)
57 @param min Minimum number of observations
58 @param max Maximum number of observations */
59 Generator(Double_t psi=-1,
60 Double_t v1=.05, Double_t v2=.05,
61 UInt_t min=100, UInt_t max=1000)
62 : fPsi(psi), fV1(v1), fV2(v2), fMin(min), fMax(max)
64 /** Prepare for the next event.
65 @return Number of observations */
68 // Generate a uniform random direction
70 if (fPsi >= 0) fPsiR = fPsi;
71 else fPsiR = gRandom->Uniform(0, 2 * TMath::Pi());
72 return unsigned(gRandom->Uniform(fMin, fMax));
74 /** Create an observation */
77 // Generate a uniform random direction
78 Double_t phi = gRandom->Uniform(0, 2 * TMath::Pi());
79 Double_t rel = phi - fPsiR;
80 Double_t dphi = -2 * TMath::Sin(rel) * fV1;
81 dphi -= TMath::Sin(2 * rel) * fV2;
85 /** Get the event plane */
86 Double_t Psi() const { return fPsiR; }
96 /** Run test program */
98 TestFlow(UInt_t n_events=100, Int_t seg=-1, UInt_t n_max=20000)
100 Generator generator(-1, 0.00, 0.05, n_max, n_max);
101 AliFMDFlowAxis a(10, -5, 5);
102 AliFMDFlowBinned1D* flow = new AliFMDFlowBinned1D(2, a);
103 AliFMDFlowTrue1D* real = new AliFMDFlowTrue1D(2, a);
104 TH2D* hist = new TH2D("hist","hist",a.N(),a.Bins(),
105 (seg>0?seg:90),0, 2* TMath::Pi());
106 Double_t dphi = (seg <= 0 ? 0 : 2 * TMath::Pi() / seg);
111 std::cout << std::endl;
112 for (UInt_t i = 0; i < n_events; i++) {
113 std::cout << "\rEvent # " << i << std::flush;
114 // Generate an event, get the number of objects, get the true
115 // event plane, shuffle the phis around randomly.
116 UInt_t n_obs = generator.Prepare();
117 Double_t rpsi_r = NormalizeAngle(generator.Psi());
125 real->SetPsi(rpsi_r);
126 std::cout << " (" << n_obs << " observations)" << std::flush;
127 for (UInt_t j = 0; j < n_obs; j++) {
128 if (j % 2000 == 0) std::cout << "." << std::flush;
129 Double_t x = gRandom->Gaus(0, 3);
130 Double_t phi = generator();
133 Int_t iseg = Int_t(phi / dphi);
134 phi = dphi * (iseg + .5);
140 flow->Event(phis.fArray, xs.fArray, 0, phis.fN);
141 real->Event(tphis.fArray, xs.fArray, 0, tphis.fN);
143 std::cout << std::endl;
147 gStyle->SetPalette(1);
149 TCanvas* c = new TCanvas("C");
152 TVirtualPad* p = c->cd(1);
156 flow->Draw("bnst colz");
160 flow->Draw("bnstr colz");
163 new TBrowser("b", flow);
167 #include <TApplication.h>
168 /** Entry point for test program */
172 TApplication app("app", 0, 0);