source: trunk/MagicSoft/Mars/mtemp/findTelAxisFromStars.C@ 4545

Last change on this file since 4545 was 4545, checked in by wittek, 20 years ago
*** empty log message ***
File size: 6.9 KB
Line 
1void ReadSetup(TString fname, MAstroCamera &cam)
2{
3 MMcConfigRunHeader *config=0;
4 MGeomCam *geom=0;
5
6 TFile file(fname);
7 TTree *tree = (TTree*)file.Get("RunHeaders");
8 tree->SetBranchAddress("MMcConfigRunHeader", &config);
9 if (tree->GetBranch("MGeomCam"))
10 tree->SetBranchAddress("MGeomCam", &geom);
11 tree->GetEntry(0);
12
13 cam.SetMirrors(*config->GetMirrors());
14 cam.SetGeom(*geom);
15}
16
17void findTelAxisFromStars(const TString filename="20040422_23213_D_Mrk421_E.root", const TString directory="/.magic/magicserv01/MAGIC/rootdata/2004_04_22/", const UInt_t numEvents = 0)
18{
19 gLog.SetNoColors();
20
21 MParList plist;
22 MTaskList tlist;
23 plist.AddToList(&tlist);
24
25 MGeomCamMagic geomcam;
26 MCameraDC dccam;
27 MStarLocalCam starcam;
28
29 //$$$$$$$$$$$$$$$$ ww
30 MHTelAxisFromStars htelaxis;
31 plist.AddToList(&htelaxis);
32 //$$$$$$$$$$$$$$$$ ww
33
34
35 plist.AddToList(&geomcam);
36 plist.AddToList(&dccam);
37 plist.AddToList(&starcam);
38
39 // Reads the trees of the root file and the analysed branches
40 MReadReports read;
41 read.AddTree("Currents");
42 read.AddTree("Drive"); // If you do not include Drive info, the MFindStars class
43 // will not use the star catalog method
44 read.AddFile(directory+filename); // after the reading of the trees!!!
45 read.AddToBranchList("MReportCurrents.*");
46 read.AddToBranchList("MReportDrive.*");
47
48 MGeomApply geomapl;
49 // TString continuoslightfile =
50 // "/data/MAGIC/Period016/rootdata/2004_04_16/20040416_22368_P_Off3c279-2CL100_E.root";
51
52 TString continuoslightfile =
53"/.magic/magicserv01/MAGIC/rootdata/2004_04_16/20040416_22368_P_Off3c279-2CL100_E.root";
54
55
56 Float_t mindc = 0.9; //[uA]
57
58 MCalibrateDC dccal;
59 dccal.SetFileName(continuoslightfile);
60 dccal.SetMinDCAllowed(mindc);
61
62 const Int_t numblind = 5;
63 const Short_t x[numblind] = { 47, 124, 470, 475, 571};
64 const TArrayS blindpixels(numblind,(Short_t*)x);
65 Float_t ringinterest = 100; //[mm]
66 Float_t tailcut = 2.5;
67 UInt_t integratedevents = 1;
68
69 // We need the MAGIC mirror geometry from a MC header:
70 //TString geometryfile = "/mcdata/standard/camera/NSB_013/Gamma/Gamma_zbin9_90_7_1480to1489_w0.root";
71 TString geometryfile =
72"/.magic/magicserv01/MAGIC/mcdata/standard/camera/NSB_013/Gamma/Gamma_zbin9_90_7_1480to1489_w0.root";
73
74
75
76
77 // We need the Bright Star Catalog:
78 //TString catalogfile = "/home/rwagner/bsc5.dat";
79 TString catalogfile = "mtemp/mmpi/macros/bsc5.dat";
80
81 //$$$$$$$$$$$$$$$$ ww
82 MSourceDirections sdirs;
83 sdirs.SetGeometryFile(geometryfile);
84 const Double_t ra = MAstro::Hms2Rad(11, 4, 26);
85 const Double_t dec = MAstro::Dms2Rad(38, 12, 36);
86 sdirs.SetRaDec(ra,dec);
87 sdirs.AddDirection(ra,dec,1,"Mkn 421");
88 const Double_t ra = MAstro::Hms2Rad(11, 4, 31);
89 const Double_t dec = MAstro::Dms2Rad(38, 14, 29);
90 sdirs.AddDirection(ra,dec,1,"My_UMa 51");
91 sdirs.SetRadiusFOV(3);
92 //$$$$$$$$$$$$$$$$ ww
93
94 MFindStars findstars;
95 findstars.SetBlindPixels(blindpixels);
96 findstars.SetRingInterest(ringinterest);
97 findstars.SetDCTailCut(tailcut);
98 findstars.SetNumIntegratedEvents(integratedevents);
99 findstars.SetMinuitPrintOutLevel(-1);
100 findstars.SetGeometryFile(geometryfile);
101 findstars.SetBSCFile(catalogfile);
102 const Double_t ra = MAstro::Hms2Rad(11, 4, 26);
103 const Double_t dec = MAstro::Dms2Rad(38, 12, 36);
104 findstars.SetRaDec(ra,dec);
105 findstars.SetLimMag(8);
106 findstars.SetRadiusFOV(1.5);
107
108
109
110 //$$$$$$$$$$$$$$$$ ww
111 //Int_t InputType = 0;
112 //findstars.SetUseCorrelatedGauss(kFALSE);
113
114 MTelAxisFromStars telaxis;
115 //telaxis.FixRotationAngleAt(-1.0);
116 //telaxis.FixScaleFactorAt(-1.0);
117 //telaxis.SetInputType(InputType);
118
119 MFillH fillhisto("MHTelAxisFromStars[MHTelAxisFromStars]","");
120 //htelaxis.SetInputType(InputType);
121 //$$$$$$$$$$$$$$$$ ww
122
123
124 tlist.AddToList(&geomapl);
125 tlist.AddToList(&read);
126 tlist.AddToList(&dccal);
127 tlist.AddToList(&findstars, "Currents");
128
129 //$$$$$$$$$$$$$$$$ ww
130 tlist.AddToList(&sdirs);
131 tlist.AddToList(&telaxis);
132 tlist.AddToList(&fillhisto);
133 //$$$$$$$$$$$$$$$$ ww
134
135
136
137 // The following lines you only need if in addition you want to display
138 // independent MAstroCamera output
139 //
140 // TString fname = "/mcdata/standard/camera/NSB_013/Gamma/Gamma_zbin9_90_7_1480to1489_w0.root";
141 // MObservatory magic1;
142 // const Double_t ra = MAstro::Hms2Rad(11, 4, 26); //Mkn421
143 // const Double_t dec = MAstro::Dms2Rad(38, 12, 36);
144 //
145 // MAstroCamera stars;
146 // ReadSetup(fname, stars);
147 // stars.SetLimMag(9);
148 // stars.SetRadiusFOV(3);
149 // stars.SetRaDec(ra, dec);
150 // stars.ReadBSC("/home/rwagner/bsc5.dat");
151 // stars.SetObservatory(magic1);
152
153 MEvtLoop evtloop;
154 evtloop.SetParList(&plist);
155
156 if (!evtloop.PreProcess())
157 return;
158
159 MHCamera display(geomcam);
160 display.SetPrettyPalette();
161 display.Draw();
162 gPad->cd(1);
163 starcam.Draw();
164
165 UInt_t numevents=0;
166
167 while (tlist.Process())
168 {
169 starcam.Print("namepossizchierr");
170
171 numevents++;
172 if (numevents%integratedevents==0)
173 {
174 display.SetCamContent(findstars.GetDisplay());
175 gPad->Modified();
176 gPad->Update();
177 // This line prints the results:
178 // starcam.Print();
179 // This is how to access the TList of stars:
180 // TList* starlist = starcam.GetList();
181
182 // This is how to iterate over stars found:
183 // TIter Next(starlist);
184 // MStarLocalPos* star;
185 // UInt_t starnum = 0;
186 // cout << filename << " ";
187 // cout << "Iterating over list" << endl;
188 // while ((star=(MStarLocalPos*)Next()))
189 // {
190 // cout << "star[" << starnum << "] ";
191 // cout << star->GetMeanX() << " "
192 // << star->GetMeanY() << " ";
193 // starnum++;
194 // }
195 // cout << endl;
196
197 }//integratedevents
198
199 MTime time;
200 time.Set(2004, 4, 22, 21, 51, 15);
201
202 //superimpose star picture
203 // stars.SetTime(time);
204 // TObject *o = stars.Clone();
205 // o->SetBit(kCanDelete);
206 // o->Draw();
207
208 // wait after each event
209 if (!HandleInput())
210 break;
211
212 }
213
214
215
216 evtloop.PostProcess();
217 tlist.PrintStatistics();
218
219 //$$$$$$$$$$$$$$$$ ww
220 /*
221 gLog << "Event loop finished; call DrawClone of MHTelAxisFromStars" << endl;
222 TObject *obj = plist.FindObject("MHTelAxisFromStars");
223 if (obj)
224 {
225 obj->Print();
226 obj->Dump();
227 obj->DrawClone();
228
229 gLog << "Draw a clone of the histogram" << endl;
230 TObject *o = obj->Clone();
231 o->SetBit(kCanDelete);
232 o->Draw();
233 }
234 else
235 gLog << "address of MHTelAxisFromStars container is zero" << endl;
236 */
237 //$$$$$$$$$$$$$$$$ ww
238
239
240
241}
242
243
244Bool_t HandleInput()
245{
246 TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
247
248 while (1)
249 {
250 //
251 // While reading the input process gui events asynchronously
252 //
253 timer.TurnOn();
254 TString input = Getline("Type 'q' to exit, <return> to go on: ");
255 timer.TurnOff();
256
257 if (input=="q\n")
258 return kFALSE;
259
260 if (input=="\n")
261 return kTRUE;
262 };
263
264 return kFALSE;
265}
Note: See TracBrowser for help on using the repository browser.