Changeset 19841 for trunk


Ignore:
Timestamp:
10/31/19 09:52:19 (5 years ago)
Author:
tbretz
Message:
Added a lot of comments.
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// ==========================================================================
    14int HandleInput(int evtnum)
    25{
     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
    38    TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
    4 
    59    while (1)
    610    {
     
    2226}
    2327
     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
    2444void plot_callisto(const char *fname)
    2545{
    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    }
    2753
    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    }
    2961
     62    // Setup the branch with the calibrated datafor reading
    3063    MSignalCam *signal = NULL;
    31     T->SetBranchAddress("MSignalCam.", &signal);
     64    chain.SetBranchAddress("MSignalCam.", &signal);
    3265
     66    // Create the FAMOUS style camera with a
     67    // focal distance of 0.5m and 61 pixels
    3368    MGeomCamFAMOUS geom(0.5, kFALSE);
    3469
     70    // Instantiate three camera histograms
    3571    MHCamera cam_signal(geom);
    3672    MHCamera cam_cleaned(geom);
    3773    MHCamera cam_time(geom);
    3874
     75    // Setup names for the cameras
    3976    cam_signal.SetName("Signal");
    4077    cam_cleaned.SetName("Cleaned");
    4178    cam_time.SetName("Time");
     79
     80    // Fix minimum for amplitude at 0 ("disable zero suppression")
    4281    cam_signal.SetMinimum(0);
    4382    cam_cleaned.SetMinimum(0);
    4483
     84    // Create a canvas and divide it into 4 (2x2) pads
     85    // Add all four camera displays in the pads
    4586    TCanvas c;
    4687    c.Divide(2,2);
     
    5596    cam_time.Draw();
    5697
     98    // Loop over the data
    5799    int evtnum = 0;
    58100    while (evtnum>=0)
    59101    {
     102        // Infinite loop (start over at the beginning)
    60103        if (evtnum>=T->GetEntries())
    61104            evtnum = 0;
    62105
    63         T->GetEntry(evtnum);
     106        // Get event
     107        chain.GetEntry(evtnum);
    64108
    65109        //  0: Number of Photons*PixRatio <default>
     
    75119        // 11: as 8, but returns kFALSE if signal <=0
    76120
     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.
    77125        cam_signal.SetCamContent(*signal, 10); // num phot uncleaned
    78126        cam_cleaned.SetCamContent(*signal, 3); // num phot cleaned
    79127        cam_time.SetCamContent(*signal, 8); // arr time cleaned
    80128
     129        // Signal root that the objects displayed in all four pads
     130        // were changed and the pads have to be updated
    81131        for (int i=0; i<4; i++)
    82132        {
     
    85135        }
    86136
     137        // Wait for user intput
    87138        evtnum = HandleInput(evtnum);
    88139    }
Note: See TracChangeset for help on using the changeset viewer.