Changeset 19373 for trunk/FACT++


Ignore:
Timestamp:
11/11/18 13:31:26 (6 years ago)
Author:
tbretz
Message:
On the way to make it more maintanance friendly. Fixed a bug (some roi were roiTM)
Location:
trunk/FACT++/gui/RawEventsViewer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.cc

    r19368 r19373  
    370370    selectedPixel = 393;
    371371    inputFile = NULL;
    372     eventData = NULL;
    373372    drawPatch = false;
    374373    drawImpulse = true;
     
    430429        inputFile->close();
    431430        delete inputFile;
    432     }
    433     if (eventData != NULL) {
    434         delete[] eventData;
    435         delete[] rawEventData;
    436         delete[] waveLetArray;
    437431    }
    438432    if (fZeroArray != NULL)
     
    687681    eventNum = 1;
    688682
    689     if (eventData != NULL) {
    690         delete[] eventData;
    691         delete[] rawEventData;
    692         delete[] waveLetArray;
    693     }
    694     eventData = new float[1440*nRoi + 160*nRoiTM];//(1440+160)*nRoi];
    695 
    696     rawEventData = new int16_t[1440*nRoi + 160*nRoiTM];//(1440+160)*nRoi];
    697     waveLetArray = new int16_t[1024*1440];
     683    eventData.resize(1440*nRoi + 160*nRoiTM);
     684    rawEventData.resize(1440*nRoi + 160*nRoiTM);
     685    waveLetArray.resize(1024*1440);
    698686    try
    699687    {
    700         inputFile->SetPtrAddress("Data", rawEventData);
     688        inputFile->SetPtrAddress("Data", rawEventData.data());
    701689        if (inputFile->HasColumn("EventNum"))
    702690            inputFile->SetPtrAddress("EventNum", &eventNum);
     
    724712            cout << "Warning: could not find column \"StartCellTimeMarker\"" << endl;
    725713        if (inputFile->HasColumn("TimeMarker"))
    726             inputFile->SetPtrAddress("TimeMarker", &rawEventData[1440*nRoi]);
     714            inputFile->SetPtrAddress("TimeMarker", rawEventData.data()+1440*nRoi);
    727715        else
    728716            cout << "Warning: could not find column \"TimeMarker\"" << endl;
     
    804792                                                 const int roiTM)
    805793{
    806 
    807     eventData = new float[1440*roi + 160*roiTM];//(1440+160)*nRoi];
     794    eventData.assign(inputData.begin(), inputData.end());
    808795    nRoi=roi;
    809796    nRoiTM=roiTM;
     
    813800    mean=0;
    814801    for (int i=0;i<1440*roi + 160*roiTM;i++) {
    815         eventData[i] = (float)inputData[i];
    816802        mean += inputData[i];
    817803        if (inputData[i] > max)
     
    854840void RawDataViewer::ApplyCalibration()
    855841{
    856     for (int i=0;i<1440*nRoi + 160*nRoiTM;i++)//(1440+160)*nRoi;i++)
    857         eventData[i] = (float)rawEventData[i];
     842    eventData.assign(rawEventData.begin(), rawEventData.end());
    858843
    859844    if (fIsDrsCalibration)
    860845    {
    861         fDrsCalib.Apply(eventData, rawEventData, startPix, nRoi);
    862         DrsCalibrate::RemoveSpikes(eventData, nRoi);
     846        fDrsCalib.Apply(eventData.data(), rawEventData.data(), startPix, nRoi);
     847        DrsCalibrate::RemoveSpikes(eventData.data(), nRoi);
    863848        //TODO apply calibration to the Time markers
    864849    }
     
    891876
    892877    vector<float> pixelStatsData(1440*4);
    893     DrsCalibrate::GetPixelStats(pixelStatsData.data(), eventData, nRoi);
     878    DrsCalibrate::GetPixelStats(pixelStatsData.data(), eventData.data(), nRoi);
    894879
    895880    for (vector<PixelMapEntry>::const_iterator it=fPixelMap.begin(); it!=fPixelMap.end(); it++)
     
    951936            cout << "Warning: did not expect Time Markers data from Monte-Carlo simulations. These will not be mapped properly." << endl;
    952937        //first copy the data
    953         int16_t* tempData = new int16_t[1440*nRoi];
    954         for (int i=0;i<1440*nRoi;i++)
    955             tempData[i] = rawEventData[i];
     938        vector<int16_t> tempData(rawEventData.begin(), rawEventData.begin()+1440*nRoi);
    956939        //copy back the data and re-map it on the fly
    957940        for (int i=0;i<1440;i++)
    958941            for (int j=0;j<nRoi;j++)
    959942                rawEventData[i*nRoi + j] = tempData[softwareMapping[i]*nRoi + j];
    960 
    961         delete[] tempData;
    962943    }
    963944//    cout << "Getting row " << rowNum << endl;
     
    11781159    GLWindow->ApplyCalibration();
    11791160
    1180     threeD_Window->setData(GLWindow->eventData);
     1161    threeD_Window->setData(GLWindow->eventData.data());
    11811162
    11821163    on_autoScaleColor_clicked();
     
    14901471    PosOfMax_window->SetData(GLWindow->PosOfMaxvalues);
    14911472    Max_window->SetData(GLWindow->Maxvalues);
    1492     threeD_Window->setData(GLWindow->eventData);//rawEventData);
     1473    threeD_Window->setData(GLWindow->eventData.data());//rawEventData);
    14931474
    14941475    if (RMS_window->isVisible())
     
    15901571        str.str("");
    15911572        str << i << " | ";
    1592         for (int j=0;j<GLWindow->nRoi;j++)
    1593         {
    1594             int value = GLWindow->eventData[1440*GLWindow->nRoi + i*GLWindow->nRoi + j];
     1573        for (int j=0;j<GLWindow->nRoiTM;j++)
     1574        {
     1575            int value = GLWindow->eventData[1440*GLWindow->nRoi + i*GLWindow->nRoiTM + j];
    15951576            if (delayMap.find(value) != delayMap.end())
    15961577                 delayMap[value]++;
     
    20452026    }
    20462027
    2047 
    20482028int realNumSamples = GLWindow->nRoi;
    20492029    if (GLWindow->nRoiTM != 0)
  • trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.h

    r19368 r19373  
    9191//    void drawHexagon(int index, bool solid);
    9292    int selectedPixel;
    93     float *eventData;
    94     float *rmsData;
    95     int16_t* rawEventData;
    96     int16_t* waveLetArray;
     93    vector<float> eventData;
     94    //vector<float> rmsData;
     95    vector<int16_t> rawEventData;
     96    vector<int16_t> waveLetArray;
    9797    valarray<double> RMSvalues;//(1440);
    9898    valarray<double> Meanvalues;
Note: See TracChangeset for help on using the changeset viewer.