source: trunk/Mars/hawc/plot_callisto.C@ 19745

Last change on this file since 19745 was 19735, checked in by tbretz, 5 years ago
Fixed a race condition problem and made the loop turn around.
File size: 2.0 KB
Line 
1int HandleInput(int evtnum)
2{
3 TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
4
5 while (1)
6 {
7 timer.TurnOn();
8 const char *gl = Getline("Type 'q' to exit, or event number and <return> to go on: ");
9 timer.TurnOff();
10
11 TString input = gl;
12 if (input=="q\n")
13 return -1;
14
15 if (input=="\n")
16 return evtnum+1;
17
18 return atoi(input.Data());
19 };
20
21 return -1;
22}
23
24void plot_callisto(const char *fname)
25{
26 TFile f(fname);
27
28 TTree *T = f.Get("Events");
29
30 MSignalCam *signal = NULL;
31 T->SetBranchAddress("MSignalCam.", &signal);
32
33 MGeomCamFAMOUS geom(0.5, kFALSE);
34
35 MHCamera cam_signal(geom);
36 MHCamera cam_cleaned(geom);
37 MHCamera cam_time(geom);
38
39 cam_signal.SetName("Signal");
40 cam_cleaned.SetName("Cleaned");
41 cam_time.SetName("Time");
42 cam_signal.SetMinimum(0);
43 cam_cleaned.SetMinimum(0);
44
45 TCanvas c;
46 c.Divide(2,2);
47
48 c.cd(1);
49 cam_signal.Draw();
50
51 c.cd(2);
52 cam_cleaned.Draw();
53
54 c.cd(3);
55 cam_time.Draw();
56
57 int evtnum = 0;
58 while (evtnum>=0)
59 {
60 if (evtnum>=T->GetEntries())
61 evtnum = 0;
62
63 T->GetEntry(evtnum);
64
65 // 0: Number of Photons*PixRatio <default>
66 // 1: Error*sqrt(PixRatio)
67 // 2: Cleaning level = Num Photons*sqrt(PixRatio)/Error
68 // 3: Number of Photons
69 // 4: Error
70 // 5: Island index
71 // 6: arrival time of mapped pixels
72 // 7: arrival time if signa avove 20phe
73 // 8: arrival time
74 // 10: as 0, but returns kFALSE if signal <=0
75 // 11: as 8, but returns kFALSE if signal <=0
76
77 cam_signal.SetCamContent(*signal, 10); // num phot uncleaned
78 cam_cleaned.SetCamContent(*signal, 3); // num phot cleaned
79 cam_time.SetCamContent(*signal, 8); // arr time cleaned
80
81 for (int i=0; i<4; i++)
82 {
83 c.GetPad(i+1)->Modified();
84 c.GetPad(i+1)->Update();
85 }
86
87 evtnum = HandleInput(evtnum);
88 }
89}
Note: See TracBrowser for help on using the repository browser.