Ignore:
Timestamp:
10/31/11 14:52:20 (13 years ago)
Author:
tbretz
Message:
Moved some common code between MARS and FACT++ to DrsCalib.h as new class DrsCalibration; renamed CalibData to DrsCalibrate.
File:
1 edited

Legend:

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

    r12310 r12343  
    477477    drawBlur = false;
    478478    loopCurrentEvent = false;
     479    fIsDrsCalibration = false;
    479480    SetAutoRefresh(true);
    480481#ifdef LOAD_RAW
     
    10591060    //calibrationLoaded = false;
    10601061
    1061     MessageImp msg;
    1062     if (!DataCalib::ReadFits(file, msg))
    1063     {
    1064         DataCalib::Restart();
    1065         return;
    1066     }
    1067     /*
    1068 
    1069     calibInputFile = new fits(file);
    1070     if (!*calibInputFile)
    1071     {
    1072         delete calibInputFile;
    1073         calibInputFile = NULL;
    1074         return;
    1075     }
    1076 
    1077 //    if (calibInputFile->HasKey("NROI"))
    1078 //    {
    1079 //        cout << "Looks like you're trying to load a regular raw data file as DRS calib. aborting." << endl;
    1080 //        delete calibInputFile;
    1081 //        calibInputFile = NULL;
    1082 //        return;
    1083 //    }
    1084 
    1085     if (!calibInputFile->SetPtrAddress("BaselineMean", baseLineMean)){
    1086         cout << "Missing column " << "BaseLineMean" << " Aborting load..." << endl;
    1087         return;}
    1088     if (!calibInputFile->SetPtrAddress("GainMean", gainMean)){
    1089         cout << "Missing column " << "GainMean" << " Aborting load..." << endl;
    1090         return;}
    1091     if (!calibInputFile->SetPtrAddress("TriggerOffsetMean", triggerOffsetMean)){
    1092         cout << "Missing column " << "TriggerOffsetMean" << " Aborting load..." << endl;
    1093         return;}
    1094 
    1095     calibInputFile->GetNextRow();
    1096 
    1097  //   for (int i=0;i<1024;i++)
    1098  //       cout << gainMean[i] << " ";
    1099  //   cout << endl << endl;
    1100 
    1101     delete calibInputFile;
    1102 */
    1103     //calibrationLoaded = true;
    1104 
    1105     emit newFileLoaded();
    1106 
    1107     //if (calibratedCheckBox->isChecked())
     1062    string msg;
     1063    try
     1064    {
     1065        msg = fDrsCalib.ReadFitsImp(file);
     1066        if (msg.empty())
     1067        {
     1068            emit newFileLoaded();
     1069            updateGL();
     1070            return;
     1071        }
     1072    }
     1073    catch (const runtime_error &e)
     1074    {
     1075        msg = e.what();
     1076    }
     1077
     1078    cerr << msg << endl;
     1079    fDrsCalib.Clear();
     1080}
     1081
     1082/************************************************************
     1083 * PLUS EVENT
     1084 ************************************************************/
     1085void RawDataViewer::plusEvent()
     1086{
     1087    eventStepping(true);
     1088}
     1089/************************************************************
     1090 * MINUS EVENT
     1091 ************************************************************/
     1092void RawDataViewer::minusEvent()
     1093{
     1094    eventStepping(false);
     1095}
     1096/************************************************************
     1097 * SET EVENT STEP
     1098 ************************************************************/
     1099void RawDataViewer::setEventStep(int step)
     1100{
     1101    eventStep = step;
     1102}
     1103/************************************************************
     1104 * EVENT STEPPING
     1105 ************************************************************/
     1106
     1107void RawDataViewer::ApplyCalibration()
     1108{
     1109    for (int i=0;i<(1440+160)*nRoi;i++)
     1110        eventData[i] = (float)rawEventData[i];
     1111
     1112    if (fIsDrsCalibration)
     1113    {
     1114        fDrsCalib.Apply(eventData, rawEventData, startPix, nRoi);
     1115        DrsCalibrate::RemoveSpikes(eventData, nRoi);
     1116    }
     1117
     1118    vector<float> pixelStatsData(1440*4);
     1119    DrsCalibrate::GetPixelStats(pixelStatsData.data(), eventData, nRoi);
     1120
     1121    for (vector<PixelMapEntry>::const_iterator it=fPixelMap.begin(); it!=fPixelMap.end(); it++)
     1122        RMSvalues[it->index] = pixelStatsData[1*1440+it->hw()];
     1123
     1124    if (isVisible())
    11081125        updateGL();
    11091126}
    1110 /************************************************************
    1111  * PLUS EVENT
    1112  ************************************************************/
    1113 void RawDataViewer::plusEvent()
    1114 {
    1115     eventStepping(true);
    1116 }
    1117 /************************************************************
    1118  * MINUS EVENT
    1119  ************************************************************/
    1120 void RawDataViewer::minusEvent()
    1121 {
    1122     eventStepping(false);
    1123 }
    1124 /************************************************************
    1125  * SET EVENT STEP
    1126  ************************************************************/
    1127 void RawDataViewer::setEventStep(int step)
    1128 {
    1129     eventStep = step;
    1130 }
    1131 /************************************************************
    1132  * EVENT STEPPING
    1133  ************************************************************/
     1127
    11341128void RawDataViewer::eventStepping(bool plus)
    11351129{
     
    11491143    inputFile->GetRow(rowNum);
    11501144//    cout << "Getting row " << rowNum << endl;
    1151     for (int i=0;i<(1440+160)*nRoi;i++)
    1152         eventData[i] = (float)rawEventData[i];
    11531145#endif
    11541146
    1155 //    if (drawCalibrationLoaded && calibrationLoaded)
    1156 //    {
    1157 
    1158 //    if (calibratedCheckBox->isChecked())
    1159         DataCalib::Apply(eventData, rawEventData, startPix, nRoi);
    1160         CalibData::RemoveSpikes(eventData, nRoi);
    1161 
    1162         vector<float> pixelStatsData(1440*4);
    1163         CalibData::GetPixelStats(pixelStatsData.data(), eventData, nRoi);
    1164 
    1165 
    1166         for (vector<PixelMapEntry>::const_iterator it=fPixelMap.begin(); it!=fPixelMap.end(); it++)
    1167         {
    1168             RMSvalues[it->index] = pixelStatsData[1*1440+it->hw()];
    1169         }
    1170 
    1171         /*
    1172 
    1173         for (int i=0;i<1440;i++)
    1174             for (int j=0;j<nRoi;j++)
    1175             {
    1176                 int realj = (j+startPix[i])%1024;
    1177                 eventData[i*1024+j] *= 2000.f/4096.f;
    1178                 eventData[i*1024+j] -= (baseLineMean[i*1024+realj]+triggerOffsetMean[i*1024+j]);
    1179                 eventData[i*1024+j] /= gainMean[i*1024+realj];
    1180                 eventData[i*1024+j] *= (50000.f/65536.f) * 2500.f;
    1181             }
    1182     }
    1183     */
    1184         if (isVisible())
    1185             updateGL();
     1147    ApplyCalibration();
     1148
    11861149    emit signalCurrentEvent(eventNum);
    11871150    emit signalCurrentPixel(selectedPixel);
    11881151}
     1152
    11891153/************************************************************
    11901154 * NEXT SLICE. deprec ?
     
    13751339void UIConnector::on_calibratedCheckBox_stateChanged(int state)
    13761340{
    1377     for (int i=0;i<(1440+160)*GLWindow->nRoi;i++)
    1378         GLWindow->eventData[i] = (float)GLWindow->rawEventData[i];
    1379 
    1380 //    if (GLWindow->calibratedCheckBox->isChecked())
    1381     if (state)
    1382     {
    1383         DataCalib::Apply(GLWindow->eventData, GLWindow->rawEventData, GLWindow->startPix, GLWindow->nRoi);
    1384         CalibData::RemoveSpikes(GLWindow->eventData, GLWindow->nRoi);
    1385     }
    1386 
    1387     GLWindow->updateGL();
    1388 
    1389     //drawCalibrationCheckBox->setChecked(false);
     1341    GLWindow->fIsDrsCalibration = state;
     1342    GLWindow->ApplyCalibration();
    13901343
    13911344    on_autoScaleColor_clicked();
     
    22202173    if (!autoScaleColor->isChecked())
    22212174    {
    2222         /*
    22232175        GLWindow->ss[0] = 0.496;
    22242176        GLWindow->ss[1] = 0.507;
     
    22312183        colorRange3->setValue(GLWindow->ss[3]);
    22322184        colorRange4->setValue(GLWindow->ss[4]);
    2233         */
    22342185        return;
    22352186    }
Note: See TracChangeset for help on using the changeset viewer.