1 | /* ======================================================================== *\
|
---|
2 | !
|
---|
3 | ! *
|
---|
4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
---|
6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
---|
8 | ! *
|
---|
9 | ! * Permission to use, copy, modify and distribute this software and its
|
---|
10 | ! * documentation for any purpose is hereby granted without fee,
|
---|
11 | ! * provided that the above copyright notice appear in all copies and
|
---|
12 | ! * that both that copyright notice and this permission notice appear
|
---|
13 | ! * in supporting documentation. It is provided "as is" without express
|
---|
14 | ! * or implied warranty.
|
---|
15 | ! *
|
---|
16 | !
|
---|
17 | !
|
---|
18 | ! Author(s): Javier López, 05/2004 <mailto:jlopez@ifae.es>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2004
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | Bool_t HandleInput()
|
---|
26 | {
|
---|
27 | TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
|
---|
28 | while (1)
|
---|
29 | {
|
---|
30 | //
|
---|
31 | // While reading the input process gui events asynchronously
|
---|
32 | //
|
---|
33 | timer.TurnOn();
|
---|
34 | TString input = Getline("Type 'q' to exit, <return> to go on: ");
|
---|
35 | timer.TurnOff();
|
---|
36 |
|
---|
37 | if (input=="q\n")
|
---|
38 | return kFALSE;
|
---|
39 |
|
---|
40 | if (input=="\n")
|
---|
41 | return kTRUE;
|
---|
42 | };
|
---|
43 |
|
---|
44 | return kFALSE;
|
---|
45 | }
|
---|
46 |
|
---|
47 | Double_t fitfunc(Double_t *x, Double_t *par);
|
---|
48 |
|
---|
49 | void distancebetweenstars(const TString filename="dc_2004_03_17_01_16_51_20440_Mrk421.root", const TString directory="/nfs/magic/CaCodata/rootdata/Mrk421/Period015/2004_03_17/", const UInt_t numEvents = 100000000)
|
---|
50 | {
|
---|
51 |
|
---|
52 | // general settings
|
---|
53 | gROOT->Reset();
|
---|
54 | gStyle->SetCanvasColor(0);
|
---|
55 | gStyle->SetCanvasBorderMode(0);
|
---|
56 | gStyle->SetPadBorderMode(0);
|
---|
57 | gStyle->SetFrameBorderMode(0);
|
---|
58 | gStyle->SetOptTitle(0);
|
---|
59 | gStyle->SetTitleOffset(1.7,"y");
|
---|
60 | gStyle->SetPadLeftMargin(0.15);
|
---|
61 | gStyle->SetOptStat(111110);
|
---|
62 | gStyle->SetOptFit(1);
|
---|
63 | gStyle->SetStatColor(0);
|
---|
64 | gStyle->SetStatBorderSize(1);
|
---|
65 | gStyle->SetStatW(0.2);
|
---|
66 | gStyle->SetStatH(0.1);
|
---|
67 | gStyle->SetStatX(0.9);
|
---|
68 | gStyle->SetStatY(0.9);
|
---|
69 |
|
---|
70 | Int_t nbins = 100;
|
---|
71 | Float_t mindist = 0.0;
|
---|
72 | Float_t maxdist = 400.0;
|
---|
73 |
|
---|
74 | TH1F* histStarsDintances = new TH1F("StarsDintances","Distance between stars",nbins,mindist,maxdist);
|
---|
75 | histStarsDintances->SetXTitle("Distance [mm]");
|
---|
76 | histStarsDintances->SetYTitle("Counts [#]");
|
---|
77 | TH1F* histStarsDintances1 = new TH1F("StarsDintances1","Distance between stars",nbins,mindist,maxdist);
|
---|
78 | TH1F* histStarsDintances2 = new TH1F("StarsDintances2","Distance between stars [1]-[3]",nbins,mindist,maxdist);
|
---|
79 | TH1F* histStarsDintances3 = new TH1F("StarsDintances3","Distance between stars [2]-[3]",nbins,mindist,maxdist);
|
---|
80 | //
|
---|
81 | // Create a empty Parameter List and an empty Task List
|
---|
82 | // The tasklist is identified in the eventloop by its name
|
---|
83 | //
|
---|
84 | MParList plist;
|
---|
85 |
|
---|
86 | MTaskList tlist;
|
---|
87 | plist.AddToList(&tlist);
|
---|
88 |
|
---|
89 | MGeomCamMagic geomcam;
|
---|
90 | MCameraDC dccam;
|
---|
91 | MStarLocalCam starcam;
|
---|
92 |
|
---|
93 | plist.AddToList(&geomcam);
|
---|
94 | plist.AddToList(&dccam);
|
---|
95 | plist.AddToList(&starcam);
|
---|
96 |
|
---|
97 | //
|
---|
98 | // Now setup the tasks and tasklist:
|
---|
99 | // ---------------------------------
|
---|
100 | //
|
---|
101 |
|
---|
102 | // Reads the trees of the root file and the analysed branches
|
---|
103 | MReadReports read;
|
---|
104 | read.AddTree("Currents");
|
---|
105 | read.AddFile(directory+filename); // after the reading of the trees!!!
|
---|
106 | read.AddToBranchList("MReportCurrents.*");
|
---|
107 |
|
---|
108 | MGeomApply geomapl;
|
---|
109 | TString continuoslightfile =
|
---|
110 | // "/home/Javi/mnt_magic_data/CaCo/rootdata/Miscellaneous/Period016/2004_04_16/dc_2004_04_16_04_46_18_22368_Off3c279-2CL100.root";
|
---|
111 | "/nfs/magic/CaCodata/rootdata/Miscellaneous/Period016/2004_04_16/dc_2004_04_16_04_46_18_22368_Off3c279-2CL100.root";
|
---|
112 |
|
---|
113 | Float_t mindc = 0.7;
|
---|
114 | MCalibrateDC dccal;
|
---|
115 | dccal.SetFileName(continuoslightfile);
|
---|
116 | dccal.SetMinDCAllowed(mindc);
|
---|
117 |
|
---|
118 | const Int_t numblind = 5;
|
---|
119 | const Short_t x[numblind] = { 47, 124, 470, 475, 571};
|
---|
120 | const TArrayS blindpixels(numblind,(Short_t*)x);
|
---|
121 | Float_t ringinterest = 100; //[mm]
|
---|
122 | Float_t tailcut = 4.0;
|
---|
123 | UInt_t integratedevents = 1;
|
---|
124 |
|
---|
125 | MFindStars findstars;
|
---|
126 | findstars.SetBlindPixels(blindpixels);
|
---|
127 | findstars.SetRingInterest(ringinterest);
|
---|
128 | findstars.SetDCTailCut(tailcut);
|
---|
129 | findstars.SetNumIntegratedEvents(integratedevents);
|
---|
130 | findstars.SetMinuitPrintOutLevel(-1);
|
---|
131 |
|
---|
132 | tlist.AddToList(&geomapl);
|
---|
133 | tlist.AddToList(&read);
|
---|
134 | tlist.AddToList(&dccal);
|
---|
135 | tlist.AddToList(&findstars, "Currents");
|
---|
136 |
|
---|
137 | //
|
---|
138 | // Create and setup the eventloop
|
---|
139 | //
|
---|
140 | MEvtLoop evtloop;
|
---|
141 | evtloop.SetParList(&plist);
|
---|
142 |
|
---|
143 | // MProgressBar bar;
|
---|
144 | // evtloop.SetProgressBar(&bar);
|
---|
145 |
|
---|
146 | //
|
---|
147 | // Execute your analysis
|
---|
148 | //
|
---|
149 |
|
---|
150 | // if (!evtloop.Eventloop(numEvents))
|
---|
151 | // return;
|
---|
152 |
|
---|
153 | if (!evtloop.PreProcess())
|
---|
154 | return;
|
---|
155 |
|
---|
156 | Float_t maxchindof = 4.;
|
---|
157 |
|
---|
158 | while (tlist.Process())
|
---|
159 | {
|
---|
160 |
|
---|
161 | Int_t numStars = starcam.GetNumStars();
|
---|
162 | if ( numStars == 3)
|
---|
163 | {
|
---|
164 |
|
---|
165 | for (Int_t first=0; first<numStars; first++)
|
---|
166 | {
|
---|
167 | if (starcam[first].GetChiSquareNdof()>0. && starcam[first].GetChiSquareNdof()<maxchindof)
|
---|
168 | {
|
---|
169 | for (Int_t second=first+1; second<numStars; second++)
|
---|
170 | {
|
---|
171 | if (starcam[second].GetChiSquareNdof()>0. && starcam[second].GetChiSquareNdof()<maxchindof)
|
---|
172 | {
|
---|
173 | Float_t dist = TMath::Sqrt((starcam[first].GetMeanX()-starcam[second].GetMeanX())*
|
---|
174 | (starcam[first].GetMeanX()-starcam[second].GetMeanX()) +
|
---|
175 | (starcam[first].GetMeanY()-starcam[second].GetMeanY())*
|
---|
176 | (starcam[first].GetMeanY()-starcam[second].GetMeanY()));
|
---|
177 |
|
---|
178 | histStarsDintances->Fill(dist);
|
---|
179 | if (first == 0 && second == 1)
|
---|
180 | histStarsDintances1->Fill(dist);
|
---|
181 | else if (first == 0 && second == 2)
|
---|
182 | histStarsDintances2->Fill(dist);
|
---|
183 | else if (first == 1 && second == 2)
|
---|
184 | histStarsDintances3->Fill(dist);
|
---|
185 |
|
---|
186 | }
|
---|
187 | }
|
---|
188 | }
|
---|
189 | }
|
---|
190 | }
|
---|
191 | }
|
---|
192 |
|
---|
193 |
|
---|
194 |
|
---|
195 | evtloop.PostProcess();
|
---|
196 |
|
---|
197 | tlist.PrintStatistics();
|
---|
198 |
|
---|
199 | //Draw results
|
---|
200 |
|
---|
201 | // histStarsDintances->Draw();
|
---|
202 |
|
---|
203 | // Creates a Root function based on function fitf above
|
---|
204 | TF1 *func = new TF1("fitfunc",fitfunc,mindist,maxdist,7);
|
---|
205 |
|
---|
206 | // Sets initial values and parameter names
|
---|
207 | func->SetParNames("ConvF","Max0","Sig0","Max1","Sig1","Max2","Sig2");
|
---|
208 | func->SetParameters(300.,500.,5.,500.,5.,500.,5.);
|
---|
209 |
|
---|
210 | // Fit histogram in range defined by function
|
---|
211 | histStarsDintances->Fit("fitfunc","R");
|
---|
212 |
|
---|
213 | // histStarsDintances1->Draw();
|
---|
214 | // histStarsDintances2->Fit("gaus","0");
|
---|
215 | // histStarsDintances2->Draw("same");
|
---|
216 | // histStarsDintances2->Fit("gaus","0");
|
---|
217 | // histStarsDintances3->Draw("same");
|
---|
218 | // histStarsDintances3->Fit("gaus","0");
|
---|
219 |
|
---|
220 | if (!HandleInput())
|
---|
221 |
|
---|
222 | delete histStarsDintances;
|
---|
223 | delete histStarsDintances1;
|
---|
224 | delete histStarsDintances2;
|
---|
225 | delete histStarsDintances3;
|
---|
226 |
|
---|
227 | }
|
---|
228 |
|
---|
229 | Double_t fitfunc(Double_t *x, Double_t *par)
|
---|
230 | {
|
---|
231 | Double_t dist[3] =
|
---|
232 | {
|
---|
233 | 0.64,0.750,1.203
|
---|
234 | };
|
---|
235 |
|
---|
236 |
|
---|
237 | Double_t fitval =
|
---|
238 | par[1]*TMath::Exp(-0.5*(x[0]-par[0]*dist[0])*(x[0]-par[0]*dist[0])/(par[2]*par[2])) +
|
---|
239 | par[3]*TMath::Exp(-0.5*(x[0]-par[0]*dist[1])*(x[0]-par[0]*dist[1])/(par[4]*par[4])) +
|
---|
240 | par[5]*TMath::Exp(-0.5*(x[0]-par[0]*dist[2])*(x[0]-par[0]*dist[2])/(par[6]*par[6]));
|
---|
241 |
|
---|
242 | // cout << "x " << x[0] << " fitval " << fitval << endl;
|
---|
243 |
|
---|
244 |
|
---|
245 | return fitval;
|
---|
246 | }
|
---|
247 |
|
---|
248 |
|
---|
249 |
|
---|