Changeset 12365


Ignore:
Timestamp:
11/02/11 15:58:34 (13 years ago)
Author:
kraehenb
Message:
More comments in calscope_batch, and exclude spikes in the peakfinderscope.
Location:
fact/tools/rootmacros
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • fact/tools/rootmacros/FOscilloscope.c

    r12166 r12365  
    11#include <cstdio>
     2#include "FCalibrateEvent.c"
    23int FOscilloscope(fits &datafile, vector<int16_t> &data, vector<int16_t> &data_offset, unsigned int &data_num, UInt_t data_px, vector<float> &drs_basemean, vector<float> &drs_gainmean, vector<float> &drs_triggeroffsetmean, UInt_t data_roi, float threshold, TH2* pulseshape, TH1* spectrum)
    34//Data, calibration, data_roi, data_num, data_px, threshold, two histograms
     
    910        UInt_t integration_delay = 5;
    1011       
    11         float sample, last_sample, integral;
     12        vector<float> calevent(data_px*data_roi); //Vector for the calibrated event
     13       
     14        float integral;
    1215        UInt_t drs_calib_offset;
    1316
     
    1821                cout << "Event number: " << data_num << endl;
    1922               
     23                FCalibrateEvent(data, data_offset, drs_basemean, drs_gainmean, drs_triggeroffsetmean, calevent, data_px, data_roi);
     24               
    2025                //Iterate over the pixels
    2126                for (int j=0; j<data_px; j++)
     
    2429               
    2530                        //Iterate over the slices
    26                         drs_calib_offset = (start_sample-1+data_offset[j])%data_roi;
    27                         last_sample = (data[j*data_roi+start_sample-1]*2000/4096.-drs_basemean[j*data_roi+drs_calib_offset]-drs_triggeroffsetmean[j*data_roi+start_sample-1])/drs_gainmean[j*data_roi+drs_calib_offset]*1907.35;
    2831                        for (UInt_t k=start_sample; k<end_sample; k++)
    2932                        {
    30                                 drs_calib_offset = (k+data_offset[j])%data_roi;
    31                                 sample = (data[j*data_roi+k]*2000/4096.-drs_basemean[j*data_roi+drs_calib_offset]-drs_triggeroffsetmean[j*data_roi+k])/drs_gainmean[j*data_roi+drs_calib_offset]*1907.35;
    32                                 if((last_sample<threshold)&&(sample>threshold))
     33                                if((calevent[j*data_roi+k-1]<threshold)&&(calevent[j*data_roi+k]>threshold)&&(calevent[j*data_roi+k+2]>threshold))
    3334                                {
    3435                                        integral = 0;
    3536                                        for(UInt_t l=integration_delay; l<integration_delay+integration_size; l++)
    3637                                        {
    37                                                 drs_calib_offset = (k+l+data_offset[j])%data_roi;
    38                                                 integral+=(data[j*data_roi+k+l]*2000/4096.-drs_basemean[j*data_roi+drs_calib_offset]-drs_triggeroffsetmean[j*data_roi+k+l])/drs_gainmean[j*data_roi+drs_calib_offset]*1907.35;
     38                                                integral+=calevent[j*data_roi+k+l];
    3939                                        }
    4040//                                      if((integral>60)&&(integral<=300)) {
     
    4242                                                for(Int_t l=-10; l<60; l++)
    4343                                                {
    44                                                         drs_calib_offset = (k+l+data_offset[j])%data_roi;
    45                                                         sample = (data[j*data_roi+k+l]*2000/4096.-drs_basemean[j*data_roi+drs_calib_offset]-drs_triggeroffsetmean[j*data_roi+k+l])/drs_gainmean[j*data_roi+drs_calib_offset]*1907.35;
    46                                                         pulseshape->Fill(l,sample);
     44                                                        pulseshape->Fill(l,calevent[j*data_roi+k+l]);
    4745                                                }
    4846//                                      }
     
    5250                                //TBD: mistake that after the deadtime the last_sample must be set new...
    5351                                //Solution: first process full pipeline
    54                                 last_sample = sample;
    5552                        }
    5653                }
  • fact/tools/rootmacros/calscope_batch.C

    r12363 r12365  
    7575        TProfile *pix = new TProfile("pix", title, 1024, -0.5, 1023.5);
    7676       
    77 //****
     77//-------------------------------------------
     78//Start the loop
     79//-------------------------------------------
    7880        char temp;
    7981        std::cout << "Plot the spectra out of limits: Enter for next, 'a' to abort." << std::endl;
     
    8385                cout << "Event number: " << data_num << endl;
    8486
     87//-------------------------------------------
     88//Calibrate the event
     89//-------------------------------------------
    8590                FCalibrateEvent(data, data_offset, drs_basemean, drs_gainmean, drs_triggeroffsetmean, calevent, data_px, data_roi);
    8691               
     92//-------------------------------------------
     93//Draw the data
     94//-------------------------------------------
    8795                pix->Reset();
    8896                std::sprintf(title,"Data: %s, DRS: %s, Px %i Ev %i",name,drsname,pixelnr,eventnr);
     
    102110                if(temp=='a') break;
    103111        }
    104 
    105 //****
    106 
    107 //-------------------------------------------
    108 //Get the calibrated event
    109 //-------------------------------------------
    110        
    111        
    112 //-------------------------------------------
    113 //Draw the data
    114 //-------------------------------------------
    115112       
    116113        return 0;
  • fact/tools/rootmacros/peakfinderscope.C

    r12303 r12365  
    1818#define n_peaks 4
    1919
    20 int peakfinderscope(const char *name, const char *drsname, size_t eventnr, size_t pixelnr)
     20int peakfinderscope(const char *name, const char *drsname, size_t pixelnr)
    2121{
    2222//******************************************************************************
     
    6060//-------------------------------------------
    6161        char title[500];
    62         std::sprintf(title,"Data: %s, DRS: %s, Px %i Ev %i",name,drsname,pixelnr,eventnr);
     62        std::sprintf(title,"Data: %s, DRS: %s, Px %i",name,drsname,pixelnr);
    6363        TCanvas *canv = new TCanvas( "canv", "Waveform", 200, 10, 700, 500 );
    6464//      TProfile *pulseshape = new TProfile("pulseshape", title, 70, -10.5, 59.5);
     
    7373        std::sprintf(title_spect,"Spectrum of all pixels (data: %s, DRS: %s)",name,drsname);
    7474        TCanvas *canv_spect = new TCanvas( "canv_spect", "Spectrum", 950, 10, 700, 500 );
    75         TH1F *spectrum = new TH1F("spectrum", title_spect,300,0,600);
     75        TH1F *spectrum = new TH1F("spectrum", title_spect,700,-200,1200);
    7676        spectrum->GetXaxis()->SetTitle("Pulse size (a.u.)");
    7777        spectrum->GetYaxis()->SetTitle("Counts");
     
    139139        canv_spect->Update();
    140140//***********************
    141         fits datafile2("20110804_025.fits");
    142         if (!datafile2)
    143         {
    144         cout << "Couldn't properly open the datafile2." << endl;
    145         return 1;
    146         }
    147         FOpenDataFile(datafile2, data, data_offset, data_num, data_n, data_roi, data_px);
    148         FOscilloscope(datafile2, data, data_offset, data_num, data_px, drs_basemean, drs_gainmean, drs_triggeroffsetmean, data_roi, threshold, pulseshape, spectrum);
    149        
    150         canv->cd();
    151         pulseshape->Draw();
    152         canv->Modified();
    153         canv->Update();
    154        
    155         canv_spect->cd();
    156         spectrum->Draw();
    157         canv_spect->Modified();
    158         canv_spect->Update();
    159 //***********************
    160         fits datafile3("20110804_026.fits");
    161         if (!datafile3)
    162         {
    163         cout << "Couldn't properly open the datafile3." << endl;
    164         return 1;
    165         }
    166         FOpenDataFile(datafile3, data, data_offset, data_num, data_n, data_roi, data_px);
    167         FOscilloscope(datafile3, data, data_offset, data_num, data_px, drs_basemean, drs_gainmean, drs_triggeroffsetmean, data_roi, threshold, pulseshape, spectrum);
    168        
    169         canv->cd();
    170         pulseshape->Draw();
    171         canv->Modified();
    172         canv->Update();
    173        
    174         canv_spect->cd();
    175         spectrum->Draw();
    176         canv_spect->Modified();
    177         canv_spect->Update();
    178 //***********************
    179         fits datafile4("20110804_027.fits");
    180         if (!datafile4)
    181         {
    182         cout << "Couldn't properly open the datafile4." << endl;
    183         return 1;
    184         }
    185         FOpenDataFile(datafile4, data, data_offset, data_num, data_n, data_roi, data_px);
    186         FOscilloscope(datafile4, data, data_offset, data_num, data_px, drs_basemean, drs_gainmean, drs_triggeroffsetmean, data_roi, threshold, pulseshape, spectrum);
    187        
    188         canv->cd();
    189         pulseshape->Draw();
    190         canv->Modified();
    191         canv->Update();
    192        
    193         canv_spect->cd();
    194         spectrum->Draw();
    195         canv_spect->Modified();
    196         canv_spect->Update();
    197 //***********************
    198141        spectrum->Fit(f_peaks,"R+");
    199142        f_peaks->GetParameters(&par[0]);
Note: See TracChangeset for help on using the changeset viewer.