- Timestamp:
- 10/31/19 09:52:19 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/hawc/plot_callisto.C
r19735 r19841 1 // ========================================================================== 2 // ============ see plot_callisto function at the end of the file =========== 3 // ========================================================================== 1 4 int HandleInput(int evtnum) 2 5 { 6 // This is a pure man's command line interface to wait for a key input 7 // and allow exit but at the same time allow interaction with the GUI 3 8 TTimer timer("gSystem->ProcessEvents();", 50, kFALSE); 4 5 9 while (1) 6 10 { … … 22 26 } 23 27 28 // ========================================================================== 29 // 30 // Run the macro with 31 // 32 // root hawc/plot_callisto.C\(\"00000001.003_Y_MonteCarlo003_Events.root\"\) 33 // 34 // The default file name is a Y-file (either as Monte Carlo-truth from ceres 35 // or from the callisto) 36 // 37 // From within root, the escape characters can be omitted, e.g. 38 // 39 // root 40 // [0] .x hawc/plot_callisto.C("00000001.003_Y_MonteCarlo003_Events.root") 41 // 42 // ========================================================================== 43 24 44 void plot_callisto(const char *fname) 25 45 { 26 TFile f(fname); 46 // Create the file for reading and get the tree 47 TFile file(fname); 48 if (file.IsZombie()) 49 { 50 cout << "Could not open file." << endl; 51 return; 52 } 27 53 28 TTree *T = f.Get("Events"); 54 TTree *T = 0; 55 file.GetObject("Events", T); 56 if (!T) 57 { 58 cout << "Could not access tree." << endl; 59 return; 60 } 29 61 62 // Setup the branch with the calibrated datafor reading 30 63 MSignalCam *signal = NULL; 31 T->SetBranchAddress("MSignalCam.", &signal);64 chain.SetBranchAddress("MSignalCam.", &signal); 32 65 66 // Create the FAMOUS style camera with a 67 // focal distance of 0.5m and 61 pixels 33 68 MGeomCamFAMOUS geom(0.5, kFALSE); 34 69 70 // Instantiate three camera histograms 35 71 MHCamera cam_signal(geom); 36 72 MHCamera cam_cleaned(geom); 37 73 MHCamera cam_time(geom); 38 74 75 // Setup names for the cameras 39 76 cam_signal.SetName("Signal"); 40 77 cam_cleaned.SetName("Cleaned"); 41 78 cam_time.SetName("Time"); 79 80 // Fix minimum for amplitude at 0 ("disable zero suppression") 42 81 cam_signal.SetMinimum(0); 43 82 cam_cleaned.SetMinimum(0); 44 83 84 // Create a canvas and divide it into 4 (2x2) pads 85 // Add all four camera displays in the pads 45 86 TCanvas c; 46 87 c.Divide(2,2); … … 55 96 cam_time.Draw(); 56 97 98 // Loop over the data 57 99 int evtnum = 0; 58 100 while (evtnum>=0) 59 101 { 102 // Infinite loop (start over at the beginning) 60 103 if (evtnum>=T->GetEntries()) 61 104 evtnum = 0; 62 105 63 T->GetEntry(evtnum); 106 // Get event 107 chain.GetEntry(evtnum); 64 108 65 109 // 0: Number of Photons*PixRatio <default> … … 75 119 // 11: as 8, but returns kFALSE if signal <=0 76 120 121 // This is a function which directly copies the entries 122 // from *signal into the camera histograms. The number 123 // is an ID which contents to be copied. This could also 124 // be done in a manula loop over all pixels. 77 125 cam_signal.SetCamContent(*signal, 10); // num phot uncleaned 78 126 cam_cleaned.SetCamContent(*signal, 3); // num phot cleaned 79 127 cam_time.SetCamContent(*signal, 8); // arr time cleaned 80 128 129 // Signal root that the objects displayed in all four pads 130 // were changed and the pads have to be updated 81 131 for (int i=0; i<4; i++) 82 132 { … … 85 135 } 86 136 137 // Wait for user intput 87 138 evtnum = HandleInput(evtnum); 88 139 }
Note:
See TracChangeset
for help on using the changeset viewer.