Ignore:
Timestamp:
04/29/20 21:48:05 (5 years ago)
Author:
giangdo
Message:
script to synchronise the data from HAWC's Eye and HAWC

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/hawc/plot_trace.C

    r19846 r19951  
     1#include <TStyle.h>
     2#include <TCanvas.h>
     3#include <TSystem.h>
     4#include <TF1.h>
     5#include <TProfile.h>
     6#include <TProfile2D.h>
     7#include <TMath.h>
     8#include <TGraph.h>
     9#include <TLine.h>
     10#include <TFitResultPtr.h>
     11#include <TFitResult.h>
     12#include <TFile.h>
     13#include <TLine.h>
     14
     15#include <cstdio>
     16#include <stdio.h>
     17#include <stdint.h>
     18
     19#include "Getline.h"
     20#include "MH.h"
     21#include "MArrayI.h"
     22#include "MDirIter.h"
     23#include "MFillH.h"
     24#include "MEvtLoop.h"
     25#include "MCamEvent.h"
     26#include "MGeomApply.h"
     27#include "MTaskList.h"
     28#include "MParList.h"
     29#include "MContinue.h"
     30#include "MBinning.h"
     31#include "MDrsCalibApply.h"
     32#include "MDrsCalibration.h"
     33#include "MRawFitsRead.h"
     34#include "MStatusDisplay.h"
     35#include "MTaskInteractive.h"
     36#include "MPedestalSubtractedEvt.h"
     37#include "MGeomCamFAMOUS.h"
     38#include "MRawRunHeader.h"
     39#include "MPedestalCam.h"
     40#include "MPedestalPix.h"
     41#include "MParameters.h"
     42
    143// ==========================================================================
    244// ============ see plot_callisto function at the end of the file ===========
     
    2163
    2264// Create a histogram for the trace
    23 TH1D hist("Trace", "Waveform", 1024, -0.25, 511.75);
     65//TH1D hist("Trace", "Waveform", 1024, -0.25, 511.75); //range = [-0.25,511.75]ns
     66TH1D hist("Trace", "Waveform (Pixel 5, Event 1)", 1024, -0.5, 1024-0.5);
    2467
    2568// All 'data members' that are required globally
     
    3477{
    3578    fEvt = (MPedestalSubtractedEvt*)plist->FindObject("MPedestalSubtractedEvt");
    36     if (!fEvt)
    37     {
    38         gfLog << err << "MPedestalSubtractedEvt not found... aborting." << endl;
    39         return kALSE;
    40     }
     79
     80    //if (!fEvt)
     81    //{
     82    //    gfLog << err << "MPedestalSubtractedEvt not found... aborting." << endl;
     83    //    return kFALSE;
     84    //}
    4185
    4286    // Create a canvas and plot the histogram into it
    43     c = new TCanvas;
     87    c = new TCanvas();
    4488    hist.SetStats(kFALSE);
    4589    hist.Draw();
    46 
    47     TF1 constant("zero", "[0]", -0.25, 511.75);
     90    hist.SetXTitle("Samples");
     91    hist.SetYTitle("Amplitude [a.u.]");
     92
     93    //TF1 constant("zero", "[0]", -0.25, 511.75);
     94    TF1 constant("zero", "[0]", -0.5, 1024);
    4895    constant.SetParameter(0, 0);
    4996    constant.SetLineColor(kBlack);
     
    59106    constant.DrawCopy("same");
    60107
     108
    61109    return kTRUE;
    62110}
     
    64112Int_t Process()
    65113{
    66     int pixel_index = 0;
     114    int pixel_index = 6; //plot trace only of this pixel
     115    int skipstart = 5;
     116    int skipend = 10;
    67117
    68118    // Number of samples per pixel (usually 1024)
     
    73123    hist.Reset();
    74124    for (int i=0; i<numsamples; i++)
    75         hist.Fill(i*0.5, cal[i]); // Convert sample to nano-second
     125        hist.Fill(i, cal[i]); // 0.5ns = 1 sample
    76126
    77127    // Reset min/max range
    78     hist.SetMinimum();
    79     hist.SetMaximum();
    80 
    81     // Set a reasonable range
    82     if (hist.GetMinimum()>-50)
    83         hist.SetMinimum(-50);
    84     if (hist.GetMaximum()<250)
    85         hist.SetMaximum(250);
     128    hist.SetMinimum(-50);
     129    hist.SetMaximum(50);
     130
     131    //// Set a reasonable range
     132    //if (hist.GetMinimum()>-30)
     133    //    hist.SetMinimum(-20);
     134    //if (hist.GetMaximum()<60)
     135    //    hist.SetMaximum(50);
     136
     137
     138
     139    TLine *line = new TLine(skipstart, 50, skipstart, -50);
     140    line->SetLineStyle(kSolid);
     141    line->SetLineColor(kRed);
     142    line->Draw();
     143
     144    TLine *line2 = new TLine(1024-skipend, 50, 1024-skipend, -50);
     145    line2->SetLineStyle(kSolid);
     146    line2->SetLineColor(kRed);
     147    line2->Draw();
    86148
    87149    // Signal root to update the canvas/pad
    88150    c->Modified();
    89151    c->Update();
     152    //c->SaveAs("/home/giangdo/Documents/Master/MA/pulse/data_single_pe/traces/pixel3/event_0.png");
     153
    90154
    91155    bool rc = HandleInput();
     
    131195
    132196    // mapping file (found in Mars/hawc)
    133     const char *mmap = usemap ? "../hawc/FAMOUSmap171218.txt" : NULL;
     197    const char *mmap = usemap ? "/home/giangdo/Documents/Master/MA/Software/Mars/hawc/HAWCsEyemap181214.txt" : NULL;
    134198
    135199    // ======================================================
     
    193257    MEvtLoop loop(gSystem->BaseName(datafile));
    194258    loop.SetParList(&plist);
    195  
    196     if (!loop.Eventloop())
     259
     260    if (!loop.Eventloop(100))
    197261        return 4;
    198262
Note: See TracChangeset for help on using the changeset viewer.