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

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